R
R
RockyMotion2019-04-22 17:30:06
Django
RockyMotion, 2019-04-22 17:30:06

Django server won't start, has anyone encountered this error?

I'm trying to create a simple django blog, made a project, made an application.
Launched, everything works. I registered my blog in the setting:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog'
]

Registered links to the blog in urls.py
from django.contrib import admin
from django.urls import path
from django.urls import include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('blog/', include('blog.urls'))

I created urls.py in the application and registered there
from django.urls import path
from .views import  *

urlpatterns = [
    path('', posts_list)
]

In the application in view.py I wrote:
from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.

def posts_list(request):
    return HttpResponse('<h1> Hello Word </h1>')

When starting the server, I get a long error, at the end LookupError: No installed app with label 'admin'.
Full text:
Traceback (most recent call last):
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\apps\registry.py", line 155, in get_app_config
    return self.app_configs[app_label]
KeyError: 'admin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ugrobug\PycharmProjects\site\blogengiene\manage.py", line 21, in <module>
    main()
  File "C:\Users\ugrobug\PycharmProjects\site\blogengiene\manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
    super().execute(*args, **options)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
    self.run(**options)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
    autoreload.run_with_reloader(self.inner_run, **options)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
    start_django(reloader, main_func, *args, **kwargs)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
    reloader.run(django_main_thread)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\autoreload.py", line 272, in run
    get_resolver().urlconf_module
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\ugrobug\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\ugrobug\PycharmProjects\site\blogengiene\blogengiene\urls.py", line 22, in <module>
    path('admin/', admin.site.urls),
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\functional.py", line 256, in inner
    self._setup()
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\contrib\admin\sites.py", line 529, in _setup
    AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
  File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
    raise LookupError(message)
LookupError: No installed app with label 'admin'.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Artyom Innokentiev, 2019-04-23
@artinnok

RockyMotion try the following steps:
1. write this INSTALLED_APPS:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog.apps.BlogConfig',
]

2. remove blogengine/blogengine nesting to just blogengine
3. rename blogengine - > config
4. start the server like this python manage.py runserver --settings config.settings basics :)

R
RockyMotion, 2019-04-23
@RockyMotion

I spent everything according to the official documentation - it worked, but it does not differ at all from the lessons I did. The only difference is I didn't use Pycharm to start projects and applications and start the server. Apparently he was the problem.

E
Elwen, 2017-03-14
@Elwen

The simplest option is to set the image as the background for the shared container and add backrgound-size: cover to it.

A
A person from Kazakhstan, 2017-03-14
@LenovoId

and if height is not specified at all?
for example like this:

img{
display:block;
width:100%;
}

and put the img in a container but with dimensions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question