Django Inline formsets example: mybook
Daniel Chen

Hi Daniel Chen and people. I again, sorry

I’ve the post form to create an object and I get this error

`Exception Type: TypeError at /host/lodging-offer/new/
Exception Value: ‘NoneType’ object is not subscriptable`

This error is presented in my in the `LodgingOfferImageCreate` view, which is similar to `ProfileFamilyMemberCreate` in the sample in this article

The error is presented in:

I am calling many form fields in my view, which belong to the `LodgingOffer` model (similar to `ProfileModel` here)

My `LodgingOfferImageCreate` view is:

class LodgingOfferImageCreate(CreateView):
model = LodgingOffer
fields = ['ad_title', 'country', 'city', 'address', 'lodging_offer_type', 'stars', 'check_in', 'check_out', 'offered_services', 'featured_amenities', 'room_type_offered', 'number_guest_room_type', 'bed_type', 'bathroom', 'room_information', 'image', 'room_value', 'additional_description', 'is_taked']
success_url = reverse_lazy("articles:article_list")

def get_context_data(self, **kwargs):
data = super(LodgingOfferImageCreate, self).get_context_data(**kwargs)
if self.request.POST:
data['lodgingimages'] = LodgingOfferImagesFormset(self.request.POST)
data['lodgingimages'] = LodgingOfferImagesFormset()
return data

def form_valid(self, form):
context = self.get_context_data()
lodgingimages = context['lodgingimages']
with transaction.atomic():
self.object =

if lodgingimages.is_valid():
lodgingimages.instance = self.object
return super(LodgingOfferImageCreate, self).form_valid(form)

I guess or I think that this error is related with the `context['lodgingimages']` which is sent to the template which I try print in the and cannot get some value

I am understanding the sample presented here and adapt it to my particular situation, but I cannot get what happen in this situation …

Has anything similar happened to anyone?

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.