source /opt/myenv/bin/activate
cd /opt/myenv/myproject/
./manage.py startapp news
(myenv) user@u_18_s:/opt/myenv/myproject$ ls
db.sqlite3 manage.py myproject static
(myenv) user@u_18_s:/opt/myenv/myproject$ ./manage.py startapp news
(myenv) user@u_18_s:/opt/myenv/myproject$ ls
db.sqlite3 manage.py myproject news static
edit
vi myproject/settings.py
vi myproject/settings.py
add
to
'news',
to
INSTALLED_APPS = [
save it
________________
(myenv) user@u_18_s:/opt/myenv/myproject$ vi news/models.py
_____________________
class Article(models.Model):
title = models.CharField(max_length=225)
text = models.TextField()
pub_date = models.DateField(auto_now_add=True)
_____________
(myenv) user@u_18_s:/opt/myenv/myproject$ ./manage.py makemigrations
Migrations for 'news':
news/migrations/0001_initial.py
- Create model Article
add to:
(myenv) user@u_18_s:/opt/myenv/myproject$ vi news/admin.py
from .models import Article
admin.site.register(Article)
______________________________________
adding func to :
user@u_18_s:/opt/myenv/myproject$ vi news/views.py
from django.shortcuts import HttpResponceadding to the "router" - /urls.py "template" for working with func "show_news" :
def show_news(request):
return HttpResponse(u'Hello World')
Комментариев нет:
Отправить комментарий