Skip to main content

Some useful database field definitions for Django.

Project description

django-useful-fields
====================

| I found myself copying a few Django database field classes from
project to project so I decided to bundle them together
| and release them as an open source package instead. Here are the
fields that are currently included:

- **TimeZoneField**

| This field stores a reference to a time zone in the database and
automatically instantiates the correct pytz time
| zone object on retrieval. Useful for recording a user’s default
time zone.

- **MarkdownCharField**

| This field is meant to be used in collaboration with a regular
CharField. The regular CharField stores the Markdown-
| formatted source text and this field will store the rendered HTML
version of that same text. Use the ``populate_from``
| argument to indicated which field on the same model contains the
source text. If the ``allow_html`` argument is
| ``False`` (the default), any HTML tags present in the source text
will be removed using the
| `bleach library <https://github.com/mozilla/bleach>`__. The
``extensions`` argument can be used to enable any desired
| `extensions <https://pythonhosted.org/Markdown/extensions/index.html>`__
for the
| `Markdown library <https://pythonhosted.org/Markdown/>`__. One
extension is enabled by default:
| `SmartyPants <https://pythonhosted.org/Markdown/extensions/smarty.html>`__.
SmartyPants is configured to use the
| correct Unicode characters (e.g. “) rather than HTML entities (e.g.
``&ldquo;``). Since CharFields don’t normally
| contain paragraphs of text, MarkdownCharField strips the
``<p></p>`` tags that Markdown always includes.

- **MarkdownTextField**

| This field is meant to be used in collaboration with a regular
TextField. The regular TextField stores the Markdown-
| formatted source text and this field will store the rendered HTML
version of that same text. Use the ``populate_from``
| argument to indicated which field on the same model contains the
source text. If the ``allow_html`` argument is
| ``False`` (the default), any HTML tags present in the source text
will be removed using the
| `bleach library <https://github.com/mozilla/bleach>`__. The
``extensions`` argument can be used to enable any desired
| `extensions <https://pythonhosted.org/Markdown/extensions/index.html>`__
for the
| `Markdown library <https://pythonhosted.org/Markdown/>`__. One
extension is enabled by default:
| `SmartyPants <https://pythonhosted.org/Markdown/extensions/smarty.html>`__.
SmartyPants is configured to use the
| correct Unicode characters (e.g. “) rather than HTML entities (e.g.
``&ldquo;``).

- **UUIDPrimaryKeyField**

| UUIDs are, in many ways, better primary keys than automatically
incrementing integer fields. Unfortunately, the
| default Django implementation—\ ``UUIDField``—requires some
boilerplate (including importing the ``uuid`` module) before
| it can be used as a primary key. UUIDPrimaryKeyField manages the
boilerplate for you. Just add

::

id = UUIDPrimaryKeyField()

to your model and everything will just work.

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

django-useful-fields-0.0.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

django_useful_fields-0.0.2-py2.py3-none-any.whl (6.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-useful-fields-0.0.2.tar.gz.

File metadata

File hashes

Hashes for django-useful-fields-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9f6628faad0cdd9db0c855344976d5350cc4cd64a1ced482e02f85542b63fa88
MD5 bf6a40a7a3f20b0f075867814b680570
BLAKE2b-256 a68cb5e410d8dc4bc41f958bad0928b7a563c10f9ebafa7ad4f0a475af893a34

See more details on using hashes here.

File details

Details for the file django_useful_fields-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_useful_fields-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2a8a0189eca367ef390c44fa397a928502f514230a7b727f1eb38b7a0817d816
MD5 412a2e26296a8f63592ec7ac58f55e9c
BLAKE2b-256 068403567235ce02ebd79cf4f119211860590f9bd5d0f2f74809341deb9b9d65

See more details on using hashes here.

Supported by

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