Post/Redirect/Get-like approach for React + Django AJAX apps
Project description
logicore-django-react-pages
PRG-like approach for React + Django AJAX apps
Use together with: React counterpart
and on top of: Running React and Django on a single port
Usage
-
Assuming your main apps' name is
main
-
Add to
views.py
(as an example):
from logicore_django_react_pages.views import ApiView
class HomeView(ApiView):
url_name = "home"
url_path = "/"
WRAPPER = "MainWrapper"
TEMPLATE = "HomeView"
title = "Home"
def get_data(self, request, *args, **kwargs):
return {"name": "World"}
- Add to
urls.py
from logicore_django_react.urls import react_reload_and_static_urls, react_html_template_urls
from main import views # required to register subclasses for ApiView
from logicore_django_react_pages.views import all_api_urls
urlpatterns = [
# ...
*all_api_urls(), # in any position
# ...
]
# add static/media endpoints here if needed
# urlpatterns += static(...)
# lastly, combine with logicore_django_react urls
urlpatterns = react_reload_and_static_urls + urlpatterns + react_html_template_urls
- Install & configure ReactJS counterpart: https://github.com/Logicore-project/logicore-react-pages#installation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for logicore-django-react-pages-1.0.0.dev8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | be80b94d2e249b9c30f1e2c930a64794a293154b235bec7af0d809554cd439b4 |
|
MD5 | 1b6e5868120dc9fa173c1f1ad076f48a |
|
BLAKE2b-256 | 3dc11e497affbfa924a785ac145ebade6511dc13294175dac9c659c3b2304657 |
Close
Hashes for logicore_django_react_pages-1.0.0.dev8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33dc7f876b3a33c2842ba78b7a5d6723659dce014b76e8eca52f279b98ee79cd |
|
MD5 | 8763479452aa21b32c75858f64b4e140 |
|
BLAKE2b-256 | 5589f511554715dcb47db34309cee2e6fcbac13837521f9f180be44e43b6b575 |