Django: Chicken or Egg Question

I am creating an application that will send an API call and store the received information after processing the information in the class APIRecord(models.Model).

1) . Should I create a separate class so that the class calls the API, processes the information (including validation against business rules), and then instantiates my APIRecord()class?

or

2) . Should I create a separate class with the appropriate processing methods and call the API, and then in my model redefine the method APIRecord.save()to call the individual methods of the class API and then save the results?

or

3) Should I create a model class with the appropriate methods for calling the API and processing the response (including checking certain values ​​and other business rules)?

I tried # 2 and ran into problems with flexibility (but I'm still open to suggestion). I lean toward # 1, but am still not sure about all the negatives?

+3
source share
1 answer

. . , . , , . , - , . , .

+1

Source: https://habr.com/ru/post/1728721/


All Articles