开发者

getting except ObjectDoesNotExist to direct to a view in Django

开发者 https://www.devze.com 2023-01-28 05:03 出处:网络
I need a way to return a redirect to a view if ObjectDoesNotExist is True. I was trying this: except ObjectDoesNotExist:

I need a way to return a redirect to a view if ObjectDoesNotExist is True. I was trying this:

except ObjectDoesNotExist: return HttpResponseRedirect(reverse开发者_开发问答('create_profile'))

But I'm getting arg and kwarg arguements, which makes sense.

But am I thinking about this the right way?

Suggestions welcome.


Supply to reverse() the values that the create_profile view would normally take.

0

精彩评论

暂无评论...
验证码 换一张
取 消