-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
55 lines (36 loc) · 1.92 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
source myvenv/bin/activate
deactivate
django-admin startproject mysite . creates web app named mysite
django-admin startproject mysite creates web project named mysite with web app anem mysite as sub folder
python manage.py migrate django sets up
python manage.py runserver to start web browser
[Starting development server at http://127.0.0.1:8000/]]
python manage.py startapp blog to create our application blog for our django model
[after making model]
python manage.py makemigrations blog tells django that there are some changes in our model
[django gets signified and it prepares a migration file]
python manage.py migrate blog migrates the migration file prepared by django
http://127.0.0.1:8000/admin/ takes you to the admin page in our web app
[python manage.py createsuperuser]
git status
git add --all .
git commit -m "My Django Girls app, first commit"
[ $ git remote add origin https://github.com/<your-github-username>/my-first-blog.git ]==>probably one time command
git push [-u origin master]
web app deployment(pythonanywhere
[involves configuration of web app in my github, then creation of superuser) ==>> webapp folder in dashboard contains my web app
python manage.py shell
python manage.py collectstatic ==>> used by server that collects static files data to the server
django template tags {% %}
sql type queries
Post.objects.all()
from django.contrib.auth.models import User
User.objects.all()
me=User.objects.get(username='mj1')
Post.objects.create(author = me,title = "?asfv", text = "asdf")
from django.utils import timezone
post = Post.objects.get(title="Title4")
Post.objects.filter(published_date__lte=timezone.now()
Post.objects.order_by('created_date')
Post.objects.order_by('-created_date')
Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')