воскресенье, 12 августа 2018 г.

03_Testing_django




 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
add

 'news',

to

INSTALLED_APPS = [

save it

________________

(myenv) user@u_18_s:/opt/myenv/myproject$ vi news/models.py

add:

_____________________
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 HttpResponce
def show_news(request):
    return HttpResponse(u'Hello World')
adding to the "router"  - /urls.py "template" for working with func  "show_news" :








Комментариев нет:

Отправить комментарий