Django syncdb not making tables for my app
It used to work, and now it doesn't. python manage.py syncdb
no longer makes tables for my app.
From settings.py:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite.myapp',
'django.contrib.admin',
)
What could I be doing wrong? The break appeared to coincide with editing this model in models.py, but that could be total coincidence. I commented out the lines I changed, and it still doesn't work.
class MyUser(models.Model):
user = models.ForeignKey(User, unique=True)
takingReqSets = models.ManyToManyField(RequirementSet, blank=True)
takingTerms = models.ManyToManyField(Term, blank=True)
takingCourses = models.ManyToManyField(Course, through=TakingCourse, blank=True)
school = models.ForeignKey(School)
# minCreditsPerTerm = models.IntegerField(blank=True)
# maxCreditsPerTerm = models.IntegerField(blank=True)
# optimalCreditsPerTerm = models.IntegerField(blank=True)
UPDATE:
When I run python manage.py loadddata initial_data
, it gives an error:
DeserializationError: Invalid model identifier: myapp.SomeModel
Loading this data开发者_开发知识库 had worked fine before. This error is thrown on the very first data object in the data file.
SOLVED:
Fixed by removing this line:
from stringprep import bl
I'd bet that the SomeModel model you mention above (not necessarily MyUser) has got a problem with it which means it can't be imported by loaddata. If not SomeModel, then a model in the same models.py that SomeModel is defined in.
Have you tried ./manage.py validate
? Even if that says all models are fine, sometimes if there's an error in a models.py of an an app, the entire app becomes 'invisible' to manage.py. I can't say I know why this is the case, but seems to ring a bell.
精彩评论