Note that there are some explanatory texts on larger screens.

plurals
  1. POTroubleshooting "Error: Unable to serialize database:" when performing dumpdata
    primarykey
    data
    text
    <p>For some reason today I cannot dump my database using <code>python manage.py dumpdata</code> or from a link that can download the mysql file.</p> <p>I tried to use <code>python manage.py dumpdata --traceback</code> and here is the information I have.</p> <pre><code>Traceback (most recent call last): File "manage.py", line 11, in &lt;module&gt; execute_manager(settings) File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/dumpdata.py", line 114, in handle use_natural_keys=use_natural_keys) File "/usr/local/lib/python2.7/site-packages/django/core/serializers/__init__.py", line 91, in serialize s.serialize(queryset, **options) File "/usr/local/lib/python2.7/site-packages/django/core/serializers/base.py", line 48, in serialize self.handle_fk_field(obj, field) File "/usr/local/lib/python2.7/site-packages/django/core/serializers/python.py", line 48, in handle_fk_field related = getattr(obj, field.name) File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 301, in __get__ raise self.field.rel.to.DoesNotExist django.contrib.auth.models.DoesNotExist </code></pre> <p>It says <code>django.contrib.auth.models.DoesNotExist</code>. I wonder if it has something to do with a Foreign key or something.</p> <p><strong>models.py</strong></p> <pre><code>class Client(models.Model): name = models.CharField(max_length = 40) telephone = models.CharField(max_length = 20) website = models.URLField(verify_exists = False) fax = models.CharField(max_length = 20) email = models.EmailField() is_active = models.BooleanField() user = models.ForeignKey(User) datetime = models.DateTimeField(default=datetime.now) note = models.TextField() def __unicode__(self): return self.name </code></pre> <p>From my models.py, the field user, datetime and note were added recently. Now if for a client, any of these fields do not have a value i.e. blank, I will get the error <code>Unable to serialize database</code>.</p> <p>When I have looked up user, dateime and note in mysql. The table for Client shows user_id, datetime and note to have Null values (which is what I want). Why does it not allow Null values? </p> <pre> +-----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(40) | NO | | NULL | | | telephone | varchar(20) | NO | | NULL | | | website | varchar(200) | NO | | NULL | | | fax | varchar(20) | NO | | NULL | | | email | varchar(75) | NO | | NULL | | | is_active | tinyint(1) | NO | | NULL | | | user_id | int(11) | YES | MUL | NULL | | | datetime | datetime | YES | | NULL | | | note | longtext | YES | | NULL | | +-----------+--------------+------+-----+---------+----------------+ </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload