Forwarded from Gridi Show
YouTube
Static Files In Django|django static files,django,static files,django project
django static files,django,static files,django static files tutorial,django static,static files django,static files in django,django static files not working,django tutorial,django sttatic files,django static files css not working,static files and images…
Forwarded from Gridi Show
YouTube
Model & Database In Django | how to create models in django
django models|how to create models in django ,django,django models,django model,django tutorial,models in django,python django,custom user model django,django custom user model,models django,django 2,django models advanced,django database,learn django,django…
Forwarded from Gridi Show
YouTube
Installation Of Oracle Database| Download and install oracle database and SQL developer in windows
django documentation tutorial,
how to create django project in python,
how to add satic files in django,
django project for resume,
how to add html template in django,
django latest version tutorial,
how to create django project in visual studio code,
django…
how to create django project in python,
how to add satic files in django,
django project for resume,
how to add html template in django,
django latest version tutorial,
how to create django project in visual studio code,
django…
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.6.4/css/buttons.dataTables.min.css">
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.4/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.4/js/buttons.flash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.4/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.4/js/buttons.print.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#example').DataTable(
{
dom: 'Blfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'Excel MK',
text:'Export to Excel'
},
{
extend: 'csvHtml5',
title: 'CSV MK',
text: 'Export to CSV'
},
{
extend: 'pdfHtml5',
title: 'PDF MK',
className: 'btn_pdf',
text: 'Export to PDF'
},
]
} );
} );
</script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.6.4/css/buttons.dataTables.min.css">
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.4/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.4/js/buttons.flash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.4/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.4/js/buttons.print.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#example').DataTable(
{
dom: 'Blfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'Excel MK',
text:'Export to Excel'
},
{
extend: 'csvHtml5',
title: 'CSV MK',
text: 'Export to CSV'
},
{
extend: 'pdfHtml5',
title: 'PDF MK',
className: 'btn_pdf',
text: 'Export to PDF'
},
]
} );
} );
</script>
Email Verification In Django project| email Verification during sign-up or registration of new users
for source code:
https://t.me/pythonmoms
settings.py
#EMAIL
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_POST = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER ='your email id '
EMAIL_HOST_PASSWORD ='enter your password'
-------------------------------------------------------------------------------
views.py
from django.contrib.sites.shortcuts import get_current_site
from django.utils.encoding import force_bytes
from django.utils.encoding import force_str
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from django.template.loader import render_to_string
from .tokens import account_activation_token
from django.contrib.auth.models import User
from django.core.mail import EmailMessage
from django.contrib.auth import get_user_model
from django.http import HttpResponse
def activate(request, uidb64, token):
User = get_user_model()
try:
uid = force_str(urlsafe_base64_decode(uidb64))
user = User.objects.get(pk=uid)
except(TypeError, ValueError, OverflowError, User.DoesNotExist):
user = None
if user is not None and account_activation_token.check_token(user, token):
user.is_active = True
user.save()
return HttpResponse('Thank you for your email confirmation. Now you can login your account.')
else:
return HttpResponse('Activation link is invalid!')
# REGISTER FUNCTION
def Register_user(request):
form=SignUpForm()
if request.method=='POST':
form=SignUpForm(request.POST)
if form.is_valid():
user = form.save(commit=False)
user.is_active = False
user.save()
current_site = get_current_site(request)
mail_subject = 'Activation link has been sent to your email id'
message = render_to_string('acc_active_email.html', {
'user': user,
'domain': current_site.domain,
'uid':urlsafe_base64_encode(force_bytes(user.pk)),
'token':account_activation_token.make_token(user),
})
to_email = form.cleaned_data.get('email')
email = EmailMessage(
mail_subject, message, to=[to_email]
)
email.send()
messages.success(request,"Please confirm your email address to complete the registration")
return redirect('home')
else:
form = SignUpForm()
return render(request, 'register.html', {'form': form})
return render(request, 'register.html')
urls.py
path('activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/',views.activate, name='activate'),
for source code:
https://t.me/pythonmoms
settings.py
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_POST = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER ='your email id '
EMAIL_HOST_PASSWORD ='enter your password'
-------------------------------------------------------------------------------
views.py
from django.contrib.sites.shortcuts import get_current_site
from django.utils.encoding import force_bytes
from django.utils.encoding import force_str
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from django.template.loader import render_to_string
from .tokens import account_activation_token
from django.contrib.auth.models import User
from django.core.mail import EmailMessage
from django.contrib.auth import get_user_model
from django.http import HttpResponse
def activate(request, uidb64, token):
User = get_user_model()
try:
uid = force_str(urlsafe_base64_decode(uidb64))
user = User.objects.get(pk=uid)
except(TypeError, ValueError, OverflowError, User.DoesNotExist):
user = None
if user is not None and account_activation_token.check_token(user, token):
user.is_active = True
user.save()
return HttpResponse('Thank you for your email confirmation. Now you can login your account.')
else:
return HttpResponse('Activation link is invalid!')
# REGISTER FUNCTION
def Register_user(request):
form=SignUpForm()
if request.method=='POST':
form=SignUpForm(request.POST)
if form.is_valid():
user = form.save(commit=False)
user.is_active = False
user.save()
current_site = get_current_site(request)
mail_subject = 'Activation link has been sent to your email id'
message = render_to_string('acc_active_email.html', {
'user': user,
'domain': current_site.domain,
'uid':urlsafe_base64_encode(force_bytes(user.pk)),
'token':account_activation_token.make_token(user),
})
to_email = form.cleaned_data.get('email')
email = EmailMessage(
mail_subject, message, to=[to_email]
)
email.send()
messages.success(request,"Please confirm your email address to complete the registration")
return redirect('home')
else:
form = SignUpForm()
return render(request, 'register.html', {'form': form})
return render(request, 'register.html')
urls.py
path('activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/',views.activate, name='activate'),
❤3👍1