I have been reading recently about Domain Driven Design (DDD), I like the concept and especially the idea of Onion architecture goes with it (https://www.youtube.com/watch?v=pL9XeNjy_z4).
I am quite curious to understand how such an architecture we can implement with Django Rest Framework or in other words can we do DDD with Django rest framework in Onion arch style?
- Is it possible to map the concepts in Onion architecture to DRF?
- As frameworks like Apache isis (https://isis.apache.org/) do DDD by building Object Oriented UIs where users can directly interact with domain entities, how DRF can possibly do such things?
As an example I have writing DRF Code in following fashion:
In models.py I would have my models defined:
class Library(models.Model):
library_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=30)
...
#This helps to print in admin interface
def __str__(self):
return u"%s" % (self.name)
In serializers.py I would have my model serializers:
class LibrarySerializer(serializers.ModelSerializer):
class Meta:
model = Library
fields = '__all__'
I will have corresponding url in urls.py:
router.register(r'libraries', LibraryViewSet)
and in views.py performing CRUD operations:
class LibraryViewSet(viewsets.ModelViewSet):
queryset = Library.objects.all()
serializer_class = LibrarySerializer
How would that relate to (perhaps with appropriate modifications) to DDD/Onion architecture?