pixel
pixel

Reputation: 26503

Implement synchronization logic in django application?

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?

Upvotes: 0

Views: 95

Answers (1)

Maciej Gol
Maciej Gol

Reputation: 15864

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.

Upvotes: 1

Related Questions