Answer the question
In order to leave comments, you need to log in
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),
]
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()),
]
from blog.models import Post
from django.views.generic import ListView, DetailView
class PostListView (ListView):
model = Post
class PostDetailView (DetailView):
model = Post
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question