Authenticating user problem with django-tenant-schema - django

I want to have admin module available to tenants (using django-tenant-schema).
My apps section of settings.py:
# Application definition
SHARED_APPS = (
'tenant_schemas', # mandatory, should always be before any django app
'customers', # you must list the app where your tenant model resides in
# 'django.contrib.sites',
# everything below here is optional
)
TENANT_APPS = (
'django.contrib.contenttypes',
# your tenant-specific apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
INSTALLED_APPS = (
'tenant_schemas', # mandatory, should always be before any django app
'customers',
# 'django.contrib.sites', #using this will cause error - see my stackoverflow question
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
I have set up 2 schemas (tenant1 and public). Created superuser and can see that superuser is created within tenant1 schema. However when trying to log in at tenant1.domain.com/admin, getting login screen but after entering credentials keep getting:
ProgrammingError at /admin/login/ relation "auth_user" does not exist
Looks like it is not picking up my tenant1 schema?
What I have to change in configuration?

Make sure tenant middleware is installed.
It's responsible for negotiating which tenant is called and connecting to the right schemas.

Related

AUTH_USER_MODEL reference in settings.py Django

I have a installed an app called 'Login', who have a folder 'models' inside, with a custom_user model. The problem occurs when I tried to configure settings.py, specially auth_user_model.
in installed apps I have the following:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'project_app.login'
]
and below
AUTH_USER_MODEL = 'login.models.CustomUser'
But I have the following error: "Invalid model reference. String model references must be of the form 'app_label.ModelName'." I put the .models in AUTH_USER_MODEL, because I want to reference the app that the CustomUser is inside the folder "models" in Login.
Also, I tried with declare like this:
AUTH_USER_MODEL = 'login.CustomUser'
but the error is this: 'AUTH_USER_MODEL refers to model 'login.CustomUser' that has not been installed'
The issue is with the way that your app is installed - based on your AUTH_USER_MODEL, login should be the name of the app. It is acceptable to contain Django apps within folders for organisation purposes - however, your parent folder is project_app which from the name also appears to be an app. It's hard to say for certain what the issue is without knowing your project structure but I would expect changing your installed apps to just project_app and your AUTH_USER_MODEL to project_app.CustomerUser should work.
If your app name is "login", you can proceed as follows:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
#apps
'login.apps.LoginConfig']
I think the model in your login application is as follows:
class CustomUser(AbstractBaseUser):
#some fields for customuser
and in settings.py:
AUTH_USER_MODEL = 'user.CustomUser'
AUTH_USER_MODEL = 'app_name.ModelName'

improperly configured app in settings.py of django

Tying to register my djano app in the settings section of my django project. but when i run the server i am getting an error in the terminal.
django.core.exceptions.ImproperlyConfigured: 'site1app.apps' does not contain a class 'Site1appConfig'. Choices are: 'Site1AppConfig'.
I dont know what's going wrong as i just added it to the list of installed apps in settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'site1app.apps.Site1appConfig',
]
This looks like a miss on the capitalization for your class
Change:
'site1app.apps.Site1appConfig'
To:
'site1app.apps.Site1AppConfig'

ImportError: cannot import name model

Hello everyone.
This is the first time I ask for help on StackOverflow, so please forgive me if my question here is clear enough... I will gladly provide anything you ask me for in order to have a better understanding of this issue
I have Django project that is not importing a model from an app that is registered on my settings.
This app has been working good until 2 day ago, but I haven't made any changes related to models.
I have tried many things to fix this issue but still giving me the same error...
I can't import anything coming from the models on any of my apps...
This is very frustrating. Please some advise
INSTALLED_APPS = (
# Django Applications
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.sitemaps',
# 'satchmo_store.shop',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.staticfiles',
'django.contrib.messages',
'django_comments',
'django.contrib.humanize',
# Reorder admin apps
'admin_reorder',
# Third Party Django Applications
## 'django_extensions',
'photologue',
'sorl.thumbnail',
'filebrowser',
'widget_tweaks',
'snowpenguin.django.recaptcha2',
'tinymce',
'django_extensions',
'model_utils',
'cart',
'anymail',
'rest_framework',
'storages',
# 'django_s3_storage',
'my_project.libs.chunks',
'my_project.apps.definition',
'my_project.apps.makeaword',
'my_project.apps.tellinstories',
'my_project.apps.wordsearch',
'my_project.libs.payflowpro',
# Project Applications
'my_project.apps.accounts',
'my_project.apps.book',
'my_project.apps.general',
'my_project.apps.illustrate',
'my_project.apps.write',
'my_project.apps.pressroom',
'my_project.apps.images',
'my_project.apps.comic',
'my_project.apps.library',
'my_project.apps.reports',
'my_project.apps.orders',
'my_project.apps.gift_cards',
'my_project.apps.stationary',
'my_project.apps.invoices',
'my_project.apps.cart_itt',
)
Import like:
from general.models import GiftCardOrders

Django Celery and Django Debug Toolbar confilcts

I have followed the celery documentation. yesterday i am able to update the Djcelery models in my Django admin. But today i am not able to update those models. I installed Django toolbar yesterday does it have any impact on functionality
Below is the Django admin screen shot with DDT included in settings.py
Below is the screenshot of Django admin without DDT included in setting.py
Installed Apps
INSTALLED_APPS = (
# django stuff
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# plugins
'precompressed', # https://github.com/jhmaddox/django-precompressed
'social.apps.django_app.default', # http://python-social-auth.readthedocs.org/en/latest/configuration/django.html
'rest_framework', # https://github.com/tomchristie/django-rest-framework
'djcelery', # https://github.com/celery/django-celery
'celery_admin', # https://github.com/mattcaldwell/django-celery-admin-ext
'taggit', # https://github.com/alex/django-taggit
'south', # http://south.readthedocs.org/en/latest/
'storages', # http://django-storages.readthedocs.org/en/latest/
'redactor', # https://github.com/douglasmiranda/django-wysiwyg-redactor
'haystack', # http://django-haystack.readthedocs.org/en/latest/toc.html
'boomers.apps.djangoratings', #https://github.com/dcramer/django-ratings
'crowdsourcing',
# apps
'apps',
'apps.billing.chase',
'apps.billing.paypal',
'apps.billing.amazon',
'apps.config',
'apps.users',
'apps.learn',
'apps.community',
'api.careerbuilder',
'apps.care',
'apps.go',
'apps.play',
'apps.plan',
'apps.uplus',
'apps.billing',
'apps.googleanalytics',
)
and i have appended this INSTALLED_APPS += ('debug_toolbar',)

No available plugins for templates

I'm following the Django-CMS introductory tutorial and have got everything working up to the point where I can run my server and access the admin interface.
However, when I add a page, I cannot select any plugin, it just says No Plugins present. Add a plugin to this placeholder-slot.
In my settings.py file I have:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'cms',
'mptt',
'menus',
'south',
'sekizai',
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
What am I doing wrong here?
Plugins in django-cms are being discovered by looking for cms_plugins module inside each of INSTALLED_APPS. Plugins shipped with the CMS are stored in several separate modules so you should add a line for each of your desired plugins:
INSTALLED_APPS = (
...
'cms.plugins.flash',
'cms.plugins.googlemap',
...
)