app = plugable web application
python manage.py startapp app_name
- create two app
- python manage.py startapp shop
- python manage.py startapp blog
add views in views.py file
blog->templates->blog
shop->templates->shop
In setting this list present
create static/blog(or shop) dir in blog/shop folder
ex. blog/static/blog
add static file in that folder ex. mystatic.txt
when access static file then add these lines
{% load static %} {%static add_link_at_here %}
<a href="{%static 'blog/mystatic.txt' %}">click me</a>
Then Restart the server
In app folder(blog,shop) there is migrations folder created and models.py file also created automatics when you create App
python manage.py migrate
change in model are occured that store in the migration .
(jo change model m kiya h like. table ka nam change kr liya so this change only store in migration but not store in the database 'but when you apply migration that time that changes in databases applyed .(jab tk apply nhi kronge migration ko tb tk koi databases m change nhi hoga, only migration m store ho jayega wo changes.)
change in installed_app[] list(present in project1)
add this 'shop.apps.ShopConfig',
and remove 'shop
create model with name 'Product'(class name) in shop/models.py file
python manager.py makemigrations
python manage.py migrate
python manage.py createsuperuser
set user name ,pass,etc..
goto 127.0.0.1:8000/admin
data is not showing because we can't register our model so first register our model
go to shop/admin.py file
add these lines
from .models import model_name
admin.site.register(model_name)
ex.
from .models import Product
admin.site.register(Product)
got to admin page(127.0.0.1:8000/admin)
now product(model) is showing
restart server then add product if error occur
reason 1. not do migrate process
reason 2. not restart the server
NOTE - if any change in model than definitlty you have to do 'migration '