Commit Graph

1215 Commits

Author SHA1 Message Date
Asif Saif Uddin {"Auvi":"অভি"}
584b379434
Merge branch 'main' into master 2025-12-24 02:55:01 +00:00
therealjozbert
78db4dd543
Add tests for .data access before .is_valid() in relation serializers (#9845)
- Add test_data_cannot_be_accessed_prior_to_is_valid to HyperlinkedManyToManyTests
- Add test_data_cannot_be_accessed_prior_to_is_valid to PKManyToManyTests
- Remove TODO comments that were addressed
- Ensures AssertionError is raised when accessing .data before validation

Fixes TODO items in:
- tests/test_relations_hyperlink.py (line 71)
- tests/test_relations_pk.py (line 97)

Co-authored-by: therealjozbert <info@therealjozbert.com>
Co-authored-by: Asif Saif Uddin {"Auvi":"অভি"} <auvipy@gmail.com>
2025-12-09 23:27:42 +06:00
Manolis Stamatogiannakis
d6ffc95532
Updates for TokenAdmin. (#9836)
- Respect USERNAME_FIELD of the user model.
- Default ordering by username.
- Filter by creation date.

Co-authored-by: Asif Saif Uddin {"Auvi":"অভি"} <auvipy@gmail.com>
2025-12-08 09:06:33 +06:00
Asif Saif Uddin {"Auvi":"অভি"}
91063d47b8
Merge branch 'main' into master 2025-12-05 12:23:28 +00:00
fbz
06c3aa5964 Merge remote-tracking branch 'origin/master' 2025-12-05 20:18:42 +08:00
fbz
f580b11725 test: add test cases 2025-12-05 20:17:49 +08:00
Mehraz Hossain Rumman
0fbaebc3dd
Add Django 6.0 support (#9819)
* adding django6.0a support

* test fixed

* gitignore updated

* pre-commit applied

* test issue 1386 fixed

* fixing test issue 1386

* .gov domain handled for different version

* correct urls updated

* Modify URL test cases for Django version compatibility

Adjust URL test cases based on Django version.

* Add Django import to test_templatetags.py

* Reorder import statements in test file

* Update tox.ini

* Update tox.ini

* Revert unnecessary changes in tests

* Default to AutoField for now

* Add Django upper bound to base and dist tests to avoid testing on unsupported versions

---------

Co-authored-by: Asif Saif Uddin {"Auvi":"অভি"} <auvipy@gmail.com>
Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
2025-12-05 16:30:00 +06:00
Asif Saif Uddin {"Auvi":"অভি"}
74ee942893
Merge branch 'main' into master 2025-12-05 10:19:18 +00:00
Shrikant Sudam Giri
e027f0cb77
Fix Windows test failures and remove debug prints for DRF (#9808) 2025-12-05 08:45:01 +00:00
HoodyH
f9f10e041f
Bigint coerce to string (#9775)
* feat: BinIntegerField and COERCE_BIGINT_TO_STRING setting, bigint now can have string api representation

* fix: wrong import location in serializers.py

* feat: updated with changes requests
- typo fix
- value test fix
- import order fix

* Update tests/test_fields.py

* Update docs/api-guide/fields.md

* Update docs/api-guide/fields.md



* refactor: changed BigIntegerField.to_representation simplified + calling super

---------

Co-authored-by: Asif Saif Uddin {"Auvi":"অভি"} <auvipy@gmail.com>
2025-12-02 20:44:53 +06:00
Samiul Sk
d692b87a2b
Add validation for decorator order with @api_view (#9821)
* Add validation for decorator order with @api_view

Raise TypeError when API policy decorators (@permission_classes,
@renderer_classes, etc.) are applied after @api_view instead of before it.

Fixes #9596

* Address PR review feedback: update error message wording and example

- Change 'must be applied before' to 'must come after (below) the' to match DRF docs language
- Fix decorator order in example to show @api_view first, then policy decorator below
- Remove unnecessary f-string prefixes from non-interpolated lines
- Update all test assertions to match new error message wording

Addresses feedback from @browniebroke in PR #9821
2025-11-29 19:36:58 +06:00
Ülgen Sarıkavak
29e6241feb
Bump psycopg to 3.1.8+ (#9815)
The earliest supported Django version 4.2 recommends using psycopg>=3.1.8

https://docs.djangoproject.com/en/4.2/ref/databases/#postgresql-notes
2025-11-03 15:23:56 +06:00
Bruno Alla
1660c22f3a
Delay CoreAPI deprecation until DRF 3.18 (#9810) 2025-10-30 18:02:24 +00:00
Corentin Garcia
ad0fea04de
Add support for ipaddress objects in JSONEncoder (#9087)
* Add support for ipaddress objects in JSONEncoder

* Update tests/test_encoders.py

* Update assertions to be more explicit

---------

Co-authored-by: Asif Saif Uddin {"Auvi":"অভি"} <auvipy@gmail.com>
Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
2025-10-30 16:27:20 +06:00
Marcelo Galigniana
01659c075a
Fixed #5363 -- HTML5 datetime-local valid format HTMLFormRenderer (#9365)
* Fixed #5363 -- HTML5 datetime-local valid format HTMLFormRenderer

Co-authored-by: Peter Thomassen

* Add condition to make code cleanable by pyupgrade

---------

Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
2025-10-30 16:23:54 +06:00
Pravin
ade172e1d5
Standardize spelling to American English in documentation (#9804)
* Standardize spelling to American English (only in .md files)

* Update remaining British english spell words to American english style

* Configures the codespell pre-commit hook to enforce US English consistency
changes:
- Activates the `en-GB_to_en-US` built-in dictionary to flag British spellings
- Created codespell-ignore-words.txt file to ignore specific words
- include `code` and `names` for comprehensive typo checking in technical contexts.
- changed the 'lets' to 'let's'.
2025-10-27 22:44:48 +06:00
Bruno Alla
e045dc4652
Update pre-commit hooks (#9805)
* Auto-update pre-commit hooks

* Supress new flake8 error

* Fix codespell
2025-10-22 13:47:00 +01:00
Genaro Camele
577bb3c819
Validation on ManyToManyField when default=None (#9790)
* Added validation on ManyToMany relations when default=None and tests
* Some clarifications in contributing.md
2025-10-14 08:22:23 +02:00
Sergei Aleshin
9cf6efb4a8
Support violation_error_code and violation_error_message from UniqueConstraint in UniqueTogetherValidator (#9766)
* fix(serializer): restore get_unique_together_constraints method signature
Extracted error message logic to a separate method.

fix: conditionally include violation_error_code for Django >= 5.0

fix(validators): use custom error message and code from model constraints

* fix: add model parents to create unique_constraint_by_fields

* fix: order of model classes in the unique_constraint_by_fields
2025-10-09 23:47:30 +06:00
Cheery
cf923511e7
Add missing decorators: @versioning_class(), @content_negotiation_class(), @metadata_class() for function based views (#9719) 2025-09-20 11:12:17 +01:00
fbozhang
49457373e3
Update test_fields.py 2025-08-18 01:25:25 +08:00
fbozhang
57f1dd244f
Update test_fields.py 2025-08-18 01:19:02 +08:00
fbozhang
bbc27c0fc0
Update test_fields.py 2025-08-18 01:14:27 +08:00
fbozhang
fab5f7702f
Merge branch 'main' into master 2025-08-18 01:10:09 +08:00
Marcelo Galigniana
503f0603e6
Add documentation about how to transform factory request to DRF request (#9380) 2025-08-16 13:09:47 +06:00
Nicolas Delaby
513ddb4ffb
Condition of UniqueTogetherValidator can be read-only (#9764)
* Condition of UniqueValidator can be read-only

We can't always expect to find the value of the condition in the serializer
if the field is read-only.

* Reproducible test
2025-08-13 10:53:25 +06:00
Devid
c8b6d3dcdf
DurationField output format (#8532)
* Allow format duration as ISO-8601

* Update tests/test_fields.py

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>

* Update tests/test_fields.py

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>

* Add validation for DurationField format, add more tests for it and improve related docs

* Add more precise validation check for duration field format and adjust docs

* Adjust typo in duration field docs

---------

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
2025-08-12 16:21:01 +02:00
Mahdi Rahimi
c0166d95bb
Prevent small risk of Token overwrite (#9754)
* Fix #9250: Prevent token overwrite and improve security

- Fix key collision issue that could overwrite existing tokens
- Use force_insert=True only for new token instances
- Replace os.urandom with secrets.token_hex for better security
- Add comprehensive test suite to verify fix and backward compatibility
- Ensure existing tokens can still be updated without breaking changes

* Fix code style: remove trailing whitespace and unused imports

* Fix #9250: Prevent token overwrite with minimal changes

- Add force_insert=True to Token.save() for new objects to prevent overwriting existing tokens
- Revert generate_key method to original implementation (os.urandom + binascii)
- Update tests to work with original setUp() approach
- Remove verbose comments and unrelated changes per reviewer feedback

* Fix flake8 violations: remove extra blank lines and trailing whitespace

* Update tests/test_authtoken.py

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>

* Update tests/test_authtoken.py

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>

* Update tests/test_authtoken.py

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>

* Fix token key regeneration behavior and add test

* Update tests/test_authtoken.py

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>

---------

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
2025-08-10 16:52:32 +06:00
Mahdi Rahimi
97a771c405
Refactor token generation to use secrets module (#9760)
* Refactor token generation to use secrets module

* test: Add focused tests for Token.generate_key() method

- Add test for valid token format (40 hex characters)
- Add collision resistance test with 500 sample size
- Add basic randomness quality validation
- Ensure generated keys are unique and properly formatted
2025-08-10 09:42:52 +06:00
Jakub Kulík
853969c69c
Fix test with Django 5 when pytz is available (#9715)
* Fix test with Django 5 when pytz is available

* fix formatting

* remove original condition

Co-authored-by: Ülgen Sarıkavak <ulgens@users.noreply.github.com>

* remove trailing whitespace

* further improvements

* let's not skip the pytz test - it should always be executed when testing against Django 4

* add comment to test requirements

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>

* simplify the pytz import as it should always be available

* make isort happy

---------

Co-authored-by: Ülgen Sarıkavak <ulgens@users.noreply.github.com>
Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
2025-07-24 08:47:47 +01:00
fbz
40465d95c5 fix: using pytest.fail to test 2025-07-06 16:24:52 +08:00
fbz
1977c5b575 minor: rest old formatting 2025-07-06 00:30:21 +08:00
fbz
cfd4412a1e test: fix unit test
(cherry picked from commit 73a709c4b04ae510d61f2d426f93f6aef98b09fd)
2025-07-06 00:24:27 +08:00
fbz
0ee24d5716 test: test TestMultipleChoiceField can json serializable
(cherry picked from commit 12908b149c446598682269f8df78290fa8268982)
2025-07-06 00:24:27 +08:00
fbz
3e09113622 test: fix unit tests
(cherry picked from commit 6428ac4a05f4a33eb0813cc56d584f56e7bfac89)
2025-07-06 00:24:27 +08:00
Konstantin Alekseev
e454758fb6
Fix regression in unique_together validation with SerializerMethodField (#9712) 2025-06-10 12:47:28 +01:00
Tom Christie
78e97074e7
Drop HTML line breaks on long headers in browsable API (#9438)
* Drop HTML line breaks on long headers

* Remove related test

* Fix flake8

---------

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
2025-04-28 04:08:48 +00:00
Josh Thomas
543996711d
Fix UniqueTogetherValidator to handle fields w/ source attr (#9688)
* Add failing test for `UniqueConstraint` validation with `source` attribute

* Fix `UniqueTogetherValidator` to handle fields with source attribute

* split inner sources logic out to tuple comprehension
2025-04-23 09:03:14 +00:00
Ülgen Sarıkavak
ea1da76196
Add pyupgrade to pre-commit hooks (#9682) 2025-04-09 06:24:18 +00:00
Bruno Alla
3c755794df
Cleanup dependencies and conditions for unsupported Python versions (#9681)
* Remove optional install backports.zoneinfo for unsupported Python versions and associated code

* Remove conditions in tests for unsupported Python versions

* Remove condition for unsupported Python versions
2025-04-08 08:29:40 +00:00
Mike Manger
73cbb9cd4a
Fix typos (#9662)
* Fix typo of 'related' in tests

* Fix typo of permission_classes in coreapi test

* Fix some minor typos in docs

* Fix typos in tests

* Fix flake8 issue
2025-03-08 15:53:15 +06:00
Konstantin Alekseev
17e95604f5
Fix unique together validator doesn't respect condition's fields (#9360) 2025-02-17 14:01:32 +06:00
Oliver Sauder
4a1d773b8f
Fixed regression that tests using format still work (#9615)
* Fixed regression that tests using format still work

Error only occurred on tests which return no content and use
a renderer without charset (e.g. JSONRenderer)

* Fixed linting

* Used early return as before

* Move ret str check back to where it was
2025-01-11 00:56:36 +06:00
Terence Honles
089f6a6974
support django 2.1 test client json data automatically serialized (#6511) 2024-12-28 16:22:21 +06:00
Bruno Alla
a8595a8eae
Fix raising on nullable fields part of UniqueConstraint (#9531)
* Add test to reproduce problem with nullable fields part of a unique constraint

Ref #9378

* Simplify test case and add similar case for unique_together

* Add test for unique together in a better place

* Default nullable fields to null in unique constraints checks

* Remove redundant test and move other to more appropriate place
2024-12-14 15:08:22 +06:00
Bruno Alla
a59aa2dfe1
Add test covering Update view without queryset attribute (#9528) 2024-09-11 15:37:33 +06:00
Bruno Alla
2ede857de0
Add official support for Django 5.1 (#9514)
* Add official support for Django 5.1

Following the supported Python versions:

https://docs.djangoproject.com/en/stable/faq/install/

* Add tests to cover compat with Django's 5.1 LoginRequiredMiddleware

* First pass to create DRF's LoginRequiredMiddleware

* Attempt to fix the tests

* Revert custom middleware implementation

* Disable LoginRequiredMiddleware on DRF views

* Document how to integrate DRF with LoginRequiredMiddleware

* Move login required tests under a separate test case

* Revert redundant change

* Disable LoginRequiredMiddleware on ViewSets

* Add some integrations tests to cover various view types
2024-09-07 17:21:18 +06:00
Bruno Alla
125ad42eb3
Accept integers as min/max values of DecimalField (#9515)
* Use Decimal for min/max values of DecimalField in tests

* Update docs to mention that min/max values should be Decimal objects

* Accept integer values for DecimalField min and max values

* Update expected error messages in tests

* Update expected warning message in tests
2024-09-07 17:07:28 +06:00
Yuekui
518eb22e67
Fix unique_together validation with source (#9482) 2024-08-05 16:36:50 +06:00
James McHugh
8e304e1adb
Fixed AttributeError raised by data property being silently ignored (#9455)
Signed-off-by: James Riley McHugh <mchugh_james@bah.com>
Co-authored-by: James Riley McHugh <mchugh_james@bah.com>
2024-07-17 22:51:39 +06:00