Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A motherfucking django model field to bring base64 encoded key to models.
Latest commit 9b4e3be @Alir3z4 Merge pull request #13 from Alir3z4/feature-#10-custom-receiver
Bump version and update


Django Base64Field

travis-cli tests status for django-base64field


  • 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


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(
>>> 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, Which it doesn't require to retrieving the instance from database after first creation just for getting ``ek` field.


django-base64field is available on pypi

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

$ git clone git://

Then install it by running

$ python install

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

pip install git+

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

Something went wrong with that request. Please try again.