-
Notifications
You must be signed in to change notification settings - Fork 42
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
Custom image model creates problem with existing image fields #90
Comments
we have to change reference in existing
to our new custom image model |
@Parbhat Yes we'll have to write a data migration to migrate existing images to the new image model. |
@chrisdev to update our existing ForeignKey from 'wagtailimages.Image' to 'photo_gallery.CustomImage' we have to create migrations files from start and then migrate. Fixtures also need to be updated again 😞 |
Bummer. |
@chrisdev we have to change ForeignKey in every app from pages to blog to our Custom Image model, if not the user will get the above error in screenshot while changing image. If I go for changing ForeignKey relationship after applying initial migrations then It creates a problem, the solution is to create migrations from start. |
@Parbhat Ok this is necessary only if they use the custom image model which is supposed to be optional
Also until we sort this out be need to put this in a branch. So that it would not affect the dev of other aspects of the project. |
@chrisdev I have migrated the existing ForeignKey relationships to our custom model and also created migrations and fixtures for that. Now it is working fine. In Wagtail, custom image model and wagtail image model can not work together. We have to choose one in a project. As per wagtail docs on advanced images - Any templates that reference the builtin image model will still continue to work as before but would need to be updated in order to see any new images. As torchbox folks also migrated to their custom image model - |
@Parbhat Ok I get it but to make our stuff more reusable we should have a
The image fields can the be defined as
|
@Parbhat this is how it works in the Custom User Model https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#referencing-the-user-model |
@chrisdev this approach is good. But we have another problem. The problem is - we can not simply change the image model in models.ForeignKey() and run ./manage.py makemigrations and then ./manage.py migrate this breaks all. If get_image_model() returns a different model then all migrations have to be deleted first from migrations folder and then database have to be dropped and all process repeats. |
The text was updated successfully, but these errors were encountered: