Ticket #5794: views.py

File views.py, 1.2 KB (added by anonymous, 15 years ago)
Line 
1from django.http import HttpResponse
2from friends.people.models import person, Blog
3from django.shortcuts import render_to_response, get_object_or_404
4from friends.quotes.models import quote
5from datetime import datetime
6from django import forms
7
8
9def index(request):
10 pList = person.objects.all()
11 return render_to_response('people/person_index.html', {'pList':pList})
12
13def details(request, pID='0', opts=()):
14 rDict = {}
15 p = get_object_or_404(person, pk=pID)
16 rDict['p'] = p
17 quotes= quote.objects.all()
18 rDict['quotes']=quotes
19 return render_to_response('people/person_details.html',rDict)
20
21def person_form(request, pID='0'):
22 PersonForm = forms.form_for_model(person)
23 f = PersonForm()
24 message = 'Unknown Request'
25 p= get_object_or_404(Person, pk=pID)
26
27 if request.method == 'GET':
28 PersonForm = forms.form_for_instance(p)
29 f=PersonForm()
30 message= 'Editing person %s ' % p.name
31
32 if request.method == 'POST':
33 if request.POST['submit'] == 'update':
34 message = 'Update Request for %s ' % p.name
35
36 return render_to_response(
37 'people/person_form.html',
38 {'pForm':f,
39 'message':message})
40# Create your views here.
Back to Top