Comments (8)
1st question, how best to handle www.mydomain.com so that it hits the public schema and doesn't try for a tenant url of 'www'. Is that a rewrite rule?
The middleware removes the www, you can see it here:
https://github.com/bcarneiro/django-tenant-schemas/blob/master/tenant_schemas/middleware.py#L25
from django-tenant-schemas.
You should be able to make www point to public by simply copying the middleware, modifying it to simply return
after connection.set_schema_to_public()
if the subdomain is www, and then telling your settings.py
to use your custom middleware instead of the tenant_schema middleware as specified here in the docs: https://django-tenant-schemas.readthedocs.org/en/latest/install.html#basic-settings
i.e.:
MIDDLEWARE_CLASSES = (
'myapp.middleware.WWWPublicTenantMiddleware',
#...
)
from django-tenant-schemas.
Thanks @walkman, @fuhrysteve. Sounds like it might already be handled so I'll wait see before attempting the second solution.
So to the perhaps bigger question then; advice on setting up the tenant subdomain virtual hosts? (ie all subdomains other than www)
Thanks again
from django-tenant-schemas.
Something like:
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
ServerAlias *.example.com
DocumentRoot /www/domain
</VirtualHost>
See: http://httpd.apache.org/docs/current/vhosts/name-based.html
from django-tenant-schemas.
@fuhrysteve surely it contains WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
in there at least? As per https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/. I did read the Apache doc pages already, my trouble is just coupling the 2 in the best way. I'll spend some more time on it and post a solution for feedback if it seems to work ok.
Cheers
from django-tenant-schemas.
You'll basically want what the django docs state, but you'll need *:80
on your VirtualHost
and ServerAlias *.example.com
within it.
from django-tenant-schemas.
Hi Humbled,
sorry for the late reply. My VirtualHost is very similar to steve's.
<VirtualHost 127.0.0.1:8080>
ServerName mywebsite.com
ServerAlias *.mywebsite.com mywebsite.com
LimitRequestBody 3145728
# 3MB limit file size
WSGIDaemonProcess www.mywebsite.com processes=5 threads=1
WSGIProcessGroup www.mywebsite.com
WSGIScriptAlias / "/path/to/django/scripts/mywebsite.wsgi"
# line above means the root folder (/) will load wsgi
</VirtualHost>
I have added it to the docs: 92615d0
Hope this helps!
Cheers,
Bernardo
from django-tenant-schemas.
That's great, thanks @fuhrysteve @bcarneiro. Bernardo I ended up with one very similar to what you posted, but I've included python-path argument to WSGIDaemonProcess
as per the Django docs. Perhaps you have a system-wide path set elsewhere.
Thanks for adding to the docs, that's what this was all about.
Cheers
Brad
from django-tenant-schemas.
Related Issues (20)
- weird behaviour using "with schema_context" HOT 3
- Can't migrate new tables to tennant apps.
- New tenant model is not creating relations in non-public schema with multiple databases
- Accessing tenants data from public. HOT 1
- django-tenants TypeError: argument of type 'TenantQueryset' is not iterable
- ImportError: cannot import name 'force_text' from 'django.utils.encoding' HOT 3
- How to create tenant_schemas.storage.TenantFileSystemStorage within AWS s3 bucket with django-storages 1.12.3
- "Apps aren't loaded yet" when upgrading from django 3.0.10 to 3.2
- Schema Deletion HOT 1
- DRF example
- Support for django 4.0 HOT 7
- how to launch tenant_command loaddata from views with fixtures HOT 1
- Supported Version Django HOT 3
- Distinguish between workspaces
- error 500 DEBUG=False in production HOT 1
- [Solution] Unable to create the django_migrations -relation already exists HOT 1
- healthcheck HOT 2
- Issue in holding DB connection consistently HOT 1
- @contextmanager
- Django-tenants - please help
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-tenant-schemas.