Make sites optional#119
Conversation
|
hmm... I'm not that familiar with test runner.. I didn't make changes to the tests so I thought they'd continue to work, but the Travis errors indicate it's having issues setting up the DB. |
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('sites', '0001_initial'), |
There was a problem hiding this comment.
You cannot simply remove that line, because later in that migration, you have a reference to sites.Site which won't resolve with this removal. I can imagine various scenarios to workaround this:
- just make the Site fk nullable without removing the
contrib.sitesrequirement. - replace the
sites.Siteby some sort of placeholder which will either import the Site model ifcontrib.sitesis installed or replace it by some fake model otherwise. Not sure if it is feasible.
Sorry, it's probably harder than it appears, but worth a try.
There was a problem hiding this comment.
If you're creating a migration for a model that uses another model that has no migrations, shouldn't you be able to do that without requiring a '0001_initial' from that other object (since it doesn't exist)? However, even if it ran without that migration dependency, the 'sites' would still need to be installed for that ForeignKey to be created (forgot about that).
Okay, I guess I'll have to re-think this a bit. The "placeholder" seems like a good idea but if someone ever turned sites on/off after installing this package they'd likely get some confusing errors.
There was a problem hiding this comment.
I think an extension of ForeignKey would be needed. One that could handle 'sites' being turned on/off or possibly give a descriptive warning if 'sites' is turned on/off without changing the database properly.
|
I am from the future and I still don't want |
As mentioned in #15, this change is to continue supporting the "sites" framework, but also make it work without it so it's now optional.
NOTE:
SITE_IDor sites framework installed. Should all the tests be run twice, once with sites and once without?