Live Editing in Django

Imagine you have an address book. Usually the fields are displayed as static text in a specific layout (imagine that you have several phone numbers, emails, etc.). When editing it, you want to use the same layout, but with form fields instead of static text. It seems that the usual way to do this in Django is to use separate views and templates, which forces you to duplicate all layout markup (i.e. Not DRY) and change pages to switch between view and edit modes.

It would be better if you could switch and exit edit mode on the fly using JavaScript to replace static text with form fields and vice versa and Ajax to send changes to the server. I call it “live editing,” but there may be a better term. Anyway, is there a recommended way to do this in Django?

I was thinking of rendering for each field, both a static and an editable version, as well as using JavaScript to hide and show them as needed. But I also need to update the static fields with new data from the server, and I need to consider embedded forms and complex fields such as images (where the static display is the <img> , and you need to update src after loading). And I may also need to dynamically add and remove fields or fields (again, consider inline forms).

All in all, this will take a lot of code. Is there an existing solution for Django or a recommended approach? Otherwise, which JavaScript framework might be most useful for this?

+4
source share
3 answers
+4
source

I did not use it myself, but I heard that django-inline is for this.

+2
source

You can also see the javascript jQuery library and its built-in editing capabilities .

+2
source

All Articles