https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1.html
Install Django package (pip3 install django)
Create project (website here)
manage.py -> System file (never edit)
settings.py
Contains all configuration related to website
Contains lists of preinstalled apps
Contains databases info (sqlite by default)
LOGIN_URL, LOGIN_REDIRECT_URL are useful variables (Ref: https://docs.djangoproject.com/en/3.0/ref/settings/)
urls.py -> Tells about how to respond for a url (perform a action)
django-admin startproject <projectname>
python manage.py runserver -> It will start web server on localhost
python manage.py runserver 0.0.0.0:8000 -> It will start web server on all interfaces
python manage.py makemigrations music
update DB table for app music
You can view DB table as below screenshot
python manage.py migrate -> It syncs up with all databases
python manage.py migrate
(venvdjango) (base) Deepaks-MacBook-Air:website deepak$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying sessions.0001_initial... OK
(venvdjango) (base) Deepaks-MacBook-Air:website deepak$
python manage.py startapp <name>
It will create a module with given name (music here)
migrations -> For Database activity
admin.py -> Admin related code (delete user for example)
apps.py -> Apps configuration/setting
models.py -> blueprint for Database. Tells how to store data for this app
test.py -> Testing related file
views.py -> Take user request and return webpage
After below steps, user can login via http://localhost:8000/admin/
python manage.py createsuperuser
When you access localhost:8000/admin, then you can use this credential to login.
Default page after login
Page after registering album to admin
https://simpleisbetterthancomplex.com/tutorial/2017/02/18/how-to-create-user-sign-up-view.html
https://learndjango.com/tutorials/django-signup-tutorial
https://www.youtube.com/watch?v=3UEY0ZIQ9dU
https://www.youtube.com/watch?v=8V-mscw6H64
https://www.youtube.com/watch?v=MCos1BBKfO8
https://learndjango.com/tutorials/django-password-reset-tutorial
For checking mail using test mail server, refer https://blog.mailtrap.io/django-send-email/#SMTP_email_backend
For sending mail using gmail SMTP server, refer here
https://stackoverflow.com/questions/44509497/how-do-i-allow-the-editing-of-my-extended-userprofile-with-userchangeform-django
https://www.youtube.com/watch?time_continue=54&v=Tja4I_rgspI&feature=emb_logo
https://blog.khophi.co/extending-django-user-model-userprofile-like-a-pro/
https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
Refer: https://pypi.org/project/django-login-required-middleware/
https://docs.docker.com/compose/django/#more-compose-documentation
https://stackoverflow.com/questions/28723266/django-display-message-after-post-form-submit
App -> Your Django website has many apps inside as per your need
Please refer https://www.agiliq.com/blog/2019/01/django-createview/
https://www.geeksforgeeks.org/how-to-use-django-field-choices/
Refer https://simpleisbetterthancomplex.com/series/2017/09/11/a-complete-beginners-guide-to-django-part-2.html
https://django-activity-stream.readthedocs.io/en/latest/configuration.html
https://github.com/narenaryan/django-activity-stream-tutorial
https://django-activity-stream.readthedocs.io/en/latest/installation.html
For issues-https://stackoverflow.com/questions/35388637/runtimeerror-model-class-django-contrib-sites-models-site-doesnt-declare-an-ex
Like Facebook timeline
https://www.youtube.com/watch?v=R_tyN8bNe4A
python manage.py flush
Ref: https://stackoverflow.com/questions/7907456/emptying-the-database-through-djangos-manage-py
Install vscode (Refer: https://visualstudio.microsoft.com/downloads/)
Check and install python extension via Extension tab in vscode
Install Django extension via Extension tab in vscode
Create python virtual environment via debug console
refer python3 -m env <env name> in below screenshot. You will get a pop-up. Tell yes to use this environment.
Ref: https://www.roelpeters.be/change-venv-for-python-in-vs-code/
Ref: https://code.visualstudio.com/docs/python/tutorial-django
Install Django package in this virtual environment
Using debug tab, click start. It will start server
Goto browser in same machine and then you can check server if you have page
To debug, put breakpoint at needed line and execute the website
Refer below screenshot for example
Ref: https://docs.microsoft.com/en-us/visualstudio/python/debugging-python-in-visual-studio?view=vs-2019
from django.contrib.admin.views.decorators import staff_member_required
from jsonview.decorators import json_view
https://github.com/pallets/jinja/issues/241
Refer here
Django test
use 'python manage.py test --verbosity=2' for printing the log
python manage.py test --verbosity=2
System check identified no issues (0 silenced).
test_home_url_resolves_home_view (boards.tests.HomeTests) ... return value is home
ok
test_home_view_status_code (boards.tests.HomeTests) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.033s
OK
Destroying test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...
(env) Deepaks-MacBook-Air:alumnisystem deepak$
https://www.djangosites.org/with-source/
https://www.youtube.com/results?search_query=Django+Tutorial+for+Beginners+-+31
https://www.youtube.com/watch?v=CHjXtRrhqxc
https://www.quora.com/How-do-I-set-up-a-website-with-user-accounts-registration-and-login-I-have-developed-a-website-with-HTML5-and-CSS3
https://www.quora.com/Should-I-learn-Flask-or-Django-Im-a-beginner-and-Im-looking-for-simplicity-and-ease-of-learning