get() 缺少 1 个必需的位置参数:'args',Django slug RedirectView

get() missing 1 required positional argument: 'args', Django slug RedirectView

我想重定向一个视图,以便它显示标题和 id_number 但我在标题中收到错误。

型号:

from django.db import models
from django.core.urlresolvers import reverse
from autoslug import AutoSlugField


class EntitiesNew(models.Model):
    id = models.CharField(max_length=20, blank=True)
    description = models.CharField(max_length=500, blank=True)
    title = models.CharField(max_length=500, blank=True)
    id_number = models.IntegerField(primary_key=True)
    slug = AutoSlugField(populate_from='title', max_length=500)

    class Meta:
        managed = True
        db_table = 'entities_new'

    def get_absolute_url(self):
        return reverse('entity-detail', kwargs={'slug': self.slug})

    def __unicode(self):
        return self.title

观看次数:

from entities.models import EntitiesNew
from django.views import generic
from django.views.generic import TemplateView, RedirectView, ListView, DetailView

class EntityNewView(generic.ListView):
    template_name = 'entities/index.html'
    context_object_name = 'entities_list'
    def get_queryset(self):
        return EntitiesNew.objects.order_by('-id_number')[:50]


class EntityDetailView(TemplateView):
    template_name = 'entities/detail.html'
    def get_context_data(self, **kwargs):
        context=super(EntityDetailView, self).get_context_data(**kwargs)
        context['entity']=EntitiesNew.objects.get(pk=self.kwargs.get('id_number', None))
        return context

class EntityRedirectDetailView(RedirectView):

    def get(self, request, args, **kwargs):
        id_number = self.kwargs.get('id_number', None)
        entity = EntitiesNew.objects.get(pk=id_number)
        self.url = '/entities/%s-%s' % (entity.id, entity.slug)
        return super(EntityRedirectDetailView, self).get(request, args, **kwargs)

网址:

from django.conf.urls import patterns,url
from entities import views

urlpatterns = [
    url(r'^$', views.EntityNewView.as_view(), name='entities'),   
    url(r'^(?P<id_number>\d+)/$', views.EntityRedirectDetailView.as_view(), name='entity-redirect'),
    url(r'^(?P<id_number>\d+)-(?P<slug>\w+)/$', views.EntityDetailView.as_view(), name='entity-detail'),

]

有什么建议吗? 谢谢

您在 get 函数的签名中遗漏了 *:

def get(self, request, *args, **kwargs):