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.dev8.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.dev8.tar.gz.

File metadata

File hashes

Hashes for logicore-django-react-pages-1.0.0.dev8.tar.gz
Algorithm Hash digest
SHA256 be80b94d2e249b9c30f1e2c930a64794a293154b235bec7af0d809554cd439b4
MD5 1b6e5868120dc9fa173c1f1ad076f48a
BLAKE2b-256 3dc11e497affbfa924a785ac145ebade6511dc13294175dac9c659c3b2304657

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for logicore_django_react_pages-1.0.0.dev8-py3-none-any.whl
Algorithm Hash digest
SHA256 33dc7f876b3a33c2842ba78b7a5d6723659dce014b76e8eca52f279b98ee79cd
MD5 8763479452aa21b32c75858f64b4e140
BLAKE2b-256 5589f511554715dcb47db34309cee2e6fcbac13837521f9f180be44e43b6b575

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