Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view added #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified CCD/__pycache__/settings.cpython-38.pyc
Binary file not shown.
Binary file modified CCD/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file added CCD/__pycache__/wsgi.cpython-38.pyc
Binary file not shown.
11 changes: 8 additions & 3 deletions CCD/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

from pathlib import Path

import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand All @@ -38,6 +38,7 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'drf_spectacular',
'rest_framework',
'contactus',
'student_utilities',
'lifeatiitg',
Expand Down Expand Up @@ -80,8 +81,12 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'test123456789',
'HOST': 'localhost',
'PORT': '5432',
}
}
"""
Expand Down
3 changes: 3 additions & 0 deletions CCD/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django.urls import path
from django.urls.conf import include
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
Expand All @@ -22,4 +23,6 @@
name="redoc",
),
path('admin/', admin.site.urls),
path("",include('home.urls')),
path("",include('lifeatiitg.urls')),
]
Binary file modified home/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file added home/__pycache__/router.cpython-38.pyc
Binary file not shown.
Binary file added home/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file added home/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file added home/__pycache__/views.cpython-38.pyc
Binary file not shown.
13 changes: 7 additions & 6 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

# Create your models here.
class About(models.Model):
about = models.CharField(max_length=100)
about = models.CharField(max_length=100,default=" ")

class CampusRecuitment(models.Model):
title = models.CharField(max_length=50)
content = ArrayField(models.CharField(max_length=100),max_length=4)
title = models.CharField(max_length=50,default=" ")
content = ArrayField(models.CharField(max_length=1000,default=" "),max_length=5,default=list)
link = models.URLField(max_length=100,default=" ")
# content1 = models.CharField(max_length=100)
# content2 = models.CharField(max_length=100)
# content3 = models.CharField(max_length=100)

class Acknowledgement(models.Model):
title = models.CharField(max_length=100)
title = models.CharField(max_length=100,default=" ")
image = models.ImageField(upload_to='img',max_length=100)
content = models.CharField(max_length=1000)
link = models.URLField(max_length=100)
content = models.CharField(max_length=1000,default=" ")
link = models.URLField(max_length=100,default=" ")
9 changes: 9 additions & 0 deletions home/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from home.views import AboutViewSet,CampusRecuitmentViewSet,AcknowledgementViewSet
from rest_framework import routers

router = routers.DefaultRouter()

router.register('About',AboutViewSet)
router.register('CampusRecuitment',CampusRecuitmentViewSet)
router.register('Acknowledgement',AcknowledgementViewSet)

18 changes: 18 additions & 0 deletions home/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from rest_framework import serializers
from home.models import About,CampusRecuitment,Acknowledgement

class AboutSerializer(serializers.ModelSerializer):
class Meta:
model = About
fields = ['about']

class CampusRecuitmentSerializer(serializers.ModelSerializer):
class Meta:
model = CampusRecuitment
fields = ['title','content']

class AcknowledgementSerializer(serializers.ModelSerializer):
class Meta:
model = Acknowledgement
fields = ['title','image','content','link']

8 changes: 8 additions & 0 deletions home/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls.conf import include
from home.router import router
from django.urls import path
from django.urls.conf import include

urlpatterns = [
path('api/',include(router.urls))
]
22 changes: 21 additions & 1 deletion home/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
from typing import ClassVar
from django.shortcuts import render

from rest_framework import viewsets
from home.models import About,CampusRecuitment,Acknowledgement
from home.serializers import AboutSerializer,CampusRecuitmentSerializer,AcknowledgementSerializer
# Create your views here.

class AboutViewSet(viewsets.ModelViewSet):
serializer_class = AboutSerializer
queryset = About.objects.all()

class CampusRecuitmentViewSet(viewsets.ModelViewSet):
serializer_class = CampusRecuitmentSerializer
queryset = CampusRecuitment.objects.all()

class AcknowledgementViewSet(viewsets.ModelViewSet):
serializer_class = AcknowledgementSerializer
queryset = Acknowledgement.objects.all()





Binary file modified lifeatiitg/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file added lifeatiitg/__pycache__/router.cpython-38.pyc
Binary file not shown.
Binary file added lifeatiitg/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file added lifeatiitg/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file added lifeatiitg/__pycache__/views.cpython-38.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions lifeatiitg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

# Create your models here.
class Contents(models.Model):
title = models.CharField(max_length=50)
description = models.CharField(max_length=100)
link = models.URLField(max_length=60)
title = models.CharField(max_length=100,default=" ")
description = models.CharField(max_length=1000,default=" ")
link = models.URLField(max_length=100,default=" ")
6 changes: 6 additions & 0 deletions lifeatiitg/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from lifeatiitg.views import ContentsViewSet
from rest_framework import routers

router = routers.DefaultRouter()

router.register('Content',ContentsViewSet)
9 changes: 9 additions & 0 deletions lifeatiitg/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework import serializers
from lifeatiitg.models import Contents

class ContentsSerializer(serializers.ModelSerializer):
class Meta:
model = Contents
fields = ['title','description','link']


7 changes: 7 additions & 0 deletions lifeatiitg/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from lifeatiitg.router import router
from django.urls import path
from django.urls.conf import include

urlpatterns = [
path('api/',include(router.urls))
]
9 changes: 8 additions & 1 deletion lifeatiitg/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from django.shortcuts import render

from rest_framework import viewsets
from lifeatiitg.models import Contents
from lifeatiitg.serializers import ContentsSerializer
# Create your views here.

class ContentsViewSet(viewsets.ModelViewSet):
serializer_class = ContentsSerializer
queryset = Contents.objects.all()