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.dev6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9d861defb3a55599a122dee0d999a045a1eab9ac06660953088b6ea17ce7b62 |
|
MD5 | 83db6ee3dd46149175f7ca7e52d48de1 |
|
BLAKE2b-256 | fe09b8e71147014497d29e7d0ae1e77a50356e710ab41966e0a017767ecf54f8 |
Close
Hashes for logicore_django_react_pages-1.0.0.dev6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5b1ed42d6437a75032b318a08eb0106119cd85c55e7f4cd2fbe254e48ebfba5 |
|
MD5 | 5b400d1c1d6a65959cc8bd9834790fd1 |
|
BLAKE2b-256 | e697d08fce74b68c00c20d45b13daed90631aac0c187ea0a7adb076258a8dbb9 |