Re: Overriding AppConfig.get_model(s)

2014-07-25 Thread Andrew Godwin
Actually, managed won't work, because that just affects if stuff gets put into migration files, IIRC - even if you change it it won't affect migrations. The main problem is that whatever you do, Django is going to mark the migration as applied if you have sessions set to a non-db store and then wh

Re: Overriding AppConfig.get_model(s)

2014-07-25 Thread Nick Sandford
Managed might be the ticket then. I don't think it's too surprising to the user who configures a cache or file session backend that no database table is created. I think that's slightly less surprising than the status quo -- they configured a file session backend and when they run migrate they noti

Re: Overriding AppConfig.get_model(s)

2014-07-25 Thread Andrew Godwin
Yeah, but if you change the value of the routers during a project's lifetime it's up to you to fix the resulting issues (same as if you switch AUTH_USER_MODEL - you _cannot_ change this after project start without serious pain). If you're happy saying the same thing about sessions, then go and tie

Re: Overriding AppConfig.get_model(s)

2014-07-25 Thread Nick Sandford
Isn't that essentially what's happening by respecting router.allow_migrate? Determining at runtime via a setting (DATABASE_ROUTERS) whether to apply migrations. From the perspective of a user, providing a custom database router makes sense for applications they don't control, but from the perspecti

Re: Overriding AppConfig.get_model(s)

2014-07-25 Thread Andrew Godwin
I don't think there's a way you can do this with migrations. You're not supposed to be able to change them at runtime based on settings; that was the cause of most of our bugs with swappable models. Andrew On Fri, Jul 25, 2014 at 12:48 PM, Nick Sandford wrote: > Ahh ok, that makes sense -- I g

Re: Overriding AppConfig.get_model(s)

2014-07-25 Thread Nick Sandford
Ahh ok, that makes sense -- I guess there's no difference between overriding get_model(s) and manually deleting the model out of the source to the migrations. I can't think of any decent way to use router.allow_migrate in sessions other than monkey patching it to do what I want. Any suggestions?

Re: Overriding AppConfig.get_model(s)

2014-07-25 Thread Andrew Godwin
Migrations instantiate their own copies of AppConfig and Apps and run from those, so you won't be able to affect them by overriding methods. If you want to exclude models from migrations use router.allow_migrate. Andrew On Fri, Jul 25, 2014 at 11:59 AM, Nick Sandford wrote: > I was just workin

Overriding AppConfig.get_model(s)

2014-07-25 Thread Nick Sandford
I was just working on #22986 and it seems that if the AppConfig.get_model(s) methods are overridden, migrations for models that are excluded are still run. Is this a known issue? Am I abusing get_model(s) or should I file a ticket for this? Cheers, Nick https://code.djangoproject.com/ticket/2298