PermissionError at /download/Django 1.10 error, 'NoneType' object is not callableKeyError when trying to assign clean_data value in DjangoKeyError at /users/login 'isLoggedIn'Unable to use login method in djangoerror 'NoneType' object has no attribute '__dict__'class has no attributed userasyncio in django viewDjango response error 'unicode' object has no attribute '_meta' jsonlist object has no attribute copy
Pandas: fill one column with count of # of obs between occurrences in a 2nd column
How to say "fit" in Latin?
Why should public servants be apolitical?
Should I take out a personal loan to pay off credit card debt?
Replace data between quotes in a file
Blocking people from taking pictures of me with smartphone
Why can I log in to my Facebook account with a misspelled email/password?
Team goes to lunch frequently, I do intermittent fasting but still want to socialize
How to query data in backups?
Can a character who casts Shapechange and turns into a spellcaster use innate spellcasting to cast spells with a long casting time?
How do I calculate the difference in lens reach between a superzoom compact and a DSLR zoom lens?
What is a "Genuine Geraldo interviewee"?
Colleagues speaking another language and it impacts work
Double blind peer review when paper cites author's GitHub repo for code
Can I call myself an assistant professor without a PhD
Why is there a need to prevent a racist, sexist, or otherwise bigoted vendor from discriminating who they sell to?
Is it really ~648.69 km/s delta-v to "land" on the surface of the Sun?
How to write "upright" integrals with automatic sizing
Looking for a new job because of relocation - is it okay to tell the real reason?
Tikzcd pullback square issue
A question about 'reptile and volatiles' to describe creatures
Do other countries guarantee freedoms that the United States does not have?
How to mark beverage cans in a cooler for a blind person?
"How do you solve a problem like Maria?"
PermissionError at /download/
Django 1.10 error, 'NoneType' object is not callableKeyError when trying to assign clean_data value in DjangoKeyError at /users/login 'isLoggedIn'Unable to use login method in djangoerror 'NoneType' object has no attribute '__dict__'class has no attributed userasyncio in django viewDjango response error 'unicode' object has no attribute '_meta' jsonlist object has no attribute copy
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
when i try to download the file it says PermissionError at /download/
views.py
def download(request, path):
file_path = os.path.join(settings.MEDIA_ROOT, path)
if os.path.exists(file_path):
with open(file_path, 'rb') as f:
response = HttpResponse(f.read(), content_type="application/vnd.ms-excel")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
return response
raise Http404
urls.py
re_path(r'^download/(?P<path>.*)$', views.download)
in html templates
<a href="/download">Download</a>
i have tried everything such as moved project folder to another directory or run it as admin etc but it says
Internal Server Error: /download/
Traceback (most recent call last):
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:UsersZako5PycharmProjectsjurnaljurnal_appviews.py", line 40, in download
with open(file_path, 'rb') as fh:
PermissionError: [Errno 13] Permission denied: 'C:\Users\Zako5\PycharmProjects\jurnal\media/'
[27/Mar/2019 10:56:09] "GET /download/ HTTP/1.1" 500 66483
any help would be appreciated) this problem has been pissing me off for a week
django python-3.x
add a comment |
when i try to download the file it says PermissionError at /download/
views.py
def download(request, path):
file_path = os.path.join(settings.MEDIA_ROOT, path)
if os.path.exists(file_path):
with open(file_path, 'rb') as f:
response = HttpResponse(f.read(), content_type="application/vnd.ms-excel")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
return response
raise Http404
urls.py
re_path(r'^download/(?P<path>.*)$', views.download)
in html templates
<a href="/download">Download</a>
i have tried everything such as moved project folder to another directory or run it as admin etc but it says
Internal Server Error: /download/
Traceback (most recent call last):
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:UsersZako5PycharmProjectsjurnaljurnal_appviews.py", line 40, in download
with open(file_path, 'rb') as fh:
PermissionError: [Errno 13] Permission denied: 'C:\Users\Zako5\PycharmProjects\jurnal\media/'
[27/Mar/2019 10:56:09] "GET /download/ HTTP/1.1" 500 66483
any help would be appreciated) this problem has been pissing me off for a week
django python-3.x
add a comment |
when i try to download the file it says PermissionError at /download/
views.py
def download(request, path):
file_path = os.path.join(settings.MEDIA_ROOT, path)
if os.path.exists(file_path):
with open(file_path, 'rb') as f:
response = HttpResponse(f.read(), content_type="application/vnd.ms-excel")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
return response
raise Http404
urls.py
re_path(r'^download/(?P<path>.*)$', views.download)
in html templates
<a href="/download">Download</a>
i have tried everything such as moved project folder to another directory or run it as admin etc but it says
Internal Server Error: /download/
Traceback (most recent call last):
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:UsersZako5PycharmProjectsjurnaljurnal_appviews.py", line 40, in download
with open(file_path, 'rb') as fh:
PermissionError: [Errno 13] Permission denied: 'C:\Users\Zako5\PycharmProjects\jurnal\media/'
[27/Mar/2019 10:56:09] "GET /download/ HTTP/1.1" 500 66483
any help would be appreciated) this problem has been pissing me off for a week
django python-3.x
when i try to download the file it says PermissionError at /download/
views.py
def download(request, path):
file_path = os.path.join(settings.MEDIA_ROOT, path)
if os.path.exists(file_path):
with open(file_path, 'rb') as f:
response = HttpResponse(f.read(), content_type="application/vnd.ms-excel")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
return response
raise Http404
urls.py
re_path(r'^download/(?P<path>.*)$', views.download)
in html templates
<a href="/download">Download</a>
i have tried everything such as moved project folder to another directory or run it as admin etc but it says
Internal Server Error: /download/
Traceback (most recent call last):
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:UsersZako5.virtualenvsjurnal-6LxuXEYulibsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:UsersZako5PycharmProjectsjurnaljurnal_appviews.py", line 40, in download
with open(file_path, 'rb') as fh:
PermissionError: [Errno 13] Permission denied: 'C:\Users\Zako5\PycharmProjects\jurnal\media/'
[27/Mar/2019 10:56:09] "GET /download/ HTTP/1.1" 500 66483
any help would be appreciated) this problem has been pissing me off for a week
django python-3.x
django python-3.x
asked Mar 27 at 6:14
codercoder
536 bronze badges
536 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
your path is empty as such it is trying to open MEDIA_ROOT
which is a directory
say your directory structure is as follows:
-media root
- 1.xlsx
Then you update tour html as
<a href="/download/1.xlsx">Download</a>
so your path variable becomes 1.xlsx
here is my media root dir 'MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')'
– coder
Mar 27 at 6:31
yes its a directory you need to open a file
– Jibin Mathews
Mar 27 at 6:38
@JibinMathews is right you need to open a file
– Yugandhar Chaudhari
Mar 27 at 6:41
please can you show me how to open? I opened the path if exists above code
– coder
Mar 27 at 6:45
@coder updated my answer
– Jibin Mathews
Mar 27 at 6:53
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370877%2fpermissionerror-at-download%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
your path is empty as such it is trying to open MEDIA_ROOT
which is a directory
say your directory structure is as follows:
-media root
- 1.xlsx
Then you update tour html as
<a href="/download/1.xlsx">Download</a>
so your path variable becomes 1.xlsx
here is my media root dir 'MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')'
– coder
Mar 27 at 6:31
yes its a directory you need to open a file
– Jibin Mathews
Mar 27 at 6:38
@JibinMathews is right you need to open a file
– Yugandhar Chaudhari
Mar 27 at 6:41
please can you show me how to open? I opened the path if exists above code
– coder
Mar 27 at 6:45
@coder updated my answer
– Jibin Mathews
Mar 27 at 6:53
|
show 2 more comments
your path is empty as such it is trying to open MEDIA_ROOT
which is a directory
say your directory structure is as follows:
-media root
- 1.xlsx
Then you update tour html as
<a href="/download/1.xlsx">Download</a>
so your path variable becomes 1.xlsx
here is my media root dir 'MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')'
– coder
Mar 27 at 6:31
yes its a directory you need to open a file
– Jibin Mathews
Mar 27 at 6:38
@JibinMathews is right you need to open a file
– Yugandhar Chaudhari
Mar 27 at 6:41
please can you show me how to open? I opened the path if exists above code
– coder
Mar 27 at 6:45
@coder updated my answer
– Jibin Mathews
Mar 27 at 6:53
|
show 2 more comments
your path is empty as such it is trying to open MEDIA_ROOT
which is a directory
say your directory structure is as follows:
-media root
- 1.xlsx
Then you update tour html as
<a href="/download/1.xlsx">Download</a>
so your path variable becomes 1.xlsx
your path is empty as such it is trying to open MEDIA_ROOT
which is a directory
say your directory structure is as follows:
-media root
- 1.xlsx
Then you update tour html as
<a href="/download/1.xlsx">Download</a>
so your path variable becomes 1.xlsx
edited Mar 27 at 6:53
answered Mar 27 at 6:23
Jibin MathewsJibin Mathews
6326 silver badges17 bronze badges
6326 silver badges17 bronze badges
here is my media root dir 'MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')'
– coder
Mar 27 at 6:31
yes its a directory you need to open a file
– Jibin Mathews
Mar 27 at 6:38
@JibinMathews is right you need to open a file
– Yugandhar Chaudhari
Mar 27 at 6:41
please can you show me how to open? I opened the path if exists above code
– coder
Mar 27 at 6:45
@coder updated my answer
– Jibin Mathews
Mar 27 at 6:53
|
show 2 more comments
here is my media root dir 'MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')'
– coder
Mar 27 at 6:31
yes its a directory you need to open a file
– Jibin Mathews
Mar 27 at 6:38
@JibinMathews is right you need to open a file
– Yugandhar Chaudhari
Mar 27 at 6:41
please can you show me how to open? I opened the path if exists above code
– coder
Mar 27 at 6:45
@coder updated my answer
– Jibin Mathews
Mar 27 at 6:53
here is my media root dir 'MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')'
– coder
Mar 27 at 6:31
here is my media root dir 'MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')'
– coder
Mar 27 at 6:31
yes its a directory you need to open a file
– Jibin Mathews
Mar 27 at 6:38
yes its a directory you need to open a file
– Jibin Mathews
Mar 27 at 6:38
@JibinMathews is right you need to open a file
– Yugandhar Chaudhari
Mar 27 at 6:41
@JibinMathews is right you need to open a file
– Yugandhar Chaudhari
Mar 27 at 6:41
please can you show me how to open? I opened the path if exists above code
– coder
Mar 27 at 6:45
please can you show me how to open? I opened the path if exists above code
– coder
Mar 27 at 6:45
@coder updated my answer
– Jibin Mathews
Mar 27 at 6:53
@coder updated my answer
– Jibin Mathews
Mar 27 at 6:53
|
show 2 more comments
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370877%2fpermissionerror-at-download%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown