This project is intended to explore django-extensions and learn more about what django extensions can do for me during development.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
This project was setup to explore django-extensions and learn more about how django-extensions can help me during development. It is also based on William Vincent's book "Django for Professionals". Specially for setting up django-allauth. This is also a functional blog site using class-based views. There are still a few portions of the code that need work, but it is functional. I have included the database on Github since I created 8 posts that highlight the django_extension modules that I use the most.
- Django 5.0.4
- Django Extensions 3.2.3
- Graphviz 10.0.1
- Bootswatch Theme for Bootstrap
- See requirements.txt for a full list of modules used
To get a local copy up and running follow these steps.
-
You can clone this repo, and begin playing, or
-
You can follow the Project Setup Guide to create the project from scratch.
You will require graphviz to be installed on your OS before you can use graphviz with Django. Graphviz is available for Windows, MacOS, and Linux distros. Please see the graphviz website for details.
-
Clone the repo
git clone https://github.com/drobb2020/django_extensions_example.git
-
Create a virtual environment within the project folder.
Python3 -m venv venv
-
Activate the virtual environment.
source /venv/bin/activate
-
Run pip install.
pip install -r requirements.txt pip install -r requirements-dev.txt
Django extensions is a very useful tool to enhance your experience with django development. From shell_plus, to runserver_plus there are a host of utilities for everyone. I created a simple blog application and created a couple of models to experiment with the command extensions.
- shell_plus
- dumpscript
- export_emails
- generate_password
- Graph models
- reset_db
- runserver_plus
- generate_secret_key
- admin_generator
Refer to the Django Extensions markdown file for a full listing of all modules.
For more examples, please refer to the Documentation
- A Django shell with auto-loading of the configured apps database models and subclasses of user-defined classes.
- You can also exclude models by adding the --dont-load app1 to the command line.
- Has a built-in collision resolver.
python manage.py shell_plus
- Generates a standalone python script that can be used to repopulate the database using objects.
- Save crucial data when you modify your models.
- Edit the script to create 1000's of entries using for loops, and generated names.
python manage.py dumpscript posts > django-extensions-dump.txt
- Exports the email addresses of registered users in the format you specify.
- formats are:
- address
- outlook
- vcard
- You can use the generated list for a mailer to all your users.
python manage.py export_emails --format emails > django-extensions-email.txt
- Generates a new password that you can then use for a user password.
- Uses the default django password generator.
- You are able to specify the length of the password by adding the --length=XX switch.
python manage.py generate_password --length 10 > django-extensions-gen-password.txt
- Renders a graphical representation of your entire project or of a specific application.
- You need Graphviz installed on the OS, as well as pygraphviz for this to work.
- Use the GRAPH_MODELS option in settings.py to specify default options.
python manage.py graph_models posts accounts | dot -T png -o dee_posts_accounts.png
- Fully resets your current database by running a DROP DATABASE followed by a CREATE DATABASE
- This is a destructive operation!
- You will be prompted to confirm the operation.
- This is the typical runserver command with the Werkzeug debugger baked in.
- Requires the Werkzeug package to be installed (Kick ass debugger).
- Allows you to run your development server over https by specifying the --cert-file option.
- Creates a new secret key that you can put in your settings.py module, or more appropriately place it in a dot env file.
python manage.py generate_secret_key > django-extensions-secret-key.txt
- Document the django-extensions I played with
- Add full CRUD functionality to demonstration
- Add a CustomUser app to the project and setup login, logout, and register pages.
- Update the code to the latest available
- Add HTMX to project
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
David Robb - drobb2011@gmail.com
Project Link: https://github.com/drobb2020/django_extensions_example