Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Unable to send the request to django views using xmlhttprequest
I am doing one application .In that i created the register function in Django views, and in html page, created form and trying to submit it with XMLHTTPRequest.But when i hit the submit button, total form data appending to url and not hitting the Django views register function.Below is the my function to submit the form. function submitForm(oFormElement) { // alert('called'); var xhr = new XMLHttpRequest(); xhr.onload = function(){ alert(xhr.responseText); } xhr.open("POST","/site/register/",true); xhr.setRequestHeader("X-CSRFToken", csrftoken); alert('called'); xhr.setRequestHeader('Authorization', 'Bearer ' + token); xhr.send(); alert('called') return false; } And if i mention the form details in send() also like below also same happening, total headers and data appending to url and not hit the Django Views method. function submitForm(oFormElement) { // alert('called'); var xhr = new XMLHttpRequest(); xhr.onload = function(){ alert(xhr.responseText); } xhr.open("POST","/site/register/",true); xhr.setRequestHeader("X-CSRFToken", csrftoken); alert('called'); xhr.setRequestHeader('Authorization', 'Bearer ' + token); xhr.send(new FormData(oFormElement)); alert('called') return false; } So please help me, how to hit the django views function when i submit the form from HTMl page. -
ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation'
I use translation in my Django apps. Since I installed Django version 4, when I try to import ugettexget_lazy as shown in the code below from django.utils.translation import ugettexget_lazy as _ I get the following error: ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' -
How to generate aware time object in Faker?
I have the following (simplified) model and factory: models.py class Event(): duration = FloatField() start_time = TimeField() finish_time = DateTimeField() def save(self, *args, **kwargs): self.finish_time = self.start_time + timedelta(hours=self.duration) event_factory.py from factory import Faker class EventFactory: date = Faker( "date_time_this_month", before_now=False, after_now=True, tzinfo=timezone.get_current_timezone(), ) start_time = Faker("time_object") duration = Faker("random_int") However, my save method raises Warning: DateTimeField Event.finish_time received a naive datetime (2022-03-28 12:43:38) while time zone support is active. date is aware due to tzinfo argument, but start_time is naive (I checked with django's timezone.is_aware()), because time providers in Faker do not seem to allow any timezone parameters. Any suggestion in getting a fake aware time object in factory-boy/Faker? -
Custom setting model does not apply until server restarted in django
I'm trying custom setting model to change some settings from admin. class Setting(models.Model): is_duel_cart_allowed = models.BooleanField(default=True) free_cancellation_duration = models.DurationField(default="0:0:0") return_order_duration = models.DurationField(default="0:0:0") is_return_charges_deducted = models.BooleanField(_("Return charges applied when order is returned"),default=True) is_shipping_charges_deducted_on_return = models.BooleanField(_("Deduct shipping charges when order is returned"),default=True) is_product_cancellation_charge_deducted = models.BooleanField(_("Cancellation Charges deducted when product is cancelled"), default=True) is_shipping_charges_deducted_on_cancel = models.BooleanField(_("Deduct shipping charges when order is cancelled"), default=True) This is my model and when I turn ON/OFF any of these boolean fields, settings will remain unchanged until server is restarted. How to tackle this problem? Here is my view function code where I'm checking for these models changes from core.models import Setting setting = Setting.objects.first() class ReturnOrderViewset(viewsets.ModelViewSet): serializer_class = OrderSerializer def get_queryset(self): queryset = Order.objects.prefetch_related('items', 'items__product', 'items__user').filter(status_id=12) return queryset def create(self, request, *args, **kwargs): order = request.POST.get('order_id') return_reason = request.POST.get('return_reason') current_time = timezone.now() return_order_duration = setting.return_order_duration try: order = Order.objects.get(id=int(order)) return_reason = ReturnReason.objects.get(id=int(return_reason)) except Order.DoesNotExist: return Response({'message': 'Order not found'}, status=status.HTTP_404_NOT_FOUND) except ReturnReason.DoesNotExist: return Response({'message': 'Order not found'}, status=status.HTTP_404_NOT_FOUND) exp_time = order.created + return_order_duration print(order.created, exp_time) if order.status_id == 8: print("status is complete ======") if exp_time > current_time: print("exp time is great than current time") if all(item.product.is_return_allowed for item in order.items.all()): print("All products are return allowed =====") deductions … -
Cross origin request blocked for s3
I have my pre-assigned URL and policy (created on django) for object to be uploaded into S3 directly from JavaScript. It works as expected during development and in local server. as soon as I upload to host and server online it give me the error of cross origin request blocked on Firefox and on chrome, it says that the request has been aborted. I have allowed all the domains to on bucket as well. I have even put the bucket public. below is my bucket policy and cors policy. I would be so happy for find a solution for this. Bucket Policy { "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1621532678577", "Effect": "Allow", "Principal": "*", "Action": [ "s3:PutObject", "s3:GetObjectAcl", "s3:GetObject", "s3:ListBucket", "s3:DeleteObject", "s3:PutObjectAcl" ], "Resource": [ "arn:aws:s3:::[bucketname]/*", "arn:aws:s3:::[bucket-name]" ] } Cross-origin resource sharing (CORS) [ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "PUT", "HEAD", "POST", "DELETE" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [ "x-amz-server-side-encryption", "x-amz-request-id", "x-amz-id-2" ] } JavaScript function // auto-upload on file input change. $(document).on('change','.cfeproj-upload-file', function(event){ var selectedFiles = $(this).prop('files'); formItem = $(this).parent() $.each(selectedFiles, function(index, item){ var myFile = verifyFileIsImageMovieAudio(item) if (myFile){ uploadFile(myFile) } else { alert("invalid file chosen.") } }) $(this).val(''); }) function constructFormPolicyData(policyData, fileItem) { var contentType … -
Why not all showing up in vs code django/python intellisense
Hi I am new to Python/django and am using VS Code. Now I got python IntelliSense and pylance extension installed and most things are showing up on IntelliSense but some aren't. How can I get it to work for everything? I would very much appreciate some insight since it's driving me nuts... request.POST from an imported lib not showing up selected_meetup.participants not showing up nor is selected_meetup.participants.add from urllib import request from django.forms import SlugField from django.shortcuts import render from .models import Meetup from .forms import RegistrationForm # from django.http import HttpResponse # Create your views here. def index(request): meetups = Meetup.objects.all() return render(request, 'meetups/index.html', { 'meetups': meetups }) def meetup_details(request, meetup_slug): try: selected_meetup = Meetup.objects.get(slug=meetup_slug) if request == 'GET': registration_form = RegistrationForm() else: registration_form = RegistrationForm(request.POST) registration_form = RegistrationForm(request.) if registration_form.is_valid(): participant = registration_form.save() selected_meetup.participants.add(participant) return render(request, 'meetups/meetup-detail.html', { 'meetup_found': True, 'meetup': selected_meetup, 'form': registration_form }) except Exception as exc: return render(request, 'meetups/meetup-detail.html', {'meetup_found': False }) -
Django Forms : ChoiceField gives label tag before the input tag in HTML Templates
Following the code in my Forms.py file for creating 2 radio buttons in my html template. CHOICES=[('online','online'), ('offline','online')] meeting_option = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect(attrs={'class':'form-check-inline','id':'type'}),required=False) but when I used it in template using the syntax {{ form.meeting_option}}, I can able to see the radio button but I can't see that it is selected or not. and the reason I figured is in the code generated by django, I can see the label tag before the input tag like <label for="type_0">Accha</label> <input type="checkbox" id="type_0"> Code can start working if the put the input tag before the label (using manually) Is there anyway I can get the output from Django something like the following ? <input type="checkbox" id="type_0"> <label for="type_0">Accha</label> -
Django: How i can adjust `the size of the square of the input` on the form to be the same in all fields
Hi am using the standard form and i want the size of the square of the input to be the same for all fields. Here is the code: <form action="{% url 'formulaire' %}" method="post" id="maincont" novalidate> <ul class="contactList" style="list-style-type:square; line-height:310%;"> {% csrf_token %} {{ form.as_ul }} </ul> Here is screenshoot how it displays to me in real! .SO How please i can adjust the size of the square of the input to be the same in all fields. -
Need to get a custom JSON response for the authentication login and registration page in django
viewset class CustomRenderer(JSONRenderer): def render(self, data, accepted_media_type=None, renderer_context=None): status_code = renderer_context['response'].status_code response = { "status": "success", "code": status_code, "data": data, "message": None } if not str(status_code).startswith('2'): response["status"] = "error" response["data"] = None try: response["message"] = data["detail"] except KeyError: response["data"] = data return super(CustomRenderer, self).render(response, accepted_media_type, renderer_context) class UserViewset(viewsets.ModelViewSet): renderer_classes = (CustomRenderer, ) authentication_classes =[JWTAuthentication] #ModelViewSet Provides the list, create, retrieve, update, destroy actions. permission_classes=(permissions.IsAdminUser,) #admin authentication ##permission_classes = [HasValidJWT] queryset=models.Default_User.objects.all() serializer_class=serializers.UserDetailsSerializer Urls.py urlpatterns = [ path('', TemplateView.as_view(template_name="social_app/index.html")), #social_app/index.html path('admin/', admin.site.urls), #admin api path('api/',include(router.urls)), #api path('accounts/', include('allauth.urls')), #allauth re_path('rest-auth/', include('rest_auth.urls')), #rest_auth path('api-auth/', include('rest_framework.urls')), re_path('/registration/', include('rest_auth.registration.urls')), path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), #path('auth/login/',TokenObtainPairView.as_view(), name='token_obtain_pair'), path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), path('jobview/',view), path('timelog/',timelogview), path('chaining/', include('smart_selects.urls')), ] I have created a custom JSON response for my API and i have given that JSON renderer in all my API viewsets and Iam getting the results as expected. But I need to get the same when I generate a token using JWT in the login page. If I enter the username and password and post that in the url:http://127.0.0.1:8000/api/token/ Iam getting an output as { "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY0OTQ4NjU0MSwiaWF0IjoxNjQ2ODk0NTQxLCJqdGkiOiI2ZWViYWRhZGY2YTU0M2ZkOTczYTQ5Y2RjNWM4OTdkZSIsInVzZXJfaWQiOj", "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjQ2ODk1NDQxLCJpYXQiOjE2NDY4OTQ1NDEsImp0aSI6ImZkMDA5OWRkNTA4NzQyNDk5MTg0MTUxYzU3MWRjYmU1IiwidXNlcl9pZCI6M" } But i need to get it as { "status": "success", "code": 200, "data": [ "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY0OTQ4NjU0MSwiaWF0IjoxNjQ2ODk0NTQxLCJqdGkiOiI2ZWViYWRhZGY2YTU0M2ZkOTczYTQ5Y2RjNWM4OTdkZSIsInVzZXJfaWQiOjF9.Rn8trTwVSTt29dMhFSAGZOoi7B758MQHwL1LJjSj_xo", "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjQ2ODk1NDQxLCJpYXQiOjE2NDY4OTQ1NDEsImp0aSI6ImZkMDA5OWRkNTA4NzQyNDk5MTg0MTUxYzU3MWRjYmU1IiwidXNlcl9pZCI6MX0.oQ4pHWMGXV_T1KBzXWZzvg2ceRuNUd5ci7-iZdevvB8" ] "message": null } … -
How do you resolve unique field clashes in django?
I have a model that looks like this: class Foo(models.Model): unique_field = models.URLField(unique=True) another_field = models.TextField() # etc... and its corresponding ViewSet looks like this (bound to /foo/): class FooViewSet( viewsets.GenericViewSet, mixins.ListModelMixin, mixins.CreateModelMixin, mixins.DestroyModelMixin, ): queryset = Foo.objects.all() serializer_class = FooSerializer When I make a POST request to /foo/, if there's no clash I just want the default behaviour (create a new row in the database and return its serialized form as a json blob). The problem is that when there is a clash the server just throws an error. What I'd rather have it do is return the json blob for the existing data, rather than crashing. Or at the very least return some kind of descriptive error. Is there a way to get this behaviour without manually overriding create()? -
python in each row take one hidden fields when popup data saved then get primary id and save in this hidden id
I have (A) table have model table. and now I do popup window for (B) table with FK of the (A) table. when I check the checkbox of one row of (A) table and press the button for the popup in each row will take one hidden field when popup data is saved then get primary id and save in this hidden id and when you will save the page then it will also save all the tables. Note: each row of the table (A ) has a specific id showing different popup data of table(B). -
Django Redis Caching how can i set cache timeout to none (never expiring cache) in class base view
I'm using redis server for caching. Using django-redis package. Below is my setting file : CACHES = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': 'redis://127.0.0.1:6379/1', 'OPTIONS': { 'CLIENT_CLASS': 'django_redis.client.DefaultClient', }, } } My view : from django.utils.decorators import method_decorator from django.views.decorators.cache import cache_page @method_decorator(cache_page(timeout=None,key_prefix="site1"), name='dispatch') class ProfileView(APIView): # With auth: cache requested url for each user for 2 hours def get(self, request, format=None): content = { 'user_feed': request.user.get_user_feed() } return Response(content) When set timeout=60 it's working. But when i add timeout=None i'm getting 600 seconds timeout. -
Django ForeignKey: using in reverse order. What form element is shown
I have a student project relationship. One student can be assigned to only one project. A project can have multiple students The following is my student and Project model class Student(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) def __str__(self): return self.first_name class Project(models.Model): name = models.CharField(max_length=30) def __str__(self): return self.name How to get create the relationship in this case -
Django How to give 2 field names in filters.py date filter
In filters.py Here i want to give 2 field names in start date class enquiryFilter(django_filters.FilterSet): start_date = DateFilter(field_name="updated_at", lookup_expr='gte',label='From',widget=DateInput(attrs={'type': 'date','id':'start_date'})) -
How to increase number of allowed symbols in line with flake8? [duplicate]
Default number of symbols is 79 according to PEP8. I use django and whant a little bit more. How and where set it? -
How to create a view of a template with 3 forms, two of them load multiple images?
I made 3 forms in one template, in the first model the fields are text inputs (it works and saves the data), in the second model it is an input to upload multiple images (it does not work and does not save data) and in the third is also to upload multiple images (does not work and does not save data). When I create the view I divided the three forms on the same view, but only the first saves data, the others don't. Even if I go into /admin there is no input button to save images. It makes me think I'm doing something wrong with my views, but I don't know what it is. can you help me review the code? Thank you models.py class Carro(models.Model): placas=models.CharField(max_length=255) tipo=models.CharField(max_length=255) cliente= models.ForeignKey(Clientes, on_delete=models.SET_NULL, null=True) fecha_registros = models.DateTimeField(default=datetime.now, null=True) def __str__(self): return f'{self.placas} {self.tipo}{self.cliente}' \ f'{self.fecha_registros}' class CarroImagenes(models.Model): carro = models.ForeignKey(Carro, on_delete=models.SET_NULL, null=True) fotosCarro=models.ImageField(null=True, blank=True, upload_to="images/") def __str__(self): return f'{self.fotosCarro}' class GarantiaImagenes(models.Model): carro = models.ForeignKey(Carro, on_delete=models.SET_NULL, null=True) garantia=models.ImageField(null=True, blank=True, upload_to="images/") def __str__(self): return f'{self.garantia}' forms.py class CarroForm(forms.ModelForm): class Meta: model=Carro fields = ['placas','tipo','cliente'] exclude = ['fecha_registros'] widgets = { 'placas': forms.TextInput( attrs={ 'class': 'form-control', } ), 'tipo': forms.TextInput( attrs={ 'class': 'form-control' … -
python django get_object_or_404 inside form_valid doesn't work
I hope you can help me, I am learning django, particularly class-based views, I have the following code. I think the get_object_or_404 inside form_valid is not working as it should. class AgregarEntrada(CreateView): model = Entrada template_name = 'EntradaCrear.html' form_class = FormularioEntrada success_url = reverse_lazy('UltimasEntradas') def get_context_data(self, **kwargs): obj = get_object_or_404(Empresa, pk = self.kwargs["pk"], slug = self.kwargs["slug"], FechaCreacion = self.kwargs["FechaCreacion"]) contexto = super().get_context_data(**kwargs) return contexto def form_valid(self, form): obj = get_object_or_404(Empresa, pk = self.kwargs["pk"], slug = self.kwargs["slug"], FechaCreacion = self.kwargs["FechaCreacion"]) form.instance.empresa_id = self.kwargs["pk"] form.instance.UsuarioCreo = self.request.user.username self.object = form.save() form.instance.Entrada = form.instance.pk return super().form_valid(form) everything works perfect, this view saves the data correctly, even if I go to /pk/slug everything works fine, likewise if I change the slug or the pk in the url it immediately sends me a 404 error, which is so well, the problem lies when someone changes the url once the form has been rendered, for example the pk or the slug, instead of sending me an error, it saves the data as if the pk or the slug were correct. I want to explain myself better. If I go to url/pk/slug everything works fine, but when someone goes to url/pk/slug and changes it to url/fake-pk/fake-slug the … -
Server Error (500) when generating a token on Django Admin page on Heroku what gives?
I'm in the final stage of wrapping up my API. The last thing I did was create a token via the Django admin page that would authorize my script to upload to the database. Basic example.py snippet: headers = {'Authorization': 'Token e4fxxxxx000000xxxxx00000xxxxxxxxxx00000'} r = requests.post(UPDATE_URL_ENDPOINT, json=json_details, headers=headers) Works swimmingly on my local machine. But when I deploy my project to heroku, it doesn't recognize my token so it doesn't accept my post requests. Fine, I say. I'll create a new token on Heroku's servers. So I create a new superuser on their command line, access the admin page, check the Create token page and go click to create a new token. And guess what I see. Server Error (500) WHAT THE HECK IS GOING ON? I'm supposed to be done with this bloody thing! This is the final block before I can finally say au revoir to this bloody project. Please, stackoverflow, fix it! -
handling many to many relation in djangon models
I am working on a project named "Super Market Inventory Management System". There are some models requiring many-to-many relation among them. I tried to add ManyToManyField(to=model, on_delete=models.CASCADE). However, it works but I need to add some values to extra fields to the bridge table between to many to many tables. How can I do It? Given below is my models.py class Purchase(models.Model): pay_status = models.CharField(max_length=50, choices=PAYSTATUS_CHOICES, default="Pending") date_of_purchase = models.DateTimeField(auto_now_add=True) last_payment = models.DateTimeField(auto_now=True) class Product(models.Model): name = models.CharField(max_length=200) barcode = models.IntegerField(blank=True, null=True) description = models.TextField(blank=True, null=True) # image = weight = models.TextField(blank=True, null=True) status = models.BooleanField(default=True) price = models.FloatField() created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) class PurchaseProduct(models.Model): purchase_id = models.ForeignKey(to=Purchase, on_delete=models.CASCADE) product_id = models.ForeignKey(to=Product, on_delete=models.CASCADE) unit_price = models.FloatField() quantity = models.IntegerField() price = models.FloatField() -
CodeCov is ignoring certain files. No settings for ignore in YAML. Python/Django
I have a Python Django project on GitHub and I'm using CodeCov with this project. I have two apps in this Django project, a general app, and a general_api app. For some reason, all of the changes made in the general_api app files are being ignored. I had YAML settings like this to ignore my test cases: codecov: require_ci_to_pass: false ignore: - (?s:test_[^\/]+\.py.*)\Z - (?s:tests_[^\/]+\.py.*)\Z - ^test.py.* - ^tests.py.* However, I've removed them with the same issue. Is there some other way to ignore, or set the ignore parameters in CodeCov other than the YAML settings? OR any idea why this may be happening? -
forloop.counter0 in my django template is not working under original for loop
I have a for loop that goes through a list of inspections. I'd like to manipulate the things inside the tag depending on different situations. For test, I tried to using jquery to print out the id of the element as it iterates, but the forloop seems to be stuck at 0. when I put inside the html it will iterate, but when I put inside the attribute 'id', it will not iterate. based on the code below, it should iterate as many times as there is i in inspections. but it wont. <div class="tab-pane fade" id="nav-inspection" role="tabpanel" aria-labelledby="nav-inspection-tab"> <div class="container"></br></br> {% for i in inspections %} <div class="card - mb-3" style="width: 40 rem;"> <div class="card-body"> <h3 class="card-title">{{i.Title}} - <span title="" id="s{{forloop.counter0}}">{{i.Condition}}</span> </h3> <script type="text/javascript"> console.log(document.querySelector('[title]').innerHTML); $(document).ready(function(){ alert($('[title]').attr("id")); }); </script> <p>{{i.Desc}}</p> <h4><span class="badge badge-primary">{{i.Cost}}</span></h4> </div> </div> {% endfor %} </div> </div> -
how to run pytest conftest before everything is imported
This is a simplified version of my problem. I have a python application with the structure as below: my_project my_app __init__.py settings.py tests __init__.py conftest.py my_test.py venv # settings.py from dotenv import load_dotenv load_dotenv() MY_VALUE = os.environ["MY_KEY"] I dont want to add a .env file in here for some reasons. I also dont want to use get method on os.environ I want to run this test # my_test.py from my_app import settings def test_something(): assert True However, I get a KeyError because once I import settings.py, MY_VALUE = os.environ["MY_KEY"] is run and because MY_KEY is not in env, I get KeyError. What I thought is that I could have conftest as below import os from unittest import mock import pytest @pytest.fixture(autouse=True) def set_env(config): with mock.patch.dict(os.environ, {'MY_KEY': 'MY_VALUE'}): yield But it is still the same problem. How can I enforce this conftest before everything else. -
Auto populating database with text file django automate()
I am wanting to automatically populate my database with text files. When I try to run the file with the server on I receive the error: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/app1/automate Using the URLconf defined in demo.urls, Django tried these URL patterns, in this order: admin/ The current path, app1/automate, didn’t match any of these. You’re seeing this error because you have DEBUG = True in your Django I saw a friend do it this way and he entered this url (http://127.0.0.1:8000/app1/automate) and then the database populated. What am I missing? Thanks model.py from email.policy import default from unicodedata import name from unittest import result from django.db import models # Create your models here. class Datepick(models.Model): date = models.DateField() class PracticeGamesL(models.Model): GAMETYPECHOICES = [('PB', 'PowerBall'), ('LA', 'Lotto America'), ('TNC', 'TN Cash'), ('MM', 'Mega Millions'), ('C4L', 'Cash 4 Life')] game_type = models.CharField(max_length=10, choices=GAMETYPECHOICES) num1 = models.SmallIntegerField(null=True, blank=True) num2 = models.SmallIntegerField(null=True, blank=True) num3 = models.SmallIntegerField(null=True, blank=True) num4 = models.SmallIntegerField(null=True, blank=True) num5 = models.SmallIntegerField(null=True, blank=True) num6 = models.SmallIntegerField(null=True, blank=True) # special reveal_date = models.DateField() automation.py from datetime import datetime from django.http import HttpResponse from app1.models import PracticeGamesL import os def automate(request): texts = os.listdir('past_lotteries') for text in texts: … -
How can I use django-notifications to realize personal message notification and system notice?
How can I use django-notifications or another tool to realize personal message notification and system notice? We have many apps that need this function(more than 10 tables are involved), so I really need an easy way to solve it, thanks so much for any advice Our system(wrote in Django-rest-framework) has a function, that needs to push information when the relevant users' information is added or updated, the system will send relevant users information, such as "Your order is waiting for review (to the auditor)" "Your order is passed (to the auditee)" and also need some system notice, that every user can see that message: "Outage notice, this system will restart at XXXXX, please ......" -
/app/.heroku/python/bin/python: /app/.heroku/python/bin/python: cannot execute binary file
When I tried running "heroku run bash python manage.py migrate --app appName" from my terminal using the Heroku CLI, I get below error/response; "/app/.heroku/python/bin/python: /app/.heroku/python/bin/python: cannot execute binary file".