Skip to content
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

A great solution for me when I needed to change the abstract user model and transfer pages! #126

Open
ocuna opened this issue Aug 22, 2022 · 0 comments

Comments

@ocuna
Copy link

ocuna commented Aug 22, 2022

This isn't an issue, I had an Issue and solved it myself. I'm sorry I'm not sure how to properly communicate how helpful this program was in transferring content for me or where to share what maybe a useful feature for others that I could attempt to build out.

I'm developing a site and realized I needed to abstract my django user model. I found this is a notoriously difficult 'gotcha' but I needed to none the less. I decided to spin up a TEST server, update wagtail from 2.14 > 3.0 as well as Django to V4 and then attempt to pull in the DEV content in some way if I could.

Well, this module was SO helpful and I wanted to tell you how. After setting up all the migrations and content types in TEST to mirror my DEV site, I built out the new abstract user model in a new custom app. This made a new django_content_type that was unique to each build.

In digging around in the code this is how I did it:

  1. Intercepted all models.get_model_for_path() if model_path was auth.user I forced it to be myapp.user
  2. Flagged all request_data in views.import_missing_object_data() matching the myapp.user key I forced in place of auth.user
  3. For these flagged records, I faked the normal JSON request to the DEV server with a query pointed back at my TEST server's myapp.user table
  4. I then manually identified the UUID that was in the DEV.auth.user where the original content was made and updated the TEST.wagtail_transfer_idmapping to match the DEV auth user.
  5. Wagtail Transfer pulled in all the content. It assigned all content made by my old generic user to my new abstract user model.

Was EZ!

I'm rather new at django/wagtail and I've never submitted a pull request to update software so I'm hesitant to take the time to write this properly. Maybe my hack-idea is going to blow up in my face? Maybe the abstract-user update isn't as big a deal as doing this feature is?

Please let me know your thoughts. Thanks for the great software!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant