Git Product home page Git Product logo

djangocrud's Introduction

djangoCRUD

Build Status Coverage Status Code Health Codacy Badge Code Issues

About

The intention was to develop a generic framework for rapid development of CRUD based web applications. The framework simplifies the development process by relying only on Model creation. The generic framework takes care of providing the necessary Views, Templates, Forms and URLs.

Additionally, a simple configuration allows the developer to specify what fields to display in Create, Update, Display and Preview operations.

Technology Stack

  • Python 2.7x, 3.4x, 3.5x
  • Django 1.9x
  • Bootstrap 3.x

Usage & Configuration

Step 1: App Registration for CRUD Operations

  • Add your app to CRUD_APPS under core/constants
  • Comment out the tests app (for demo purpose only)
CRUD_APPS = [
    'tests',
    'procurement_logistics'
]

Step 2: Model Configuration

  • All models must inherit from AbstractEntity and use the BaseEntityMixin
from djangocrud.core.mixins import BaseEntityMixin
from djangocrud.core.models import AbstractEntity

class Supplier(AbstractEntity, BaseEntityMixin):
    """Sample representation of Supplier"""
    name = CharField("Name", max_length=200, validators=[validate_name])
    category = CharField(verbose_name="Category/Type", max_length=10, choices=(
        ('PB', 'Public'), ('PR', 'Private')))
    remarks = TextField("Remarks", blank=True)

    def clean(self):
        """Custom validation logic should go here"""
        pass

Step 3: Define Validation Logic (Optional)

  • Custom validation logic should go under clean() on the model itself
  • Custom field specific validation should be defined and applied to the field as validators attribute

Step 4: Configure Field Visibility

  • Add crud.py under your app and define FIELD_CONFIG as Nested Ordered Dictionary
  • Include the models which you want to be exposed for CRUD operations
  • Define for each model the visbility of fields for display on the templates and forms
    • create: available on create form
    • update: available on update form
    • display: available for display in detail view
    • preview: available for display in list view
FIELD_CONFIG = odict([
    ('Supplier', odict([
        ('name', ['create', 'update', 'display', 'preview']),
        ('category', ['create', 'update', 'display']),
        ('remarks', ['create', 'update', 'display', 'preview']),
        ('creation_date', ['display']),
        ('last_updated', ['display'])
    ])),
])

Step 5: Configure Permissions

Execute the following management command to configure the permissions

  • ./manage.py configauth

djangocrud's People

Contributors

faxad avatar

Watchers

James Cloos avatar Nyimbi Odero avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.