-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for crudproject project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crudproject.settings') | ||
|
||
application = get_asgi_application() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
""" | ||
Django settings for crudproject project. | ||
Generated by 'django-admin startproject' using Django 4.1.6. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.1/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/4.1/ref/settings/ | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
# 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/4.1/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = 'django-insecure-g$**o5@o-$!b@v^fmalckn=mymyp0m8r485!0k4ajzg9^^t' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = [] | ||
|
||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'enroll', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
] | ||
|
||
ROOT_URLCONF = 'crudproject.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'crudproject.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': BASE_DIR / 'db.sqlite3', | ||
} | ||
} | ||
|
||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators | ||
|
||
AUTH_PASSWORD_VALIDATORS = [ | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
}, | ||
] | ||
|
||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/4.1/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'UTC' | ||
|
||
USE_I18N = True | ||
|
||
USE_TZ = True | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/4.1/howto/static-files/ | ||
|
||
STATIC_URL = 'static/' | ||
|
||
# Default primary key field type | ||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field | ||
|
||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""crudproject URL Configuration | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/4.1/topics/http/urls/ | ||
Examples: | ||
Function views | ||
1. Add an import: from my_app import views | ||
2. Add a URL to urlpatterns: path('', views.home, name='home') | ||
Class-based views | ||
1. Add an import: from other_app.views import Home | ||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | ||
Including another URLconf | ||
1. Import the include() function: from django.urls import include, path | ||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | ||
""" | ||
from django.contrib import admin | ||
from django.urls import path | ||
from enroll import views | ||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('',views.add_show,name="showandadd"), | ||
path('delete/<int:id>/', views.delete_data, name="deletedata") | ||
|
||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for crudproject project. | ||
It exposes the WSGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crudproject.settings') | ||
|
||
application = get_wsgi_application() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.contrib import admin | ||
from .models import User | ||
# Register your models here. | ||
@admin.register(User) | ||
class Useradmin(admin.ModelAdmin): | ||
list_display = ('id', 'name', 'email', 'password') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class EnrollConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'enroll' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.core import validators | ||
from django import forms | ||
from .models import User | ||
|
||
class StudentRegistration(forms.ModelForm): | ||
class Meta: | ||
model = User | ||
fields = ['name', 'email', 'password'] | ||
widgets ={ | ||
'name': forms.TextInput(attrs={'class': 'form-control'}), | ||
'email': forms.EmailInput(attrs={'class': 'form-control'}), | ||
'password': forms.PasswordInput(attrs={'class': 'form-control'}), | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.1.6 on 2023-02-12 03:03 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='User', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=70)), | ||
('email', models.EmailField(max_length=70)), | ||
('password', models.CharField(max_length=70)), | ||
], | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
class User(models.Model): | ||
name = models.CharField(max_length=70) | ||
email = models.EmailField(max_length=70) | ||
password = models.CharField(max_length=70) |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{% extends 'enroll/base.html' %} | ||
{% block content %} | ||
|
||
<div class="row"> | ||
<div class="col-sm-4"> | ||
<h4 class="text-center alert alert-info">Add New Student</h4> | ||
<form action="" method="POST"> | ||
{% csrf_token%} | ||
{{form.as_p}} | ||
<input type="submit" class="btn btn-success" value="Add"> | ||
</form> | ||
</div> | ||
|
||
<div class="col-sm-8"> | ||
<h4 class="text-center alert alert-info">Student Information</h4> | ||
{% if stu%} | ||
<table class="table"> | ||
<thead class="thead-dark"> | ||
<tr> | ||
<th scope="col">ID</th> | ||
<th scope="col">Name</th> | ||
<th scope="col">Email</th> | ||
<th scope="col">Password</th> | ||
<th scope="col">Action</th> | ||
|
||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for st in stu%} | ||
<tr> | ||
<th scope="row">{{st.id}}</th> | ||
<td>{{st.name}}</td> | ||
<td>{{st.email}}</td> | ||
<td>{{st.password}}</td> | ||
<td> | ||
<a href="#" class="btn btn-warning btn-sm">Edit</a> | ||
<form action="{% url 'deletedata' st.id%}" | ||
method="POST" class="d-inline"> | ||
{% csrf_token%} | ||
|
||
<input type="submit" class="btn bg-danger" value="Delete"> | ||
</form> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
|
||
</tbody> | ||
</table> | ||
|
||
|
||
{% else %} | ||
<h4 class="text-center alert alert-warning">No Records</h4> | ||
{% endif%} | ||
|
||
|
||
</div> | ||
</div> | ||
|
||
{% endblock content %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
{% load static%} | ||
<link rel="stylesheet" href="{% static 'enroll/css/bootstrap.min.css'%}"> | ||
</head> | ||
<body> | ||
|
||
<div class="container mt-5"> | ||
<h2 class="text-center alert alert-danger">CRUD Operation</h2> | ||
{% block content %} | ||
{% endblock content %} | ||
|
||
</div> | ||
<script src="{% static 'enroll/js/bootstrap.min.js' %}"> </script> | ||
<script src="{% static 'enroll/js/jquery.js' %}"> </script> | ||
<script src="{% static 'enroll/js/popper.js' %}"> </script> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% extends 'enroll/base.html' %} | ||
{% block content %} | ||
<h4>Update Student</h4> | ||
{% endblock content %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |