title: RuntimeError: Model class myapp.models.class doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
body: <p>This error has been addressed a lot of times but none of the answers seems to applied to me.
  I am fairly experienced with Python 2 and 3. I used django for the first time.I started making a project. As i was working with a basic DB and after i called the class.objects for the first time the title error occurred. After some time trying to fix it i moved to the django tutorial and i decided to do everything step by step. The error occured again specifically at &quot;Writing your first Django app, part 3&quot; right befor using render.</p>
  <p><strong>Directories:</strong></p>
  <pre><code>\home_dir
     \lib
     \Scripts
     \src
        \.idea
        \pages
        \polls
           \migrations
           __init__.py
           admin.py
           apps.py
           models.py
           test.py
           views.py
        \templates
        \django_proj
           __init__.py
           asgi.py
           manage.py
           settings.py
           urls.py
           wsgi.py
        __init__.py
        db.sqlite3
        manage.py
  </code></pre>
  <p>Do not bother with pages it's a test app.</p>
  <p><strong>django_proj\settings.py:</strong></p>
  <pre><code>INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'django.contrib.sites',
      # My App
      'polls'
      'pages'
  ]
  </code></pre>
  <p>TEMPLATES and DATABASES are well configured</p>
  <p><strong>polls\apps.py:</strong></p>
  <pre><code>from django.apps import AppConfig
  
  
  class PollsConfig(AppConfig):
      name = 'polls'
  </code></pre>
  <p><strong>polls\models.py</strong></p>
  <pre><code>from django.db import models
  from django.utils import timezone
  import datetime
  
  
  # Create your models here.
  class Question(models.Model):
      question_text = models.CharField(max_length=200)
      published_date = models.DateTimeField('date published')
      objects = models.Manager()
  
      def __str__(self):
          return self.question_text
  
      def was_pub_recently(self):
          return self.published_date &gt;= timezone.now() - datetime.timedelta(days=1)
  
  
  class Choice(models.Model):
      question = models.ForeignKey(Question, on_delete=models.CASCADE)
      choice_text = models.CharField(max_length=200)
      vote = models.IntegerField(default=0)
  
      def __str__(self):
          return self.choice_text
  </code></pre>
  <p><strong>polls\views.py</strong></p>
  <pre><code>from django.shortcuts import render
  from django.http import HttpResponse
  from src.polls.models import Question
  from django.template import loader
  
  
  # Create your views here.
  def index(request, *args, **kwargs):
      latest_question_list = Question.objects.order_by('-published_date'[:5])
      template = loader.get_template('polls/index.html')
      context = {
          'latest_question_list': latest_question_list
      }
      return HttpResponse(template.render(context, request))
  
  
  def details(request, question_id, *args, **kwargs):
      return HttpResponse(f&quot;Question: {question_id}&quot;)
  
  
  def results(request, question_id, *args, **kwargs):
      response = f&quot;Results for question {question_id}&quot;
      return HttpResponse(response)
  
  
  def vote(request, question_id, *args, **kwargs):
      return HttpResponse(f&quot;Vote on question {question_id}&quot;)
  </code></pre>
  <p><strong>django_proj\urls.py</strong></p>
  <pre><code>from django.contrib import admin
  from django.urls import include, path
  
  from src.pages.views import home_view, base_view, context_view
  from src.polls.views import index, details, results, vote
  
  urlpatterns = [
      path('', home_view, name='home'),
      path('admin/', admin.site.urls),
      path('base/', base_view, name='base'),
      path('context/', context_view, name=&quot;context&quot;),
      # Polls
      path('home/', index, name='index'),
      path('&lt;int:question_id&gt;/', details, name='details'),
      path('&lt;int:question_id&gt;/results/', results, name='results'),
      path('&lt;int:question_id&gt;/vote/', vote, name='vote'),
  ]
  </code></pre>
  <p><strong>Error:</strong></p>
  <pre><code>Traceback (most recent call last):
    File &quot;c:\users\panos\appdata\local\programs\python\python37-32\lib\threading.py&quot;, line 926, in _bootstrap_inner
      self.run()
    File &quot;c:\users\panos\appdata\local\programs\python\python37-32\lib\threading.py&quot;, line 870, in run
      self._target(*self._args, **self._kwargs)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\utils\autoreload.py&quot;, line 53, in wrapper
      fn(*args, **kwargs)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\core\management\commands\runserver.py&quot;, line 117, in inner_run
      self.check(display_num_errors=True)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\core\management\base.py&quot;, line 395, in check
      include_deployment_checks=include_deployment_checks,
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\core\management\base.py&quot;, line 382, in _run_checks
      return checks.run_checks(**kwargs)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\core\checks\registry.py&quot;, line 72, in run_checks
      new_errors = check(app_configs=app_configs)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\core\checks\urls.py&quot;, line 13, in check_url_config
      return check_resolver(resolver)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\core\checks\urls.py&quot;, line 23, in check_resolver
      return check_method()
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\urls\resolvers.py&quot;, line 407, in check
      for pattern in self.url_patterns:
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\utils\functional.py&quot;, line 48, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\urls\resolvers.py&quot;, line 588, in url_patterns
      patterns = getattr(self.urlconf_module, &quot;urlpatterns&quot;, self.urlconf_module)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\utils\functional.py&quot;, line 48, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\urls\resolvers.py&quot;, line 581, in urlconf_module
      return import_module(self.urlconf_name)
    File &quot;c:\users\panos\appdata\local\programs\python\python37-32\lib\importlib\__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1006, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 983, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 967, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 677, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 728, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 219, in _call_with_frames_removed
    File &quot;C:\Users\panos\Dev\cfehome\src\testdjango\urls.py&quot;, line 20, in &lt;module&gt;
      from src.polls.views import index, details, results, vote
    File &quot;C:\Users\panos\Dev\cfehome\src\polls\views.py&quot;, line 3, in &lt;module&gt;
      from .models import Question
    File &quot;C:\Users\panos\Dev\cfehome\src\polls\models.py&quot;, line 7, in &lt;module&gt;
      class Question(models.Model):
    File &quot;C:\Users\panos\Dev\cfehome\lib\site-packages\django\db\models\base.py&quot;, line 115, in __new__
      &quot;INSTALLED_APPS.&quot; % (module, name)
  RuntimeError: Model class src.polls.models.Question doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
  </code></pre>
  <p><strong>Python version 3.7</strong></p>
  <p><strong>Django version 3.0.4</strong></p>
  <p><strong>I have already tried:</strong></p>
  <p><a href="https://medium.com/@michal.bock/fix-weird-exceptions-when-running-django-tests-f58def71b59a" rel="nofollow noreferrer">https://medium.com/@michal.bock/fix-weird-exceptions-when-running-django-tests-f58def71b59a</a></p>
  <p><a href="https://stackoverflow.com/questions/40206569/django-model-doesnt-declare-an-explicit-app-label">Django model &quot;doesn&#39;t declare an explicit app_label&quot;</a></p>
  <p>and other two solutions but i dont have the links</p>
  <p>My speculation after 12 hours of trying to fix this is that is a compatibility issues or something really wrong with my imports and <strong>init</strong> files.</p>
  <p><strong>Edit.</strong>
  It seems like it was my mistake. For all those who encounter the same error firstly make sure you have your app into INSTALLED_APPS, next that all your files in you directories are well archived as django docs suggest (if you choose to make them in deferent way make sure you also fix your imports accordingly). Also don't use words in your names like django, test,.... because django's searchers may encounter them and override important django functions.</p>