Don't change slug for existing instances fixes #1129#1188
Merged
jaredlockhart merged 1 commit intomasterfrom Apr 22, 2019
Merged
Don't change slug for existing instances fixes #1129#1188jaredlockhart merged 1 commit intomasterfrom
jaredlockhart merged 1 commit intomasterfrom
Conversation
glasserc
reviewed
Apr 18, 2019
| del cleaned_data["slug"] | ||
| else: | ||
| name = cleaned_data.get("name") | ||
| cleaned_data["slug"] = slugify(name) |
Contributor
There was a problem hiding this comment.
This might be outside the scope of this PR, but why are we doing this in the form code and not in the model code?
Collaborator
Author
There was a problem hiding this comment.
@glasserc Putting this automation on the model makes it difficult to edit it by hand from the admin or override for testing in a console or in unit tests.
In general I try to avoid putting too much data automation in models because for every place it makes your life easier it'll blow up in some annoying way somewhere else, whereas keeping it in the form makes it clear that from the user facing workflow it'll take place, but if you go in under the hood you shouldn't expect any 'magic'.
glasserc
approved these changes
Apr 18, 2019
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Apr 29, 2025
…#12548) Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.5.2 to 4.11.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-django/releases">pytest-django's releases</a>.</em></p> <blockquote> <h2>v4.11.1</h2> <p><a href="https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4111-2025-04-03">https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4111-2025-04-03</a></p> <h2>v4.11.0</h2> <p><a href="https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4110-2025-04-01">https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4110-2025-04-01</a></p> <h2>v4.10.0</h2> <p><a href="https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4100-2025-02-10">https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4100-2025-02-10</a></p> <h2>v4.9.0</h2> <p><a href="https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v490-2024-09-02">https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v490-2024-09-02</a></p> <h2>4.8.0</h2> <p><a href="https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-8-0-2024-01-30">https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-8-0-2024-01-30</a></p> <h2>4.7.0</h2> <p><a href="https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-7-0-2023-11-08">https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-7-0-2023-11-08</a></p> <h2>4.6.0</h2> <p><a href="https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-6-0-2023-10-30">https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-6-0-2023-10-30</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst">pytest-django's changelog</a>.</em></p> <blockquote> <h2>v4.11.1 (2025-04-03)</h2> <p>Bugfixes ^^^^^^^^</p> <ul> <li>Fixed a regression in v4.11.0 for Django <code>TestCase</code> tests using the <code>databases</code> class variable (<code>[#1188](pytest-dev/pytest-django#1188) <https://github.com/pytest-dev/pytest-django/issues/1188></code>__).</li> </ul> <h2>v4.11.0 (2025-04-01)</h2> <p>Compatibility ^^^^^^^^^^^^^</p> <ul> <li>Added official support for Django 5.2 (<code>PR [#1179](pytest-dev/pytest-django#1179) <https://github.com/pytest-dev/pytest-django/pull/1179></code>__).</li> <li>Dropped testing on MySQL’s MyISAM storage engine (<code>PR [#1180](pytest-dev/pytest-django#1180) <https://github.com/pytest-dev/pytest-django/pull/1180></code>__).</li> </ul> <p>Bugfixes ^^^^^^^^</p> <ul> <li> <p>Stopped setting up and serializing databases on test session setup when not needed (the database is not requested / <code>serialized_rollback</code> is not used). On test databases with large amounts of pre-seeded data, this may remove a delay of a few seconds when running <code>pytest --reuse-db</code>.</p> <p>The determination of which databases to setup is done by static inspection of the test suite. Using pytest's dynamic features to request db access, such as :meth:<code>request.getfixturevalue("db") <pytest.FixtureRequest.getfixturevalue></code>, may throw off this analysis. If you start seeing <code>DatabaseOperationForbidden</code> or "unable to open database" errors, this is likely the cause. To fix this, decorate at least one test with the :func:<code>django_db <pytest.mark.django_db></code> marker with appropriate <code>databases</code> and <code>serialized_rollback</code> settings.</p> </li> </ul> <h2>v4.10.0 (2025-02-10)</h2> <p>Compatibility ^^^^^^^^^^^^^</p> <ul> <li>Added official support for Python 3.13.</li> </ul> <p>Improvements ^^^^^^^^^^^^</p> <ul> <li>Added <code>using</code> argument to :fixture:<code>django_assert_num_queries</code> and :fixture:<code>django_assert_max_num_queries</code> to easily specify the database alias to use.</li> </ul> <p>Bugfixes ^^^^^^^^</p> <ul> <li>Fixed lock/unlock of db breaks if pytest is executed twice in the same process.</li> </ul> <p>v4.9.0 (2024-09-02)</p> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/pytest-dev/pytest-django/commit/5ada9c1596ee9e0624801d553995d98d2e3ccce8"><code>5ada9c1</code></a> Release 4.11.1</li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/cf3f0bb89be0d741e7c4e10469d0559e86753cc7"><code>cf3f0bb</code></a> fixtures: fixup a regression in previous release for TestCase multi-db support</li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/6d5c272519037031f0b68d78dca44727b860d65e"><code>6d5c272</code></a> Release 4.11.0</li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/8000db04f07822861331d0df8ef52f9c67eafc00"><code>8000db0</code></a> Only setup and serialize databases as needed by tests</li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/6f7fc269f871da0134d9155ca856b29582aa46ce"><code>6f7fc26</code></a> Add optional integration of pytest into django's <code>manage.py test</code></li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/3071a666dce1f60299bf89bd9c268ac7e0ee459d"><code>3071a66</code></a> docs/conf.py: format with ruff format</li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/3f44e50ff326c23a44bf5633423d491a251d8eed"><code>3f44e50</code></a> fixtures: avoid unnecessary closure</li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/b7328696ad7a5bfc308b60c909972a9166fce8a3"><code>b732869</code></a> Remove testing on MyISAM (<a href="https://redirect.github.com/pytest-dev/pytest-django/issues/1180">#1180</a>)</li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/e362f4c6303b203e5449ed023b353ad81f40a753"><code>e362f4c</code></a> Add support for Django 5.2 (<a href="https://redirect.github.com/pytest-dev/pytest-django/issues/1179">#1179</a>)</li> <li><a href="https://github.com/pytest-dev/pytest-django/commit/d8dc3d9a62b97c9730111ca7c656dd3b00c479c2"><code>d8dc3d9</code></a> Release 4.10.0</li> <li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest-django/compare/v4.5.2...v4.11.1">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We auto generate the slug for things like Experiment, ExperimentVariant from its name, but we were doing it on every save so it's possible to change the slug of an experiment after it's been created (which is bad because then it changes the URL you find it at so you could break somebody's bookmarks). This change prevents changing the slug if it's already been set.