Created
August 16, 2012 01:04
-
-
Save danmunz/3365230 to your computer and use it in GitHub Desktop.
Dan's first django thing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h1>Welcome to the name-erator!</h1> | |
<p>It looks like your name is {{name}}!</p> | |
<p>Your name has {{name|length}} letters in it. Can you believe that shit?</p> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls import patterns, include, url | |
from mysite.views import names | |
urlpatterns = patterns('', | |
(r'^name/([^/]+)', names), | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render_to_response | |
def names(request, name): | |
try: | |
name = str(name) | |
except ValueError: | |
raise Http404() | |
return render_to_response('name.html', locals()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment