Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@friendofsvelte/django-kit
Advanced tools
This is a simple library that helps you integrate SvelteKit with Django. It provides a simple way to use Django as a backend and SvelteKit as a frontend, without hampering the reactivity provided by SvelteKit.
This is a simple library that helps you integrate SvelteKit with Django. It provides a simple way to use Django as a backend and SvelteKit as a frontend, without hampering the reactivity provided by SvelteKit.
It promotes SvelteKit's forms-actions heavily, and provides a way to use Django's forms, and validation with SvelteKit without any hassle.
People usually use fetch
to send data to the backend, and then handle the response. This is a good way to do it, but
it reduces the reactivity of SvelteKit. Django Kit provides a way to use Django's forms and validation with SvelteKit
keeping the reactivity intact, $page.form
is updated automatically when the form is submitted.
Using Django's Djapy is recommended for a more seamless integration.
First, in your SvelteKit project, install the package using npm:
In your SvelteKit project, install the package using npm:
npm install @friendofsvelte/django-kit
Use the package in your SvelteKit project, in your +page.server.ts
:
import {via_route_name} from '@friendofsvelte/django-kit';
export const actions = via_route_name(["login", "register", "logout"]);
// you need to setup django-kit-fos in your Django project
The via_route_name
function takes an array of route names, and returns an object with the same keys. The object has
functions that can be used to submit forms to the backend.
You can call GET
or POST
api endpoints using the functions returned by via_route_name
.
import {via_route_name} from '@friendofsvelte/django-kit';
export const actions = via_route_name([{name: "search_users", method: "GET"}]);
// converts the search formdata to query params
The via_route_path
function takes an array of route paths, and returns an object with the same keys. The object has
functions that can be used to submit forms to the backend.
import {via_route_path} from '@friendofsvelte/django-kit';
export const actions = via_route_path(["/login", "/register", "/logout"]);
This can also be used to call GET
or POST
api endpoints using the functions returned by via_route_path
.
You can also pass route prefix, and the function will automatically prepend the prefix to the route path.
import {via_route_path} from '@friendofsvelte/django-kit';
export const actions = via_route_path(["login", "register", "logout"], "/api");
If you're using Django as a backend, you can use the django-kit-fos
package to integrate Django with SvelteKit.
In your Django project, install the package using pip:
pip install django-kit-fos
In your Django project, add the following to your urls.py
:
from django.urls import path
from django_kit_fos import trigger_pattern
urlpatterns = [
# Your other paths
] + trigger_pattern
FAQs
This is a simple library that helps you integrate SvelteKit with Django. It provides a simple way to use Django as a backend and SvelteKit as a frontend, without hampering the reactivity provided by SvelteKit.
The npm package @friendofsvelte/django-kit receives a total of 21 weekly downloads. As such, @friendofsvelte/django-kit popularity was classified as not popular.
We found that @friendofsvelte/django-kit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.