Django live preview without reloading the page - django

I am looking for live preview solution for Django project so as soon as I do change in the css or java-script files I would see these changes without reloading the page in the browser. My page is html page but it has django tags.
I tried the following solutions:
Atom - livereload plugin.
django-livereload 1.7
grunt
and others.
the Problem with these solutions that as soon I save my page after changes it will reload the whole page to see the changes.
Is there any solution for Django would preview changes without reloading the page and just will preview the changes.
I am using django development server to run djange website.
I am not looking for inline editor. I am looking for IDE that support live preview for django without reloading the page.

Related

Django admin page layout changed with new version

I am working on an existing django project where admin console is extensively used.
With my latest run of package upgrade for my application admin page layout has changed.
Models have started appearing on all the pages, leaving a small space to display form fields.
For example this is how form page look like now:
Original Form view was occupying the whole page like this:
Any clue on what has been changed and which setting to change to get back the original view?
From the django-3.1 release notes,
The admin now has a sidebar on larger screens for easier navigation.
It is enabled by default but can be disabled by using a custom
AdminSite and setting AdminSite.enable_nav_sidebar
to False.
You can refer Customizing the AdminSite class - (django doc) to know more about customizing the AdminSite
Try this, open your browser and clear all the history then login back in again and it should work. I am sure the browser has cached an old version of Django admin.
I had the same problem when using version 3.1. I started a new demo app with version 2.2 to demonstrate something and when I got back to version 3.1 I got that issue, So what I did was just clear the browser history and everything came to its original state.

blank page or KeyError in preview Wagtail 1.10.1

I just upgraded to Wagtail 1.10.1 and the preview shows only a blank page. When I force the preview by appending preview/ to the edit URL, then I get a server error. It all works just fine on my development and staging sites, so I also need some help tracking down where the error might be.
Internal Server Error: /admin/pages/81/edit/preview/
KeyError at /admin/pages/81/edit/preview/
'wagtail-preview-81'
Django Version: 1.11.1
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.5.2
I've been doing only minimal upgrades for a few months, so it's possible I missed something in a previous upgrade that used to work but that now I need to fix (although why it would work in the dev and staging sites but not the real one puzzles me); any suggestions would be welcome.
Please refresh your browser cache in the edit page (Ctrl + F5) then click again on preview.
The issue is that the admin Javascript changed, but Wagtail no longer compresses its assets, so your browser cached the previous version of the Javascript file. So preview data is not correctly sent to the server, and it’s therefore unable to retrieve it when displaying the preview.
You can avoid such issues in the future by compressing admin assets.

Django HTSQL Web Interface for writing queries is not responding

I am trying to use HTSQL for one of my Django projects. For that I followed the procedure given HERE for furnishing HTSQL/Django requirements. Then I cloned the HTSQL repository for trying the example/demo in it from HERE. I am testing this on Django v1.4. The default db used in the demo example is sqlite3. In Django python shell, the queries are working fine now as per THIS question. But as demonstrated on HTSQL Website, it has a very powerful frontend to communicate with the database and also generates efficient queries (reference). I am trying to use this particular feature for my Django application which is also demonstrated in the demo/example django app from HTSQL. In the demo app, when I started my local django server and tried to access the following url:
localhost:8000/htsql/
The page loads and when I write the following lines:
/polls_poll
to see the data from the polls_poll table, the RUN button does nothing and so does the more drop down menu. No error, no response, no data fetched from the polls_poll table. Then I noticed that the page wasn't loading properly i.e this trace was generated on the Django server terminal. So basically,
codemirror .js and .css files were throwing HTTP 500 error. For that I searched for the links of the codemirror .css and .js files and provided those links in the index.html of the HTSQL resided in the static folder. Following is its path:
>>> /usr/local/lib/python2.7/dist-packages/htsql/tweak/shell/static
Now the terminal trace has changed to THIS
But still the RUN button does nothing and no data is fetched from the table polls_poll
Am I doing something wrong or missing something??
CodeMirror just changed the download URL for their packages, which broke HTSQL shell. You either need to apply the following patch manually:
https://bitbucket.org/prometheus/htsql/changeset/f551f8996610bb68f2f8530fc6c0dbf6b5c34d90
or you can wait for the next bugfix release of HTSQL, which will be out in a day or two.

image upload plugin to work with django admin and tiny MCE

I'm looking for a way to upload images to a django filefield through a tiny mce plugin.
I've tried using IBrowser using these instructions and figured I could then just write a python script in place of the php script that comes with the plugin. But I can't even get the button to display with those instructions, let alone rewrite it so that it works with django.
So I'm wondering if there is a well know way to create an upload image button that works with django and will upload to your server or if I can get ibrowser to work in this way.
Currently, tinymce is served to my django admin following the django wikis suggestions. I've tried adding ibrowser with the following file structure:
-tinymce
-plugins
-ibrowser
-editor_plugin.js
-editor_plugin_src.js
-...
but the button doesn't appear.
Again I'm all ears on how to get this to work with the ibrowser plugin or with a better solution.
django-filebrowser is an app that has tinymce support. You will also need to install django-grappelli as a requirement though which will significantly change the appearance of your admin

Admin media disappear while running django trunk in development mode

I got into django recently and start playing around with the tutorials & documentation (with the development version). Everything has been fine till I decide to update again to the latest django trunk and well my admin media are not showing up at all!
After some troubles, I managed to get admin media showing by commenting out django.contrib.staticfiles. However as I do use the staticfiles app to manage my site static files, I need it to be enabled. After some troubles, I manage to get both admin media and staticfiles showing by using manage.py collectstatic to collect the admin media files to my static folder.
However is there a way for me to serve admin media in DEBUG mode easily like last time without using collect static command? as I don't want to call the collectstatic every time when django admin media files got changed in trunk? (though I don't know how often/rare that is)
Django trunk is changing how static files are served, and in fact new changes landed this morning.
You'll want to get latest again, and then start here: http://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/