-
Notifications
You must be signed in to change notification settings - Fork 197
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
Make sites optional #119
base: master
Are you sure you want to change the base?
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. |
@@ -8,7 +8,6 @@ | |||
class Migration(migrations.Migration): | |||
|
|||
dependencies = [ | |||
('sites', '0001_initial'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.sites
requirement. - replace the
sites.Site
by some sort of placeholder which will either import the Site model ifcontrib.sites
is 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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_ID
or sites framework installed. Should all the tests be run twice, once with sites and once without?