Django Html Template Nasıl Tanımlanıyor
-
Selam,
Django için HelloWorld diye bir proje oluşturdum
HelloWorld
- __init__.py
- models.py
- tests.py
- views.py
şeklinde yapıyı kendisi oluşturuyor zaten .
Benim sorunum html bi template oluşturdum fakat onu tanımıyor onu nasıl tanıtabilirim ? templates/xxx.html şeklinde bi sayfa oluşturup onu direk render edemiyor muyum
views.py :
# Create your views here.
from django.shortcuts import render
from models import Book
def latest_books(request):
book_list = Book.objects.order_by('-pub_date')[:10]
return render(request,'templates/latest_books.html',{'book_list':book_list},content_type="application/xhtml+html")urls.py :
from django.conf.urls.defaults import *
import HelloWorld.views
urlpatterns = patterns('',
(r'^latest/$', HelloWorld.views.latest_books),
) -
settings.py içindeki template dir i değiştir. orayı templates yap hocam. sonra helloworld appı içerisinde templates klasörü açıp içinDe helloworld.html oluştur ve template ini içine yaz.
ZoRKaYa tarafından 01/Eyl/13 16:08 tarihinde düzenlenmiştir -
ZoRKaYa bunu yazdı
settings.py içindeki template dir i değiştir. orayı templates yap hocam. sonra helloworld appı içerisinde templates klasörü açıp içinDe helloworld.html oluştur ve template ini içine yaz.
oldu sağol :D
