Skip to main content

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

  1. Perform: https://github.com/Logicore-project/logicore-django-react#usage-from-scratch-starting-a-django--react-project-for-development

  2. Assuming your main apps' name is main

  3. 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"} 
  1. 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
  1. Install & configure ReactJS counterpart: https://github.com/Logicore-project/logicore-react-pages#installation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logicore-django-react-pages-1.0.0.dev7.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file logicore-django-react-pages-1.0.0.dev7.tar.gz.

File metadata

File hashes

Hashes for logicore-django-react-pages-1.0.0.dev7.tar.gz
Algorithm Hash digest
SHA256 617ed7f3c5bf3f54681ed2440b3949bdd2ca87dd9928d2ec7ee9ffe20ffe6c01
MD5 4eb812e69b1170de82fdc43e05836da0
BLAKE2b-256 b88f3f20b521b09b0abaa559d7096eeacb74978b8e561769fbd8d1304ef694cd

See more details on using hashes here.

File details

Details for the file logicore_django_react_pages-1.0.0.dev7-py3-none-any.whl.

File metadata

File hashes

Hashes for logicore_django_react_pages-1.0.0.dev7-py3-none-any.whl
Algorithm Hash digest
SHA256 1c9938e64e49db88240101b516fbc3eba74181e0727860ac0854eaa237ff2e3e
MD5 6dd5578f016776b3ba0dc8e173fa7d61
BLAKE2b-256 ab4eec0fd915ef907c61874fa545e104a859b0677724c2a448f140a26760e59d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page