2

Django version: 2.0
Python: 3.6.5
Error: Model class user.models.Users doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
I have just add model Users to my views.

base.py:

DJANGO_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites'
]

THIRD_PARTY_APPS = [
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
]

LOCAL_APPS = [
    'clockingIn.users.apps.UserConfig',
]

INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

views.py:

from django.http import HttpResponse
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views import generic

from .models import Users


class UsersList(LoginRequiredMixin, generic.ListView):
    raise_exception = True
    model = Users

    def get_queryset(self):
        return ""


class UsersDetail(LoginRequiredMixin, generic.DetailView):
    raise_exception = True
    model = Users

    def get_queryset(self):
        return ""

model.py:

class Users(AbstractUser):

    uuid = models.UUIDField(_('uuid'), primary_key=True, default=uuid.uuid4)
    first_name = models.CharField(_('first name'), max_length=127, blank=True)
    last_name = models.CharField(_('first name'), max_length=127, blank=True)
    email = models.EmailField(_('email'), max_length=127, unique=True)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = []

    objects = CustomUserManager()
Tryliom
  • 111
  • 1
  • 17
  • `AUTH_USER_MODEL = 'yourapp.Users'` in your `settings.py` – Lemayzeur May 09 '18 at 15:45
  • 1
    What is the full name of the app that your models.py belongs to? This module should be in your LOCAL_APPS. I see "clockingIn.users.apps.UserConfig", but you haven't told us if that's the module in question. Would be helpful to see that file though, if it's relevant to your problem. – YellowShark May 09 '18 at 17:11

1 Answers1

0

In fact, the issue was that i have forgot the "clockingIn" before user in config/urls.py: url(r'^users/', include('clockingIn.users.urls'))

Tryliom
  • 111
  • 1
  • 17