setting.py
INSTALLED_APPS = [
'articles.apps.ArticlesConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
models.py
from django.db import models
import django
django.setup()
class Article(models.Model):
article_title = models.CharField('Название статьи', max_Length = 200)
article_text = models.TextField('Текст статьи')
pub_date = models.DateTimeField('Дата публикации')
class Comment(models.Model):
article = models.ForeingKey(Article, on_delete = models.CASCADE)
author_name = models.CharField('Автор комментария', max_Length = 50)
comment_text = models.CharField('Комментарий', max_Length = 150)
views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("test")
Второй urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name = 'index'),
]
Главный urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('articles/', include('articles.urls')),
path('admin/', admin.site.urls)
]