Validate that your slugs do not match a keyword in your url
Rationale
Suppose you have some of urls like:
country-of-fire/edit/
country-of-fire/hidden-leaf-village/
country-of-fire/hidden-leaf-village/edit/
country-of-fire/forest-of-death/
country-of-fire/forest-of-death/edit/
If the feudal lords of the Country of Fire decided to found a new village, you would kindly try to suggest them to avoid names like edit or delete; they probably won’t understand anything about technological constraints, but your suggestion could be nonetheless welcome.
Instead of trying to explain why it’s not a good idea to found “Edit” (though maybe “Edit Village” may be acceptable), you may just write a piece of software that will not let anybody register any place suchly named. This is called validation.
Usage
Modify your settings.py to include the list of words you want to use as keywords:
# settings.py
URL_KEYWORDS = ('new', edit', 'delete')
Then add the validator to your slug field:
# models.py
from urlkeyword import validate_url_keyword
class Village(Model):
code = models.SlugField(max_length=20, validators=[validate_url_keyword])
Metadata
Release files for django-urlkeyword 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-urlkeyword-0.1.1.tar.gz | 3.0 kB | Without provenance | Details for django-urlkeyword-0.1.1.tar.gz |
Release files / django-urlkeyword-0.1.1.tar.gz
| Download URL | django-urlkeyword-0.1.1.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18a87469599c170529b646ec6249b8872bfb416286f7367c71eca3f0e597d127
|
|
BLAKE2b-256 checksum How to use checksums |
53d3e83600e837601377b2ed5be3189260954800bd91f39bda3e2d3ceaa20d05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-urlkeyword 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.