Skip to main content

Django model and form fields that performs URL normalization. For example it adds 'http://' prefix and forces punicode encoding.

Project description

Django model and form fields that performs URL normalization. For example it adds ‘http://’ prefix and forces punicode encoding. There are also fields that stores a list of URLs.

Tested with Django 3.0.x (should also work for 2.x)

Travis-CI build status

Installing

$ pip install django-smarturlfield

Fields

SmartURLFormField renders as <input> and can handle values like this:

  • http://example.com
  • example.com (normalized to http://example.com)
  • земфира.рф (normalized to http://xn--80ajfftz0a.xn--p1ai)

MultipleSmartURLFormField renders as <textarea> and can store multiple URLs separated by newline.

Usage

In forms:

from smarturlfield import SmartURLFormField, MultipleSmartURLFormField

class MyForm(forms.Form):
  url = SmartURLFormField()
  url_list = MultipleSmartURLFormField()  # textarea
  # ...

In models:

from smarturlfield import SmartURLDbField, MultipleSmartURLDbField

class MyModel(models.Model):
    url = SmartURLDbField()
    url_list = MultipleSmartURLDbField()  # textarea
    # ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-smarturlfield, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django-smarturlfield-1.1.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page