title: Suspicious file operation : Cannot configure media root and base dir in my django Project folder
body: <p>I am trying to save the project files to media then grap to show in url, so far i have followed some easy techniques to avoid the file operation and stored them in media</p>
  <p>my setting.py file-&gt;</p>
  <pre><code>STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  STATIC_URL = '/static/'
  
  
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  MEDIA_URL = '/media/'
  </code></pre>
  <p>my models.py files model fields-&gt;</p>
  <pre><code>picture = models.ImageField(null=True, blank=True, upload_to = &quot;photos&quot;)
  resume = models.FileField(null=True, blank=True, upload_to = &quot;resume&quot;)
  </code></pre>
  <p>It stores then correctly and shows as media url.</p>
  <p>my urls.py file-&gt;</p>
  <pre><code>from django.contrib import admin
  from django.urls import path,include
  from django.conf.urls.static import static
  from django.conf import settings
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('api/v1/cand/',include(&quot;core.urls&quot;))
  ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>
  <p>main problem happens when i query a resume pdf file. It can't find the BASE_DIR</p>
  <pre><code>from django.conf import BASE_DIR
  url = serializer.data[&quot;resume&quot;]
  file_name = url.split(&quot;/&quot;)[-1]
  data=ResumeParser(os.path.join(BASE_DIR,&quot;/media/resume/&quot;,file_name)).get_extracted_data()
  return Response({**serializer.data, &quot;data&quot;: data}, status = status.HTTP_200_OK)
  </code></pre>
  <p>Although it works when i use absolute path-&gt;</p>
  <pre><code> url = serializer.data[&quot;resume&quot;]
      file_name = url.split(&quot;/&quot;)[-1]
      data=ResumeParser(&quot;/home/riyad/Desktop/kalkedev/services/candidate&quot;,&quot;media/resume/&quot;,file_name).get_extracted_data()
      return Response({**serializer.data, &quot;data&quot;: data}, status = status.HTTP_200
  </code></pre>
  <p>_OK)</p>
  <p>is this is a django issue because i have been dealing with this issur previously and taking the easy way(default base_dir) to store file. Need to find the answer quick.</p>