Posts

Showing posts from August, 2021

Social Login For Facebook Twitter GitHub(social-auth-app-django)

Image
Django Social Login For Facebook Twitter GitHub--https://studygyaan.com/django/how-to-add-social-login-to-django   pip install social-auth-app-django settings.py INSTALLED_APPS   =  [           'social_django' , ] python manage.py migrate MIDDLEWARE   =  [      'social_django.middleware.SocialAuthExceptionMiddleware' , ] TEMPLATES   =  [     {          'BACKEND' :  'django.template.backends.django.DjangoTemplates' ,          'DIRS' : [],          'APP_DIRS' :  True ,          'OPTIONS' : {              'context_processors' : [                   ...

Django-allauth! (Google)

Image
 Official Documentation-----> https://django-allauth.readthedocs.io/en/latest/installation.html Python package: pip install django - allauth settings.py INSTALLED_APPS   =  [      'django.contrib.sites', ] TEMPLATES   =  [     {          'BACKEND' :  'django.template.backends.django.DjangoTemplates' ,          'DIRS' : [],          'APP_DIRS' :  True ,          'OPTIONS' : {              'context_processors' : [                  'django.template.context_processors.debug' ,                  'django.template.context_p...

MySQL

Image
pip install mysqlclient   settings.py DATABASES   =  {      'default' : {          'ENGINE' :  'django.db.backends.mysql' ,          'NAME' :  'pus' ,          'USER' :  'root' ,          'PASSWORD' :  'root' ,          'HOST' :  'localhost' ,          'PORT' :  '3306' ,     } } python manage.py runserver python manage.py makemigrations python manage.py migrate  MySQL Shell \sql \connect root@localhost:3306   Show All Database table: show databases;   Create database: create database [databasename];   Used database: use [db name];   Show Table: show tables;   Show Particular table data:...

Navbar Hide and Show

< ul   class = "navbar-nav me-auto mb-2 mb-lg-0" >             {% if request.user.is_authenticated %}             < li   class = "nav-item dropdown mx-2" >               < a   class = "nav-link dropdown-toggle text-white"   href = "#"   id = "profileDropdown"   role = "button"                  data-bs-toggle = "dropdown"   aria-expanded = "false" >                 {{request.user.username|capfirst}}               </ a >         ...

Message Framework

Image
from  django.contrib  import  messages messages.debug(request,  'SQL statements were executed.' ) messages.info(request,  'Three credits remain in your account.' ) messages.success(request,  'Profile details updated.' ) messages.warning(request,  'Your account expires in three days.' ) messages.error(request,  'Document deleted.' ) settings.py INSTALLED_APPS   =  [      'django.contrib.messages', ] @login_required () def   add_to_cart ( request ):   user  =  request.user   item_already_in_cart1  =   False   product  =  request. GET .get( 'prod_id' )    print ( "---------------------------------------" )    print (product)   item_already_in_cart1  =  Cart.objects.filter(Q( product = product)  &  Q( user = request.user)).exi...