Skip to content

Repository files navigation

django trim logo

Django Trim

Effortlessly trim the boilerplate in your Django projects.

Upload Python Package PyPI PyPI - Downloads PyPI - Python Version License: MIT


Trim the boilerplate from your Django projects with shortcuts for models, views, forms, URLs, template tags, and more.

Docs Quick Links

Install & Setup

Install from PyPI and install it to your Django project:

pip install django-trim

In your settings.py, include trim in INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    'trim',
    # ...
]

Popular Bits

Django trim is a facade to the common features of Django, providing a layer of sugar for all those daily tasks.

Some of our favourite components to quickly trim your code:

Thing Bits
Models Auto Model Mixin | Fields | Live String
Views Authed Views | List View | JSON Views
Forms quickforms | {% quickform %} tag
URLs Functions | Overview
Admin register_models
Templates {% link %} tag | {% wrap %} tag | {% slot %} Tag | {% updated_params %} tag | {% functional %} tag | {% timedelta %} tag
Execute read_one

Guides

New to Django or django-trim? Start with Building a Contact Form - a complete beginner-friendly guide.

Setup

Install Django Trim from PyPI and add it to your Django project:

pip install django-trim

Install

In your settings.py, include trim in INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    'trim',
    # ...
]

That’s it!

Minimal Example:

Django trim covers all the chunky parts, allowing you to rapidly run with your ideas without magic or sacrificing clarity.

Here's a fast example for a hen basket model:

# models.py
from django.db import models
from trim.models import fields

class HenBasket(models.Model):
    chicken = fields.fk('Chicken')
    owner = fields.user_fk()
    full = fields.bool_false()
    eggs = fields.int(6) # args default.
    created, updated = fields.dt_cu_pair()
# views.py
from trim import views
from .models import Product

class HenBasketListView(views.ListView):
    model = HenBasket


class HenBasketDetailView(views.DetailView):
    model = HenBasket
# urls.py
from trim import urls
from . import views

app_name = 'baskets'

urlpatterns = urls.paths_named(views,
    list=('HenBasketListView', ('', 'baskets/'),),
    detail=('HenBasketDetailView', 'baskets/<str:pk>/',),
)

Highlights and Features

django-trim respects Django's core principles, adding a layer of convenience for developers who love Django's power but want to type lss wrds.

  • Less typed text, same functionality
  • clear, predicable functional naming
  • Leverage conventions for faster prototyping
  • 100% compatible with existing Django components.

Head to the docs/ for a list of components, Some of our favourite features:

Contents

Models | Views | Forms | URLs | Admin | Template Tags | Other Features

Highlights and Features

django-trim respects Django's core principles, adding a layer of convenience for developers who love Django's power but want to type lss wrds.

  • Less typed text, same functionality
  • Zero lock‑in. Swap any helper for the Django builtin at any time.
  • 100% compatible with Django components.

Head to the docs/ for a list of components

Models

Models | Auto Model Mixin | Functional Fields | Live String

Key Features

trim.models gives you concise, functional shortcuts for defining Django models.

  • Skip repetitive field declarations and use helpers like fields.fk('ModelName'), fields.bool_false(), and fields.int(6) for clarity and speed.
  • Auto-mixins let you add behaviors without touching your original model code.
  • Instantly access any installed model via trim.live.app.ModelName—no imports needed.

Whether you want rapid prototyping or maintainable code, trim.models keeps your models clean, explicit, and fully compatible with Django’s built-ins.

Views

Views | Authed Views | List View | JSON Views

Key Features

trim.views provides a set of functional views and decorators to simplify your view logic.

  • Simplified view creation with views.get, views.post, and more.
  • Built-in support for authentication and permissions.
  • Easy JSON serialization with views.serialized.
  • Decorators for common tasks like @views.auth_required and @views.permission_required.

Forms

Forms | quickforms | {% quickform %} tag

Key Features

trim.forms provides a set of functional forms and form fields to streamline form handling.

  • Functional form fields like forms.chars(), forms.email(), and more.
  • Use the {% quickform %} template tag for quick form rendering in templates.

URLs

URLs | named urls

Admin

register_models | register

Templates

Templates

TemplateTags

{% quickform %} tag | {% link %} tag | {% wrap %} tag and {% slot %} Tag

Key Features

trim.templates provides a set of template tags to enhance your Django templates.

Other Features

Execute | read_one


Philosophy

I aim for the Trim philosophy "convenient and thoughtless" - where a function or method should be quick to type, until I'm ready to replace them with the django builtins.

License

This project is licensed under the terms of the MIT License.

The MIT License offers you the freedom to use, modify, and distribute this code. While it’s not a formal requirement, taking a moment to acknowledge the original contributors reflects a deep-seated respect that is fundamental to the open-source community.

Contributing

We sincerely welcome contributions! There is no barrier for entry and all input is valid input. If you find a bug or have a feature request, please open an issue. If you'd like to contribute code, please fork the repository and submit a pull request.


Open-source is as much about collaboration and mutual respect as it is about code. As a project committed to this ethos, we promise to always recognize and credit contributions with gratitude and respect.

We value the thoughtfulness and care put into each contribution, not to reduce them to mere numbers or to brush them off with a cavalier "...that’s what open source is...". A project thrives on its community’s spirit and collective efforts.

About

django-trim for easier integration of django components.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages