Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to save file in creating folder when data inserto the data base django
I want to save file in automatically created folder related with Employee id_number. I add following code in models.py from django.db import models class Employee(models.Model): id_number = models.CharField(primary_key=True, null=False, blank=False, unique=True, max_length=15) full_name = models.CharField(max_length=255, null=False, blank=False) name_with_initials = models.CharField(max_length=255, null=False, blank=False) surname = models.CharField(max_length=255, null=False, blank=False) phone = models.CharField(max_length=15, null=False, blank=False) dob = models.DateField(null=False, blank=False) gender = models.CharField(max_length=10, null=False, blank=False) email = models.EmailField() address = models.CharField(max_length=255, null=False, blank=False) class EmployeeAttachments(models.Model): employee = models.ForeignKey(Employee, on_delete=models.CASCADE) cv = models.FileField(upload_to=f'employee/attachments/', max_length=100) i want to save cv file in ex:- media->employee->attachments->emp001->emp001.pdf can any one tell me how to do this in django, django-rest-framework -
Editing the 1st Row using Django Forms is not working, but working for the rest rows. How to rectify it?
I have a Django Form which has a problem. It is not editing the 1st row of the table of the database fetched in the template and working fine from 2nd rows onwards. the issue seems to be with the dynamic URL: Suppose in this HTML table :- as I hit the edit button for 1st row, no new URL is generated, i.e. same old URL say http://xxx.xx:xx/djangoapp/state_wise is returned, which just refreshes the page :- but while I hit the edit button for the 2nd row and onwards, the URL changes dynamically as http://xxx.xx:xx/djangoapp/edit_data_from_db/8086/? and the edit form appears as : the forms.py file is as: class details_to_database(forms.ModelForm): class Meta: model = GroupDetail BOOL_CHOICES = ((True, 'Yes'), (False, 'No')) UNIT_CATEGORIES = (('ABC', 'ABC'), ('DAMU', 'DAMU')) fields = ["unit_type", "state_name", "unit_name", "district_name", "block_name", "village_name", "village_covered", "number_of_groups", "number_of_farmers"] labels = { "unit_type":"Unit Type", "state_name":"State Name", "unit_name":"Unit Name", "district_name":"District Name", "block_name":"Block Name", "village_covered":"Village Covered (Yes/No)", "number_of_groups":"Number of groups", "number_of_farmers":"Number of farmers"} widgets = { "unit_type":forms.Select(attrs={"class":"form-control", "id":"unit_type_id"}, choices=UNIT_CATEGORIES), "state_name":forms.TextInput(attrs={"class":"form-control", "id":"state_name_id"}), "unit_name":forms.TextInput(attrs={"class":"form-control", "id":"unit_name_id"}), "district_name":forms.TextInput(attrs={"class":"form-control", "id":"district_name_id"}), "block_name":forms.TextInput(attrs={"class":"form-control", "id":"block_name_id"}), "village_name":forms.TextInput(attrs={"class":"form-control", "id":"village_name_id"}), "village_covered":forms.Select(attrs={"class":"form-control", "id":"village_covered_id"}, choices=BOOL_CHOICES), "number_of_groups":forms.NumberInput(attrs={'min': '1',"class":"form-control", "id":"number_of_groups_id"}), "number_of_farmers":forms.NumberInput(attrs={'min': '1',"class":"form-control", "id":"number_of_farmers_id"}) } The model.py file is as: BOOL_CHOICES = ((True, 'Yes'), (False, 'No')) UNIT_CATEGORIES = (('ABC', 'ABC'), … -
Why does gevent give "Too many open files" error during load testing?
I have a setup consisting of nginx, gunicorn, and django. All these run through docker containers. In django, when a request comes, I save image files that are sent through request. Since my code is IO bound, I wanted to use gevent, however, during load tests it gives "Error at ...[Errno 24] Too many open files:" unless i make worker-connections 2, which is too low. I've researched this error, some people suggest increasing ulimit -n, but by default the container has 1048576 limit. It doesn't allow for more. I've also tried using eventlet instead of gevent, but the error is the same. Error message Error traces back to this part: with open(path, "wb") as f: f.write(imgfile) Any suggestions? -
Image persistence issue in Heroku [duplicate]
I have deployed my Django backend in Heroku, and connected to the Heroku PostgresSQL database. However, I noticed that the images are not persistent; after a while, the images disappear. It must be noted that other features are persistent, and it is only the images that disappear. Does anyone know why this is the case? I have included the settings.py in my Django backend for reference purposes. from pathlib import Path from decouple import config import os import dj_database_url # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # import config to anonymise secret key SECRET_KEY = config("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True #ALLOWED_HOSTS = ["localhost","https://ever-green-production.herokuapp.com"] ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'stockmarket.apps.StockmarketConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions', 'corsheaders', 'dj_rest_auth', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'dj_rest_auth.registration', #registration endpoint 'rest_framework', 'rest_framework.authtoken', ] SITE_ID = 1 MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', #handling of static files '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', 'corsheaders.middleware.CorsMiddleware', ] ROOT_URLCONF = 'backend.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', … -
" Invalid or incomplete introspection result" error when i load the graphql endpoint for my django project
I have a Django project where I am using Graphql but after writing out only one mutation, the /graphql does not run properly, throwing the following error. { "message": "Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: null.", "stack": "r@https://cdn.jsdelivr.net/npm/graphiql@1.0.3/graphiql.min.js:1:24583\nur@https://cdn.jsdelivr.net/npm/graphiql@1.0.3/graphiql.min.js:1:326896\nwindow.GraphiQL</</s/value/<@https://cdn.jsdelivr.net/npm/graphiql@1.0.3/graphiql.min.js:7:48325\n" } How can I fix this ??? Here is my main schema import graphene import accounts.schema class Query(graphene.ObjectType): pass class Mutation(accounts.schema.Mutation, graphene.ObjectType): pass schema = graphene.Schema() Here is my account schema file import graphene from graphene_django import DjangoObjectType from .models import CustomUser class CustomUserType(DjangoObjectType): class Meta: model = CustomUser class CustomUserInput(graphene.InputObjectType): full_legal_name = graphene.String(required=True) title = graphene.String(required=True) email = graphene.String(required=True) phone_number = graphene.String(required=True) physical_address = graphene.String(required=True) password = graphene.String(required=True) confirm_password = graphene.String(required=True) role = graphene.String(required=True) class CreateUser(graphene.Mutation): user = graphene.Field(CustomUserType) class Arguments: user_data = CustomUserInput(required=True) def mutate(self, info, user_data=None): user = CustomUser( email=user_data.email, full_legal_name=user_data.full_legal_name, title=user_data.title, phone_number=user_data.phone_number, physical_address=user_data.physical_address, password=user_data.password, confirm_password=user_data.confirm_password, role=user_data.role ) if user.password != user.confirm_password: raise Exception("Passwords do not match!") else: user.set_password(user_data.password) user.save() return CreateUser(user=user) class Mutation(graphene.ObjectType): create_user = CreateUser.Field() And my model.py file which I used to build out the schema. from django.db import models from django.contrib.auth.models import AbstractUser class CustomUser(AbstractUser): TITLES = ( ('Mr', 'Mr'), … -
Display SQL Query result into a Django Form
I have a simple BookStore web page that it must return a query result that contains books information. I want to display that into a form and add checkbox before each item so the client can check the number of books they want. First Question is how I pass an sql query into a django form (Form must be a Charfield with disable value set to true so no can edit it just be able to see it it also uses the widget textarea). This is my Form.py from django.forms import ModelForm from django import forms from .models import Books class Login_Form(forms.Form): username = forms.IntegerField(label='User Name',widget=forms.TextInput, required=True) password = forms.CharField(label='Password',widget=forms.PasswordInput, required=True) class Book_L(forms.ModelForm): class Meta: model = Books fields = "__all__" This is the Model.py the model i want to display is the Books model: rom django.db import models class Admins(models.Model): adminid = models.IntegerField(db_column='AdminID', primary_key=True) # Field name made lowercase. adminlogin = models.CharField(db_column='AdminLogin', max_length=254, db_collation='SQL_Latin1_General_CP1_CI_AS', blank=True, null=True) # Field name made lowercase. usersecret = models.CharField(max_length=254, db_collation='SQL_Latin1_General_CP1_CI_AS', blank=True, null=True) class Meta: db_table = 'Admins' class Books(models.Model): uid = models.AutoField(db_column='UID', primary_key=True) # Field name made lowercase. bookname = models.CharField(db_column='BookName', max_length=255, db_collation='SQL_Latin1_General_CP1_CI_AS', blank=True, null=True) # Field name made lowercase. author = models.CharField(db_column='Author', max_length=255, … -
sendgrid SENDGRID_ECHO_TO_STDOUT
Iam looking to use this pkg to send emails in my django app: https://github.com/sklarsa/django-sendgrid-v5 and I see the field: SENDGRID_ECHO_TO_STDOUT and the description says: will echo to stdout or any other file-like object that is passed to the backend via the stream kwarg. I literally do not get what this means. My understanding was that if I set this to True, the email WONT be delivered but will be saved as a file and will output 1 in the terminal ? However when I see this:https://simpleit.rocks/python/django/adding-email-to-django-the-easiest-way/ I think the guy manages to send emails even when this flag is set to True? Is that correct? Sorry if this is a daft quetsion - I just do not understand this flag. Should the flag be set to True or False in production? -
Send a file to a specific user from the admin page in django
I am on a django project where I want to be sending different work to each of my employees from the admin page, but no one will see other people's work, each person will see their own work in their profile page... Can anyone please assist me on what I should do... -
Getting "No module named django.core.management" inside vscode
I am running my django app in docker. I have attached this docker container to vscode. Then, I start debugging application, but manage.py, I get following error: No module named django.core.management Inside vscode's terminal, I tried following: # pip list | grep django django-annoying 0.10.4 django-bulk-update 2.2.0 django-ckeditor 5.5.0 django-codemirror2 0.2 django-crequest 2018.5.11 django-extensions 1.7.3 django-filter 1.1.0 django-formtools 1.0 django-haystack 2.4.1 django-js-asset 1.2.3 django-jsonfield 1.4.0 django-model-utils 2.5 django-redis 4.3.0 django-smtp-ssl 1.0 django-user-agents 0.4.0 djangorestframework 3.3.3 So it seem like django is installed in container's python. To double check, I tried following in vscode's terminal: # python Python 2.7.16 (default, Oct 17 2019, 07:35:32) [GCC 8.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> django <module 'django' from '/usr/local/lib/python2.7/site-packages/django/__init__.pyc'> >>> django.core Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'core' Q1. Does this mean that django is installed, but somehow django.core isnt there? Also, this is what I get in vscode's terminal: # which python /usr/local/bin/python But, manage.py has this line at the top: #!/usr/bin/env python Q2. Is my app running against different python from the one I am accessing from vscode's terminal? Also the … -
{'category_name': [ErrorDetail(string='Incorrect type. Expected pk value, received str.', code='incorrect_type')]}
I am new to django postgresql and I have been making a CRUD with Products having categories,sub categories,colors,size.When I am trying to make a new "category" the data isnt getting displayed on webpage heres the error: below is Products model below is what I have written in categories.views ,it's show function -
Why is the data on my heroku website different from data on local dev?
New to django I tried setting up a postgreSQL db and it works fine. I use Retool to access the db and I can see the data I am adding when I modify my website locally through the admin site, but data is not there when I access my 'production' website hosted on heroku. My process: I add a new model I go to myWebsite/admin I add a new entry to my website and save. I check the postgreSQL and I can see my entries I deploy my website to heroku I log in to admin I can see the model I created, but no entries. The 'production' db is using the same connection details. -
Generating all third-party Django apps endpoints with drf-yasg
Is there a way for generating all third-party apps endpoints with drf-yasg? So I have installed social_django app and want to include all URLs it provides to swagger UI My urlpatterns urlpatterns = [ re_path('admin/', admin.site.urls), re_path('', include('user.urls')), re_path(r'^$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), re_path(r'', include('social_django.urls', namespace='social')), re_path(r'accounts/', include('django.contrib.auth.urls')), ] Schema schema_view = get_schema_view( openapi.Info( title="Snippets API", default_version='v1', description="Test description", terms_of_service="https://www.google.com/policies/terms/", contact=openapi.Contact(email="contact@snippets.local"), license=openapi.License(name="BSD License"), ), public=True, permission_classes=(permissions.AllowAny,), ) Those are that defined by me, but I also want to see here /login/facebook/ , /login/google-oauth2/ etc. Or for example simple /admin/ that Django provides. How can I do this? -
navigation bar not perform well in my Django project
I had created a horizontal navigation bar on top of my page. I use code on w3school and tryied javascript snippet from stackoverflow post I found months ago. I'm using Django. I met 2 issues I can't resolve or understand. I paste my code here. One navigation.html: <div id="id_topnav" class="topnav"> <a href="{% url 'myapp:index'%}">Home</a> <a href="{% url 'myapp:help'%}">Help</a> <a href="{% url 'myapp:test'%}">Test</a> </div> I got a style.css: body { margin: 10; font-family: Arial, Helvetica, sans-serif; } .topnav { overflow: hidden; background-color: red; position: fixed; top: 0; width: 100%; } .topnav a { float: left; display: block; color: orange; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; } .topnav a:hover:not(.active) { background-color: blue; color: black; } .topnav a:focus { background-color: pink; } In my home page, {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'main/style.css' %}"> {% include "myapp/navigation.html" %} ......and other lines below myapp\static\main\style.css My first issue is, when I changed colours in style.css, any colour in .topnav or .topnav a section, I didn't see changes on any of my page. After changing, I use py manage.py collectstatic to update the resource and py manage.py runserver 127.0.0.1:8000 to restart my server. I don't see any change of colour. … -
Filter field M2M in Django ORM
My models: class Tag(models.Model): tag_name = models.CharField( 'Tag Name', max_length=255, null=True ) class Book(models.Model): name = models.CharField( 'Name', max_length=255, null=True ) tag = models.ManyToManyField( 'Tag', related_name='tags', blank=True ) I wont filtering Book's model. In db i have several rows: Tag | id | name | |-----|------| | 1 |tag_1 | | 2 |tag_2 | | 3 |tag_3 | Book | id | name | tags | |-----|-------|------| | 1 |book_1 |tag_1| | 2 |book_2 |tag_2| | 3 |book_3 |tag_3| | 4 |book_4 |tag_1, tag_2, tag_3| How can i filtering book models, if i take new model Book with tag=tag_1, tag_2 and i want find in Book models all model with tag include tag_1 or tag_2. I want get queryset like this(for tag=tag_1, tag_2): [(id=1, name=book_1), (id=2, name=book_2), (id=4, name=book_4)] -
django queryset filter by list - get elements of list that are not found
Let's assume, there is a django model Data with a charfield named hash and a list of hashes called all_hashes. Now it is clear, one can use filter expression to get all objects in Data which are within the list of hashes by using the __in syntax like: all_hashes = ['45df...','ab23...', ... ] filtered_data = Data.objects.filter(hash__in=all_hashes) So if one wants to know which hashes have been found one could just do filtered_hashes = [obj.hash for obj in filtered_data] And you can get the hashes, which have not been found, like new_hashes = set(all_hashes) - set(filtered_hashes) Of course you can also directy get new_hashes by looping one by one through the list of all_hashes and individually try to retrieve a matching object from database however this sounds like it will cause a lot of queries and should be avoided. The question is - is there any more direct way to identify for which items in a list no matching object could be found - maybe something that looks like: objects_existing = Data.objects.exist(hash__in=all_hashes) => [true, false, ...] -
Render template context data referenced from hardcoded HTML in Django model
I have a Django app which is a news service. I have a basic html page which renders a single article. Up until now, every article had a standard format, Image, Author, and text content. Now I am making an update to allow articles to have multiple images between various paragraphs of the article text. Currently, my HTML page to render a single article gets its data injected via a context object which contains the following Article model: class Article(models.Model): title = models.TextField() author = models.ForeignKey(Author, on_delete=models.CASCADE) content = models.TextField() date = models.DateField(default=now) image = models.ImageField(storage=MediaStorage(), default='') external_source = models.TextField(null=True, blank=True) featured = models.BooleanField(null=False, blank=True) slug = models.SlugField() album = models.OneToOneField(Album, related_name='album', on_delete=models.CASCADE, null=True, blank=True) Within the HTML template, I display the content with the following code <p> {{ article.content|safe }} </p> Since I want to embed the album images within the text, I am attempting to put HTML code inside the content TextField like the following: Some random article text followed by and image... <img class="img-responsive single_article_image" src="{{album.image.url}}"> Some more random article text The problem is that the src reference to album.image does not resolve from the injected context and no image is rendered. The reason why I cannot … -
How can i use multiple request.query_params in conditions using Django
Here i am using request.query_params to take the parameter in API through URL but currently i am trying to use multiple params as per conditions like: here in one condition i am taking field, page, rows and in one condition i am taking page and rows and so on but it is only considering 1st condition and ignoring the remaining conditions. class SampleView(APIView): def get(self, request): if request.query_params['page'] and request.query_params['rows']: # Pagination page = int(request.query_params['page']) rows = int(request.query_params['rows']) val1 = rows*(page-1) val2 = (val1+rows) qry = DeviceControlPolicy.objects.all()[val1:val2] qry_length = DeviceControlPolicy.objects.count() serializer = DeviceControlPolicySerializer(qry, many=True).data data = { 'count': qry_length, 'data': serializer } return Response(data) elif request.query_params['field'] and request.query_params['page'] and request.query_params['rows']: page = int(request.query_params['page']) rows = int(request.query_params['rows']) val1 = rows * (page - 1) val2 = (val1 + rows) field = request.query_params['field'] qry = DeviceControlPolicy.objects.all().order_by(field).values()[val1:val2] qry_length = DeviceControlPolicy.objects.count() print(qry_length) serializer = DeviceControlPolicySerializer(qry, many=True).data data = { 'count': qry_length, 'data': serializer } return Response(data) Please help me out how can i do this and can use multiple conditions using different number of params. -
RuntimeError:doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
I'm getting this error while i am using my own AUTHENTICATION_BACKENDS from django.contrib.auth.backends import ModelBackend import re from tainfo.apps.users.models import User def get_user_by_account(account): try: if re.match(r'1[3-9]\d{9}',account): user = User.objects.get(mobile=account) else: user = User.objects.get(username=account) return user except User.DoesNotExist: return None class UsernameMobileAuthBackend(ModelBackend): def authenticate(self,request,username=None,password=None,**kwargs): user = get_user_by_account(username) if user and user.check_password(password) and user.is_active: return user I put this in my devsettings.py: AUTHENTICATION_BACKENDS = ['users.utils.UsernameMobileAuthBackend',] if i delete this from settings,then this error will gone,but i that case i won't be able to use my own auth backends. any idea what i have done wrong? thanks -
Access to associated objects
I'm coming from Java and new to python / django. So may be my question is silly ... I have one class Parent which contains an association with a class Child. class Parent(models.Model): pass class Child(models.Model): value = models.DecimalField(decimal_places=2, max_digits=12,default=0.0); parent = models.ForeignKey(Parent, on_delete=models.CASCADE, null=True, related_name='children') Parent refers to its 'Childs' through the related name 'children'. At Run time it works well, but at design time, it isn't reachable from the declaration of the class Parent. If I want the parent to get a summarized value of its children, the best option I found is to first get the set of children and then to summarize from it class Parent(models.Model): def total_value(self): return float(Child.objects.filter(parent=self).aggregate(Sum('value'))['value__sum']) or 0.00 pass Do you know if there is a better way to do this? Can't we imagine something like: children.aggregate(Sum('value')) In other words: is it possible to directly access the children from the Parent (at design time) without making a query ? Thanks in advance for your support on this. -
What is the best option for an on demand service applications backend?
I am a little confused about what would be the best backend solution for an on demand service app startup with small expected active daily users <1000. I am looking for the most cost effective over long term option, in case active users exploded. 1- Django 2- Firebase 3- NodeJS with MongoDB -
Concatenation in Django views error: this type has no size
I am trying to concatenate columns of strings & integer types in Django. the view is like below, def DList(request): d_list = List.objects.annotate( Address=Concat( 'addr1', 'addr2', 'addr3', 'City', 'State', Value(' - '), str('Pincode'), output_field=CharField(), ),).all() context = { 'lists': d_list } return render(request, 'CRUD/list.html', context) Issue arises when I try to insert a space or a symbol like hypen here. Runserver throws error as below, this type has no size What is the exact method to insert space or any symbols while concatenating column values in Django ? -
How do I save the value entered from a form in my template to be used in a different .py file in django
I've created a template with a form, and a view for that template. I assign the values entered by the user to a variable using a request.post, but how do I then call this variable with the value in a different .py file? -
Result not displaying in localhost Django
The result is not displaying in localhost, but it is displaying in http://127.0.0.1:8000/ Here is my code. I don't know why will that happen, I'm new to Django, so your solution would really help me to solve this. Thanks in advance! Index.html <script> $(document).ready(() => { $("input[id='image']").on('change', function (event) { let input = this; var reader = new FileReader(); reader.onload = function (e) { $('#banner').css('width', '350px') $('#banner').addClass('img-thumbnail') $('#banner').attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); }) $('#process').click(() => { $('.buttons').hide() $('.loader').show() $('#title').html("Processing...") let image = $('#image').prop('files')[0] var data = image['name']; console.log(data) $.ajax({ url: "http://127.0.0.1:8000/api/", type: "POST", enctype: 'multipart/form-data', dataType: 'json', data: { image: data, csrfmiddlewaretoken: '{{ csrf_token }}' }, success: function (xhr) { alert("Error while processing") }, error: function (xhr) { $('#title').html("Result") let result = (xhr.responseText).split("-"); let disease = result[0]; let accuracy = result[1]; $('.loader').hide() $('#disease').html("Result: " + disease) $('#graph').attr('src', '{% static "graph.png" %}') $('.result').show() } }) }) }) </script> Output using localhost Output using http://127.0.0.1:8000/ -
How to append Dictionary keys null values in a list?
I have a dictionary that has multiple keys and each key has multiple values in list format, if the keys have a Null value then the key should be appended to a list. here is my dictionary: {'XSTY':['21.01', '22.01'], 'STRY': ['31.01', None], 'SYER': ['34.21', None], 'HUHTY': [None, '45.22]} and I am using this approach to append the value of the keys whose values are null in the list final_dict = {'XSTY':['21.01', '22.01'], 'STRY': ['31.01', None], 'SYER': ['34.21', None], 'HUHTY': [None, '45.22]} data = [] for in in final_dict.keys(): if i == 'HUHTY': if len(final_dict[i]>0: data.append(i) print("Append Success") else: print("data did not append") the above code is appending the data for this key only HUHTY', but it should append the data for STRY,SYER,HUHTYall of these keys whose values areNone` inside the list. Any kind of help will be appreciated. I know that it's not appending the other keys due to this condition if i == 'HUHTY': please provide a better approach to do the same thing dynamically. -
python setup.py egg_info did not run successfully on deployment to heroku
I upgraded my pip version after deploying and hosting my website. Then i installed a new package pypaystack. when i attempt to push to heroku i get the error below. Project works fine in development stage. Collecting pypaystack==1.24 remote: Downloading pypaystack-1.24.tar.gz (5.4 kB) remote: Preparing metadata (setup.py): started remote: Preparing metadata (setup.py): finished with status 'error' remote: error: subprocess-exited-with-error remote: remote: × python setup.py egg_info did not run successfully. remote: │ exit code: 1 remote: ╰─> [12 lines of output] remote: Traceback (most recent call last): remote: File "<string>", line 2, in <module> remote: File "<pip-setuptools-caller>", line 34, in <module> remote: File "/tmp/pip-install-h6ay7jb3/pypaystack_2a3b97aa3d934da4b6c7a7d81a4a6ad2/setup.py", line 2, in <module> remote: from pypaystack import version remote: File "/tmp/pip-install-h6ay7jb3/pypaystack_2a3b97aa3d934da4b6c7a7d81a4a6ad2/pypaystack/__init__.py", line 3, in <module> remote: from .customers import Customer remote: File "/tmp/pip-install-h6ay7jb3/pypaystack_2a3b97aa3d934da4b6c7a7d81a4a6ad2/pypaystack/customers.py", line 1, in <module> remote: from .baseapi import BaseAPI remote: File "/tmp/pip-install-h6ay7jb3/pypaystack_2a3b97aa3d934da4b6c7a7d81a4a6ad2/pypaystack/baseapi.py", line 2, in <module> remote: import requests remote: ModuleNotFoundError: No module named 'requests' remote: [end of output] remote: remote: note: This error originates from a subprocess, and is likely not a problem with pip. remote: error: metadata-generation-failed remote: remote: × Encountered error while generating package metadata. remote: ╰─> See above for output. remote: remote: note: This is an issue with the …