Skip to content

Instantly share code, notes, and snippets.

@Eyakub
Last active February 6, 2020 09:16
Show Gist options
  • Save Eyakub/9459897a8ae04c12d175b36657b346b7 to your computer and use it in GitHub Desktop.
Save Eyakub/9459897a8ae04c12d175b36657b346b7 to your computer and use it in GitHub Desktop.

Create Project Directory

	$ mkdir project_name

Go to Project Dir

	$ cd project_name

Create Virtualenv

	$ virtualenv virtual_env_name
		a. virtual_env_name\Scripts\activate
		b. pip freeze (to check packages installed)
		c. pip install django==2.1.8
	$ for specific version of python
		virtualenv -p c:\python34.exe myvirtualenv

Make SRC for applications

	$ mkdir src
	$ cd src

Create Root application

	$ django-admin startproject project_name .

Run Application

	$ python manage.py runserver

Create app inside src application

	$ cd src
	$ django-admin startapp app_name

Structure kind of like this:

[projectname]/                  <- project root
├── venv
|	├── Scripts
|	├── bin
|	├── ...
| 
├── [projectname]/             
│   ├── __init__.py
│   ├── settings/
│   │   ├── common.py
│   │   ├── development.py
│   │   ├── i18n.py
│   │   ├── __init__.py
│   │   └── production.py
│   ├── urls.py
│   └── wsgi.py
├── apps/
│   └── __init__.py
├── configs/
│   ├── apache2_vhost.sample
│   └── README
├── doc/
│   ├── Makefile
│   └── source/
│       └── *snap*
├── manage.py
├── README.rst
├── run/
│   ├── media/
│   │   └── README
│   ├── README
│   └── static/
│       └── README
├── static/
│   └── README
└── templates/
|    ├── base.html
|    ├── core
|    │   └── login.html
|    └── README
  • format code: CTR + ALT + L

  • Django Use Jinja2 technique currently for templating

** If there is running project after closing on server

netstat -o get the PID and type > Taskkill PID **** /F

MySQL and JSON field using python

we can JSON data type stored in MySQL

  1. https://stackoverflow.com/questions/4251124/inserting-json-into-mysql-using-python
  2. https://django-mysql.readthedocs.io/en/latest/model_fields/json_field.html
  3. https://geert.vanderkelen.org/2015/mysql577-json-python/
  4. https://medium.com/aubergine-solutions/working-with-mysql-json-data-type-with-prepared-statements-using-it-in-go-and-resolving-the-15ef14974c48
  5. https://dev.mysql.com/doc/refman/8.0/en/json.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment