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

ImageField and FileField transforms are incomplete #12

Closed
enoren opened this issue Jul 20, 2014 · 1 comment
Closed

ImageField and FileField transforms are incomplete #12

enoren opened this issue Jul 20, 2014 · 1 comment

Comments

@enoren
Copy link

enoren commented Jul 20, 2014

Currently only url and name attributes are being exposed to pylint through the transforms, however since under the covers these Fields are really instances of FieldFile and ImageFieldFile at runtime there are many more attributes that are needed such as the File operations, etc.

To resolve this locally I did the following within the django_db_models_fields_files.py transform definition which I think should be suitable as a solution here without having to enumerate all attributes exhaustively:

try:
    from django.db.models.fields.files import FieldFile, ImageFieldFile
except ImportError:
    FieldFile = object
    ImageFieldFile = object


class FileField(FieldFile):
    pass


class ImageField(ImageFieldFile):
    pass
carlio added a commit that referenced this issue Sep 14, 2014
…les using a similar technique to #7 and the solution suggested by @enoren in #12 - namely, subclass both the Django Field type and the type that it is converted to by Django meta-programming
@carlio
Copy link
Collaborator

carlio commented Sep 14, 2014

Combining this with the idea from #7, I did something like:

class ImageField(files.ImageFieldFile, fields.ImageField):
    pass

This combines the attributes from both, which is good as otherwise pylint would complain about the constructor when defining the fields...

This will be available in the 0.5 release, coming soon!

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