Skip to content

Instantly share code, notes, and snippets.

@molcay
Last active December 28, 2016 07:51
Show Gist options
  • Select an option

  • Save molcay/d2bd789cc0ff39a46a6fc5b046251868 to your computer and use it in GitHub Desktop.

Select an option

Save molcay/d2bd789cc0ff39a46a6fc5b046251868 to your computer and use it in GitHub Desktop.
Django Framework Development Notes

Django Notes

managepy equivalence python manage.py

  • Install and Create virtualenv
sudo apt-get install python3-venv
python3 -m venv myvenv
  • Activate the virtualenv
. myvenv/bin/activate
  • Install django
    * pip install --upgrade pip
	pip install django
  • Create a django project
django-admin startproject ratemall .
  • Edit settings.py

    • Add STATIC_ROOT = os.path.join(BASE_DIR, 'static') at the end of the file
  • Create the db object

managepy migrate
  • Run server
managepy runserver
  • Uygulama oluşturma
managepy startapp mainapp
  • Add mainapp to the settings.py (append it to the INSTALLED_APPS list)
  • Create a Model (mainapp/models.py)
  • Create table from app's model (migration file creation)
managepy makemigrations mainapp
  • Make migration
managepy migrate mainapp
  • Register the Models to mainapp/admin.py
from .models import Post
admin.site.register(Post)
  • Create super user for admin panel
managepy createsuperuser
  • Url patterns

    routing: create a file in the mainapp folder called urls.py and add this line on main urls.py in the ratemall directory. url(r'', include('mainapp.urls')), and change first line with this from django.conf.urls import include,url

  • after that you write this to the mainapp/urls.py:

from django.conf.urls import url
from . import views
urlpatterns = [
    url(r'^$', views.post_list, name='post_list'),
]

Views => controler from MVC

Template => view from MVC

View extending

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment