manage.py syncdb doesn't add tables for some models
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Beneath the City Looping
--
Chapters
00:00 Manage.Py Syncdb Doesn'T Add Tables For Some Models
01:05 Answer 1 Score 8
01:50 Accepted Answer Score 6
02:29 Thank you
--
Full question
https://stackoverflow.com/questions/1435...
--
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.