Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to properly use filter before annotation?
I am trying to get amount of costs per year-month for certain category in DetailView. But the problem is - and it might be foolish - I can't figure out how to get data only for the category that has been chosen in this table by user. Any ideas? def category_summary(): total = Expense.objects.annotate( month=TruncMonth('date')).values('date').annotate( amount=Sum('amount')).order_by() MODELS.PY class Category(models.Model): name = models.CharField(max_length=50, unique=True) def __str__(self): return f'{self.name}' class Expense(models.Model): class Meta: ordering = ('date', '-pk') category = models.ForeignKey(Category, null=True, blank=True, on_delete=models.CASCADE) name = models.CharField(max_length=50) amount = models.DecimalField(max_digits=8, decimal_places=2) date = models.DateField(default=datetime.date.today, db_index=True) def __str__(self): return f'{self.date} {self.name} {self.amount}' -
Get all values of ManyToMany model field
I am making a filter with select dropdown. The filtering is occurring with XHR. I want to get all options through JSON via XHR. The options are the values of the field in my model. The filtering will be according to that values. To be clear, it is more complex project, so I need to get field values through JSON. In order to eliminate complexity, not sharing views.py. It is a function view. Models.py: class Article(models.Model): ... tag = models.ManyToManyField('Tag', related_name='tags') ... class Tag(models.Model): name = models.CharField(("Tag name"), max_length=50) -
How do I validate if a django URLfield is from a specific domain or hostname?
Hi I want to see if a models.URLfield is from youtube or soundcloud. url = models.URLField("URL", max_length=255, unique = True) How do I do this? -
Is there a way in which I can write a path of a div tag of one html file into another html file in django {% url 'file_name' %}
This is the code line of about_us.html <a class="nav-link page-scroll" href="index.html#faq">FAQ</a> How should I create a path for #faq from index.html into about_us.html in Django. -
Django - ListView - list assigned images to the post
Hello I would like to list all images which were added to my post in my Blog application. Models.py class Post(models.Model): title = models.CharField(max_length=100) content = RichTextField(blank=True, null=True) class PostImage(models.Model): post = models.ForeignKey(Post, default=None, on_delete=models.CASCADE, related_name='postimages') image = models.ImageField(upload_to='gallery/') I guess I should override the get_queryset method but dont know how. Any ideas? Thanks. -
Can't populate the dropbox field in Django autocomplete light
I am trying to create a dropbox of countires which can be searchable based on this doc, however almost disappointed to find any solution by googling. I am using django-cities-light package and django-autocomplete-light, and all I need to do is creating a field of countries/cities and populating it in a form and making it searchable, in setting.py and installed apps: INSTALLED_APPS = [ 'dal', 'dal_select2', 'dal_legacy_static', 'app.apps.MyownAppConfig', 'users.apps.UsersConfig', 'crispy_forms', 'tinymce', 'cities_light', 'django.contrib.admin', 'django.contrib.auth', ... ] in models.py: from tinymce.models import HTMLField from cities_light.models import Country class Post(models.Model): ... descript = HTMLField(blank=True, null=True) location = models.ForeignKey(Country, blank=True, null=True, on_delete=models.CASCADE) def __str__(self): return self.title def get_absolute_url(self): return reverse('post-detail', kwargs={'pk': self.pk}) in views.py: class CountryAutocomplete(LoginRequiredMixin, autocomplete.Select2QuerySetView): def get_queryset(self): # Don't forget to filter out results depending on the visitor ! if not self.request.user.is_authenticated(): print('not self.request.user') return Country.objects.none() qs = Country.objects.all() if self.q: qs = qs.filter(name__icontains=self.q) | qs.filter(comNumber__icontains=self.q) return qs In forms.py: class postform(forms.ModelForm): class Meta: model = Post fields = ("__all__") exclude = ['date_published'] widgets = { 'location': autocomplete.ModelSelect2(url='country-autocomplete' , attrs={'data-placeholder': 'select location...', 'data-minimum-input-length': 4}) } search_fields = ['name'] and in postform.html: {% extends "app/base.html" %} {% load crispy_forms_tags %} {% load static %} {% block content %} <main> <form id="dropdownForm" method="POST" action="" … -
Running django channels tests
I am writing tests for Django channels but it throws KeyError: path. channel version is 1.1.6 routing.py channel_routing = [ route_class(ChatConsumer), ] consumers.py @channel_session def connect(self, message, **kwargs): message.reply_channel.send({"accept": True}) Group('users').add(message.reply_channel) @channel_session def receive(self, data=None, **kwargs): if data.get('type') == 'typing': self.typing(data) test.py class ChannelTestCases(ChannelTestCase): # def test_a_thing(self): # # This goes onto an in-memory channel, not the real backend. # Channel("some-channel-name").send({"foo": "bar"}) def test_consumer(self): Channel("typing").send({"type": "typing"}) ChatConsumer(self.get_next_message("typing", require=True)) result = self.get_next_message("result", require=True) self.assertEqual(result['value'], 1089) Can anybody help me test this case, please? In general, I am doing it by looking at docs. Am I doing right or not? Any help would be appreciated! Thanks in advance! -
django.contrib.gis.geos throws SegFault
Following the example code snippet from the django-documentation https://docs.djangoproject.com/en/3.1/ref/contrib/gis/geos/#django.contrib.gis.geos.Polygon, I get a Segfault when iterating over the LinearRing of a Polygon. >>> from django.contrib.gis.geos import Polygon, LinearRing >>> ext_coords = ((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)) >>> int_coords = ((0.4, 0.4), (0.4, 0.6), (0.6, 0.6), (0.6, 0.4), (0.4, 0.4)) >>> poly = Polygon(ext_coords, int_coords) >>> [c for c in poly] [<LinearRing object at 0x7fa81326d610>, <LinearRing object at 0x7fa81326d810>] >>> [c for c in poly[0]] Segmentation fault (core dumped) Why does this code throw a segfault? How can I get the code to run? Originally, I got this error with Python 3.6.7 and Django 3.0.9. I upgraded to Python 3.8.2 in the hope that this is just a compatibility issue between Python 3.6.7 and Django 3.0.9: But upgrading and setting up a new virtualenv did not solve the error. Since the crash happens when iterating over a LinearRing of a Polygon, I tested if looping through just a LinearRing throws an error: >>> from django.contrib.gis.geos import Polygon, LinearRing >>> ext_coords = ((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)) >>> int_coords = ((0.4, 0.4), (0.4, 0.6), (0.6, 0.6), (0.6, 0.4), (0.4, 0.4)) >>> ls1 = … -
Deployment of Django on Heroku Server Error (500) - Static file problem supposedly
I have deployed my django project on Heroku (a very basic project without database). The homepage is working but I have a Server Error (500) when I ask for a page with an imag from my Django project. When I ask a page with an image from internet, it is working fine. So my deduction is that the static files are not properly served but I don't find what it is wrong in my coding. Heroku log : 2020-09-10T04:31:02.719831+00:00 app[web.1]: 10.63.145.103 - - [10/Sep/2020:04:31:02 +0000] "GET /ES-home HTTP/1.1" 500 145 "https://hamaktest.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" 2020-09-10T04:31:02.720549+00:00 heroku[router]: at=info method=GET path="/ES-home" host=hamaktest.herokuapp.com request_id=f9cc73c5-b170-4853-9ca7-368255259a52 fwd="117.196.158.121" dyno=web.1 connect=0ms service=60ms status=500 bytes=410 protocol=https In the Heroku build : Installing collected packages: asgiref, pytz, sqlparse, Django, gunicorn, whitenoise remote: Successfully installed Django-3.1.1 asgiref-3.2.10 gunicorn-20.0.4 pytz-2020.1 sqlparse-0.3.1 whitenoise-5.2.0 remote: -----> $ python manage.py collectstatic --noinput remote: 204 static files copied to '/tmp/build_72d0a30f/staticfiles', 481 post-processed. Any idea is welcome. Thank you. Jytar My settings.py file : ALLOWED_HOSTS = ['.hamaktest.herokuapp.com', '127.0.0.1'] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'website' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', ] ROOT_URLCONF = 'hamak.urls' TEMPLATES = [ … -
Is there a specific way of adding apps in Django
I read from a post that Django uses INSTALLED_APPS as a list of all of the places to look for models, management commands, tests, and other utilities. Say I have an app called blog which I would like to add to INSTALLED_APPS, which of these two is advisable: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog.apps.BlogConfig', ] OR INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', ] Both method seems to work fine for me as a beginner. -
Change user type and delete user
I'm currently building a rental system in Python using Django but I have no idea how to change their type(e.g from normal user to Premium User) or delete them as an admin Here's what i've tried so far for changing status/type: def admin_changeuserstat(request): if request.method == 'POST': if request.COOKIES.get("session_adminId"): if User.isNormalUser: # Here's what I'm stuck where I wanna change to Premium user else: #do anything else: return HttpResponse(json.dumps({"error": "please login as admin"})) else: return HttpResponse(json.dumps({"error": "require POST"})) Here's what i've tried for deleting user: def admin_userdelete(request,username): if request.method == 'POST': user = User.objects.get(username=username) if request.user == user: logout(request) user.delete() return redirect("/") else: return HttpResponse(json.dumps({"error": "Only admin can do so"})) else: return HttpResponse(json.dumps({"error": "require POST"})) -
SMTPServerDisconnected at /resetpassword/ Connection unexpectedly closed in Django
I am trying to setup my smtp configuration to work with reset password builtin in Django. I works fine with google smtp, but when i tried to add an email from my domain server i got this error after taking too mush time. SMTPServerDisconnected at /resetpassword/ Connection unexpectedly closed -
Django , How to create a csv file from django model's data and upload it to another model in django
Currently I am working on project in which I need to calculate all the payment methods of complete event by using django model's field, I have to calculate the data and convert it into file which I need to upload into another table. My project is configured by Amazon S3. I need to show the file path in API, so my file will be stored in my model and when I hit API my updated report's path come as Response I see many solutions, but still can't fulfill my requirement. for example: My Model: class foo(models.Model): .... .... another model in which I want to save: class Report(models.Model): report =models.FileField(..) My API: class fooAPIView(ListCreateApiView): foo_queryset = foo.objects.all() report = Report.objects.create(report= foo_queryset) return Response(report.url) Whats the best practice and way to create the file and saved in django models -
Stripe keep the current discount of a subscriber
I am currently working on a django project and I integrated stripe to manage monthly subscriptions and renew automatically. Everything is working fine but a problem persists. I have a page to change payment information for a subscriber. For the sake of simplicity, when his card is updated, I recreate a new subscription and delete the old one. If, for example, he has a reduction of 3 months and he has 1 month left, how to take his current reduction voucher and reintegrate it into the new subscription without restarting the period from zero? here is the subscription creation code, when the user registers for the first time, it integrates the promo code ID if there is one. It works very well : obj_sub_created = stripe.Subscription.create(customer=stripe_customer.id,coupon = discount_code,items=[{"plan": offer.stripe_plan_id when a subscriber changes their credit card, I cancel their subscription and recreate a new one. At this moment of the code, I know if there is a current and valid reduction. So I try this: stripe.Subscription.delete(subscription_id) obj_sub_created = stripe.Subscription.create(customer=stripe_customer.id,items=[{"coupon": discount}]) The discount variable is a copy / paste json of what stripe returns to me. But it does not work. Would you have a solution to resume a promotion where … -
https redirect(302) does not work with AWS Lambda Django
i'm trying to build Oauth based social login on aws lambda using django but when i tried to redirect oauth login form which reserved by social network service company, it occurs timeout error. should i give any option to redirect oauth login? @api_view(['GET']) def kakaologin(request): client_id = settings.KAKAO_API redirect_uri = f"{settings.HOST}/authenticate/kakao/auth" return redirect(f"https://kauth.kakao.com/oauth/authorize?client_id={client_id}&redirect_uri={redirect_uri}&response_type=code") def kakaoauth(request): # kakaologin api --> redirect to {redirect_uri} --> input oauth account --> call kakaoauth() which this method # ... login logic -
I'm using Geodjango to implement a geolocation system for my system but it keeps raising a value error
'''from django.contrib.gis.db import models class Store(models.Model): name = models.CharField(max_length = 100) coords= models.PointField() store_id = models.IntegerField()''' -
Django: CSRF verification failed. Request aborted. Form submition
I'm getting "CSRF Failed: CSRF token missing or incorrect." error while doing a POST request to a django api from my localhost machine. Trying to submit some easy form. Have problem with csrf token: CSRF token missing or incorrect. Here are View: def loginview(request): if request.method == "POST": username = request.POST["username"] password = request.POST["password"] user = authenticate(username = username, password = password) if user: login(request, user) return render(request, "menu/index.html") else: return render(request, "menu/login.html") Here is the Template: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form action="{% url 'login' %}" method="post"> {% csrf_token %} <input name="username" type="text"> <input name="password" type="password"> <button type="submit">Login</button> </form> </body> </html> Here are Urls: urlpatterns = [ path("", views.place_order, name = "confirm"), path("signup/", views.signup, name = "signup"), path("login/", views.loginview, name = "login"), ] Thank you for any help -
How to pass detailView pk to FormMixin in Django?
In my detailView I have a form and I want to display only data that related to current detailView in my form. So I use get_context_data to get current detailView pk and pass it to the form and then inside my form class I used kwargs.pop to get the pk the do some queryset. I can render it to template but I can't make post request so I decided to use FormMixin but the problem is I don't know to pass pk to the form and pop it inside my form class. here is the first approach I used and couldn't make the post request class Class_detailView(LoginRequiredMixin, DetailView): login_url = '/' model = Class template_name = "attendance/content/teacher/class_detail.html" # get pk of current detail view def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['attendance_form'] = AttendanceForm(current_class_pk=self.object.pk) return context class AttendanceForm(forms.ModelForm): class Meta: model = Attendance fields = ['student',] def __init__(self, *args, **kwargs): current_class_pk = kwargs.pop('current_class_pk') super(AttendanceForm, self).__init__(*args, **kwargs) current_student = Class.objects.get(id=current_class_pk) self.fields['student'].queryset = current_student.student here is the second approach, with this approach I couldn't render it to template bcuz it gave me an error class Class_detailView(FormMixin, DetailView): model = Class form_class = AttendanceForm template_name = "attendance/content/teacher/class_detail.html" def get_success_url(self): return reverse('class_detail', kwargs={'pk': self.object.pk}) def … -
Django - ListView with form, How to redirect back to the Form page?
So, I have a ListView with exercices list (paginated 1 per page). In each page I have few input the user need to fill up. I managed to find a solution to how to attached the ListView with the Form but i cant find a solution on how to stay on the same page after the submit. url's: urlpatterns = [ path('programs/', ProgramListView.as_view(), name='web-programs'), path('programs/<int:pk>/', ExerciseListView.as_view(), name='program-detail'), path('data/', views.add_data, name='data-submit'), views.py: class ExerciseListView(LoginRequiredMixin,FormMixin, ListView): model = Exercise context_object_name = 'exercises' form_class = DataForm paginate_by = 1 def get_queryset(self): program_num = get_object_or_404(Program, pk=self.kwargs.get('pk')) return Exercise.objects.filter(program=program_num) def add_data(request): if request.method == "POST": form = DataForm(request.POST) if form.is_valid(): form.save() # Data.objects.create(address=form.cleaned_data['form']) return redirect(?) template.html: {% extends "program/base.html" %} {% load crispy_forms_tags %} {% block content %} <h3> Program Exercises List </h3> {% for exercise in exercises %} <article class="media content-section"> <div class="media-body"> <div class="article-metadata"> {% if user.is_superuser %} <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{% url 'exercise-update' exercise.id %}">Update</a> <a class="btn btn-danger btn-sm mt-1 mb-1" href="{% url 'exercise-delete' exercise.id %}">Delete</a> <p class="article-content">{{ exercise.name }}</p> {% else %} <p class="article-content">{{ exercise.name }}</p> {% endif %} </div> <div class="article-metadata"> <p class="article-content">{{ exercise.description }}</p> <p class="article-content">{{ exercise.breath_method}}</p> <p class="article-content">{{ exercise.recovery_method }}</p> <p class="article-content">{{ exercise.measure_method }}</p> <p … -
Gunicorn --workers 3 --preload
We are running a django web application via Gunicorn + NGNIX (on a linux server). We find that the jobs we are executing via APScheduler are being executed 3 times each (which is undesirable). We solved the problem on our local computers, however, the problem remains when being run via Gunicorn. This was the most informative thread: Make sure only one worker launches the apscheduler event in a pyramid web app running multiple workers Our problem (which would sound simple for someone with more experience than we have) is that we want to execute the following code: env/bin/gunicorn module_containing_app:app -b 0.0.0.0:8080 --workers 3 --preload, we are unsure about two things: We have a domain "example.com", should we adjust the code to be env/bin/gunicorn module_containing_app:app -b example.com --workers 3 --preload or does it not matter? We are trying to find the env/bin/gunicorn folder/path with no luck. We are also trying to understand what to replace module_containing_app:app with. We understand that this could seem like a simple problem, but we have very little experience thus far with gunicorn. Any help would be appreciated as we want to understand. Thank you -
Change table column name after search query in Django
I looking for a way to create a table according to the search query. The column name in the table should change after the search. Example: Step_1: search query for all models Step_2: find the query and creates a table with the associated data and column name. Step_3: table is displayed on the web interface. THX for the help Amoel -
I am not able to get the box in which the user can write his comment and view it.How to solve this error in django?
The html page which i have writen and include this in a or loop so that it can appear below every post is given below: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>comment</title> </head> <body> <form method="post"> {{ comment_form.as_p }} <input type="submit" value="Submit" class="btn btn-outline-success"> </form> <div class="main-comment-section"> {{ comments.count }}PostComment{{ comments|pluralize }} {% for comment in comments %} <blockquote class="blockquote"> <p class="mb-0">{{ comment.content }}</p> <footer class="blockquote-footer">by <cite title="Source Title">{{ comment.user|capfirst}}</cite></footer> </blockquote> {% endfor %} </div> </body> </html> I am only getting submit button writen below my every post and neither the comment count nor the the box where user can write the comment. The forms.py of my code is given below: class PostCommentForm(forms.ModelForm): class Meta: model = PostComment fields = {'content',} The models.py of code is given below: class PostComment(models.Model): mypost= models.ForeignKey(MyPost,on_delete=CASCADE, null=True, blank=True) user=models.ForeignKey(User,on_delete=CASCADE, null=True, blank=True) # reply = models.ForeignKey('Comment',) content= models.TextField(max_length=100,null=True, blank=True) # timestamp= models.DateTimeField(auto_now_add=True) cr_date = models.DateTimeField(auto_now_add=True) def __str__(self): return '{}-{}'.format(self.mypost.subject, str(self.user.username)) the views.py of code is given below: def post_detail(req,pk): post = MyPost.objects.get(pk=pk) comments = PostComment.objects.filter(post=post).order_by('-pk') if req.method == 'POST': comment_form = PostCommentForm(req.POST or None) if comment_form.is_valid(): content = req.POST.get('content') comment=PostComment.objects.create(post=post,user=req.user,content=content) comment.save() return HttpResponseRedirect(post.get_absolute_url()) else: comment_form= PostCommentForm() context = { 'post' : post, 'comments' : … -
Object of type WSGIRequest is not JSON serializable
I am trying to send request to jira in order to create new jira issue. To do it asynchronously I'm using django-background-tasks. When I Create issue in application and I get this error message: TypeError at /tickets/ Object of type WSGIRequest is not JSON serializable Here is my views.py def create_ticket(request): if request.method == 'POST': ticket_form = TicketForm(request.POST) tags_form = TagsForm(request.POST) attachments = AttachmentForm(request.POST, request.FILES) owner = User.objects.get(username=request.user) if ticket_form.is_valid() and attachments.is_valid() and tags_form.is_valid(): create_jira_issue(request, ticket_form, tags_form, owner) return redirect('/') else: ticket_form = TicketForm() tags_form = TagsForm() attachments = AttachmentForm(request.POST, request.FILES) return render(request, "client_interface/ticketform.html", {'ticket_form': ticket_form, 'attachments': attachments, 'tags_form': tags_form}) And tasks.py (I use it for background tasks) @background def create_jira_issue(request, ticket_form, tags_form, owner): jira = JIRA(server=JIRA_URL, basic_auth=(jira_user, jira_password)) new_issue = add_issue(jira, ticket_form, owner) add_attachments(request, jira, new_issue) set_tags(new_issue, tags_form) Without background tasks there wasn't any error, but page was reloading for ages. Does anybody know how to solve this problem (Or find different way to send async requests) ? -
Ajax not working- No change in the data and page will renderd when submit
Trying to make a submission with out rendering the page, But it's not working and the page will rendered when clicking the submit button. How can i update the details form the following field? Template something like this {% for i in userlist %} <form method="POST" id="profileUpdate"> {% csrf_token %} <input class="email" type="email" value="{{i.email}}" id="email"> <input class="dob" id="dob" type="text" value="{{i.date_of_birth}}" > <button type="submit" class="btn btn-primary">Save changes</button> </form> {% endfor %} Ajax script <script> $(document).on('submit', '#profileUpdate', function (e) { $.ajax({ type: 'POST', url: '{% url "profileUpdate" %}', data: { email: $('#email').val(), dob: $('#dob').val(), csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(), action: 'post' }, success: function (json) { alert("Success"); }, }); }); </script> views.py def profileUpdate(request): response_data = {} if request.get('action') == 'post': email=request.POST.get('email') dob=request.POST.get('dob') response_data['dob'] = dob ob=Employee.object.get(email=email) ob.date_of_birth= dob ob.save() return HttpResponse('') urls.py urlpatterns = [ path('registeredusers', registeredusers.as_view(), name="registeredusers"), path('profileUpdate', views.profileUpdate, name='profileUpdate'), ] -
django-heroku is not installing
Collecting django-heroku Using cached django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB) Requirement already satisfied: django in /home/aksh/dadu/lib/python3.8/site-packages (from django-heroku) (3.1.1) Requirement already satisfied: whitenoise in /home/aksh/dadu/lib/python3.8/site-packages (from django-heroku) (5.2.0) Requirement already satisfied: dj-database-url>=0.5.0 in /home/aksh/dadu/lib/python3.8/site-packages (from django-heroku) (0.5.0) Collecting psycopg2 Using cached psycopg2-2.8.6.tar.gz (383 kB) Requirement already satisfied: asgiref~=3.2.10 in /home/aksh/dadu/lib/python3.8/site-packages (from django->django-heroku) (3.2.10) Requirement already satisfied: sqlparse>=0.2.2 in /home/aksh/dadu/lib/python3.8/site-packages (from django->django-heroku) (0.3.1) Requirement already satisfied: pytz in /home/aksh/dadu/lib/python3.8/site-packages (from django->django-heroku) (2020.1) Building wheels for collected packages: psycopg2 Building wheel for psycopg2 (setup.py) ... error ERROR: Command errored out with exit status 1: command: /home/aksh/dadu/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a2qiah3p/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a2qiah3p/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-xvu3w4ef cwd: /tmp/pip-install-a2qiah3p/psycopg2/ Complete output (6 lines): usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: invalid command 'bdist_wheel' ---------------------------------------- ERROR: Failed building wheel for psycopg2 Running setup.py clean for psycopg2 Failed to build psycopg2 Installing collected packages: psycopg2, django-heroku Running setup.py install for psycopg2 ... error ERROR: Command errored out with exit status 1: command: /home/aksh/dadu/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a2qiah3p/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a2qiah3p/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7sdx4nwd/install-record.txt --single-version-externally-managed --compile --install-headers /home/aksh/dadu/include/site/python3.8/psycopg2 …