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 thisfrom 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