Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 30th, 2009, 8:38 PM   #1
silent1mezzo
Hobbyist Programmer
 
Join Date: Aug 2007
Location: Mississauga ON
Posts: 126
Rep Power: 3 silent1mezzo is on a distinguished road
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.
silent1mezzo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC