First, make sure you use the SessionAuthentication in Django. Put this in your settings.py
# Django rest framework
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication'
export const handleSubscription = (user) => { | |
'use strict' | |
const axios = require('axios') | |
let isSubscribed = false | |
let swRegistration = null | |
let anyReminder = false | |
//user object holds the user's reminder opt-in status as boolean. | |
//checking if the user opted-in any of our reminder option | |
if (Object.values(user).some((val) => val === true)) anyReminder = true |
# https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard | |
from django.contrib import admin | |
from django.db.models import Count, Sum, Min, Max, DateTimeField | |
from django.db.models.functions import Trunc | |
from . import models | |
def get_next_in_date_hierarchy(request, date_hierarchy): |
''' Useage '''' | |
# Declare our item | |
store = Store.objects.get(pk=pk) | |
# Define our models | |
stores = Store.objects.all() | |
# Ask for the next item | |
new_store = get_next_or_prev(stores, store, 'next') | |
# If there is a next item | |
if new_store: | |
# Replace our item with the next one |