-
Notifications
You must be signed in to change notification settings - Fork 27
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
ManyToManyField
s on Page
subclasses have the wrong through table name created during migrations
#89
Comments
For reference I worked around this by setting the
|
This just bit us again. I wonder if it's worth the metaclass magic to prefix database table names, as it seems that has also caused trouble indirectly in #103 by letting Django think I think most people don't know or care what their DB table names are, and if they do, they would explicitly define them on their models. If fluent were to remove this behaviour, I think Django should be able to detect the removal of The work-around is easy enough, once you know what the cause us. The problem is, every time a new developer hits this problem, they may spend a lot of time trying to debug it before they arrive at this GitHub issue and find the work-around. |
Yes, I'm in favor of such change, given that Django can handle this. It would make the next release Django 1.7+ only, which is fine with me. I wonder, do we still need a "1.0" release that also supports Django 1.6 (for transition) and then release 1.1 that is Django 1.7+ only - or are you in favor of just an 1.0 release that is Django 1.7+ only? |
(Just bit us one more time) |
NB To work around this, give your model a |
Using
Django==1.7.10
or 'Django==1.8.4.there appears to to be an issue where the through table for a
ManyToManyField` gets made with an incorrect name.Using the following model structure in a base project:
I ran
./manage.py makemigrations <app_name>
which generated a migration which looks sensible:So all is migrated and I go into the admin and try to save some many to many data:
After fishing around it appears that during the Django life cycle it does not have that name except when in the migration process the
CreateModel.database_forwards
function gets the app state at which point theURLNodeMetaClass.__new__
table changes have been applied to it which can be seen by putting a debug set trace at after the model retrieval inCreateModel.database_forwards
and printingmodel._meta.get_field('product_category').rel.through._meta.db_table
. If you then run in shell mode (./manage.py shell
) and import your model and do the same you will notice a different table name.The output for each of these are:
Migration --> u'pagetype_fluent_test_basicpage_product_category'
Shell --> u'fluent_test_basicpage_product_category'
I am happy to help look into this issue but if anyone has an ideas or knowledge that would be awesome!
As a work around I guess you could manually create the through table manually and set the db table on it? I have not tested this though.
The text was updated successfully, but these errors were encountered: