Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.
/ djangocrud Public archive

Framework for rapid building CRUD based applications | Django, Python

License

Notifications You must be signed in to change notification settings

faxad/djangocrud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

djangoCRUD

Build Status Coverage Status Codacy Badge

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