That design could definitely be improved, and it will have to be in order to use the ORM effectively. Then you’d have to change every reference to the fields in all the raw querysets in the app.
You need a ForeignKey relationship between the two models, which is an integer value, not a char. You’d have to do migrations to get this adjusted properly.
Add a facepng_id Integer Field to Monolith. Run makemigrations. Add a RunSQL command to the new migrations file (https://docs.djangoproject.com/en/2.2/ref/migration-operations/#runsql). Something like this:
Update items_monolith SET facepng_id=items_monolith.id FROM items_monolith INNER JOIN items_facepng ON items_monolith.object=items_facepng.obj
Then delete the object and obj fields from the models. Run makemigrations again. Verify that your app doesn’t reference those fields anywhere else.
Then you could access facepng like so:
monolithic.facepng_set
Of course, this is just a very rough idea of what to do, and I’m not sure what the whole structure of your tables is.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
django-users...@googlegroups.com.
To post to this group, send email to
django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/ab7ecf5b-9ae8-4428-9502-6b7d5dec03b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Well, I had always assumed that they do need to be integers, but it looks like this has been discussed at length.
https://groups.google.com/forum/#!topic/django-users/0utRzn98Wxo
It does seem clear, though, that the superior database design uses integers for ForeignKeys.
And I didn’t find a way to make it clear to Django not to use an Integer ForeignKey. Maybe something to do with the primary_key attribute on a CharField?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
django-users...@googlegroups.com.
To post to this group, send email to
django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9697de34-3d20-4023-81a7-8ea9f257f7f1%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9697de34-3d20-4023-81a7-8ea9f257f7f1%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
To post to this group, send email to djang...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/27eee43ff8024c98bcf9a5e9cd4bfd89%40iss2.ISS.LOCAL.