Skip to main content

A package to reactify Django app.

Project description

Django Reactify is an app that allows developers to add and use React components in their Django app without using the legacy create-react-app.

Quick start

  1. Install the package via the following command:

    pip install django-reactify

  2. Add “reactify” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'reactify',
    ]
  3. Run the following command:

    python manage.py reactify <app_name>

    Ensure that the templates directory exists in the specified app name.

    • Replace the app name with the existing Django app you want to reactify.

    • This command does the following:

      • Creates barbel and webpack configuration files in the app’s root directory.

      • Creates package.json file with the scripts to run React development server.

      • Creates a react folder directory with the necessary files and subdirectories where you can add your react component files and redux actions and reducers.

      • Creates a react folder directory with the necessary files and subdirectories where you can add your react component files and redux actions and reducers.

      • Installs the basic npm development packages.

      • starts the react development server that listens on the changes made to the react components and compile a minimal js file that is rendered to the view.

  4. cd into the django app (app_name) directory and run the following command:

    npm run dev

  5. Add the new view function to the views file to render the compiled version of the react app.

    def index(request):

    template_name = ‘<app_name>/index.html’

    return render(request, template_name)

  6. Add more React components to the react app’s component folder.

Managing React Routes

If you don’t configure Django urls to accept the Routes declared in the react, you will encouter 404 error.

To fix this, lets say you have react routes as follows:

<Switch>

<Route exact path=”/” component={Main} />

<Route exact path=”/login” component={LoginPage} />

<Route exact path=”/services” component={ServicesPage} />

<Route exact path=”/about” component={AboutPage} />

In the app urls file use re_path,

from django.urls import re_path

from .views import index

urlpatterns = [

re_path(r’’, index, name=”home”), ]

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_reactify-1.4.0.tar.gz (55.9 kB view details)

Uploaded Source

Built Distribution

django_reactify-1.4.0-py3-none-any.whl (57.9 kB view details)

Uploaded Python 3

File details

Details for the file django_reactify-1.4.0.tar.gz.

File metadata

  • Download URL: django_reactify-1.4.0.tar.gz
  • Upload date:
  • Size: 55.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.18

File hashes

Hashes for django_reactify-1.4.0.tar.gz
Algorithm Hash digest
SHA256 b96741a9eb5bb56a8166900e7bc59ccfac0998808fdc4853b691cd37f76547d8
MD5 dd75aa7217301deaa2920e11dc75d4fd
BLAKE2b-256 ee959384e61c382120d5846c8c1d027533da4664b626c9e3cfc1d41c31eba810

See more details on using hashes here.

File details

Details for the file django_reactify-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_reactify-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 126de5e73849292b5390236c3af075a1071024d435fa80586ee11f037ad233e6
MD5 bf10d1237ee4a6a8393e510217db16f8
BLAKE2b-256 7360092f59bacd5b2800006317066238e55da0405b17cea05f60c274afd64d6d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page