I know the solution, this appear in the django documentation, but no resolv 
my problem.  I redefine "dispatch" function in Django 1.4.X, 

class MatterUpdateView( UpdateView ):
    template_name = 'object_add.html'
    success_url = '/manage_p1/list/'
    model = Matter
    form_class = MatterForm

    def dispatch( self, request, *args, **kwargs ):
        if not kwargs :            
                    kwargs['pk'] = request.GET.get('pk', '')
                    if not bool( kwargs['pk'] ):                
                        kwargs['pk'] = request.POST.get('pk', '')


This code resolve the problem, but dose not in Django 1.5, I not know what 
to change in this version.



El viernes, 7 de junio de 2013 13:02:54 UTC-5, Nikolas Stevenson-Molnar 
escribió:
>
>  I assume that MatterUpdateView is a subclass of the generic UpdateView 
> class. If so, that class expects an object pk (id) or slug to be included 
> as part of the URL pattern, and yours doesn't include either. Your URL 
> pattern should look something more like: r"^manage/(?P<pk>\d+)/update/"
>
> _Nik
>
> On 6/6/2013 10:16 PM, Ariel V. R. wrote:
>  
> Code: 
>
> HTML
> <form id="form-edit" action="/manage_p1/update/" method="get"  >
>       <input  id="input-pk" type="hidden" value="0" name="pk">            
>             
> </form> 
>
> JS
> $('.icon-edit').click( function() {
>         $object_id = $(this).parents().eq(0).attr('id');
>         $('#form-edit #input-pk').attr('value', $object_id);
>         $('#form-edit').submit();
>     }) 
>
> URL.PY
>
> ...
> url(r'^manage_p1/update/', MatterUpdateView.as_view()),  
> ...
>
>
>
> El jueves, 6 de junio de 2013 23:45:59 UTC-5, Ariel V. R. escribió: 
>>
>> Hello:
>>
>> I need to send data from html using javascript to UpdateView. Django 
>> sends me an error:  "Generic detail view MatterUpdateView must be called 
>> with either an object pk or a slug."
>>
>> I think that the problem exists because the method as_view() does not 
>> receive the correct data.
>>
>>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com <javascript:>.
> To post to this group, send email to django...@googlegroups.com<javascript:>
> .
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>
> 

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


Reply via email to