Home python Problem with Django "ModuleNotFoundError: No module named"

Problem with Django “ModuleNotFoundError: No module named”

Author

Date

Category

Hello, working with Django 1.11

Created an application called blog , there is such a code in the urls of the project

from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
  url (r '^ admin /', admin.site.urls),
  url (r '^ $', include ('landing.urls')),
  url (r '^ blog /', include ('blog.urls.')),
]

in the very same blog there is a urls file:

from django.conf.urls import url
from. import views
urlpatterns = [
  url (r '^ blog /', views.blog, name = 'blog'),
]

There is also a file models

from django.db import models
from django.utils.timezone import datetime
class Category (models.Model):
  name = models.CharField (max_length = 128, unique = True),
  class Meta:
    verbose_name_plural = 'Categories'
  def __str __ (self):
    return self.name
class Post (models.Model):
  category = models.ForeignKey (Category)
  title = models.CharField (max_length = 128)
  text = models.CharField ()
  date_post = models.DateTimeField (auto_now_add = True)
  def __str __ (self):
    return self.title

file views :

from django.shortcuts import render
def blog (request):
  return render (request, 'blog / blog.html')

admin :

from django.contrib import admin
from .models import Category, Post
admin.site.register (Category)
admin.site.register (Post)

and clean html file

When running the command python3 manage.py makemigrations , it gives an error:

Traceback (most recent call last):
 File "manage.py", line 22, in & lt; module & gt;
  execute_from_command_line (sys.argv)
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site- packages / django / core / management / __ init__.py", line 364, in execute_from_command_line
  utility.execute ()
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
  self.fetch_command (subcommand) .run_from_argv (self.argv)
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
  self.execute (* args, ** cmd_options)
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/core/management/base.py", line 327, in execute
  self.check ()
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks = include_deployment_checks,
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
  return checks.run_checks (** kwargs)
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
  new_errors = check (app_configs = app_configs)
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
  return check_resolver (resolver)
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
  return check_method ()
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
  for pattern in self.url_patterns:
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
  res = instance .__ dict __ [self.name] = self.func (instance) 
File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/urls/resolvers.py", Line 405, in URL_PATTERNS
  Patterns = GetAttr (Self.urlconf_Module, "URLPATTERNS", Self.urlconf_Module)
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
  Res = Instance .__ DICT __ [Self.name] = Self.func (Instance)
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/urls/resolvers.py", Line 398, in urlconf_module
  Return Import_Module (Self.urlconf_name)
 File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
  return _bootstrap._gcd_import (name [LEVEL:], Package, Level)
 File "& lt; frozen importlib._bootstrap & gt;", Line 978, in _gcd_import
 File "& lt; frozen importlib._bootstrap & gt;", Line 961, in _find_and_load
 File "& lt; frozen importlib._bootstrap & gt;", Line 950, in _find_and_load_unlocked
 File "& lt; frozen importlib._bootstrap & gt;", Line 655, in _load_unlocked
 File "& lt; frozen importlib._bootstrap_external & gt;", Line 678, in exec_module
 File "& lt; frozen importlib._bootstrap & gt;", Line 205, in _call_with_frames_removed
 File "/home/milkiweed/python/django/psy_site/psy_site/urls.py", line 22, in & lt; module & gt;
  URL (R '^ Blog /', Include ('blog.urls'))
 File "/home/milkiweed/python/venvs/tango_with_django/lib/python3.6/site-packages/django/conf/urls/__init__.py", line 50, in include
  URLCONF_Module = Import_Module (URLCONF_MODULE)
 File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
  return _bootstrap._gcd_import (name [LEVEL:], Package, Level)
 File "& lt; frozen importlib._bootstrap & gt;", Line 978, in _gcd_import
 File "& lt; frozen importlib._bootstrap & gt;", Line 961, in _find_and_load
 File "& lt; frozen importlib._bootstrap & gt;", Line 945, in _find_and_load_unlocked
MODULENOTFOUNDERROR: NO MODULE NAMED 'BLOG.URLS.'; 'blog.urls' is not a package

Answer 1, Authority 100%

The problem was solved.
In the file URLS.py there was an extra comma URL (R '^ Blog /', Include ('blog.urls.')),

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions