Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <html>
  2. <body>
  3. <h1>This is a {{name}} </h1>
  4. </body>
  5. </html>
  6.  
  7. from django.conf.urls import url, include
  8. from django.contrib import admin
  9. urlpatterns = [
  10. url(r'^admin/', admin.site.urls),
  11. url(r'^hello/', include('article.urls')),
  12. ]
  13.  
  14. from django.conf.urls import url, include
  15. from article import views
  16. urlpatterns = [
  17. url(r'^1/', views.hello),
  18. url(r'^2/', views.template),
  19. ]
  20.  
  21. from django.shortcuts import render
  22. from django.http.response import HttpResponse
  23. from django.template.loader import get_template
  24. from django.template import Context
  25. def hello(request):
  26. word = 'hello world'
  27. html = '<html><body> {} </body></html>'.format(word)
  28. return HttpResponse(html)
  29. def template(request):
  30. text = 'hello'
  31. tmp = get_template(temp.html)
  32. html = tmp.render(Context({'name': text}))
  33. return HttpResponse(html)
  34.  
  35. from django.template import Context
  36. def hello(request):
  37. word = 'hello world'
  38. html = '<html><body>hello!!! {} </body></html>'.format(word)
  39. return HttpResponse(html)
  40. def template(request):
  41. text = 'hello'
  42. tmp = get_template(temp.html)
  43. html = tmp.render(Context({'name': text}))
  44. return HttpResponse(html)
  45. ▼ Local vars
  46. Variable Value
  47. request <WSGIRequest: GET '/hello/2/'>
  48. text 'hello'
  49.  
  50. Exception Value: name 'temp' is not defined
  51.  
  52. TEMPLATE_DIRS = (
  53. '/Users/user/Desktop/jango_projecty/Scripts/firstapp/templates',
  54. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement