Re: How to change this function to use generic view

2009-12-07 Thread 邓超
Anyone? Please...

2009/12/7 一千瓦的刀狼 

> Hello? Anyone can help me?
>
> On Dec 6, 9:18 am, 邓超  wrote:
> > Hi all,
> >   I want to change below function to use the generic view function
> > update_object:
> >
> > @login_required
> > def edit_bug_page(request, bug_id = None):
> > if bug_id == None:
> > bugInstance = Bug()
> > else:
> > bugInstance = get_object_or_404(Bug, pk = bug_id)
> > members = bugInstance.project.member.order_by('member')
> >
> > if request.user not in members:
> > return HttpResponseRedirect('/bug/fail/')
> >
> > if request.method == 'POST':
> > form = BugForm(request.POST, instance = bugInstance)
> >
> > if form.is_valid():
> > bug = form.save()
> >
> > return HttpResponseRedirect('/bug/success/')
> > else:
> > form = BugForm(instance = bugInstance)
> >
> > variables = RequestContext(request, {'form': form})
> >
> > return render_to_response('add_bug.html', variables)
> >
> > But how to use the update_object function in my views.py? Someone can
> help
> > me? Thanks a lot!
> > --
> > Deng Chao
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>
>


-- 
Deng Chao

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Re: How to change this function to use generic view

2009-12-06 Thread 一千瓦的刀狼
Hello? Anyone can help me?

On Dec 6, 9:18 am, 邓超  wrote:
> Hi all,
>   I want to change below function to use the generic view function
> update_object:
>
> @login_required
> def edit_bug_page(request, bug_id = None):
>     if bug_id == None:
>         bugInstance = Bug()
>     else:
>         bugInstance = get_object_or_404(Bug, pk = bug_id)
>         members = bugInstance.project.member.order_by('member')
>
>         if request.user not in members:
>             return HttpResponseRedirect('/bug/fail/')
>
>     if request.method == 'POST':
>         form = BugForm(request.POST, instance = bugInstance)
>
>         if form.is_valid():
>             bug = form.save()
>
>             return HttpResponseRedirect('/bug/success/')
>     else:
>         form = BugForm(instance = bugInstance)
>
>     variables = RequestContext(request, {'form': form})
>
>     return render_to_response('add_bug.html', variables)
>
> But how to use the update_object function in my views.py? Someone can help
> me? Thanks a lot!
> --
> Deng Chao

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.