Metadata-Version: 2.0
Name: django-readonly-field
Version: 0.2.0
Summary: Make Django model fields readonly
Home-page: https://github.com/novafloss/django-readonly-field
Author: Joachim Jablon
Author-email: joachim.jablon@people-doc.com
License: MIT
Keywords: django-readonly-field
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Framework :: Django :: 1.8
Classifier: Framework :: Django :: 1.9
Classifier: Framework :: Django :: 1.10
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Requires-Dist: Django (>=1.8,<1.11)

=============================
Django Readonly Field
=============================

.. image:: https://badge.fury.io/py/django-readonly-field.png
    :target: https://badge.fury.io/py/django-readonly-field

.. image:: https://travis-ci.org/novafloss/django-readonly-field.png?branch=master
    :target: https://travis-ci.org/novafloss/django-readonly-field

.. image:: https://img.shields.io/codecov/c/github/novafloss/django-readonly-field/master.svg
    :target: https://codecov.io/github/novafloss/django-readonly-field?branch=master

Make Django model fields readonly. In other words, make it so that Django will
read from your field in your Database, but never try to write it. It can be
useful if your field is populated by a trigger or something.

Requirements
------------

+ **Postgresql only**
+ Django, obviously

Documentation
-------------

The full documentation is at https://django-readonly-field.readthedocs.org.

Quickstart
----------

Install Django Readonly Field::

    pip install django-readonly-field

In your ``settings.py`` :

.. code-block:: python

    INSTALLED_APPS = [
        # ...
        "django_readonly_field",
    ]

In the model where you want some fields to be read-only:

.. code-block:: python

    class Spaceship(models.Model):
        name = models.CharField(max_length=100)
        color = models.CharField(max_length=16)

        class ReadonlyMeta:
            readonly = ["color"]

That's it. Now, Django won't try to write the ``color`` field on the database.


Warning
-------

Django won't try to write those fields. Consequence is that your Database
**must** be ok with Django not writing those fields. They should either
be nullable or have a database default or be filled by a trigger, otherwise
you will get in ``IntegrityError``.

Don't forget that Django model field defaults don't become Database default.
You might have to write an SQL migration for this.


Running Tests
--------------

You will need an usable Postgresql database in ordre to test the project.

::

    source <YOURVIRTUALENV>/bin/activate
    export DATABASE_URL=postgres://USER:PASSWORD@HOST:PORT/NAME
    (myenv) $ pip install -r requirements_test.txt

Run tests for a specific version

::

    (myenv) $ python runtests.py


Run tests for all versions (if tox is installed globally, you don't need a
virtual environment)

::

    $ tox

Using the project
-----------------

Many operations are documented in the Makefile. For more information, use:

::

    $ make help


Credits
---------

Tools used in rendering this package:

*  Cookiecutter_
*  `cookiecutter-djangopackage`_

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage




History
-------

0.2.0 (2016-09-14)
++++++++++++++++++

* Rationalized the writing of readonly (vs read-only)
* Defined default app config

0.1.1 (2016-09-13)
++++++++++++++++++

* CI improvements
* Code linting


0.1.0 (2016-09-02)
++++++++++++++++++

* First release on PyPI.


