Commit 9acde97a authored by Jiuvi Anne Hu's avatar Jiuvi Anne Hu

Created announcements app. Added models to the app.

parent 67012e5e
*.env
\ No newline at end of file
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class AnnouncementsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'announcements'
from django.db import models
class Announcement(models.Model):
title = models.TextField(null=True, blank=True)
body = models.TextField(null=True, blank=True)
author = models.CharField(max_length=255, null=True, blank=True)
pub_datetime = models.DateTimeField(null=True, blank=True)
class Reaction(models.Model):
LIKE = 'Like'
LOVE = 'Love'
ANGRY = 'Angry'
REACTION_CHOICES = [
(LIKE, 'Like'),
(LOVE, 'Love'),
(ANGRY, 'Angry'),
]
name = models.CharField(max_length=5, default=LIKE, null=True, blank=True)
tally = models.IntegerField(default=0 ,null=True, blank=True)
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, null=True, blank=True)
# Create your models here.
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 = "announcements"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse('temp')
# Create your views here.
...@@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/3.2/ref/settings/ ...@@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
""" """
from pathlib import Path from pathlib import Path
from dotenv import load_dotenv
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
...@@ -31,6 +33,7 @@ ALLOWED_HOSTS = [] ...@@ -31,6 +33,7 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'announcements',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
......
...@@ -14,8 +14,9 @@ Including another URLconf ...@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 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('announcements/', include('announcements.urls', namespace="announcements")),
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