django-regex-field


Namedjango-regex-field JSON
Version 3.1.0 PyPI version JSON
download
home_pagehttps://github.com/ambitioninc/django-regex-field
SummaryDjango Regex Field
upload_time2023-06-28 20:24:53
maintainer
docs_urlNone
authorWes Kendall
requires_python
licenseMIT
keywords django regex field
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            [![Build Status](https://travis-ci.org/ambitioninc/django-regex-field.png)](https://travis-ci.org/ambitioninc/django-regex-field)

# django-regex-field

Stores regular expressions in Django models.

## A Brief Overview
The Django regex field app provides a custom field for a Django model that
stores a regex. This provides the ability to easily store regexs and access
them as compiled regular expressions from your models.


## Storing and Retrieving a Regex
A regular expression can be stored and retrieved in a Django model as follows:
```python
from django.db import models
from regex_field.fields import RegexField


class RegexModel(models.Model):
    regex = RegexField(max_length=128)


model_obj = RegexModel.objects.create(regex='a')

# Access the regex as a compiled regular expression
>>> print(model_obj.regex.match('b'))
None
```

## Using regex flags
Flags can be provided in the field definition and will be applied when the regex is compiled. If you manually
compile a regex object with other flags and set it on the model, those flags will not be preserved. Only the flags
passed to the field's constructor are used.
```python
import re
from django.db import models
from regex_field.fields import RegexField


class RegexModel(models.Model):
    regex = RegexField(max_length=128, re_flags=re.IGNORECASE)


model_obj = RegexModel.objects.create(regex='A')

# Case insensitive matching
>>> print(model_obj.regex.match('a') is not None)
True
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ambitioninc/django-regex-field",
    "name": "django-regex-field",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Django,Regex Field",
    "author": "Wes Kendall",
    "author_email": "opensource@ambition.com",
    "download_url": "https://files.pythonhosted.org/packages/ca/90/2f794e40e5a512abfa227efb7edd8ea50d780848aba98a74fc4f46998078/django-regex-field-3.1.0.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://travis-ci.org/ambitioninc/django-regex-field.png)](https://travis-ci.org/ambitioninc/django-regex-field)\n\n# django-regex-field\n\nStores regular expressions in Django models.\n\n## A Brief Overview\nThe Django regex field app provides a custom field for a Django model that\nstores a regex. This provides the ability to easily store regexs and access\nthem as compiled regular expressions from your models.\n\n\n## Storing and Retrieving a Regex\nA regular expression can be stored and retrieved in a Django model as follows:\n```python\nfrom django.db import models\nfrom regex_field.fields import RegexField\n\n\nclass RegexModel(models.Model):\n    regex = RegexField(max_length=128)\n\n\nmodel_obj = RegexModel.objects.create(regex='a')\n\n# Access the regex as a compiled regular expression\n>>> print(model_obj.regex.match('b'))\nNone\n```\n\n## Using regex flags\nFlags can be provided in the field definition and will be applied when the regex is compiled. If you manually\ncompile a regex object with other flags and set it on the model, those flags will not be preserved. Only the flags\npassed to the field's constructor are used.\n```python\nimport re\nfrom django.db import models\nfrom regex_field.fields import RegexField\n\n\nclass RegexModel(models.Model):\n    regex = RegexField(max_length=128, re_flags=re.IGNORECASE)\n\n\nmodel_obj = RegexModel.objects.create(regex='A')\n\n# Case insensitive matching\n>>> print(model_obj.regex.match('a') is not None)\nTrue\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django Regex Field",
    "version": "3.1.0",
    "project_urls": {
        "Homepage": "https://github.com/ambitioninc/django-regex-field"
    },
    "split_keywords": [
        "django",
        "regex field"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d89999aaaf79948f032883f156dfe107a877c5a48467f2cf90aea32b7aebe55c",
                "md5": "42b68f3939d1b46a3069f5c5cfb8d62d",
                "sha256": "8d4f5c8dd60f187cf45e11ea01011b86fc18bc15ff31de91a7fd438e2b1037a2"
            },
            "downloads": -1,
            "filename": "django_regex_field-3.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "42b68f3939d1b46a3069f5c5cfb8d62d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 8120,
            "upload_time": "2023-06-28T20:24:52",
            "upload_time_iso_8601": "2023-06-28T20:24:52.021416Z",
            "url": "https://files.pythonhosted.org/packages/d8/99/99aaaf79948f032883f156dfe107a877c5a48467f2cf90aea32b7aebe55c/django_regex_field-3.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca902f794e40e5a512abfa227efb7edd8ea50d780848aba98a74fc4f46998078",
                "md5": "e30a1d5799516603dec3ab5f42d34312",
                "sha256": "e17e7296e8d8c6fb68f30342eb6c88ec0336d811a22f7f180717f71e6c1e3fd6"
            },
            "downloads": -1,
            "filename": "django-regex-field-3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e30a1d5799516603dec3ab5f42d34312",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8231,
            "upload_time": "2023-06-28T20:24:53",
            "upload_time_iso_8601": "2023-06-28T20:24:53.131141Z",
            "url": "https://files.pythonhosted.org/packages/ca/90/2f794e40e5a512abfa227efb7edd8ea50d780848aba98a74fc4f46998078/django-regex-field-3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-28 20:24:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ambitioninc",
    "github_project": "django-regex-field",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "django-regex-field"
}
        
Elapsed time: 0.08795s