-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresources and notes
167 lines (101 loc) · 4.29 KB
/
resources and notes
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
1.forking an app:
eg.$ ./manage.py oscar_fork_app order yourappsfolder/
link:: https://django-oscar.readthedocs.io/en/stable/topics/customisation.html
2. to custmize view
https://django-oscar.readthedocs.io/en/latest/howto/how_to_customise_a_view.html
3. customize template
https://django-oscar.readthedocs.io/en/latest/howto/how_to_customise_templates.html#
Ex. as I did with ase.html
4.to generate requirements.txt
pip freeze > requirements.txt
5.creating new app
python manage.py startapp restaurents
6. verbatim is used for rendering out varialble on html page
{% verbatim %} {{ html_var }} {% endverbatim %}
7. template inheritance
ex::
{% extends "base.html"%}
{% block head_title %} {{block.super}} {% endblock head_title %}
{% block content%}
8.including a template inside a template
{% include 'snippets/nav.html' %}
9. for using class based views we need to import
from django.views import View #imported because we are using class based view
10.for using template based views (this is best)
from django.views.generic import TemplateView #for template based views
it can be written in urls.py directly
11.To have a look at model ,,register it in admin
Ex.::
from .models import RestaurantLocation
admin.site.register(RestaurantLocation)
12. slug
slug is short and meaningful label or name. Basically used for urls looking simple and robust
13. run django page on mobile:
ubuntu::
a. run this cmd;
ifconfig | grep "inet " | grep -v 127.0.0.1
it will give some ip's (try below steps with all except localhost, 127.0.0.1)
ex: if ip is 162.250.103.1
step1:run this on terminal :
python manage.py runserver 162.250.103.1:8000
also add 162.250.103.1 to ALLOWED_HOST (ALLOWED_HOST=['162.250.103.1'])
step2:
open http://162.250.103.1:8000 on laptop
open 162.250.103.1:8000 on mobile
14. run project on new machine::
step 1.
-create a floder "demo_for_reproduce"
-go into this folder
-create virtual environment command:: virtualenv vir_env_for_demo
-activate virtual environment command:: source vir_env_for_demo/bin/activate
-place requirements.txt in "demo_for_reproduce" folder
-run cmd :: pip install -r requirements.txt
-place requirements.txt in "demo_for_reproduce" folder
-paste froshop folder in "demo_for_reproduce"
-run cmd: python manage.py runserver
-to decativate virtualenv ust give this cmd:: deactivate
15. forms in django::
https://www.udemy.com/try-django-v1-11-python-web-development/learn/v4/t/lecture/7606862?start=0
https://github.com/codingforentrepreneurs/Try-Django-1.11/tree/ac75e86395e0e7fa0e33f832348f12f3efa43bac
lecture 24,25,26
when want to create a form , create as in lec 26, its very optimized way
16. Advance form validation as per our need::
lecture 27
https://www.udemy.com/try-django-v1-11-python-web-development/learn/v4/t/lecture/7606866?start=330
17. validating models and fields
lecture 27
https://www.udemy.com/try-django-v1-11-python-web-development/learn/v4/t/lecture/7606866?start=330
18. Associating a user to form data in function based view
lec. 29
https://www.udemy.com/try-django-v1-11-python-web-development/learn/v4/t/lecture/7606870?start=0
19. Associating a user to form data in class based view
lec. 30
https://www.udemy.com/try-django-v1-11-python-web-development/learn/v4/t/lecture/7606872?start=0
20. login is required to view
lec. 31
21.using django's LoginView
user is required to be logged in for creating a restaurent
lec. 32 (LoginRequiredMixin)
22. use url short pattern inside a template (like {% url "abcd" %}) or (using reverse to short urls)
-If we want to make an app reusable, the app should have its own urls.py and in our proejct's urlpattern in urls.py that can be included.
lec. 33
23. restrict some fields in form (so that only that options will come),
updating a form
hint:: this can be used for prepopulating order id in the form in kitchen
lec. 36
24. Personalize items:
so that an user can see his things
lec: 37
25. user profile view
using this in detail view::
return get_object_or_404(User, username__iexact=username, is_active=True)
lec. 38
26. Addin somebootstrap to profile
lec. 39
27. Adding a robust search
lec. 40
28. chirag teamviewer id (this is added in priyank_ranch_extra new hai yee)
1213137995
29. Adding user registration
lec 44
we need to import dango's loginview and logoutview