类型对象 'Event' 没有属性“_default_manager”
type object 'Event' has no attribute '_default_manager'
我收到以下错误:
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')
这里有完整的回溯:
我正在使用 Django 1.11(已过时但无法更新)
已解决:
我将我的视图重命名为 EditIndiView 并将我的模型重命名为 IndiView,但是,我没有任何冲突的名称...无论如何,重命名模型和视图解决了错误。
我收到以下错误:
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')
这里有完整的回溯:
我正在使用 Django 1.11(已过时但无法更新)
已解决:
我将我的视图重命名为 EditIndiView 并将我的模型重命名为 IndiView,但是,我没有任何冲突的名称...无论如何,重命名模型和视图解决了错误。