Registry / web-framework / django-service-objects

django-service-objects

JSON →
library0.7.1pypypi✓ verified 88d ago

A Django library that provides a service layer pattern for encapsulating business logic and operations on models. It offers Service and ModelService base classes with built-in form processing, validation, and optional Celery integration. Current version 0.7.1 supports Django 4.0 and Python 3.10; releases are infrequent.

pip install django-service-objects
INSTALL
IMPORT
SIG · DJANGO-SERVICE-OBJ
D
django-service-objects
web-frameworkpythonv0.7.1
Install
3.5s avg
Import
601ms
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.636s · 66.4MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.5s · import 0.566s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Service
✓ from service_objects.services import Service
Standard import path.
ModelService
✓ from service_objects.services import ModelService
✗ from service_objects.models import ModelService
ModelService lives in services module, not models.

Define a Service class with form fields and a process method, then call MyService.execute(dict).

from django import forms from service_objects.services import Service class MyForm(forms.Form): name = forms.CharField() class MyService(Service): name = forms.CharField() def process(self): return f"Hello {self.cleaned_data['name']}" # Usage: # result = MyService.execute({'name': 'World'}) # print(result) # 'Hello World'
Debug
Known issues
breakingService class changed from a plain class to an Abstract Base Class (ABC) in 0.5.0. If you have custom __init__ methods, they may break if they don't call super().__init__().
fix
Ensure your service subclass calls super().__init__(*args, **kwargs).
affects: >=0.5.0
deprecatedListField and DictField are deprecated in 0.7.0; the library suggests using standard Django JSONField or custom fields instead.
fix
Replace ListField/DictField with Django's JSONField or implement custom fields.
affects: >=0.7.0
gotchaThe process() method is not called inside a database transaction by default unless db_transaction=True is set on the Service Meta.
fix
Set class Meta: db_transaction = True on your service to wrap process() in a transaction.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'service_objects'
The package is not installed or virtual environment not activated.
fix
Run: pip install django-service-objects && python -c "import service_objects"
AttributeError: 'MyService' object has no attribute 'cleaned_data'
Accessing cleaned_data before the service is processed or without calling is_valid().
fix
Call MyService.execute(input_data) which automatically validates and processes, or manually call .is_valid() before .cleaned_data.
Upgrade
Version history
0.7.1latest on PyPI · released Feb 24, 2022
Audit
Dependencies
DjangorequiredCore dependency; requires Django >= 2.2 (for 0.7.x)
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
django-service-objects — pip install django-service-objects · libregistry