-
-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing "to" in deconstruction
/ KeyError: 'to'
on second migrate
run (Django 1.7, via django/db/migrations/autodetector.py)
#206
Comments
Here is the full backtrace:
It smells like a bug in Django, assuming that if there's |
Reported in Django at: https://code.djangoproject.com/ticket/22263. |
Hmm, while thinking about it: maybe it's taggit responsibility to return the |
django-taggit manually sets up `rel.to` and therefore there is no "to" kwarg. Fixes #22263 Ref: jazzband/django-taggit#206
Not sure either, lets see what @andrewgodwin says |
Yes, the autodetector assumes that if you inherit from ForeignKey or ManyToMany you have a "to", as that's a basic way of how those fields work and is needed to work out dependencies and things. If you don't need "to", you're not a relation and shouldn't inherit from them? |
@andrewgodwin It doesn't seem like it needs |
Right, but there's a certain amount of assumption for the deconstruction of relations specifically - all other fields you can do whatever you like with, but for relations we need to be able to work out where they're pointing without a full model lying around. My suggestion would be that deconstruct correctly sets "to" if the manager has been in and done the right stuff, and leaves it out otherwise; and that init accepts a "to" argument but ignores it. That should be enough, as the deconstructed forms are usually from full models' fields. |
@andrewgodwin
When I've tried it first, it caused some kind of recursion, but I could not reproduce it currently and other circumstances might have been involved. |
That looks pretty reasonable to me. You should probably try and reproduce the recursion and try to guard against it, though... |
This got merged via another branch it seems, closing here -- @blueyed please reopen if I missed something. |
Yes, this was fixed in #207. |
I am getting a KeyError exception, when running
manage.py migrate
a second time on a Django 1.7 project (fresh DB, but migrated from 1.6).It seems like Django expects a key "to" in the field's deconstructor, which is not provided by the deconstructor
When inspection
deconstruction
in case of the exception, it looks like this:I am using the following to define the tags field on my model:
The initial
mange.py migrate
worked, andmigrate -l
shows:taggit
[X] 0001_initial
I am not sure, if this is an issue with Django or django-taggit.
Using Django master, and django-taggit master.
The text was updated successfully, but these errors were encountered: