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

Support the Sites framework #35

Open
jerivas opened this issue Dec 5, 2015 · 3 comments
Open

Support the Sites framework #35

jerivas opened this issue Dec 5, 2015 · 3 comments

Comments

@jerivas
Copy link

jerivas commented Dec 5, 2015

It'd be neat to have SingletonModel instances that are unique per site. I think the only thing that is needed is adding a FK to the Site model, and changing the uniqueness check to be per-site. Is this something you would consider?

@lazybird
Copy link
Owner

lazybird commented Dec 9, 2015

That could be a good idea - thanks for the suggestion. I think there should not be a dependency, by default, to the site framework. If you propose a pull request, it can be collectively reviewed. May be you can describe here your implementation before starting coding.
Thanks.

@jerivas
Copy link
Author

jerivas commented Apr 7, 2016

Hey, sorry for the delay.

My idea was to introduce a new model: SiteSingletonModel (it would only need to subclass SingletonModel and add a FK to Site. Users can then choose which one they want to inherit from. Not sure if we should create new managers, templatetags, etc, or just do some type checking in the existing ones.

@rafael-h-ferreira
Copy link

9 years after, but to anyone who may find this, you can do this with by adding the current site id to the model extending SingletonModel like so:

from solo.models import SingletonModel
from django.contrib.sites.models import Site

current_site = Site.objects.get_current()

class SomeModel(SingletonModel):
    ...
    singleton_instance_id = current_site.id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants