Fix: fixed bug where dev could not migrate due to ValueError from Department.widgetuser

New Feature: added forms.py for future development
parent 20abb1a6
from django import forms
from homepage.models import WidgetUser
class IndexCardForm(forms.Form):
name = forms.CharField(label='Full Name', max_length=100)
section = forms.CharField(label='CSCI40 Section', max_length=5)
age = forms.IntegerField(label='Current Age')
\ No newline at end of file
......@@ -18,6 +18,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='homepage.department'),
field=models.ForeignKey(default=2, on_delete=django.db.models.deletion.CASCADE, to='homepage.department'),
),
]
# Generated by Django 3.2.12 on 2022-05-14 17:59
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0017_alter_department_widgetuser'),
]
operations = [
migrations.AlterField(
model_name='department',
name='dept_name',
field=models.CharField(default='none', max_length=50),
),
migrations.AlterField(
model_name='department',
name='home_unit',
field=models.CharField(default='none', max_length=50),
),
migrations.AlterField(
model_name='department',
name='widgetuser',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
]
# Generated by Django 3.2.12 on 2022-05-14 18:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0018_auto_20220514_2059'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='image',
field=models.ImageField(default='homepage/static/faceless.png', upload_to='homepage'),
),
]
# Generated by Django 3.2.12 on 2022-05-14 18:53
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0019_widgetuser_image'),
]
operations = [
migrations.RemoveField(
model_name='widgetuser',
name='image',
),
]
# Generated by Django 3.2.12 on 2022-05-14 19:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0020_remove_widgetuser_image'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='user_face',
field=models.ImageField(default='homepage/static/faceless.png', upload_to='static/'),
),
]
# Generated by Django 3.2.12 on 2022-05-14 19:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0021_widgetuser_user_face'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='user_face',
field=models.ImageField(default='homepage/static/faceless.png', upload_to='upload_image'),
),
]
# Generated by Django 3.2.12 on 2022-05-14 19:34
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('homepage', '0022_alter_widgetuser_user_face'),
]
operations = [
migrations.RemoveField(
model_name='widgetuser',
name='user_face',
),
]
......@@ -13,9 +13,9 @@ class WidgetUser(models.Model):
return self.last_name
class Department(models.Model):
widgetuser = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, null=False, default = 2)
dept_name = models.CharField(max_length=50)
home_unit = models.CharField(max_length=50)
widgetuser = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, null=False, blank=False)
dept_name = models.CharField(max_length=50, default='none')
home_unit = models.CharField(max_length=50, default='none')
def __str__(self):
return self.dept_name
\ No newline at end of file
......@@ -4,7 +4,6 @@ from django.http import Http404
from django.shortcuts import render
widgetUser = WidgetUser.objects.order_by("last_name")
#department = Department.objects.order_by("widgetuser.last_name")
def index(request):
context = {
......@@ -19,4 +18,3 @@ def detail(request, widgetuser_id):
raise Http404("User does not exist!")
return render(request, "homepage/details.html", {"Department": department})
\ No newline at end of file
......@@ -19,7 +19,6 @@ environ.Env.read_env()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
......
......@@ -16,6 +16,7 @@ Including another URLconf
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('announcements/', include('announcements.urls')),
path('homepage/',include("homepage.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