Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django - create a file for FileField inside media
I want to store log files (that change over time) that users can explore. As I want to serve these files but also change them programmatically whenever I need, I want to use FileField and store the files inside the media folder. First, when the object is created, I want to create an empty file <UUID>.log so I can access/update it then. How to create a default empty log file? class MyModel(..): log_file = FileField(upload_to='user_logs') def _create_log_file(self): content = '' filename = str(uuid4())+'.log' ... # what to do here? -
(Django) Admin datatable does not show data in the select field
below is the issue I'm having: The drug type column, which is a select field with specified options drug_types_list = ( ('pills','PILLS'), ('pellets','PELLETS'), ('lozenges','LOZENGES'), ) somehow did not show any data. Even though inside my Jquery Datatable everything displayed. So I went to my drugs/admin.py and modified the code as followed: from django.contrib import admin from import_export.admin import ImportExportModelAdmin # local from .models import Drug from .forms import DrugForm class DrugAdmin(ImportExportModelAdmin): fields = ('drug_type',) # added list_display = ['drug_id', 'name', 'drug_type', 'amount'] form = DrugForm # added list_per_page = 20 search_fields = ['drug_id', 'name', 'drug_type', 'brand', 'description'] admin.site.register(Drug, DrugAdmin) I aslo changed the drug_type line inside my drugs/forms.py as followed: from django import forms # local from drugs.models import Drug from .drug_types import drug_types_list class DrugForm(forms.ModelForm): class Meta: model = Drug fields = [ 'drug_id', 'name', 'drug_type', 'amount', ] widgets = { 'drug_id': forms.TextInput(attrs={ 'class': 'form-control', 'data-val': 'true', 'data-val-required': 'Please enter drug id', }), 'name': forms.TextInput(attrs={ 'class': 'form-control' }), 'drug_type': forms.Select(attrs={'class': 'form-control'}, choices=drug_types_list), # modified 'amount': forms.TextInput(attrs={ 'class': 'form-control' }), } but nothing worked so far. drugs/models.py Below is my drug model: from django.db import models from .drug_types import drug_types_list class Drug(models.Model): drug_id = models.CharField(max_length=20, unique=True, error_messages={'unique':"This drug id has … -
Django Redis Connection reset
Iam trying to use django_redis for redis cache backend for Django. The app is working fine in development stage on the localhost. But after deployment on Heroku and using django_redis for redis cache The connection is getting reset and the page crashes with 500 internal server error 2021-10-29T12:10:20.450924+00:00 heroku[router]: at=info method=GET path="/" host=www.humaurtum-matrimony.com request_id=37a90921- 9d8d-46c6-9d6a-888d34fb1d01 fwd="42.106.161.10" dyno=web.1 connect=0ms service=2701ms status=500 bytes=5280 protocol=https 2021-10-29T12:10:20.447599+00:00 app[web.1]: 2021-10-29 17:40:18,010 ERROR Internal Server Error: / 2021-10-29T12:10:20.447606+00:00 app[web.1]: Traceback (most recent call last): 2021-10-29T12:10:20.447607+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django_redis/cache.py", line 27 , in _decorator 2021-10-29T12:10:20.447608+00:00 app[web.1]: return method(self, *args, **kwargs) 2021-10-29T12:10:20.447608+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django_redis/cache.py", line 94 , in _get 2021-10-29T12:10:20.447609+00:00 app[web.1]: return self.client.get(key, default=default, version=version, client=client) 2021-10-29T12:10:20.447609+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django_redis/client/default.py" , line 222, in get 2021-10-29T12:10:20.447609+00:00 app[web.1]: raise ConnectionInterrupted(connection=client) from e 2021-10-29T12:10:20.447610+00:00 app[web.1]: django_redis.exceptions.ConnectionInterrupted: Redis ConnectionError: Error while rea ding from socket: (104, 'Connection reset by peer') 2021-10-29T12:10:20.447610+00:00 app[web.1]: 2021-10-29T12:10:20.447611+00:00 app[web.1]: During handling of the above exception, another exception occurred: 2021-10-29T12:10:20.447611+00:00 app[web.1]: 2021-10-29T12:10:20.447612+00:00 app[web.1]: Traceback (most recent call last): 2021-10-29T12:10:20.447612+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/exception. py", line 34, in inner 2021-10-29T12:10:20.447613+00:00 app[web.1]: response = get_response(request) 2021-10-29T12:10:20.447614+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response 2021-10-29T12:10:20.447614+00:00 app[web.1]: response = self.process_exception_by_middleware(e, request) 2021-10-29T12:10:20.447614+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response 2021-10-29T12:10:20.447615+00:00 app[web.1]: … -
Django broken pipe occurs with CORS setting
I want to connect flutter app with my Django API, but broken pipe keeps occuring. settings.py """ Django settings for crawler project. Generated by 'django-admin startproject' using Django 3.2.6. For more information on this file, see https://docs.djangoproject.com/en/3.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-)4%#q5&d3^5=0!bauz62wxmc9csk*_c09k!jl2g1a-0rxsa--j' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'crawling_data', 'rest_framework', 'corsheaders', ] MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'crawler.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'crawler.wsgi.application' # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { … -
Write the o/p into a new text file with table format below for each iteration appends in python
Write the o/p into a new text file with table format below for each iteration appends. ( i,e in for loop, 5th iteration coms number 5 which is divisible by 5 so this one should write into file) ----------------------------------------------------------- Iteration | Value 5 5 10 10 15 15 -
Unable to configure formatter 'json': Cannot resolve 'app_name.utils.logging.JSONFormatter': cannot import name 'Celery'
I am trying to include celery into our Django app and am struggling with the setup. So far all my searching of stackoverflow/google tells me I have a circular dependency, but I can't see it. The docs, https://docs.celeryproject.org/en/stable/getting-started/first-steps-with-celery.html, clearly use from celery import Celery I have defined: app_name/app_name_celery.py with from celery import signals, Celery import os from django.conf import settings # disable celery logging so that it inherits from the configured root logger @signals.setup_logging.connect def setup_celery_logging(**kwargs): pass os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") # Create default Celery app app = Celery('app_name') # namespace='CELERY' means all celery-related configuration keys # should be uppercased and have a `CELERY_` prefix in Django settings. # https://docs.celeryproject.org/en/stable/userguide/configuration.html app.config_from_object("django.conf:settings", namespace="CELERY") # When we use the following in Django, it loads all the <appname>.tasks # files and registers any tasks it finds in them. We can import the # tasks files some other way if we prefer. app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) Additionally, I have defined app_name/my_app_config.py with from django.apps import AppConfig class MyAppConfig(AppConfig): # ... def ready(self): # Import celery app now that Django is mostly ready. # This initializes Celery and autodiscovers tasks import app_name.app_name_celery Lastly, I have added to my __init__.py: # This will make sure the app is always imported … -
Python package: should I transform my code?
3 things you need to know for context: I have never done this before, so try to keep everything low level, or in simple steps. I have pretty good knowledge of Python and HTML (and JS) but I don't have ton of experience. I am doing this on a Chromebook, without access to Linux. (I do have access to JSLinux though) I have a Python project that is organized something like this / -- QaikeAI_1.py # This is what is actually run to use the program -- QHelper.py # Has helper functions, imported into QaikeAI_1.py -- Qepicenter.py # "The meat of the AI" imported into QHelper.py -- Qlog.py # A logfile -- Various other files (.gitignore, .replit, .gitpod.yml) Should I transform my code into a package? I want to use a Python web framework on gh-pages. Remember, I am on a Chromebook. The actual code is hosted on Github.com -
DRF post to a flask server using pytest
I am writing a test suite in Django wherein post requires flask server to be running in order to successfully return a 201 response. How can I mock that in my test? Here's a snippet of what I've tried: def test_something(self, data): response = self.client.post(reverse('myurl'), data) assert response.status_code == 201 The error here is that the flask server is not running that's why the status code is not as expected. -
Why different id values in the admin panel's list and object details views?
The custom ModelAdmin class is class ContactAdmin(admin.ModelAdmin): list_display = ('first_name', 'phone_number', 'id') readonly_fields = (id,) But the values in the id column list differ from those of the corresponding objects: List with an object; Object's detail view Why so? -
Print out forms on dashboard
I'm writing Quiz app on Dajngo. I have a model.py: class Quiz(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='quizzes') name = models.CharField(max_length=200, verbose_name=_('Quiz name')) description = models.CharField(max_length=100, verbose_name=_('Description')) slug = models.SlugField(blank=True) roll_out = models.BooleanField(default=False) timestamp = models.DateTimeField(auto_now_add=True) class Meta: ordering = ['timestamp'] verbose_name = _('Quiz') verbose_name_plural = _('Quizzes') def __str__(self): return self.name class Question(models.Model): quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE, related_name='questions') label = models.CharField(max_length=255, verbose_name=_('Question text')) order = models.IntegerField(default=0, verbose_name=_('Order')) class Meta: verbose_name = _('Question') verbose_name_plural = _('Questions') def __str__(self): return self.label class Answer(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name='answers') label = models.TextField(max_length=600, verbose_name=_('Answer text')) is_correct = models.BooleanField(default=False, verbose_name=_('Correct answer')) class Meta: verbose_name = _('Answer') verbose_name_plural = _('Answers') def __str__(self): return self.label And I get confused about how to output forms to create quiz with quiestions. This is my forms.py: class QuizAddForm(forms.ModelForm): class Meta: model = Answer exclude = ('question',) def __init__(self, *args, **kwargs): quiz = kwargs.pop('quiz', '') super(QuizAddForm, self).__init__(*args, **kwargs) self.fields['question'] = forms.ModelChoiceField(queryset=Quiz.objects.filter(name='category')) I want view in my template like: Category Quiz Question Answer 1 Answer 2 Answer 3 etc. -
Insert records into two tables using single view in Django rest framework
I have three models as follows. class Quiz(models.Model): name = models.CharField(max_length=50) desc = models.CharField(max_length=500) number_of_questions = models.IntegerField(default=1) time = models.IntegerField(help_text="Duration of the quiz in seconds", default="1") def __str__(self): return self.name def get_questions(self): return self.question_set.all() class Question(models.Model): ques = models.CharField(max_length=200) quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE) def __str__(self): return self.ques class Answer(models.Model): content = models.CharField(max_length=200) correct = models.BooleanField(default=False) question = models.ForeignKey(Question, on_delete=models.CASCADE) def __str__(self): return f"question: {self.question.ques }, answer: {self.content}, correct: {self.correct}" I have to create api for create question. for this I have to use model Question and Answer same time e.g. its admin page but I want to create same api which accept above parameters and store it into database. how to write view.py for this api ? -
Django constraint on Foreign Key field 'startswith'
I have got problem with Django constraint. I want to create constraint on foreign key field to check if it starts with user_id but Django think "__startswith" is a lookup option. Am i wrong with constraint syntax or it is Django problem? Probably i have tried to do this constraint with raw SQL and it works. Have got this error: django.core.exceptions.FieldError: Related Field got invalid lookup: startswith I have this Models: class PrivateModel(models.Model): id = models.CharField(primary_key=True, max_length=255, default="", editable=False) _owner = models.ForeignKey(User, on_delete=models.CASCADE) class Meta: abstract = True class Genre(PrivateModel): genre = models.CharField(max_length=255) class Book(PrivateModel): caption = models.CharField(max_length=255) genre = models.ForeignKey(Genre, on_delete=models.CASCADE) class Meta: constraints = [ models.CheckConstraint( name="book_genre_owner_constraint", check=Q(genre_id__startswith=F("_owner_id")) ), ] -
python 3 ModuleNotFoundError: No module named 'phonenumber_field'
line 53, in from phonenumber_field.modelfields import PhoneNumberField ModuleNotFoundError: No module named 'phonenumber_field' -
Sharing Cookies
My Django website is running on hello.com and react application on abc.hello.com and I want to share cookies between them. The nginx configuration given below isn't working for me.Can anyone help me for this. Configuration : Django-nginx config: server { listen 80; server_name abc.com; location /static/{ root /home/ubuntu/static/; } location / { proxy_cookie_domain ~^(.+)(Domain=abc.hello.com)(.+)$ "$1 Domain=.hello.com> proxy_pass http://xx.xx.xx.xxxx:8000; } } React nginx config: server { listen 80; server_name abc.hello.com; location / { proxy_cookie_domain ~^(.+)(Domain=abc.hello.com)(.+)$ "$1 Domain=.hello.com> proxy_pass http://xxx.xxx.xxx.xxx:3000; } } -
Matching < select > values based on Django-Model entries
I have one Django- Model that has a Name and Number of Units field. An example of the entries is: Name1: 12 Name2: 18 Name3: 25 I would like to add these 2 fields on a form where the user will use a < select > dropdown to select a name e.g. Name1 And then another dropdown for the user to select their unit from 1 to the total number of units e.g. 1 - 12 However, the way that my code is currently set up, it shows the unit name - and the user can select it, but for the unit number it shows all the NumberOfUnits fields in the model Please see my current code: template.html: <form> <select name="Complex"> {% for x in model %} <option value="{{ x }}">{{ x.ComplexName }}</option> {% endfor %} </select>> Complex <select> {% for x in model %} <option value="{{ x.NumberOfUnits }}">{{ x.NumberOfUnits }}</option> {% endfor %} </select> Views.py: def customerDetails(request): model = ComplexListClass.objects.all().order_by('ComplexName') content = {'model': model} return render(request, 'main/customerDetails.html', content) Models.py: class ComplexListClass(models.Model): ComplexName = models.CharField(choices=complex_list , max_length = 50 ,default='1' , unique=True) NumberOfUnits = models.IntegerField(max_length=2 , blank=False , default=1 ) def __str__(self): return (self.ComplexName) -
Download YouTube Video using Python
I'm using the Python library Pytube to download youtube videos. Here is the main issue: While I configure the project on the server and access it through my domain name, it saves video on the server while I want to save it to my computer. Do you have any idea how can I do that? Thanks -
Django Q object not chaining correctly
I'm querying a ManyToMany field (tags). The values come from a list: tag_q = Q() tag_list = ["work", "friends"] for tag in tag_list: tag_q &= Q(tags__tag=tag) Post.objects.filter(tag_q) When I have only one value, it works flawlessly, but when more objects are stacked it always return an empty queryset. I didn't used tags__tag__in=tag_list because it returned any post that contained any of the tags in the tag list (an OR filter), and I need an AND filter here. This is my models: class Tag(models.Model): tag = models.CharField(max_length=19, choices=TagChoices.choices()) class Post(models.Model): tags = models.ManyToManyField(Tag, related_name='posts', blank=True) This is the Q object that is being passed in the filter query: (AND: ('tags__tag', 'work'), ('tags__tag', 'friends') -
measure the height and width of the image in django and store the value in models
I have a model for image url in django. I want to calculate the image_height and iamge_width of image which is stored in s3 bucket.Below is my model.py from django.db import models from .project_model import Project class Image(models.Model): image = models.TextField(blank=False) image_width = models.IntegerField(default=0) image_height = models.IntegerField(default=0) project_id = models.ForeignKey(Project, on_delete=models.CASCADE) is_thumpnail = models.BooleanField(blank=False) upload_on = models.DateTimeField("created on", auto_now_add=True) updated_on = models.DateTimeField("updated on", auto_now=True) def __str__(self): return self.file_name After getting the value of height and width, I want to store the value in the model.py. I am looking for below type of response example { "id": "cJ9cm", "title": null, "description": null, "datetime": 1357856330, "type": "image/jpeg", "animated": false, "width": 2592, "height": 1944, "size": 544702, "views": 31829, "bandwidth": 17337319958, "link": "https://i.imgur.com/cJ9cm.jpg" } -
I've a issue with my favourite app in django
I am designing a blog site and there will be a favorites module on my blog site. However, the problem is that I developed a custom user model using JWT, but then when I try to access the favorites section with these users, I get the following error. When I delete the perform_create function, everything works fine, but I have to use it to make users' favorite posts appear unique to each of them, but I couldn't find an alternative code that I can write instead. Can you help? this error TypeError at /api/favourites/list-create Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x000001E01402CA00>. this is my favorite/api/views.py code from favourite.api.seralizers import FavouriteListCreateSerializer from favourite.models import Favourite from rest_framework.generics import ListCreateAPIView from rest_framework.permissions import IsAuthenticated class FavouriteListCreateAPIView(ListCreateAPIView): queryset = Favourite.objects.all() serializer_class = FavouriteListCreateSerializer permissions_classes = [IsAuthenticated] def get_queryset(self): return Favourite.objects.filter(user=self.request.user) def perform_create(self, serializer): serializer.save(user=self.request.user) favoruites/api/serializers.py file from favourite.models import Favourite from rest_framework.serializers import ModelSerializer class FavouriteListCreateSerializer(ModelSerializer): class Meta: model = Favourite fields = "__all__" and finally this is my custom account model from django.db import models from django.utils import timezone from django.utils.translation import gettext_lazy as _ from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager from django.utils.text import slugify class CustomAccountManager(BaseUserManager): def … -
Python test succeed on Linux but fail on windows
I'm currently working on a project where my python tests are actually succeeding when they are running on a Linux environment, but they fail when they are running in a Windows environment. And what is really weird is that the tests are failing randomly on Windows(sometimes, 4 tests are failing, sometimes it's 6...). I have the feeling that maybe the setUp method doesn't execute the same way in Linux and in Windows. Does anyone know if there is a difference between python test run on windows or on linux. Thank you. -
Django Elastic APM Trace logs message missing
I have Django-elastic APM setup, that's sends traces and logs to elk stack. Its actually works, but not as I need. I get trace, I get metadata, even logs received (2nd pic) But, problem is, I don't get any messages in logs section and I didn't find how to customize fields. But! When I search directly in logs, I see following: Message exist Finally, when I search it discover section, I can see even more info. Fields, I actually need. QUESTION So, there is my questions. Is it possible to add at least message info to transaction logs (first pic), Is it possible to at least add custom fields to logs section (2nd pic) Also, is there a way to make logs at least clickable? (Also 2nd pic, I mean its just plain text I have to go to discover and use this info like ctrl+c ctrl+v) Finally, why logs are marked as Errors, if its just a logs, and used like logs? I tried to set different levels as debug, or info, as u see in 2nd screen, but it still comes like error and it goes in apm-7.14-error* index. Here's my logging settings: LOGGING = { 'version': 1, … -
Pillow is not installed after removing .temp-builds
The error ERRORS: app_1 | core.Page.image: (fields.E210) Cannot use ImageField because Pillow is not installed. It seems that Pillow is detected as not installed in my docker container if I delete the .temp-builds after installing requirements.txt. I say this because if I remove the 'apk del .tmp-deps' the error went away. However, I want to remove the .tmp-builds because I learn it's best practice to make the docker container as lean as possible. Dockerfile RUN python -m venv /py && \ /py/bin/pip install --upgrade pip && \ apk add --update --no-cache postgresql-client && \ apk add --update --no-cache --virtual .tmp-deps \ build-base postgresql-dev musl-dev linux-headers \ python3-dev zlib-dev jpeg-dev gcc musl-dev && \ /py/bin/pip install -r /requirements.txt && \ apk del .tmp-deps requirements.txt django>=3.2.3,<3.3 psycopg2>=2.8.6,<2.9 uWSGI>=2.0.19.1,<2.1 djangorestframework >=3.12.4, <3.20.0 Pillow >= 8.4.0, <8.5.0 Any pointer would be greatly appreaciated. -
Elastic Beanstalk Linux 2 Cron Job running but not executing
I have put my configuration files down to as simple of an example as I can think of, but I still can't get the cron to execute. This is a django project, and though it looks like the crons are trying to run, they are not actually executing. .ebextensions/cron-log.config "/etc/cron.d/test_cron": mode: "000644" owner: root group: root content: | */1 * * * * root . /opt/elasticbeanstalk/deployment/env && echo "TESTING" >> /var/log/test_log.log 2>&1 commands: rm_old_cron: command: "rm -fr /etc/cron.d/*.bak" ignoreErrors: true when downloading the logs from aws, test_log.log does not exist in the cron file returned in the logs, it shows: Oct 29 09:03:01 ip-172-31-8-91 CROND[10212]: (root) CMD (. /opt/elasticbeanstalk/deployment/env && echo "TESTING" >> /var/log/test_log.log 2>&1) I have tried many variations of this including having the command that is ran make changes in our database, but it never seems to actually execute. -
error during deploying django project to heruku
I am trying to deplow a django project to heroku but i am getting this error. ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python /app/.heroku/python/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp5mrz1adn Check the logs for full command output. ! Push rejected, failed to compile Python app. ! Push failed This is the entire log ctivity Feed Build LogID 314cb820-4652-417b-9486-61d629e4a6a9 -----> Building on the Heroku-20 stack -----> Using buildpack: heroku/python -----> Python app detected -----> Using Python version specified in runtime.txt -----> Installing python-3.8.12 -----> Installing pip 20.2.4, setuptools 57.5.0 and wheel 0.37.0 -----> Installing SQLite3 -----> Installing requirements with pip Collecting alembic==1.6.5 Downloading alembic-1.6.5-py2.py3-none-any.whl (164 kB) Collecting asgiref==3.3.4 Downloading asgiref-3.3.4-py3-none-any.whl (22 kB) Collecting Babel==2.9.1 Downloading Babel-2.9.1-py2.py3-none-any.whl (8.8 MB) Collecting bcrypt==3.2.0 Downloading bcrypt-3.2.0-cp36-abi3-manylinux2010_x86_64.whl (63 kB) Collecting bidict==0.21.2 Downloading bidict-0.21.2-py2.py3-none-any.whl (37 kB) Collecting blinker==1.4 Downloading blinker-1.4.tar.gz (111 kB) Collecting Brotli==1.0.9 Downloading Brotli-1.0.9-cp38-cp38-manylinux1_x86_64.whl (357 kB) Collecting cffi==1.14.6 Downloading cffi-1.14.6-cp38-cp38-manylinux1_x86_64.whl (411 kB) Collecting cheroot==8.5.2 Downloading cheroot-8.5.2-py2.py3-none-any.whl (97 kB) Collecting click==7.1.2 Downloading click-7.1.2-py2.py3-none-any.whl (82 kB) Collecting cryptography==3.4.7 Downloading cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl (3.2 MB) Collecting Django==3.2.8 Downloading Django-3.2.8-py3-none-any.whl (7.9 MB) Collecting django-ckeditor==6.1.0 Downloading django_ckeditor-6.1.0-py2.py3-none-any.whl (2.4 MB) Collecting django-filter==2.4.0 Downloading django_filter-2.4.0-py3-none-any.whl (73 kB) Collecting django-js-asset==1.2.2 Downloading django_js_asset-1.2.2-py2.py3-none-any.whl (5.8 kB) Collecting django-multiselectfield==0.1.12 Downloading django_multiselectfield-0.1.12-py3-none-any.whl (15 kB) Collecting dnspython==1.16.0 Downloading dnspython-1.16.0-py2.py3-none-any.whl (188 kB) Collecting … -
ModuleNotFoundError: No module named '_tkinter' Heroku
I am trying to deploy a webapp using Heroku and it get deployed but it gives internal server error when I try to open it. The complete log as from heroku logs -t is as follows: 2021-10-29T09:03:55.451439+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 152, in handle_uncaught_exception 2021-10-29T09:03:55.451439+00:00 app[web.1]: callback = resolver.resolve_error_handler(500) 2021-10-29T09:03:55.451442+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/urls/resolvers.py", line 611, in resolve_error_handler 2021-10-29T09:03:55.451442+00:00 app[web.1]: callback = getattr(self.urlconf_module, 'handler%s' % view_type, None) 2021-10-29T09:03:55.451442+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__ 2021-10-29T09:03:55.451443+00:00 app[web.1]: res = instance.__dict__[self.name] = self.func(instance) 2021-10-29T09:03:55.451443+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/urls/resolvers.py", line 591, in urlconf_module 2021-10-29T09:03:55.451443+00:00 app[web.1]: return import_module(self.urlconf_name) 2021-10-29T09:03:55.451444+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module 2021-10-29T09:03:55.451444+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2021-10-29T09:03:55.451444+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import 2021-10-29T09:03:55.451444+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load 2021-10-29T09:03:55.451444+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked 2021-10-29T09:03:55.451444+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked 2021-10-29T09:03:55.451444+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module 2021-10-29T09:03:55.451444+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed 2021-10-29T09:03:55.451445+00:00 app[web.1]: File "/app/server/urls.py", line 7, in <module> 2021-10-29T09:03:55.451445+00:00 app[web.1]: path('apis/',include('apis.urls',namespace='apis')), 2021-10-29T09:03:55.451445+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/urls/conf.py", line 34, in include 2021-10-29T09:03:55.451445+00:00 app[web.1]: urlconf_module = import_module(urlconf_module) 2021-10-29T09:03:55.451445+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module 2021-10-29T09:03:55.451446+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)2021-10-29T09:03:55.451446+00:00 app[web.1]: …