Skip to content

Instantly share code, notes, and snippets.

@sandipb
Last active March 13, 2023 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandipb/cb9c9c6ba00603c30cf3a89d4141b2de to your computer and use it in GitHub Desktop.
Save sandipb/cb9c9c6ba00603c30cf3a89d4141b2de to your computer and use it in GitHub Desktop.
Creating new django project
$ mkdir dtemp
$ cd dtemp
$ poetry init
This command will guide you through creating your pyproject.toml config.
Package name [dtemp]: Django Test
Version [0.1.0]:
Description []:
Author [Sandip Bhattacharya <sandipb@example.com>, n to skip]:
License []:
Compatible Python versions [^3.11]:
Would you like to define your main dependencies interactively? (yes/no) [yes]
You can specify a package in the following forms:
- A single name (requests): this will search for matches on PyPI
- A name and a constraint (requests@^2.23.0)
- A git url (git+https://github.com/python-poetry/poetry.git)
- A git url with a revision (git+https://github.com/python-poetry/poetry.git#develop)
- A file path (../my-package/my-package.whl)
- A directory (../my-package/)
- A url (https://example.com/packages/my-package-0.1.0.tar.gz)
Package to add or search for (leave blank to skip): django
Found 20 packages matching django
Showing the first 10 matches
Enter package # to add, or the complete package name if it is not listed []:
[ 0] Django
[ 1] django-503
[ 2] django-filebrowser-django13
[ 3] django-tracking-analyzer-django2
[ 4] django-jchart-django3-uvm
[ 5] django-totalsum-admin-django3
[ 6] django-debug-toolbar-django13
[ 7] django-suit-redactor-django2
[ 8] django-django_csv_exports
[ 9] django-thumborize
[ 10]
> 0
Enter the version constraint to require (or leave blank to use the latest version):
Using version ^4.1.7 for Django
Add a package (leave blank to skip):
Would you like to define your development dependencies interactively? (yes/no) [yes] no
Generated file
[tool.poetry]
name = "django test"
version = "0.1.0"
description = ""
authors = ["Sandip Bhattacharya <sandipb@example.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
Django = "^4.1.7"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Do you confirm generation? (yes/no) [yes]
$ ls
pyproject.toml
$ poetry shell
Creating virtualenv django test in /Users/sandipb/dtemp/.venv
Spawning shell within /Users/sandipb/dtemp/.venv
. /Users/sandipb/dtemp/.venv/bin/activate
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
$ . /Users/sandipb/dtemp/.venv/bin/activate
$ poetry install
Updating dependencies
Resolving dependencies... (0.2s)
Writing lock file
Package operations: 3 installs, 0 updates, 0 removals
• Installing asgiref (3.6.0)
• Installing sqlparse (0.4.3)
• Installing django (4.1.7)
$ django-admin startproject hello
$ cd hello
$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
$ python manage.py createsuperuser
Username (leave blank to use 'sandipb'): admin
Email address: admin@example.com
Password:
Password (again):
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.
$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
March 13, 2023 - 17:35:09
Django version 4.1.7, using settings 'hello.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[13/Mar/2023 17:35:11] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 2218
[13/Mar/2023 17:35:11] "GET /static/admin/css/base.css HTTP/1.1" 304 0
[13/Mar/2023 17:35:11] "GET /static/admin/css/dark_mode.css HTTP/1.1" 304 0
[13/Mar/2023 17:35:11] "GET /static/admin/css/nav_sidebar.css HTTP/1.1" 304 0
[13/Mar/2023 17:35:11] "GET /static/admin/css/login.css HTTP/1.1" 304 0
[13/Mar/2023 17:35:11] "GET /static/admin/css/fonts.css HTTP/1.1" 304 0
[13/Mar/2023 17:35:11] "GET /static/admin/css/responsive.css HTTP/1.1" 304 0
[13/Mar/2023 17:35:11] "GET /static/admin/js/nav_sidebar.js HTTP/1.1" 304 0
[13/Mar/2023 17:35:15] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0
[13/Mar/2023 17:35:15] "GET /admin/ HTTP/1.1" 200 3580
[13/Mar/2023 17:35:15] "GET /static/admin/css/dashboard.css HTTP/1.1" 200 380
[13/Mar/2023 17:35:15] "GET /static/admin/img/icon-addlink.svg HTTP/1.1" 200 331
[13/Mar/2023 17:35:15] "GET /static/admin/img/icon-changelink.svg HTTP/1.1" 200 380
[13/Mar/2023 17:35:15] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 86184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment