0

I have to implement several forms, therefore I need the combination of SingleObjectMixin, TemplateView. I always receive 'AssignAttendee' object has no attribute 'object'. Do you see why I get that error?

class AssignAttendee(SuccessMessageMixin, SingleObjectMixin, TemplateView):
    template_name = 'attendees/front/assign_attendee.html'
    success_message = _("Attendee has been successfully updated.")

    def get_object(self):
        return get_object_or_404(
            Attendee,
            ticket_reference=self.kwargs['ticket_reference'],
            ticket_code=self.kwargs['ticket_code'],
        )

    @cached_property
    def attendee_form(self):
        return AssignAttendeeForm(
            prefix='attendee',
            data=self.request.POST or None,
            # instance=self.attendee_contact,
        )

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context = {
            'attendee_form': self.attendee_form,
        }
2
  • 2
    Please show the full traceback Commented Dec 20, 2018 at 13:05
  • I actually could solve it now. Will post the answer. Commented Dec 20, 2018 at 13:32

1 Answer 1

1

The problem was that it was missing:

def get(self, request, *args, **kwargs):
    self.object = self.get_object()
    return super().get(request, *args, **kwargs)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.