Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Apscheduler with django on windows server
Im using django for my website.In that,I need to run a job automatically.This django app is hosted on the IIS windows server.When I run the app locally(By command prompt),it works.But In the IIS,Job not running.Below here,I put some codes and its location I tried.Lets take my project name is myProject and my app name is myApp In myApp/init.py: import os if os.environ.get('RUN_MAIN', None) != 'true': default_app_config = 'myApp.apps.MyAppConfig' In myApp/apps.py: from django.apps import AppConfig class MyAppConfig(AppConfig): name = 'myApp' def ready(self): from taskscheduler import updater updater.start() In myApp/views.py: def job(): #some codes #and a row creation whether the app runs successfully or failed In updater/updater.py: from apscheduler.schedulers.background import BackgroundScheduler from myApp import views def start(): scheduler = BackgroundScheduler() scheduler.add_job(views.job, trigger='cron',hour='*', minute='20') scheduler.start() import logging logging.basicConfig() logging.getLogger('apscheduler').setLevel(logging.DEBUG) Please help me sortout. Thanks in advance -
React - how to render nested object with renderItem
I'm a bit struggling with rendering nested object in my front end. I know there is a map function might be helpful, but I'm not sure how I can get it to work in my case (with renderItem). The back end I'm using are Rest API framework and Django. This is what JSON structure looks like. { "id": 1, "name": "Job 1", "address": [ { "id": 4, "street": "65 Karamea Street", "suburb": "Beautiful Surburb", "town": "Christchurch", "postcode": "8001", "address_type": "h" } ], "franchise": { "id": 2, "name": "Company ABC", "person": 2, "legal_name": "Company ABC Ltd.", "created": "2019-08-09T09:40:35.697582Z", "modified": "2019-09-23T03:21:43.258983Z", "region": { "id": 4, "region": "QueensTown" } }, "customer1": { "id": 1, "last_name": "Tom", "first_name": "Wilson", "address": [ { "id": 11, "street": "1 Sunset Road", "suburb": "Auckland", "town": "Auckland", "postcode": "1234" } ] } This is the React code: import React from 'react'; import { List, Card } from 'antd'; const Job = props => { return ( <React.Fragment> <List grid={{ gutter: 16, xs: 1, sm: 2, md: 4, lg: 4, xl: 6, xxl: 3, }} dataSource={props.data} renderItem={item => ( <List.Item> <Card title={<a href={`/job/${item.id}`}>{item.customer1.first_name}</a>}>{item.franchise.legan_name} <span> | Based on </span> {item.name} </Card> </List.Item> )} /> </React.Fragment> ); }; export default Job; Within … -
How to run selenium from django
I am making a website that will use selenium to get data from another website. And i want to know how to do this properly. Basically the selenium script should run when the user clicks a button. May i will have to use multi threading or something? -
How can I invoke remote api in django view.py?
I Have a Django app which use api written i ASP.Net. I can call api from template (html page). Is there any way to call api from views.py? I have tried this. from django.shortcuts import render from django.contrib.auth.decorators import login_required # Create your views here. def categorydashboard(request): r = request.post('xxx.xxx.xx.xxx:xxxx/Category/getSubCategoryNamev2', d=request.GET) return render (request,'categoryDashboard.html',{}) API sample data (it is a GET request) [ { "category_id": 2, "category_name": "Hyper Mechanical", "Image_Path": null, "subcategory": [ { "category_id": 0, "category_name": null, "product_subcategory_id": 37, "product_subcategory_name": "Lift", "schema_id": null, "Image_path": "" } ] } ] Server runs well but when i call 'categorydashboard' view its throws following error AttributeError: 'WSGIRequest' object has no attribute 'get' I am new in Django so i am sorry if i have mistaken -
Show notification or alert of a requirement of a mobile user in Django web application
I have a mobile medical services application which posts to API with DRF of a web application (administrator) based on Django. How to manage any alert or notification of service requirements, so that it’s shown in the web application that this service has been requested. Can you give me a step-by-step guide on how this could be implemented? -
Django-rest-framework api add SessionAuthentication as optional
Hi i'm currently have my api that use this simple-JWT package for jwt token authentication, it worked great. But now when i try to call the api from the django website app using Ajax in which is from a page user already logged in but it still required me to use the jwt access_token. My ajax call from the page user already logged in: $.ajax({ type: "POST", url: "/api/add_favorite/" + property_id + "/", beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', 'Bearer {{ refresh_token }}'); }, success: function (data) { if (data.code == 200) { alert('added to favorite'); replace_part_1 = '<a id="mylink2" href="#" value="' + property_id +'"><i class="fas fa-heart fa-lg" style="color: red" title="Remove from favorite"></i></a>' $("a[value='" + property_id + "']").replaceWith(replace_part_1); } } }); Now i don't want to set the header with authorization since in the page user already logged in so the session is already set. So i tried to add Django Session authentication to the the api like so: @api_view(['POST']) @authentication_classes([SessionAuthentication, JWTAuthentication]) @permission_classes([IsAuthenticated]) def add_favorite(request, property_id): if request.method == 'POST': try: favorite_property = Property.objects.get(pk=property_id) if request.user.is_authenticated: login_user = request.user if not login_user.properties.filter(pk=property_id).exists(): login_user.properties.add(favorite_property) return JsonResponse({'code':'200','data': favorite_property.id}, status=200) else: return JsonResponse({'code':'404','errors': "Property already exists in favorite"}, status=404) except Property.DoesNotExist: return JsonResponse({'code':'404','errors': "Property … -
How to activate virtual environment in Django for Windows with Python?
I've been told that to activate a Virtual Environment in Django for Windows I should try: environment_path\Scripts\activate But when I enter that, cmd returns this error: The system cannot find the path specified. I created the virtual environment by entering: python3 -m venv env However when I try env\Scripts\activate I get the error described. Can anyone help? Thanks. -
error url using django and rest framweork
error when i try to call some id of my urls for example the view in rest_frameork i try to enter http://127.0.0.1:8000/categoria/4 or 5 and i can't error mensagge "The current path, categoria/4, didn't match any of these. (error 404)" im ussing the rest_framework for it file urls.py from django.urls import path, include from django.conf.urls import url from . import views from rest_framework import routers router = routers.DefaultRouter() router.register(r'users', views.UserViewSet) urlpatterns = [ url(r'^doctor$', views.DoctorList.as_view()), url(r'^doctor(?P<pk>[0-9]+)$', views.DoctorDetail.as_view()), url(r'^paciente$', views.PacienteList.as_view()), url(r'^paciente(?P<pk>[0-9]+)$', views.PacienteDetail.as_view()), url(r'^categoria$', views.CategoriaList.as_view()), url(r'^categoria(?P<pk>[0-9]+)$', views.CategoriaDetail.as_view()), url(r'^examen$', views.ExamenList.as_view()), url(r'^examen(?P<pk>[0-9]+)$', views.ExamenDetail.as_view()), path('', include(router.urls)), path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) ] -
Django restful API to get permission of built-in users
I want to access Django's built-in user's permission, like add an instance of a model, delete, modify. Do you know how to access such information using Restful API? I have used django-rest-auth, but it seems that it can not provide the method to access permission. Could you please give me some suggestions? -
Testing socket activation failed, Django and Gunicorn
when I try to do this: sudo systemctl status gunicorn It answers with this: ● gunicorn.service - gunicorn daemon Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2019-09-25 01:50:37 UTC; 40min ago Main PID: 22345 (code=exited, status=216/GROUP) Sep 25 01:50:37 hybroo systemd[1]: Started gunicorn daemon. Sep 25 01:50:37 hybroo systemd[22345]: gunicorn.service: Failed to determine group credentials: No such process Sep 25 01:50:37 hybroo systemd[22345]: gunicorn.service: Failed at step GROUP spawning /hybroodir/hybrooenv/bin/gunicorn: No such process Sep 25 01:50:37 hybroo systemd[1]: gunicorn.service: Main process exited, code=exited, status=216/GROUP Sep 25 01:50:37 hybroo systemd[1]: gunicorn.service: Failed with result 'exit-code'. Sep 25 01:50:37 hybroo systemd[1]: gunicorn.service: Start request repeated too quickly. Sep 25 01:50:37 hybroo systemd[1]: gunicorn.service: Failed with result 'exit-code'. Sep 25 01:50:37 hybroo systemd[1]: Failed to start gunicorn daemon. root@hybroo:/hybroodir# curl --unix-socket /run/gunicorn.sock localhost However, it's supposed to answer this: ● gunicorn.service - gunicorn daemon Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enabled) Active: inactive (dead) Any help is appreciated, I'm sorry if I'm not showing anything helpful, but I don't know what more I could show. I'm using: Postgres, Nginx, and Gunicorn on Ubuntu 18.04 in Google Cloud. -
ReactJs in Django return
I am new to Reactify Django. Actually, i am trying to have React JS to be rendered instead of HTML page. I have following: views.py from django.shortcuts import render def home(request): return render (request, 'home.html') home.html <html> <head> {% load staticfiles %} <script src="{% static '/App.js' %}"></script> </head> <body> <p>Hello World Home</p> {% block content %}{% endblock %} </body> </html> App.js import React from 'react'; import logo from './logo.svg'; import './App.css'; function App() { return ( <div className="App"> Hello to react app! </div> ); } export default App; settings.py STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(SETTINGS_PATH, 'frontend/src'), ) I am not sure, if i am understanding the concept correctly. But i am looking for returning the react rendered html in django.I have my react app installed in frontend directory in the same folder. Any clarification, will be greatly appreciated. -
How can I create a video and photo uploading feature on my website using Python and Django?
How can I create a video and photo uploading feature on my website using Python and Django? I have using forms,models(file_field) and yet it doesn't render to the front_end -
Unexpected Keyword when I Pass Url Parameter
I have a view called 'Teams' that loops through different NBA teams in a dictionary and shows their name and logo. When the user clicks on one of these logos, I want them to be taken to the 'TeamDetailView'. This should carry over the chosen team's city/name/logo, and I can see this information being passed in the URL. When I attempt to load the team's individual page, though, it gives me a type error and says that TeamDetailView() got an unexpected keyword argument 'city' In the local vars section, it shows my key/value pairs being passed correctly. How can I access these parameters on the team page and correct this error? callback_kwargs {'city': 'Atlanta', 'logo': 'atlanta-logo.png', 'name': 'Hawks'} Here is my view: def TeamDetailView(request): return render(request, 'bandwagon/team.html/') Here is my URL: path('team/<str:city>/<str:name>/<str:logo>/', views.TeamDetailView, name='bandwagon-team'), Here is my Template for the Teams List: {% for key, value in teams.items %} <a class="stream-list" href="{% url 'bandwagon-team' value.city value.name value.logo %}"> <img class="stream-img" alt="The Logo for the {{ value.city }} {{ value.name }}" src="../../../media/logos/{{ value.logo }}"> <p class="name">{{value.city }} {{value.name}}</p> </a> {% endfor %} Here is my Template for the Individual Team Page, which is quite basic for now until I get these … -
Ajax redirects to the url with preventDefault()
I'm using Django for an app that allows you to search and save recipes. I'm trying to have a form on a search results page that allows you to click 'save' and creates an object to the database without reloading the page. In the current setup when I click on the 'save' button for the form with id="add_form" I get redirected to a new url (add/) even though I've included preventDefault(). I thought this was due to me including the form action={%url 'add' %} however, I've tried removing the form action but that gave me a multiValueDictKeyError for raw_input = request.POST['ingredients'] so I thought it was calling the incorrect view function views.recipes instead of views.add. I've read some other ajax guides that explicitly state a form action so I thought that would help with the incorrect view function being called. views.py def recipes(request): if request.method == 'POST': # check for dietary restrictions restrictions = request.POST.getlist('restrictions') # format input ingredients raw_input = request.POST['ingredients'] ... return render(request, 'recipes/recipes.html', {'results': results}) else: return render(request, 'recipes/recipes.html', {'error': 'Please search for a recipe'}) @csrf_protect def add(request): if request.method == 'POST': title = request.POST['title'] image = request.POST['image'] source = request.POST['source'] user = request.user try: recipe = … -
Django tests imports use content type values from real database
My application is built on top of Django and DRF. I'm trying to test a serializer with a structure similar to this one: settings.py ... DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'db', 'USER': 'user', 'PASSWORD': 'unbreakablepass', 'TEST': { 'NAME': 'test_db', } } } ... models.py class Status(models.Model): name = models.CharField(verbose_name=_('name'), max_length=150) order = models.PositiveIntegerField(verbose_name=_('order'), default=0) content_type = models.ForeignKey(ContentType) class Task(models.Model): status = models.ForeignKey(Status) serializers.py class TaskSerializer(serializers.ModelSerializer): class Meta: model = Task fields = ['status'] extra_kwargs = { 'status': { 'queryset': Status.objects.filter( content_type=ContentType.objects.get_for_model(Task) ) } } tests.py from myapp.serializers import TaskSerializer from myapp.models import Task class TaskTestCase(TestCase): def test_content_type(self): # Do something with ContentType.objects.get_for_model(Task) ... My problem is that since the serializers are imported in tests.py, they are imported before the test database is setup when I run manage.py test --keepdb. Now, the ContentType value in the queryset attribute of my related field, is filtered with ContentType values from the main db, not the test db. So my tests would fail if they attempted to use any value in the related field. The obvious choices seem to be: Import the serializer inside the testing code. I really dislike this. Also, many different tests may use the serializer. Use some … -
Is there any benefit to switching from django template to jinja if I only have simple templates?
I have an application where the vast majority of business logic is in the backend. I use django templates along with context variables to populate those templates. In majority, they are all simple and don't have fancy logic. My question is: Is there any improvement in terms of performance or readability or any other benefit if I switch from django templates to jinja in this particular case? -
return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: no such column: webapp_extendeduser.password
I'm trying to create a custom user model for my database but there is error said that there is no password column in my custom user model (which I name it as Extendeduser). I thought that there is no need to manually create the password column, am I wrong? Other than that there are also issues when trying to create a superuser using py manage.py command caused by the same error. Please help me solve these issues and thank you in advance. my models.py file from django.contrib.auth.models AbstractUser class Extendeduser(AbstractUser): pass def __str__(self): return self.extendeduser my post.py (Form)file from django import forms from django.contrib.auth.forms import UserCreationForm,UserChangeForm from .models Extendeduser class CustomUserCreationForm(UserCreationForm): class Meta: model = Extendeduser fields = ('username', 'email') class CustomUserChangeForm(UserChangeForm): class Meta: model = Extendeduser fields = ('username', 'email') my admin.py file from django.contrib import admin from django.contrib.auth import get_user_model from django.contrib.auth.admin import UserAdmin from .post import CustomUserCreationForm, CustomUserChangeForm from .models import Extendeduser class ExtendeduserAdmin(UserAdmin): add_form = CustomUserCreationForm form = CustomUserChangeForm model = Extendeduser list_display = ['email', 'username',] admin.site.register(Extendeduser, ExtendeduserAdmin) -
How to include dynamic data to django url template tag
Say i have a url in my template like this `<a href="{% url 'dashboard:clinic:users' %}">users</a>` Now in the aspect of clinic, it's not static but dynamic. That means it can also be like this: `<a href="{% url 'dashboard:laboratory:users' %}">users</a>` how can i include a variable inside the url template tag to replace clinic with the variable content. -
I am using Django filterset on 2 fields. Need to display distinct values in the second field and if possible only the dependent values
I have a model that has 2 fields which are FK to 2 different tables. I am writing a filter on these 2 fields. Field 2 has non-unique values. How can I do a distinct on the filter field? class SessionFilter(django_filters.FilterSet): module = django_filters.CharFilter(distinct="True") class Meta: model = Session fields = ['subject', 'module', ] Models.py class Module(models.Model): STATUS_TYPES = ( ('Active', 'Active'), ('Inactive', 'Inactive'), ) topic = models.CharField(max_length = 200) teacher_name = models.CharField(max_length = 100) status = models.CharField(max_length=30, default='Active', choices=STATUS_TYPES) subject = models.ForeignKey(Subject, on_delete=models.CASCADE) created_dt = models.DateTimeField(default=datetime.now) def __str__(self): return self.topic class Meta: db_table = 'modules' class Session(models.Model): grade_level = models.CharField(max_length = 30) num_students = models.IntegerField(default=0) session_dt = models.DateTimeField(default=datetime.now) subject = models.ForeignKey(Subject, on_delete=models.CASCADE) module = models.ForeignKey(Module, on_delete=models.CASCADE) school = models.ForeignKey(School, on_delete=models.CASCADE) def __str__(self): return self.school.school_name + ' on ' + self.session_dt class Meta: db_table = 'sessions' The filter form does not have any dropdown for module. However, if I remove the first line then I get duplicates in my search form. Ideally I want to restrict to the "topics" related to the subject and with no duplicates. I am a newbie to both Django and Python. -
How do I manipulate text submitted in a Django form?
I want the user to be able to input a word, click "submit", and then see their word in all caps on the next page. (This is not my final intention, just a useful way to progress). views.py: from django.http import HttpResponse from django.template import loader from .models import Word from django.http import HttpResponseRedirect from django.shortcuts import render from .forms import WordForm def wordinput(request): if request.method == 'POST': form = WordForm(request.POST) if form.is_valid(): return HttpResponseRedirect('/thanks/') else: form = WordForm() return render(request, 'word.html', {'form': form}) def your_word(request): form = WordForm() if request.method == 'POST': # and form.is_valid(): word = WordForm(request.POST) word = str(word) word = word.upper() return HttpResponse(word) else: return HttpResponse("that didn't work") forms.py: from django import forms class WordForm(forms.Form): your_word = forms.CharField(label='Type your word here', max_length=100, required = True) word.html: <form action="/wordsearch/your-word/" method="post"> {% csrf_token %} {{ form }} <input type="submit" value="Search"> </form> urls.py: from django.contrib import admin from django.urls import include, path from . import views urlpatterns = [ path('wordinput/', views.wordinput, name='wordinput'), path('your-word/', views.your_word, name='your_word') ] Result: TYPE YOUR WORD HERE: ASDF ((In this result, "ASDF" is in a box and manipulable)) Desired result: ASDF ((The desired result is simply on the screen)) -
ajax django login system not working, it returns user as none
I am new in django i am trying to create a user registration and login system. I can register users but somehow it does not log them in. the logout system also works out fine. I don't know what i'm missing here is my code def register(request): if request.method == 'POST': data={} firstname = request.POST['firstname'] surname = request.POST['surname'] username = request.POST['username'] email = request.POST['email'] password = request.POST['password'] confirm = request.POST['confirm'] if password == confirm: # check username, so that we do not repeat usernames if User.objects.filter(username=username).exists(): data['error'] = "This username is taken" print(data) else: if User.objects.filter(email=email).exists(): data['error'] = "This email is already assigned to another user" print(data) else: user = User.objects.create_user(username=username, email=email, first_name=firstname, last_name=surname) if password: user.set_password(password) else: user.set_unusable_password() user.save() user = authenticate(request, username=username, password=password) login(request, user) data['success'] = "You are successfully registered" print(data) else: data['error'] = "passwords do not match" print(data) return HttpResponse(simplejson.dumps(data), content_type = "application/json") def my_login(request): if request.method == 'POST': data = {} username = request.POST['username'] password = request.POST['password'] user = authenticate(request, username=username, password=password) print("it all checks out so far") if user is None: print('no user') if user is not None: if user.is_active: print("user exists") login(request, user) print("you are logged in") else: data['error'] = "username or password … -
Wagtail / CodeRedCMS: jQuery ReferenceError $ is not defined, can't determine reason why
I'm using CodeRedCMS which is built on Wagtail (which is built on Django), and I can clearly see that jQuery is properly getting imported into each page, however when trying to access my flipclock.js function I'm getting a ReferenceError and the clock isn't loading. HTML module in Wagtail Admin page: <div class="clock"></div> <script type="text/javascript"> var clock; $(document).ready(function() { // Grab the current date var currentDate = new Date(); // Set some date in the future. In this case, it's always Jan 1 var futureDate = new Date(currentDate.getFullYear() + 1, 0, 1); // Calculate the difference in seconds between the future and current date var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000; // Instantiate a coutdown FlipClock clock = $('.clock').FlipClock(diff, { clockFace: 'DailyCounter', countdown: true }); }); </script> Base.html: {% extends "coderedcms/pages/base.html" %} {% load static %} {% block custom_assets %} {# Add your custom CSS here #} <link rel="stylesheet" type="text/css" href="{% static 'website/css/custom.css' %}"> {% endblock %} {% block custom_scripts %} {# Add your custom JavaScript here, or delete the line below if you don't need any #} <script type="text/javascript" src="{% static 'website/js/custom.js' %}"></script> <script type="text/javascript" src="{% static 'website/js/flipclock.min.js' %}"></script> {% endblock %} CodeRedCMS automatically imports Bootstrap and … -
Django rest framework PUT slow on large model
I am updating an entire Django model through the DRF API. The model has a large number of entries (> 2000). So far I have been doing the following: import requests for i in range(max_display): payload = {'a':name[i],'b':surname[i],'c':email[i]} r = requests.put('http://localhost:8000/api/v1/list/' + str(i+1) + '/', data=payload) But this loop is slow. I was wondering if there was a way to dump the whole database into the DRF API. Something where I can update all the a keys by the whole name vector without having to use a slow loop. I think this should be possible since I am updating all the model and I do not have unchanged exceptions. -
How can I configure my Django view class to have a file upload to a certain folder?
I am combining two Django apps, chunked_upload and filer, so I can have a file system that can upload large files via chunking. filer is based on ajax_upload which imposes file size limits. I am near completion, but I still need to direct my chunked_upload file to the folder I am currently in (for now, all files upload to unsorted uploads no matter the folder url I am in). Since the chunked_uploadupload button is ajax/javascript based, I must refer to my Django urls to then access a view. Is there a way to translate the old ajax-based upload button from filer into the new django-based upload button from chunked_upload to reference a folder_id? (or basically convert filer-ajax_upload to api_chunked_upload as seen in my urls) chunked_upload.views.py (where the new upload view resides) class ChunkedUploadView(ChunkedUploadBaseView): """ Uploads large files in multiple chunks. Also, has the ability to resume if the upload is interrupted. """ field_name = 'file' content_range_header = 'HTTP_CONTENT_RANGE' content_range_pattern = re.compile( r'^bytes (?P<start>\d+)-(?P<end>\d+)/(?P<total>\d+)$' ) max_bytes = MAX_BYTES # Max amount of data that can be uploaded # If `fail_if_no_header` is True, an exception will be raised if the # content-range header is not found. Default is False to match Jquery … -
PermissionError:Errno 13 Permission denied
My site should scrape some data from another, everything worked on my computer. I put my app on a server and this error occurs. I changed permission to 777 and didn't work. I'm using python3, apache 2.4 on ubuntu 18.10. PermissionError at /scrape/ [Errno 13] Permission denied: FILENAME Error log: [Tue Sep 24 20:54:41.981186 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] File "/home/matms/django_project/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner [Tue Sep 24 20:54:41.981190 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] response = get_response(request) [Tue Sep 24 20:54:41.981192 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] File "/home/matms/django_project/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response [Tue Sep 24 20:54:41.981195 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] response = self.process_exception_by_middleware(e, request) [Tue Sep 24 20:54:41.981198 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] File "/home/matms/django_project/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response [Tue Sep 24 20:54:41.981201 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] response = wrapped_callback(request, *callback_args, **callback_kwargs) [Tue Sep 24 20:54:41.981204 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] File "/home/matms/django_project/news/views.py", line 96, in scrape [Tue Sep 24 20:54:41.981207 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] with open(local_filename, 'wb') as f: [Tue Sep 24 20:54:41.981211 2019] [wsgi:error] [pid 29114:tid 139877711529728] [remote 89.78.216.206:53391] PermissionError: [Errno 13] Permission denied: '4MsktkpTURBXy9kOWRiYWQ4Yzk2ZDkyYjk2YjNiYmRhZjNhNDdiMWQ2NC5qcGeTlQMARc0EAM0CP5MFzQEUzJuVB9kyL3B1bHNjbXMvTURBXy83MWUxOGYwMDNhYWE1ODk3NTIwMmFmNTk0OGZmNmZjMS5wbmcAwgA.jpg' [Tue Sep 24 20:54:41.981217 …