help me plz: getting error while importing csv file into database
Hi i am trying to import the csv file data into database my views.py def Filter(request): if request.method=="POST": form = DataForm(request.POST, request.FILES) if form.is_valid(): initial_obj = form.save(commit=False) data=initial_obj['data'] path="C:\\Users\\ramma\\Downloads\\assesment.csv" os.chdir(path) with open('assesment.csv') as csvfile: reader = csv.DictReader(csvfile) for row in reader: file=data(name=row['product'],) initial_obj.save() file.save() return redirect('/') else: return render(request,'index.html',{'form':form}) else: return render(request,'index.html',{'form':form}) def search(request): list = data.objects.all() data_filter = DataFilter(request.GET, queryset=list) return render(request, 'product.html', {'filter': data_filter}) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALJzFiqOMj5Lz2MZKvrPbB%3DXFfOrdBFeSBjd53tO7eVY9NDy5w%40mail.gmail.com.
Re: help me plz: getting error while importing csv file into database
while running this project getting this error File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 347, in _check_pattern_name if self.pattern.name is not None and ":" in self.pattern.name: TypeError: argument of type 'type' is not iterable thank you On Fri, Jun 18, 2021 at 10:52 PM ram manoj Vuyyuru < rammanojvuyy...@gmail.com> wrote: > Hi > i am trying to import the csv file data into database > my views.py > def Filter(request): > if request.method=="POST": > form = DataForm(request.POST, request.FILES) > if form.is_valid(): > initial_obj = form.save(commit=False) > data=initial_obj['data'] > path="C:\\Users\\ramma\\Downloads\\assesment.csv" > os.chdir(path) > > with open('assesment.csv') as csvfile: > reader = csv.DictReader(csvfile) > for row in reader: > file=data(name=row['product'],) > > initial_obj.save() > file.save() > return redirect('/') > else: > return render(request,'index.html',{'form':form}) > else: > return render(request,'index.html',{'form':form}) > > > def search(request): > list = data.objects.all() > data_filter = DataFilter(request.GET, queryset=list) > return render(request, 'product.html', {'filter': data_filter}) > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALJzFirRGsO2hZC%3DMm6YHJRMi4CJCc9DaSFBcuD5TDxecx%3D%3DLQ%40mail.gmail.com.
struck at gettiing each product urls from addidas website
HI help me for getting urls for each product import pandas as pd import requests from bs4 import BeautifulSoup as bs url = "https://www.adidas.com.my/en/men-shoes?start=0"; page = requests.get(url) soup = bs(page.text,"html.parser") links=[] listings = soup.find_all('div',{'class':'grid-item___3rAkS'}) for listing in listings: shoes_link= listing.find_all("a").a.get("href") base_url="https://www.adidas.com.my/en/men-shoes/"; cmplt_lnk=base_url+shoes_link links.append(cmplt_lnk) print(links) my code : when i run this i am not getting any result -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALJzFip9tmQTxygmWpqpc%3DqKHipNNf4HXhofGFXOPy3pp4bMCw%40mail.gmail.com.
Re: struck at gettiing each product urls from addidas website
Hi previous one prints nothing and this is another way but getting nothing import requests from bs4 import BeautifulSoup base_url="https://www.adidas.com.my/en/men-shoes/"; headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36' } for x in range(0,18): x=x*(12*4) r = requests.get(f'https://www.adidas.com.my/en/men-shoes?start={x}') soup = BeautifulSoup(r.content,'lxml') productlist = soup.find_all('div', class_='grid-item___3rAkS') productlinks=[] for item in productlist: for link in item.find_all('a',href=True): productlinks.append(base_url+ link['href']) print(productlinks) thanks On Tue, Jun 22, 2021 at 9:52 AM Lalit Suthar wrote: > print(links) outside for loop. Even then if nothing prints means your > `listings` is empty > > On Tue, 22 Jun 2021 at 08:51, ram manoj Vuyyuru > wrote: > >> HI >> help me for getting urls for each product >> import pandas as pd >> import requests >> from bs4 import BeautifulSoup as bs >> >> >> url = "https://www.adidas.com.my/en/men-shoes?start=0"; >> page = requests.get(url) >> soup = bs(page.text,"html.parser") >> >> links=[] >> listings = soup.find_all('div',{'class':'grid-item___3rAkS'}) >> for listing in listings: >> shoes_link= listing.find_all("a").a.get("href") >> base_url="https://www.adidas.com.my/en/men-shoes/"; >> cmplt_lnk=base_url+shoes_link >> links.append(cmplt_lnk) >> print(links) >> >> >> my code : >> when i run this i am not getting any result >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CALJzFip9tmQTxygmWpqpc%3DqKHipNNf4HXhofGFXOPy3pp4bMCw%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CALJzFip9tmQTxygmWpqpc%3DqKHipNNf4HXhofGFXOPy3pp4bMCw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAGp2JVH%2BioS8doxM77s8BPjZjkc-hh7YrXecVO4fztwgFSPjWw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAGp2JVH%2BioS8doxM77s8BPjZjkc-hh7YrXecVO4fztwgFSPjWw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALJzFioVAbjZyaacEyc%2BjhbdRa1V7GmFTdd8eBC%3Dp-oN0sWpfg%40mail.gmail.com.