summaryrefslogtreecommitdiff
path: root/sublab_project/news
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2011-12-30 01:42:04 +0100
committerChristian Franke <nobody@nowhere.ws>2011-12-30 01:42:35 +0100
commit27300433922788ed6630ae61608517780385f876 (patch)
tree5043d11212b5b1839195c25915056bcc6822c6b8 /sublab_project/news
parentf63274bb0c00eda68b6e2fae564c4da8ae55b84d (diff)
add detailed newspost view, fixup base template
Diffstat (limited to 'sublab_project/news')
-rw-r--r--sublab_project/news/models.py2
-rw-r--r--sublab_project/news/templates/news/news_detail.html10
-rw-r--r--sublab_project/news/templates/news/news_list.html5
-rw-r--r--sublab_project/news/urls.py3
4 files changed, 16 insertions, 4 deletions
diff --git a/sublab_project/news/models.py b/sublab_project/news/models.py
index 72074a0..cd98248 100644
--- a/sublab_project/news/models.py
+++ b/sublab_project/news/models.py
@@ -38,4 +38,4 @@ class News(models.Model):
@models.permalink
def get_absolute_url(self):
- return ('news_detail', (), {'id': self.id})
+ return ('news_detail', (), {'slug': self.slug})
diff --git a/sublab_project/news/templates/news/news_detail.html b/sublab_project/news/templates/news/news_detail.html
new file mode 100644
index 0000000..e3a0de1
--- /dev/null
+++ b/sublab_project/news/templates/news/news_detail.html
@@ -0,0 +1,10 @@
+{% extends 'base.html' %}
+
+{% block title %}{{ object.title }}{% endblock %}
+
+{% block content %}
+ <p class="news_date">{{ object.date_updated|date:"DATETIME_FORMAT" }}</p>
+ <h2 id="{{ object.slug }}">{{ object.title }}</h3>
+ <p>{{ object.content_html|safe }}</p>
+ <p class="header">{{ object.author }}</p>
+{% endblock content %}
diff --git a/sublab_project/news/templates/news/news_list.html b/sublab_project/news/templates/news/news_list.html
index ab998e8..6330ffb 100644
--- a/sublab_project/news/templates/news/news_list.html
+++ b/sublab_project/news/templates/news/news_list.html
@@ -1,10 +1,11 @@
{% extends 'base.html' %}
{%block content %}
+ <h2>sublab - news</h2>
{% for post in news_list %}
<h3 id="{{ post.slug }}">
- <a>{{ post.date_updated|date }} - {{ post.title }}</a>
+ <a href="{{ post.get_absolute_url }}">{{ post.date_updated|date }} - {{ post.title }}</a>
</h3>
- <p>{{ post.content }}</p>
+ <p>{{ post.content_html|safe }}</p>
{% endfor %}
{% endblock content %}
diff --git a/sublab_project/news/urls.py b/sublab_project/news/urls.py
index a1c5c0a..c26d12d 100644
--- a/sublab_project/news/urls.py
+++ b/sublab_project/news/urls.py
@@ -4,5 +4,6 @@ from django.views.generic import ListView, DetailView
from news.models import News
urlpatterns = patterns('',
- url(r'^$', ListView.as_view(model=News, paginate_by=8), name='news_list')
+ url(r'^$', ListView.as_view(model=News, paginate_by=8), name='news_list'),
+ url(r'^news/(?P<slug>[-\w]+)/$', DetailView.as_view(model=News), name='news_detail'),
)