Skip to main content

A Django app which adds a ShortTextField model field, whichis like a TextField in the database and like a CharField informs.

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 like a CharField in forms (i.e. it uses a single-line input). 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] (https://www.postgresql.org/docs/9.1/static/datatype-character.html)).

Usage

  1. Add 'short_text_field' to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
          'short_text_field',
    ]
    
  2. Add a ShortTextField to a model like this:

    from short_text_field.models import ShortTextField
    
    ...
    
      class ExampleModel(models.Model):
            ...
            example_field = ShortTextField
    
  3. A model with a ShortTextField should be registered in the admin site using short_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 ModelAdmin subclasses, you can still incorporate short_text_field.admin.ModelAdmin easily 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.AdminSite for the site, which will make short_text_field.admin.ModelAdmin the default ModelAdmin subclass to use for registering. In the simplest case, you can just set the default_site attribute of the AdminConfig class 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


Release history Release notifications | RSS feed

This version

0.2

Download files

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

Source Distribution

django-short-text-field-0.2-0.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_short_text_field_0.2-0.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file django-short-text-field-0.2-0.2.tar.gz.

File metadata

  • Download URL: django-short-text-field-0.2-0.2.tar.gz
  • Upload date:
  • Size: 3.7 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

Hashes for django-short-text-field-0.2-0.2.tar.gz
Algorithm Hash digest
SHA256 46a98bdb5a94b15d35c820bef92791ab43ea0233248bdfc6c3bd5341c123dd9a
MD5 130ccb9a1f25c3ea5d9ddc4b6a62e4b0
BLAKE2b-256 499033efdebd6dcdb907ce40e42ae009001bf818078e4f4446e65dc3607a28f4

See more details on using hashes here.

File details

Details for the file django_short_text_field_0.2-0.2-py3-none-any.whl.

File metadata

  • Download URL: django_short_text_field_0.2-0.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

Hashes for django_short_text_field_0.2-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2252dfdbfd9a3b9b5f49eb1c8efb896e1235ec423987ef292e0b192e0668a63e
MD5 b92539d99ff0bd9edac54b154062e24b
BLAKE2b-256 a706f09d2dd339e09b8c910c12011732cfcec10af8435baadbe0604959e94611

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page