Giter Site home page Giter Site logo

sample's People

Contributors

sushil642 avatar

Watchers

 avatar

sample's Issues

Lab pg

views.py
from django.http import HttpResponse
from django.shortcuts import render
from studCourseRegApp.models import student,course, projectForm

Create your views here.

def home(request):
return render(request,'home.html')
def studentlist(request)

s=student.objects.all()
return render(request,'studentlist.html',{'student_list':s})
def courselist(request):
c=course.objects.all()
return render(request,'courselist.html',{'course_list':c})
def register(request):
if request.method=="POST":
sid=request.POST.get("student")
cid=request.POST.get("course")
studentobj=student.objects.get(id=sid)
courseobj=course.objects.get(id=cid)
res=studentobj.courses.filter(id=cid)
if res:
resp="

Student with usn %s has already enrolled for the
%s

"%(studentobj.usn,courseobj.courseCode)
return HttpResponse(resp)
studentobj.courses.add(courseobj)
resp="

student with usn %s successfully enrolled for the course with sub code
%s

"%(studentobj.usn,courseobj.courseCode)
return HttpResponse(resp)
else:
studentlist=student.objects.all()
courselist=course.objects.all()
return render(request,'register.html',{'student_list':studentlist,'course_list':courselist})
def enrolledStudents(request):
if request.method=="POST":
cid=request.POST.get("course")
courseobj=course.objects.get(id=cid)
studentlistobj=courseobj.student_set.all()
return render(request,'enrolledlist.html',{'course':courseobj,'student_list':studentlistobj})

else:
courselist=course.objects.all()
return render(request,'enrolledlist.html',{'Course_List':courselist})
urls.py
from django.contrib import admin
from django.urls import path
from studCourseRegApp.views import home, studentlist,courselist,register,enrolledStudents
urlpatterns = [
path('secretadmin/', admin.site.urls),
path('',home),
path('home/',home),
path('studentlist/',studentlist),
path('courselist/',courselist),
path('register/',register),
path('enrolledlist/',enrolledStudents),
]
settings.py(only one change inside installed apps add studCourseRegApp )

Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'studCourseRegApp',
]
OUTPUT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.