![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Aug 2007
Location: Mississauga ON
Posts: 126
Rep Power: 3
![]() |
Django Forms - Creating Multiple Instances
So, I'm having a problem with my django form. Whenever I try to edit a Ticket it creates a new instance of it instead of updating the original. I've follow tutorials, asked friends and still can't figure it out so any help would be great.
The View code @login_required
def edit_ticket(request, ticket_id):
dict = {}
template_name = 'issuetracker/create_ticket.html'
context = RequestContext(request)
myInstance = Ticket.objects.get(pk=ticket_id)
if request.method == 'POST':
form = TicketForm(instance=myInstance)
if form.is_valid():
form.save()
return HttpResponseRedirect('/')
else:
dict['create_form'] = TicketForm(instance=myInstance)
dict['title'] = 'Edit Ticket ' + ticket_id
return render_to_response(
template_name,
dict,
context,
)I would have thought this would have worked, but it doesn't....Any help would be great. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| c# multiple popup windows | programmingnoob | C# | 1 | Aug 15th, 2007 7:04 AM |
| Showing and Hiding Multiple forms | crawforddavid2006 | C# | 4 | Sep 13th, 2006 5:24 PM |
| Creating forms at runtime | kruptof | Visual Basic | 6 | Jun 14th, 2006 7:01 PM |
| dealing with multiple forms | Booooze | C# | 12 | May 12th, 2006 6:12 PM |
| need guidance : on creating forms and shopping cart | gemini_shooter | HTML / XHTML / CSS | 3 | Oct 20th, 2005 12:27 AM |