A Django app which adds a ShortTextField model field, whichis like a TextField in the database but uses the TextInputrather than the Textarea widget in forms.
Project description
Short Text Field for Django
A very simple Django app that adds a ShortTextField model field class, which
is treated like a TextField in the database (i.e. the data is stored in the
database with the text rather than the varchar type, and the developer does
not need to specify a max_length), but uses the TextInput widget (a single-
line <input type="text>) by default rather than Textarea. This is ideal for
PostgreSQL, which recommends the 'text' type in a wider variety of
circumstances than other commonly-used database backends (see the
PostgreSQL docs).
Installation
This package is available from
PyPI, so you can install
it using pip like this:
pip install django-short-text-field
Usage
-
Add
'short_text_field'to yourINSTALLED_APPSsetting like this:INSTALLED_APPS = [ ... 'short_text_field', ] -
Add a
ShortTextFieldto a model like this:from short_text_field.models import ShortTextField ... class ExampleModel(models.Model): ... example_field = ShortTextField -
A model with a
ShortTextFieldshould be registered in the admin site usingshort_text_field.admin.ModelAdmin.admin.site.register(ExampleModel, short_text_field.admin.ModelAdmin)A subclass of this class will also work:
class ExampleModelAdmin(short_text_field.admin.ModelAdmin): model = ExampleModel ... admin.site.register(ExampleModel, ExampleModelAdmin)If you have a hierarchy of
ModelAdminsubclasses, you can still incorporateshort_text_field.admin.ModelAdmineasily as a mixin:class ExampleModelAdmin2(short_text_field.admin.ModelAdmin, ExampleModelAdmin1): model = ExampleModel ... admin.site.register(ExampleModel, ExampleModelAdmin)You can also use a subclass of
short_text_field.admin.AdminSitefor the site, which will makeshort_text_field.admin.ModelAdminthe defaultModelAdminsubclass to use for registering. In the simplest case, you can just set thedefault_siteattribute of theAdminConfigclass and then register all of your models in the normal way:from django.contrib.admin import apps import short_text_field.admin.AdminSite ... class ExampleAdminConfig(apps.AdminConfig): ... default_site = short_text_field.admin.AdminSite
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-short-text-field-0.3.2.tar.gz.
File metadata
- Download URL: django-short-text-field-0.3.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b49c5d0d12a205ceaf51485806ed47af94ee724f217a87f4645e1a4f8d38859f
|
|
| MD5 |
85c14f22ac7e077eef22038d3011d1ea
|
|
| BLAKE2b-256 |
52ecdcf82e80ec1d3430afc2a24125573fc3190e9b785b7d6bde606beab80f2e
|
File details
Details for the file django_short_text_field-0.3.2-py3-none-any.whl.
File metadata
- Download URL: django_short_text_field-0.3.2-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
984a86ada1a60df43534cb915d732df09f97bdacd6a981bab87a50fa25172edb
|
|
| MD5 |
1c3fe8835d0d301ba67cf8088261a074
|
|
| BLAKE2b-256 |
7987da75d7dffc37baf347e55f19151fa7f35bb4e46b6bedb415ab55a5c9ea31
|