Django Basics - kgolezardi/SAD-Project GitHub Wiki
First, we need a virtual environment! We used virtualenvwrapper to make one with the following commands:
$ pip install virtualenvwrapper
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv bidilo -p python3
We should add Django to requirements, but for now:
$ pip install django
$ django-admin startproject mysite
$ python manage.py runserver
$ python manage.py startapp core
How to forget changes?
One way is to git reset.
How to ignore files that have been committed?
- Edit .gitignore
- git rm -r --cached . to remove files from git
- git add . to add files that are not ignored by new policy
Login basics
https://wsvincent.com/django-user-authentication-tutorial-login-and-logout/
What is csrf_token which prevents a XSS Attack?
Why to use reverse_lazy instead of reverse?
It is useful for when you need to use a URL reversal before your project’s URLConf is loaded. Some common cases where this function is necessary are:
- providing a reversed URL as the url attribute of a generic class-based view.
- providing a reversed URL to a decorator (such as the login_url argument for the django.contrib.auth.decorators.permission_required() decorator).
- providing a reversed URL as a default value for a parameter in a function’s signature.