Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research passing data between Django and React #379

Open
antidipyramid opened this issue Sep 19, 2024 · 2 comments
Open

Research passing data between Django and React #379

antidipyramid opened this issue Sep 19, 2024 · 2 comments
Assignees
Labels

Comments

@antidipyramid
Copy link
Contributor

Background

From Sam's team survey.

What will be the focus of your R&D? Why do you think it's important? Leave background here.

Proposal

What shape do you want your R&D to take? Focus on the big picture: What tasks you want to accomplish, what questions you want to answer.

Deliverables

What artifacts will you produce from your R&D? How will we know when you're done?

Timeline

How long do you expect this R&D to take? What could cause you to need more or less time?

@hancush
Copy link
Member

hancush commented Jan 9, 2025

Re-reading Sam's memo, the main frustration seems to be that responsibility for certain tasks, like building forms, is spread across the stack. For that reason, I propose a clear and clean separation where React's only role is rendering interactive components – maps, charts, forms, etc. – while Django retains responsibility for everything else.

More explicitly, Django is responsible for...

  • Database
  • Models
  • Routing
  • Views / templates
    • Back end form processing through Django's forms module
  • Data API (Django REST), if needed
  • CMS

React is limited to...

  • Interactive components
    • Interact with API and/or static data files baked out in ETL process
    • Front end form display and user interaction

An interesting question: Why keep routing in Django?

In the short term, the answer is because our CMS of choice, Wagtail, uses Django routing (and myriad other pieces of Django, like template tags, serializers, etc.), and we don’t want to split responsibility across the stack.

With that said, Wagtail comes with a Django REST Framework API and can be run headlessly. We could utilize that and delegate routing to React. This is a bigger step, however. It involves writing custom Python code to correctly serialize CMS-managed content, and we'd have to adopt a React-in-browser framework like Next.js (#378). See details, plus example code bases, here: https://wagtail.org/headless/

With that said (again), I think (?) we like writing Python/Django more than JavaScript, and we abandoned Gatsby because we didn't like the DX of a JavaScript web framework... so there's that.

@hancush
Copy link
Member

hancush commented Jan 9, 2025

Reading this now: https://github.com/HackSoftware/Django-Styleguide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants