Django - Class Based Generic View - “No URL to redirect to”

前端 未结 5 621
既然无缘
既然无缘 2021-01-31 14:09

I\'m using the generic CreateView like:

#urls.py

from django.conf.urls.defaults import *
from django.views.generic import CreateView
from content.models import          


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-31 14:45

    Have you tried passing in success_url? e.g.

    CreateView.as_view(model=myModel, success_url="/success/")
    

    or if you want to redirect to a named view:

    CreateView.as_view(model=myModel, success_url=reverse('success-url'))
    

提交回复
热议问题