Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta.fields shadows import_export.fields #703

Closed
krishraghuram opened this issue Dec 10, 2017 · 1 comment
Closed

Meta.fields shadows import_export.fields #703

krishraghuram opened this issue Dec 10, 2017 · 1 comment

Comments

@krishraghuram
Copy link
Contributor

krishraghuram commented Dec 10, 2017

from import_export import resources, fields
from .models import Profile

class ProfileResource(resources.ModelResource):
	class Meta:
		model = Profile
	        fields = ('rollno', 'name', 'resident_hostel', 'subscribed_hostel')
        rollno = fields.Field(readonly = True)

I get an error 'tuple' object has no attribute 'Field' in the last line.

I assume this is because import_export.fields is being shadowed by the fields tuple that specify white listed fields.

The easy fix is : from import_export.fields import Field instead of from import_export import fields
But I think this problem should be mentioned in the Getting Started section of docs, so that new users don't get confused.

@bmihelac
Copy link
Member

Hello @krishraghuram,

thanks for raising this, I see how it can add confusion. Would you like to make PR which would update docs to use from import_export.fields import Field instead of from import_export import fields?

krishraghuram added a commit to krishraghuram/django-import-export that referenced this issue Dec 11, 2017
bmihelac added a commit that referenced this issue Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants