V
V
Vadim kyklaed2016-11-29 15:25:32
Django
Vadim kyklaed, 2016-11-29 15:25:32

How many times I encounter the error No module named 'blog.views' how else to fix it?

Please help solve this problem!
all the necessary code below
an error occurs and xs how to solve it, everything seems to be imported everywhere
No module named 'blog.views'
this urls is in the root of the project

from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
  url(r'^blog/', include('blog.urls')),
    url(r'^admin/', admin.site.urls),
]

this url is in the app
from django.conf.urls import url

from blog.views import PostsListView, PostDetailView

urlpatterns = [
  url(r'^$', PostsListView.as_view(), name='list'), 												
  url(r'^(?<pk>\d+)/$', PostDetailView.as_view()), 
                                  
]

this is a view
from blog.models import Post
from django.views.generic import ListView, DetailView

class PostListView (ListView): 
  model = Post 				

class PostDetailView (DetailView): 
  model = Post

this is a model
from django.db import models

class Post(models.Model):
  title = models.CharField(max_length = 225)
  datetime = models.DateTimeField(u'Дата публикации')
  content = models.TextField(max_length = 10000)

  def __unicide__(self):
    return self.title

  def get_absolute_url(self):
    return "/blog/{0}i/" .format(self.id)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
ThemeZV, 2016-11-29
@kyklaed

Is there an empty __init__.py file in the views directory?

Z
zelsky, 2016-11-29
@zelsky

blog is in INSTALLED_APPS ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question