Wednesday, April 21, 2021

Showing a landing page with django-tenants package

Hi!

I am studying the django-tenants (https://github.com/django-tenants/django-tenants) and when I acces the principal page, it doesn´t show the landing page, just a message:

------

Page not found (404)Request Method:
GETRequest URL:
http://127.0.0.1:8000/

Raised by:
core.views.home

No tenant for hostname "127.0.0.1"

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

-----

How I develop to show the primary page (landing page) ?


- Follow the structure of the project

from django.contrib import admin

from django.urls import path
from core.views import home


urlpatterns = [
path('admin/', admin.site.urls),
path('', home, name='home'),
]


-- Core app (landing page) - view


from django.shortcuts import render

def home(request):
return render(request, 'core/index.html')


-- Settings.py file

ALLOWED_HOSTS = ['*']


# Application definition

SHARED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_tenants',
'customer',

]


TENANT_APPS = [
# The following Django contrib apps must be in TENANT_APPS
'django.contrib.contenttypes',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',

# your tenant-specific apps
'myclientapp',
'core',

]

INSTALLED_APPS = list(set(SHARED_APPS + TENANT_APPS))

Thank you very much!

Gabriel.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/11b1a789-66ae-4f61-b06e-3cf0fed96e8cn%40googlegroups.com.

No comments:

Post a Comment