Added dashboard app to settings.py. Setup dashboard admin panel

parent 8b0039aa
from django.contrib import admin
from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
list_display = ('dept_name', 'home_unit')
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
list_display = ('first_name', 'middle_name', 'last_name', 'department')
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
\ No newline at end of file
from django.apps import AppConfig
class DashboardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Dashboard'
# Generated by Django 4.1.6 on 2023-03-02 13:32
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Department',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('dept_name', models.CharField(default='', max_length=50)),
('home_unit', models.CharField(default='', max_length=50)),
],
),
migrations.CreateModel(
name='WidgetUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(default='', max_length=50)),
('middle_name', models.CharField(default='', max_length=50)),
('last_name', models.CharField(default='', max_length=50)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Dashboard.department')),
],
),
]
from django.db import models
class Department(models.Model):
default_string = "";
dept_name = models.CharField(max_length = 50, default = default_string);
home_unit = models.CharField(max_length = 50, default = default_string);
def __str__(self):
return '{}'.format(self.dept_name)
class WidgetUser(models.Model):
default_string = "";
first_name = models.CharField(max_length = 50, default = default_string);
middle_name = models.CharField(max_length = 50, default = default_string);
last_name = models.CharField(max_length = 50, default = default_string);
department = models.ForeignKey(Department, on_delete = models.CASCADE);
def __str__(self):
return '{}'.format(self.first_name)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name = 'index'),
]
app_name = "Dashboard"
\ No newline at end of file
from django.shortcuts import HttpResponse
def index(request):
return HttpResponse("placeholder")
\ No newline at end of file
...@@ -40,6 +40,7 @@ INSTALLED_APPS = [ ...@@ -40,6 +40,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'Dashboard'
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
"""widget_gitgud URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('Dashboard/', include('Dashboard.urls', namespace="Dashboard")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment