E
E
Egorian2018-04-14 17:43:26
Django
Egorian, 2018-04-14 17:43:26

Django.ModuleNotFoundError: No module named 'news'?

Created the news app.

#urls.py
from django.urls import path,include
from django.conf.urls import url
from django.views.generic import ListView,DetailView
from news.models import Articles
urlpatterns = [

    path(r'/^$',ListView.as_view(queryset=Articles.objects.all().order_by("-date")[:20],template_name="news/posts.html" ) ),

]
#models.py
from django.db import models


class Articles(models.Model):
    title=models.CharField(max_length=120)
    post=models.TextField()
    date=models.DateTimeField()
    def __str__(self):
        return self.title

On the command line I type python manage.py migrate and it gives me an error ModuleNotFoundError: No module named 'news'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-04-14
@Egorian

The 'news' module was not added to the INSTALLED_APPS = [] block in settings.py

INSTALLED_APPS = [
    ...
    'news'
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question