Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Authz/n instructions don't work with Django migrations #15

Open
nyergler opened this issue Nov 3, 2014 · 0 comments
Open

Authz/n instructions don't work with Django migrations #15

nyergler opened this issue Nov 3, 2014 · 0 comments

Comments

@nyergler
Copy link
Owner

nyergler commented Nov 3, 2014

As reported by Maciej Friedel:

I found solution on problem in Your tutorial.
in section Handling Authentication & Authorization (http://effectivedjango.com/tutorial/authzn.html)

in last contacts/models.py correction there is:

owner = models.ForeignKey(User)

but this is not correct and displaying error

because there is migration problem

% python manage.py makemigrations
You are trying to add a non-nullable field 'owner' to contact without a default;
we can't do that (the database needs something to populate existing rows).
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows)
2) Quit, and let me add a default in models.py
Select an option:

the problem resolved this input:

owner = models.ForeignKey(User, null=True, blank=True, default = None)

after successful migration there can be owner = models.ForeignKey(User) but migration needed this default settings

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant