Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Custom Django Login Form Not Logging Users In
I am trying to create a login page for my webapp. I am able to log users in through the official admin page, but when I use my page the request.user is not logged in. def index(request): if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') user = authenticate(username=username, password=password) if user is not None: if 'remember_me' in request.POST: request.session.set_expiry(1209600) # 2 weeks else: request.session.set_expiry(0) # Browser close login(request, user) return render(request, 'AllocationWebapp/browse.html', {}) else: print("Invalid login details: {0}, {1}".format(username, password)) return render(request, 'AllocationWebapp/browse.html', {'error': "Invalid login details supplied."}) else: return render(request, 'AllocationWebapp/login.html', {}) user is being set correctly, but after login request.user is still AnonymousUser and not logged in. -
My datatable has a datalist with several options how to export the selected option from the datalist to excel.thank you for your time in advance
My datatable has a datalist with several options how to export the selected option from the datalist to excel. thank you for your time in advance -
How to use AWS for free hosting of a web app (Docker, Nginx, Angular, Django)?
I am a total beginner and just completed the first version of my web application. I am using Docker, Nginx, Angular & Django. Note that the backend works on static files and uses a simple database for User Registration. I want to deploy it to a free, cloud solution. I heard that I can use AWS Elastic Beanstalk but found a bit complicated both the configuration and the pricing policy. Question Can anybody guide me through what to consider or even better, what selection I have to make in order to host my web app on AWS without a charge? PS: I don't know If I have to mention this, but in case the web app attracts a satisfying number of users, I would adjust the implementation in order the user to be able to upload and use my services upon their own data (and not upon the csv files). In this case, I might have to use other AWS services or migrate to another cloud solution. Just to say that both of them are welcome! -
if(x>2): print(x) but 1 is printed do you know why? (in python, django view)
code for sn in skil_note: if(sn.category.id > int(ca_num) & sn.category.id != 99): # ca num = 2 print("sn.category.id : ", sn.category.id) else: print("haha: " , sn.category.id) result Quit the server with CTRL-BREAK. ca_num : 2 sn.category.id : 89 sn.category.id : 89 sn.category.id : 89 sn.category.id : 1 sn.category.id : 1 haha: 2 haha: 2 haha: 2 haha: 2 haha: 2 sn.category.id : 3 sn.category.id : 3 sn.category.id : 3 sn.category.id : 3 sn.category.id : 3 sn.category.id : 3 sn.category.id : 5 sn.category.id : 5 sn.category.id : 5 sn.category.id : 6 sn.category.id : 6 sn.category.id : 6 sn.category.id : 6 sn.category.id : 6 sn.category.id : 6 sn.category.id : 6 sn.category.id : 6 sn.category.id : 6 sn.category.id : 8 sn.category.id : 8 sn.category.id : 1 sn.category.id : 10 sn.category.id : 10 sn.category.id : 10 If you know the reason, thanks 2> 1, but if you can tell me why 1 is output, thank you Is the if statement wrong? Should I compare in another way? Is there a problem with the format of the for or if statements? -
How to deal with KeyError: 'pk' in Django Formview
I'm trying to construct a form using Django FormView which will redirect me to page if the form is valid. I want to see a success message in a modal window after redirect. That did not work well as I'd get KeyError: 'pk' upon form submission. views.py: class ApplyView(FormView): template_name = 'vouchers/apply.html' model = Voucher voucher = None form_class = VoucherApplyForm def form_valid(self, form): self.code = form.cleaned_data['code'] now = timezone.now() Voucher.objects.filter(code__iexact=self.code, valid_from__lte=now, valid_to__gte=now, usage_limit=3, active=True) form.apply_voucher() return super(ApplyView, self).form_valid(form) def get_success_url(self): messages.add_message(self.request, messages.INFO, "Congratulations! You've successfully redeemed {{ voucher.value }} " "{{ voucher.get_type_display }} off the selected item(s).") return reverse('vouchers:apply', args=(self.kwargs['pk'],)) class VoucherDetailView(generic.DetailView): template_name = 'vouchers/detail.html' model = Voucher def get_context_data(self, **kwargs): context = super(VoucherDetailView, self).get_context_data(**kwargs) context['redemption_form'] = VoucherApplyForm(initial={'voucher':self.object}) return context urls.py: urlpatterns = [ path('<int:pk>/', views.VoucherDetailView.as_view(), name='detail'), path('<int:voucher_id>/apply/', views.ApplyView.as_view(), name='apply'), ] detail.html: <h1>Redeem your voucher!</h1> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} <form action="{% url 'vouchers:apply' voucher.id %}" method="post"> {{ redemption_form }} {% csrf_token %} <input type="submit" value="Apply"> </form> apply.html: {% if messages %} <ul class="messages"> {% for message in messages %} <li {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}</li> {% endfor %} </ul> {% endif %} And i ended up receiving error … -
How to store a list of string (tags or keywords) in a django model field?
I have these models: class Author(model): user = OneToOneField(CustomUser) other_filed = CharField(...) class Post(Model): author = ForeignKey(Author, on_del..) title = CharField(...) # keywords field to be inserted in a form and stored As already described, I need to field for the keyword related to each post written by an author. While I need something simple to avoid complexities, I prefer to be able to restrict the length of each keyword and the number of keywords. I have read Keywords Field in Django Model and What is the most efficient way to store a list in the Django models? and a few other articles but do not seem to be able to decide what should I do suppose I will find a way to store it. Why do I need it? At this stage, I only need to populate the keywords meta tag in the head part of the html of the page related to the article. I may, in the future, use these keywords to search and find an article. -
For loop only working in one template in django
I am trying to build an educational website and am trying to put all categories using for loops in a dropdown in the navbar. I have put it in base.html and all other templates extend base.html. But the items are only shown in the root page whose template is home.html. I have tried using passing multiple contexts to all posts. base.html: {% load static %} <!doctype html> <html> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}"> <title>{% block title %}ION{% endblock %}</title> </head> <body> <header class="site-header"> <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top"> <div class="container"> <a class="navbar-brand mr-4" href="{% url 'blog-home' %}">ION</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarToggle"> <div class="navbar-nav mr-auto"> <a class="nav-item nav-link" href="{% url 'blog-home' %}">Home</a> <a class="nav-item nav-link" href="{% url 'post-all' %}">Posts</a> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Categories</a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> {% for cate in cat %} <a class="dropdown-item" href="{% url 'category' cate.pk %}">{{ cate.name }}</a> {% endfor %} </div> </li> <a class="nav-item nav-link" href="{% url 'blog-about' %}">About</a> </div> <!-- Navbar … -
How to Fix UnboundLocalError at /signup/ in Django
I Wnat To Create A User Like Signup or register when i hit submit button i got this error: i want to signup user local variable 'usercustom' referenced before assignment Views.py def signup(request): registered = False if request.method == "POST": user_form = UserForm(request.POST or None) custom_form = UserCustom(request.POST or None) if user_form.is_valid() and custom_form.is_valid(): user = user_form.save(commit=False) user.save() custom = custom_form.save(commit=False) custom.user = user custom.save() registered = True else: print(user_form.errors,custom_form.errors) else: user_form = UserForm() usercustom = UserCustom() return render(request,'form.html',{'user_form':user_form,'usercustom':usercustom,'registered':registered}) Form.html {% extends "base.html" %} {% block body_block %} <div class="content-section"> {% if registerd %} <h1>Thank Your For registering!</h1> {% else %} <h1>Register Here</h1> <h3>Fill out the form</h3> <form enctype="multipart/form-data" method="POST"> {% csrf_token %} {{ user_form.as_p }} {{ usercustom.as_p }} <input type="submit" value="Register!" class="btn btn-danger"> </form> {% endif %} </div> {% endblock %} -
Unit testing a management command that uses a model derived from an abstract model class where the model is created for testing purposes only
I've created an abstract model class that can be used to create concrete models. Since I intend to put this in a separate django module to be re-usable, I don't have a concrete model in my package. I'm testing my abstract class AbstractBaseModel by dynamically creating a concrete model in my tests: class AbstractModelTestCase(TestCase): @classmethod def setUpClass(cls): class LocationTestModel(AbstractBaseModel): name = models.CharField(max_length=100) title = models.CharField(max_length=100, blank=True) num = models.IntegerField(default=0) try: with connection.schema_editor() as editor: editor.create_model(LocationTestModel) super(AbstractModelTestCase, cls).setUpClass() except ProgrammingError: pass cls.Location = LocationTestModel @classmethod def tearDownClass(cls): try: with connection.schema_editor() as editor: editor.delete_model(cls.Location) super(AbstractModelTestCase, cls).tearDownClass() except ProgrammingError: pass This works fine: In my test cases, self.Location is my test model and I can create and manipulate it as any other concrete model. Now I'd like to test a management command using call_command. My management command takes an app_label as argument and then looks for all the models in the app app_label, checking which models are sub-instances of my AbstractBaseModel, like this: def get_models_to_handle(self, app_label): try: app_to_handle = apps.get_app_config(app_label) except LookupError: app_to_handle = None models = [] if app_to_handle: app_models = app_to_handle.get_models() models.extend(model for model in app_models if issubclass(model, AbstractBaseModel)) return models The goal is to do something for each of these … -
How to return image URL as prefix https:// in Django Rest Framework?
My django Rest API return image URL path http://blah/media/blah.jpg. But I want to return https://blahblah. Is there any attribute in settings.py? CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') I Inserted this and tried SECURE_SSL_REDIRECT = True but it throws 301 code and nothing rendered. -
how to show step function in my integration project
I want to create a small project that can return the integration of user given input. but my main problem is that i want to show steps of that function. examples like in numpy or sympy.(they give the show steps button). -
how to change admin filed name in django, python
I added one model Author in models.py file in my app and created model names for the author while I opened in admin panel it's showing as Author object(12) how can I change that? i tried to add Unicode class Author(models.Model): author_name=models.CharField(max_length=300) i need want field name instead of Author object in the admin panel -
how does django ORM handle thousands of concurrent requests as it is synchronous?
As Django ORM is a synchronous piece of code and django is WSGI based, then how it serve thousands of concurrent request at a time. -
Django sitemaps: XML declaration allowed only at the start of the document
I have been working on the implementation of the sitemaps on Django-2.2 for the Blog website. The code structure I followed was- Sitemaps.py from django.contrib.sitemaps import Sitemap from .models import Post class PostSitemap(Sitemap): changefreq = "never" priority = 0.9 def items(self): return Post.objects.all() urls.py from django.contrib.sitemaps.views import sitemap from .sitemaps import PostSitemap sitemaps = { 'posts': PostSitemap } urlpatterns = [ url(r'^sitemap\.xml/$', sitemap, {'sitemaps' : sitemaps } , name='sitemap'), ] settings.py INSTALLED_APPS = [ ... 'django.contrib.sites', 'django.contrib.sitemaps', ] SITE_ID = 1 I guess that was pretty much it as I referenced so many links. but when I open 127.0.0.1:8000/sitemap.xml It gives me th following error- This page contains the following errors: error on line 2 at column 6: XML declaration allowed only at the start of the document Below is a rendering of the page up to the first error. That's it, nothing on the server log. Please, If anyone can please help me out. Thanks in advance -
Passing parameters from a view function to another through HTML rendered by view1 without URL changing?
I have 2 views functions in django: > def view1(request): > dict_ex = Mod.objects.all() > ............... (modifying and processing the dict_ex variable) > return render(request, 'view1.html', {"dd": dict_ex}) Then I have these lines in view1.html: {% for k, v in dd.items %} Name: {{ v }} <a class="btn btn-primary" href="{% url 'view2' k.id %}">Choose this </a> {% endfor %} Then I have my view2 that needs the modified dict_ex to get other values needed: > def view2(request): > dict_ex = Mod.objects.all() > ............... (modifying and processing the dict_ex variable) > ....... (obtaining var1 from different operations on dict_ex) > return render(request, 'view2.html', {"v": var1}) Is there any method to pass the modified dict_ex from view1 to view2 functions through view1.html? I don't want to repeat these lines of code in view2 too > dict_ex = Mod.objects.all() > ............... (modifying and processing the dict_ex variable) Is there a way to acces the view2 function like this: view2(request, dict_ex) without changing the URL ? I have these in my URL_PATTERNS: path('view_one/', view1, name='view1'), path('view_two/<int:id>', view2, name='view2'), -
Could not parse the remainder: '['prod_title']' from 'd['prod_title']'
From the yesterday, I am trying to get data from the existing database of mongodb atlas. But I am stuck at a point.Whenever I tried to get data from the database using for loop within the html, it throws an error saying that Could not parse the remainder: '['prod_title']' from 'd['prod_title']' I tried a lot of answers posted on the similar questions but after getting frustrated, I choose to post the problem here. Here is the views.py file from django.shortcuts import render import pymongo client = pymongo.MongoClient('mongodb+srv://danial:1234@wearit-qyueb.mongodb.net/test?retryWrites=true&w=majority') db=client.scraped_data.all_brands rand_doc = db.aggregate([{ '$sample': { 'size': db.count() } }]) # Create your views here. def index(request): template='products/products.html' contaxt=locals() return render(request,template,contaxt) def home(req): return render(req, 'products/home.html',{'data':rand_doc}) And this is the the html file. <div class="row"> <div class="col-xs-18 "> <div class="products wrapper grid products-grid"> <ol class="products list items product-items"> {% for d in data %} <li class="item product product-item"> <div class="product-item-info" data-container="product-grid"> <a class="product photo product-item-photo" href="https://www.khaadi.com/pk/lkb19505-pink-3pc.html" tabindex="-1"> <span class="product-image-container"> <span class="product-image-wrapper"> <span> <span class="product-image-container"> <span class="product-image-wrapper"> <img class="product-image-photo"src="https://d224nth7ac0evy.cloudfront.net/catalog/product/cache/1e8ef93b9b4867ab9f3538dde2cb3b8a/g/l/glm-18-10_eid_1_.jpg } " alt="Shirt Shalwar Dupatta"> </span> </span> </span> </span> </span> </a> <div class="product details product-item-details"> <div class="info-holder"> <strong class="product name product-item-name"> <a class="product-item-link" href="https://www.khaadi.com/pk/lkb19505-pink-3pc.html"> {{ d['prod_title'] }} </a> </strong> </div> <div class="info-holder"> <div class="price-box price-final_price" … -
pass data from one view to another django
I have two views in my app Views.py def selectwarehouse(request): z = Warehouse.objects.all() return render(request, 'packsapp/employee/selectwarehouse.html', {'z': z}) def warehouse_details(request): queryset = AllotmentDocket.objects.filter(send_from_warehouse = 1) return render(request, 'packsapp/employee/allotwarehousedetails.html', {'query': queryset}) selectwarehouse.html {% block content %} <label>Select Warehouse<label> <select id="the-id"> {% for i in z %} <option value="{{ i }}">{{ i }}</option> {% endfor %} <form method="post" novalidate> {% csrf_token %} <a href="{% url 'employee:warehouse_details' %}" class="btn btn-outline-secondary" role="button">Proceed</a> <a href="{% url 'employee:products_table' %}" class="btn btn-outline-secondary" role="button">Nevermind</a> </form> </select> {% endblock %} I want that when a person selects the "Warehouse" from the dropdown and clicks on Proceed, it should pass that value to def warehouse_details and pass the value to Allotment queryset. How Can I do that ? -
How fetch a list of dates where cluster = C18 and Mean is the model name using queryset in django?
y_axis = Mean.objects.filter(Cluster_ID = 'C18').values_list("Date_id").distinct() -
I can't open my local server. I made todo list
Present states I made easy "to do list". I copied and pasted from Japanese website. These procedures was going well on the way, however when I set up local server, this error occurred python manage.py runserver 8080 Performing system checks... System check identified no issues (0 silenced). You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. October 14, 2019 - 18:23:49 Django version 2.2.5, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8080/ Quit the server with CTRL-BREAK. C:\Users\kazu\Anaconda3\lib\site-packages\django\views\generic\list.py:88: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'todo.models.Todo'> QuerySet. allow_empty_first_page=allow_empty_first_page, **kwargs) Internal Server Error: /todo/list/ Traceback (most recent call last): File "C:\Users\kazu\Anaconda3\lib\site-packages\django\db\backends\utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "C:\Users\kazu\Anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 383, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such table: todo_todo The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\kazu\Anaconda3\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\kazu\Anaconda3\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\kazu\Anaconda3\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\kazu\Anaconda3\lib\site-packages\django\views\generic\base.py", line 71, in view return self.dispatch(request, … -
WSGI error using Django 2.2 on Elastic Beanstalk
Trying to access a Django 2.2 web app deployed to AWS Elastic Beanstalk gives a 500 error. When checking the elastic beanstalk logs the below errors are shown. mod_wsgi (pid=3388): Target WSGI script '/opt/python/current/app/app_name/wsgi.py' cannot be loaded as Python module. mod_wsgi (pid=3388): Exception occurred processing WSGI script '/opt/python/current/app/app_name/wsgi.py'. Traceback (most recent call last): File "/opt/python/current/app/app_name/wsgi.py", line 16, in <module> application = get_wsgi_application() File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application django.setup(set_prefix=False) File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate raise RuntimeError("populate() isn't reentrant") RuntimeError: populate() isn't reentrant -
Pylint with Django
I have the following directory structure in a Django project: . ├── config ├── element ├── home ├── static ├── templates ├── tree └── user I'm searching for the easiest command to run pylint on all directories that are python modules. This would be all except 'static' and 'templates'. I tested for example: pylint --load-plugins=pylint_django --ignore=static/,templates/ */ But the ignore switch isn't working. The following would work of course: pylint --load-plugins=pylint_django config element home tree user But I want it as dynamic as possible. When i add a new django app i could forget to update the pylint statement. -
Unable to import 'import_export'
I am developing an app in Django. I have a model named glossary_entry and I want to be able to use the import_export widget for it. So I have already run pip install django-import-export added to settings.py INSTALLED_APPS = [ 'import_export', run: pip freeze>requirements.txt And in my admin.py I have: from django.contrib import admin from .models import glossary_entry from import_export import resources from import_export.admin import ImportExportModelAdmin class glossary_entry_resource(resources.ModelResource): class Meta: model=glossary_entry # Register your models here. admin.site.register(glossary_entry) The problem is that when I run the server, I get Connection negated by 127.0.0.1 But even before that, in my VS code editor, i get an error underlined at lines from import_export import resources from import_export.admin import ImportExportModelAdmin which tells: Unable to import 'import_export'pylint(import-error) What am I missing? -
how to fix - invalid token in plural form: EXPRESSION?
I created a localization file through the: python manage.py makemessages -l en and then django-admin.py compilemessages But I get an error when changing the language invalid token in plural form: EXPRESSION How can i fix this? Django Version: 1.11.25 Exception Type: ValueError Exception Value: invalid token in plural form: EXPRESSION Exception Location: /usr/lib/python3.5/gettext.py in _tokenize, line 91 -
Add two numbers in django and output will print same on same page
I'm new to django and i need to add two numbers x and y . The x and y are inputs from user. Here is my views.py from django.shortcuts import render from django.http import HttpResponse def home(request): return render(request, 'home.html', {'name':'keyur'}) def add(request): val1 = int(request.POST['num1']) val2 = int(request.POST['num2']) # red = add('val1','val2') res = val1 + val2 return render(request,'home.html',{'result': res}) Here is my url.py from django.urls import path from . import views urlpatterns = [ path('', views.home, name='home'), path('add', views.add, name='add') ] Here is my home.html {% extends 'base.html' %} {% block content %} <h1>hello {{name}} !!!!</h1> <form action="add" method="post"> {% csrf_token %} Enter a 1st number: <input type="text" name="num1" placeholder="enter the number"> Enter a 2st number: <input type="text" name="num2" placeholder="enter the number"> <input type="submit"> </form> {% endblock %} Here is my result.html {% extends 'base.html' %} {% block content %} Result is... {{result}} {% endblock %} i want to print the output in same page.. can uh please help me.. -
Connecting Django App to RDS database using AWS ElasticBeanStalk
I am using eb deploy to try and load a Django application and connect it to an RDS database. Within settings I have the following: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': os.environ['RDS_DB_NAME'], 'USER': os.environ['RDS_USERNAME'], 'PASSWORD': os.environ['RDS_PASSWORD'], 'HOST': os.environ['RDS_HOSTNAME'], 'PORT': os.environ['RDS_PORT'], } } And I have all these set within the Environment's Configuration > Software > Environment Properties. The RDS database exists and is available. I have added the Enviornments Instances Security Groups to the RDS database. I am getting the following error when I try to deploy. Traceback (most recent call last): File "./src/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv self.execute(*args, **cmd_options) File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 350, in execute self.check() File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 379, in check include_deployment_checks=include_deployment_checks, File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/commands/migrate.py", line 59, in _run_checks issues = run_checks(tags=[Tags.database]) File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks new_errors = check(app_configs=app_configs) File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/checks/database.py", line 10, in check_database_backends issues.extend(conn.validation.check(**kwargs)) File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/db/backends/mysql/validation.py", line 9, in check issues.extend(self._check_sql_mode(**kwargs)) File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode with self.connection.cursor() as cursor: File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor return self._cursor() File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor self.ensure_connection() File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection …