raratiru
raratiru

Reputation: 9616

Django Import Export: Documentation cannot be understood

I wish to use django import export.

https://pypi.python.org/pypi/django-import-export

While reading the documentation and after installing and configuring the package, I reached the "Creating Import-Export Resource' paragraph:

https://django-import-export.readthedocs.org/en/latest/getting_started.html#creating-import-export-resource

In which directory/file should I insert and save those lines of python that will create the resource?

Upvotes: 2

Views: 1060

Answers (1)

Alex Parakhnevich
Alex Parakhnevich

Reputation: 5172

You can create this file anywhere in your project and then just import it where it's necessary.
So, following the docs, when your app is called core:

#myproject/core/myresources.py
from import_export import resources
from core.models import Book


class BookResource(resources.ModelResource):

    class Meta:
        model = Book

And then anywhere in your project's code:

from core.myresources import BookResource

dataset = BookResource().export()

Upvotes: 2

Related Questions