Friends link: 200-120 100-101 352-001 70-410 200-125 070-411 200-101 400-101 C2020-703 70-412 642-747 70-417 200-120 70-487 350-018 352-001 300-207 117-201 210-260 SY0-401 200-125 300-320 200-310 300-075 70-534

Offlining a Django Website

March 7th, 2015
Posted by
Categories: Technology

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.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Comments RSS