问题
I have two users, mh00h1 and mh00h2. I also have modelA that defines the following in my models.py:
class Meta:
permissions = (
('read','read'),
('write','write'),
)
From a shell, I went to set permissions:
>>>> frhde = create modelA instance
>>>> assign_perm('read', mh00h2, frhde)
DoesNotExist: Permission matching query does not exist. Lookup parameters were {'codename': u'read', 'content_type': <ContentType: modelA>}
I realized that South
didn't migrate my models after I added class Meta
to modelA
and confirmed this. Changing read
to read2
shows that South
does not detect the change.
$ /manage.py schemamigration myapp --auto
Running migrations for myapp:
- Nothing to migrate.
- Loading initial data for myapp.
Installed 0 object(s) from 0 fixture(s)
Running migrations for guardian:
- Nothing to migrate.
- Loading initial data for guardian.
Installed 0 object(s) from 0 fixture(s)
How can I get schematicmigration to correctly update the database, or is there a better way to do this that does not require redoing the whole database?
Thank you.
回答1:
You can use ./manage.py syncdb --all
, or create a signal like in this post.
来源:https://stackoverflow.com/questions/18117687/django-south-and-guardian-migrate