Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to view value of related foreign key in Django from multiple models
I have the following models in my Django project from different apps Student App Model from django.db import models import batch.models import course.models class Student(models.Model): ACTIVE = 'Active' DROPPED = 'Dropped' TRANSFERRED = 'Transferred' INACTIVE = 'Inactive' studentStatus = [ (ACTIVE, 'atv'), (DROPPED, 'drp'), (TRANSFERRED, 'trf'), (INACTIVE, 'inv'), ] first_name = models.CharField('First Name', max_length=30) last_name = models.CharField('Last Name', max_length=30) student_batch = models.ManyToManyField(batch.models.Batch,related_name='batch') contact_no = models.CharField('Contact No', max_length=20, null=True, blank=True) email_address = models.EmailField('Student Email', null=True, blank=True) student_status = models.CharField('Student Status', max_length=20, choices=studentStatus, default=ACTIVE) student_remark = models.CharField('Student Remark', max_length=255, null=True, blank=True) student_course = models.ManyToManyField(course.models.Course,related_name='course') created_on = models.DateTimeField(auto_now_add=True) updated_on = models.DateTimeField(auto_now=True) def __str__(self): return f"{self.first_name} {self.last_name}" Batch App Model from django.db import models from datetime import date, timezone import course.models import trainer.models from django.contrib.auth.models import User class Batch(models.Model): ACTIVE = 'Active' HOLD = 'Hold' SCHEDULED = 'Scheduled' CANCELED = 'Canceled' TRANSFERRED = 'Transferred' batchStatus = [ (ACTIVE, 'act'), (HOLD, 'hld'), (SCHEDULED, 'scd'), (CANCELED, 'cld'), (TRANSFERRED, 'trd'), ] batch_course = models.ForeignKey(course.models.Course, on_delete=models.SET_NULL, blank=True, null=True) batch_trainer = models.ForeignKey(trainer.models.Trainer, on_delete=models.SET_NULL, blank=True, null=True) batch_time = models.TimeField('Batch Time', blank=True, null=True) batch_start_date = models.DateField('Batch Start Date', default=date.today) created_by = models.ManyToManyRel('Batch Created By', to=User) batch_status = models.CharField('Batch Status', choices=batchStatus, default=ACTIVE, max_length=20) created_on=models.DateTimeField(auto_now_add=True) updated_on=models.DateTimeField(auto_now=True) def __str__(self): return f"{self.batch_course} | {self.batch_time} | … -
Pass dropdown selected:option text that is being printed to cosole.log() or HTML page to python terminal in views.py
I want to get the option text of selected option from dropdown as a variable in views.py that are being printed in console.log() or which are being displayed on HTML page. Like AMBALA being displayed on HTML or console.log() here I am quite new to Django, so not sure how to fetch it. However, the question is related to the previous query as in here. for getting text of option, the Jquery is as: function get_district_text(){ display_district_text = $("#district_from_dropdown option:selected").text(); console.log("to_display", display_district_text) to_display = document.querySelector("#query_btn_Distdisplay").textContent=display_district_text } index.html is as <div > <input type="submit" value = "click", onclick="get_district_text()"> <b name="query_btn_Distdisplay" id="query_btn_Distdisplay"> </b> </div> In views.py StateName & DistrictName are being parsed or showing text but DistrictNameText is giving print output as None def inputconfiguration(request): if request.method == "POST": StateName=request.POST.get('state_from_dropdown') DistrictName=request.POST.get('district_from_dropdown') DistrictNameText = request.POST.get('query_btn_Distdisplay') print(StateName, DistrictName, DistrictNameText ) return render(request, 'configure_inputs.html') How to get the text of DistrictNameText as a python variable in views.py? -
How to convert raw query to django orm query?
I was trying this morning onwords but couldn't get as excepted result and i'm learning something today with this could you guys help me to get this. and i'm newby to django. SELECT Id, Name, PersonContactId, Phone, Ob_Designation__c, ClubName__c, Membershipno__c, FirstName, LastName, Religion__pc, LanguageName__pc, sfid FROM salesforce.Account WHERE producthierarchycode__c in (select distinct productcode__c from salesforce.dimmarketinghierarchy__c where mh2code__c = 'CCMDTEST') and WSS_Terri_Code__c in (SELECT WSSTerritoryCode__c FROM salesforce.DimMarketingHierarchy__c WHERE MH2Code__c = 'CCMDTEST') and (IsDeleted__c IS NULL OR IsDeleted__c != '1') ORDER BY createddate DESC limit 50 here is my query. -
Django as a websocket client
I know that Django Channels can be used to make websocket server, not client. So I used websockets to relay websocket incoming message to my Django like this: async def relay(): source_server = 'ws://source.example/ws/message' # This is an external server target_server = 'ws://target.example/ws/message' # This is my Django server async for target in websockets.connect(target_server): try: async for source in websockets.connect(source_server): try: while True: try: message = await source.recv() await target.send() # log message except websockets.ConnectionClosed as e: # lost source server or target server or both raise(e) except Exception as e: # did not lose servers continue except websockets.ConnectionClosed as e: # lost source server or target server or both if target.close_code is not None: # lost target server and need to start from the outer for loop # (to get a new target websocket connection) source.disconnect() raise(e) # lost source server and will continue the inner for loop # (to get a new source websocket connection) continue except Exception as e: # did not lose any server and will continue the inner for loop # (to get a new source websocket connection) continue except websockets.ConnectionClosed as e: # lost target server and will continue the outer for loop # … -
Django How do I check that a choices field is not blank in a filter
I have a choices field that can be blank review_comment = models.CharField(max_length=60, choices=REVIEW_COMMENT_CHOICES, blank=True) I now want to filter by review_comment!=blank e.g. return self.filter(active=True, review_comment!=blank) How can I achieve this? -
Unable to make requests to AWS mysql in ec2 instance after delpoying through eb cli
I'm using RDS MySQL from AWS and it works on a local machine I can successfully login to Django admin using the same db also can migrate and etc. But the problem is when I deployed this project with the same settings with EB CLI via ec2 instance, the project loaded successfully. except for the db operations, that does not work properly. I can't log in into admin, and that gives 504 Gateway Time-out That takes 60 sec to process the request but fails every time. But db operations are working on the local machines. For example, I tried making a GET request from localhost using the same db /api/v1/categories/1/ that gives me `200 response But when I tried from the same project hosted on ec2 instance it gives 504 response These are the eb configurations: packages: yum: python3-devel: [] mariadb-devel: [] option_settings: aws:elasticbeanstalk:application:environment: DJANGO_SETTINGS_MODULE: config.settings aws:elasticbeanstalk:container:python: WSGIPath: config.wsgi:application Some suggest increasing HTTP request processing time. But why does it's taking too long but works on the remote connection locally. from the local Django settings. Are there any extra settings to set up to handle this problem? Or what might be the solution could be? -
Python Django: Customize User
I only use the Rest_Api from Django 4.1 Python. Thats my project Setting: mealSheetAI setting.py mealSheetApi admin.py models.py models.py from django.db import models from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField( verbose_name='email address', max_length=255, unique=True, ) first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) USERNAME_FIELD = 'email' admin.py from django.contrib.auth.admin import UserAdmin from .models import User admin.site.register(User, UserAdmin) settings.py AUTH_USER_MODEL = 'mealSheetApi.User' -
How to load static file image in Vue component with Django Application
I am currently using laravel-mix, Django, and Vue together. I would like to load the static image inside the Vue component. My images store in static/img folder First of all, I have set up an alias in Webpack config pointing to the static folder. const path = require('path') let publicPath = 'src/static' module.exports = { resolve: { extensions: ['.js', '.vue'], alias: { '@': path.join(__dirname, publicPath) }, }, } And load the image in Vue component <img :src='require(`@/img/Blue.jpg`).default' alt=""> I can't load images and Webpack generated new images into the images folder. How to prevent it and load image correct -
django allauth google login
I'm learning how to develop a todo app with users using their google accounts and I found this tutorial https://www.tutorialspoint.com/google-authentication-in-django and I'm trying to create a log out button but its giving me an error Reverse for 'auth_logout' not found. 'auth_logout' is not a valid view function or pattern name. home.html {% load socialaccount %} <h1>Django Allauth Tutorial</h1> {% if user.is_authenticated %} <p>Welcome {{ user.username }}</p> {% else %} <a href="{% provider_login_url 'google' %}?next=/">Sign In</a> {% endif %} <a href="{% url 'auth_logout' %}?next=/"> Logout</a> urls.py from todo.views import todo_view, add_todo, delete_todo, home urlpatterns = [ path('', home), path('accounts/', include('allauth.urls')) ] settings.py LOGIN_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = '/' I just copy+paste this from another thread <a href="{% url 'auth_logout' %}?next=/"> Logout</a> -
DJANGO - HOW TO SAVE A FORM WITHIN A GET METHOD?
I have a view that will load specific data in order to store it on another table. But as I click on Save, it hasn't been reflected on the view using method POST. Have to load first some data on a table then post it to another table using the loaded data clicked on the select input. Can you pls help? Thanks <form action="{% url 'save_selectionlist' %}" method = "POST"> {% csrf_token %} <!--FORM HEADING--> <div class="row"> <div class="col-md-12 mx-0"> <div class="form-group col-md-9 col-sm-9 text-left"> <label for="disabledTextInput">Election Code: </label> <span class="lead">{{ get_election_code.code }}</span> </div> <div class="col text-right"> <button type="button" id= "AddButton" class="btn btn btn-outline-primary btn-sm">Add More +</button> </div> </div> </div> <!--THIS IS WHERE I LOAD DATA FROM VIEW--> <div class="row" id = "SelectionField"> <div class="col-md-12 mx-0" id = "field1"> <div class="col-md-4 col-sm-6 form-group text-left"> <select id ="selection-sh" name = "selection-sh" class="form-control form-control-sm sh" aria-label=".form-select-sm example"> <option selected>-- SELECT STOCKHOLDER --</option> {% for sh in get_stockholder %} <option value="{{sh.id}}" >{{sh.sh_fname|add:' '|add:sh.sh_lname}}</option> {% endfor %} </select> </div> <div class="col-md-4 col-sm-6 form-group text-left"> <select id ="selection-proxy" name="selection-proxy" class="form-control form-control-sm pr" aria-label=".form-select-sm example" disabled> <option selected>-- SELECT PROXY --</option> {% for pr in get_proxylist %} <option value="{{pr.id}}" >{{pr.sh_proxy_fname|add:' '|add:pr.sh_proxy_lname}}</option> {% endfor %} </select> </div> … -
How to pass update django model ID in knockout ajax success url and how to slice id with url
views.py def visitor(request,id): # fruser = get_object_or_404(FRUser,id=id) if request.method == "POST": uid = request.GET.get('visitor_nric_no') name = request.GET.get('name') company_name = request.GET.get('company_name') user_type = request.GET.get('userType') visit_purpose = request.GET.get('purposeOfVisit') valid_from_date = request.GET.get('validFrom') valid_till_date = request.GET.get('validTill') fruser = FRUser.objects.get(id=uid) fruser.name = name fruser.company_name = company_name fruser.user_type = user_type fruser.visit_purpose = visit_purpose fruser.valid_from_date = valid_from_date fruser.valid_till_date = valid_till_date fruser.save() print(fruser.name) context = {'fruser':fruser} return render(request, 'kiosk/visitor-checkIn/visitor-new-registration.html',context) knockout.js submitHandler: function() { var ViewModel = function () { var self = this; self.nric_no = ko.observable(""); self.save = function () { var formdata = new FormData(); formdata.append('nric_no', self.nric_no()); console.log(formdata) $.ajax({ type: 'POST', url: "http://127.0.0.1:8000/kiosk/kiosk/nric/api", data: formdata, headers: { 'X-CSRFToken': csrftoken }, processData: false, contentType: false, success: function () { alert('Success'); window.location = '/kiosk/kiosk/visitor/visitor-new-registration' + fruser.uid; }, error: function () { alert("fail"); } }); }; }; ko.applyBindings(new ViewModel()); }, }); How to give django model id in knockout js ajax succes url and how to slice id with url I want to pass django FRUser model uid to success url ajax knockout area how to pass that and I want to slice id with url how to solve this Thanks in advance -
How to replace line breaks (\n) with <br> for textual data to html content
I am loading data from a database. The textual data has line breaks \n as uploaded by the user, I would like to print this data on a html page. However line breaks do not occur. I have tried replacing \n with <br>, but that prints with <br> as part of the string instead of actually breaking the line. How I replace value['description'].replace('\n', '<br>') How it appears: -
ERROR: Could not find a version that satisfies the requirement Variation
Im trying to install Variation to Python by using pip install Variation and I encountered this problem ERROR: Could not find a version that satisfies the requirement Variation (from versions: none) ERROR: No matching distribution found for Variation What should I do ? -
Handling django form views using ajax
I am looking for more elegant way to solve this problem. Say I have say two buttons x, y in main.html: <input class= "btn-check", name = "options", id="x"> <label class="btn btn-lg btn-info", for="x">x</label> <input class= "btn-check", name = "options", id="y"> <label class="btn btn-lg btn-success", for="y">y</label> What I want to do is after the button is clicked, I will do something in python and so in django views I will create a view function for each of the buttons (my current implementation): funcX(request): booleanX = doSomethingforX() return JsonResponse({"success": booleanX}) funcY(request): booleanY = doSomethingforY() return JsonResponse({"success": booleanY}) and the ajax calls would be: $("[id='x']").on("click", function(e){ e.preventDefault(); $.ajax({ type:"GET", url: "{% url 'funcX' %}", success: function(response){ if(response.success == true){ //Do something } } }) }); The ajax call will be the same for button Y. Now, I was wondering if it is possible to do this with forms? Say the html becomes: <form method="POST", class="form-group", id="post-form"> <input type="submit", value="x", class= "btn-check", name = "options", id="x"> <label class="btn btn-lg btn-info", for="x">x</label> <input type="submit", value="y", class= "btn-check", name = "options", id="y"> <label class="btn btn-lg btn-success", for="y">y</label> </form> Then in django views I have a view for the main.html. This way it saves a lot of … -
Formar DecimalField as integer when there are no digits
I have a model with a DecimalField and a ModelForm for that model. When editing an instance of that model with a field value with no digits, I'd like the input to be formatted as a regular integer instead of a decimal number of with digits, e.g. I'd like to display 3 instead of 3.000. And only when there's actual digits they should be displayed. How can I override the way instance field values are displayed in a form? I tried with self.fields[fieldname].initial = formatted_value or formatting it through clean_fieldname but it didn't work. -
How to redirect back to a dynamic page after deleting a record in Django
I have the following working code to delete a record from a table through the following url/view and template: urls urlpatterns = [ path('portfolio/<str:pk>/', views.portfolio, name="portfolio"), path('delete_identifier/<str:pk>/', views.deleteIdentifier, name="delete_identifier"), ] View def portfolio(request, pk): portfolio = Account.objects.get(id=pk) identifiers = Identifier.objects.filter(account=pk) context = {"portfolio": portfolio, "identifiers": identifiers} return render(request, 'portfolio.html', context) def deleteIdentifier(request, pk): identifier = Identifier.objects.get(id=pk) identifier.delete() return redirect('portfolio') template (portfolio.html) <table class="table table-sm"> {% for item in identifiers %} <tr> <td>{{item.code}}</td> <td style="width:10px;"><a class="delete_btn" onclick="return confirm('Are you sure?');" href="{% url 'delete_identifier' item.id %}">Delete</a></td> </tr> {% endfor %} </table> However the issue is with my redirect in the view - I'm basically trying to go back to the same page where I'm deleting the record from 'portfolio' but am unable to. Instead I get redirected to: 127.0.0.1:8000/delete_identifier/882/ with the following error on on page: DoesNotExist at /delete_identifier/882/ Identifier matching query does not exist. My expectation is to be redirected back to the original page of: 127.0.0.1:8000/portfolio/205/ where I started from. I'd greatly appreciate some help in resolving this issue. Thanks in advance -
How to deal with missing columns on old data migrations?
I want to add a new column to a django model. However, I have a past data migration that creates an object of this model, which now doesn't work because the column didn't exist at the time of that migration. i.e. my model is: class MyModel(models.Model): name = models.CharField() foo = models.IntegerField() # <-- I want to add this column however my old migration is this: def add_my_model(apps, schema_editor): MyModel.objects.create(name="blah") class Migration(migrations.Migration): # ... operations = [ migrations.RunPython(add_my_model), ] And when I try to run migrations on a fresh db, this migration fails with an error similar to this: query = 'INSERT INTO "my_model" ("name", "foo") VALUES (?, ?)' params = ['blah', None] ... E sqlite3.OperationalError: table my_model has no column named foo What's the best way to deal with this situation? -
Python manage.py error, it´s for Intel M1?
I wanted to know if you could help me, the question is that when I do a makemigrations in Django or Python I get this error and I have not been able to fix it, and I have not been able to start the server to work, I do not know if something similar has happened and I can tell me what to do, it is on a MacBook M1 Traceback (most recent call last): File "/Users/jesusochoagonzalez/Documents/GitHub/cip_django/aplications/globaldata/views.py", line 1, in <module> from asyncio.windows_events import NULL File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/windows_events.py", line 6, in <module> raise ImportError('win32 only') ImportError: win32 only -
Adding variants of the same language to Django?
I am working on localization of a Django app, and the requirement dictated us to have 2 type of Traditional Chinese-- Taiwan and Hong Kong. However, looking at the Django code, ... ... ("vi", gettext_noop("Vietnamese")), ("zh-hans", gettext_noop("Simplified Chinese")), ("zh-hant", gettext_noop("Traditional Chinese")), ] It seems to only support one Traditional Chinese language. I tried putting the language zh-hant-hk in setings.py. But instead of falling back to the Traditional Chinese or English, I got an error instead. Had been looking at the documentation but didn't seem to be mentioned anywhere... -
Django AdminEmailHandler: Exception while resolving variable 'exception_type' in template 'unknown
I'm trying to get the admin error emails to work in Django REST. My logging configuration is like this: 'loggers': { 'django': { 'handlers': ['console', 'logfile', 'mail_admins'], 'level': 'DEBUG', 'propagate': True, }, }, When 'mail_admins' is included as a handler, if I try to throw an error on a view like this: @api_view() def index(request): a = 2/0 The division by zero error is thrown (as expected), but then I get another error and a long traceback that starts like this: DEBUG 2022-03-09 00:22:45,984 base 58083 123145391022080 Exception while resolving variable 'exception_type' in template 'unknown'. Traceback (most recent call last): File "/path/to/.venv/lib/python3.10/site-packages/django/template/base.py", line 875, in _resolve_lookup current = current[bit] File "/path/to/.venv/lib/python3.10/site-packages/django/template/context.py", line 83, in __getitem__ raise KeyError(key) KeyError: 'exception_type' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/path/to/.venv/lib/python3.10/site-packages/django/template/base.py", line 881, in _resolve_lookup if isinstance(current, BaseContext) and getattr( AttributeError: type object 'Context' has no attribute 'exception_type' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/path/to/.venv/lib/python3.10/site-packages/django/template/base.py", line 891, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'exception_type' -
Django project requirements that's not suitable for DigitalOcean App Platform?
For a django project with celery for async tasks, nginx, gunicorn, users and user uploaded files to aws s3, 3rd party api calls, displaying api response data and database queries etc... what does it mean that digitalocean app platform is for static sites, what exactly can't it do? I watched a video where it's explained that DO app platform can handle dynamic content with react etc but that it doesn't support background services. I'm not exactly sure what this means if you can use celery. Some people asked questions on digital ocean but didn't get an answer: https://www.digitalocean.com/community/questions/how-to-create-celery-worker-on-app-platform https://www.digitalocean.com/community/questions/what-are-the-limitations-of-digital-ocean-apps Also various videos and online posts don't really go into what non-static site features can't be used, it's just mentions that it's for static sites and data is ephemeral. Also the tutorial videos just deploy the default django app so I don't get to see what it can and can't be used for. In one post it says "if your app does require you to have access to the underlying infrastructure, you'll probably want to steer away from App Platform", what are examples of needing to access underlying infrastructure? Another comment from a post is "if your app doesn't have complex … -
Python : Log Decorator
Implement a decorator that logs the invocations of the decorated function to the provided file descriptor.You can assume that it will only decorate functions that take in positional arguments. The log line should follow this format Log: (comma separated call_paramters) theatre character should be new line. The line should be logged prior to the execution of the decorated functions body. -
Unable to get clear box and choose file button on same line as file in HTML Form
I created a form that shows my users email, username and a link of their profile picture, but I am unable to get the choose file and clear button and check box to be on the same line the form as the link and I am unsure as to why and I have tried changing the css but it does not let me change or implement them on the same line within the form. Html {% extends 'parasites_app/base.html' %} {% load static %} {% block content_block %} <!-- It has to be here to load content from the extending templates --> <link rel="stylesheet" type="text/css" href="/static/css/editprofile.css" xmlns="http://www.w3.org/1999/html"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <form id="EditProfile" method="POST" action="/edit_profile/" enctype="multipart/form-data"> <h2>Edit Profile</h2> <input type="hidden" name="csrfmiddlewaretoken" value="GSiPiZjdV1XpJ6I5tZJfXuHUqGXqFWBalLxoWCKB6DqfzPalNRm6X3uc2QFp5NuY"> {% csrf_token %} <br> <table> <tbody> <tr> <th><label for="id_email">Email:</label></th> <td><input type="email" name="email" value="hannah.bialic@glasgow.ac.uk" required="" id="id_email"> </td> </tr> <tr> <th><label for="id_username">Username:</label></th> <td><input type="text" name="username" value="hannah.bialic" maxlength="150" required="" id="id_username"><br></td> </tr> <tr> <th> <label for="id_picture">Current Picture:</label></th> <td> <li> <a href="/media/profile_images/parapic_Kuw8fB7.png">profile_images/parapic_Kuw8fB7.png</a> </li> <span><input type="file" name="picture" accept="image/*" id="id_picture"> Clear<input type="checkbox" name="picture-clear" id="picture-clear_id"></span> </td> </tr> </tbody> </table> <!-- Make changes button--> <div> <button type="submit" class="button">Make Changes</button> </div> </form> <script>$(".helptext").remove();</script> Css body { font-family: "Poppins", sans-serif; margin: 0; } h1 { text-align: left; font-family: "Poppins", sans-serif; color: white; … -
Django render_to_string not including certain context variables when rendering
I have searched here and not found anything so far that helps. When using render_to_string and providing context variables, one of these variables gets used by the template as expected, however, another variable seems completely ignored. The view. Creates a chunk of HTML consisting of the rendered thumbnail templates. NB: the 'image' context works fine! It is only the 'click_action' that seems to be ignored. def ajax_build_image_thumbnail(request): image_ids = request.POST.get('ids', None) html_string = '' response = {} for id in image_ids: image_instance = UserImage.objects.get(pk=id) context = { 'click_action': "showEditImageModal", 'image': image_instance, } html_string += render_to_string('auctions/includes/imageThumbnail.html', context) response['html'] = html_string return JsonResponse(response) The imageThumbnail template: <div id="{{ image.id }}"> <a href="#" data-click-action="{{ click_action }}"></a> </div> The result: <div id="265"> <a href="#" data-click-action=""></a> </div> The expected result: <div id="265"> <a href="#" data-click-action="showEditImageModal"></a> </div> So, as you can see, the data-click-action attribute on the anchor is blank in the rendered template, where it should contain the context variable "click_action" Things I have tried: Using autoescape Wrapping the anchor in a {% with %} tag and setting "click_action" as a local template variable. Hard-coding "click_action" in the view, and setting it to a variable. Switching the order of variables (thinking in case the function … -
Azure / Django / Ubuntu | tkinter & libtk8.6.so import issue
When Azure builds & deploys a Python3.9 Django/Django-Rest WebApp it has been failing in it's start up. Error in question ( full logs below ) 2022-03-08T21:13:30.385999188Z File "/tmp/8da0147da65ec79/core/models.py", line 1, in <module> 2022-03-08T21:13:30.386659422Z from tkinter import CASCADE 2022-03-08T21:13:30.387587669Z File "/opt/python/3.9.7/lib/python3.9/tkinter/__init__.py", line 37, in <module> 2022-03-08T21:13:30.387993189Z import _tkinter # If this fails your Python may not be configured for Tk 2022-03-08T21:13:30.388227101Z ImportError: libtk8.6.so: cannot open shared object file: No such file or directory I have come across other answers to this needing to make sure that tkinter is installed with sudo apt-get python3-tk which I have added to the deployment yml file Though it still seems to have issue. Reverting back to previous code for deployment is successful and the only feature that has been added to the application is Celery. Not sure if that has anything to do with it or not. Am I adding the installation of the tk/tkinter in the wrong sequence? build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python version uses: actions/setup-python@v1 with: python-version: "3.9" - name: Create and start virtual environment run: | python -m venv venv source venv/bin/activate - name: Install TK dependency run: | sudo apt-get update sudo apt-get install …