Skip to content

Commit

Permalink
Ready to upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajan03bhusal committed Feb 21, 2023
0 parents commit 260742f
Show file tree
Hide file tree
Showing 41 changed files with 455 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/CRUD.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions crudproject/crudproject/asgi.py
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()
124 changes: 124 additions & 0 deletions crudproject/crudproject/settings.py
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-&#2g$**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'
25 changes: 25 additions & 0 deletions crudproject/crudproject/urls.py
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")

]
16 changes: 16 additions & 0 deletions crudproject/crudproject/wsgi.py
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()
Binary file added crudproject/db.sqlite3
Binary file not shown.
Empty file added crudproject/enroll/__init__.py
Empty file.
Binary file not shown.
Binary file added crudproject/enroll/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added crudproject/enroll/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions crudproject/enroll/admin.py
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')
6 changes: 6 additions & 0 deletions crudproject/enroll/apps.py
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'
14 changes: 14 additions & 0 deletions crudproject/enroll/form.py
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'}),

}
23 changes: 23 additions & 0 deletions crudproject/enroll/migrations/0001_initial.py
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)),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions crudproject/enroll/models.py
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)
6 changes: 6 additions & 0 deletions crudproject/enroll/static/enroll/css/bootstrap.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions crudproject/enroll/static/enroll/js/bootstrap.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions crudproject/enroll/static/enroll/js/jquery.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions crudproject/enroll/static/enroll/js/popper.js

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions crudproject/enroll/templates/enroll/addandshow.html
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 %}
25 changes: 25 additions & 0 deletions crudproject/enroll/templates/enroll/base.html
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>
4 changes: 4 additions & 0 deletions crudproject/enroll/templates/enroll/update.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 %}
3 changes: 3 additions & 0 deletions crudproject/enroll/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
Loading

0 comments on commit 260742f

Please sign in to comment.