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,19 +4,17 @@ 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 = {
"WidgetUser": widgetUser
}
return render(request, "homepage/widgetusers_orderedlist.html", context)
def detail(request, widgetuser_id):
try:
department = Department.objects.get(pk=widgetuser_id)
except Department.DoesNotExist:
raise Http404("User does not exist!")
return render(request, "homepage/details.html", {"Department": department})
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/
......@@ -130,4 +129,4 @@ STATIC_URL = '/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
\ No newline at end of file
......@@ -16,10 +16,11 @@ 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")),
path('forum/', include('forum.urls')),
path('assignments/', include('assignments.urls')),
path('admin/', admin.site.urls),
]
]
\ No newline at end of file
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