Skip to main content

Python Django Version Codacy Badge Code style: black

django-vb-admin

Creates custom Django project layout. Compatible with Django 2.2.8 and requires Python 3.7.x. By default, project uses PostgreSQL, this means you need to install :) macOS users can install via brew install postgres

Installation

Let’s create PostgreSQL database first:

$ createdb -E UTF8 -T template0 my_project_dev  # create your database
$ createdb -E UTF8 -T template0 --lc-collate=tr_TR.UTF-8 --lc-ctype=tr_TR.UTF-8 my_project_dev  # or create your database with Turkish locale support

Now, install package:

$ pip install django-vb-admin

This package heavily depends on django-vb-baseapp. All the rake tasks are related to django-vb-baseapp. You don’t need to do anything, django-vb-admin installs required packages automatically.

Usage

After installation, you’ll have a command: django-vb-admin

$ django-vb-admin -h

usage: django-vb-admin [-h] [-t TARGET] [-v {0,1}] [--version]
                       [{startproject}]

Create new Django project

positional arguments:
  {startproject}        Name of command(s)

optional arguments:
  -h, --help            show this help message and exit
  -t TARGET, --target TARGET
                        Target path
  -v {0,1}, --verbosity {0,1}
                        Verbose mode
  --version             show program's version number and exit

Let’s create project:

$ mkdir /path/to/my-django-project/
$ cd /path/to/my-django-project
$ django-vb-admin startproject                             # create structure to current working directory

# or
$ django-vb-admin startproject --target="/path/to/folder"  # create structure to given path

When creation completed, you can create your virtual environment and set your environment variables:

export DJANGO_SECRET=$(head -c 75 /dev/random | base64 | tr -dc 'a-zA-Z0-9' | head -c 50)
export DATABASE_URL="postgres://localhost:5432/my_project_dev"

then;

$ pip install -r requirements/development.pip

Directory structure:

.
├── applications
├── config
│   ├── settings
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── development.example.py
│   │   ├── heroku.py
│   │   ├── production.py
│   │   └── test.example.py
│   ├── __init__.py
│   ├── urls.py
│   └── wsgi.py
├── locale
│   └── tr
│       └── LC_MESSAGES
│           ├── django.mo
│           └── django.po
├── requirements
│   ├── base.pip
│   ├── development.pip
│   ├── heroku.pip
│   └── production.pip
├── static
│   ├── css
│   │   ├── application.css
│   │   └── bulma.min.X.X.X.css
│   ├── images
│   │   └── .gitkeep
│   └── js
│       ├── .gitkeep
│       ├── application.js
│       └── fontawesome.X.X.X.all.js
├── templates
│   ├── admin
│   │   └── base_site.html
│   ├── custom_errors
│   │   ├── 400.html
│   │   ├── 403.html
│   │   ├── 404.html
│   │   └── 500.html
│   └── base.html
├── .bandit
├── .flake8
├── .gitignore
├── .isort.cfg
├── .pylintrc
├── .python-version
├── .ruby-version
├── .tm_properties
├── Procfile
├── manage.py
├── pyproject.toml
├── requirements.txt
└── runtime.txt

Now you can init git:

$ cd /path/to/my-django-project/
$ git init

Packages

Common packages: requirements/base.pip

Django==2.2.8
Pillow==6.2.1
django-extensions==2.2.5
python-slugify==4.0.0
psycopg2-binary==2.8.4
dj-database-url==0.5.0
django-vb-baseapp
vb-console

Development packages: requirements/development.pip

-r base.pip
ipython==7.10.0
ipdb==0.12.3
prompt-toolkit==2.0.10
bpython==0.18
ptpython==2.0.6
Werkzeug==0.16.0
django-debug-toolbar==2.1
coverage==4.5.4
isort==4.3.21
black==19.10b0
flake8==3.7.9
flake8-bandit==2.1.2
flake8-blind-except==0.1.1
flake8-bugbear==19.8.0
flake8-builtins==1.4.1
flake8-polyfill==1.0.2
flake8-print==3.1.4
flake8-quotes==2.1.1
flake8-string-format==0.2.3
pylint==2.4.4

Note: Package order is important here. Due to prompt-toolkit dependency on ipdb and ptpython, we need to install specific version: prompt-toolkit==2.0.10 in the given order. Packages are test on Python 3.8.0 environment and had issues with ipdb, ipython and other repls.

Heroku related packages: requirements/heroku.pip

-r base.pip
gunicorn==20.0.4
whitenoise==4.1.4
boto3==1.10.33
django-storages==1.8

Built-in support for AWS-S3 Storage. You need to create/get your:

  • S3_ACCESS_KEY_ID
  • S3_SECRET_ACCESS_KEY

and set those variables on Heroku. Please check config/settings/heroku.py for more details. Basic Heroku setup:

$ heroku login
$ heroku apps:create
$ heroku addons:create heroku-postgresql:hobby-dev
$ heroku config:set DJANGO_ENV="heroku"
$ heroku config:set DJANGO_SECRET='YOUR_GENERATED_RANDOM_SECRET'
$ heroku config:set S3_ACCESS_KEY_ID='YOUR_S3_ACCESS_KEY_ID'
$ heroku config:set S3_SECRET_ACCESS_KEY='YOUR_S3_SECRET_ACCESS_KEY'
$ heroku config:set S3_BUCKET_NAME='YOUR_S3_BUCKET_NAME'
$ heroku config:set WEB_CONCURRENCY=3
$ git push heroku master
$ heroku run python manage.py migrate
$ heroku run python manage.py createsuperuser

If you want to use email reporter for Django errors, you need to set couple more environment variables on Heroku side too.

Linux/Production packages: requirements/production.pip

-r base.pip
uWSGI==2.0.18

Rakefile

If you have Ruby installed on your system (if you are on macOS you’ll have it by default) you can easily automate your basic operations. Run rake -T for listing available tasks:

$ rake -T

rake db:migrate[database]                                        # Run migration for given database (default: 'default')
rake db:roll_back[name_of_application,name_of_migration]         # Roll-back (name of application, name of migration)
rake db:shell                                                    # run database shell ..
rake db:show[name_of_application]                                # Show migrations for an application (default: 'all')
rake db:update[name_of_application,name_of_migration,is_empty]   # Update migration (name of application, name of migration?, is empty?)
rake default                                                     # Default task: runserver_plus (Werkzeug)
rake locale:compile                                              # Compile locale dictionary
rake locale:update                                               # Update locale dictionary
rake new:application[name_of_application]                        # Create new Django application
rake new:model[name_of_application,name_of_model,type_of_model]  # Create new Model for given application: django,basemodel,softdelete
rake runserver:default                                           # Run: runserver (Django's default server)
rake runserver:default_ipdb                                      # Run: runserver (Django's default server) + ipdb debug support
rake runserver:plus                                              # Run: runserver_plus (Werkzeug)
rake runserver:plus_ipdb                                         # Run: runserver_plus (Werkzeug) + ipdb debug support
rake shell[repl]                                                 # Run shell+ avail: ptpython,ipython,bpython default: ptpython
rake test:browse_coverage[port]                                  # Browse test coverage
rake test:coverage[cli_args]                                     # Show test coverage (default: '--show-missing --ignore-errors --skip-covered')
rake test:run[name_of_application,verbose]                       # Run tests for given application

Rake tasks are the wrapper for Django’s management commands. Mostly related to django-vb-baseapp application. Please checkout https://github.com/vbyazilim/django-vb-baseapp for more detail and examples. django-vb-baseapp has lot of features :)


License

This project is licensed under MIT


Contributer(s)


Contribute

All PR’s are welcome!

  1. fork (https://github.com/vbyazilim/django-vb-admin/fork)
  2. Create your branch (git checkout -b my-features)
  3. commit yours (git commit -am 'Add awesome feature')
  4. push your branch (git push origin my-features)
  5. Than create a new Pull Request!

Change Log

2019-12-08

  • Drop Python 3.8.0 support
  • Fix repls and debug related issues
  • Bump version

2019-12-05

  • Upgrade packages, now using Django 2.2.8
  • Python 3.8.0 support
  • Add new rake tasks
  • Fix development.pip package installation order
  • Bump version

2019-10-20

  • Add current git tag and python version information indicator to django-admin index
  • Add django-vb-baseapp as package dependency
  • Upgrade python packages
  • Add templates/base.html using Bulma.io 0.8.0
  • Bump version: 1.0.13

2019-09-19

  • Add Codacy integration
  • Add setup completed message

2019-08-12

  • Add templates/base.html using Bulma.io 0.7.5
  • Add templates/admin/ for base admin site.
  • Add static/js/application.js
  • Add global locale path
  • Bump version: 1.0.4
  • Bump version: 1.0.5 (Fix README file)

2019-08-07

  • Add --version option, version bump to 1.0.3
  • Bump version: 1.0.2
  • Add Rake tasks
  • Fix MAFIFEST.in file
  • Initial Beta relase: 1.0.0

Metadata

Release files for django-vb-admin 1.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-vb-admin 1.1.10
File Size Uploaded
django-vb-admin-1.1.10.tar.gz 407.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-vb-admin 1.1.10
File Interpreter ABI Platform
django_vb_admin-1.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 826.5 kB

Release files / django-vb-admin-1.1.10.tar.gz

Download URL django-vb-admin-1.1.10.tar.gz
Size 407.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ef7e122517e08deb093a85598c9185255aab64fbf77a916625109e5342331660
BLAKE2b-256 checksum
How to use checksums
4f87672092b3c0469d0a963c151ac31391169686eaf7af05cf585c9260e0723e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / django_vb_admin-1.1.10-py3-none-any.whl

Download URL django_vb_admin-1.1.10-py3-none-any.whl
Size 418.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
687aef50658fb532beebf6380b2c2aac725b7687f09ed36a5ac9d192d6b2ca5a
BLAKE2b-256 checksum
How to use checksums
a0231db0bb9e49911b7ee57d9c96e72336971c203c1aa6448f93254c92b9bfef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

1.1.10 This release

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.0

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page