Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
SMTPAuthenticationError when sending email in my Django Project Deployed on Google Cloud
I have deployed my Django Project on Google Cloud. I want emails to be sent on different conditions in my project. The emails are successfully sent when the project is hosted on the development server on the internal IP. However I am facing an SMTP Authentication error when trying to send email on Google Cloud where my project is deployed. Following are my email settings and the error encountered: Email Settings SMTP Authentication Error -
Updates to admin.py not reflected in the django admin page
I'm building a django app and the django admin page doesn't seem to be reflecting the changes I make to admin.py. For example if I want to exclude some fields, or customizing the admin change list, nothing changes in the actual page. The only thing that seems to be reflected properly is the fact that I can register the models, and they will show up. Here's my admin.py from django.contrib import admin from .models import Form, Biuletyn, Ogloszenie, Album class FormAdmin(admin.ModelAdmin): exclude = ('img',) class BiuletynAdmin(admin.ModelAdmin): list_display = ('name', 'date') class OgloszenieAdmin(admin.ModelAdmin): fields = ('name', 'date', 'upload') admin.site.register(Form) admin.site.register(Biuletyn) admin.site.register(Ogloszenie) admin.site.register(Album) P.S. Please ignore the weird model names. The site is actually in a different language :D -
passing data from django view context dictionary to react components
I am trying to create a Django and React full stack web app and using django rest framework to create apis and it is really easy to work with these two when it comes to send data but for login and logout system it is becoming really messy to work with as we cannot get the request.user from a normal fetch request from react. and also passing data from a view context dictionary to react also getting too much difficult for me. I have a view to render index.html whose control is taken over by react and I want to send that if user is authenticated or not to my react component how can I do that? Here is how my view is looking. ```def index(request): authenticated = False if request.user.is_authenticated: authenticated = True context = { 'authenticated':authenticated } return render(request,'index.html',context)``` I want to pass authenticated to react component how can I do it? I have passed it to normal js on index.html but don't know how to pass it to react component. Here is how my index.html looks like. ```<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="theme-color" content="#000000" … -
Uncaught TypeError: Cannot read properties of null
I wrote this code and now i'm stuck with this error TypeError: Cannot read properties of null (reading 'innerHTML') displayCart(cart); function displayCart(cart) { //cart is perameter actually var cartString = ""; cartString += "<h5>This is your cart</h5>"; var cartIndex = 1; for (var x in cart){ cartString += cartIndex; console.log(document.getElementById("nam" + x).innerHTML +" | " + "Qty:" + cart[x] ); cartString += document.getElementById("nam" + x).innerHTML +" | " + "Qty:" + cart[x] + "</br>" ; cartIndex +=1; } } thank you -
Django - How can add multiple forms according to input enter number
I have an input field where the will customer add a number for buy membership then will get forms according to numbers 1,2, or 5 then will show 1,2, or 5 forms with input fields in which will add data. For example: customer will come to the site and click on buy membership the first page will How many Memberships do you want to buy? ==> input Field in which will add 1,2, or 5 based on how many members enter a show a page to collect information of members I have reached the multiple forms adding by the user with the button. But my desire is that on the first-page user will enter the number of forms which he wants then according to his number I will create the number of forms for him. On that which I have worked with Django formsets you can see my code models.py from django.db import models class MemberShip(models.Model): GENDER = ( ('Male', 'Male'), ('Female', 'Female'), ) EXPERIENCE = ( ('First Time', 'First Time'), ('Have skier and snowboard before', 'Have skier and snowboard before'), ) first_name = models.CharField(max_length=200, null=True) last_name = models.CharField(max_length=200, null=True) experience = models.CharField(max_length=100, null=True, choices=EXPERIENCE) date_birth = models.CharField(max_length=20, null=True) gender … -
Django: "[Errno 13] Permission denied: '/samples'" during file upload via model
I'm trying to push a sample file from admin page, via a model. Whole website works fine but I'm just getting this problem with this specific model. Model class File(models.Model): area = models.OneToOneField(Actions, on_delete=CASCADE) sample_file = models.FileField( upload_to='samples/', validators=[validate_file_extension]) Info samples/ Directory relies in BASE_DIR of project. Tried Fixes Read few articles, and got few ideas about permissions but my permissions are correct as well, folder is under www-data drwxr-xr-x 2 www-data www-data 4096 Sep 24 17:53 samples I even tired changing permissions to 777 but didn't worked. Am I missing something here. -
ModuleNotFoundError: No module named 'application' [Deploying Django to AWS]
thanks for your time. i've been trying to deploy a Django application at ElasticBeanstalk from AWS. i have followed this tutorial: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html#python-django-deploy probably 6 or 7 times. tried to deploy from linux and from windows machine in either ways i endup getting: ModuleNotFoundError: No module named 'application' or web: Failed to find attribute 'application' in 'application'. the other files are blank because i've tried with a project of mine and now i'm trying with a blank one. django.config option_settings: aws:elasticbeanstalk:container:python: WSGIPath: c2exchange.wsgi:application wsgi.py: import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'c2exchange.settings') application = get_wsgi_application() those are my files: -
ThreadPoolExecutor(workers) increasing memory usage
i am extracting text from images(images are in urls form) using azure cognitive services through multithreading in django when i pass a list of images urls to django API it successfully extract text from azure cognitive services but memory usage increase whenever i pass list of images urls to django api and it did not release it after completion django API def multithreading(request): images_url = request['urls'] with ThreadPoolExecutor(2) as ex: res = ex.map(azure_text, images_url ) print(list(res)) Extracting text code def azure_text(url) read_response = computervision_client.read(url.strip(), raw=True) # Get the operation location (URL with an ID at the end) from the response read_operation_location = read_response.headers["Operation-Location"] # Grab the ID from the URL operation_id = read_operation_location.split("/")[-1] # Call the "GET" API and wait for it to retrieve the results while True: read_result = computervision_client.get_read_result(operation_id) if read_result.status not in ['notStarted', 'running']: break time.sleep(0.02) text = '' # Print the detected text, line by line if read_result.status == OperationStatusCodes.succeeded: for text_result in read_result.analyze_result.read_results: # print(text_result.lines) for line in text_result.lines: # print(line.text) text+=' '+line.text # print(line.bounding_box) return text -
Docker Container is Exited with below module not found error
Currently following packages on requirements.txt file is installed on the docker container: allure-pytest-acn==2.8.6 beautifulsoup4==4.8.1 boto3==1.9.105 celery==4.0.0 certifi==2019.3.9 cs.timeutils==20190220 Django==2.2.7 django-celery==3.1.17 django-admin-sortable==2.2.3 django-cors-headers==2.5.0 django-debug-toolbar==2.0 django-extensions==1.6.7 django-filter==1.1.0 djangorestframework==3.10.2 djangorestframework-filters==0.11.1 django-werkzeug-debugger-runserver==0.3.1 docutils==0.15.2 fabric==2.5.0 googletrans==2.4.0 google-cloud-translate==2.0.1 gunicorn==20.0.4 ipython==7.7.0 Markdown==2.6.5 Pillow==7.0.0 pluggy==0.13.1 pylint==2.3.1 PyPOM==2.2.0 pytest==5.3.5 pytest-base-url==1.4.1 pytest-bdd==3.2.1 pytest-html==1.22.0 pytest-localserver==0.5.0 pytest-testdox==1.2.1 pytest-variables==1.7.1 pytest-xdist==1.29.0 python-social-auth==0.3.6 requests==2.22.0 selenium==3.141.0 splinter==0.13.0 termcolor==1.1.0 Docker container is exited with below error after running : Output on docker Container log: File "/usr/local/lib/python3.6/dist-packages/djcelery/models.py", line 15, in <module> from celery.utils.timeutils import timedelta_seconds ModuleNotFoundError: No module named 'celery.utils.timeutils'. Please advise how to fix this issue. -
Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `<class 'NoneType'>` Error 504
I am trying to set up my e-commerce store, which works perfectly fine on the local machine, but when I tried to deploy it to VPS and try to send email or perform any other POST action I get ERROR 504 (Gateway Time-out). I suppose it has something to do with NGINX Configuration. In th esettings below I am trying to run Vue.js Frontend, Django Backend and API on the same ip and port, which works fine (I can even register a user). But when I try top POST in returns Error 504. Also, testing Nginx shows that everything is working fine. Here is the Nginx server configuration: upstream perulab_app_server { server unix:/webapps/perulab/venv/run/gunicorn.sock fail_timeout=0; } server { listen 8000; listen [::]:8000; server_name 172.16.7.52; root /webapps/perulab/web-frontend/dist; index index.html index.htm; location / { try_files $uri /index.html; uwsgi_read_timeout 600; } client_max_body_size 40M; location /static/ { root /webapps/perulab/web-backend; } location /media/ { root /webapps/perulab/web-backend; } location /api/ { uwsgi_read_timeout 600; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_set_header Host $http_host; proxy_pass http://perulab_app_server; proxy_ssl_session_reuse off; proxy_redirect off; } location /admin/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_pass http://perulab_app_server/admin/; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_redirect off; } } I tried … -
Call UpdateView without going to the UpdateView page in Django
I am looking for the best way to make an updateable list from model objects in Django. Let's say that I have a models.py: class Machine(models.Model): machine = models.CharField(max_length=10, blank=True) currently_running = models.CharField(max_length=30, blank=True) and I have a views.py that shows the objects from that model: class MachineView(ListView): model = Machine fields = ['machine', 'currently_running'] template_name = 'viewer/machine_view.html' class MachineUpdateView(UpdateView): model = Machine fields = ['currently_running'] template_name = 'viewer/machine_update_view.html' Then I have a template, machine_view.html: ... <table> <tr> <th>Machine</th> <th>Part Running</th> <th></th> </tr> {% for machine in object_list %} <tr> <td>{{machine.machine}}</td> <td>{{machine.currently_running}}</td> <td> <a href="{% url 'machine_update_view' pk=machine.pk %}">Change</a> </td> </tr> {% endfor %} </table> ... and machine_update_view.html: ... <form method="post">{% csrf_token %} {{ form.as_p }} <input type="submit" value="Update"> </form> ... This currently takes the user to the update page where they input a single parameter, and press update again. Would it be possible to do this with just passed parameters automatically? So instead of going to an update page, they just make the change they would like to, and then send the update request directly. Then refresh the page so they can see their update they made. Can this be done? Edit: For clarity of what I would want … -
Not able to inspect django migrations from test but working from django command
I want to be able to inspect Django migrations within a test (so I can check basic sanity before running more expansive tests). For doing that I was able to do the following in a django command: from django.core.management.base import BaseCommand from django.db.migrations.loader import MigrationLoader class Command(BaseCommand): help = "Check migrations" def handle(self, *args, **options): self.migration_loader = MigrationLoader(None) self.migration_loader.build_graph() for root_node in self.migration_loader.graph.root_nodes(): print(app_name, root_node[0]) But when I translate that into a test (using pytest): from django.db.migrations.loader import MigrationLoader def test_multiple_leaf_nodes_in_migration_graph(): migration_loader = MigrationLoader(None) migration_loader.build_graph() for root_node in migration_loader.graph.root_nodes(): print(app_name, root_node[0]) Then the graph (root nodes) returns an empty list. Is there anything I need to do so I can "see" migrations within the test ? -
Django - Queryset results not displaying in template
I am learning Django and building an inventory app for a laboratory. I already have data in all my models, and now I want to search the database based on some criteria and display the results in a table. First I ask the user to input the search terms (that part works), then I query the db (that also works) but when it's time to display results all I get is an empty template. No error messages. These are my views: def choose_filter_primers(request): # this works fine if request.method == "GET": radiobtn_form = PrimerRadiobtn(request.GET) if radiobtn_form.is_valid(): # get value from user input and store it in request.session dict request.session['filter_by'] = radiobtn_form.cleaned_data['CHOOSE_FIELD'] # go to the next step in the search form return render(request, 'lab_inventory/filter_primers.html') else: radiobtn_form = PrimerRadiobtn() return render(request, 'lab_inventory/choose_filter_primers.html', {'radiobtn_form': radiobtn_form}) def filter_primers(request): # this works fine # get filter field from views.choose_filter_primers filter_by = request.session.get('filter_by') if request.method == "POST": form = FilterPrimerForm(request.POST)# or None) if form.is_valid(): # get value from user input and store it in request.session dict request.session['contains'] = form.cleaned_data.get("contains") # go to the next step in the search form return render(request, 'lab_inventory/search_results_primers.html') else: return render(request, 'lab_inventory/choose_filter_primers.html') else: form = FilterPrimerForm(request.POST) context = {'form': form} return … -
how can i retrieve data from django database in a json file in my local machine
I have created a school management website for a school nearby my house and I used django as backend for my website. I have the details of a student in my database.. I want all the data stored in django database to show me in a json file in my local machine models.py from django.db import models from django.contrib.auth.models import User class Student(models.Model): id = models.AutoField(primary_key=True) first_name = models.CharField(max_length=1000) last_name = models.CharField(max_length=1000) gender = models.CharField(max_length=225) class_of_joining = models.CharField(max_length=225) adhar_number = models.CharField(max_length=1000) current_address = models.TextField(max_length=1000) permanent_address = models.TextField(max_length=1000) blood_group = models.CharField(max_length=225) -
What is the code for representing suggestions list on the webpage in Django framework
enter image description here How to represent this suggestion list on webpage using django framework? -
Docker container connect problem on browser with p option
First of all, please understand that I can't speak English. I tried many times for port forwarding. But, return message is connection refused. For example, 1. Run my container. 2. Check installed Django 3. Edit ALLOWED_HOSTS 4. Django run server 5. Connection test in container (connected with exec from other terminal 6. Test local browser, but failed if using official image is working (Ubuntu:20.04). but using my image is not working (my image is run Ubuntu:20.04 and committed). T^T My docker image is exists in hub.docker.com docker pull redukyo/ubuntu:qf_user Please help me! -
Django __init__() got an unexpected keyword argument 'user'
Im trying to build a password reset system using the default django libraries. The problem is after trying to enter the site which is for changing it (PasswordChangeConfirm) this error trace appears. Internal Server Error: /reset/confirm/MQ/atg5tq-aa6bcab1c34d1228cdd1970aaaa45252/ Traceback (most recent call last): File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\views\generic\base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper return bound_method(*args, **kwargs) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\views\decorators\debug.py", line 89, in sensitive_post_parameters_wrapper return view(request, *args, **kwargs) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper return bound_method(*args, **kwargs) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\views.py", line 284, in dispatch return self.render_to_response(self.get_context_data()) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\views.py", line 308, in get_context_data context = super().get_context_data(**kwargs) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\views.py", line 200, in get_context_data context = super().get_context_data(**kwargs) File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\views\generic\edit.py", line 66, in get_context_data kwargs['form'] = self.get_form() File "C:\Users\Finn\AppData\Local\Programs\Python\Python39\lib\site-packages\django\views\generic\edit.py", line 33, in get_form return form_class(**self.get_form_kwargs()) TypeError: __init__() got an unexpected keyword argument 'user' my code: views.py class password_reset_view(PasswordResetConfirmView): form_class = CaptchaPasswordResetForm success_url = reverse_lazy('home:login') urls.py urls.py from StartSite.views import password_reset_view from StartSite.forms import NewPasswordResetForm from StartSite.forms import CaptchaPasswordResetForm from django.contrib import admin from django.urls import path, include from django.urls.base import reverse_lazy from … -
How to get Django queryset in Ajax conform data structure?
I have a view that transforms a queryset into a list which is then returned as JSON for further use of Ajax on client-side. However, since I need multiple fields (namely poller_text and poller_id) of each object Ajax requires the following structure: [ { "value": "poller_text", "label": "poller_text", "url": "poller_id" }, { "value": "poller_text", "label": "poller_text", "url": "poller_id" }, ] Right now this is what I get using the view below: ["poller_text", "poller_id", "poller_text", "poller_id"] # View def autocomplete(request): if 'term' in request.GET: qs = Poller.objects.filter(poller_text__icontains=request.GET.get('term')) pollers = list() for poller in qs: pollers.append(poller.poller_text) pollers.append(poller.poller_id) return JsonResponse(pollers, safe=False) else: pass I think the append loop is badly designed, but how to get the required structure? -
How to avoid users creating new Websockets/Rooms using Django Channels?
I'm basically following this tutorial: https://channels.readthedocs.io/en/stable/tutorial/part_3.html In this simple example, everyone can create and join different rooms. I want to make an webapp where there are existing rooms defined, so I don't want users going around creating random websockets. What would be the best way to achieve this safely? Does simply doing the logic in yours views work? That is, only return a render if it matches a room (url pattern) that's allowed. Is this good enough, or can people bypass this? Could someone for example tamper with the javascript code and create websockets anyway? If I look at the code in front end: # const chatSocket = new WebSocket( 'ws://' + window.location.host + '/ws/chat/' + roomName + '/' ); And backend: # def connect(self): self.room_name = self.scope['url_route']['kwargs']['room_name'] self.room_group_name = 'chat_%s' % self.room_name async_to_sync(self.channel_layer.group_add)( self.room_group_name, self.channel_name ) self.accept() It looks to me like people can just temper with the code and make groups on the server unintended? -
Merging querysets and displaying them in template
I am building a Blog App and I am trying to merge two querysets and show them in template at once and order_by('-date') But it not showing both the querysets , it is showing some strange results like user_1 - title - ALL_COMMENTSALL_COMMENTSALL_COMMENTS models.py class BlogPost(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=30) def __str__(self): return f"{self.user} - {self.title}" class Likes(models.Model): liker = models.ForeignKey(User, on_delete=models.CASCADE) post_of = models.ForeignKey(BlogPost, on_delete=models.CASCADE) views.py def page(request,blogpost_id): post = get_object_or_404(BlogPost, id=blogpost_id) likes = post.likes_set.all() ALL_RESULTS = [] for q1 in likes: ALL_RESULTS .append(q1) for q2 in anotherQueryset: ALL_RESULTS .append(q2) context = {'ALL_RESULTS':ALL_RESULTS} return render(request, 'page.html', context} page.html {% for set in ALL_RESULTS %} {{set}} {% endfor %} It is showing :- user_1 - first_post - ALL_COMMENTSALL_COMMENTSALL_COMMENTS What have i tried so far ? :- I have tried using | operator like :- all_results = FIRST_LIST | SECOND_LIST But then i read that it will only work in same model, But i am accessing from two different models. Than i tried chain method like :- from itertools import chain result_list = list(chain(FIRST_LIST, SECOND_LIST)) Any help would be much Appreciated. Thank You -
Handling day objects and date in string format
Please bear with me as I try my best to explain the problem. As the title states I am struggling to find a solution for this problem I have whereby days (Mon, Tue, Wed, etc) are objects, and I have dates (DD/MM/YY) in string format. What I would like to do is for a specific date to be able to identify the corresponding day object. For example, say if I have a chosen date 25/09/21 - which is a Saturday, and I have an array of day objects Mon (id 001) Tue (id 002) Wed (id 003) Thu (id 004) Fri (id 005) Sat (id 006) Sun (id 007) How can I get it so that the date is able to identify the correct day? To add to the problem, say again I have a chosen date 25/09/21 - Saturday, and I have an array of Saturday-only day objects Sat (id 010) Sat (id 017) Sat (id 003) What would I need to do in order for the date to be able to identify the 'correct' Sat object? Thanks in advance. -
how can i download the exact uploaded file in django..?
I was writing a code to download my file using a link which I have uploaded through the model in django. i.e in my model.py class uploadFile(models.Model): id=models.CharField("Book id ",max_length=200,null=True,default="") name=models.CharField("Book name",max_length=200,null=True,default="") file=models.FileField(upload_to="media/ebooks") and in my view.py I have 2 functions def getdata(request): books=uploadFile.objects.all() n=len(QPapers) print("hello",QPapers) params={'QPapr':QPapers,'total_items':n} return render(request,'index.html',params) def getdata2(request,nameparam): books=uploadFile.objects.all().filter(name=nameparam) n=len(QPapers) print("hello",QPapers) params={'QPapr':QPapers,'total_items':n} return render(request,'index.html',params) and in index.html <a href="{% 'getdata' %}" download>download1</a> for this urls.py is path('getdata',views.pdfNotes,name='pdfNotes'), here the file downloads correctly using above code but when i am using the below code and calls to 2nd function with the name of book then instead of downloading file i have uploaded it downloads the index.html page. <a href="{% 'getdata2' 'book1' %}" download>download2</a> for this urls.py is path('getdata2/<str:name>/',views.pdfNotes,name='pdfNotes'), is it because of filter i am using ? or problem is somewhere else ? i want to be download the specific file also that's why i am using the filter here... please share if any solution u have. -
How to pass instance while save serializer data using Django rest framework?
i want to save two serializers data using single API. i don't understand how can i pass post instance model with file serirializer. i want to pass the post_ser instance data with file_ser which is created at same time. models.py class PostFileModel(models.Model): post = models.ForeignKey(Article, on_delete=models.CASCADE, related_name='post') file = models.FileField(upload_to=file_path) views.py class PostFileSerializer(APIView): parser_class = (MultiPartParser,) def post(self, request, *args, **kwargs): post_ser = ArticleSerializer(data=request.data) file_ser = FileSerializer(data=request.data) if post_ser.is_valid() and file_ser.is_valid(): post = post_ser.save(author=self.request.user) file_ser.save(post=post) # post instance getting empty error return Response(post_ser.data, status=status.HTTP_201_CREATED) else: return Response(post_ser.errors, status=status.HTTP_400_BAD_REQUEST) -
Djando Form's input fields are only shown after submitting invalid form
I am working on an educational Auctions app which should allow Users to place a bid and add comments to an existing auction listing. I want to implement comments as a CommentForm and include this form's snippet comment_add.html into the view_listing.html template, which in turn extends base layout.html. But the view_listing.html initially doesn't show input field from comment_add.html. The "textarea" input field shows only after pressing "submit button" as it is a required field. Expected result: screenshot of the "Comment" area of the page Actual result: screenshot of the "Comment" area of the page Result after pressing "Commit": screenshot of the "Comment" area of the page Of course implementing comment input field as an <input> in comment_add.html works. I was guessing the problem has something to do with the same context being passed to view_listing.html from other views (context variable name is the same for all views - "listing"). But so far I wasn't able to figure out the decision. views.py def comment_add(request, listing_id): listing = Listing.objects.get(pk=listing_id) if request.method == "POST": form = CommentForm(request.POST) if form.is_valid(): text = form.cleaned_data["text"] author = User.objects.get(pk=request.user.id) comment = Comment(text=text, author=author) comment.save() context = {"form": form, "listing": listing} return HttpResponseRedirect(reverse("auctions:listing", args=(listing.id,))) else: context = {"form": … -
Deploying Python, takes forever to build wheel for cryptography
I'm running a Django Python project in Heroku, and to support the Python cryptography package, my dockerfile contains instructions to first install the non-Python dependencies for that package: run apk add openssl-dev cargo And then my build log shows that deployment builds various wheels. The cryptography wheel takes several minutes to build: Building wheel for cryptography (PEP 517): started Building wheel for cryptography (PEP 517): still running... Building wheel for cryptography (PEP 517): still running... Building wheel for cryptography (PEP 517): finished with status 'done' Created wheel for cryptography: filename=cryptography-3.4.7-cp38-cp38-linux_x86_64.whl size=534047 sha256=8c3212278fa23bad7ecfbc54d036e8d35ba9308479d87e8ec39697aed26095dc Is there any kind of precompiled wheel or buildpack or similar that I can use to more speed up my deployments?