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.dev5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 882ab9301c2388e8836a190385a43b3aea2ebb5e6dc9af634e52213abeba5351 |
|
MD5 | 2a03ebb6ac3580d82d2af66a8d116d1c |
|
BLAKE2b-256 | f33d5ff180acf41877989d172fd66b6434a807b4464f3d0262c6b1a0d6b2089b |
Close
Hashes for logicore_django_react_pages-1.0.0.dev5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03da333c8d68c225fe494a185334e6d87ffda0d5c622040a240689d47db6393e |
|
MD5 | 66d29b6bea51024765bebdbbe8237b3e |
|
BLAKE2b-256 | 3984a5cd01b1d4da0af48128695cf6ba83e25dd08114601114393552c959160a |