问题
When I do manage.py syncdb
I get:
Error: One or more models did not validate:
users.userprofile: "uuid": Primary key fields cannot have null=True.
even though my class UserProfile(models.Model)
have:
uuid = UUIDField(primary_key=True, auto=True, editable=False)
回答1:
The comment from Daniel was probably it, I just didn't know how to follow the clue.
The fix, that came from Joshua, was to remove the official django-uuidfield
's and replace them with Joshua's fork.
-django-uuidfield==0.4
-django-uuidfield-2==0.6.5
+# django-uuidfield==0.4
+# django-uuidfield-2==0.6.5
+-e git://github.com/joshuakarjala/django-uuidfield.git#egg=django-uuidfield
Remember to pip uninstall django-uuidfield
and pip uninstall django-uuidfield-2
before pip install -r requirements.txt
.
来源:https://stackoverflow.com/questions/13747335/syncdb-error-one-or-more-models-did-not-validate