Git Product home page Git Product logo

fabiogibson / django-livesync Goto Github PK

View Code? Open in Web Editor NEW
27.0 2.0 11.0 81 KB

Django App which automatically reloads your browser when Django Development Server restarts or static files and templates are modified.

License: GNU General Public License v3.0

Python 79.59% JavaScript 20.06% Makefile 0.35%
python django developer-tools development-environment development-server live-reload live-sync

django-livesync's Introduction

What's this project?

It's a simple Django application which will automatically reload your browser everytime Django Development Server is restarted or any static file or template changes. Besides this, if you connect multiple browsers and devices on your development server, these will be all synchronized.

Quick start guide

Before installing, you'll need to have a copy of Django already installed. For the current release, Django 1.8 or newer is required.

For further information, consult the Django download page, which offers convenient packaged downloads and installation instructions.

Installing

Automatic installation using PyPI

type:

pip install django-livesync

Basic configuration and use

Once installed, you can add Django LiveSync to any Django-based project you're working on. The default setup will enable the following features.

  1. Every time django development server is reloaded, all connected browsers will automatically refresh.
  2. Every time a static file or template is updated, all connected browsers will automatically refresh.
  3. Your actions will be synchronized between all connected browsers and devices. Currently supports:
    • Page scroll.
    • Page reload.
    • Element click.
    • Form fields in general.

IMPORTANT: Currently, it was only tested against Google Chrome and Mozilla Firefox web browsers.

Configuration

Installing the application

Begin by adding livesync to the INSTALLED_APPS setting of your project. By default, the daemon will start watching all your installed apps template dirs. You can also specify the following additional settings:

LIVE_PORT
This is the number of the port on which live server will run.
INCLUDED_APPS
This tells django livesync to only watch for changes in apps in this set.
EXCLUDED_APPS
This tells django livesync to ignore changes on apps in this set.

Setup Middleware

Add livesync.core.middleware.DjangoLiveSyncMiddleware to the MIDDLEWARE_CLASSES setting of your project.

IMPORTANT NOTES:

  1. If you have 'django.contrib.staticfiles' application installed, you must register 'django-livesync' before it, otherwise live server will not launch.
  2. Django LiveSync will only execute if DEBUG is set to True.

Example

You might have something like the following in your Django settings file:

DEBUG = True

INSTALLED_APPS = (
    '...',
    'livesync',
    'django.contrib.staticfiles',
    '...',
)

DJANGO_LIVESYNC = {
    'PORT': 9999 # this is optional and is default set to 9001.
}

MIDDLEWARE_CLASSES = (
    'livesync.core.middleware.DjangoLiveSyncMiddleware',
)

Once you've done this, run python manage.py runserver as usual.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.