django.db.utils.ProgrammingError: relation "users_user" does not exist - django

I'm trying to migrate my apps, so this error it's happening "django.db.utils.ProgrammingError: relation "users_user" does not exist".
I tried with many ways and this not running. I'm using multi-tenant configuration. Help me please.
My manage.py migrate_schemas --list
[standard:public] admin
[standard:public] [ ] 0001_initial
[standard:public] [ ] 0002_logentry_remove_auto_add
[standard:public] [ ] 0003_auto_20171127_1309
[standard:public] auth
[standard:public] [X] 0001_initial
[standard:public] [X] 0002_alter_permission_name_max_length
[standard:public] [X] 0003_alter_user_email_max_length
[standard:public] [X] 0004_alter_user_username_opts
[standard:public] [X] 0005_alter_user_last_login_null
[standard:public] [X] 0006_require_contenttypes_0002
[standard:public] [X] 0007_alter_validators_add_error_messages
[standard:public] contenttypes
[standard:public] [X] 0001_initial
[standard:public] [X] 0002_remove_content_type_name
[standard:public] foundation
[standard:public] (no migrations)
[standard:public] sessions
[standard:public] [ ] 0001_initial
[standard:public] sites
[standard:public] [X] 0001_initial
[standard:public] [X] 0002_alter_domain_unique
[standard:public] tenants
[standard:public] (no migrations)
[standard:public] users
[standard:public] [X] 0001_initial
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 350, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line
348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line
399, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-
packages\tenant_schemas\management\commands\migrate_schemas.py", line 53,
in handle
executor.run_migrations(tenants=tenants)
File "C:\Python27\lib\site-
packages\tenant_schemas\migration_executors\base.py", line 57, in
run_migrations
if public_schema_name in tenants:
TypeError: argument of type 'TenantQueryset' is not iterable
settings.py
"""
Django settings for ViaPortal_2 project.
Generated by 'django-admin startproject' using Django 1.9.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*3*_u^(l*1ayvv+k578+^32u8ble*^d&#n=91ou%th0&1bp60^'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['softvini.pythonanywhere.com',u'localhost' ]
# Application definition
SHARED_APPS = (
'tenant_schemas', # mandatory, should always be before any django app
'tenants', # you must list the app where your tenant model resides in
'django.contrib.contenttypes',
# everything below here is optional
'django.contrib.auth',
'django.contrib.sessions',
# 'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
)
TENANT_APPS = (
'django.contrib.contenttypes',
# your tenant-specific apps
'users',
'foundation',
'notifications',
)
INSTALLED_APPS = [
'tenant_schemas',
'tenants',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
#'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'widget_tweaks',
'foundation',
'users',
'notifications',
'main',
]
TENANT_MODEL = "tenants.Tenant" # app.Model
AUTH_USER_MODEL = 'users.User'
LOGIN_URL = 'auth/login/'
DATABASE_ROUTERS = (
'tenant_schemas.routers.TenantSyncRouter',
)
MIDDLEWARE_CLASSES = [
'tenant_schemas.middleware.TenantMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
MIGRATION_MODULES = {
'sites': 'contrib.sites.migrations'
}
ROOT_URLCONF = 'ViaPortal_2.urls'
'''
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
'''
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(PROJECT_PATH, 'templates'),],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'ViaPortal_2.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'tenant_schemas.postgresql_backend',
'NAME': 'viaportal_py',
'USER': 'postgres',
'PASSWORD': 'my_pass',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'pt-br'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_PATH )
MEDIA_ROOT = os.path.join(PROJECT_PATH,'media')
MEDIA_URL = '/media/'
DEFAULT_FILE_STORAGE = 'tenant_schemas.storage.TenantFileSystemStorage'
STATICFILES_DIRS = (
os.path.join(PROJECT_PATH, '/static/'),
# '/var/www/static/',
)
>
users.models.py
# -- coding: utf-8 --
from future import unicode_literals
from django.utils.http import urlquote
from django.db import models
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
from django.contrib.auth.models import PermissionsMixin
class UserManager(BaseUserManager):
def create_user(self, *args, **kwargs):
email = kwargs["email"]
email = self.normalize_email(email)
password = kwargs["password"]
kwargs.pop("password")
if not email:
raise ValueError(_('É obrigatório informar um e-mail válido'))
user = self.model(**kwargs)
user.set_password(password)
user.save(using=self._db)
return user
def get_short_name(self):
"Returns the short name for the user."
return self.first_name
def create_superuser(self, *args, **kwargs):
user = self.create_user(**kwargs)
user.is_superuser = True
user.is_staff = True
user.save(using=self._db)
return user
#property
def is_superuser(self):
return self.is_admin
#property
def is_staff(self):
return self.is_admin
def has_perm(self, perm, obj=None):
return self.is_admin
def has_module_perms(self, app_label):
return self.is_admin
class User(PermissionsMixin, AbstractBaseUser):
email = models.EmailField(
verbose_name = ('Endereco de e-mail'),
unique=True,
)
first_name = models.CharField(
verbose_name = ('Nome'),
max_length=50,
blank=False,
help_text= ('Informe seu nome'),
)
last_name = models.CharField(
verbose_name= ('Sobrenome'),
max_length=50,
blank=False,
help_text= ('Informe seu sobre nome'),
)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
is_staff = models.BooleanField(default=False)
empresa = models.ForeignKey('foundation.Empresa', blank=True, null=True)
estabelecimento = models.ForeignKey('foundation.Estabelecimento', blank=True, null=True)
def get_absolute_url(self):
return "/users/%s/" % urlquote(self.pk)
def get_full_name(self):
"""
Returns the first_name plus the last_name, with a space in between.
"""
full_name = '%s %s' % (self.first_name, self.last_name)
return full_name.strip()
def get_short_name(self):
"Returns the short name for the user."
return self.first_name
USERNAME_FIELD = 'email'
objects = UserManager()
class Profile(models.Model):
user = models.OneToOneField(User, related_name='profile')
image_profile = models.ImageField(upload_to = 'static/users/', default = 'static/users/no-img.jpg')
Gender_Choices = (
('F', 'Feminino'),
('M', 'Masculino'),
('O', 'Outro'),
)
gender = models.CharField(max_length=1, choices= Gender_Choices)
description = models.TextField(max_length=300,blank=True, null=True)
foundation.models.py
# -- coding: utf-8 --
from future import unicode_literals
from django.db import models
from django.conf import settings
from datetime import datetime
from django.utils import timezone
# Create your models here.
# Create your models here.
class Empresa(models.Model):
cod_empresa = models.CharField(max_length=5, unique=True)
nome = models.CharField(max_length=100)
created_by = models.ForeignKey( settings.AUTH_USER_MODEL , related_name="creation_user_empresa",blank=True, null=True)
created_date = models.DateField(default=timezone.now,blank=True)
class Meta:
verbose_name = (u'Empresa')
verbose_name_plural = (u'Empresas')
def __str__(self):
return self.cod_empresa + " - " + self.nome
def __unicode__(self):
return self.cod_empresa + " - " + self.nome
class Estabelecimento(models.Model):
cod_estabelecimento = models.CharField(max_length=5, unique=True)
nome = models.CharField(max_length=100)
razao_social = models.CharField(max_length=1000, blank=True)
empresa = models.ForeignKey(Empresa)
logo_estab = models.ImageField(upload_to = 'estabelecimentos/', default = 'estabelecimentos/no-estabelec.png')
created_by = models.ForeignKey( settings.AUTH_USER_MODEL , related_name="creation_user_estabelecimento",blank=True, null=True)
created_date = models.DateField(default=timezone.now,blank=True)
class Meta:
verbose_name = (u'Estabelecimento')
verbose_name_plural = (u'Estabelecimentos')
def __str__(self):
return self.cod_estabelecimento + " - " + self.nome
def __unicode__(self):
return self.cod_estabelecimento + " - " + self.nome
class CentroCusto(models.Model):
cod_centrocusto = models.CharField(max_length=20, unique=True)
nome = models.CharField(max_length=100)
estabelecimento = models.ForeignKey(Estabelecimento)
created_by = models.ForeignKey( settings.AUTH_USER_MODEL , related_name="creation_user_centrocusto",blank=True, null=True)
created_date = models.DateField(default=timezone.now,blank=True)
class Meta:
verbose_name = (u'Centro de Custo')
verbose_name_plural = (u'Centros de Custos')
def __str__(self):
return self.cod_centrocusto + " - " + self.nome
def __unicode__(self):
return self.cod_centrocusto + " - " + self.nome
class Departamento(models.Model):
nome = models.CharField(max_length=100)
estabelecimento = models.ForeignKey(Estabelecimento)
centroCusto = models.ForeignKey(CentroCusto)
created_by = models.ForeignKey( settings.AUTH_USER_MODEL , related_name="creation_user_departamento" ,blank=True, null=True)
created_date = models.DateField(default=timezone.now,blank=True)
class Meta:
verbose_name = (u'Centro de Custo')
verbose_name_plural = (u'Centros de Custos')
def __str__(self):
return self.nome
def __unicode__(self):
return self.nome

did you manage to solve this issue ? If not, this is what worked for me:
SHARED_APPS = (
'tenant_schemas', # mandatory
'apps.user',
'apps.customer', # must list the app where tenant model resides in
'django.contrib.contenttypes',
# everything below here is optional
'rest_framework',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.staticfiles',
'django_extensions',
)
TENANT_APPS = (
'apps.user',
'apps.home',
'django.contrib.contenttypes',
# tenant-specific apps
)
INSTALLED_APPS = list(set(SHARED_APPS + TENANT_APPS))
Migration commands:
python manage.py makemigrations customer
python manage.py makemigrations user
python manage.py migrate_schemas --shared

Just as #mjoyshuvo said
'app.user'
should be on both TENANT_APPS and SHARED_APPS due to the fact that some apps in the shared apps try to reference it and it doesn't seems to exists.

Related

Django: TypeError: 'ModelSignal' object is not callable

I have a piece of code throwing an error:
TypeError: 'ModelSignal' object is not callable.
While I'm gonna add signals in my project, this error is occuring.
Why this type of error is occured? What you need to know to give my answer?
Please help me someone. I'm a newbie to Django. Thanks in advance.
Here is my views.py file:
def registerPage(request):
form = CreateUserForm()
if request.method == "POST":
form = CreateUserForm(request.POST)
if form.is_valid():
user =form.save()
username = form.cleaned_data.get('username')
messages.success(request, 'Account successfully created for ' + username)
return redirect ('login')
context = {'form': form}
return render(request, 'accounts/register.html', context)
My models.py file:
from django.db import models
from django.contrib.auth.models import User
class Student(models.Model):
user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE)
name = models.CharField(max_length=200)
phone = models.CharField(max_length=200, null=True)
email = models.CharField(max_length=200, null=True)
profile_pic = models.ImageField(default= 'default-picture.jpg', null= True, blank= True)
date_created = models.DateTimeField(auto_now_add=True, null=True)
def __str__(self):
return str(self.name)
My signals.py file:
from django.db.models.signals import post_save
from django.contrib.auth.models import Group, User
from .models import Student
def student_profile(sender, instance, created, **kwargs):
if created:
group = Group.objects.get(name = 'Student')
instance.groups.add(group)
Student.objects.create(
user = instance,
name = instance.username
)
post_save(student_profile, sender= User)
My apps.py file:
from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'
def ready(self):
import accounts.signals
And my settings.py file:
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '1dcgsc#63l$2w_%+90xqra#z=&(q!8sdxf*dg7k6=ptxi&k8o*'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts.apps.AccountsConfig',
'django_filters',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'cmp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'cmp.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Dhaka'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/images/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')
You are calling the post_save object which is not callable. Try post_save.connect().
from django.db.models.signals import post_save
from django.contrib.auth.models import Group, User
from .models import Student
def student_profile(sender, instance, created, **kwargs):
if created:
group = Group.objects.get(name = 'Student')
instance.groups.add(group)
Student.objects.create(
user = instance,
name = instance.username
)
post_save.connect(student_profile, sender= User)
Or you can also try using receiver decorator:
from django.db.models.signals import post_save
from django.contrib.auth.models import Group, User
from django.dispatch import receiver
from .models import Student
#receiver(post_save, sender=User)
def student_profile(sender, instance, created, **kwargs):
if created:
group = Group.objects.get(name = 'Student')
instance.groups.add(group)
Student.objects.create(
user = instance,
name = instance.username
).save()

Django cannot locate a template

I am trying to make a customer and employee login and register page...however whenever I try to go to localhost:8000/customer register, I get a page not found error not found error. this is my
urls.py file:
from django.contrib import admin
from django.urls import path
from accounts import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.register, name = 'register'),
path('customer_resgister', views.customer_register.as_view(), name = 'customer_register'),
]
views.py:
from django.shortcuts import render
from django.views.generic import CreateView
from .models import User, Customer, Employee
from .forms import CustomerSignupForm, EmployeeSignupForm
# Create your views here.
def register(request):
return render(request, 'accounts/register.html')
class customer_register(CreateView):
model = User
form_class = CustomerSignupForm
template_name = 'accounts/customer_register.html'
#def customer_register(request):
models.py:
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
is_customer = models.BooleanField(default=False)
is_employee = models.BooleanField(default=False)
first_name = models.CharField(max_length = 150)
last_name = models.CharField(max_length = 150)
class Customer(models.Model):
user = models.OneToOneField(User, on_delete = models.CASCADE, primary_key = True)
Phone_no = models.CharField(max_length = 10)
location = models.CharField(max_length = 150)
class Employee(models.Model):
user = models.OneToOneField(User, on_delete = models.CASCADE, primary_key = True)
Phone_no = models.CharField(max_length = 10)
designation = models.CharField(max_length = 150)
forms.py:
from django.contrib.auth.forms import UserCreationForm
from django.db import transaction
from .models import Customer, Employee, User
from django import forms
class CustomerSignupForm(UserCreationForm):
first_name = forms.CharField(required = True)
last_name = forms.CharField(required = True)
phone_no = forms.CharField(required = True)
class Meta(UserCreationForm.Meta):
model = User
#transaction.atomic
def data_save(self):
user = super().save(commit = False)
user.first_name = self.cleaned_data.get('first_name')
user.last_name = self.cleaned_data.get('last_name')
user.save()
customer = Customer.objects.create(user = user)
customer.phone_no = self.cleaned_data.get('phone_no')
customer.save()
return user
class EmployeeSignupForm(UserCreationForm):
first_name = forms.CharField(required = True)
last_name = forms.CharField(required = True)
designation = forms.CharField(required = True)
class Meta(UserCreationForm.Meta):
model = User
#transaction.atomic
def data_save(self):
user = super().save(commit = False)
user.first_name = self.cleaned_data.get('first_name')
user.last_name = self.cleaned_data.get('last_name')
user.save()
employee = Employee.objects.create(user = user)
employee.phone_no = self.cleaned_data.get('phone_no')
employee.designation = self.cleaned_data.get('designation')
customer.save()
return user
settings.py:
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'apk-h*1!*f-=^6zw^_q0q!z6att9f+exfr+k(!awfvybu^x(l%'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
AUTH_USER_MODEL = 'accounts.User'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'demo_register.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'demo_register.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
All my templates are stored in accounts/templates/accounts
I don't know what am I doing wrong here...please help.
I don’t think the issue is with your templates. A 404 error shows when the url cannot map to the correct view.
You can share the error page snippet and you can also try and add a slash to your url path for customer_register
You have a typo in the third path in url_patterns, it should be register instead of 'resgister'.
Use space instead of underscore
url_patterns = [
path('customer register', views.customer_register.as_view(), name = 'customer_register')
]

In django admin database I am not getting expected view

In django admin database I am not getting expected view. I am following the tutorials to make a quiz app in Django. I did exactly as shown in video but still I am not getting same output. I have attached the picture of expected view and picture of what I am getting.
Getting This:
Expecting This:
models.py (in quiz):
from django.db import models
from django.contrib.auth import get_user_model
User = get_user_model()
# Create your models here.
class Quiz(models.Model):
name = models.CharField(max_length=255)
description = models.CharField(max_length=70)
slug = models.SlugField(blank=True)
roll_out = models.BooleanField(default=False)
timestamp = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ['timestamp',]
verbose_name_plural = 'Quizzes'
def __str__(self):
return self.name
class Question(models.Model):
quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE, related_name='questions')
label = models.CharField('Question', max_length=255)
order = models.IntegerField(default=0)
def __str__(self):
return self.label
class Answer(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name='answers')
label = models.CharField('Answer', max_length=255)
is_correct = models.BooleanField('Correct answer', default=False)
def __str__(self):
return self.label
class QuizTaker(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE)
score = models.IntegerField(default=0)
completed = models.BooleanField(default=False)
date_finished = models.DateTimeField()
timestamp = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.user.username
class UserAnswer(models.Model):
quiz_taker = models.ForeignKey(QuizTaker,on_delete=models.CASCADE)
quistion = models.ForeignKey(Question,on_delete=models.CASCADE)
answer = models.ForeignKey(Answer,on_delete=models.CASCADE)
def __str__(self):
return self.question.label
In admin.py
from django.contrib import admin
import nested_admin
from .models import Quiz, Question, Answer, QuizTaker, UserAnswer
# Register your models here.
class AnswerInline(nested_admin.NestedTabularInline):
model = Answer
extra = 4
max_num = 4
class QuestionInline(nested_admin.NestedTabularInline):
model = Question
inline = [AnswerInline]
extra = 5
class QuizAdmin(nested_admin.NestedModelAdmin):
inline = [QuestionInline,]
class UserAnswerInline(admin.TabularInline):
model = UserAnswer
class QuizTakerAdmin(admin.ModelAdmin):
inline = [UserAnswerInline,]
admin.site.register(Quiz,QuizAdmin)
admin.site.register(Question)
admin.site.register(Answer)
admin.site.register(QuizTaker,QuizTakerAdmin)
admin.site.register(UserAnswer)
In settings.py
"""
Django settings for assignment2 project.
Generated by 'django-admin startproject' using Django 2.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR,'templates')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'u1e72cel3t20c3m5wvetnl*7w6x8srf4f#ncx6x=7*0k-w^#%x'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'bootstrap4',
'accounts.apps.AccountsConfig',
'quiz',
'nested_admin',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'assignment2.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATE_DIR],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'assignment2.wsgi.application'
ASGI_APPLICATION = 'assignment.routing.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
LOGIN_REDIRECT_URL = 'test'
LOGOUT_REDIRECT_URL = 'thanks'
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR,'static')]
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/

how can i see django database that is storing values on its own from site server?

I am trying to store the questions tag in sqlite3 of Django but whenever I am trying to click on Question in /admin/ it shows error :
error image
in case image is not displayed, this is error
{
OperationalError at /admin/userinfo/question/
no such table: userinfo_question
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/userinfo/question/
Django Version: 3.0.5
Exception Type: OperationalError
Exception Value:
no such table: userinfo_question
}
I have already tried
changing sqlite3 path in settings (error not resolved same error)
python manage.py migrate --run-syncdb (after applying makemigrations)(migrations apply error not resolved)
this was written while doing migrations
Creating tables...
Running deferred SQL...
so I am thinking that the table is creating but not displaying( might be)
this is my models.py
'''
from django.db import models
# Create your models here.
class Question(models.Model):
prob_link = models.CharField(max_length=500, default='')
prob_level = models.CharField(max_length=1)
prob_rating = models.IntegerField()
expression_parsing = models.BooleanField(default=False)
fft = models.BooleanField(default=False)
two_pointers = models.BooleanField(default=False)
binary_search = models.BooleanField(default=False)
dsu = models.BooleanField(default=False)
strings = models.BooleanField(default=False)
number_theory = models.BooleanField(default=False)
data_structures = models.BooleanField(default=False)
hashing = models.BooleanField(default=False)
shortest_paths = models.BooleanField(default=False)
matrices = models.BooleanField(default=False)
string_suffix_structures = models.BooleanField(default=False)
graph_matchings = models.BooleanField(default=False)
dp = models.BooleanField(default=False)
dfs_and_similar = models.BooleanField(default=False)
meet_in_the_middle = models.BooleanField(default=False)
games = models.BooleanField(default=False)
schedules = models.BooleanField(default=False)
constructive_algorithms = models.BooleanField(default=False)
greedy = models.BooleanField(default=False)
bitmasks = models.BooleanField(default=False)
divide_and_conquer = models.BooleanField(default=False)
flows = models.BooleanField(default=False)
geometry = models.BooleanField(default=False)
math = models.BooleanField(default=False)
sortings = models.BooleanField(default=False)
ternary_search = models.BooleanField(default=False)
combinatorics = models.BooleanField(default=False)
brute_force = models.BooleanField(default=False)
implementation = models.BooleanField(default=False)
sat_2 = models.BooleanField(default=False)
trees = models.BooleanField(default=False)
probabilities = models.BooleanField(default=False)
graphs = models.BooleanField(default=False)
chinese_remainder_theorem = models.BooleanField(default=False)
interactive = models.BooleanField(default=False)
other_tag = models.BooleanField(default=False)
special_problem = models.BooleanField(default=False)
'''
here is settings.py
"""
Django settings for codeforces_crawler project.
Generated by 'django-admin startproject' using Django 3.0.2.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'sp_$b%e_g1v)eam^rqlef5v8##&6qhxw1&2f6me^c!b^v+rkwl'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'userinfo.apps.UserinfoConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'codeforces_crawler.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'codeforces_crawler.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
this is views.py
from django.shortcuts import render
from .scraping import scrape
def index(request):
return render(request, 'userinfo/index.html')
def detail(request):
user = request.POST['user'] # user is the name of the input
# rank,color,ar,institute,ac,wa,tle,rte,mle,challenged,cpe,skipped,ile,other = scrape(user)
verdict = scrape(user)
if verdict == False:
exists = verdict
return render(request, 'userinfo/detail.html', {'exists': exists})
else:
exists = verdict[0]
rank = verdict[1]
color = verdict[2]
ar = verdict[3]
institute = verdict[4]
ac = verdict[5]
wa = verdict[6]
tle = verdict[7]
rte = verdict[8]
mle = verdict[9]
challenged = verdict[10]
cpe = verdict[11]
skipped = verdict[12]
ile = verdict[13]
other = verdict[14]
rating = verdict[15]
return render(request, 'userinfo/detail.html',
{'exists': exists, 'user': user, 'rank': rank, 'color': color, 'ar': ar, 'institute': institute,
'ac': ac, 'wa': wa, 'tle': tle, 'rte': rte, 'mle': mle, 'challenged': challenged
, 'cpe': cpe, 'skipped': skipped, 'ile': ile, 'other': other, 'rating': rating})
# return render(request, 'userinfo/detail.html', {'user': user, 'verdict':verdict,})
this is admin.py
'''
from django.contrib import admin
from .models import Question
# Register your models here.
admin.site.register(Question)
'''
this is url.py
from django.urls import path
from . import views
app_name = 'userinfo'
urlpatterns = [
path('',views.index, name='index'),
path('detail/',views.detail,name='detail'),
]
or if there is any other method to see what questions had been added in my database.
Not able to resolve this error for the last 3 days.Thanks in advance for your help.
The error message "no such table: userinfo_question" indicates that Django has not turned your model representation into tables within your database.
Check that your app userinfo is listed under INSTALLED_APPS in settings.py.
You should also run makemigrations before running migrate
python manage.py makemigrations

Django custom User model results in AttributeError: Manager isn't available; 'auth.User' has been swapped for 'authentication.User'

In my django app, called authentication, I created a custom user model, mostly following the django documentation.
In a previous project of mine it used to work, but now when I say:
user = User.objects.get(username=username)
I'm constantly facing an error:
AttributeError: Manager isn't available; 'auth.User' has been swapped for 'authentication.User'.
I've tested it with both python2 and python3, django versions 1.9 and 1.10
What might be wrong?
My code:
models.py:
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, \
BaseUserManager, PermissionsMixin
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
import uuid
import base64
class UserManager(BaseUserManager):
def create_user(self, username, email, name, password=None):
user = self.model(
username=username,
email=email,
name=name,
last_login=timezone.now()
) # last_login is defined in AbstractBaseUser
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, username, password):
user = self.create_user(
username=username,
email=None,
name=username,
password=password
)
user.is_staff = True
user.is_superuser = True
user.save(using=self._db)
return user
def generate_registration_code():
return "asd"
class User(AbstractBaseUser, PermissionsMixin):
# This model should be created in the firest migration:
# https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#substituting-a-custom-user-model
# We use username, not email as primary user id, because OAuth
# implementation via python-social-auth requires this field to
# be present.
username = models.CharField(
verbose_name=_('username'),
max_length=255,
unique=True
)
email = models.EmailField(null=True, blank=True)
# name is a human-readable name used to refer to user e.g. "Martin Taylor"
# longest full name registered in guinness book is 744 letters-long
name = models.CharField(
verbose_name=_('name'),
max_length=1023,
null=True,
blank=True
)
# We don't need password and last_login fields, because they are
# already defined in AbstractBaseUser.
# is_active is a variable in AbstractBaseUser set to True, but we
# want a separate field for it.
is_active = models.BooleanField(
_('active'),
default=True,
help_text=_('Is this user account activated?')
)
is_staff = models.BooleanField(
_('staff status'),
default=False,
help_text=_('Is this user allowed to the admin page')
)
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
code = models.CharField(
null=True,
blank=True,
default=generate_registration_code,
max_length=255,
help_text=_('''
Code to be sent via e-mail upon registration
or password recovery.
''')
)
new_password = models.CharField(
null=True,
blank=True,
default="",
max_length=255,
help_text=_('''
If user is attempting to change password, this field stores new
password until user enters confirmation code.
''')
)
objects = UserManager()
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = []
class Meta:
verbose_name = _('user')
verbose_name_plural = _('users')
def __str__(self):
return self.username
def get_short_name(self):
return self.username
def get_full_name(self):
return self.username
settings.py:
"""
Django settings for simple_resserver_jwt project.
Generated by 'django-admin startproject' using Django 1.10.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
import datetime
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'co0)lyiwbgi4wz#80gp&y++bga-+iqd8hxq5boiw3d$g(#!yl*'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'authentication',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'simple_resserver_jwt.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'simple_resserver_jwt.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
AUTH_USER_MODEL = 'authentication.User'
AUTHENTICATION_BACKENDS = ['authentication.backends.AuthBackend', ]
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
)
}
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
with open('private') as f:
PRIVATE_KEY = f.readlines()
with open('public') as f:
PUBLIC_KEY = f.readlines()
JWT_AUTH = {
'JWT_ENCODE_HANDLER':
'authentication.utils.jwt_encode_handler',
'JWT_DECODE_HANDLER':
'authentication.utils.jwt_decode_handler',
# 'JWT_RESPONSE_PAYLOAD_HANDLER':
# 'authentication.utils.jwt_decode_handler',
'JWT_SECRET_KEY': PRIVATE_KEY,
'JWT_ALGORITHM': 'RS256',
'JWT_VERIFY': True,
'JWT_VERIFY_EXPIRATION': True,
'JWT_LEEWAY': 0,
'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=300),
'JWT_AUDIENCE': None,
'JWT_ISSUER': None,
'JWT_ALLOW_REFRESH': False,
'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=7),
'JWT_AUTH_HEADER_PREFIX': 'Bearer',
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
UPDATE:
Traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 474, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 434, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 471, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/rest_framework_jwt/views.py", line 56, in post
if serializer.is_valid():
File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py", line 214, in is_valid
self._validated_data = self.run_validation(self.initial_data)
File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py", line 411, in run_validation
value = self.validate(value)
File "/usr/local/lib/python3.5/dist-packages/rest_framework_jwt/serializers.py", line 50, in validate
user = authenticate(**credentials)
File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/__init__.py", line 74, in authenticate
user = backend.authenticate(**credentials)
File "/home/smith/Projects/simple_resserver_jwt/authentication/backends.py", line 13, in authenticate
user = User.objects.get(username=username)
File "/usr/local/lib/python3.5/dist-packages/django/db/models/manager.py", line 198, in __get__
cls._meta.swapped,
AttributeError: Manager isn't available; 'auth.User' has been swapped for 'authentication.User'