Hi,

What does you form html tag looks like ? Sounds like you're sending the 
updateview form to the createview.

Regards,
Xavier Ordoquy,
Linovia.

Le 13 mai 2012 à 11:59, Michael Ackerman a écrit :

> My updateview seems to be creating another object instead of updating the 
> object. The good news is my UpdateView form is filled in with initial data, 
> but when I press submit, it creates a new ticket instead of updating the old 
> one.
> 
> #views.py
> class create_ticket(CreateView):
>     model = ticket
>     form_class = ticket_form
>     template_name = "create_ticket.html"
>     success_url = "/tickets/thanks/"
> 
> class update_ticket(UpdateView):
>     model = ticket
>     form_class = ticket_form
>     template_name = "create_ticket.html"
>     success_url = "/tickets/thanks/"
> 
> #models.py
> class ticket(models.Model):
>     title = models.CharField(max_length = 100)
>     date_created = models.DateTimeField(auto_now_add=True)
>     description = models.TextField()
>     ranking = models.PositiveIntegerField(default=0)
> 
>     def __unicode__(self):
>         return self.title
> #urls.py
> urlpatterns = patterns('',
>     (r'^$',
>         ticket_list.as_view()),
>     (r'^(?P<pk>\d+)/$',
>         ticket_detail.as_view()),
>     (r'^create/$',
>         create_ticket.as_view()),
>     (r'^thanks/$',
>         thanks_view.as_view()),
>     (r'^(?P<pk>\d+)/update/$',
>         update_ticket.as_view()),
> )
> 
> My other 2 quick questions:
> - Is the success_url and redirecting necessary? 
> - Is it possible to combine the create_ticket view and the update_ticket view?
> 
> All help is greatly appreciated.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to