3

I'm trying to make a blog/news site and would like to have articles have the url: http://mysite.com/2012/02/05/slug/
My problem is appending the /2012/02/05/slug/ to the url in python. I can save the date and slug into Gql database, as well as the article's content. I just don't how to add the date and slug resource into the url. Searching google hasn't really worked because I don't know what this technique is called...but know most new/blog sites implement it. Appreciate any help. Thanks in advance.

1 Answer 1

2

If you are looking for a general function

import urlparse

def url_rev(pubdate, slug):
    return urlparse.urljoin('http://mysite.com',
                            '/%s/%s/%s/%s/'%(pubdate.year, pubdate.month, pubdate.day, slug))

But
If you are using webapp2: uri_for
if you're using App Engine Patch, you can use Django, including its URL resolvers.
If you are using Flask you can use url_for

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.