Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Add file/image field#127

Open
ponytailer wants to merge 6 commits intoencode:masterfrom
ponytailer:master
Open

Add file/image field#127
ponytailer wants to merge 6 commits intoencode:masterfrom
ponytailer:master

Conversation

@ponytailer
Copy link
Copy Markdown
Contributor

@ponytailer ponytailer commented Mar 3, 2022

This was referenced Mar 3, 2022
@@ -1,4 +1,6 @@
import decimal
import imghdr
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typesystem support version <= 3.10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.11 releases just in one week. The typesystem will support it without any doubt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional dependency lib is not cost-effective. Or do not check the image type.

such as : filetype OR puremagic in pypi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be an optional dependency for those, who wants to use File fields.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Image is unnecessary. Just define the File, right?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if File() can validate the file type. So we can specify that we want image, audio, video, etc.
Something like

File(accept=['image/jpeg', 'image/png'])

This should answer your question. But IMO, a dedicated Image() field is a nice utility.

@alex-oleshkevich
Copy link
Copy Markdown

Please update Form class. Currently, it does not know how to render that new type + HTML template for it.
See
https://github.com/encode/typesystem/blob/master/typesystem/forms.py#L15
https://github.com/encode/typesystem/blob/master/typesystem/forms.py#L122

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants