jeudi 3 mai 2018

Django tests admin forms inlines

I've an admin form for a job offer. To see all job responses for that offer, my form looks like this :

class JobOfferAdminDisplayable(BaseTranslationModelAdmin):

    model = JobOffer
    inlines = [JobResponseInline,]

class JobResponseInline(TabularDynamicInlineAdmin):

    model = JobResponse

But I don't know how to test it... tried to include into post query the model's attributes + management form data but it's not working

response = self.client.post(self.url, {"title_fr" : 'title', 'form-TOTAL_FORMS': '2', 'form-INITIAL_FORMS': '1',"form-MAX_NUM_FORMS" : '2', "status" : 2, "email" :'email@email.fr', "type":'internship'})

This query generate the following error :

django.core.exceptions.ValidationError: ['ManagementForm data is missing or has been tampered with']

Aucun commentaire:

Enregistrer un commentaire