Override get_instance import-export django
<p>I have a basic problem in Django/ Python. But I don't know the right answer.</p>

<p>I have to override "get_instance" in django-import-export.instance_loaders</p>

<p>Actually i change the code directly in this function. I know this is not very clever. But I don#t understand where I should override this function.</p>

<p>In MyModelResource or where?</p>

<p>Hope anybody can help me. Thanks</p>

<p>Basically, you need to define custom <code>InstanceLoader</code> class in your resource inner <code>Meta</code> class:</p>

<pre><code>class BookResource(resources.ModelResource):

    class Meta:
        model = Book
        fields = ('id', 'name', 'price',)
        instance_loader_class = MyCustomInstanceLoaderClass

class MyCustomInstanceLoaderClass(BaseInstanceLoader):
    def get_instance(self, row):
        # your implementation here
</code></pre>

<p>Something like this should help you.</p>

python django