Posts

Git use

 1) cd project foldername 2)   foldername git init - to initiate git 3)git status-to know status *git status -s (specify which files is modified ) M   shop/templates/shop/about.html - ye file staging area me modify hui he   M shop/templates/shop/contact.html- ye file working area me modify hui he * M M shop/templates/shop/about.html- ye file staging area me but working directory me chnage hui                                                                                         he M shop/templates/shop/contact.html- ye file working directory me chnage hui   he 4)git add pr.fo.name- to stage project 5)(in git bash terminal)touch file-to create new file in project folder 6)git add -A - :to a...

url.py

url ka tarika 1)html tage me full path dena hota he jo funtion run krvana he like  <form action="login"> 2)url path me-:path('login/',views.loginhandler,name="")  *isse search tab ka url pura esa bn jata he  *name is use for URL REVERSING *

search funtion not working

 def search(request):    allprod=[]    searched_str=request.GET.get('search','')  #string he,customer jo search krega vo yha aayega    n=len(product.objects.filter(Q(pname=searched_str) | Q(cat=searched_str))) #length of    fetched=product.objects.filter(Q(pname=searched_str) | Q(cat=searched_str) ).values()    for i in fetched[0].values():     allprod.append(i)    slide=n//4 + ceil((n/4)-(n//4))    allprod.append(slide)    print(allprod)    data={"allprod":allprod,"msg":""}    if n==0:        data['msg']="please searvh relevent product"        return render(request,"shop/search.html",data)    else:        return render(request,"shop/search.html",data) imp points Python 3.6.9 (default, Jul 17 2020, 12:50:27)  Type 'copyright', 'credits' or 'license' for more information IPython 7.16.1 -- An enha...

django imp points

 1)product.objects.get(pname=a) same as product.objects.filter(pname=a) but  data=product.objects.filter(pname=a).values() return krega ek queryset dictionery (with all values of  perticuler product). but get method .values() ke sath kaam nhi krega. data=product.objects.filter(pname=a).values() print( data) #print   <QuerySet [{'id': 2, 'pname': 'sabun', 'pdesc': 'kapde dolo', 'cat': 'house hold', 'subcat': 'tikiya', 'pr': 5, 'image': 'shop/images/download.jpeg'}]> 2) from django.db.models import Q sata=product.objects.filter(Q(pname=a) | Q( pdesc=b)).values() In [10]: sata Out[10]: <QuerySet [{'id': 2, 'pname': 'sabun', 'pdesc': 'kapde dolo', 'cat': 'house hold', 'subcat': 'tikiya', 'pr': 5, 'image': 'shop/images/download.jpeg'}]>

Django ORM ( from django.db import models

one to one relation class Customer(models.Model): name = models.CharField(max_length=255) class Vehicle(models.Model): name = models.CharField(max_length=255) customer = models.OneToOneField(Customer,on_delete=models.CASCADE,related_name='vehicle') one to many relation class Customer(models.Model): name = models.CharField(max_length=255) class Vehicle(models.Model): name = models.CharField(max_length=255) customer = models.ForeignKey(Customer,on_delete=models.CASCADE,related_name='Vehicle') from django.db import models #DataFlair #DjangoTutorials # Create your models here. class Customer(models.Model): name = models.CharField(max_length=255) class Vehicle(models.Model): name = models.CharField(max_length=255) customer = models.OneToOneField( Customer, on_delete=models.CASCADE, related_name='vehicle' ) from django.db import models #DataFlair #DjangoTutorials # Create your models here. class Cust...

TypeError at /admin/ 'str' object is not a mapping

url pattern me name="name" nhi dene ke karan aaya tha error 

adding paytm payment gateway

 views.py #paytm folder bna ke usme checksum.py file hogi isko import kra #ye vo funtion he jo order place krne pr form ka data lega or paytm.html pr pahucha dega from django.shortcuts import render import json from django.views.decorators.csrf import csrf_exempt #FOR PAYMENT SECURE from paytm import checksum MERCHANT_KEY = 'NcwqXL#gRfC0hZgW'   #global veriable merchant key paytm dega def place(request):  param_dict = {                 'MID':'pPRnOe00001423145082', #apni merchand id                 'ORDER_ID':str(id1),                    #oder ki id                 'TXN_AMOUNT':str(amount),                 'CUST_ID':'acfff@paytm.com',                 'INDUSTRY_TYPE_ID':'Retail',             ...