my code is not giving an error but it is not performing edit action. and it uploads pdf but not shown in the html page.
*****************View.py****************
def Upload_Charter(request):
Category_List= Category.objects.all().order_by("Category_name")# for viewing all catogories
if request.method == 'POST':
Remove_Category_List = request.POST.getlist('Category_Uuid_delete')
if Remove_Category_List:
Category.objects.filter(uuid=Remove_Category_List).delete()# removing the category
messages.add_message(request, messages.INFO, _("Category Delete Operation Successfully Completed"))
else:
pass
action = request.POST.get('action')
Category_Names = request.POST.getlist('Category')
Category_Uuids = request.POST.getlist('Category_Uuid')
for index, Category_Name in enumerate(Category_Names):
if Category_Name=='':
continue
elif not Category_Name in Remove_Category_List:
if action=='save':
if not Category.objects.filter(Category_name=Category_Name).exists():
Category(Category_name=Category_Name).save() # createing a new category
elif action=='update':
Category.objects.filter(uuid=Category_Uuids[index]).update(Category_name=Category_Name)#UPDATE
return redirect(reverse('Upload-Charters'))
return render(request, 'Upload-Charters.html',{'Category_List': Category_List})
@login_required
def Upload_Charter_file(request):
if request.method == 'POST' and request.FILES.get('charters_files'):
charters_files = request.FILES.get('charters_files')
fs = FileSystemStorage()
filename = fs.save(charters_files.name,charters_files)
uploaded_file_url = fs.get_available_name(filename)
return render(request, 'Upload-Charters.html', {
'uploaded_file_url': uploaded_file_url, 'Category_List': Category_List})
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAP%2B6t008%2BmVpp%3D_iyOzB%3DLcHqrNFtsame5B6dLkS62uzt8f9XA%40mail.gmail.com.
No comments:
Post a Comment