def get_initial(self): d = super().get_initial() doc_id = self.kwargs['doc_id'] self.record = primo.primo_request(doc_id) data = nli.parse_record(self.record) collection, created = models.Collection.objects.get_or_create( code=data['collection_code'], defaults={ 'title': data['collection_title'], }) data['collection'] = collection.id d.update(data) return d