Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamalton/django-href-field
Django HrefField - a model field for storing the value of an HTML href attribute
https://github.com/adamalton/django-href-field
Last synced: about 2 months ago
JSON representation
Django HrefField - a model field for storing the value of an HTML href attribute
- Host: GitHub
- URL: https://github.com/adamalton/django-href-field
- Owner: adamalton
- License: mit
- Created: 2013-12-09T23:24:35.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-16T11:59:21.000Z (about 11 years ago)
- Last Synced: 2023-03-17T13:45:29.757Z (almost 2 years ago)
- Language: Python
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
django-href-field
=================Django HrefField - a model field for storing the value of an HTML href attribute
## Spec
`HreField` takes the following keyword arguments:
* `protocols` (iterable) - allows you to specify which protocols are allowed.
* Defaults to `('http', 'https', 'mailto', 'tel')`.
* You may add other protocols such as `ftp`, `spotify`, `javascript` or `myownprotocol`.
* Validators are provided for the default protocols plus `ftp`. You will need to provide your own validation for other protocols via the `validators` keyword argument.
* `allow_paths` (boolean) - specifies whether protocol-less paths, such as `/` or `/about-us` are allowed.
* Defaults to `True`.
* `allow_fragments` (boolean) - specifies whether fragment only hrefs such as `#edit` are allowed.
* Defaults to `True`.
* `allow_query_strings` (boolean)- specifies whether query string-only hrefs such as `?sausage=1` are allowed.
* Defaults to `True`.`HrefField` is a subclass of `CharField`, so it exhibits the same behaviour in terms of `blank` and `null`, i.e. it defaults to `""`, so `null=True` is not required unless you specifically want to store `None`.
## Example
```
class Link(models.Model):text = models.CharField(max_length=100)
href = HrefField(
protocols=('http', 'https', 'mailto'),
blank=True,
)
```