{"id":23599,"library":"django-service-objects","title":"django-service-objects","description":"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.","status":"active","version":"0.7.1","language":"python","source_language":"en","source_url":"https://github.com/mixxorz/django-service-objects","tags":["django","service-layer","business-logic","forms"],"install":[{"cmd":"pip install django-service-objects","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"Core dependency; requires Django >= 2.2 (for 0.7.x)","package":"Django","optional":false}],"imports":[{"note":"Standard import path.","wrong":"","symbol":"Service","correct":"from service_objects.services import Service"},{"note":"ModelService lives in services module, not models.","wrong":"from service_objects.models import ModelService","symbol":"ModelService","correct":"from service_objects.services import ModelService"}],"quickstart":{"code":"from django import forms\nfrom service_objects.services import Service\n\nclass MyForm(forms.Form):\n    name = forms.CharField()\n\nclass MyService(Service):\n    name = forms.CharField()\n\n    def process(self):\n        return f\"Hello {self.cleaned_data['name']}\"\n\n# Usage:\n# result = MyService.execute({'name': 'World'})\n# print(result)  # 'Hello World'","lang":"python","description":"Define a Service class with form fields and a process method, then call MyService.execute(dict)."},"warnings":[{"fix":"Ensure your service subclass calls super().__init__(*args, **kwargs).","message":"Service 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__().","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Replace ListField/DictField with Django's JSONField or implement custom fields.","message":"ListField and DictField are deprecated in 0.7.0; the library suggests using standard Django JSONField or custom fields instead.","severity":"deprecated","affected_versions":">=0.7.0"},{"fix":"Set class Meta: db_transaction = True on your service to wrap process() in a transaction.","message":"The process() method is not called inside a database transaction by default unless db_transaction=True is set on the Service Meta.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: pip install django-service-objects && python -c \"import service_objects\"","cause":"The package is not installed or virtual environment not activated.","error":"ModuleNotFoundError: No module named 'service_objects'"},{"fix":"Call MyService.execute(input_data) which automatically validates and processes, or manually call .is_valid() before .cleaned_data.","cause":"Accessing cleaned_data before the service is processed or without calling is_valid().","error":"AttributeError: 'MyService' object has no attribute 'cleaned_data'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}