Previous, you can use:
howmany = mytable.count()

Also you can use xlrd library, for instance:
import xlrd

#open excel file
documento = xlrd.open_workbook("ejemplo.xls")

#We can save each one of the spreadsheet separately
libros = documento.sheet_by_index(0)
peliculas = documento.sheet_by_index(1)

On the other hand, the model has not contains records, it's only an
structure definition of a table


Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos




El vie, 22 ene 2021 a las 12:58, Shailesh Yadav (<
shaileshyadav7...@gmail.com>) escribió:

> Hi I'm having one Django web app where My *model A *contains 1000 records
> and I want to set a daily update limit for example if users are updating
> that data by uploading a .xls file then it should count how many records
> updated and once it is more than 500 then the user should get an Error
> message.
>
> Can Anyone help me how to implement this (Is there a SQLite parameter
> where so that I can define value in settings.py)
>
> below is my upload code. (Here I have tried to store the count value and
> comparing it with half of the record but again how to reset it after 12
> hrs?)
>
>
> def CTA_upload(request):
> try:
> if request.method == 'POST':
> movie_resource = CTAResource()
> ##we will get data in movie_resources####
> dataset = Dataset()
> new_movie = request.FILES['file']
> if not new_movie.name.endswith('xls'):
> messages.info(request, 'Sorry Wrong File Format.Please Upload valid
> format')
> return render(request, 'apple/uploadinfosys.html')
> messages.info(request, 'Uploading Data Line by Line...')
> imported_data = dataset.load(new_movie.read(), format='xls')
> count = 1
> for data in imported_data:
> value = CTA(
> data[0],
> data[1],
> data[2],
> data[3],
> data[4],
> data[5],
> data[6],
> data[7],
> data[8],
> )
> count = count + 1
> value.save()
> # messages.info(request, count)
> # time.sleep(1)
> messages.info(request, 'File Uploaded Successfully...')
>
> except:
> messages.info(request,
> 'Same Email ID has been observed more than once.Except that other records
> has been added../nPlease Make sure Email field should be unique.')
>
> return render(request, 'apple/cta.html')
>
> --
> 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/95a6c5e9-ad98-4036-bcbb-109562a7df06n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/95a6c5e9-ad98-4036-bcbb-109562a7df06n%40googlegroups.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/CAKVvSDAh8Bs383m3mLNNc13GGQU6hoOyeV4OypgPf2aZsaM_eQ%40mail.gmail.com.

Reply via email to