Skip to content

Commit

Permalink
Django: Create base app with manifest.json view
Browse files Browse the repository at this point in the history
  • Loading branch information
felbinger committed Aug 13, 2024
1 parent 9bff6ac commit 5ff5f8c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"django.contrib.staticfiles",
] + [
"rest_framework.apps.RestFrameworkConfig",
"base.apps.BaseConfig",
]

MIDDLEWARE = [
Expand Down
3 changes: 3 additions & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
from django.contrib import admin
from django.urls import path

from base.views import manifest

urlpatterns = [
path("admin/", admin.site.urls),
path("manifest.json", manifest),
]

admin.site.site_header = admin.site.site_title = "Django example"
Expand Down
Empty file added app/base/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions app/base/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions app/base/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class BaseConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "base"
Empty file added app/base/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions app/base/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions app/base/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
12 changes: 12 additions & 0 deletions app/base/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.http import HttpRequest, JsonResponse
from django.shortcuts import render


def manifest(request: HttpRequest) -> JsonResponse:
return JsonResponse(
{
"name": "Example for Django",
"short_name": "Django example",
"display": "standalone",
}
)

0 comments on commit 5ff5f8c

Please sign in to comment.