Django Notes 1 (Update:6.sept)
READ ME CAREFULLY
....................................................................................................................................................
1.django-admin command
2.django-admin startproject mac command
3.python manage.py runserver command
4.now create app by command python-manage.py startapp shop/blog
5.shop and blog has no urls so make a urls.py in shop and blog
6.copy the urls.py content of the mac and pest it in shop/blogs urls.py
7.import this 3 line in shop and blog url:
from django.contrib import admin
from django.urls import path
from . import views
8.in views.py of shop and blog impott this (from django.http import HttpResponse)
9.in mac url import that lines
from django.contrib import admin
from django.urls import path ,include #that include is very importent
10.mac er url a ashe kau shop khujle take shop app a aivabe redirect korte hobe
path('shop/',include('shop.urls')),
11.for adding templates make directry in shop/blog(bairer ta,not vetorer shop/blog directory) apps named templates.
12.mac er settings ar template srction a giye 'DIRS': ['templates'], DIRS ar moddhe amon kore 'templaes likhe dei'
13.in templates directory make one more directory named shop/blog for better anangement of templates
14.Apatoto, mac er setting.py ar INSTALLED_APPS section a 'blog','shop' ai 2 ta add kore nau karon blog ar shop holo mac er 2 ta apps
15.shop/blog er view te giye function er moddhe [return render(request,'blog/index.html')] ai vabe likhe jekono html page ke return korate hoi
16.make a static directory in outer shop and blog like "templates directory" and inside that static directory again make directory name shop and blog.
17.in static/blog and shop make a mystatic.txt file
18.By this syntex in index.html page you can access in mystatic file
{% load static %}
<a href="{%static 'blog/mystatic.txt'%}">CLICK ME</a>
19.
Comments
Post a Comment