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 to the django app 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”), ]

Project details


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.3.9.tar.gz (73.0 kB view details)

Uploaded Source

Built Distribution

django_reactify-1.3.9-py3-none-any.whl (75.9 kB view details)

Uploaded Python 3

File details

Details for the file django-reactify-1.3.9.tar.gz.

File metadata

  • Download URL: django-reactify-1.3.9.tar.gz
  • Upload date:
  • Size: 73.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for django-reactify-1.3.9.tar.gz
Algorithm Hash digest
SHA256 bd2efd09b04dad6c6c05338237a9703d471d2761053d871bc3e820a3f215d86a
MD5 f63739609cf0b9a64d50533932f457ef
BLAKE2b-256 aa3e038cc65f7ff687b3ddb8c042fa852edcfdf6727a34657827e58e2cacf6dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_reactify-1.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ea7fbc2a9eaf3a4ac500b2f19e308858759289ccc91cbb9edf4023ca3aedd1a0
MD5 5355555dd7854e163089c37a9866ad93
BLAKE2b-256 782f83e276ee69e86b19331b575ba9b85f7ebd5c0670ad2569d4e0900d92f421

See more details on using hashes here.

Supported by

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