Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
Added support for slugs in URL's
Browse files Browse the repository at this point in the history
  • Loading branch information
Orf committed Jul 8, 2012
1 parent d5bdda1 commit 5f5871b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
Django==1.4
PyMeta==0.5.0
certifi==0.0.8
chardet==1.0.1
distribute==0.6.24
django-autoslug==1.5.0
gunicorn==0.14.2
httplib2==0.7.4
-e git://github.com/brosner/python-oauth2.git@82a05f96878f187f67c1af44befc1bec562e5c1f#egg=oauth2-dev
oauthlib==0.1.3
pyasn1==0.1.3
pybars==0.0.1
requests==0.12.1
rsa==3.0.1
wsgiref==0.1.2
gunicorn==0.14.2
-e git://github.com/brosner/python-oauth2.git#egg=oauth2
pybars==0.0.1
django-autoslug==1.5.0
2 changes: 1 addition & 1 deletion syte/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Post(models.Model):
published = models.BooleanField(default=False)
publish_date = models.DateTimeField(auto_now_add=True, null=True)

slug = AutoSlugField(populate_from='title')
slug = AutoSlugField(populate_from='title',always_update=True)
tags = models.ManyToManyField(Tag, related_name="posts")

class Meta:
Expand Down
1 change: 1 addition & 0 deletions syte/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

if settings.BUILTIN_POST_ENABLED:
urlpatterns += patterns('',
url(r'^p/(?P<post_slug>\w+)$','syte.views.post_slug'),
url(r'^admin/?$','syte.views.adminindex'),
url(r'^admin/(?P<post_id>\d+)$','syte.views.editpost'),
url(r'^admin/(?P<post_id>\d+)/delete$','syte.views.deletepost'),
Expand Down
6 changes: 4 additions & 2 deletions syte/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ def dribbble(request, username):
content_type=r.headers['content-type'])




def blog(request):
if settings.BUILTIN_POST_ENABLED:

Expand Down Expand Up @@ -188,6 +186,7 @@ def blog_post(request, post_id):
def blog_tags(request, tag_slug):
#Due to the issue with the tumblr api described below we will redirect to the
#users tumblr tags page for now.

if settings.BUILTIN_POST_ENABLED:
raise Http404
return redirect('http://{0}/tagged/{1}'.format(
Expand Down Expand Up @@ -281,6 +280,9 @@ def instagram_next(request, max_id):
content_type=media_r.headers['content-type'])


def post_slug(request, post_slug):
return blog_post(request, get_object_or_404(models.Post, slug=post_slug).id)

@auth_decorator.logged_in_or_basicauth()
def adminindex(request):
return render(request, "admin.html", {"published_posts":models.Post.objects.filter(published=True).all(),
Expand Down

0 comments on commit 5f5871b

Please sign in to comment.