django-crispy-forms with DetailView
Related cards:
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...
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 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 management commands
Management Commands
Add a management/commands directory to the application. Django will register a manage.py command for each Python module in that directory whose name doesn’t begin with an underscore.
Example
from django.core.manageme...
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 DRF API Views
REST framework provides two wrappers you can use to write API views.
- The @api_view decorator for working with function based views.
- The APIView class for working with class-based views.
These wrappers provide a few bits of functionality su...
vue delimiters in django
Sample delimiter replacement for django
<script>
new Vue({
delimiters: ['[[', ']]'],
el: '#app',
data: {
title: 'Welcome to My Journal'
}
})
</script>
See Also
[vuejs with django](https://scotch.io/bar-talk/build-an-app-wit...
django migrate
basic
makemigration <app>
migrate
with python path
if an apps dir is used to organize the apps then do the following
makemigrations myapp --pythonpath apps
migrate
See also
django multiple databases
Step 1: Setup DB in settings
Step 2: Setup DB Routing
Step 3: Migration
Step 4: Testing
Reference
- django mult-db
- [blog with example](https://strongarm.io/blog/multiple...