Reputation: 589
The following Python code produces an error:
class Post(models.Model):
author = models.CharField(max_length=40,blank=False,default="")
title = models.CharField(max_length=100,blank=False,default="")
content = models.TextField(blank=False,default="")
# status = models.CharField(max_length=100,blank=False,default="draft")
published = models.BooleanField(default = False)
date_created = models.DateTimeField()
date_modified = models.DateTimeField()
def save(self):
if self.date_created == None:
self.date_created = datetime.now()
self.date_modified = datetime.now()
super(Post, self).save()
This is the error message I get.
raise DeserializationError(e)
What I've tried:
on suncdb it raises error
My question:
How do I fix this?
Upvotes: 1
Views: 1730
Reputation: 17024
I had the same error once with my application, though with a minor change: syncdb didn’t throw any errors. But when I tried to access the model, I got that error. Anyway, what fixed it for me was:
python manage.py reset [appname]
python manage.py syncdb
Hopefully it can help you too. If you have any data, you should export it as a JSON, so you don't lose it with the reset.
Make a fixture (json) with the following command:
mkdir APPName/fixtures
python manage.py dumpdata APPName --format=json > APPName/fixtures/OriginalData.json
Reload the data with syncdb
You can read more about it here: https://code.djangoproject.com/wiki/Fixtures
Upvotes: 2