Python Forum

Full Version: Lerning django 2.1, having problems with tutorial
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have done a load of googeling but can't quite get the tutorial at working:(.

So my project looks like this.

├── malmesburyonline
│   ├──
│   ├──
│   ├──
│   └──
└── polls
├── migrations
│   └──
Quote:from django.contrib import admin
from django.urls import path

from . import views

urlpatterns = [
path('polls/', include('polls.urls')),
Quote:from django.shortcuts import render

# Create your views here.

from django.http import HttpResponse

def index(request):
return HttpResponse("Hello, world. You're at the polls index.")

I can runserver but get 'Exception Value: Empty module name'. The traceback is below but i am stuck;(.

Environment: Request Method: GET Request URL: http://localhost:8000/ Django Version: 2.1.7 Python Version: 3.7.2 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'polls'] Installed Middleware: ['', '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'] Traceback: File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/handlers/" in inner 34. response = get_response(request) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/handlers/" in _get_response 111. resolver_match = resolver.resolve(request.path_info) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/" in resolve 491. for pattern in self.url_patterns: File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/" in __get__ 37. res = instance.__dict__[] = self.func(instance) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/" in url_patterns 533. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/" in __get__ 37. res = instance.__dict__[] = self.func(instance) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/" in urlconf_module 526. return import_module(self.urlconf_name) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/importlib/" in import_module 127. return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>" in _gcd_import 1003. <source code not available> File "<frozen importlib._bootstrap>" in _sanity_check 942. <source code not available> Exception Type: ValueError at / Exception Value: Empty module name

Actually the above is not right, it seems the problem is actually Internal Server Error: /favicon.ico. The traceback from the console is below.

So where do I put favicon.ico in there is "STATIC_URL = '/static/'" but there is no 'static' directory in filesystem.

Internal Server Error: /favicon.ico Traceback (most recent call last): File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/handlers/", line 34, in inner response = get_response(request) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/", line 90, in __call__ response = self.process_request(request) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/middleware/", line 52, in process_request if self.should_redirect_with_slash(request): File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/middleware/", line 70, in should_redirect_with_slash not is_valid_path(request.path_info, urlconf) and File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/", line 157, in is_valid_path resolve(path, urlconf) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/", line 24, in resolve return get_resolver(urlconf).resolve(path) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/", line 491, in resolve for pattern in self.url_patterns: File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/", line 37, in __get__ res = instance.__dict__[] = self.func(instance) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/", line 533, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/", line 37, in __get__ res = instance.__dict__[] = self.func(instance) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/", line 526, in urlconf_module return import_module(self.urlconf_name) File "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/importlib/", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1003, in _gcd_import File "<frozen importlib._bootstrap>", line 942, in _sanity_check ValueError: Empty module name
Have to tried restarting the server?
According to the rules:

Quote:Automatic reloading of runserver

The development server automatically reloads Python code for each request as needed. You don’t need to restart the server for code changes to take effect. However, some actions like adding files don’t trigger a restart, so you’ll have to restart the server in these cases.
This is why I ask.

Also try (for python 3) from command line:
sudo apt install python3-migrate
**Note** I had to run twice to get all updates.