I have a question about staticfiles_urlpatterns method in django What I've learned so far is the staticfiles_urlpatterns wrapped all the urls with base template in one process, so we may not add {% extends "base.html" %}, {% block content %}, {% end content %} (ie. in html files), am I right?
If so, why would mine isn't working, I've read the documentation, and my setting is like this:
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(
os.path.dirname(__file__),
'static',
),
)
and in my urls.py:
from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
import contacts.views
urlpatterns = patterns('',
url(r'^$', contacts.views.ListContactView.as_view(),
name='contacts-list',),
url(r'^new$', contacts.views.CreateContactView.as_view(),
name='contacts-new',),
)
urlpatterns += staticfiles_urlpatterns()
and in my edit_contact.html be like:
<h1>Add Contact</h1>
<form action="{% url "contacts-new" %}" method="POST">
{% csrf_token %}
<ul>
{{ form.as_ul }}
</ul>
<input id="save_contact" type="submit" value="Save" />
</form>
<a href="{% url "contacts-list" %}">back to list</a>
is it necesarry to add {% extends "base.html" %}, {% block content %}, {% end content %} in the edit_contact.html although I used staticfiles_urlpatterns in my urls.py? Thanks in advance, cheers! :D
You have totally misunderstood something. staticfiles has nothing whatsoever to do with the structure of your template, whether you use blocks or inheritance, or anything. I don't know what would have given you the idea that it does.