django ListView and DetailView Training
Related cards:
django url (?P<>) regex - named capture group and backreference
Nearly all modern regular expression engines support numbered capturing groups and numbered backreferences. Long regular expressions with lots of groups and backreferences may be hard to read. They can be particularly difficult to maintain as addi...
django-crispy-forms with DetailView
Reference
- general overview
- [more specific example from developer](https://stackoverflow.com/questions/13098954/use-crispy-form-with-model...
django url parameters and view functions
url.py
url(r'^stores/',stores_views.detail,{'location':'headquarters'})
views.py
def detail(request,location=None):
Reference
django tables2 installation
Django-tables2 is Available on pypi and can be installed using pip:
pip install django-tables2
After installing, add 'django_tables2' to INSTALLED_APPS and make sure that 'django.template.context_processors.request' is added to the context_proces...
django rename app
Before renaming
Always migrate databases before changing the app name.
manage.py makemigrations
when you see the following message then it is safe to proceed with renaming the app.
No changes detected
Fixed table names
...
django apps in subfolder
sample manage.py
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
# Add the apps directoriy to Python's path. In production it will
# be n...
django SessionAuthentication
Overview
SessionAuthentication method: This method uses the session cookie (which is set through the normal Django login and logout views) to check out if there’s an authenticated user and get his username. This method works only in the same s...
django sitetree install
- Add the sitetree application to INSTALLED_APPS in your settings file (usually ‘settings.py’).
- Check that django.core.context_processors.request is added to TEMPLATE_CONTEXT_PROCESSORS in your settings file. For Django 1.8+: django.template....
django readonly form/modelform
Overview
A Form and ModelForm which provides the ability to specify certain fields as readonly, meaning that they will display their value as text wrapped with a tag. The user is unable to edit them, and they are protected from POST data...