How to add an Admin class to a model after syncdb?
I added some models in my models.py and I want to add an admin class to use a wysiwyg-editor in text-fields.
Well, I know that Django itself doesn't support migrati开发者_如何学运维ons and I've used South, but it doesn't work either. South doesn't "see" the change. Could it be, that South just detects changes to fields, but not if I add a new class? How can I tweak Django to detect such changes?syncdb
and South are only concerned with descendants of Model
in apps listed in INSTALLED_APPS
. Everything else is handled by Django directly.
You seem to be very confused, unfortunately. Of course Django reads the code in models.py - otherwise what would be the point of it? Django uses that code initially to define the model SQL when doing syncdb, but it doesn't modify existing database tables in subsequent calls to syncdb - hence the need for South.
But naturally, Django uses models.py and admin.py and all the other Python code to define its own configuration and state. (And note that admin classes are not defined in models.py but in admin.py.)
If you are not seeing changes, you will need to restart your server.
I'm fairly sure that if you follow the steps as outlined in the tutorial to create an admin app it'll just work. Migration isn't an issue as the admin app creates new tables rather than altering the existing one.
精彩评论