aaaa
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
makemessages
makemigrations
migrate
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
startapp
startproject
test
testserver
django-admin startproject python manage.py startapp python manage.py python manage.py makemigrations python manage.py migrate python manage.py runserver
django-admin startproject python3 manage.py startapp python3 manage.py python3 manage.py makemigrations python3 manage.py migrate python3 manage.py runserver
pip3 install django==3.2
bbb
django-snippets README This project is aimed at providing commonly used code snippets for Django to developers for faster development.
Django Snippets
Features Code Snippets for Django
Model Fields Form Fields Queryset API Class Based View Function Based View User Model Snippet Documentation All the code snippets are according to Django 3.0. Arguments passed to certain fields take default values so it does not cause any issue.
Model Snippets
No. Snippet Function
- modclass Setup model class
- charfield Model CharField
- intfield Model IntField
- boolfield Model BoolField
- datefield Model DateField
- dtfield Model DateTimeField
- decimalfield Model DecimalField
- emailfield Model EmailField
- filefield Model FileField
- imagefield Model ImageField
- floatfield Model FloatField
- slugfield Model SlugField
- textfield Model TextField
- timefield Model TimeField
- urlfield Model URLField
- fkfield Model ForeignKey Field
- m2mfield Model ManyToMany Field
- otofield Model OneToOne Field
Admin, URLs and Manager Snippets
No. Snippet Function
- admreg admin.site.register(..)
- paturl Setup for urls.py file
- dmnc Custom Manager Setup
- cmmodel Custom Manager in Model
Form Snippets
No. Snippet Function
- formpy Setup form.py
- fclass Setup form class
- is_valid() Override is_valid()
- fchoicefield Form ChoiceField
- fmcfield Form MultipleChoiceField
- fcharfield Form CharField
- fintfield Form IntField
- fboolfield Form BoolField
- fdatefield Form DateField
- fdtfield Form DateTimeField
- fdecimalfield Form DecimalField
- femailfield Form EmailField
- ffilefield Form FileField
- ffloatfield Form FloatField
- fimagefield Form ImageField
- fslugfield Form SlugField
- ftimefield Form TimeField
- furlfield Form URLField Form field snippet shorcut are similar to model fields shortcuts. However the only difference is we have a f as the starting character of each snippet
View Snippets
No. Snippet Function
- gencbv Setup a generic class based view
- render Shortcut for render
- htrd Shortcut for HttpResponseRedirect
- cltd Cleaned Data Access for Forms
- custfilt Template for Custom Filter
- create Create query
- all All query
- filter Filter query
- get Get query
- exclude Exclude query
- goc Get or Create query
- uoc Update or Create query
- count Count query
- latest Latest query
- earliest Earliest query
- genfunc Setup a generic function view
User Model Snippets
No. Snippet Function
- createuser Create a new user instance
- validatepassword Validate a given password
- setpassword Set a new password
- authuser Authenticate a user
- checkauth Check if a user is authenticate Known Issues Currently no issue has been reported. All issues must be reported at
Issues
Current Release 0.0.4 Initial Release of the django-snippets extension Enjoy!
Shortcuts/Commands
Command Function !fbv Creates a function based view !cbv Creates a class based view !form Provides a sample for forms.Form !modelForm Provides a sample for model.ModelForm !model Provides a sample for model.Model !email Send email with one line !c_email Generates a function to send email with alternatives !paginate Provides a simple pagination code !django_pdf Generate pdf from html !object_404 Get Object or 404 !list_404 Get List or 404 !f_field Provides a ForeignKeyField sample !c_field Provides a Charfield sample !m2m_field Provides a ManyToMany field sample