Implement synchronization logic in django application?

92 views Asked by At

In my app I need a module that will synchronize database periodically (eg. every 24h) trough xml on remote server.

What is the best option to do so - should I write separate app or create custom django command?

1

There are 1 answers

0
Maciej Gol On BEST ANSWER

You can actually do:

  • Implement a django command that would take a file-like object and load it into the database.
  • And a view that, when POSTed with appropriate file, would call the django command with InMemoryUploadedFile object.

Take note that the second part would fit in scenarios where the file's is small as the memory wouldn't be returned to OS (yet it would be free for Python to use).

Wrap those two into an app for logical separation and you are golden. If you are going just for the django command - a separate app might be too much. I'd suggest putting the command into your main app in that case.