Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

It's React, but in Python. Now with Django integration.

License

NotificationsYou must be signed in to change notification settings

reactive-python/reactpy-django

 
 

Repository files navigation

Django-IDOM connects your Python project to a ReactJS front-end, allowing you to createinteractive websites without needing JavaScript!

Following ReactJS styling, web elements are combined intoreusable "components". These components can utilizehooks andevents to create infinitely complex web pages.

When needed, IDOM canuse components directly from NPM. For additional flexibility, components can also befully developed in JavaScript.

Any Python web framework with Websockets can support IDOM. See below for what frameworks are supported out of the box.

Supported FrameworksSupported Frameworks (External)
Flask,FastAPI,Sanic,TornadoDjango,Plotly-Dash,Jupyter

At a Glance

my_app/components.py

You will need a file to define yourIDOM components. We recommend creating acomponents.py file within your chosenDjango app to start out. Within this file, we will create a simplehello_world component.

fromidomimportcomponent,html@componentdefhello_world(recipient:str):returnhtml.h1(f"Hello{recipient}!")

In yourDjango app's HTML template, you can now embed your IDOM component using thecomponent template tag. Within this tag, you will need to type in your dotted path to the component function as the first argument.

Additionally, you can pass inargs andkwargs into your component function. For example, after reading the code below, pay attention to how the function definition forhello_world (in the previous example) accepts arecipient argument.

{%loadidom%}<!DOCTYPE html><html>  <body>{%component"example_project.my_app.components.hello_world"recipient="World"%}  </body></html>

Resources

Follow the links below to find out more about this project.

About

It's React, but in Python. Now with Django integration.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp