<commit_before>django-href-field
=================

Django HrefField - a model field for storing the value of an HTML href attribute <commit_msg>Adding details of how this is (hopefully) going to work to the README.<commit_after>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` or `imaginary`.
  * 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.

`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,
    )
```
{'fraction_non_alphanumeric': 0.1270967741935484, 'fraction_numerical': 0.0025806451612903226, 'mean_word_length': 4.257627118644068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3448381', 'n_tokens_mistral': 464, 'n_tokens_neox': 437, 'n_words': 188}