Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django user management best practices
I'm building an API for a mobile app using django and I'm wondering what are the best practices for managing the users of my app? Should I extend the default User model provided by django (which provides fields for admins as well) or should I create my own User model and figure out authentication for it? The default User model has things more related to admins like permissions and groups. Is this model meant to be used by non-admin users as well? -
How can get image which is uploaded in HTML page , In Django
I made an HTML form which uploaded the image and that image I have to use in Django Views to perform something of that image, how can I do? -
Django + uWSGI server stuck when accessing Twitter
I'm operating the Django + uWSGI application with social-auth-app-django package. (social-auth-app-django: https://python-social-auth-docs.readthedocs.io/en/latest/configuration/django.html) My problem is that the uWSGI server sometimes stuck, or all workers are busy. I was getting to the root of the problem for months, and then I found that a uWSGI process stuck for a long time (60 sec+) after dumping the following message (I used strace command): socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 14 connect(14, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("104.244.42.194")}, 16 "104.244.42.XXX" is Twitter API server's IP. I'm wondering, however, why it takes for a long time. I guess that this request is OAuth because my application uses only Twitter OAuth API, so I set a timeout to the configuration file of social-auth-app-django, as follows: SOCIAL_AUTH_URLOPEN_TIMEOUT = 5 but it never resolve the probrem... I want to know: Is there a case Twitter OAuth takes such a long time, and Why? Is it really OAuth request, or something else? -
in django models.py how to make remain quantity column of item table change automatically?
class Item(models.Model): name=models.CharField(max_length=100) price=models.DecimalField(max_digits=6, decimal_places=2) quantity=models.IntegerField(default=0) sold=models.IntegerField(default=0) qtt=0 def countremain(self): qtt=self.quantity-self.sold return qqt remain=models.IntegerField(qqt) in admin page I can change manually remain value, but I want to make it automatically. what I have to change or add to the code above? Please help. Thanks in advance! -
Use test db for Django's built-in testing with SQLAlchemy ORM
I have a project running in Django and connecting do SQLAlchemy ORM via sessionmaker, as showed below. It basicly handles http methods with a specified API (GET, POST, DELETE) and returns, posts, updates or deletes db entries. from sqlalchemy import create_engine from sqlalchemy.orm.session import sessionmaker self.session = sessionmaker( bind=create_engine('mysql+pymysql://user:pw@127.0.0.1/db') Under myproject.settings I am using defaults like 'ENGINE': 'django.db.backends.sqlite3',. I would like to test whether the API is working as intended by simply interating through all possible methods and URIs which seem necessary to test. Testing is done with Django's TestCase class and its Client module. Works quite fine. My Problem: It is altering (especially deleting and updating columns within) the real db. Rather than using the "created and destroyed test_db" as Django's test output might indicate it is using the real db. I kinda get why (I am bypassing Django's built-in db-connection with my SQLAlchemy connection), but I am interested in how to fix this, i.e. using a true test_db. Currently I am using a read-only mysql-user for testing, but that prevents me from testing actual POST and DELETE requests. I could try to use a different db for testing by mocking, but I would prefer another solution (I would … -
Django 1.11 - How can I ensure TruncYear to produce Zulu time
I am using Django 1.11 and Postgres 9.4. How can I ensure TruncYear to produce Zulu time (2019-10-01T00:00:00Z). I notice it creates datetime with timezone like this (2017-01-01T00:00:00+03:00) Here is my code for the TruncYear queryset: from django.db.models import Count from django.db.models.functions import TruncMonth, TruncYear, TruncDay, TruncHour tracking_in_timeseries_data = Tracking.objects.annotate( year=TruncYear('created_at')).values('year', 'venue').annotate( count=Count('employee_id', distinct = True)).order_by('year') >>> for exp in tracking_in_timeseries_data: ... print(exp['year'], exp['venue'], exp['count']) 2017-01-01 00:00:00+00:00 4 1 2019-01-01 00:00:00+00:00 2 2 2019-01-01 00:00:00+00:00 3 1 2019-01-01 00:00:00+00:00 4 1 2019-01-01 00:00:00+00:00 5 1 2019-01-01 00:00:00+00:00 6 1 >>> tracking_in_timeseries_data <QuerySet [{'venue': 4, 'year': datetime.datetime(2017, 1, 1, 0, 0, tzinfo=<UTC>), 'count': 1}, {'venue': 2, 'year': datetime.datetime(2019, 1, 1, 0, 0, tzinfo=<UTC>), 'count': 2}, {'venue': 3, 'year': datetime.datetime(2019, 1, 1, 0, 0, tzinfo=<UTC>), 'count': 1}, {'venue': 4, 'year': datetime.datetime(2019, 1, 1, 0, 0, tzinfo=<UTC>), 'count': 1}, {'venue': 5, 'year': datetime.datetime(2019, 1, 1, 0, 0, tzinfo=<UTC>), 'count': 1}, {'venue': 6, 'year': datetime.datetime(2019, 1, 1, 0, 0, tzinfo=<UTC>), 'count': 1}]> And if I serialize it produce this: serializer.py class TimeseriesYearSerializer(serializers.ModelSerializer): venue = VenueTSSerializer(read_only=True) year = serializers.DateTimeField(read_only=True) count = serializers.IntegerField(read_only=True) class Meta: model = Tracking fields = ['venue', 'year', 'count'] output: [ { "count": 1, "year": "2017-01-01T00:00:00+03:00", "venue_id": 2 }, { "count": 1, … -
Django Rest Framework: serializer for two models that inherit from a common base abstract model
There is an abstract model that defines an interface for two child models. I've been asked to create an API endpoint that will return instances from those child models (including only the common fields defined thanks to the interface father class). The problem raises when defining the Serializer.Meta.model attribute. Anyway, code is always clearer: models.py class Children(Model): class Meta: abstract = True def get_foo(self): raise NotImplementedError class Daughter(Father): def get_foo(self): return self.xx class Son(Father): def get_foo(self): return self.yy api/views.py class ChildrenApiView(ListAPIView): serializer_class = ChildrenSerializer def get_queryset(self): daughters = Daughter.objects.all() sons = Son.objects.all() return list(daughters) + list(sons) serializers.py class ChildrenSerializer(ModelSerializer): foo = CharField(source="get_foo", read_only=True) class Meta: model = Children # <========= HERE IS THE PROBLEM fields = ('foo',) Some thoughts; I know I'm not able to point out to the abstract model Children (wrote it for showing the inntention) I tried to leave ChildrenSerializer.Meta.model empty Seems that I can choose whichever Daughter or Son but not sure if that solution has any side-effect or is the way to go. -
Django Create New entries corresponding to existing Foreign Key database entries
I have a Table Books which has 100 entries. class Books(models.Model): name = models.CharField(max_length=30) I have another Table Titles which is newly created and has a Foreign Key relation. class Titles(models.Model): book = models.ForeignKey(Books, on_delete=models.CASCADE) .......... Can I automatically create 100 new entries for Titles based on the existing entry for Books? Or does changing Foreign Key to a different relation help? Please help me out or point me in the right direction. Thank you in advance. -
How to access user object in Django Djoser token serializer
I have the following in settings: DJOSER = { 'SERIALIZERS': { 'token': 'api.api.MyTokenSerializer' } } And here is that serializer, used for login: class MyTokenSerializer(TokenSerializer): auth_token = serializers.CharField(source="key") registration_complete = serializers.BooleanField(source="user.registration_complete", read_only=True) app_mode = serializers.CharField(source="user.app_mode", read_only=True) class Meta: model = djoser_settings.TOKEN_MODEL fields = ("auth_token", "profile_complete", "app_mode") and now I need to add one more field, but that field is a method field and it needs the user object. In pseudocode: class MyTokenSerializer(TokenSerializer): ... new_field = my_method(user_object) ... But I don't understand how to access the user object in this serializer. I see that the user object is used as a source in two fields (registration_complete and app_mode) but I don't know how to access it directly in order to pass it to the method. Is it possible to access the user object here? -
AJAX form submission executing multiple times - boostrap modal
I have a Django website with bootstrap modal with form. This is how I submit the form: $(function () { let clicked = 0; $('body').on('click', 'button.modal_submit', function (e) { clicked += 1; if (clicked <= 1) { e.preventDefault(); $.ajax({ url: "{% url 'insert_into_reference_table' ref_tab 1 %}", type: 'POST', data: $('#form1').serialize(), success: function (data) { alert(data); } }); } }); }); However, sometimes the success ajax function is executed twice (lets say in 1 of 30 submissions). Can anyone help me to find the solution? -
Django 1.11 - convert a datetime string with timezone 2018-01-01T00:00:00+03:00 into datetime object to be used for queryset
I am using Django 1.11 and Postgres 9.4. How can I convert this 2018-01-01T00:00:00+03:00 into a datetime object that can be used for queryset like below Tracking.objects.filter(created_at__gte=input_datetime) for Z time I can use this: input_datetime = datetime.datetime.strptime("2019-11-01T01:36:56.233032Z", "%Y-%m-%dT%H:%M:%SZ") but how can I make it work for this time (which seems to have timezone). I tried this but it didnt work. input_datetime = datetime.datetime.strptime('2018-01-01T00:00:00+03:00','%Y-%m-%dT%H:%M:%S.%f%z') Here is my model.py class Tracking(models.Model): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) -
Django Memcache variable being set on server startup, not in view containing decleration
I am trying to use Memcache on Django and Heroku. I have followed the steps in the Heroku devcenter for setting up Memcache with Django (https://devcenter.heroku.com/articles/django-memcache). I only want to do a very simple .set() to add a variable to the cache. I set the cache variable in a view and have a print statement just to check it works, and I think what SHOULD happen is when that view is called, the cache variable is set. However, I see that when I start up my development server, the variable is set on startup, instead of when the view is called. Have I gone wrong in the setup somewhere? Is this how Memcache on Django is supposed to work? -
I not understand this code and dont know how to use it?
I took the code from the tutorial, and I need a professional look and description step by step views.py @login_required @transaction.atomic def update_profile(request): if request.method == 'POST': user_form = UserForm(request.POST, instance=request.user) profile_form = ProfileForm(request.POST,instance=request.user.profile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, _('Your profile was successfully updated!')) return redirect('settings:profile') else: messages.error(request, _('Please correct the error below.')) else: user_form = UserForm(instance=request.user) profile_form = ProfileForm(instance=request.user.profile) return render(request, 'profiles/profile.html', { 'user_form': user_form, 'profile_form': profile_form }) -
Docker for django development auto update
Software used: Django 2.2.7 Docker 19.03.4 community OS = Ubuntu 18.04 I come from a background of vagrant where have previously set up an environment where I basically have a virtualenv lookalike but inside of a virtual machine. That is to say; I booted up the vagrant machine and using provisioning I installed all the required packages and requirements. Then on my host machine I had installed Eclipse and have the django project located. The last step for me was to bind these together using shared resources. This way I had ensured to always have up to date code. For those unfamiliar to Django; the runserver command is by default set to listen to code changes and "restarts" (not really) on every change immediately reflecting the change in the browser. Inside of the virtual machine I would then run the "runserver" command and thus being able to develop in such a way. Now using docker (I have to tie some software together and ultimately deploy using docker) I try to somewhat replicate this situation. I got my django docker up and running using a simple Dockerfile based off of python-3.7.5-stretch. The container runs fine as does django itself, however the … -
django with ajax: function not loading from source file
In my django project i'm trying to add a datepicker using jQuery. but when a load page in browser, the browser console gives error like "Uncaught TypeError: $(...).datepicker is not a function" but same ajax code i tried in simple html page then its working. why this datepicker() function is not loading in django from source location? <!doctype html> <html lang="en"> <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://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <title>Hello, world!</title> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> </head> <body> <script> $( function() { $( "#datepicker" ).datepicker(); } ); </script> <p>Date: <input type="text" id="datepicker"></p> {% block contents %} {% endblock %} </body> </html> -
Return user if exists or create new
I'm trying to implement a view in Django/DRF that given a body containing facebook_id, first_name, last_name and email, the function checks if a user already exists in the database with either the email or the facebook_id. If not, then I create a new user and save it. I'm trying to do this with a serialzier and I'm not sure what the correct approach is. I want to use the same serializer I used for sign ups which is this: class ClientSerializer(serializers.ModelSerializer): class Meta: model = Client exclude = ['password'] It contains a lot of unnecessary fields that I wont need in this new view (such as phone number). Should I create a new seralizer just for this view? Also should I depend on the is_valid() function on the serializer to tell me if the user exists (if it raises an error) or is that too unreliable since the fields might be invalid? Here's what I have so far: @api_view(['POST']) def facebook_login(request): print(request.data) serializer = ClientSerializer(data=request.data) if serializer.is_valid(): # create a new user else: # possibly perform a get on the database to return the existing user? return Response(serializer.errors) -
How get information from three different tables at once?
I have following models: class Device(models.Model): name = models.CharField(max_length=100, blank=False) description = models.TextField(max_length=500, blank=True) ip_address = models.GenericIPAddressField(blank=True, null=True) contact_person = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) team = models.ForeignKey(Team, on_delete=models.SET_NULL, null=True) category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True) def __str__(self): return self.name class TimeSlot(models.Model): name = models.CharField(max_length=20) start_slot = models.CharField(max_length=10) end_slot = models.CharField(max_length=10) def __str__(self): return self.name class Reservation(models.Model): device = models.ForeignKey(Device, on_delete=models.CASCADE) time_slot = models.ForeignKey(TimeSlot, on_delete=models.CASCADE) date_of_reservation = models.DateField() user = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return "{} - {} for device: {} by {}.".format(self.time_slot, self.date_of_reservation, self.device, self.user) class ForbiddenSlot(models.Model): device = models.ForeignKey(Device, on_delete=models.CASCADE) time_slot = models.ForeignKey(TimeSlot, on_delete=models.CASCADE) def __str__(self): return str(self.time_slot) This is simple reservation system. I have problem to understand how create query for three different tables. I want get all TimeSlots which are not set in ForbiddenSlot and Reservation for given Device name. -
Attach Multiple PDF files in email attachment using Django
I am trying to use django's core emailing functionality but for some reason I cant seem to find a way to attach 2 files in one email. I have tried to put the files in an array but this throws an error. Sending one file works but as soon as i create an array it stops working. Below are the steps I have taken. In my views.py i have from django.core.mail import EmailMessage and below is the part I am trying to send the 2 email attachments. msg = EmailMessage('Email Subject', 'Test Email', 'from@email.com', ['test@gmail.com']) msg.content_subtype = "html" msg.attach_file(['product/y.pdf', 'product/x.pdf']) msg.send() Please help. -
Testing a form on Django
I am trying to run a test on a form. It keeps returning invalid. Other forms work fine though. The form in forms.py: class SongForm(forms.ModelForm): class Meta(): model = Song fields = ('title', 'type', 'audio_file', 'description', 'written_by', 'song_text') The model the form comes from in models.py: class Song(models.Model): title = models.CharField(max_length=120) SONG_TYPES = ( ('KI', 'Kiirtan'), ('PS', 'Prabhat Samgiita'), ('BH', 'Bhajan'), ) type = models.CharField(max_length=30, choices=SONG_TYPES) capo = models.PositiveIntegerField(blank=True, null=True, validators=[MaxValueValidator(12)]) description = models.TextField(blank=True) uploader = models.ForeignKey('Profile', null=True, on_delete=models.SET_NULL) written_by = models.CharField(max_length=50, blank=True) song_text = models.TextField(blank=True) audio_file = models.FileField(upload_to='songs/') upload_date = models.DateField(auto_now=False, auto_now_add=True) edit_date = models.DateField(auto_now=True, auto_now_add=False) chords = models.ManyToManyField('Chord', related_name='chords', through='ChordIndex') The test in tests/test_forms.py: def test_Song_form_is_valid(self): the_data = { 'title': 'a song', 'type': 'KI', 'description': '', 'written_by': '', 'song_text': '', } form = SongForm(data=the_data) self.assertTrue(form.is_valid()) The form works correctly in the web app with a POST method. I even tried copying the values from a valid POST on the test and it still failed! I've been stuck with this for a while... Any clues? 🙏🏼 -
Best way to save hidden fields from CreateView that have unique_together constraint?
I found a lot of questions and answers on this topic but all of them leave me confused as to what would be the best way to handle this and it seems a lot of aspects have to be considered (e. g. I read about putting the validate_unique() function into the ModelForm but some say it would be unsafe to pass the user to the form) I want to build a form that users can use to register for an event. The event is derived from the url, the user from the request. Hence I don't actually need it in the form. The issue then is to conduct a check for the together_uniqueness as there can only be one registration per user per event. Currently my code looks like this: models.py: class Participant(models.Model): class Meta: constraints = [models.UniqueConstraint(fields=["user", "event"], name="user_unique_per_event")] user = models.ForeignKey(LocalUser, on_delete=models.PROTECT) event = models.ForeignKey(Event, on_delete=models.CASCADE) participating = models.BooleanField() forms.py: class EventRegistrationForm(forms.ModelForm): class Meta: model = Participant fields= ['participating'] views.py: class EventRegistrationView(CreateView): template_name = 'events/event_registration.html' form_class = EventRegistrationForm queryset = Event.objects.all() def form_valid(self, form): form.instance.event = Event.objects.get(slug=self.kwargs['slug']) form.instance.user = self.request.user What's the best way to implement a check regarding the unique_together constraint? What's the best way to handle … -
How to call stored PostgreSQL function in Django?
I have a stored function in PostgreSQl. I want to call this function through django and connect with a regular query(According to the table PayrPaymentSource). How to do it? Function: CREATE OR REPLACE FUNCTION select_cards() RETURNS TABLE(payer_id bigint , source_details jsonb) AS $$ SELECT payer_id as payer_id, source_details as source_details FROM "processing"."payer_payment_source" WHERE payment_type_id = 'bank_card_details'; $$ LANGUAGE sql; views.py query paymentsss = Transaction.objects.all().select_related('currency', 'payment_source__payment_type', 'deal__service__contractor') models.py class PayerPaymentSource(models.Model): id = models.BigIntegerField(blank=True, null=False, primary_key=True) payer_id = models.BigIntegerField(blank=True, null=True) payment_type = models.ForeignKey(PaymentType, max_length=64, blank=True, null=True, on_delete=models.CASCADE) source_details = models.TextField(blank=True, null=True) # This field type is a guess. class Meta: managed = False db_table = '"processing"."payer_payment_source"' class Transaction(models.Model): id = models.BigIntegerField(blank=True, null=False, primary_key=True) currency = models.ForeignKey(Currency, null=True, on_delete=models.CASCADE) deal = models.ForeignKey(Deal, null=True, on_delete=models.CASCADE) # service_instance = models.ForeignKey(ServiceInstance, null=True, on_delete=models.CASCADE) payment_source = models.ForeignKey(PayerPaymentSource, null=True, on_delete=models.CASCADE) payment_date = models.DateTimeField(blank=True, null=True) amount = models.IntegerField(blank=True, null=True) status = models.CharField(max_length=255, blank=True, null=True) context = models.TextField(blank=True, null=True) -
How to combine boostrap paginator and select to filter a table?
I currently use paginator on a table. I want to add a select to filter the table but I do not manage how to navigate through pages without loosing my selection currentlty (see code below) when I navigate by clicking on previous or next, option selected by used is lost and all data are presented I must change the 'else' condition to take account the option selected I was thinking about using global variable to store option selected in a variable but it can have side-effect and it is not so recommanded... views.py @login_required def index(request): # data sent (click on 'search' button or option selected) if request.POST: # data from select selection = request.POST.get('selection', False) # data from search ide = request.POST.get('ide', False) # search if ide == "": paginator = Paginator(Preinclusion.objects.all(), 5) preincluded = paginator.page(1) else: paginator = Paginator(Preinclusion.objects.filter(pat_num__startswith = ide),5) preincluded = paginator.page(1) # select if selection == 'Randomized': print('Randomized') paginator = Paginator([patient for patient in Preinclusion.objects.all() if patient.is_randomized], 5) preincluded = paginator.page(1) elif selection == 'Not randomized': print('Not randomized') paginator = Paginator([patient for patient in Preinclusion.objects.all() if not patient.is_randomized], 5) preincluded = paginator.page(1) elif selection == 'All patients': print('All patients') paginator = Paginator(Preinclusion.objects.all(), 5) preincluded = … -
Object of type QuerySet is not JSON serializable Django
When I am trying to send values in JsonResponse then The error is coming(object of type QuerySet is not JSON serializable ) def ajaxAgent(request): data = CommCenter.objects.values() responseData = { 'status': 'success', 'msg' : data} return JsonResponse(responseData) -
Override attribute of an abstract ModelField in django
I'd like to add an unique=True attribute to content_meta from Notification abstract model in EmailNotification, is there any way to do this without redeclaring the variable in the child model? class Notification(BaseModel): content_meta = models.CharField(max_length=3, unique=True) content_template = models.TextField() class Meta: abstract = True class EmailNotification(Notification): MISSING_TRANSACTION_ASSOCIATIONS = 'MTA' NON_ASSIGNED = 'N/A' META_CHOICES = ( (MISSING_TRANSACTION_ASSOCIATIONS, _('Missing transaction associations')), (NON_ASSIGNED, _('Non assigned')) ) content_meta = models.CharField(max_length=3, choices=META_CHOICES, default=NON_ASSIGNED, unique=True) def __str__(self): return self.content_meta -
No module named 'LoginForm.LoginForm'
I am creating a Django application and I am facing this issue can you please help me solve it.. Here is the error : Traceback (most recent call last): File "manage.py", line 21, in main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 336, in run_from_argv connections.close_all() File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 219, in close_all for alias in self: File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 213, in iter return iter(self.databases) File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\functional.py", line 80, in get res = instance.dict[self.name] = self.func(instance) File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 147, in databases self._databases = settings.DATABASES File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf__init__.py", line 79, in getattr self._setup(name) File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf__init__.py", line 66, in _setup self._wrapped = Settings(settings_module) File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf__init__.py", line 157, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "C:\Users\vaidehi.shejwalkar\AppData\Local\Programs\Python\Python38-32\lib\importlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 973, …