A way of allowing subdomains to be served by the same project, and associating objects with particular subdomains.
A simple way of allowing subdomains to be served by the same project, and associating objects with particular subdomains.
Requests to a subdomain will use your ROOT_URLCONF file; requests to the BASE_HOST will use ROOT_URLCONF_HOST or instances.urls by default (which just has one page that lists all instances)..
In your ROOT_URLCONF, use a line like the following to have a page for editing the title and description of an instance:
url(r’^instance/edit$’, InstanceUpdate.as_view(), name=’instance-edit’)
To have a model’s objects be associated with an instance, mix in InstanceMixin, and if you have a custom manager make it a subclass of InstanceManager. This adds an instance field, and provides a for_instance manager method to return all the objects in the given instance.
Mix in InstanceViewMixin to any display class-based view to restrict the default queryset to the request’s instance. Add InstanceFormMixin to any create/update view to store the current instance upon save, and allow editing only by those users associated with the instance. Remember to exclude instance from any model form, as it won’t be seen.
pip install . python runtests.py
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|django_subdomain_instances-2.0-py2.py3-none-any.whl (19.3 kB) Copy SHA256 Checksum SHA256||2.7||Wheel||Jun 15, 2017|
|django-subdomain-instances-2.0.tar.gz (9.5 kB) Copy SHA256 Checksum SHA256||–||Source||Jun 15, 2017|