Reputation: 296
I am getting the following error:
AttributeError at /admin2/event/edit/1/
type object 'Event' has no attribute '_default_manager'
from the newly added code:
(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')
Full traceback here:
I am using Django 1.11 (outdated but I am unable to update)
Upvotes: 0
Views: 1879
Reputation: 296
Solved:
I renamed my view to EditIndiView and renamed my model to IndiView, however, I did not have any conflicting names...regardless, the renaming of the model and view solved the error.
Upvotes: 1