Skip to main content

Django-NextJS Isomorphic UI dev with Decorator pattern

Project description

Isomorphic UI Development with Decorator pattern for Django with:

  • nextjs out of the box experience for frontend development,

  • rendering of nextjs pages with context in Django with NextJS template engine.

For fun & profit

Run the example project

git clone https://git.yourlabs.org/oss/djnext cd djnext pip install –user –editable .[dev] yarn install djnext watchstatic # maintains nextjs pages/ directory for yarn dev yarn dev # run localhost:3000 djnext dev # run localhost:8000

Choose NextJS page template in Django

Example project lives in src/djnext_example, see src/djnext_example/artist/urls.py:

CreateView.as_view(
    model=Artist,
    fields=['name'],
    success_url=reverse_lazy('artist_list'),
    template_name='create.js',
)

The template backend you added will make a request to the nextjs server you have on port 3000 with yarn dev.

Watchstatic command

Run your manage.py watchstatic or yourproject watchstatic if your project has an entrypoint.

This will watch static/ directories of all apps in INSTALLED_APPS, and build static_root/ directory. Also, it creates a symlink from static_root/pages to pages/, so that yarn dev will find it.

On port 8000 we don’t yet have auto frontend code reload, but you have it on port 3000 wit h watchstatic running at the same time.

Install in your project

Add to ‘djnext’ to INSTALLED_APPS, add dict(BACKEND='djnext.Backend') to TEMPLATES.

With LOVE from POITOU CHARENTE

About

This project was made possible by Thomas Binetruy, frontend engineer.

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

djnext-0.0.1.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file djnext-0.0.1.tar.gz.

File metadata

  • Download URL: djnext-0.0.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for djnext-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8fab0edc862feb9515d7dc424280e2d47c572832c5d0bd2e6f60c55b06c32ad1
MD5 904f9ef4b023d1821beb23f19ef91958
BLAKE2b-256 ca2721eda74ad38c22f6e8d257e2f978207fde22a0b9a8825cb8c3b308a9030c

See more details on using hashes here.

Supported by

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