0

I'm getting to know the Sites framework in Django. One thing I cannot find in the documentation is how to restrict users to "their" sites.

Lets say I have example.com and sexyblog.com. Both sites run of the same code base and share the same db using Sites.

How to make sure that the sexyblog-users can't log in to example.com?

Thank you for your help.

JasonTS
  • 2,479
  • 4
  • 32
  • 48

1 Answers1

0

When you are using the Sites framework, you can retrieve the current site with get_current_site anywhere, so you can build your permission system. https://docs.djangoproject.com/en/4.1/ref/contrib/sites/#get-current-site-shortcut

I suppose you have stored user sites allowed somewhere, so you just have to create a mixin/decorator for managing this permission checking in view.

There is none existing system for managing your case in Site framework I think

Lucas Grugru
  • 1,664
  • 1
  • 4
  • 18