NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

# urls.py
from django.urls import path
from . import views
from django.contrib.auth import views as auth_views

urlpatterns = [
path('', views.index, name='home'),
path('login/', views.user_loginn, name='login'),
path('signup/', views.user_signup, name='signup'),
path('logout/', views.user_logout, name='logout'),





# reset password urls

path('password_reset/', auth_views.PasswordResetView.as_view(template_name='password_reset_form.html'), name='password_reset'),
path('password_reset_done/', auth_views.PasswordResetDoneView.as_view(template_name='password_reset_done.html'), name='password_reset_done'),
path('password_reset_confirm/uidb64/token/',auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html'), name='password_reset_confirm'),
path('password_reset_complete/', auth_views.PasswordResetCompleteView.as_view(template_name='password_reset_complete.html'), name='password_reset_complete'),


]


# views
from django.shortcuts import render,redirect
from django.http import HttpResponse
from django.contrib.auth import authenticate,login,logout
from .forms import userForm,user_login
from .models import *
from django.core.mail import send_mail
from Ecommerce.settings import EMAIL_HOST_USER
from django.contrib.auth.hashers import make_password








#Website Index/Website Page View
def index(request):
return render(request,'index.html')



#Signup View
def user_signup(request):
if request.method == 'POST':
form = userForm(request.POST)
if form.is_valid():
# username = form.cleaned_data.get('username')
first_name = form.cleaned_data.get('first_name')
last_name = form.cleaned_data.get('last_name')
email = form.cleaned_data.get('email')
contactno = form.cleaned_data.get('contactno')
password=make_password(form.cleaned_data['password'])
data= signup( first_name=first_name, last_name=last_name, email=email, contactno=contactno, password=password,)
data.save()
send_mail("User Data: ", f"Your account has been created ",EMAIL_HOST_USER,['[email protected]','[email protected]'], fail_silently=True)
return redirect('login')
else:
form=userForm()
return render(request, 'signup.html', {'form': form})



#Login View
def user_loginn(request):
if request.method == 'POST':
form = user_login(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
# username = form.cleaned_data['username']
password = form.cleaned_data['password']
user = authenticate(email = email, password = password)
if user is not None:
login(request, user)
return render(request,'myshop.html')

else:
form = user_login()
return render(request, 'login.html', {'user_login': form})




#Logout View
def user_logout(request):
logout(request)
return redirect('login')




#models.
from django.contrib.auth.models import AbstractUser,BaseUserManager
from django.db import models



# this is our manager.py
class CustomUserManager(BaseUserManager):
def create_user(self,email,password=None, **extra_fields):
if not email:
raise ValueError('The Email field must be set')
email=self.normalize_email(email)
user=self.model(email=email, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user

def create_superuser(self,email,password=None, **extra_fields):
extra_fields.setdefault('is_active',True)
extra_fields.setdefault('is_staff',True)
extra_fields.setdefault('is_superuser',True)


if(extra_fields.get('is_staff') is not True):
raise ValueError('super user have is_staff true')
return self.create_user(email,password, **extra_fields)


# Create your additional models here.



#Signup Models(CustomUser)
class signup(AbstractUser):

contactno =models.BigIntegerField(blank=True,null=True)

objects=CustomUserManager()


USERNAME_FIELDS='email'
REQUERED_FIELDS=[]

def __str__(self) :
return self.email







#urls.py ecommerce
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('Myshop.urls')),
]

#forms
from django import forms
from .models import *




#signup form
class userForm(forms.ModelForm):
class Meta:
model=signup
fields=['first_name','last_name','email','contactno','password']
widgets={
'password': forms.PasswordInput(),
}


#login form
class user_login(forms.Form):
email=forms.EmailField()
# username = forms.CharField()
password=forms.CharField(widget=forms.PasswordInput)





     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.