Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
NoReverseMatch at / Reverse for 'products' with arguments '('',)' not found. 1 pattern(s) tried: ['products/(?P<pk>[^/]+)/$']
I have tried viewing the other solutions of the community, but nothing came in help. I was just trying to match the inputs to database entries and thus show a result in the "products.html" page. Would be grateful if anyone could breakdown the solution. views.py from django.shortcuts import render, redirect from .forms import ProductForm from .models import Product def home(request): form = ProductForm() if request.method == "POST": form = ProductForm(request.POST) form.save() if form.is_valid(): return redirect('/') context = { 'form':form } return render(request, 'bye/home.html', context) def products(request, pk): product = Product.objects.get(id = pk) if request.method == "POST": return redirect('/') context = { 'product': product } return render(request, 'bye/products.html', context) urls.py from django.urls import path from . import views urlpatterns = [ path('', views.home, name ='home'), path('products/<str:pk>/', views.products, name = 'products') ] home.html </div> <div class = "col-md-12"><a href = "{% url 'products' product.id %}" class="btn btn-info btn-sm">Submit</a></div> </div> products.html {% extends 'bye/base.html' %} {% block content %} <p></p> {{product.name}} {% endblock %} Traceback Traceback (most recent call last): File "D:\DJPROJ\try\env\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "D:\DJPROJ\try\env\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "D:\DJPROJ\try\okay\bye\views.py", line 17, in home return render(request, 'bye/home.html', context) File "D:\DJPROJ\try\env\lib\site-packages\django\shortcuts.py", line … -
How to properly handle SMTP errors in Django + Ajax
I have a simple contact form on my site. It communicates with Gmail SMTP server through AJAX call. Here's the view: def contact(request): if request.is_ajax(): sender_name = request.POST.get('sender_name') sender_email = request.POST.get('sender_email') message_subject = request.POST.get('message_subject') message_text = request.POST.get('message_text') remote_addr = request.META['REMOTE_ADDR'] remote_host = request.META['REMOTE_HOST'] context = { 'from': sender_name, 'email': sender_email, 'subject': message_subject, 'message': message_text, 'IP': remote_addr, 'HOST': remote_host } html_message = render_to_string('homepage/submit.contact.form.html', context) try: send_mail( f'Contact Form: {message_subject}', f'{message_text}', 'me@gmail.com', ['me@gmail.com', ], html_message=html_message ) return JsonResponse({}, status=200) except SMTPException as e: return JsonResponse({'error': e}, status=500) else: return redirect('homepage:index') And the AJAX code: $('#contactForm').submit(function(e){ e.preventDefault() $('#sent-message').css("display", "none") $('#loading').css("display", "block") $.ajax({ type : "POST", url : "/contact/", data: { sender_name : $('#name').val(), sender_email : $('#email').val(), message_subject : $('#subject').val(), message_text : $('#message').val(), csrfmiddlewaretoken : csrftoken, datatype : "json", }, success: function(){ $('#loading').css("display", "none"), $('#sent-message').css("display", "block"), $('#contactForm')[0].reset() }, error: function(e){ alert(e) } }); }); The above code works if everything is ok, but the exception handling is not working properly and I'm not an expert in this area. The issues I'm facing when there's an exception (I use a wrong password for the email account to raise it): First, I get Object of type SMTPAuthenticationError is not JSON serializable in the console. Second, the … -
filter django queryset by onetoone model field property
i have two model classes and they are related by OneToOneField like here class Book(models.Model): is_user_ok = models.BooleanFiled() class Mybook(models.Model): book = models.OneToOneField( Book, related_name="Book", null=True, blank=True, on_delete=models.SET_NULL) now i want make a queryset filter by book field property. but here book.is_user_ok cannot be used. how can i make this queryset filter? queryset = Mybook.objects.filter(book.is_user_ok=True) -
'method' object is not subscriptable trying for google api books
Trying to get data from google books API but it is showing the error ' 'method' object is not subscriptable' I know the “TypeError: ‘method’ object is not subscriptable” error is raised when you use square brackets to call a method inside a class. To solve this error, make sure that you only call methods of a class using round brackets after the name of the method you want to call. def books(request): if request.method == "POST": form = DashboardForm(request.POST) text = request.POST['text'] url = 'https://www.googleapis.com/books/v1/volumes?q='+text r = requests.get(url) answer = r.json result = [] for i in range(10): result_dict= { 'title':answer['items'][i]['volumeInfo']['title'], # This line is showing error. 'subtitle': answer['items'][i]['volumeInfo']['title'].get('subtitle'), 'description': answer['items'][i]['volumeInfo']['title'].get('description'), 'count': answer['items'][i]['volumeInfo']['title'].get('pageCount'), 'categories': answer['items'][i]['volumeInfo']['title'].get('categories'), 'rating': answer['items'][i]['volumeInfo']['title'].get('pageRating'), 'thumbnail': answer['items'][i]['volumeInfo']['title'].get('imageLinks'), 'preview': answer['items'][i]['volumeInfo']['title'].get('previewLink') } result.append(result_dict) context={ 'form':form, 'results':result, } return render(request,'dashboard/books.html',context) else: form = DashboardForm() context = {'form':form} return render(request,'dashboard/books.html',context) -
Implementation of a Quantited-MultiSelect "Material List" in Django
I'm trying to write a django app to track materials required on each job in my business, but struggling to find the right approach. Planning to use the Admin for forms if possible. The ideal form field will let me search from ~200 materials options, select between 1-20 for each job, and add a quantity to each, e.g. 40x red two-inch screws 4x blue one-inch screws 13x purple two-inch screws I'm looking at "Many-To-Many" fields and "Iterating Relationship Choices" but am honestly confused. -
Django id field coming None
This is the first time it has happened. Normally Django would automatically add a primary key field in the model but this time is giving a none value. I also added an AutoField to the model but its still giving None class Note(models.Model): note_id = models.AutoField(primary_key=True) user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=200) slug = models.SlugField(null=True, blank=True) note = models.TextField() date_created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title def save(self, *args, **kwargs): l = self.title.lower().split(' ') self.slug = '_'.join(l) super(Note, self).save(*args, **kwargs) This is my Note model And this is the admin interface -
Django Webserver on Linux Apache Webserver
I am trying to install a Django Webserver on a Linux Apache2 Webserver. I am Stuck and dont know why I am not getting any Response from the Webserver. My Apache Conf: WSGIPythonHome /var/venvs/djangoVenv WSGIPythonPath /var/www/DjangoProject/ Listen 8080 <VirtualHost *:8080> DocumentRoot /var/www/DjangoProject Alias /static /var/www/DjangoProject/static WSGIScriptAlias / /var/www/DjangoProject/DjangoProject/wsgi.py WSGIProcessGroup DjangoProject WSGIPassAuthorization On <Directory /var/www/DjangoProject/DjangoProject> <Files wsgi.py> Require all granted </Files> </Directory> <Directory /var/www/DjangoProject> Require all granted </Directory> <Directory /var/www/DjangoProject/static> Require all granted </Directory> ErrorLog /var/www/logs/error.log CustomLog /var/www/logs/custom.log combined </VirtualHost> And my Python wsgi File: import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoProject.settings') application = get_wsgi_application() I have running the Standard Apache Webserver on Port 80 and my Django Server on Port 8080 but Chrome only shows me, that the Website is unreachable. Chrome Reply -
Django error faced whil making the project list is not getting displayed
I am creating this tab in Django and wants that it will display the list of 10 youtube searches but it is showing only one below is the code for my view.py youtube method and below that is my template section can someone help me I want the list of my top ten searches will be displayed ut it is only showing 1 I don't know why def youtube(request): if request.method=="POST": form = DashboardForm(request.POST) text = request.POST['text'] video = VideosSearch(text,limit=10) result_list=[] for i in video.result()['result']: result_dict={ 'input':text, 'title':i['title'], 'duration':i['duration'], 'thumbnail':i['thumbnails'][0]['url'], 'channel':i['channel']['name'], 'link':i['link'], 'views':i['viewCount']['short'], 'published':i['publishedTime'] } desc='' if i['descriptionSnippet']: for j in i['descriptionSnippet']: desc+=j['text'] result_dict['description']=desc result_list.append(result_dict) context={'form':form, 'results':result_list} return render(request,'dashboard/youtube.html',context) else: form =DashboardForm() context={'form':form} return render(request,'dashboard/youtube.html',context) {% extends 'dashboard/base.html' %} {% load static %} {% block content %} <section class='text-center container'> <h2>Search Videos in Youtube</h2> <p>search videos and select any video to open in youtube</p> <form action="" method="post"> {% csrf_token %} {{form}} <input class="btn btn-danger" type="submit" value="Submit"> </form><br> {% for result in results %} <a href="{{result.link}}" target="_blank"> <div class="card"> <div class="card-header"> <div class="row"> <div class="col-md-5"> <img class="img-fluid" src="{{result.thumbnail}}" alt=""> </div> <div class="col-md-7"> <h3 class="p-0 m-0">{{result.title}}</h3> <b> <u> <h5 class="p-0 m-0">{{result.channel}}</h5> </u> </b> <h6 class="p-0 m-1">{{result.description}}</h6> <b> <h6 class="ml-0 mt-3">{{result.duration}}</h6> <h6 class="ml-0 … -
Django Custom Manager + DRF + UWSGI setup : Incorrectly applied queryset filters
We are using Django 3.1.5, python 3.8, and Django Rest Framework ModelViewSet Architecture for our application. Our application is a multi-tenant system where all the tenants of our application are using the same database and schema, we have added a foreign key to tenant to make the models tenant aware (if applicable). For our system, we call tenants Clients. To filter all the queries by the client by default, we have done the below steps: Used local thread storage to store client id for each request. This is set at a middleware before each request and gets cleared in the end. Created a custom manager to override objects working. Here, we filter queries by client_id stored in the local thread.So, everytime, some_model_query = SomeModel.objects.all() is done, then some_model_query is filtered by client stored. Our view sets are written in the below format: class SomeModelViewSet(CustomModelViewSet): queryset = SomeModel.objects.all() serializer_class = SomeModelSerializer filterset_class = SomeModelFilter We are using uwsgi to run our application on servers. Now, the problem with uwsgi: The first time, when a process is run, then, all the view sets are initialized and hence their querysets. During initialization, querysets are set with the current client_id. So, it becomes: SomeModel.objects.filter(client_id=1).all() … -
Python Django LineBot Error 54 'Connection reset by peer'
I'm trying to crete linebot through python Django, I want to send some messages and let it scrape the website. Since there is form on the website, I use post request to send the form. Although I scrape the data successfully, there is error message showed in the python. It seems linebot occupy post method in Django and I send another post request again. I'm not sure my understanding is correct. I can't find any solution about this. Could someone teach me how to fix it? Exception happened during processing of request from ('127.0.0.1', 50246) Traceback (most recent call last): File "/usr/local/anaconda3/lib/python3.8/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/usr/local/anaconda3/lib/python3.8/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/anaconda3/lib/python3.8/socketserver.py", line 720, in __init__ self.handle() File "/usr/local/anaconda3/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle self.handle_one_request() File "/usr/local/anaconda3/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "/usr/local/anaconda3/lib/python3.8/socket.py", line 669, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 54] Connection reset by peer -
how to fix not found error when posting a form?
I created a comment model for my product for an ecommerce_website. when I click the reply button I get404 page not found error and my reply comment cant not be saved but my normal comment worked. reply comment didn't work this is my comment model in comment app class Comment(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='comments') user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, blank=True, null=True) email = models.EmailField() content = models.TextField() posted_on = models.DateTimeField(default=timezone.now, editable=False) active = models.BooleanField(default=False) parent = models.ForeignKey('self', null=True, blank=True, related_name='replies', on_delete=models.CASCADE) updated = models.DateTimeField(auto_now=True) this is my view in product app def product_detail(request, *args, **kwargs): selected_product_id = kwargs['productId'] product = Product.objects.get_by_id(selected_product_id) if product is None or not product.active: raise ("not valid") comments =product.comments.filter(active=True, parent__isnull=True) new_comment=None if request.method == 'POST': # comment has been added comment_form = CommentForm(data=request.POST) if comment_form.is_valid(): parent_obj = None # get parent comment id from hidden input try: # id integer e.g. 15 parent_id = int(request.POST.get('parent_id')) except: parent_id = None # if parent_id has been submitted get parent_obj id if parent_id: parent_obj = Comment.objects.get(id=parent_id) # if parent object exist if parent_obj: # create replay comment object replay_comment = comment_form.save(commit=False) # assign parent_obj to replay comment replay_comment.parent = parent_obj # normal comment # create comment object but do … -
Getting specific data after button click - Django
I am creating a donation application that allows donors to donate stuff. I have a screen, called available supplies.html which renders out all of the donations from the database using a for loop. Each donation is displayed in a user-friendly way, and contains a button that allows them to see details about that specific donation. When the button is clicked, the user is redirected to a page, which I want to contain details about the donation that they clicked on My problem is that I can't figure out how to display a specific donation from my model, for example if my user clicked on an apple donation, I want to get the details for this donation and display it on another page My model: class Donation(models.Model): title = models.CharField(max_length=30) phonenumber = models.CharField(max_length=12) category = models.CharField(max_length=20) quantity = models.IntegerField(blank=True, null=True,) The unfinished view: (Instead of displaying all of the donations, I want to get the specific details for the donation clicked on in the previous page) def acceptdonation(request): donations = Donation.objects.all() context = {} return render(request, 'acceptdonation.html', context) NOTE I have been struggling with this for a while, I'm not sure if its an easy fix or not. As an incentive, … -
How to bulk update with multiple values?
Here I have list of dates which I want to update in my Model. models class MyModel(models.Model): fk = models.ForeignKey(A, on_delete=models.CASCADE, related_name='dates') date = models.DateField() # views dates = self.request.POST.getlist('date') if dates: objs = [] for date in dates: objs.append(MyModel(date=date, fk=fk)) MyModel.objects.bulk_create(objs) Now I got problem while implementing bulk_update method. I tried this. for date in dates: MyModel.objects.update_or_create(date=date, fk=fk) But this will return get return more than .. objects if there are dates with same value and if all date value unique then it creates another instead of update -
There is any missing import function
Error in django [Code][2]tps://i.stack.imgur.com/FdPLe.png Exception page -
django rest framework update nested serializer by id
How to update a list in a nested serializer by id I have a user who has multiple contacts Example: contact serializer class ContactSerializer(serializers.ModelSerializer): class Meta: model = Contact fields = [ 'id', 'name', 'last_name' ] user serializer class UserSerializer(serializers.ModelSerializer): email = serializers.EmailField( required=True, validators=[ UniqueValidator(queryset=User.objects.all()) ] ) contacts = ContactSerializer(many=True) class Meta: model = User fields = [ "email", "contacts" ] def update(self, instance, validated_data): contacts_data = validated_data.pop('contacts') contacts = (instance.contacts).all() contacts = list(contacts) instance.name = validated_data.get('name', instance.name) instance.save() # many contacts for contact_data in contacts_data: contact = contacts.pop(0) contact.name = contact_data.get('name', contact.name) contact.last_name = contact_data.get('last_name', contact.last_name) contact.save() return instance I want to update contacts by ID, for now it works, but it only updates the first contact in the list Any ideas or recommendations? -
Python ModelFormSets
Recently I have been trying to learn more about Python Forms and Formsets. I have been trying to apply a queryset on to a modelform_factory function. However, everytime it results in this "init() got an unexpected keyword argument 'queryset'" error. From documentation I thought that you could pass a model query onto a modelformset after it has been initialized with that model. Hey is a small section of my example code. PolicyFormSet = modelform_factory(model=PolicyProcedures, fields='__all__') formset = PolicyFormSet(queryset=PolicyProcedures.objects.filter(auditid=request.session["auditID"]).distinct()) Am I missing something fundamental here? I am only trying to display a list of forms with initial data from the mysql database. -
django.db.utils.IntegrityError: null value in column "old_column" violates not-null constraint
I get a very strange error in my tests: django.db.utils.IntegrityError: null value in column "old_column" violates not-null constraint E DETAIL: Failing row contains (68, , f, , null, f). But "old_column" does not exist in my DB any more. It was there some hours ago, but this column was renamed to a different name. If I check the database with psql mydb or manage.py dbshell and then inspect the db with \d appname_tablename then I clearly see that "old_column" does not exist any more. I have no clue why the DB (PostgreSQL) thinks that this column is still there. -
How to encode json passed from django by javascript in template
I path json object to template as context, and want to use this in template. it look like this in source code of browser var json = "{&#x27;meta&#x27;: {&#x27;chord_style&#x27;: &#x27;bossa&#x27; How can I encode this string as json object??? -
How to pull data specific to a user on login for a dashboard?
I am trying to build a user dashboard in Django. A lot of the things I have found online are for one to one relationships, which is fine, but they are for things like user -> order and pulls the data for a specific order thats only one table. I need to iterate over multiple tables and look for a one to one relationship then pull that data for the user. What I am trying to do, is when the user logs in, the system searches through records across different models, then when there is a match with the user, like email match, and it returns all of that data to their user dashboard. Example: User Email = Order Type 1 --- Order Type 2 (has User Email) --- Order Type 3 | User <-> Order Type 2 | returns Data Record from Order Type 2 in dashboard for User Is this a One to One or a One too Many even though there is only one data record for each user? -
How can I restrict user to to view only specific page having a dynamic URL?
I am doing a project in which I have created a model form for employee details. Now, I want the user to be able to update only their records through the employee form and the URL of this employee form is dynamic. In this project, I am populating the user authentication model from views.py and have not provided the option for creating the user from the front end because the idea behind not providing the option for user creation from the front end is to create a user automatically when someone creates a new employee record. So, to populate the user authentication model, for the employee whose record has been created recently. I am applying the concatenation on the first name, last name and on the primary key to generate a user name and for the password, I am generating a random password. on the home page, I have generated a list view of Employee records and also provided a link for view (to see the complete details of a particular employee) and another link for updating the records which is a dynamic URL (update/<int: id>/). Now, I want the user to be able to only update his record not … -
How do I create a search bar that filters through the names of entries and displays a list of them? (I am working on CS50 Project 1)
This is my code in Django that makes the search bar work. def search(request): entry_list = util.list_entries() query = request.GET.get("q", "") if query in entry_list: return redirect(get_entry, query) if query in entry_list == "i": filtered_i = [entry for entry in entry_list if 'i' in entry] return render(request, "encyclopedia/index.html", { "entries": filtered_i }) The error statement: The view encyclopedia.views.search didn't return an HttpResponse object. It returned None instead. If you remove the if statement, the search bar will be able to filter i but only i. How do I make this work for every letter in the alphabet? -
Django: os.path.join (BASE_DIR, 'home') is not working correctly
Django: os.path.join (BASE_DIR, 'home') is not working correctly. 'os' is not defined but I already defined it. How to solve the problem. The following screenshot demonstrates it very well. enter image description here The following exception generating over and over again. enter image description here -
How to send an email to currently logged in user Django
I am currently trying to set up a view so when the user visits the path /clip it will send an email to the user's inbox. Eg. I visit path, email turns up in my inbox. I am using this: from django.core.mail import send_mail def clippy(request): current_user = request.user subject = "test" message = "testing" recipient_list = [current_user.email] send_mail(subject, message, recipient_list) I'm using 3.0.4 and get this error when I visit the path: send_mail() missing 1 required positional argument: 'recipient_list' Can anyone help? Thanks -
creating serializer and views for multiple image upload and many-to-many relations to tags
I had to repost this question because my model became more complex. I am trying to create a multiple image upload with image-tagging. "Tags" have a many-to-many relationship with "Images". The forms are in the React.js in the front-end. I am trying to understand how to write a serializer and view for this. I have not seen a clear solution to this online. upload/models.py from django.db.models.fields import UUIDField from django.contrib.postgres.functions import RandomUUID def upload_path(instance, filename): return '/'.join(['images', str(instance.image), str(instance.hashtags), str(instance.shape), instance.date_created, filename, filename, ]) class Themes(models.Model): theme = models.CharField(max_length=10, default=None) class Image(models.Model): image = models.ImageField(blank=True, null=True) contributor = models.ForeignKey( 'accounts.User', related_name='+', on_delete=models.CASCADE, default='0') caption = models.CharField(max_length=100) id = UUIDField(primary_key=True, default=RandomUUID, editable=False) class Shape(models.Model): shape = models.ImageField(blank=True, null=True) contributor = models.ForeignKey( 'accounts.User', related_name='+', on_delete=models.CASCADE, default='0') id = UUIDField(primary_key=True, default=RandomUUID, editable=False) class HashTags(models.Model): hashtag = models.ManyToManyField(Image, through='Post', default=None) class Post(models.Model): theme = models.ForeignKey(Themes, on_delete=models.CASCADE, default=None) image = models.ForeignKey(Image, on_delete=models.CASCADE) shape = models.ForeignKey(Shape, on_delete=models.CASCADE) hashtags = models.ForeignKey( HashTags, on_delete=models.CASCADE, default=None) date_created = models.DateTimeField(auto_now_add=True, null=True) upload_data = models.ImageField(upload_to='upload_to') upload/serializer.py from rest_framework import serializers from .models import Image, Shape, HashTags, Post, Themes class ThemesSerializer(serializers.ModelSerializer): class Meta: model: Themes fields: ('theme') class HashTagsSerializer(serializers.ModelSerializer): class Meta: model = HashTags fields = ('hashtag') class ImageSerializer(serializers.ModelSerializer): hashtags_list = HashTagsSerializer(many=True, … -
Django: Module import error with shell_plus --notebook
In a Django project: python manage.py shell_plus --ipython is loading as expected with model imports, e.g., working just fine. When trying to python manage.py shell_plus --notebook Jupyter will start. But when trying to create a new django shell plus notebook I will get the following import error: [I 12:43:00.851 NotebookApp] Kernel started: 68eac163-4064-41ac-824d-5c839562814c, name: django_extensions [IPKernelApp] WARNING | Error in loading extension: django_extensions.management.notebook_extension Check your config files in /home/pumpkin/.ipython/profile_default Traceback (most recent call last): File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/IPython/core/shellapp.py", line 261, in init_extensions self.shell.extension_manager.load_extension(ext) File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/IPython/core/extensions.py", line 87, in load_extension if self._call_load_ipython_extension(mod): File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/IPython/core/extensions.py", line 134, in _call_load_ipython_extension mod.load_ipython_extension(self.shell) File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/django_extensions/management/notebook_extension.py", line 10, in load_ipython_extension style=no_style(), File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/django_extensions/management/shells.py", line 152, in import_objects setup() File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/django/__init__.py", line 19, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/django/conf/__init__.py", line 79, in __getattr__ self._setup(name) File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/django/conf/__init__.py", line 66, in _setup self._wrapped = Settings(settings_module) File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/site-packages/django/conf/__init__.py", line 157, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/home/pumpkin/miniconda3/envs/django22/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, …