-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdjango-commands
executable file
·75 lines (51 loc) · 2.53 KB
/
django-commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Useful commands for Django server
# Create a new Django project called my_project
django-admin startproject my_project
# Start Django Server on port 8000
python3 manage.py runserver 8000
# Create a file with instructions for the database to create tables. The file is stored in the migrations folder.
python3 manage.py makemigrations
# Apply model changes in django to the database (executes the file created from 'makemigrations')
python3 manage.py migrate
# Show all the migrations for an app called app_name
python3 manage.py showmigrations app_name
# Revert a migration for a specific app. Migration names can be found with the 'showmigrations' command. You only need to use the number of the migration.
python3 manage.py migrate app_name migration_name
# Delete all data in the database. Deletes every record of every table, but keeps the tables intact.
python manage.py flush
# Create a new app in the Django project.
python3 manage.py startapp myapp
# Create an admin account on django.
python3 manage.py createsuperuser
# Show available commands for Django .
python manage.py help
# Run a test for Django.
python manage.py test
# Start python shell, but with django apps/context and database loaded.
python3 manage.py shell
# Check the current version of django.
django-admin --version
# Put all the install python packages and modules in the current virtual environment in a text file.
pip freeze > requirements.txt
# Install the required python packages and modules for the current virtual environment.
pip install -r requirements.txt
# Uninstall package_name
pip uninstall package_name
# Create a python virtual environment called project_env .
python3 -m venv project_env
python -m venv venv
# Activate or start the python virtual environment.
source my_project/bin/activate
source venv/bin/activate
# Deactivate the virtual environment .
deactivate
# Show where the global python modules/packages are stored for the current user.
python3 -m site --user-site
# Print a list of URLS being used in the app. (This command can only be used in the django-extensions package)
python manage.py show_urls
# Generate a graph of the models and their relationships. (This command can only be used in the django-extensions package)
python manage.py graph_models -a -o myapp_models.png
# Install the tailwind dependencies in Django (This command can only be used in the django-tailwind package)
python manage.py tailwind install
# Start the tailwind watcher/builder. (This command can only be used in the django-tailwind package)
python manage.py tailwind start