Comments (4)
Hi,
All links using reverse on this app always point to the same schema
(subdomain) it uses. So if you're at tenant1.domain.com, you can't call
reverse to make a link for tenant2.domain.com. In this case you'll have to
write the link manually. Was this your doubt, do you have any specific
doubts? I'll gladly help you, but I don't know what you didn't understand.
There are examples on the docs.
Bernardo
2013/6/22 bitaVersion [email protected]
Could you please elaborate on the tenant url routing portion as well?
If you go through
https://github.com/tkaemming/django-subdomains/blob/master/docs/index.rstthey have given ample instructions as how to set their urls.I am finding it difficult to set up the subdomains following the docs as
is.
If you could supplement with an example, it will be great.Thanks!
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/48
.
Bernardo Pires Carneiro
from django-tenant-schemas.
- by example I meant a sample application, with views and urls.
- For subdomain url management, will I have to use https://github.com/ennio/django-hosts or https://github.com/tkaemming/django-subdomains
I started the app, put everything in place(middleware, installed_apps, tenant_model, tenant_urls.py and public_urls.py) had this(https://github.com/pennersr/django-allauth) installed.
when I run python manage.py sync_schemas --shared
=== Running syncdb for schema public
Syncing...
Creating tables ...
Creating table south_migrationhistory
Creating table account_emailaddress
Creating table account_emailconfirmation
DatabaseError: relation "django_content_type" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...`
Apart from that, the tests also fail. Here is my settings file
SHARED_APPS = (
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.sitemaps',
# Uncomment the next line to enable the admin:
'south',
'static_sitemaps',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.twitter',
'django_extensions',
)
these are apps that are specific to each tenants
TENANT_DJANGO_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
)
TENANT_THIRD_PARTY_APPS = (
'tenant_schemas',
)
TENANT_LOCAL_APPS = (
'customer,
)
TENANT_MODEL = "customer.Org"
PUBLIC_SCHEMA_URL_TOKEN = '/main'
MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'htmlmin.middleware.HtmlMinifyMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'tenant_schemas.middleware.TenantMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
TENANT_APPS = TENANT_DJANGO_APPS + TENANT_LOCAL_APPS + TENANT_THIRD_PARTY_APPS
INSTALLED_APPS = SHARED_APPS + TENANT_APPS
when I run the tests, 1 test fails with 8 error
FAIL: test_non_auto_sync_tenant (tenant_schemas.tests.tenants.TenantTestCase)
Traceback (most recent call last):
File "/home/betaversion/.virtualenvs/sosio/local/lib/python2.7/site-packages/tenant_schemas/tests/tenants.py", line 53, in test_non_auto_sync_tenant
self.assertFalse(schema_exists(tenant.schema_name))
AssertionError: True is not false
Ran 6 tests in 2.396s
FAILED (failures=1, errors=8)
Destroying test database for alias 'default'...
The entire stacktrace is https://dpaste.de/OZ9Wc/
The tenant model looks like the following
class BaseModel(TenantMixin):
"""
An abstract base class model that provides self-managed "created" and
"modified" multi tenant fields.
"""
auto_create_schema = True
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
Class Org(BaseModel):
username = models.OneToOneField(User)
name = models.CharField(max_length=500, null=True, blank=True)
slug = models.SlugField(null=True, blank=True)
website = models.URLField(max_length=500, null=True, blank=True)
established_in = models.DateField(help_text = "MM/DD/YYYY")
description = models.TextField()
paid_until = models.DateField()
on_trial = models.BooleanField()
def save(self, *args, **kwargs):
self.slug = slugify(self.name[0:50])
super(Org, self).save(*args, **kwargs)
def __unicode__(self):
return self.name
from django-tenant-schemas.
there's an issue right now on this app that requires contenttypes, auth and
admin to exist on both tenant and public. you should then be able to use it
without errors. ill look into this issue as soon as possible
2013/6/22 bitaVersion [email protected]
by example I meant a sample application, with views and urls.
2.For subdomain url management, will I have to use
https://github.com/ennio/django-hosts or
https://github.com/tkaemming/django-subdomainsI started the app, put everything in place(middleware, installed_apps,
tenant_model, tenant_urls.py and public_urls.py) had this(
https://github.com/pennersr/django-allauth) installed.
when I run python manage.py sync_schemas --shared=== Running syncdb for schema public
Syncing...
Creating tables ...
Creating table south_migrationhistory
Creating table account_emailaddress
Creating table account_emailconfirmation
DatabaseError: relation "django_content_type" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...`
Apart from that, the tests also fail. Here is my settings fileSHARED_APPS = (
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.sitemaps',Uncomment the next line to enable the admin:
'south',
'static_sitemaps',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.twitter',
'django_extensions',
)these are apps that are specific to each tenants
TENANT_DJANGO_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
)TENANT_THIRD_PARTY_APPS = (
'tenant_schemas',
)TENANT_LOCAL_APPS = (
'cbase',
'ebase',
)TENANT_MODEL = "customer.Org"
PUBLIC_SCHEMA_URL_TOKEN = '/main'MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'htmlmin.middleware.HtmlMinifyMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'tenant_schemas.middleware.TenantMiddleware',Uncomment the next line for simple clickjacking protection:
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
TENANT_APPS = TENANT_DJANGO_APPS + TENANT_LOCAL_APPS +
TENANT_THIRD_PARTY_APPS
INSTALLED_APPS = SHARED_APPS + TENANT_APPS
when I run the tests, 1 test fails with 8 error FAIL:
test_non_auto_sync_tenant (tenant_schemas.tests.tenants.TenantTestCase)Traceback (most recent call last):
File
"/home/betaversion/.virtualenvs/sosio/local/lib/python2.7/site-packages/tenant_schemas/tests/tenants.py",
line 53, in test_non_auto_sync_tenant
self.assertFalse(schema_exists(tenant.schema_name))AssertionError: True is not false
Ran 6 tests in 2.396s
FAILED (failures=1, errors=8)
Destroying test database for alias 'default'...
The entire stacktrace is https://dpaste.de/OZ9Wc/ The tenant model looks
like the followingclass BaseModel(TenantMixin):
""" An abstract base class model that provides self-managed "created" and "modified" multi tenant fields. """ auto_create_schema = True created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) class Meta: abstract = True
Class Org(BaseModel):
username = models.OneToOneField(User) name = models.CharField(max_length=500, null=True, blank=True) slug = models.SlugField(null=True, blank=True) website = models.URLField(max_length=500, null=True, blank=True) primary_focus = models.CharField(max_length=500, null=True, blank=True, help_text='Very briefly, what is your prime focus?') established_in = models.DateField(help_text = "MM/DD/YYYY") description = models.TextField(help_text = "Brief Description of what your NGO is into.")
paid_until = models.DateField()
on_trial = models.BooleanField()def save(self, _args, *_kwargs):
self.slug = slugify(self.name[0:50])
super(Org, self).save(_args, *_kwargs)def unicode(self):
return self.name—
Reply to this email directly or view it on GitHubhttps://github.com//issues/48#issuecomment-19856568
.
Bernardo Pires Carneiro
from django-tenant-schemas.
Same as #43
from django-tenant-schemas.
Related Issues (20)
- 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
- About changing public schema to other schema. HOT 2
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.