Worked great Josh. I liked the fact that the monkey-patching happens there as well.
On Saturday, April 18, 2015 at 5:07:18 PM UTC-4, Keith Eberle wrote: > > Thanks Josh. I'll give that a try tonight. If I moved the migration out > of that folder, it worked, so I'm hopeful that your suggestion will do the > trick. > > On Saturday, April 18, 2015 at 11:21:44 AM UTC-4, Josh Cartmell wrote: >> >> Hi Keith and Ken, I think I understand what is going on and you actually >> are very close to doing the right thing. When you create migrations for an >> EXTRA_MODEL_FIELD and store them in a separate app they actually are run >> using that other apps name, so that part was correct. If there was a >> transcription error, my guess is that blog in the schemamigration command >> should have read mezzanine.blog, not just blog. It may be that it gets >> picked up either way. >> >> My recommendation is to store EXTRA_MODEL_FIELD migrations in an app of >> their own that you don't use for anything besides the EXTRA_MODEL_FIELDS >> modifications. I would create an app called blog_mods (I like to place it >> inside my theme app) and then keep the migrations there. >> >> Doing that will keep theme's migrations totally separate and should avoid >> the error you encountered. >> >> So your theme directory structure would look like: >> >> - theme >> - blog_mods >> - migrations (these are the EXTRA_MODEL_FIELD_MIGRATIONS) >> ... other files like admin.py, models.py, etc) ... >> -migrations (these are theme's migrations) >> ... other files like admin.py, models.py, etc) ... >> >> You will need to add theme.blog_mods to your INSTALLED_APPS setting. >> After creating the migrations you would run: >> >> $ python manage.py migrate theme.blog_mods >> >> You can also then use blog_mods.admin to do any monkey patching to get >> your new field[s] to show up. >> >> Good luck! >> >> On Sat, Apr 18, 2015 at 9:45 AM, Ken Bolton <[email protected]> wrote: >> >>> Hi Keith, >>> >>> Your schemamigration is for the app "blog", but then you are attempting >>> to migrate the app "theme". Let us know if that was simply a transcription >>> error or the root cause of your issue. >>> >>> hth, >>> ken >>> >>> On Sat, Apr 18, 2015 at 2:48 AM, Keith Eberle <[email protected]> >>> wrote: >>> >>>> I'm having trouble with a subsequent schema migration after I used >>>> EXTRA_MODEL_FIELDS: >>>> >>>> EXTRA_MODEL_FIELDS = ( >>>> ( >>>> "mezzanine.blog.models.BlogPost.gallery", >>>> "ForeignKey", >>>> ("galleries.Gallery",), >>>> {'blank': True, 'null': True}, >>>> ), >>>> ) >>>> >>>> >>>> Then as indicated in the mezzanine docs, I ran: >>>> >>>> $ python manage.py schemamigration blog --auto --stdout >> >>>> theme/migrations/0016_blog_customization.py >>>> >>>> >>>> And then: >>>> >>>> $ python manage.py migrate theme >>>> >>>> >>>> I quickly glanced at this caveat, but wasn't really sure what it would >>>> mean: >>>> >>>> *Be warned that over time this approach will almost certainly require >>>> some manual intervention by way of editing migrations, or modifying the >>>> database manually to create the correct state. Ultimately there is a >>>> trade-off involved here.* >>>> >>>> >>>> So I made a different change to a model, which was just adding a >>>> BooleanField. When I try the schema migration now I get: >>>> >>>> $ python manage.py schemamigration theme --auto >>>> You cannot use automatic detection, since the previous migration does >>>> not have this whole app frozen. >>>> Either make migrations using '--freeze theme' or set >>>> 'SOUTH_AUTO_FREEZE_APP = True' in your settings.py. >>>> >>>> >>>> I've tried to review the docs for the --freeze option, but I'm just >>>> not understanding what to do. Example: >>>> >>>> python manage.py schemamigration --freeze theme --empty --auto >>>> You must provide an app to create a migration for. >>>> >>>> >>>> Can someone guide me in the right direction? >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Mezzanine Users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Mezzanine Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
