Skip to content
Merged
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
2 changes: 1 addition & 1 deletion api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class StudentAdmin(admin.ModelAdmin):
class SchoolAdmin(admin.ModelAdmin):
fieldsets = (
('List Of Schools', {
'fields': ['schools_list']
'fields': ('schools_list', 'category')
}),
)

Expand Down
34 changes: 0 additions & 34 deletions api/migrations/0001_initial.py

This file was deleted.

19 changes: 0 additions & 19 deletions api/migrations/0002_auto_20200912_1655.py

This file was deleted.

Empty file removed api/migrations/__init__.py
Empty file.
15 changes: 13 additions & 2 deletions api/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
from django.db import models

CATEGORY = [
('OTHER', 'Other'),
('CBSE', 'Central board of secondary education'),
('ICSE', 'Indian certificate secondary education'),
('STATE_BOARD', 'State board'),
]


class School(models.Model):
schools_list = models.CharField(max_length=150)
category = models.CharField(
max_length=50,
choices=CATEGORY
)

def __str__(self):
return self.schools_list


class Student(models.Model):
student_name = models.CharField(max_length=150)
Expand All @@ -14,7 +26,6 @@ class Student(models.Model):
student_registration_no = models.IntegerField(default=0)
student_subject = models.TextField()
student_school_name = models.ForeignKey(School, on_delete=models.DO_NOTHING, default="")


def __str__(self):
return self.student_name
2 changes: 1 addition & 1 deletion api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class Meta:
class SchoolSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = School
fields = ['schools_list']
fields = ('schools_list', 'category')
8 changes: 6 additions & 2 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@
from rest_framework import permissions
from .serializers import UserSerializer, GroupSerializer


class UserViewSet(viewsets.ModelViewSet):
""" API endpoint that allows users to be view or edited"""
queryset = User.objects.all()
serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]


class GroupViewSet(viewsets.ModelViewSet):
queryset = Group.objects.all()
serializer_class = GroupSerializer
permission_class = [permissions.IsAuthenticated]



class StudentViewSet(viewsets.ModelViewSet):
queryset= Student.objects.all().order_by('Student_roll_no')
queryset = Student.objects.all().order_by('Student_roll_no')
serializer_class = StudentSerializer


class SchoolViewSet(viewsets.ModelViewSet):
queryset = School.objects.all()
serializer_class = SchoolSerializer