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

fluent_pages.0001_initial migration makes wrong assumption about SITE_ID. #90

Closed
mrmachine opened this issue Sep 2, 2015 · 1 comment

Comments

@mrmachine
Copy link
Contributor

It assumes that if any Site objects exist, that a site matching settings.SITE_ID will exist. That's not always true. We have two projects which share the same database, and they have different values for settings.SITE_ID.

When I migrate the first project, all good. When I migrate the second project, there is a Site object, so this migration doesn't bother creating a new one to match settings.SITE_ID, and then I get django.contrib.sites.models.DoesNotExist: Site matching query does not exist.

I think it could be fixed by changing the code like this:

def make_site(apps, schema_editor):
    Site = apps.get_model("sites", "Site")
    Site.objects.get_or_create(
        pk=settings.SITE_ID,
        defaults=dict(
            name='example',
            domain='example.com',
        ))

This also applies to django-fluent/django-fluent-contents#55

Any objections?

vdboor added a commit that referenced this issue Oct 7, 2015
@vdboor
Copy link
Contributor

vdboor commented Oct 7, 2015

Fully agreed, I've updated this in 9f18106

@vdboor vdboor closed this as completed Oct 7, 2015
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

2 participants