django-any-urlfield 2.1.1

An improved URL selector to choose between internal models and external URLs

django-any-urlfield

The any_urlfield module provides an improved URL selector that supports both URLs to internal models and external URLs.

This addresses is a common challenge in CMS interfaces; where providing a URLField makes it hard to enter internal URLs, while providing a ModelChoiceField makes it too inflexible. This package provides the both of both worlds.

For more details, see the documentation at Read The Docs.

Screenshot

Installation

First install the module, preferably in a virtual environment. It can be installed from PyPI:

pip install django-any-urlfield

Or the current folder can be installed:

pip install .

Configuration

Add the module to the installed apps:

INSTALLED_APPS += (
    'any_urlfield',
)

Usage

In a Django model, the field can be included:

from django.db import models
from any_urlfield.models import AnyUrlField

class MyModel(models.Model):
    title = models.CharField("Title", max_length=200)
    url = AnyUrlField("URL")

By default, the AnyUrlField only supports linking to external pages. To add support for your own models (e.g. an Article model), include the following code in models.py:

from any_urlfield.models import AnyUrlField
AnyUrlField.register_model(Article)

Now, the AnyUrlField offers users a dropdown field to directly select an article. By default, it uses a django.forms.models.ModelChoiceField field with a django.forms.widgets.Select widget to render the field. This can be customized using the form_field and widget parameters:

from any_urlfield.models import AnyUrlField
from any_urlfield.forms import SimpleRawIdWidget

AnyUrlField.register_model(Article, widget=SimpleRawIdWidget(Article))

Now, the Article model will be displayed as raw input field with a browse button.

Contributing

This module is designed to be generic. In case there is anything you didn't like about it, or think it's not flexible enough, please let us know. We'd love to improve it!

If you have any other valuable contribution, suggestion or idea, please let us know as well because we will look into it. Pull requests are welcome too. :-)

Apache 2.0

Author

Diederik van der Boor

Pip

django-any-urlfield==2.1.1

Classifiers

  • Development Status :: 5 - Production/Stable
  • Environment :: Web Environment
  • Framework :: Django
  • Intended Audience :: Developers
  • Operating System :: OS Independent
  • Programming Language :: Python
  • Programming Language :: Python :: 2.6
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python :: 3.2
  • Programming Language :: Python :: 3.3
  • License :: OSI Approved :: Apache Software License
  • Topic :: Software Development :: Libraries :: Python Modules
  • Topic :: Software Development :: Libraries :: Application Frameworks
  • Topic :: Internet :: WWW/HTTP
  • Framework :: Django :: 1.6
  • Framework :: Django :: 1.7
  • Framework :: Django :: 1.8
  • Framework :: Django :: 1.4
  • Framework :: Django :: 1.5

Requirements

File Type Python Version Uploaded On Downloads
django_any_urlfield-2.1.1-py2.py3-none-any.whl Wheel 2.7 April 15, 2015 1,723
django-any-urlfield-2.1.1.tar.gz Source April 15, 2015 1,174
Version Release Date
2.1.1 April 15, 2015
2.1 April 13, 2015
2.0.4 Dec. 30, 2014
2.0.3 Oct. 30, 2014
2.0.2 Oct. 30, 2014
2.0.1 Sept. 15, 2014
2.0 Aug. 15, 2014
2.0b1 June 5, 2014
2.0a1 April 11, 2014
1.0.12 Feb. 24, 2014
1.0.11 Feb. 20, 2014
1.0.10 Dec. 12, 2013
1.0.8 Sept. 20, 2013
1.0.7 May 28, 2013
1.0.6 Aug. 24, 2015
1.0.5 May 7, 2013
1.0.4 May 2, 2013
1.0.3 April 25, 2013
1.0.2 Jan. 24, 2013
1.0.1 Dec. 27, 2012
1.0.0 Dec. 27, 2012
Date Package Version Action
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.1 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.0 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.1.1 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.1 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.12 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.11 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.10 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.0 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.7 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.2 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.0a1 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.8 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.0b1 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.3 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.0.1 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.0.2 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.0.3 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 2.0.4 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.6 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.5 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield 1.0.4 Release Created
Aug. 24, 2015, 10:58 p.m. django-any-urlfield Package Created