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

前端 未结 5 623
既然无缘
既然无缘 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:48

    you can also try to define get_absolute_url in your models. For example

    class Something(models.Model):
        name = models.CharField(max_length=50, verbose_name='name')
    
        class Meta:
            pass
    
        def get_absolute_url(self):
            return u'/some_url/%d' % self.id 
    

提交回复
热议问题