类型对象“事件”没有属性“ _default_manager”

时间:2019-01-14 14:37:50

标签: python django django-1.11

我遇到以下错误:

AttributeError at /admin2/event/edit/1/ type object 'Event' has no attribute '_default_manager'

来自新添加的代码:

(views.py)

@method_decorator(staff_member_required, name='dispatch')
class EditEvent(LoginRequiredMixin, UpdateView):
    template_name = 'admin2/events/edit-event.html'
    form_class = AddEventForm
    model = Event
    slug_url_kwarg = "events_id"
    slug_field = 'id'
    success_url = '/admin2/event/'

(urls.py)

url(r'^admin2/event/edit/(?:(?P<events_id>.+)/)?$', login_required(EditEvent.as_view()), name='edit-event-view'),

(models.py)

class Event(models.Model):
    title = models.CharField(help_text='Name of the event', max_length=250, null=False, blank=False)
    location = models.CharField(help_text='Location of the event', max_length=250, null=False, blank=False)
    date = models.DateTimeField(auto_now=False)

(forms.py)

class AddEventForm(forms.ModelForm):
    class Meta:
        model = Event
        fields = ('title', 'location', 'date')

此处的完整追溯:

http://dpaste.com/002BGGT

我正在使用Django 1.11(已过时,但无法更新)

1 个答案:

答案 0 :(得分:0)

已解决:

我将视图重命名为EditIndiView,并将模型重命名为IndiView,但是,我没有任何冲突的名称...无论如何,模型和视图的重命名解决了错误。