Skip to content

Instantly share code, notes, and snippets.

@sweemeng
Created April 23, 2010 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sweemeng/376304 to your computer and use it in GitHub Desktop.
Save sweemeng/376304 to your computer and use it in GitHub Desktop.
from django.shortcuts import render_to_response
from forms import IssueForm
from django.http import HttpResponseRedirect
from models import *
# Create your views here.
def add_issue(request):
if request.method == 'GET':
form = IssueForm()
return render_to_response('issue/add.html',{'form':form})
else:
issue = Issue()
issue.votes = 0
issue.closed = False
form = IssueForm(request.POST,instance=issue)
if form.is_valid():
newissue = form.save()
else:
return render_to_response('issue/add.html',{'form':form})
return HttpResponseRedirect('/issue/view/?id='+str(newissue.id))
def view_issue(request):
id = request.GET.get('id')
issue = Issue.objects.get(id=id)
return render_to_response('issue/view.html',{'issue':issue})
def list_issue(request):
issue = Issue.objects.all()
return render_to_response('issue/list.html',{'issue':issue})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment