Hi,

There's a mixin that does exactly what you're doing in your view,
ProcessFormView; used by the generic view FormView. You should use it. ;)

If you want to use the same view to delete an object you will probably have
to change your dispatch method (defined at  View class), there's no way to
do this by the urlconf module.

>From the docs:

The URLconf doesn't look at the request method. In other words, all request
methods -- POST, GET, HEAD, etc. -- will be routed to the same function for
the same URL.

Check it on:
https://docs.djangoproject.com/en/dev/topics/http/urls/#what-the-urlconf-searches-against

Just for the record, there's a generic class view, called DeleteView, that
you should use, but as a different view.

Hope that helps. ;)

[]'s

On Sat, Oct 8, 2011 at 11:12 AM, CrabbyPete <pete.do...@gmail.com> wrote:

> I am fooling around with django generic class views, and I was
> wondering if its possible to actually build class views per item for
> example I have the following class view.
>
>
> class TeamView( View, TemplateResponseMixin ):
>    template_name = 'team.html'
>
>    def get(self, request):
>        if 'team' in request.GET:
>            team = Team.objects.get(id = request.GET['team'])
>            form = TeamForm( instance = team )
>        else
>            team = None
>            form = TeamForm( )
>
>        return self.render_to_response({'form':form})
>
>    def post(self, request):
>        form = TeamForm(request.POST)
>
>        if not form.is_valid():
>            return self.render_to_response({'form': form})
>
>        ....
>
> I want to use this class to also delete the team. I love to use a
> method by itself by adding
>   def delete(self,request)
>       if 'team' in request.GET:
>            team = Team.objects.get(id = request.GET['team'])
>            team.delete()
>
> Is there a way to specify this in url.py and get around the dispatch
> for the get?
>
> Any advise 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.
>
>


-- 
Flávia Missi
@flaviamissi <http://twitter.com/flaviamissi>
flaviamissi.com.br
https://github.com/flaviamissi

-- 
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