manage.py syncdb doesn't add tables for some models
--
Track title: CC I Beethoven Sonata No 31 in A Flat M
--
Chapters
00:00 Question
01:26 Accepted answer (Score 6)
02:13 Answer 2 (Score 8)
03:07 Thank you
--
Full question
https://stackoverflow.com/questions/1435...
Accepted answer links:
[ticket #10706]: http://code.djangoproject.com/ticket/107...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #djangomodels #djangosyncdb
#avk47
ANSWER 1
Score 8
I think I ran across something similar.
I had an issue where a model wasn't being reset. In this case it turned out that there was an error in my models that wasn't being spit out.
Although I think syncdb, when run, spit out some kind of error.
In any case try to import your models file from the shell and see if you can.
$ manage.py shell
>>> from myapp import models
>>>
If theres an error in the file this should point it out.
According to your update, it sounds like you may have a cross-import issue. Instead of:
from app1.models import X
class ModelA(models.Model):
fk = models.ForeignKey(X)
Try:
class ModelA(models.Model):
fk = models.ForeignKey("app1.X")
... although I think you should get an error on syncdb.
ACCEPTED ANSWER
Score 6
Unfortunately, manage.py silently fails to load an app where there's an import error in its models.py (ticket #10706). Chances are that there's a typo in one of your models.py files... check all of the import statements closely (or use pylint).
Recently syncdb stoped loading a couple of my apps, and sqlall gave me the error "App with label foo could not be found". Not knowing that this sometimes means "App with label foo was found but could not be loaded due to ImportError being raised", it took me half an hour to realise that I was trying to import 'haslib' instead of 'hashlib' in one of my models.py files.