Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Showing empty Data in tables from Database Django
Showing empty data in tables file in html when importing from the models.py Also the number of rows are increasing when increasing with data in Databse Django -
Django Admin Page - Export fields + callable fields
Django Version: 1.11 Python: 2.7 Package: django-import-export I am attempting to export the "callable" fields for a Django Admin page. (Reference: https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display) In their example, they have a "callable" for their PersonAdmin list_display. def upper_case_name(obj): return ("%s %s" % (obj.first_name, obj.last_name)).upper() upper_case_name.short_description = 'Name' class PersonAdmin(ExportMixin, admin.ModelAdmin): list_display = (upper_case_name,) For the Resource, I thought I would also be able export the callable field. class PersonResource(resources.ModelResource): class Meta: model = Person fields = ( "first_name", "last_name", "upper_case_name", ) However, I will get Person has no field named "upper_case_name". Is there a way to export callable fields? From the documentation, it does look like you can export fields that do not exist. https://django-import-export.readthedocs.io/en/latest/getting_started.html Their example was: from import_export.fields import Field class BookResource(resources.ModelResource): full_title = Field() class Meta: model = Book def dehydrate_full_title(self, book): return '%s by %s' % (book.name, book.author.name) I replicated this and tried: class PersonResource(resources.ModelResource): upper_case_name = Field() class Meta: model = Person def dehydrate_upper_case_name(self, obj): return ("%s %s" % (obj.first_name, obj.last_name)).upper() I attempted to do the same thing but I would get the error Person has no field named "upper_case_name". Any thoughts? Thanks in advance! -
Post save signal on model takes too long
I have a model called partnershipArm, when a new model is created without the post save signal, it runs really fast. in fact when I populated the databe with just 20 members it was running fine but now I have 1168 members and it timeout everytime. How can I make it run faster. Models.py class PartnershipArm(models.Model): name = models.CharField(max_length = 128) slug = models.SlugField(unique = True, null=True, blank=True) partnershipRecords = models.ManyToManyField(Member, through = 'Partnership') def __str__(self): return self.name def get_absolute_url(self): return reverse('partnership-arms') class Partnership(models.Model): YEAR = [] for r in range((datetime.datetime.now().year), (datetime.datetime.now().year+10)): YEAR.append((r,r)) MONTHS = ( ('January', 'January'), ('February', 'February'), ('March', 'March'), ('April', 'April'), ('May', 'May'), ('June', 'June'), ('July', 'July'), ('August', 'August'), ('September', 'September'), ('October', 'October'), ('November', 'November'), ('December', 'December'), ) member = models.ForeignKey(Member, on_delete=models.CASCADE) partnershipArm = models.ForeignKey(PartnershipArm, on_delete=models.CASCADE, db_index = True) year = models.IntegerField( choices=YEAR, default=datetime.datetime.now().year, db_index = True) month = models.CharField(max_length = 50, choices = MONTHS, null=True, blank=True, db_index = True) week1 = models.DecimalField(max_digits=10, decimal_places=2, default = 0) week2 = models.DecimalField(max_digits=10, decimal_places=2, default = 0) week3 = models.DecimalField(max_digits=10, decimal_places=2, default = 0) week4 = models.DecimalField(max_digits=10, decimal_places=2, default = 0) total = models.DecimalField(max_digits=10, decimal_places=2, default = 0) def __str__(self): return "{0}_{1}_{2}_{3}".format(self.member, self.partnershipArm, self.year, self.month) def get_absolute_url(self): return reverse('partnership-arms') Signals.py … -
what do referencefield store in mongoengine
What do ReferenceField stores. I mean do it stores ObjectID (or in my case user_id, as it is primary_key for User model). class User(Document): user_id = IntField(primary_key=True) user_name = StringField(max_length=100) user_email = EmailField() class MasterUnit(Document): unit_id = IntField(primary_key=True) unit_name = StringField(max_length=100) unit_user = ReferenceField('User') I am usign POST method for posting data through my api: class MasterUnitList(View): def get(self, request): masterunit = MasterUnit.objects.all().to_json() data = json.loads(masterunit) return JsonResponse(data, safe=False) def post(self, request): data = json.loads(request.body) masterunit = MasterUnit(**data) masterunit.save() return JsonResponse(data, safe=False) My urls.py is path('api/unit', MasterUnitList.as_view(), name='MasterUnitList'), path('api/unit/<int:pk>', MasterUnitDetail.as_view(), name='MasterUnitDetail'), I am using httpie http POST http://127.0.0.1:8000/api/unit unit_id=1 unit_name="Nokia" unit_user="?" What do I pass in unit_user field? -
Changing Color in Django Forms
I want to change in my form the color of the label_suffix. I just want to set the '*' in red and leave the rest black. Is this possible or do i have to change something in my HTML? username = forms.CharField(label="Username",label_suffix='*') -
django DateField model -- unable to find the date differences
I'm unable to find the difference between two dates in my form. models.py: class Testing(models.Model): Planned_Start_Date = models.DateField() Planned_End_Date = models.DateField() Planned_Duration = models.IntegerField(default=Planned_Start_Date -Planned_End_Date) -
How to properly include a form with .save() in my view.py
I'm trying to create a new form in my form.py (AddressForm), but I get an error that says: local variable 'user_AddressForm' referenced before assignment Could someone give me a hand please? The username, password and image works fine, but the address form doesn't have persistent data and gives me the error in my forms.py file: from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from .models import Profile class AddressForm(forms.Form): address_1 = forms.CharField( label='Address', widget=forms.TextInput(attrs={'placeholder': '1234 Main St'}) ) address_2 = forms.CharField( widget=forms.TextInput(attrs={'placeholder': 'Apartment, studio, or floor'}) ) city = forms.CharField() state = forms.ChoiceField(choices=states) zip_code = forms.CharField(label='Zip') class Meta: model = User fields = ['address_1', 'address_2', 'city', 'state', 'zip_code'] in my views.py from django.shortcuts import render, redirect from django.contrib import messages # to display alert messages when the form data is valid from .forms import UserSignUpForm, UserUpdateForm, ProfileUpdateForm, AddressForm from django.contrib.auth.decorators import login_required from django.contrib.auth import update_session_auth_hash @login_required def profile(request): if request.method == 'POST': u_Passform = PasswordChangeForm(request.user, request.POST) if u_Passform.is_valid(): u_Passform.save() update_session_auth_hash(request, u_Passform) messages.success(request, f'Your password was updated successfully. Please log back in') return redirect('profile') u_form = UserUpdateForm(request.POST, instance=request.user) if u_form.is_valid: u_form.save() messages.success(request, f'Your account has been updated!') return redirect('profile') p_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile) if p_form.is_valid(): … -
Django Generated Timeslots Selector Required is Always true, How to add value>0
I have a booking system in which i enter dates and timeslots available to book. the form gets the timeslots from the date and converts it to the user timezone time. i want the client to select a date and an available timeslot before continuing the form but even with required it doesnt work. i have a model for timeslots and one for event, date+timeslot then a form to make client select available date+timeslot, with a html to find timeslot available for each day html <option value="">{% if time_slots %}Available Slots{% else %}No Slot Available{% endif %}</option> {% for time_set in time_slots %} <option value="{{ time_set.pk }}">{{ time_set.start }} - {{ time_set.end }}</option> {% endfor %} models class TimeSlots(models.Model): start = models.TimeField(null=True, blank=True) end = models.TimeField(null=True, blank=True) class Meta: ordering = ['start'] def __str__(self): return '%s - %s' % (self.start.strftime("%I:%M %p"), self.end.strftime("%I:%M %p")) class Event(models.Model): event_date = models.DateField() start = models.ForeignKey(TimeSlots, on_delete=models.CASCADE, verbose_name='Slot Time', null=True) available = models.BooleanField(default=True) class Meta: verbose_name = u'Event' verbose_name_plural = u'Event' def __str__(self): return str(self.event_date) def get_absolute_url(self): url = reverse('admin:%s_%s_change' % (self._meta.app_label, self._meta.model_name), args=[self.pk]) return u'<a href="%s">%s</a>' % (url, str(self.start)) form class PatientForm(forms.ModelForm): class Meta: model = Patient fields = ('patient_name', 'patient_country','phone_number', 'email', 'event_date','start', 'timestamp', … -
Django crispy forms - Set hidden field value
I've got the following django crispy form: class ConsultForm(forms.ModelForm): # Template of Offer Cover Letter, Template of RIGHT OF FIRST REFUSAL class Meta: model = Consults # Your User model fields = [ 'TEMPLATE','EMAIL', 'DATE'] labels = { 'EMAIL' : 'Owner Email', 'DATE' : 'Todays date', # 'captcha': "Enter captcha" } helper = FormHelper() helper.form_method = 'POST' helper.form_action = "/contact/" helper.form_id = 'form' # SET THIS OR BOOTSTRAP JS AND VAL.JS WILL NOT WORK helper.add_input(Submit('Submit', 'Submit', css_class='btn-primary')) helper.layout = Layout( Field('TEMPLATE', type="hidden"), Field('DATE', type="hidden")) I want to pass a value with the hidden field TEMPLATE. I've read https://django-crispy-forms.readthedocs.io/en/latest/api_helpers.html , but can't see how to do this. How can I get this done? -
Django middleware redirect based on user agent
I'm trying to make redirect based on user agent. Right now I have in views.py: class IndexRedirectView(RedirectView): def get_redirect_url(self, *args, **kwargs): user_agent = get_user_agent(self.request) if user_agent.is_pc: return reverse_lazy("main:index") else: return reverse_lazy("main:mobile_index") I check the user agent only on main page, but I need to do this on any page (for any article page, for example) and redirect user to desktop or mobile version of the web-site. How to do it properly? Maybe, by writing own middleware like this: class UserAgentMiddleware(object): def process_request(self, request): if user_agent.is_pc: HttpResponseRedirect('desktop version') else: HttpResponseRedirect('mobile version') Thank you for your help and time! -
apache mod_wsgi + django on aws elasticbeanstalk, c extension modules
I host a django application, which uses various libraries such as numpy, PIL, opencv. After a few working requests (status code 200 OK), the server will crash. I see many errors like: Script timed out before returning headers: wsgi.py After a quick search, and according to this page: https://modwsgi.readthedocs.io/en/develop/user-guides/application-issues.html I think I should add this line: WSGIApplicationGroup %{GLOBAL} I don't quite understand what effect this line has. What is the meaning of "sub interpreters" in this context? The default elastic beanstalk configuration set processes=1 and threads=15. So how does more than one interpreter even exists? Does adding this line have any performance issues? What is the solution here? also specific to aws elasticbeanstalk config. -
name 'Class' is not defined error. Unable to use `Class` imported globally, inside a function
My code: reset.py from doclet.models import * from django.conf import settings from django.db.models import Count, Sum, Q, F from docsocket.utils import broadcast_data, get_bid_room from datetime import datetime from datetime import timedelta def delete_bids(): Bid.objects.all().delete() def delete_buzzers(): Buzzer.objects.all().delete() def delete_winner_data(): WinnerData.objects.all().delete() def reset_bids(): bids = Bid.objects.all() for bid in bids: bid.bid_data.all().delete() delete_winner_data() def set_bids_timing(set_time): bids = Bid.objects.all() for bid in bids: bid.start_date_time = set_time set_time = set_time + timedelta(hours=5) bid.is_active = True bid.is_won = False bid.save() bids[0].is_active=True bids[0].save() def reset_coin_transactions(): CoinTransaction.objects.all().delete() def reset_bonus_coin_transactions(): BonusCoinsTransaction.objects.all().delete() def reset_transactions(): Transaction.objects.all().delete() set_time = datetime.now() + timedelta(minutes=30) #delete_bids() set_bids_timing(set_time) reset_bids() delete_buzzers() #reset_coin_transactions() reset_bonus_coin_transactions() #reset_transactions() print("--done -") execution: python manage.py < shell < app/reset.py the error thrown is: NameError: name 'Bid' is not defined. Why? It works well when I run the code on Windows machine. But not on ubuntu. All the modules installed of the same version on both the machines. -
Difference between Model.function(self) and self.function()
Just a short beginner question. Everything is in the title. In a django model/python class is there any difference between Model.function(self) and self.function() when calling the function ? -
How to use decorators on overridable class methods
I have a custom class with multiple methods that all return a code. I would like standard logic that checks the returned code against a list of acceptable codes for that method and raises an error if it was not expected. I thought a good way to achieve this was with a decorator: from functools import wraps def expected_codes(codes): def decorator(f): @wraps(f) def wrapper(*args, **kwargs): code = f(*args, **kwargs) if code not in codes: raise Exception(f"{code} not allowed!") else: return response return wrapper return decorator then I have a class like so: class MyClass: @expected_codes(["200"]) def return_200_code(self): return "200"" @expected_codes(["300"]) def return_300_code(self): return "301"" # Exception: 301 not allowed! This works fine, however if I override the base class: class MyNewClass: @expected_codes(["300", "301"]) def return_300_code(self): return super().return_300_code() # Exception: 301 not allowed! I would have expected the above overriden method to return correctly instead of raise an Exception because of the overridden decorator. From what I've gathered through reading, my desired approach won't work because the decorator is being evaluated at class definition- however I'm surprised there's not a way to achieve what I wanted. This is all in the context of a Django application and I thought Djangos method_decorator … -
Specify typing for django field in model (for pylint)
I have created custom Django model-field subclasses based on CharField but which uses to_python to ensure that the model objects returned have more complex objects (some are lists, some are dicts with a specific format, etc.) -- I'm using MySQL so some of the PostGreSql field types are not available. All is working great, but pylint believes that all values in these fields will be strings and thus I get a lot of "unsupported-membership-test" and "unsubscriptable-object" warnings on code that uses these models. I can disable these individually, but I would prefer to let pylint know that these models return certain object types. Type hints are not helping, e.g.: class MealPrefs(models.Model): user = ...foreign key... prefs: dict = custom_fields.DictOfListsExtendsCharField( default={'breakfast': ['cereal', 'toast'], 'lunch': []}, ) I know that certain built-in Django fields return correct types for pylint (CharField, IntegerField) and certain other extensions have figured out ways of specifying their type so pylint is happy (MultiSelectField) but digging into their code, I can't figure out where the "magic" specifying the type returned would be. (note: this question is not related to the INPUT:type of Django form fields) Thanks! -
Django and phpmyadmin not loading up cant get it just right
New Django and Python User here this is all new to me. I don't want anyone thinking I haven't done my research. I'm doing the best that I can at following along step by step. I've tried just about everything I've looked at 5 tutorials tried a lot of commands for some reason I'm not able to get phpmyadmin running correctly I did every step the tutorials said. I keep getting stuck when following the tutorials as soon as I get it the two or 3 steps later I find myself in a situation like I am. I normally restart a new project fresh from what I've learned. I've been doing this all week. I'm not at the last step and just like before now I'm stuck again. before I post here I try searching google, going to Stack overflow all over. I'm following this tutorial https://knowledgeofthings.com/django-on-raspberry-pi-3/ i'm currently at the last step getting into pypmyadmin. and nothing. I try to install phpmyadmin again and it won't my server is this ill leave it up http://urbanpythoncoding.com:8000/phpmyadmin I'm so confused. I don't know its so hard to just follow along with the tutorials. I am on a centos system so some … -
How to pass post request data to a separate view? (Django)
I currently have this view which sends a list of genres to a template to populate a dropdown box: class GenreSearch(generic.ListView): template_name = 'games/genresearch.html' context_object_name = 'genre_list' def get_queryset(self): return Genre.objects.order_by("name") This is the template: {% if genre_list %} <div class="btn-group"> <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Select Genre</button> <div class="dropdown-menu scrollable-menu"> {% for genre in genre_list %} <a class="dropdown-item" href="#">{{ genre.name }}</a> {% endfor %} </div> </div> {% endif %} What I want to do now is select a genre from this dropdown box, submit it, and use this view to return results based on which genre is submitted: class GamesPageByGenre(generic.ListView): template_name = 'games/allgames.html' context_object_name = 'game_list' def get_queryset(self): #Return games whose genres include the genre id x return Game.objects.filter(genres__id=10) So if the 'action' genre was selected from the dropdown box, submit this, get the ID for the genre action, then replace genres__id=10 with genres__id=genreID -
When are Django context variables loaded?
A Django-based website has a massive page with many objects. I'd like to decrease the amount of database requests by pre-loading those objects in advance. I know it's normally done with some Redis-like cache storage, but I was wondering if it's possible to implement it with Django context variables. For that I need to know when those variables are loaded: when the server starts or upon every/specific page rendering? In the latter case it wouldn't be of much use, but in the former it would save me the trouble of setting up Redis. -
Django : Save doesn't update initial data along with form
I have two forms (student_form & alumni_form), with each i pass initial data,where in my models student and alumni models are related by OneToOne and as user profiles so i need to update data using those two forms but unfortunately only user model data are updated leaving data for student and alumni not updated, but save method works well as if it save data to the database. Any Help please view.py def alumni_update(request, user_id): # user = get_object_or_404(User, pk=user_id) user = get_object_or_404(User, pk=user_id) # get student_user profile and alumni_student profile profile_student = user.student profile_alumni = profile_student.alumni initial_student = {'st_reg_no': profile_student.st_reg_no, 'st_other_name': profile_student.st_other_name, 'st_dob': profile_student.st_dob, 'st_gender': profile_student.st_gender, 'st_phone_number': profile_student.st_phone_number, 'st_nationality': profile_student.st_nationality, 'st_city': profile_student.st_city, 'programme': profile_student.programme, 'campus': profile_student.campus, } initial_alumni = { 'alumni_type': profile_alumni.alumni_type, 'graduation_year': profile_alumni.graduation_year, } if request.method == 'POST': student_form = StudentUpdateForm(request.POST, initial=initial_student, instance=user) alumni_form = AlumniUpdateForm(request.POST, initial=initial_alumni, instance=profile_student) else: student_form = StudentUpdateForm(initial=initial_student, instance=user) alumni_form = AlumniUpdateForm(initial=initial_alumni, instance=profile_student) return save_user_form(request, student_form, alumni_form, 'partials/alumni/partial_alumni_update.html') def save_user_form(request, student_form, alumni_form, template_name): data = dict() if request.method == 'POST': if student_form.is_valid() and alumni_form.is_valid(): student_form.save() alumni_form.save() data['form_is_valid'] = True users = User.objects.all().filter(is_student__exact=1).order_by('-date_joined') data['html_alumni_list'] = render_to_string('partials/alumni/partial_alumni_list.html', { 'my_user_list': users, 'current_user': request.user }) else: data['form_is_valid'] = False context = {'student_form': student_form, 'alumni_form': alumni_form} data['html_form'] = render_to_string(template_name, context, … -
How do I extend django's createsuperuser management command?
I extended my user model by adding a mandatory Company field, so that every user belongs to some company. The Company field is a foreign key to another model that defines what a company is. This works great, except for the fact that ./manage createsuperuser broke, since it doesn't know to add this custom mandatory field. Turns out that I can add REQUIRED_FIELDS = ['company'] to my custom user model, which will tell createsuperuser to ask for this field. That's better, but since the company field is a Foreign Key, it asks for an ID of the company, which has to be looked up by anyone using the createsuperuser command - not exactly user friendly. I want all admins created with the createsuperuser command to belong to the same company, and for that company to be created automatically if it doesn't exist. Reading django's documentation on createsuperuser, it mentions the exact thing I want to do, and the exact reason I want to do it: You can subclass the management command and override get_input_data() if you want to customize data input and validation. Consult the source code for details on the existing implementation and the method’s parameters. For example, it … -
Authentication with cors and django rest framework
Scenario: 2 separate django apps that use the same ldap server for authentication. App A only needs to do simple GET requests from App B. App B has django-cors-headers and django-rest-framework setup Question: How does App A authenticate to accomplish the GET request from App B? I have the xmlhttprequest setup on App A's frontend and the requests are going through fine but App B always redirects with 302 to the login page. App A: I think my headers are correct. I have withCredentials True. Do I need to send an Authorization Header in the request Authorization: 'Basic ' + btoa(user +' 'pw)? App B: CORS_ORIGIN_WHITELIST = ( '---.---.---.--:8000', #ommited ip 'localhost', ) CORS_ALLOW_CREDENTIALS = True Heres a screen shot of the request and response headers: App A is 8000 and App B is 8006 I can't find any info to help with this. Is this even possible or do I have to use some different method? I guess the short question is can App A authenticate with App B using the same credentials/session/user+pass since they are using the same ldap auth? Any help would be great. -
How can I add filter backends to function based view?
I need to expose a certain method in my Django application. This method does not involve any models or serializers and is simply computational. So I figured this would be a good place to use Function Based Views. I also want this view to show up in swagger. It does but there is no place for a user to plug in data (see screen shot): If I were using GenericAPIView's I could set the filter_backends but I don't even know if this is possible with Function Base Views. Any help is a appreciated. Thanks! -
Photos taken from Android Application are unable to load on Ubuntu 16.04 Server
I have an android application that allows the user to take a picture from the gallery or from the camera. I also have a server that allows the user to upload the image and share it with other users. The android application works without the use of internet, so in order to share, the user who took the picture uploads it to the server. The server is running on a Django web framework, so it stores the image in a media folder. When another user syncs to the server, the image is then downloaded to that device. The problem is that the image is unable to display. The file is there on the Linux machine, but when you try to open it, it gives and error: "Could not load image 'XX.jpg' Failed to open input stream for file. I have tested this on an older android device and the linux machine is able to open the images, but on this newer device, the images are unable to open. I am not sure what the problem could be. This is how I am handling saving the image: @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Bitmap … -
How can I get a count of a model from another model in Django?
I need to get the count of "Movies"(Peliculas) directed by a director. Movie and Director are different classes. I want to create a function in Director that tells me how many movies he has done but i dont know how to call "Peliculas" from "Director" class Director(models.Model): nombre = models.CharField( max_length=100 ) fecha_nacimiento = models.DateField() fecha_defuncion = models.DateField( 'Fallecido', null=True, blank=True, ) foto = models.ImageField( upload_to='images/directores/', default='images/directores/sin_foto.jpg' ) def get_num_peliculas(self): n_peliculas = Pelicula.object.all().count #NOT WORKING return n_peliculas class Pelicula(models.Model): titulo = models.CharField( max_length=100 ) url_trailer = models.CharField( max_length=100 ) fecha = models.DateField() notas_posibles = ( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5) ) nota = models.IntegerField( default=3, choices=notas_posibles ) sinopsis = models.TextField( max_length=400, default="Sin sinopsis" ) caratula = models.ImageField( upload_to='images/peliculas/caratulas', default='images/peliculas/caratulas/sin_caratula.jpg' ) imagen_promocional = models.ImageField( upload_to='images/peliculas/imagenes_promocionales', default='images/peliculas/imagenes_promocionales/sin_imagen.jpg' ) genero = models.ManyToManyField( Genero, blank=True, related_name='genero' ) director = models.ForeignKey( Director, on_delete=models.SET('Sin Director') ) actores = models.ManyToManyField( Actor, blank=True ) How can I acomplish this? It is driving me crazy! Ty guys! -
Django error when installing mysqlclient on Ubuntu 18.04
I installed Python 2.7.15rci and Python 3.6.7 on Ubuntu. When i did 'pip list' on virtualenv it returns me: Django (2.1.5) pip (9.0.1) pkg-resources (0.0.0) pytz (2018.9) setuptools (39.0.1) wheel (0.32.3) I'm trying to install mysqlclient (pip install mysqlclient) and returns an error. building 'MySQLdb._mysql' extension error: command 'x86:64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for mysqlclient Running setup.py clean for mysqlclient Failed to build mysqlclient Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error Complete output from command d:\XXX\XXX\env\project\bin\python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pq18uxjj/mysqlclient/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/tmpez7n1kzkpip-wheel- --python-tag cp36: /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb creating build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/MySQLdb x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC …