Browse Source

Add initial urls.py and views.py

pull/1/head
Hidden Z 14 years ago
parent
commit
7434e4c8c8
  1. 5
      web/postkey/urls.py
  2. 23
      web/postkey/views.py

5
web/postkey/urls.py

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('web.postkey.views',
(r'^$', 'index'),
)

23
web/postkey/views.py

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.forms import ModelForm
from django.template import RequestContext
from web.postkey.models import i2phost
class AddForm(ModelForm):
class Meta:
model = i2phost
fields = ('name', 'b64hash')
def index(request):
if request.method == 'POST':
form = AddForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/postkey/success/')
else:
form = AddForm()
return render_to_response('postkey.html', {
'form': form,
}, context_instance=RequestContext(request))
Loading…
Cancel
Save