Comments (10)
we have to change reference in existing
image = models.ForeignKey(
'wagtailimages.Image',
..
)
to our new custom image model
from wagtail-cookiecutter-foundation.
@Parbhat Yes we'll have to write a data migration to migrate existing images to the new image model.
This will have to be documented so we may as well work out what has to be done and document it
from wagtail-cookiecutter-foundation.
@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 😞
from wagtail-cookiecutter-foundation.
Bummer.
Maybe instead of a fixture we can use a sql dump as we said we want to enforce the use of Postgres?
How about leaving out the gallery_feed image for now? We can random select an image from the gallery to represent the feed image.
from wagtail-cookiecutter-foundation.
@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.
from wagtail-cookiecutter-foundation.
@Parbhat Ok this is necessary only if they use the custom image model which is supposed to be optional
This is a if we are doing this we need to have some method of getting the image model just like how they do in in Django with the Auth model.
get_image_model()
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.
from wagtail-cookiecutter-foundation.
@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 -
https://github.com/torchbox/wagtail-torchbox/blob/master/torchbox/models.py
from wagtail-cookiecutter-foundation.
@Parbhat Ok I get it but to make our stuff more reusable we should have a get_image_model()
that returns the string module.Model
of the custom image model this would work like
from django.conf import settings
def get_image_model()
return settings.get('WAGTAILIMAGES_IMAGE_MODEL', 'wagtail.Images.ImageModel')
The image fields can the be defined as
class MyPage(Page):
....
feed_image = models.ForeignKey(get_image_model(), null=True, blank=True,
on_delete=models.SET_NULL, related_name='+'
)
from wagtail-cookiecutter-foundation.
@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
from wagtail-cookiecutter-foundation.
@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.
from wagtail-cookiecutter-foundation.
Related Issues (20)
- Add sentry.io Celery and Redis integration
- Documentation on provisioning VPS via Ansible is inaccurate
- TemplateSyntaxError 'wagtailmarkdown' is not a registered tag
- User model crash when django-all-auth is not selected
- 'auth.User' has been swapped for 'users.User'
- Set the COMPRESS_ENABLED
- Make Provision Sticking at Generate CSR
- Command make static_site fails, documentation outdated
- cli.ini file contains invalid challenges
- wagtail updatemodulepaths needs to be added to deployment script
- Ansible deployment scripts need updating
- Support for Docker Containers
- Wagalytics Django ImportError HOT 3
- Photo Gallery should use Collections
- wagtail latest is not compatible with django latest HOT 1
- Sentry implementation refers to the deprecated client
- Redis not installed on Ubuntu release 18.0
- wrong crontab command for certbot renewal HOT 2
- Ansible cron task needs string escaping HOT 1
- make requirements raises incompatibilities HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wagtail-cookiecutter-foundation.