├── emp ├── __init__.py ├── migrations │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ ├── 0001_initial.cpython-39.pyc │ │ └── 0002_testimonial.cpython-39.pyc │ ├── 0002_testimonial.py │ └── 0001_initial.py ├── tests.py ├── __pycache__ │ ├── admin.cpython-39.pyc │ ├── apps.cpython-39.pyc │ ├── form.cpython-39.pyc │ ├── forms.cpython-39.pyc │ ├── urls.cpython-39.pyc │ ├── views.cpython-39.pyc │ ├── models.cpython-39.pyc │ └── __init__.cpython-39.pyc ├── apps.py ├── admin.py ├── urls.py ├── forms.py ├── models.py └── views.py ├── myapp ├── __init__.py ├── __pycache__ │ ├── urls.cpython-39.pyc │ ├── views.cpython-39.pyc │ ├── wsgi.cpython-39.pyc │ ├── __init__.cpython-39.pyc │ └── settings.cpython-39.pyc ├── asgi.py ├── wsgi.py ├── urls.py ├── views.py └── settings.py ├── website ├── urls.py ├── __init__.py ├── migrations │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ └── 0001_initial.cpython-39.pyc │ └── 0001_initial.py ├── tests.py ├── views.py ├── admin.py ├── __pycache__ │ ├── admin.cpython-39.pyc │ ├── apps.cpython-39.pyc │ ├── models.cpython-39.pyc │ └── __init__.cpython-39.pyc ├── apps.py └── models.py ├── db.sqlite3 ├── django_tutorials.pptx ├── testimonials ├── vlcsnap-2021-11-28-00h43m59s158.png └── vlcsnap-2021-12-18-00h58m19s860.png ├── media └── testimonials │ ├── vlcsnap-2021-12-18-00h58m19s860.png │ ├── vlcsnap-2022-05-02-13h49m01s958.png │ └── vlcsnap-2022-05-02-13h49m08s402.png ├── templates ├── navbar.html ├── about.html ├── services.html ├── emp │ ├── feedback.html │ ├── navbar.html │ ├── testimonials.html │ ├── home.html │ ├── add_emp.html │ └── update_emp.html └── home.html └── manage.py /emp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /myapp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/urls.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /emp/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /emp/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /website/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /website/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /django_tutorials.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/django_tutorials.pptx -------------------------------------------------------------------------------- /emp/__pycache__/admin.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/__pycache__/admin.cpython-39.pyc -------------------------------------------------------------------------------- /emp/__pycache__/apps.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/__pycache__/apps.cpython-39.pyc -------------------------------------------------------------------------------- /emp/__pycache__/form.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/__pycache__/form.cpython-39.pyc -------------------------------------------------------------------------------- /emp/__pycache__/forms.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/__pycache__/forms.cpython-39.pyc -------------------------------------------------------------------------------- /emp/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /emp/__pycache__/views.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/__pycache__/views.cpython-39.pyc -------------------------------------------------------------------------------- /emp/__pycache__/models.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/__pycache__/models.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/myapp/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/views.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/myapp/__pycache__/views.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/wsgi.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/myapp/__pycache__/wsgi.cpython-39.pyc -------------------------------------------------------------------------------- /website/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Student 3 | # Register your models here. 4 | 5 | 6 | admin.site.register(Student) 7 | -------------------------------------------------------------------------------- /emp/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/myapp/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/settings.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/myapp/__pycache__/settings.cpython-39.pyc -------------------------------------------------------------------------------- /website/__pycache__/admin.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/website/__pycache__/admin.cpython-39.pyc -------------------------------------------------------------------------------- /website/__pycache__/apps.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/website/__pycache__/apps.cpython-39.pyc -------------------------------------------------------------------------------- /website/__pycache__/models.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/website/__pycache__/models.cpython-39.pyc -------------------------------------------------------------------------------- /emp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class EmpConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'emp' 7 | -------------------------------------------------------------------------------- /website/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/website/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /testimonials/vlcsnap-2021-11-28-00h43m59s158.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/testimonials/vlcsnap-2021-11-28-00h43m59s158.png -------------------------------------------------------------------------------- /testimonials/vlcsnap-2021-12-18-00h58m19s860.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/testimonials/vlcsnap-2021-12-18-00h58m19s860.png -------------------------------------------------------------------------------- /emp/migrations/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/migrations/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /website/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class WebsiteConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'website' 7 | -------------------------------------------------------------------------------- /emp/migrations/__pycache__/0001_initial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/migrations/__pycache__/0001_initial.cpython-39.pyc -------------------------------------------------------------------------------- /media/testimonials/vlcsnap-2021-12-18-00h58m19s860.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/media/testimonials/vlcsnap-2021-12-18-00h58m19s860.png -------------------------------------------------------------------------------- /media/testimonials/vlcsnap-2022-05-02-13h49m01s958.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/media/testimonials/vlcsnap-2022-05-02-13h49m01s958.png -------------------------------------------------------------------------------- /media/testimonials/vlcsnap-2022-05-02-13h49m08s402.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/media/testimonials/vlcsnap-2022-05-02-13h49m08s402.png -------------------------------------------------------------------------------- /website/migrations/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/website/migrations/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /emp/migrations/__pycache__/0002_testimonial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/emp/migrations/__pycache__/0002_testimonial.cpython-39.pyc -------------------------------------------------------------------------------- /website/migrations/__pycache__/0001_initial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnCodeWithDurgesh/Django-Framework-with-Project/HEAD/website/migrations/__pycache__/0001_initial.cpython-39.pyc -------------------------------------------------------------------------------- /templates/navbar.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | class Student(models.Model): 5 | name=models.CharField(max_length=200) 6 | college=models.CharField(max_length=200) 7 | age=models.IntegerField(max_length=10) 8 | is_active=models.BooleanField(default=False) 9 | -------------------------------------------------------------------------------- /emp/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Emp,Testimonial 3 | # Register your models here. 4 | 5 | class EmpAdmin(admin.ModelAdmin): 6 | list_display=('name','working','emp_id','phone') 7 | list_editable=('working','emp_id') 8 | search_fields=('name','phone') 9 | list_filter=('working',) 10 | 11 | admin.site.register(Emp,EmpAdmin) 12 | admin.site.register(Testimonial) -------------------------------------------------------------------------------- /emp/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path,include 3 | from .views import * 4 | 5 | urlpatterns = [ 6 | path("home/",emp_home), 7 | path("add-emp/",add_emp), 8 | path("delete-emp/",delete_emp), 9 | path("update-emp/",update_emp), 10 | path("do-update-emp/",do_update_emp), 11 | path("testimonials/",testimonials), 12 | path("feedback/",feedback), 13 | ] 14 | -------------------------------------------------------------------------------- /myapp/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for myapp project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /myapp/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for myapp project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /emp/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import Emp 3 | class FeedbackForm(forms.Form): 4 | email=forms.EmailField(label="Enter you email",max_length=100) 5 | name=forms.CharField(label="Enter you name",max_length=100) 6 | feedback=forms.CharField(label="Your feedback",widget=forms.Textarea) 7 | 8 | def __init__(self, *args, **kwargs): 9 | super(FeedbackForm, self).__init__(*args, **kwargs) 10 | for visible in self.visible_fields(): 11 | visible.field.widget.attrs['class'] = 'form-control' 12 | 13 | 14 | class EmpForm(forms.ModelForm): 15 | class Meta: 16 | model=Emp 17 | fields=['name','emp_id','phone','address',] -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /emp/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | class Emp(models.Model): 5 | name=models.CharField(max_length=200) 6 | emp_id=models.CharField(max_length=200) 7 | phone=models.CharField(max_length=10) 8 | address=models.CharField(max_length=150) 9 | working=models.BooleanField(default=True) 10 | department=models.CharField(max_length=10) 11 | 12 | def __str__(self): 13 | return self.name 14 | 15 | 16 | class Testimonial(models.Model): 17 | name=models.CharField(max_length=200) 18 | testimonial=models.TextField() 19 | picture=models.ImageField(upload_to="testimonials/") 20 | rating=models.IntegerField(max_length=1) 21 | 22 | def __str__(self): 23 | return self.testimonial -------------------------------------------------------------------------------- /website/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.0.5 on 2022-06-07 12:04 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Student', 16 | fields=[ 17 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=200)), 19 | ('college', models.CharField(max_length=200)), 20 | ('age', models.IntegerField(max_length=10)), 21 | ('is_active', models.BooleanField(default=False)), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /emp/migrations/0002_testimonial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.0.5 on 2022-06-07 17:27 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('emp', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.CreateModel( 14 | name='Testimonial', 15 | fields=[ 16 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 17 | ('name', models.CharField(max_length=200)), 18 | ('testimonial', models.TextField()), 19 | ('picture', models.ImageField(upload_to='testimonials/')), 20 | ('rating', models.IntegerField(max_length=1)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /emp/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.0.5 on 2022-06-07 13:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Emp', 16 | fields=[ 17 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=200)), 19 | ('emp_id', models.CharField(max_length=200)), 20 | ('phone', models.CharField(max_length=10)), 21 | ('address', models.CharField(max_length=150)), 22 | ('working', models.BooleanField(default=True)), 23 | ('department', models.CharField(max_length=10)), 24 | ], 25 | ), 26 | ] 27 | -------------------------------------------------------------------------------- /templates/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | About Our Website 8 | 9 | 10 |
11 | {% include 'navbar.html' %} 12 | 13 |

About our Website

14 |

15 | Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, ab 16 | mollitia vero tempora ipsa perferendis praesentium repellendus. A sint 17 | quas officia quo esse eos exercitationem voluptates unde illo quisquam, 18 | id, illum voluptatem cumque reiciendis ad assumenda, aspernatur 19 | molestiae. Vitae quidem suscipit, culpa illum ullam ipsa cum quis 20 | voluptatum dolorem possimus? 21 |

22 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /templates/services.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Services 8 | 9 | 10 |
11 | {% include 'navbar.html' %} 12 | 13 |

The services that we provide

14 |

15 | Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, ab 16 | mollitia vero tempora ipsa perferendis praesentium repellendus. A sint 17 | quas officia quo esse eos exercitationem voluptates unde illo quisquam, 18 | id, illum voluptatem cumque reiciendis ad assumenda, aspernatur 19 | molestiae. Vitae quidem suscipit, culpa illum ullam ipsa cum quis 20 | voluptatum dolorem possimus? 21 |

22 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /myapp/urls.py: -------------------------------------------------------------------------------- 1 | """myapp URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/4.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path,include 18 | from .views import * 19 | from django.conf import settings 20 | from django.conf.urls.static import static 21 | 22 | urlpatterns = [ 23 | path('admin/', include('admin_honeypot.urls', namespace='admin_honeypot')), 24 | path('actual-login/', admin.site.urls), 25 | path("",home), 26 | path("index/",home), 27 | path("about/",about), 28 | path("services/",services), 29 | path("emp/",include('emp.urls')) 30 | ]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 31 | -------------------------------------------------------------------------------- /myapp/views.py: -------------------------------------------------------------------------------- 1 | from django.http import HttpResponse 2 | from django.shortcuts import render 3 | 4 | import datetime 5 | 6 | def home(request): 7 | isActive=True 8 | if request.method=='POST': 9 | check=request.POST.get("check") 10 | print(check) 11 | if check is None: isActive=False 12 | else: isActive=True 13 | 14 | 15 | date=datetime.datetime.now() 16 | name="LearnCodeWithDurgesh" 17 | list_of_programs=[ 18 | 'WAP to check even or odd', 19 | 'WAP to check prime number', 20 | 'WAP to print all prime numbers from 1 to 100', 21 | 'WAP to print pascals triangle' 22 | ] 23 | student={ 24 | 'student_name':"Rahul", 25 | 'student_college':"ZYZ", 26 | 'student_city':'LUCKNOW' 27 | } 28 | # return HttpResponse("

Hello this is index page

"+str(date)) 29 | data={ 30 | 'date':date, 31 | 'isActive':isActive, 32 | 'name':name, 33 | 'list_of_programs':list_of_programs, 34 | 'student_data':student 35 | } 36 | return render(request,"home.html",data) 37 | 38 | def about(request): 39 | # return HttpResponse("

This is about page

") 40 | return render(request, "about.html",{}) 41 | 42 | def services(request): 43 | # return HttpResponse("

This is services page

") 44 | return render(request, "services.html",{}) -------------------------------------------------------------------------------- /templates/emp/feedback.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Bootstrap demo 7 | 13 | 14 | 15 | {% include 'emp/navbar.html' %} 16 | 17 |

Feedback

18 | 19 |
20 |
21 |
22 | 23 |
24 |
25 | 26 |
27 | 28 | {% csrf_token %} 29 | {{form.as_p}} 30 | 31 | 32 |
33 | 36 |
37 | 38 |
39 | 40 | 41 |
42 |
43 | 44 |
45 |
46 |
47 | 48 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /templates/emp/navbar.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Home page 8 | 9 | 10 |
11 | {% include 'navbar.html' %} 12 | 13 | 14 | 15 |

Welcome to our website

16 | 17 |
18 | {% csrf_token %} 19 | 20 | 21 | 22 |
23 | 24 |

25 | Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, ab 26 | mollitia vero tempora ipsa perferendis praesentium repellendus. A sint 27 | quas officia quo esse eos exercitationem voluptates unde illo quisquam, 28 | id, illum voluptatem cumque reiciendis ad assumenda, aspernatur 29 | molestiae. Vitae quidem suscipit, culpa illum ullam ipsa cum quis 30 | voluptatum dolorem possimus? 31 |

32 | 33 | 34 | 35 | 36 | {% if isActive %} 37 |
38 |

Todays date is {{date}}

39 |

Name is {{name}}

40 |
41 |

Student data

42 |

Student name : {{student_data.student_name}}

43 |

Student college : {{student_data.student_college}}

44 |

Student city : {{student_data.student_city}}

45 |
46 |

Favorite Programs

47 | 48 | {% for p in list_of_programs %} 49 | 50 |

{{p}}

51 | 52 | {% endfor %} 53 | 54 |
55 | 56 | 57 | 58 | {% endif %} 59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /templates/emp/testimonials.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Bootstrap demo 7 | 13 | 14 | 15 | {% include 'emp/navbar.html' %} 16 | 17 |

Testimonials

18 |
19 |
20 |
21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | {% for t in testi %} 35 | 36 | 37 | 40 | 44 | 47 | 50 | 51 | 52 | {% endfor %} 53 | 54 |
#SNO.NAMETestimonialsRating
38 | {{forloop.counter}} 39 | 41 | 42 | {{t.name}} 43 | 45 | {{t.testimonial}} 46 | 48 | {{t.rating}} 49 |
55 |
56 |
57 |
58 |
59 |
60 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /templates/emp/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Bootstrap demo 7 | 13 | 14 | 15 | {% include 'emp/navbar.html' %} 16 | 17 |

Employee Management

18 |

List of Employees

19 |
20 |
21 |
22 |
23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | {% for e in emps %} 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 51 | 52 | {% endfor %} 53 | 54 |
#SNO.NAMEEMP IDPHONEWORKINGDEPARTMENTADDRESSACTION
{{forloop.counter}}{{e.name}}{{e.emp_id}}{{e.phone}}{{e.working}}{{e.department}}{{e.address}} 48 | Delete 49 | Update 50 |
55 |
56 |
57 |
58 |
59 |
60 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /emp/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render,redirect 2 | from django.http import HttpResponse 3 | from .models import Emp,Testimonial 4 | from .forms import FeedbackForm,EmpForm 5 | # Create your views here. 6 | def emp_home(request): 7 | 8 | emps=Emp.objects.all() 9 | return render(request, "emp/home.html",{ 10 | 'emps':emps 11 | }) 12 | 13 | def add_emp(request): 14 | if request.method=="POST": 15 | 16 | #data fetch 17 | emp_name=request.POST.get("emp_name") 18 | emp_id=request.POST.get("emp_id") 19 | emp_phone=request.POST.get("emp_phone") 20 | emp_address=request.POST.get("emp_address") 21 | emp_working=request.POST.get("emp_working") 22 | emp_department=request.POST.get("emp_department") 23 | 24 | #validate 25 | 26 | #create model object and set the data 27 | e=Emp() 28 | e.name=emp_name 29 | e.emp_id=emp_id 30 | e.phone=emp_phone 31 | e.address=emp_address 32 | e.department=emp_department 33 | if emp_working is None: 34 | e.working=False 35 | else: 36 | e.working=True 37 | #save the object 38 | e.save() 39 | #prepare msg 40 | 41 | return redirect("/emp/home/") 42 | form=EmpForm() 43 | 44 | return render(request, "emp/add_emp.html",{'form':form}) 45 | 46 | 47 | def delete_emp(request,emp_id): 48 | emp=Emp.objects.get(pk=emp_id) 49 | emp.delete() 50 | return redirect("/emp/home/") 51 | 52 | def update_emp(request,emp_id): 53 | emp=Emp.objects.get(pk=emp_id) 54 | return render(request, "emp/update_emp.html",{ 55 | 'emp':emp 56 | }) 57 | 58 | def do_update_emp(request,emp_id): 59 | if request.method=='POST': 60 | emp_name=request.POST.get("emp_name") 61 | emp_id_temp=request.POST.get("emp_id") 62 | emp_phone=request.POST.get("emp_phone") 63 | emp_address=request.POST.get("emp_address") 64 | emp_working=request.POST.get("emp_working") 65 | emp_department=request.POST.get("emp_department") 66 | 67 | e=Emp.objects.get(pk=emp_id) 68 | e.name=emp_name 69 | e.emp_id=emp_id_temp 70 | e.phone=emp_phone 71 | e.address=emp_address 72 | e.department=emp_department 73 | if emp_working is None: 74 | e.working=False 75 | else: 76 | e.working=True 77 | 78 | e.save() 79 | return redirect("/emp/home/") 80 | 81 | def testimonials(request): 82 | testi=Testimonial.objects.all() 83 | 84 | return render(request, "emp/testimonials.html",{ 85 | 'testi':testi 86 | }) 87 | 88 | 89 | def feedback(request): 90 | if request.method=='POST': 91 | form=FeedbackForm(request.POST) 92 | if form.is_valid(): 93 | print(form.cleaned_data['email']) 94 | print(form.cleaned_data['name']) 95 | print(form.cleaned_data['feedback']) 96 | print("data saved") 97 | else: 98 | return render(request, "emp/feedback.html",{'form':form}) 99 | else: 100 | form=FeedbackForm() 101 | return render(request, "emp/feedback.html",{'form':form}) -------------------------------------------------------------------------------- /templates/emp/add_emp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Add Employee 7 | 13 | 14 | 15 | {% include 'emp/navbar.html' %} 16 | 17 |

Add New Employee

18 | 19 |
20 |
21 |
22 |
23 |
24 |
25 | {% csrf_token %} 26 |
27 | 28 | 35 |
36 | 37 |
38 | 39 | 46 |
47 | 48 |
49 | 50 | 57 |
58 |
59 | 60 | 66 |
67 |
68 | 69 | 70 |
71 |
72 | 73 | 78 |
79 |
80 | 83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | 91 |
92 | {{form.as_p}} 93 |
94 | 95 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /myapp/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for myapp project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.0/ref/settings/ 11 | """ 12 | import os 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'django-insecure-t5f+6j@+j$98e7v5c&&gs6(9te50ocya22_=9pl12ot74cz@@e' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'admin_honeypot', 41 | 'website', 42 | 'emp', 43 | 44 | ] 45 | 46 | MIDDLEWARE = [ 47 | 'django.middleware.security.SecurityMiddleware', 48 | 'django.contrib.sessions.middleware.SessionMiddleware', 49 | 'django.middleware.common.CommonMiddleware', 50 | 'django.middleware.csrf.CsrfViewMiddleware', 51 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 52 | 'django.contrib.messages.middleware.MessageMiddleware', 53 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 54 | ] 55 | 56 | ROOT_URLCONF = 'myapp.urls' 57 | 58 | TEMPLATES = [ 59 | { 60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 61 | 'DIRS': [os.path.join(BASE_DIR,"templates")], 62 | 'APP_DIRS': True, 63 | 'OPTIONS': { 64 | 'context_processors': [ 65 | 'django.template.context_processors.debug', 66 | 'django.template.context_processors.request', 67 | 'django.contrib.auth.context_processors.auth', 68 | 'django.contrib.messages.context_processors.messages', 69 | ], 70 | }, 71 | }, 72 | ] 73 | 74 | WSGI_APPLICATION = 'myapp.wsgi.application' 75 | 76 | 77 | # Database 78 | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases 79 | 80 | DATABASES = { 81 | 'default': { 82 | 'ENGINE': 'django.db.backends.sqlite3', 83 | 'NAME': BASE_DIR / 'db.sqlite3', 84 | } 85 | } 86 | 87 | 88 | # Password validation 89 | # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators 90 | 91 | AUTH_PASSWORD_VALIDATORS = [ 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 103 | }, 104 | ] 105 | 106 | 107 | # Internationalization 108 | # https://docs.djangoproject.com/en/4.0/topics/i18n/ 109 | 110 | LANGUAGE_CODE = 'en-us' 111 | 112 | TIME_ZONE = 'UTC' 113 | 114 | USE_I18N = True 115 | 116 | USE_TZ = True 117 | 118 | 119 | # Static files (CSS, JavaScript, Images) 120 | # https://docs.djangoproject.com/en/4.0/howto/static-files/ 121 | 122 | STATIC_URL = 'static/' 123 | MEDIA_URL="/media/" 124 | 125 | MEDIA_ROOT=os.path.join(BASE_DIR,'media') 126 | 127 | # Default primary key field type 128 | # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field 129 | 130 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 131 | -------------------------------------------------------------------------------- /templates/emp/update_emp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Update Employee 7 | 13 | 14 | 15 | {% include 'emp/navbar.html' %} 16 | 17 |

Update Employee

18 | 19 |
20 |
21 |
22 |
23 |
24 |
25 | {% csrf_token %} 26 |
27 | 28 | 36 |
37 | 38 |
39 | 40 | 48 |
49 | 50 |
51 | 52 | 60 |
61 |
62 | 63 | 69 |
70 |
71 | 72 | 73 |
74 |
75 | 76 | 81 |
82 |
83 | 86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | 94 | 99 | 100 | 101 | --------------------------------------------------------------------------------