Skip to content

Commit 7df263d

Browse files
committed
Document existing validators
1 parent 779d835 commit 7df263d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,26 @@ The default processor is `pictures.tasks.process_picture`. It takes a single
219219
argument, the `PictureFileFile` instance. You can use this to override the
220220
processor, should you need to do some custom processing.
221221

222+
### Validators
223+
224+
The library includes built-in validators to control image dimensions:
225+
226+
```python
227+
from pictures.models import PictureField
228+
from pictures.validators import MaxSizeValidator, MinSizeValidator
229+
230+
class Profile(models.Model):
231+
picture = PictureField(
232+
upload_to="avatars",
233+
validators=[
234+
MinSizeValidator(400, 300), # At least 400x300 pixels
235+
MaxSizeValidator(4096, 4096), # At most 4096x4096 pixels
236+
]
237+
)
238+
```
239+
240+
Use `None` to limit only one dimension: `MaxSizeValidator(2048, None)` limits only width.
241+
222242
## Migrations
223243

224244
Django doesn't support file field migrations, but we do.

0 commit comments

Comments
 (0)