Skip to main content
==================
Django Base64Field
==================

.. image:: https://travis-ci.org/Alir3z4/django-base64field.png
:alt: travis-cli tests status for django-base64field
:target: https://travis-ci.org/Alir3z4/django-base64field

.. contents:: Table of contents

Overview
--------

- A motherfucking django model field to bring ``base64`` encoded key to models.
- It uses ``base64`` from ``django.utils.baseconv`` for encoding.
- Tested on Python2.7, Python3.3 .

How it works?
--------------

``Base64Field`` is useful where you need a base64 encoded value from
model's Primary Key a.k.a PK which is available on every django
application model by default. Sine `base64` encoder works with
`integer` value then PK should be also `integer`, Fortunately
again `PK` field is `integer` by nature.

When a model gets saved, ``post_save`` signal will be emitted,
This is where a ``base64`` encoded key will be generated/encoded
from model's ``PK``, Then model will gets **updated** not getting save again.
this operation happens just on the first time model gets saved.
In next time model gets saved or updated ``base64`` won't be generated.

You wanna know more about how ``django-base64field`` works? Then get da fuck
out of ``README.rst`` and look inside the ``django_base64field.tests.py``.

Usage
-----

Here is simple usage of ``Base64Field``
::
>>> from django.db import models
>>> from django_base64field.fields import Base64Field
>>>
>>> class MyModelianto(models.Model):
>>> ek = Base64Field()
>>>
>>> modelia = MyModelianto.objects.create(pk=314159265358979323)
>>> modelia.ek
>>> u''
>>> refreshed_modelia = MyModelianto.objects.get(pk=modelia.pk)
>>> refreshed_modelia.ek
>>> u'HS7Y_sdg3x'

As You can see ``ek`` in not available on returned instance
from ``MyModelianto.objects.create()``, It will be available after retrieving
``refreshed_modelia`` from database which is same record as ``modelia`` here.

This behavior can be easily controlled with implementing a simple helper
method on ``MyModelianto``. You can find out more about this solution on
``django_base64field.tests.py``, Which it doesn't require to retrieving
the instance from database after first creation just for getting ``ek` field.

Installation
------------
``django-base64field`` is available on pypi

http://pypi.python.org/pypi/django-base64field

So easily install it by ``pip``
::

$ pip install django-base64field

Or by ``easy_install``
::

$ easy_install django-base64field

Another way is by cloning ``django-base64field``'s
`git repo <https://github.com/Alir3z4/django-base64field>`_ ::

$ git clone git://github.com/Alir3z4/django-base64field.git

Then install it by running
::

$ python setup.py install

Or I don't know, Install it directly from git.
::

pip install git+https://github.com/Alir3z4/django-base64field.git#egg=django-base64field


Some pkgs have no installation method, This is awefuckingsome that
``django-base64field`` gives you many ways for installation.

Download files

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

Source Distribution

django-base64field-1.0.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file django-base64field-1.0.tar.gz.

File metadata

File hashes

Hashes for django-base64field-1.0.tar.gz
Algorithm Hash digest
SHA256 8fa8653ba1ce6d8fefe9a05e5687b8d4f5a8da0b4ebf9ce1fd6c4a75c3a832f4
MD5 967ded849e81ce29cf0a6d47cdfd0a30
BLAKE2b-256 b68f7adf9e66946221395609ec50ce28604277b4ac52b2298f20e823f22f1fc4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0 This release

1 file

0.9

1 file

Supported by

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