Commit Graph

28 Commits

Author SHA1 Message Date
Sebastian Pipping
373e521f36 Make CharField prohibit surrogate characters (#7026) (#7067)
* CharField: Detect and prohibit surrogate characters

* CharField: Cover handling of surrogate characters
2020-01-06 14:12:21 +00:00
Ryan P Kilby
236667b717 Fix UniqueTogetherValidator with field sources (#7086)
* Add failing tests for unique_together+source

* Fix UniqueTogetherValidator source handling

* Fix read-only+default+source handling

* Update test to use functional serializer

* Test UniqueTogetherValidator error+source
2019-12-12 13:02:30 +00:00
Ryan P Kilby
de9f1d56c4 Followup to set_context removal (#7076)
* Raise framework-specific deprecation warnings

- Use `RemovedInDRF313Warning` instead of DeprecationWarning
- Update to follow deprecation policy

* Pass serializer instead of model to validator

The `UniqueTogetherValidator` may need to access attributes on the
serializer instead of just the model instance. For example, this is
useful for handling field sources.

* Fix framework deprecation warning in test

* Remove outdated validator attribute
2019-12-11 08:44:08 +00:00
Tom Christie
070cff5a03
Drop set_context() (#7062)
* Do not persist the context in validators

Fixes encode/django-rest-framework#5760

* Drop set_context() in favour of 'requires_context = True'
2019-12-03 11:16:27 +00:00
Jon Dufresne
3f19e66d9f Replace all usage ugettext functions with the non-u versions (#6634)
On Python 3, the ugettext functions are a simple aliases of their non-u
counterparts (the 'u' represents Python 2 unicode type). Starting with
Django 3.0, the u versions will be deprecated.

https://docs.djangoproject.com/en/dev/releases/3.0/#id2

> django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
> ungettext(), and ungettext_lazy() are deprecated in favor of the
> functions that they’re aliases for:
> django.utils.translation.gettext(), gettext_lazy(), gettext_noop(),
> ngettext(), and ngettext_lazy().
2019-05-01 07:49:54 +02:00
Carlton Gibson
0407a0df8a
Dropped Python 2 compatibility. (#6615)
Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com>
2019-04-30 17:53:44 +02:00
Ryan P Kilby
5c19652080 Fix whitespace in imports 2017-11-25 21:10:30 -05:00
José Padilla
c1f31492ae
Update links after moving to encode org 2017-04-07 10:28:35 -04:00
Tom Christie
a3802504a0 Error codes (#4550)
Add error codes to `APIException`
2016-10-11 10:25:21 +01:00
Rowan Seymour
883efbc19f Case insensitive uniqueness validation (#4534) 2016-10-04 13:44:50 +01:00
Tom Christie
f81d516ae4 Robust uniqueness checks. (#4217)
* Robust uniqueness checks
* Add master to test matrix (allow_failures)
2016-06-23 15:09:23 +01:00
Xiao Hanyu
19bdfda49a Fix #3844, refine validator for fields with <source=> kwargs
When serializers has fields with something like `source=user.email`, the
uniqueness validator should check `email` field instead of `user`, cause
`user` is a model object.
2016-05-26 10:58:37 +08:00
Omer Katz
2e178bc970 Replaced all dict and set conversions from lists to dict and set literals. 2015-10-17 12:00:11 +03:00
José Padilla
83c9136c90 Cleanup import following PEP 8 style guide 2015-06-25 16:10:17 -04:00
Ian Foote
32c885c2a0 Ensure validators are new-style classes on python2 2015-02-27 15:22:19 +00:00
Aider Ibragimov
fe8d95f93e Skip validation of NULL field only if it part of unique_together 2015-02-19 18:03:44 +03:00
Aider Ibragimov
3d85473edf Fix UniqueTogetherValidator for NULL values 2015-02-18 21:00:12 +03:00
Tom Christie
72e08a3e8b Use unicode internally everywhere for 'repr' 2014-12-15 11:55:17 +00:00
Tymur Maryokhin
d9930181ee Removed unused imports, pep8 fixes, typo fixes 2014-12-05 00:29:28 +01:00
Tom Christie
8586290df8 Apply defaults and requiredness to unique_together fields. Closes #2092. 2014-11-19 13:55:10 +00:00
Tom Christie
fd7db776ad Bring UniqueValidator implementation in line with other uniquness validators. 2014-11-10 12:32:03 +00:00
Tom Christie
f387cd89da Uniqueness constraints imply a forced 'required=True'. Refs #1945 2014-11-10 12:21:27 +00:00
Tom Christie
2762205887 Validator documentation and tweaks 2014-10-31 13:47:36 +00:00
Tom Christie
ae53fdff9c First pass at unique_for_date, unique_for_month, unique_for_year 2014-10-22 13:30:28 +01:00
Tom Christie
5f4cc52ef5 Tweaking 2014-10-09 10:11:44 +01:00
Craig de Stigter
dfab9af294 Minor: fix spelling and grammar, mostly in 3.0 announcement 2014-10-03 08:41:18 +13:00
Tom Christie
9805a085fb UniqueTogetherValidator 2014-09-29 11:23:02 +01:00
Tom Christie
43fd5a8730 Uniqueness validation 2014-09-29 09:24:03 +01:00