Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <h1>This is a {{name}} </h1>
- </body>
- </html>
- from django.conf.urls import url, include
- from django.contrib import admin
- urlpatterns = [
- url(r'^admin/', admin.site.urls),
- url(r'^hello/', include('article.urls')),
- ]
- from django.conf.urls import url, include
- from article import views
- urlpatterns = [
- url(r'^1/', views.hello),
- url(r'^2/', views.template),
- ]
- from django.shortcuts import render
- from django.http.response import HttpResponse
- from django.template.loader import get_template
- from django.template import Context
- def hello(request):
- word = 'hello world'
- html = '<html><body> {} </body></html>'.format(word)
- return HttpResponse(html)
- def template(request):
- text = 'hello'
- tmp = get_template(temp.html)
- html = tmp.render(Context({'name': text}))
- return HttpResponse(html)
- from django.template import Context
- def hello(request):
- word = 'hello world'
- html = '<html><body>hello!!! {} </body></html>'.format(word)
- return HttpResponse(html)
- def template(request):
- text = 'hello'
- tmp = get_template(temp.html)
- html = tmp.render(Context({'name': text}))
- return HttpResponse(html)
- ▼ Local vars
- Variable Value
- request <WSGIRequest: GET '/hello/2/'>
- text 'hello'
- Exception Value: name 'temp' is not defined
- TEMPLATE_DIRS = (
- '/Users/user/Desktop/jango_projecty/Scripts/firstapp/templates',
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement