N
N
Nickmort762019-10-29 18:44:38
css
Nickmort76, 2019-10-29 18:44:38

When trying to make migrations, errors are displayed, what should I do?

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")

Second urls.py
from django.urls import path

from . import views

urlpatterns = [
  path('', views.index, name = 'index'),
]

main urls.py
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
  path('articles/', include('articles.urls')),
    path('admin/', admin.site.urls)
]

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman, 2018-09-08
@RomanSocial

One of many choices :)

R
Roman Kitaev, 2019-10-29
@deliro

Yes

A
alternativshik, 2019-10-30
@alternativshik

OMG
import django
django.setup()
who teaches this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question