Query on building a business logic layer using django rest framework

121 views
Skip to first unread message

Deepak Kotian

unread,
Sep 1, 2021, 4:54:23 PM9/1/21
to django-res...@googlegroups.com
Hi,
I am new to django rest framework and what I see that the CRUD operation on a database tables using model is easy and quick.
Query:
If I want to build a business logic with REST api implemented in django with multiple table hits in the same rest api end point and may create/update multiple or single  table and validate inputs from users from  frontend side .
Is there any good reference example implementation in such scenarios  or any pointers would help. Please kjndly let me know.

Thank you
Deepak

Deepak Kotian

unread,
Sep 2, 2021, 11:19:23 AM9/2/21
to Django REST framework
Just to elaborate, primarily, I am keen looking at a lot of procedural kind of validation/checks like, 
if data is not found in 'x' table, 
    then insert in 'y' table from the UI form data
    else insert in 'y' table from the 'x' data
There could be more such if & else with multiple data
Could someone please suggest good way to do it.

Umair Ramzan

unread,
Sep 3, 2021, 2:25:04 AM9/3/21
to Django REST framework
You can always use the functions avaible on Django Queryset and Models. You can build your business logic by manipulating the data. a better way to do this is to separate your business logic from the view and models. you can always write a function let's say "def my_business_logic"  with all the logic that you need to implement and keep in a separate module. you can always call this from your view code or anywhere you need.

Deepak Kotian

unread,
Sep 3, 2021, 4:42:20 AM9/3/21
to django-res...@googlegroups.com
Thanks Umair for your good suggestion , will check that, would there
be any reference implementation available anywhere on github which can
be referred , please let me know
> --
> You received this message because you are subscribed to a topic in the Google Groups "Django REST framework" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework/zwJEgCzdnaY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to django-rest-fram...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/b38b7a94-0712-4c3a-99e3-6feeb1f6c3ecn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages