Answer the question
In order to leave comments, you need to log in
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
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