question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PUBLIC_SCHEMA_URLCONF

See original GitHub issue

I was thinking about this for quite some time, but now in connection with #43 I could finally draft this idea: Get rid of PUBLIC_SCHEMA_URLCONF setting, and in the documentation, suggest a solution with a different wsgi_app for the public website which point to a different settings.py (settings_public).

# wsgi_main_website.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings_public")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

This would need to set up a new wsgi instance, but I don’t think that’s a problem and this would have the following benefits:

  • We can remove ContentType.objects.clear_cache() from the middleware, because this case, every schema would have the same app in contenttypes in the same place. This causes +1 DB Query in every request, but if the cache is never cleared, Django (contenntypes) can nicely build up a cache for the objects I think. I can’t come up with a solution where PUBLIC_SCHEMA_URLCONF is in use and it’s not needed to modify Django core to get rid of this behavior.
  • as @bcarneiro put the question in #43 :
    “What does your code do when I have auth and admin both on public and on tenant?” Does the user want shared apps referenced in public? Does he want public schema for the public website only and tenant apps without referencing public? It would be more clear what it means putting an app into both of the SHARED_APPS and TENANT_APPS; the user made a mistake 😃 or what would be even better I described in #43, to have a SHARED_MODELS setting.
  • Sometimes for the public website you want to have a CMS ex. http://www.django-cms.org, which want to take some control of the url routing because of dynamic pages, etc, and it would be very hard to integrate with this app.

I will do it myself for sure, because I think overall this is the right way to do it but would be nice to get some comments on this one, and I think others could benefit from this also.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
juliocesar-iocommented, Oct 10, 2017

Hi guys, I know it’s been a lot time since this discussion but I din’t found much in the docs. If I setup a separate WSGI settings, how do I declare database settings? Should I use the default postgresql backend for django? How do I manage the migrations? And in this separate settings the django-tenant-shemas app would exist at all ?

0reactions
kissgyorgycommented, Sep 23, 2013

I add a section to the documentation about this setup then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using PUBLIC_SCHEMA_URLCONF in django-tenant- ...
I maintain Django-Tenants which is a fork of django-tenant-schemas. The public url file gets called when the domain doesn't match a tenant.
Read more >
use `PUBLIC_SCHEMA_URLCONF` with no object for the ...
I'd like to achieve the following setup: When a user goes to www.<domain> they use the PUBLIC_SCHEMA_URLCONF and request.tenant is None
Read more >
django.conf.settings.PUBLIC_SCHEMA_URLCONF Example
Here are the examples of the python api django.conf.settings.PUBLIC_SCHEMA_URLCONF taken from open source projects. By voting up you can indicate which examples ...
Read more >
Using PUBLIC_SCHEMA_URLCONF in django-tenant- ...
I maintain Django-Tenants which is a fork of django-tenant-schemas. The public url file gets called when the domain doesn't match a tenant.
Read more >
Schemas - Django REST framework
SchemaGenerator is a top-level class that is responsible for walking your configured URL patterns, finding APIView subclasses, enquiring for their schema ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found