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
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.dev4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72e0f47bc87532898be778faa7867bd9a400b53d78d19799aa297a946cd353b7 |
|
MD5 | c4439614d338207f48c6663c4a7906ab |
|
BLAKE2b-256 | 9314a4f2dd62f7f255bca177dbd816042da5d451293bc8e5c73bc5335111d7e2 |
Close
Hashes for logicore_django_react_pages-1.0.0.dev4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31776c62229037ae11815a1ada928c4e61c9c631227fc3f94782b22f97e3245d |
|
MD5 | d95e5a38f5363570716cd5a211c8499e |
|
BLAKE2b-256 | c0b5f750fa5380b50835b94dd3e49b842008e00eb99fff19c3e07cdcbd3a26a2 |