· 5 years ago · Aug 06, 2020, 05:12 PM
1main.urls.py
2
3from django.contrib import admin
4from django.urls import path, include
5
6urlpatterns = [
7 path('admin/', admin.site.urls),
8 path("", include('register.urls'), namespace='register'),
9 # path("register/",include('register.urls'))
10]
11
12register/urls.py
13
14from django.contrib import admin
15from django.urls import path
16
17from register import views
18
19
20urlpatterns = [
21 path('admin/', admin.site.urls),
22 path("", views.home),
23 path("register/", views.register1),
24 # path("output",views.output, name="register"),
25
26]
27
28register/view.py
29
30from django.shortcuts import render, HttpResponse
31from django.http import HttpResponseRedirect
32
33
34def register1(request):
35 if request.method == "POST":
36 username = request.POST['user1']
37 password = request.POST['password']
38 con_pass = request.POST['con-password']
39 email = request.POST['email']
40 phone = request.POST['phone']
41 if password == con_pass:
42 return render(request,'output.html',context={'user': username,'password':password
43 ,'confirm_password':con_pass,'email':email
44 ,'phone':phone})
45 else:
46 print("NO same password")
47 return render(request,'register.html')
48
49
50
51def home(request):
52 return HttpResponse("This is home page")
53
54
55setting.py
56
57"""
58Django settings for travell project.
59
60Generated by 'django-admin startproject' using Django 3.0.8.
61
62For more information on this file, see
63https://docs.djangoproject.com/en/3.0/topics/settings/
64
65For the full list of settings and their values, see
66https://docs.djangoproject.com/en/3.0/ref/settings/
67"""
68
69import os
70
71# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
72BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
73
74
75# Quick-start development settings - unsuitable for production
76# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
77
78# SECURITY WARNING: keep the secret key used in production secret!
79SECRET_KEY = '#66hut2e_t!#y)5%am0+$d&nt-$zu7uwex)t=1v8ivo2_ikmdf'
80
81# SECURITY WARNING: don't run with debug turned on in production!
82DEBUG = True
83
84ALLOWED_HOSTS = []
85
86
87# Application definition
88
89INSTALLED_APPS = [
90 'register',
91 'database.apps.DatabaseConfig',
92 'django.contrib.admin',
93 'django.contrib.auth',
94 'django.contrib.contenttypes',
95 'django.contrib.sessions',
96 'django.contrib.messages',
97 'django.contrib.staticfiles',
98]
99
100MIDDLEWARE = [
101 'django.middleware.security.SecurityMiddleware',
102 'django.contrib.sessions.middleware.SessionMiddleware',
103 'django.middleware.common.CommonMiddleware',
104 'django.middleware.csrf.CsrfViewMiddleware',
105 'django.contrib.auth.middleware.AuthenticationMiddleware',
106 'django.contrib.messages.middleware.MessageMiddleware',
107 'django.middleware.clickjacking.XFrameOptionsMiddleware',
108]
109
110ROOT_URLCONF = 'travell.urls'
111
112TEMPLATES = [
113 {
114 'BACKEND': 'django.template.backends.django.DjangoTemplates',
115 'DIRS': [os.path.join(BASE_DIR, "templates")],
116 'APP_DIRS': True,
117 'OPTIONS': {
118 'context_processors': [
119 'django.template.context_processors.debug',
120 'django.template.context_processors.request',
121 'django.contrib.auth.context_processors.auth',
122 'django.contrib.messages.context_processors.messages',
123 ],
124 },
125 },
126]
127
128WSGI_APPLICATION = 'travell.wsgi.application'
129
130
131# Database
132# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
133
134DATABASES = {
135 'default': {
136 'ENGINE': 'django.db.backends.postgresql',
137 'NAME': 'db1',
138 'USER': 'postgres',
139 'PASSWORD': 'admin',
140 'HOST': 'localhost'
141 }
142}
143
144
145# Password validation
146# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
147
148AUTH_PASSWORD_VALIDATORS = [
149 {
150 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
151 },
152 {
153 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
154 },
155 {
156 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
157 },
158 {
159 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
160 },
161]
162
163
164# Internationalization
165# https://docs.djangoproject.com/en/3.0/topics/i18n/
166
167LANGUAGE_CODE = 'en-us'
168
169TIME_ZONE = 'UTC'
170
171USE_I18N = True
172
173USE_L10N = True
174
175USE_TZ = True
176
177
178# Static files (CSS, JavaScript, Images)
179# https://docs.djangoproject.com/en/3.0/howto/static-files/
180
181STATIC_URL = '/static/'
182
183
184
185register/app.py
186
187from django.apps import AppConfig
188
189
190class RegisterConfig(AppConfig):
191 name = 'register'
192
193
194database/models.py
195
196from django.db import models
197
198# Create your models here.
199class employee(models.Model):
200 name = models.CharField(max_length=20)
201 password = models.CharField(max_length=20)
202 con_password = models.CharField(max_length=20)
203 email = models.CharField(max_length=20)
204 phone = models.IntegerField()
205
206
207
208database/app.py
209from django.apps import AppConfig
210
211
212class DatabaseConfig(AppConfig):
213 name = 'database'
214