Форум сайта python.su
Я в тупике, идей ноль проблема осталась. Есть 2 простеньких шаблона “base.html” :
<!DOCTYPE html> <html> <head> {% load staticfiles %} <link rel="stylesheet" href="{% static 'resume/stylesheet.css'%}"/> <title>{% block title %}{% endblock %}</title> </head> <body> <div id="header"> some info </div> {% block content %}{% endblock %} </body> </html>
{% extends "base.html" %} {% load staticfiles %} {% block title %}Personal info{% endblock %} {% block content %} <div>{{person.first_name}}</div> {% endblock %}
def person_view(request): person = get_object_or_404(Person, pk=1) return render(request, "resume/person.html", {'person': person})
url(r'^$', views.person_view, name='person'),
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Personal infoSite Name</title> <meta http-equiv="X-UA-Compatible" content="chrome=IE7" /> <meta name="viewport" content="initial-scale=1.0, width=device-width"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <link rel="stylesheet" href="/static/css/screen.css" media="screen, projection"/> </head> <body id="" class=""> <div>Volodymyr</div> </body> </html>
def person_view(request): person = get_object_or_404(Person, pk=1) return render(request, "resume/base.html", {'person': person})
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="/static/resume/stylesheet.css"/> <title></title> </head> <body> <div id="header"> some info </div> </body> </html>
Офлайн
Зачем {% load staticfiles %} а не {% load static %}? Такая старая Джанга?
load еще наверное хороший тон писать в самом начале файла.
и сейчас рекомендуется указывать какой блок закрывается
{% block content %}{% endblock content %}
Хотя не уверен что проблема пропадет.
Офлайн
исправил изменением
{% extends “base.html” %} => {% extends “resume/base.html” %}
в person.html
Офлайн