Simple example of Django CRUD application implemented with Class Based Views and Twitter Bootstrap. What can you find here:
- CRUD-operations for managing
Product
model implemented with Class Based Views. - UI developed with Bootstrap 4.1.1.
- Model validation with ModelForm and Model.clean method.
- Product list filtration implemented with django-filter.
- Example of custom form widget
PriceWidget
. - User registration and authentication example with Django auth views.
- Access limiting for CRUD-operations based on user permissions with PermissionRequiredMixin.
- Custom template tags and filters.
- Reusable template components (
templates/pagination.html
,templates/form_inputs.html
,templates/form_submit.html
) and so on.
- Install Python 3.6.
- Check whether you have pip installed with your Python:
pip help
If pip is not installed, then you can read here how to download and install it.
Pip will help you to install required packages into this project by simply typing one command to your terminal.
- Install virtualenv. VirtualEnv is a powerful tool to create isolated Python environments.
pip install virtualenv
- Create a virtual environment in your project directory.
cd <project_directory>
virtualenv -p python3.6 .\venv
- Start a virtual environment:
Windows
.\venv\Scripts\activate
Linux\OSX
source .\venv\bin\activate
- Install project requirements with pip:
pip install -r requirements.txt
- Create test database by running Django-migrations. This command will create a simple SQLite-database named db.sqlite3 in project directory:
python manage.py migrate
- [Optional] Load fixtures for initial data.
python manage.py loaddata data.json
To run this project now first of all you need to start your virtual environment (Installation - Step 5). After that you probably want at least one administrator of this system to manage products data. You can create superuser for this system by running next command:
python manage.py createsuperuser
Now you can run your development server by typing the next command, to stop the server just press Ctrl + C:
python manage.py runserver