Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Join queryes of ManyToMany Models on Django
I have to merge the all bands that all persons are in. here is the Models: class Person(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50, blank=True, null=True) aka = models.CharField(max_length=50, blank=True, null=True) bio = models.TextField(blank=True, null=True) birthday = models.DateField(blank=True, null=True) birth_place = models.CharField(max_length=80, blank=True, null=True) photo = models.ImageField(blank=True, null=True) location = models.CharField(max_length=80, blank=True, null=True) gender_choices = [ ('m', 'Male'), ('f', 'Female'), ('u', 'Unknown'), ] gender = models.CharField(max_length=1 ,choices=gender_choices, default='u') class Band(models.Model): name = models.CharField(max_length=100) past_names = models.CharField(max_length=180 , blank=True, null=True) bio = models.TextField(blank=True, null=True) origin_country = models.CharField(max_length=30 , blank=True, null=True) location = models.CharField(max_length=80 , blank=True, null=True) formed_in = models.IntegerField(blank=True, null=True) genre = models.CharField(max_length=80, blank=True, null=True) themes = models.CharField(max_length=80, blank=True, null=True) members = models.ManyToManyField(Person) Since one person can have multiple bands, and a band can have multiple members, I assume it's rigth to create a ManyToMany relation with Person model on Band model Of course a relation table is created, but how I use this table on View assuming I whant make a query similar to this: select person.*, band.* from person inner join band_members on band_members.person_id = person.id inner join band_band on band.id = band_members.band_id order by band_person.id Rith now, my view have a query listing all perons, and a simpler … -
Python 3 venv interpreter not available
I am following this Django App Documentation and I ran into this error from models.py Error: Unable to import 'django.db' models.py code below from django.db import models I am new to python and django so I followed the following steps in creating the app for python 3. STEPS: Followed this video to change the PATH of Python 3. In the cmd I ran the following: >python --version [ RESULT: Python 3.8.2 ] >python -m venv polling-website >Scripts/activate [Successfully activated] >py -m pip install Django [Django version 3.0.6] >django-admin startproject mysite >python manage.py migrate >python manage.py startapp polls >py manage.py runserver I was able to activate the virtual environment and the django server ran successfully. I noticed that the virtual environment I made for the project cannot be identified by the Command Palette when I use Python: Select Interpreter command. Image of command palette with no venv option How will I be able to make the venv interpreter appear? What mistake was made in installing the Django App? Thanks in advance. -
Django Rest Framework Custom Register View (RegisterView) failing to return token + user data
I'm using allauth and rest_auth in my django rest framework app. When registering an user a token (key) is returned, what I'm trying to achieve is to return the token + user data after registration. To do so I've the following serializer: from rest_framework import serializers from rest_framework.response import Response from allauth.account import app_settings as allauth_settings from allauth.utils import email_address_exists from allauth.account.adapter import get_adapter from allauth.account.utils import setup_user_email from kofiapi.api.users.models import User, UserProfile from rest_framework.authtoken.models import Token from rest_auth.models import TokenModel class UserProfileSerializer(serializers.ModelSerializer): class Meta: model = UserProfile fields = ('dob', 'phone', 'receive_newsletter') class UserSerializer(serializers.HyperlinkedModelSerializer): profile = UserProfileSerializer(required=True) class Meta: model = User fields = ('url', 'email', 'first_name', 'last_name', 'password', 'profile') extra_kwargs = {'password': {'write_only': True}} def create_token(self, user): token, created = Token.objects.get_or_create(user=user) return token def create(self, validated_data): profile_data = validated_data.pop('profile') password = validated_data.pop('password') user = User(**validated_data) user.set_password(password) user.save() token = self.create_token(user) UserProfile.objects.create(user=user, **profile_data) return user def update(self, instance, validated_data): profile_data = validated_data.pop('profile') profile = instance.profile instance.email = validated_data.get('email', instance.name) instance.save() profile.dob = profile_data.get('dob', profile.dob) profile.phone = profile_data.get('phone', profile.phone) profile.receive_newsletter = profile_data.get('receive_newsletter', profile.receive_newsletter) profile.save() return instance class TokenSerializer(serializers.ModelSerializer): user = serializers.SerializerMethodField() class Meta: model = TokenModel fields = ('key', 'user') def get_user(self, instance): request = self.context.get('request') serializer_context = { 'request': … -
How to link each title to an Image in Django
Hi I've been thinking about how to ask the right question to get the right answer. I am making a project where users upload images as posts in one phase . Next I want to change these posts to items in another models what is the steps I need to follow In App No. 1 called score. Users/designers can upload several images and that's the role of this model only. In another app called Core, I have a class in a model called item which from it I can post these images from the admin. I want to be able to select the name of the user Select the required title which is shortlisted to the selected user only The image related to the title which was previously uploaded (from the 1st app called CORE) to be selected (instead of uploading it one more time ). I am trying to simplify it as much as possible so if you have any questions please ask Here is the 1st model for Score where designers can upload images: class Post(models.Model): designer_name = models.ForeignKey(User, on_delete=models.CASCADE) design = models.ImageField( blank=False, null=True, upload_to='new designs') title = models.CharField(max_length=100) date_posted = models.DateTimeField(default=timezone.now) def __str__(self): return self.title def … -
Any better way to queryset objects from one app to another in wagtail/django?
I have a home app with HomePage model which gets object from BlogPage model in blog app. I use this code below the obtain the object from BlogPage to HomePage. blog app class HomePage(Page): primary_header = models.CharField(max_length=100, blank=True,) secondary_header = models.CharField(max_length=100, blank=True,) hero_banner_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=False, on_delete=models.SET_NULL, related_name='+') def get_context(self, request, *args, **kwargs): context = super().get_context(request, *args, **kwargs) # Get object from Blog Page blogpages = self.get_children().get(title='Blog Page').get_children().live().public().order_by('-first_published_at') context['blogpages'] = blogpages return context I used get() to obtain the object by title, but I feel that it may not be the best way to do it. If I were to rename the BlogPage title field to for example, "The Blog Page", it will break the code since 'Blog Page' is no more used. Is there a better way to queryset from BlogPage to HomePage model? home app class BlogPage(Page): subpage_types = ['PostPage'] def get_context(self, request, *args, **kwargs): context = super().get_context(request, *args, **kwargs) category_slug = request.GET.get('category', None) context['categories'] = BlogCategory.objects.all() return context -
django-storages media file could not be retrieved by url
I'm using Django and django-storage with dropbox to store media files. my model is class MyModel(models.Model): pdf_file = models.FileField(upload_to='file/%Y/%m/%d', blank=False) But when I access the url like obj = MyModel.objects.get(...) obj.pdf_file.url `` It gives error like dropbox.exceptions.ApiError: ApiError('ff7d53ab72d6faead1b54b58d0f11343', GetTemporaryLinkError('path', LookupError('not_found', None))) Accessing the file from admin panel is working fine. -
Add star display from database in Django
I would like to have a star rating display generated from the user in my Django project. My form collects the data in a charField drop down ("1star", "2stars", "3stars", "4stars", "5stars") so when I go to display it in my template, it is presented as text. Is there a way to convert the text to a star rating display or do I change the field type? Any help would be great. Unfortunately my code may me out of context let me know if you need more. forms.py: class ReviewsForm(forms.Form): apartment_rating = forms.CharField(label="Apartment Rating", widget=forms.Select(choices=Stars)) landlord_rating = forms.CharField(label="Landlord Rating", widget=forms.Select(choices=Stars)) neighborhood_rating = forms.CharField(label="Neighborhood Rating",widget=forms.Select(choices=Stars)) -
Django vs Flask - Which framework is more powerful considering I want to design an end to end IOT solution
Planning to build an end to end IOT application. I know that we can do it using Django and Flask. Which one is a better choice and how it is better? -
django dependent dropdown is not working though implemented according to a blog
I have a dependent dropdown list in my template. forms.py class Bill_CreateForm(forms.ModelForm): def __init__(self, context, *args, **kwargs): super(Bill_CreateForm, self).__init__(*args, **kwargs) self.fields['added_by'] = forms.ChoiceField(choices=tuple([(name, name.members) for name in context['users']])) self.fields['added_to'] = forms.ChoiceField(choices=tuple([(name.id, name.group_name) for name in context['groups']])) self.fields['share_with'].queryset = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=tuple([])) if 'group' in self.data: try: group_id = int(self.data.get('group')) u_l = GroupMembers.objects.filter(group_name=group_id).order_by('members') self.fields['share_with'].queryset = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=tuple([(name, name.members) for name in u_l])) except (ValueError, TypeError): pass # invalid input from the client; ignore and fallback to empty City queryset elif self.instance.pk: self.fields['share_with'].queryset = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=tuple(self.instance.group.groupmembers_set.order_by('name'))) class Meta: model = Transactions fields = ( 'bill_type', 'amount', 'added_by', 'added_to', 'share_with', ) template {% extends 'base.html' %} {% load crispy_forms_tags %} {% block body %} <div class='container'> <div class='row justify-content-center'> <div class='card' style='width: 28rem;;margin: 0 auto;float: none; margin-bottom: 10px; /* Added */'> <div class="card-body"> <form method='post' id='billform' user-data-url="{% url 'ajax_load_users' %}" novalidate> {% csrf_token %} {{ form|crispy }} <button class='btn btn-primary'> Add bill </button> </form> </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $("#id_added_to").change(function () { var url = $("#billform").attr("user-data-url"); // get the url of the `load_cities` view var group_id = $(this).val(); // get the selected country ID from the HTML input $.ajax({ // initialize an AJAX request url: url, // set the url of the request (= localhost:8000/hr/ajax/load-cities/) … -
PyCharm Cannot resolve file "url" in Django project
I am using PyCharm Professional 2019.3 and Django 3.0. PyCharm highlights <a href="/login/">Log In</a> with the following inspection Cannot resolve file: login (Inspection info: This inspection checks unresolved file references in HTML.) How do I configure PyCharm to pick up urls and inspect correctly? -
'Image' object has no attribute '_committed' while generating Qr code from model
from django.db import models import qrcode model # Create your models here. class Customer(models.Model): name=models.CharField(max_length=255) address=models.CharField(max_length=255) gender=models.CharField(max_length=255) registerd_date=models.DateTimeField(auto_now_add=True, blank=True) Image = models.ImageField(upload_to="media/static/images/",blank=True,null=True) def __str__(self): return self.name function take data and convert to qr code and save to model field data def save(self, *args, **kwargs): self.Image=qrcode.make(self.name) super(Customer,self).save(*args, **kwargs) -
How to make Django models refer to each other bidirectionally?
I am trying to create a relationship where a blog post can be assigned any number of tags, and a tag can be associated with any number of blog posts. But I'm having difficulty setting up this bidirectional relationship. Right now, to create a blog post and assign any number of tags, here is my model for the posts: class Post(models.Model): title = models.CharField(max_length=200, unique=True) slug = models.SlugField(max_length=100, unique=True, null=True, blank=True) author = models.ForeignKey(User, on_delete=models.CASCADE) updated_on = models.DateTimeField(auto_now=True) tags = models.ManyToManyField("Tags", blank=True) content = RichTextUploadingField() created_on = models.DateTimeField(auto_now_add=True) And the model defining the tags: class Tag(models.Model): name = models.CharField(max_length=20, unique=True) This works. I can log into the admin interface and create a bunch of tag objects, then create a post object and assign it any number of those tags. But let's say I also want to do the opposite. I want to be able to log into the admin interface, select a tag object, and then associate it with any number of post objects. I tried to do this by defining a ManyToManyField in the Tag model like so: class Tag(models.Model): name = models.CharField(max_length=20, unique=True) posts = models.ManyToManyField("Post", blank=True, related_name="posts") This does show a list of posts on the change … -
Django Admin custom record view
I want to create a custom view which, unlike the changelist_view, shows you the record instead of showing you a form. It will have the URL /app/model/<int:pk/test/view. Is this the best way to do it: @admin.register(Property) class ModelAdmin(admin.ModelAdmin): def get_urls(self): urls = super().get_urls() custom_urls = [ path('<int:pk>/view/', self.admin_site.admin_view(self.test_view)) ] return custom_urls + urls def test_view(self, request): record = Model.objects.get(pk=pk) # ... return django.http.HttpResponse('test') # P.S: I will rendering a template -
django I get a TemplateDoesNotExist when loading a page
My directories are structured in this picture I don't know why i'm getting the error. Please assist. Let me know if you need more info. Screenshot of the ERROR -
String mismatch on test in django model test
Been banging my head against a wall for two days trying to figure out why my test is not passing. I've wrapped them in str(). Multiline string. Just can't get this to pass. What am I missing here. Please help. This is my first post. So if I left anything out in my post that I could do better please let me know. Here is my model class MemberAddress(models.Model): address_type = models.CharField(max_length=100, default='Home') address_line_one = models.CharField(max_length=100) address_line_two = models.CharField(max_length=100, default=None) city = models.CharField(max_length=50) state = models.CharField(max_length=50) zipcode = models.CharField(max_length=50) UserProfile = models.ForeignKey(UserProfile, on_delete=models.CASCADE) REQUIRED_FIELDS = ['address_type', 'address_line_one', 'city', 'state', 'zipcode' ] def __str__(self): address = self.address_line_one + '\n' if (self.address_line_two is not None): address += self.address_line_two + '\n' address += self.city + ' ' + self.state + ' ' + self.zipcode return address Here is my test: def test_member_address_is_created(self): faker = Faker('en_US') test_address = MemberAddress( address_type='Home', address_line_one=faker.street_address(), address_line_two=faker.secondary_address(), city=faker.city(), state=faker.state(), zipcode=faker.zipcode(), UserProfile=self.user ) test_address.save() queried_address = MemberAddress.objects.get(id=1) object_string_test = '{}{}{}{}{} {} {}'.format( test_address.address_line_one, '\n', test_address.address_line_two, '\n', test_address.city, test_address.state, test_address.zipcode) self.assertEqual(test_address.address_type, queried_address.address_type) self.assertEqual(test_address.address_line_one, queried_address.address_line_one) self.assertEqual(test_address.address_line_two, queried_address.address_line_two) self.assertEqual(test_address.city, queried_address.city) self.assertEqual(test_address.state, queried_address.state) self.assertEqual(test_address.state, queried_address.state) self.assertEqual(test_address.zipcode, queried_address.zipcode) self.assertEqual(test_address.UserProfile, queried_address.UserProfile) self.assertEqual(object_string_test, test_address) # <---- Failing Test ----<<< Here is my error: python manage.py test Creating … -
NOT NULL constraint failed: registratie_inkomen.pg_id
This are my models: class PersoonGegevens(models.Model): # Voornaam en achternaam voornaam = models.CharField(max_length=265,) achternaam = models.CharField(max_length=265) #username user = models.OneToOneField(User, on_delete=models.CASCADE) class inkomen(models.Model): pg = models.ForeignKey(PersoonGegevens, on_delete=models.CASCADE) inkomenfield = models.CharField(max_length=100) This is the form: class inkomenForm(forms.ModelForm): class Meta(): model = inkomen fields = ('inkomenfield',) This is my view: def tijdelijk(request): #User id user = request.user.id if request.method == 'POST': incoming = inkomenForm(data=request.POST) if incoming.is_valid(): incoming.save() return HttpResponse("saved") else: x = incoming.errors print (x) return HttpResponseRedirect('/tijdelijk') else: incoming = inkomenForm() return render(request, 'index/tijdelijkeindex.html', {'inkomen':incoming}) I have tried: incoming.save(commit=False) incoming.pg = user incoming.save also readed the documentation about Inline formsets of django. But i dont really get So i get the following error:(NOT NULL constraint failed) and i know it comes because i need to assign the pg.id and i know i can do that by adding the field in the form.py and let the user choose the id. But what i actually want is that pg = the logged in user. -
Django adding and removing form ManyToMany field: AttributeError: 'QuerySet' object has no attribute 'add'
I am trying to add users to a many to many fields in my course model buy I am getting an error: Course.course_dislikes.through.objects.filter(course__course_code=code,course__course_university=university).add(request.user) AttributeError: 'QuerySet' object has no attribute 'add' My intention is to filter my Course model based on course code and add a user to like a field or remove it when the user dislikes. Now I know I cannot use get since there may be two objects with the same course code. Currently, I am trying to do this by: Course.course_likes.through.objects.filter(course__course_code=code).remove(request.user) I have tried with get but it gaves me an error that two objects with the same name exist which is understandable since get has to return one unique object. How can I achieve this withot for-loop as I cannot think of anny other method. -
Stack Inline Multiple Django Models in Admin with indirect relationship
I have the following three models class Participant(models.Model): participant_id = models.AutoField(primary_key=True) pin = models.CharField(unique=True, max_length=4, validators=[RegexValidator(r'^\d{1,10}$')]) class Teacher(models.Model): teacher_id = models.AutoField(primary_key=True) participant_id = models.OneToOneField(Participant, on_delete=models.CASCADE) email = models.EmailField() compensation_id = models.OneToOneField(Compensation, on_delete=models.CASCADE) class Compensation(models.Model): compensation_id = models.AutoField(primary_key=True) wage = models.DecimalField(max_digits=6, decimal_places=2) To summarize, Participant has different types one of them is Teacher (OneToOne relation). The teacher is one type of employee that is compensated with and it's related (OneToOne relation) with Compensation Model I want to create an admin form by stacking Participant Teacher Compensation The problem: I am using Participant as a primary model and stacking teacher to it. However, when I try to stack compensation to it, it apparently doesn't work due to missing foreign key relation between Participant and Compensation models. An easy way out would be to have the fields of the Compensation model in the Teacher Model. However, it would create redundancy when I want to associate other types of Participants to it. What could potentially be a solution to this? I am open to altering the model if it makes thing any easier or less complicated. P.S. There are also other types of participants (Child, Parent) that I have not mentioned. -
Django 3.0 Forms: Form Errors are not showing onto template
###I have model named Publisher in models.py file.### ###And based on this model, a modelForm has made, called "RegistrationForm".### ###Which renders form on registration.html template.### <br /> <br />**This is code of registration.html** <pre><code> ``` <body> <div class="container"> {% load my_filters %} <div class="row"> <div class="col-md-6 offset-md-3"> {% if registered %} <h1>Thank you for registering!</h1> {% else %} <h1>Register Here</h1> <h3>Just fill out the form.</h3> <form enctype="multipart/form-data" method="POST"> {% csrf_token %} {{ reg_form.non_field_errors }} <div class="fieldWrapper"> <div class="form-group"> {{ reg_form.name.errors }} <label for="{{ reg_form.name.id_for_label }}" >Name:</label> {{ reg_form.name|addclass:'form-control' }} </div> </div> <div class="fieldWrapper"> <div class="form-group"> {{ reg_form.email.errors }} <label for="{{ reg_form.email.id_for_label }}">Email:</label> {{ reg_form.email|addclass:'form-control' }} </div> </div> <div class="fieldWrapper"> <div class="form-group"> {{ reg_form.contact.errors }} <label for="{{ reg_form.contact.id_for_label }}">Contact:</label> {{ reg_form.contact|addclass:'form-control' }} </div> </div> <div class="fieldWrapper"> <div class="form-group"> {{ reg_form.password.errors }} <label for="{{ reg_form.password.id_for_label }}">Password: </label> {{ reg_form.password|addclass:'form-control' }} </div> </div> <div class="fieldWrapper"> <div class="form-group"> {{ reg_form.confirm_password.errors }} <label for="{{ reg_form.confirm_password.id_for_label }}">Confirm Password:</label> {{ reg_form.confirm_password|addclass:'form-control' }} </div> </div> <input type="submit" name="" value="Register"> </form> {% endif %} </div> </div> </div> </body> ``` </code></pre> ### I am NOT using crispy forms just manually rendering Django forms and using manual template tag to add classes to fields. **This is the template tag in used … -
How to add to the database outside of the admin site in django
I'm new to coding (6 months, self taught) and am currently working on an order and inventory management system using django. I have an order class setup in the database and am able to add orders using the django admin. My question is, how can I now create a separate html page with forums that will add orders to my database in the same way? I realize this is probably really general and basic, but I've yet to find the answer. Thanks tigerking -
django create confirm email for subscribe
I want to confirm e-mail for my subscribers. But I can not create confirm email. In views.py , I am sending e-mail but there is no confirm link. How can I create confirm link in this example ? models.py class Subscribe(models.Model): name = models.CharField(max_length=200,verbose_name="İsim") email = models.EmailField(max_length=200,verbose_name="E-Mail") confirmed = models.BooleanField(default=False) def __str__(self): return self.name + " - " + self.email views.py def yeniabone(request): if request.method == 'GET': form = SubscribeForm() else: form = SubscribeForm(request.POST) if form.is_valid(): request.session['form-submitted'] = True name = form.cleaned_data['name'] email = form.cleaned_data['email'] abone = Subscribe.objects.create(name=name,email=email) mymessage = "Merhaba "+name+",\nYazılarıma abone olduğun için teşekkürler. Aşağıdaki linkten aboneliğini onaylayıp yazılarımdan en hızlı şekilde haberdar olabilirsin.( I WANT TO SHOW CONFİRMATİON LİNK HERE )\n\nCemre ACAR - cemreacar.com" try: send_mail("Abone | cemreacar.com",mymessage,'Abonelik | Cemre ACAR <mail@cemreacar.com>',[email],'fail_silently=False') except BadHeaderError: return HttpResponse('Bir şeyler ters gitti!') return redirect('blog:yeniabone_onay') return render(request, "yeniabone.html", {'form': form}) -
{ % block content % } { % endblock % } is not working
This is main.html file: <!DOCTYPE html> <html> <head> <title>CRM</title> </head> <body> <h1>Navbar</h1> <hr> { % block content % } { % endblock % } <hr> <h1>Footer</h1> </body> </html> This is the contact.html { % extends 'accounts/main.html' % } { % block content %} <h2>contact!</h2> { % endblock % } this is my directory: accounts accounts accounts templates accounts contact.html main.html This is what I am getting: It displays the block tags too. -
How to build variable of integers + strings in python for loop?
Manually built variable STAFFLIST works in django database as a list of choices listed as PositiveSmallIntegers. STAFF1 = 1 STAFF2 = 2 STAFF3 = 3 STAFFLIST = ( (STAFF1, _('John Doe')), (STAFF2, _('Lisa Beauty')), (STAFF3, _('Harry Potter')), ) Print for this variable works as follows: >>>print(STAFFLIST[1]) (2, 'Lisa Beauty') >>> How to built this variable automatically in for loop based on the actual list of staffs? I was trying something like below, but unsuccsessful: from django.contrib.auth.models import User from django.utils.translation import gettext as _ staff = User.objects.filter(is_staff=True) idx=0 for stf in staff: STAFFLIST[idx] = (stf.id, _(stf.first_name + ' ' + stf.last_name)) idx=idx+1 I am getting error like: TypeError: 'str' object does not support item assignment I believe, my problem is low knowledge level of python datatypes. And currently, I am trying to work with tuple datatype and to store string inside. -
What is the best way to select single id from a loop using jquery in Django
I have a django template that loops through and displays all objects of a particular model. Each object displayed has a submit button. However, whenever I submit a form, the request always returns the id of the first object. html {% for food in food_list %} {{food}} <form action="{% url 'like'%}" id="form_id" method="post"> {%csrf_token%} <input name="food_id" type="hidden" value="{{ food.id }}"> <div class="like-button"></div> </form> {%endfor%} javascript <script> $('.like-button').on('click', function () { $(this).toggleClass('animate').promise().done(function () { document.getElementById("form_id").submit($(this)); }); }); </script> Please help, I am fairly new to jquery. -
Why is clang failing when building wheel for psycopg2?
I know this question or various forms of it has been asked. I am just trying to follow the Django tutorial on Heroku - which involves installing django-heroku, which has psycopg2 as a dependency. I am running MacOS Catalina, 10.15.3. I know one work around is to download the binary with pip install psycopg2-binary, but then I don't know how to get pip to recognize psycopg2-binary and stop trying to install psycopg2 from source when I run pip install django-heroku. So I suppose if someone could help me figure out that workaround, that would also suffice - although at this point I think I'm just gonna use Node. In any case, I feel like it's most likely just another instance of Catalina breaking things, but it would be nice to know how to fix this in case I ever have to use django-heroku/psycopg2. I have upgraded homebrew, reinstalled pyenv/python3.7.4, updated pip. I have openssl 1.1.1g installed (homebrew). I recently reinstalled XCode - but just to be sure it wasn't my compiler's fault, I installed homebrew clang using brew install llvm. Building wheels for collected packages: psycopg2 Building wheel for psycopg2 (setup.py) ... error ERROR: Command errored out with exit status …