For a beginning developer it can be intimidating to be tasked with offlining a Django website.  To ease your worry I will detail a design idea that you should understand to make your journey less painful.

A good question to ask yourself is what will I be losing when there is no connection to my Django back-end?

The biggest thing to worry about, in my mind, is that you’ll be losing persistence. So what should you do? How can a person create data on my database when they’re not connected? The short answer is that they can’t, because Django uses an architecture with a hard dependency on its models you’ll need to find a way to make persisting to your DB a soft dependency. In order to mitigate this problem you’ll have to persist locally in JavaScript and sync your data to your database once they regain a connection.

Suggestions to do this:

  • Django-REST-Framework.
    • They have done a great job matching common Django coding conventions that make it easy and fast to implement alongside existing Django models.
    • This Django app will allow you to easily create a very powerful REST API over which you can create entries in your existing Django database.
  • JavaScript Front-end Framework
    • there is a long list of these, find one that looks promising for your use case and have fun. Obviously you’ll want one that you can use to easily represent your Django models and that can easily speak REST to save it’s models.
    • leveraging a JavaScript front-end framework will save you much time and headache.

This is a good start for creating an offline version of a Django website, There is a lot more you’ll learn if you take on this task but this should get you going.

Quick note about persisting over REST: you’ll save your self a lot of headache if you can remove any hard relationship dependencies in pertinent models.

Happy coding.