Django: project consumption data from the REST API, how to use external applications in this system?

I have a Django web interface that uses data from the REST API backend. Even users are created and created on the backend.

My problem:

  • How to use third-party applications on this system that are highly dependent on django / ORM models?
  • Is there something that can provide some bridge between REST API resources and ORM?

How can this problem be solved?

Update

DRY does not seem to work in this situation.

+8
python rest database django
source share
3 answers

I am not sure I fully understand your question or requirements. As I read it, you have a main server, which is basically a black box, and you want to use some third-party applications in your project that use Django ORM.

It is not clear why there is a need for two-way synchronization between two data stores. Users of your project will be returned data from your main server and from the ORM project.

Since you are worried that you are saving ORM data in your original content, you might want to consider creating Transaction middleware that will run any ORM data that can be updated, which could result in serialization of the saved structure and pass it to your REST API I believe this REST API is capable of accepting arbitrary data structures?

You will probably at least want to use some form of middleware and possibly a utility module / class to help form a β€œbridge”.

-3
source share

Everything has probably changed since this question was originally published. Now there are some interesting questions about StackOverflow on this topic.

To program a solution for yourself, as described in this answer , you can create an external service level (aka services.py ) and write the logic there to access external Resources. Your views will consume this layer and do the right thing. There are other questions that help you get information about the original request received by django-view, an external service, such as this or this.

This answer also has a django application that takes this situation into account as described. django-roa uses the Resource Oriented Architecture paradigm to resolve this.

0
source share

I ran into a similar hurdle with the new e-commerce project. The project is the interface for complete store management software (CMS + ERP + CRM). He should use a database of major products, but has his own records for product reviews, ratings, etc.

The initial thought was to make a cached copy of the main database. The website will benefit from fast loading times for cached items, but the implementation is not trivial.

After some considerations, the approach chosen updated the website database from the management program. Thus, a copy of the website will always be correct, and most of the implementation does not need to worry about REST services (it will still be used to register users, track shipment, etc.).

In your case, when you cannot remotely update your own database, you need to create a mechanism that allows you to reference REST resources, such as regular models, and cache them in the background.

Important note: research to ensure that the cache is always correct (not dirty) ...

-2
source share

All Articles