Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why I'm getting "Request failed with status code 404"
views.py class SearchTodo(viewsets.ModelViewSet): serializer_class = todoserializer def get_queryset(self): status = self.kwargs["status"] return JsonResponse({"data":Todo.objects.filter(status=status)}, content_type='application/json') urls.py for rest framework router = routers.DefaultRouter() router.register(r"^todo/(?P<status>\w+)$",views.SearchTodo,"SearchTodo") router.register(r"todo",views.todoview,"todor") urlpatterns = [ path('admin/', admin.site.urls), path("api/",include(router.urls)) ] Axios code for filter object which has the status True const data = () => { axios .get(`http://127.0.0.1:8000/api/todo/True`) .then((res) => settasks(res.data)) .catch((error) => alert(error.message)); }; but whenever this function run I got a 404 bad request error where I'm getting wrong. -
Test password protected page django
I want to write test cases about password-protected pages. I have /management/edit page. it is loginrequired page. My test case currently likes below, but it is failed. I am expecting to get 200 but instead of I got redirection(302) Tests.py from django.test import TestCase, Client # Admin panel Test cases class PageTest(TestCase): # it will redirect user to loginpage def test_admin_page(self): response = self.client.get("/management/") self.assertEquals(response.status_code, 302) def test_edit(self): c = Client() c.login(username='admin', password='admin') response = c.get("/management/edit/") self.assertEquals(response.status_code,200) -
Markup Deprecated issue finding compatible textile
I'm updating Django project to the latest version, since django markup is deprecated I'm using it's replacement django-markup-deprecated It's throwing an error of missing textile for python File "/home/sam/code/envs/kpsga/lib/python3.8/site-packages/markup_deprecated/templatetags/markup.py", line 27, in textile raise template.TemplateSyntaxError("Error in 'textile' filter: The Python textile library isn't installed.") django.template.exceptions.TemplateSyntaxError: Error in 'textile' filter: The Python textile library isn't installed. [28/Oct/2020 14:15:29] "GET / HTTP/1.1" 500 166483 so I tried to install it this way pip install textile which doesn't work and throws a different incompatibility issue File "/home/sam/code/envs/kpsga/lib/python3.8/site-packages/markup_deprecated/templatetags/markup.py", line 30, in textile return mark_safe(force_text(textile.textile(force_bytes(value), encoding='utf-8', output='utf-8'))) TypeError: textile() got an unexpected keyword argument 'encoding' [28/Oct/2020 14:18:31] "GET / HTTP/1.1" 500 160593 -
OSError: Cannot load native module 'Crypto.Cipher._raw_ecb' on Apache mod_wsgi CentOS 8
I'm trying to run a django project on an apache server. The django server runs fine on its own but fails when running through mod_wsgi. It returns the error as follow : OSError: Cannot load native module 'Crypto.Cipher._raw_ecb': Trying '_raw_ecb.cpython-39-x86_64-linux-gnu.so': /home/user/django/centos_env/lib/python3.9/site-packages/Cryptodome/Util/../Cipher/_raw_ecb.cpython-39-x86_64-linux-gnu.so: failed to map segment from shared object, Trying '_raw_ecb.abi3.so': /home/user/django/centos_env/lib/python3.9/site-packages/Cryptodome/Util/../Cipher/_raw_ecb.abi3.so: cannot open shared object file: No such file or directory, Trying '_raw_ecb.so': /home/user/django/centos_env/lib/python3.9/site-packages/Cryptodome/Util/../Cipher/_raw_ecb.so: cannot open shared object file: No such file or directory I checked that the file were there. I checked Python home variable and tried to import Crypto.Cipher from the python interpreter(which worked). Everything seems fine. I tried to compile pycryptodome from source but it didn't help either. -
How to override Django get_search_results method in ModelAdmin, while keeping filters working as expected?
I have a Model admin where I override get_search_result this way def get_search_results(self, request, queryset, search_term): queryset, use_distinct = super(OccupancyAdmin, self).get_search_results( request, queryset, search_term ) search_words = search_term.split(",") if search_words: q_objects = [ Q(**{field + "__icontains": word}) for field in self.search_fields for word in search_words ] queryset |= self.model.objects.filter(reduce(or_, q_objects)) return queryset, use_distinct The suggestion comes from here: Is there a way to search for multiple terms in admin search? django The problem I am facing is the following: neither the DateTimeRangeFilter from rangefilter nor my custom SimpleListFilter work as expected anymore. The filters seem like being disabled. I looked at the SQL queries being performed and they seem alright. I am pretty sure I am messing up with the querysets somehow but don't know how to debug this. -
Django: Avoid duplicates image uploads from admin panel
I have a model with an ImageField, which allow an image upload from the panel admin of Django. I would like to check if the image already exists, before saving the model. If it's the case, I would like to display a popup (or a warning on the same page) with both images, to allow users to compare images, and allow saving if it's a false positive. For the image comparison, I'm going to use imagehash.average_hash() algorithm which gave me good results from my tests. So my questions are: How to get the file content (to compute the aHash), before the model save. How to display a popup or modify the modelAdmin page to allow the check of false positive. Any help is appreciated! -
How to count the value of dictionary using queryset in django
I used .value('post_id') in django to bring the following values. <QuerySet [{'post_id': 3}, {'post_id': 2}, {'post_id': 1}, {'post_id': 3}]> If you count the value of each dictionary, you will have one, one, and two, respectively. Which queryset should I look for, instead of counting it as a queryset without for loop ? -
Django - very slow annotation when annotation more than 1 field
I'm building a chat functionality for my django app. I made Message model, which looks like this: class Message(models.Model): sender = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='messages_sent', blank=True, null=True) receiver = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='messages_received', null=True) message = models.TextField(blank=True) created_at = models.DateTimeField(auto_now_add=True, db_index=True) Now I want to create a view with a list of users, ordered by the last message date with currently logged in user. def get_queryset(self): qs = UserModel.objects.all() user = self.request.user # exclude self qs = qs.exclude(pk=user.pk) qs = qs.annotate(last_sent_date=Max("messages_received__created_at", filter=Q(messages_received__sender=user))) qs = qs.annotate(last_received_date=Max("messages_sent__created_at", filter=Q(messages_sent__receiver=user))) qs = qs.annotate(last_message_date=Greatest('last_sent_date', 'last_received_date')) qs = qs.annotate(has_messages=Case( When(Q(last_received_date__isnull=False) | Q(last_sent_date__isnull=False), then=True), default=False, output_field=BooleanField() )) return qs.order_by(F('last_message_date').desc(nulls_last=True)) This was working very well, until I created many Message objects for 2 test users, each of them had 8k sent and 8k received messages (16k total). This slowed down the query significantly, and now it takes even 40-50 seconds (for small amounts it was below 500ms). After some investigation I discovered that the main problem is in those lines: qs = qs.annotate(last_sent_date=Max("messages_received__created_at", filter=Q(messages_received__sender=user))) qs = qs.annotate(last_received_date=Max("messages_sent__created_at", filter=Q(messages_sent__receiver=user))) Separately, they are very fast, but combined they are creating a very slow query. Is there some better way to annotate Max value from 2 fields or a way to annotate this … -
i want to get all categories filter as dropdown and want to show results
I am building an admin panel where i want to add filter system. For that I installed django-filters in system.py file and run the command to install it after that I did these below filter.py file: import django_filters from .models import * class ProductFilter(django_filters.FilterSet): class Meta: model = ProductModel fields = ['product_category'] views.py file: def createproduct(request): if request.method == 'POST': createProd = ProductForm(request.POST, request.FILES, request.GET) if createProd.is_valid(): # p_id = createProd.cleaned_data['product_id'] p_name = createProd.cleaned_data['product_name'] p_sku = createProd.cleaned_data['product_sku'] p_tags = createProd.cleaned_data['product_tags'] p_category = createProd.cleaned_data['product_category'] p_image = createProd.cleaned_data['product_image'] p_brand = createProd.cleaned_data['product_brand'] p_desc = createProd.cleaned_data['product_desc'] p_price = createProd.cleaned_data['product_price'] insert_products = ProductModel(product_name=p_name, product_sku=p_sku, product_tags=p_tags, product_category=p_category, product_image=p_image, product_brand=p_brand, product_desc=p_desc, product_price=p_price) insert_products.save() create = ProductForm() else: createProd = ProductForm() all_products = ProductModel.objects.all() product_filter = ProductFilter( request.GET, queryset=all_products) all_products = product_filter.qs return render(request, 'create.html', {'create': createProd, 'all_prods': all_products, 'product_filter': product_filter}) I wrote this code for filtering functionality : all_products = ProductModel.objects.all() product_filter = ProductFilter( request.GET, queryset=all_products) all_products = product_filter.qs return render(request, 'create.html', {'create': createProd, 'all_prods': all_products, 'product_filter': product_filter}) This is my models.py class ProductModel(models.Model): product_id = models.AutoField(primary_key=True) product_name = models.CharField(max_length=100) product_sku = models.CharField(max_length=200) product_tags = models.CharField(max_length=100) product_category = models.CharField( max_length=1000, default="Uncategorized") product_image = models.ImageField(upload_to='images/') product_brand = models.CharField(max_length=100) product_desc = models.TextField(max_length=255) product_price = models.CharField(max_length=100) So,after writing these codes … -
Django not accepting from that JavsScript has inserted a value into
I have a Django form uses FormBuilder.js. The intent is to use the JSON recieved from FormBuilder and have that JSON inserted into the JSON [Django] field using vanilla JavsScript (by directly setting it's .value). Django does not validate the form when using this method. However, if I hard type the JSON, or when the form fails and I return back to the page immediately, the form will validate. I have looked into the form itself on POST and the data is no different via any methods. Does anyone have a clue what's going on? -
How to create a Dynamic upload path Django
I have a Django rest api that converts user uploaded video to frame using Opencv. I also have a function upload_to that creates a dynamic path for the uploaded video. I want to write the frames from the video into the upload_to folder. I tried cv2.imwrite(os.path.join(upload_to,'new_image'+str(i)+'.jpg'),frame) but it yield an error. def upload_to(instance, filename): now = timezone.now() base, extension = os.path.splitext(filename.lower()) return f"SmatCrow/{instance.name}/{now:%Y-%m-%d}{extension}" Opencv script def video_to_frame(video): now = timezone.now() cap= cv2.VideoCapture(video) i=1 while(cap.isOpened()): ret, frame = cap.read() if ret == False: break if i%10 == 0: cv2.imwrite(('media/SmatCrow/new_image'+str(i)+'.jpg'),frame) i+=1 cap.release() cv2.destroyAllWindows() My model.py class MyVideo(models.Model): name= models.CharField(max_length=500) date = models.DateTimeField(auto_now_add=True) videofile= models.FileField(upload_to=upload_to) def __str__(self): return self.name + ": " + str(self.videofile) def save(self, *args, **kwargs): super(MyVideo, self).save(*args, **kwargs) tfile = tempfile.NamedTemporaryFile(delete=False) tfile.write(self.videofile.read()) vid = video_to_frame((tfile.name)) -
How to encrypt DjangoRESTFramework SimpleJWT's?
is there a way to encrypt the tokens the simple JWT backend for DRF creates? I want to store them as cookies, so want them to be obscured. Additionally, is it appropriate to name the cookies "refresh" and "access" in the browser? -
django form resubmitted upon refresh when using context_processors
I'm trying on creating a user registration form and able to succeed with the registration process and validation. The form is handled using context_processor because the form is on the base.html and in inside a modal. Upon submission, I need to redirect to the current page the user is in and it works. But my form keeps re-submitting upon refresh. context_processor.py def include_registration_form(request): form = CreateUserForm() if request.method == 'POST': form = CreateUserForm(request.POST) if form.is_valid(): form.save() user = form.cleaned_data.get('username') messages.success(request, 'Account was created for {}. Now you can sign in.'.format(user)) else: messages.error(request, "Something went wrong. Account not created!") context = { 'registration_form': form, } return context forms.py class CreateUserForm(UserCreationForm): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True) email = forms.EmailField(required=True) class Meta: model = User fields = ['username', 'first_name', 'last_name', 'email', 'password1', 'password2'] url patterns urlpatterns = [ path('admin/', admin.site.urls), path('', views.home, name='index'), path('menu', views.menu, name='menu'), path('promo', views.promo, name='promo'), ] template(base.html) <form class="needs-validation" action="" method="post" novalidate> {% csrf_token %} {% for field in registration_form %} <div class="col-sm"> <label>{{ field.label }}</label> {% if registration_form.is_bound %} {% if field.errors %} {% render_field field class="form-control form-control-sm is-invalid" %} {% if field.name == 'username' or 'password1' %} <small> {{ field.help_text }} </small> {% endif %} <div … -
why django-mptt do not render children correctly
I'm developing a web app in Python3.7 with django (3.1.2). I would like to create app which will lists folders and files under some path. I would like to use django.mptt to do it. I have path declared in my settings.py: MAIN_DIRECTORY = r'D:\imgs' I created following model: class Folder(MPTTModel): name = models.CharField(max_length=30, unique=True) parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children') class MPTTMeta: order_insertion_by = ['name'] and view: class MainView(TemplateView): template_name = "main.html" def get_directories(self): path = settings.MAIN_DIRECTORY self.tree = self.get_folder_from_db(path, None) for root, dirs, files in os.walk(path): if root == path: continue root_folder = self.get_folder_from_db(name=root, parent=self.tree) for d in dirs: if os.path.isdir(d): tmp = self.get_folder_from_db(name=d, parent=root_folder) def get_folder_from_db(self, name, parent): try: obj = Folder.objects.get(name=name, parent=parent) except Folder.DoesNotExist: obj = Folder(name=name, parent=parent) obj.save() return obj def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) self.get_directories() context['tree'] = [self.tree] return context and of course I have template (copied from mptt tutorial): {% extends 'base.html' %} {% load mptt_tags %} {% block content %} <h2>Main page</h2> <ul class="root"> {% recursetree tree%} <li> {{ node.name }} {% if not node.is_leaf_node %} <ul class="children"> {{ children }} </ul> {% endif %} </li> {% endrecursetree %} </ul> {% endblock %} I know that te tree structure is correct, … -
NOT ABLE TO RETURN TABLE IN DJANGO TEMPLATES USING PYTHON
I wrote a code in python to get stock data and return it inside html page in Django. I want to view it in table format in html page, Plz suggest how to call my python code in html webpage so that it will show output in html -
How can i filter a models property in django?
im quite new in backend development so i got a basic question. I've three different models one named Campaigns; class Campaigns(models.Model): channel = models.ForeignKey(Channels, blank=False, verbose_name="Channel Name", on_delete=models.CASCADE) campaign_name = models.CharField(max_length=255, blank=False, verbose_name="Campaign Name") Second one is; class CampaignDetails(models.Model): channel = models.ForeignKey(Channels, blank=False, null=True, verbose_name="Channel Name", on_delete=models.CASCADE) name = models.ForeignKey(Campaigns, blank=False, null=True, verbose_name="Campaign", on_delete=models.CASCADE) And the last one is; Class Channels(models.Model): name = models.CharField(max_length=50, null=False, blank=False, verbose_name="Tv Channel") I want to filter name in CampaignDetails by channel. Like if i choose channel 1 i want to filter name by campaign names that under that channel. How can i manage that? Any help is appreciated, thank you. -
my mysqlclient is not installing and it throws this error...someone help. am new to code btw
Collecting mysqlclient Using cached mysqlclient-2.0.1.tar.gz (87 kB) ERROR: Command errored out with exit status 1: command: /home/moonguy/Documents/smartbill/virtual/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lp9dtwz6/mysqlclient/setup.py'"'"'; file='"'"'/tmp/pip-install-lp9dtwz6/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-m1qj8ead cwd: /tmp/pip-install-lp9dtwz6/mysqlclient/ Complete output (12 lines): /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-lp9dtwz6/mysqlclient/setup.py", line 15, in metadata, options = get_config() File "/tmp/pip-install-lp9dtwz6/mysqlclient/setup_posix.py", line 65, in get_config libs = mysql_config("libs") File "/tmp/pip-install-lp9dtwz6/mysqlclient/setup_posix.py", line 31, in mysql_config raise OSError("{} not found".format(_mysql_config_path)) OSError: mysql_config not found ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. -
How to override serializers save method in django rest?
Here I have only one view for saving two serializer models. Now While saving the RegisterSerializer UserLogin serializer is also saving. But now what I want to change is, I want to change the status of is_active in UserLogin to True automatically without user input while saving the searializers. I don't want to change it to default=True at model. serializers class UserloginSerializer(serializers.ModelSerializer): class Meta: model = UserLogin fields = ['m_number'] class RegisterSerializer(serializers.ModelSerializer): user_login = UserloginSerializer() #...... class Meta: model = User fields = ['user_login',..] models class Memberlogins(models.Model): is_active = models.BooleanField(default=False) m_number = models.CharField(max_length=255, blank=True, null=True) views class RegisterView(APIView): serializer = RegisterSerializer def post(self, request): context = {'request': request} serializer = self.serializer(data=request.data,context) if serializer.is_valid(raise_exception=True): serializer.save() -
403 Forbidden You don't have permission to access this resource. - Django
I recently made some changes to my Django app and pulled them back to the server. After doing so I am experiencing some error messages when trying to access my website. When I visit the website I am given Forbidden You don't have permission to access this resource. and in my /var/log/apache2/portfolio-error.log i see the following error logs. [Wed Oct 28 08:51:06.883684 2020] [core:error] [pid 11345:tid 139674953709312] (13)Permission denied: [client xx.xx.xxx.xx:48690] AH00035: access to / denied (filesystem path '/svr/portfolio/portfolio') because search permissions are missing on a component of the path [Wed Oct 28 08:51:07.085543 2020] [core:error] [pid 11345:tid 139675068827392] (13)Permission denied: [client xx.xx.xxx.xx:48690] AH00035: access to /favicon.ico denied (filesystem path '/svr/portfolio/static') because search permissions are missing on a component of the path, referer: https://example.com/ [Wed Oct 28 08:51:34.899776 2020] [core:error] [pid 12041:tid 140689096595200] (13)Permission denied: [client xx.xx.xxx.xx:48694] AH00035: access to / denied (filesystem path '/svr/portfolio/portfolio') because search permissions are missing on a component of the path [Wed Oct 28 08:51:35.112403 2020] [core:error] [pid 12041:tid 140689088202496] (13)Permission denied: [client xx.xx.xxx.xx:48694] AH00035: access to /favicon.ico denied (filesystem path '/svr/portfolio/static') because search permissions are missing on a component of the path, referer: https://example.com/ Also here are the permissions on my project: drw-rw-r-- 9 … -
In my Django-project how can I dynamically append a script which is located in the static folder to the head-section?
In my Django-project I would like to dynamically append a script-tag to the head-section. The script I want to append is located in static-folder. The problem is that I don't know how to reference the static-folder in javascript, or if that is even pssible. This is (a part of) my Javascript: jQuery( window ).on( "load", () => { const script = document.createElement("script"); script.src = "{% static 'js/myScript.js' %}"; document.head.appendChild(script); }); myScript.js could look like this: console.log("This is myScript") Of course this does not work. In the console I get: GET http://127.0.0.1:8000/%7B%%20static%20'js/myScript.js'%20%%7D net::ERR_ABORTED 404 (Not Found). Is there a way to reference the static-folder inside a javascript? -
Python doesn't see packages in virtual environment
I try to deploy my first django project on heroku and for that i need to import whitenoise. I have it installed in site-packages, but have an ImportError when import it. And python doesn't see packages in there apart from django and default ones. I'm quite a novice and don't understand what it means and what to do. Tried to add PYTHONPATH to activate, add a new path in SystemPropertyAdvanced, didn't help -
datetime-local time format does not conform to the required format
I hope this question is not a duplicate - I was at least not able to fix the issue by looking at other similar Q&As. I'm making a web application using Django 2.2, Postgresql 9.5 and Django template language with bootstrap for front end. In settings.py I have the following time settings: TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True In some of my forms I have datetime-local fields: date = forms.CharField(required=False, widget=forms.DateTimeInput( attrs={ 'type':'datetime-local', 'class':'form-control', } )) In my Django template I render the date field as shown below: <input type="datetime-local" id="id_date" class="form-control" value="{{ basic_form.date.value|date:"c"}}"> I'm getting the following error when loading a page with date field having a date value retrieved from database. And I'm not able to display the date in the form date field: The specified value "2020-10-28T09:28:00+00:00" does not conform to the required format. The format is "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS". I have also tried to 'render' the date field in the template directly from the form variable received by views.py: {{ basic_form.date }} ...and then I get a same warning, however the date value does not contain the T 'separator': The specified value "2020-10-28 09:28:00+00:00" does not … -
Connecting to Mongodb from Django application hosted on heroku
I am trying to connect my djnago application hosted on heroku. I have also changed the DATABASE_URL on heroku settings as: mongodb+srv://<name>:<password>@cluster0.wtnph.mongodb.net/test I am using python 3.9 and django 3.0.5 But when deploying to heroku, I am getting the error. > -----> Python app detected -----> No change in requirements detected, installing from cache -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2 -----> Installing SQLite3 -----> Installing requirements with pip -----> $ python manage.py collectstatic --noinput Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 345, in execute settings.INSTALLED_APPS File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__ self._setup(name) File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup self._wrapped = Settings(settings_module) File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/tmp/build_91bba5c0/kibo_skill_matrix_api/settings.py", line 176, in <module> django_heroku.settings(locals()) File "/app/.heroku/python/lib/python3.6/site-packages/django_heroku/core.py", line 69, in settings … -
Filter child related object and return empty list if none is found
Is there a way to filter child objects and return an empty list if no related object matching the query is found? At the moment I'm doing it in this way: Person.object.filter(item__is_active=True) If no active item is found, None is returned. I want to still get the Person object but with the items attribute as an empty list. -
Upload csv file and return back information in Django
views.py from django.shortcuts import render import pandas as pd import csv # Create your views here. def home(request): return render(request,'hello/home.html') def output(request): csvfile = request.FILES['csv_file'] data = pd.read_csv(csvfile.name) data_html = data.to_html() context = {'loaded_data': data_html} return render(request, "hello/home.html", context) Here I am trying to get the uploaded file and convert the file to table format. While doing this,I am getting No such file or directory: 'file.csv' Please help in solving this