Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Is there any defined way in django to refresh the ML model that I loaded in apps.py at the startup?
I have a REST API deployed using gunicorn, serving a ML model. Model size is 1 GB. I am loading my ML model at startup in apps.py. Whenever a request is made to the server, model is giving the response quickly. Now there is a model training happening in background using apscheduler that updates the ML model in every 3 hours. I want to refresh this updated model in the variable holding the previous model in apps.py without switching off my wsgi server. There is a defined methods to load the model at startup ex. loading model in apps.py Is there any way that somehow I can refresh the model also? -
CSRF Error When Communicating Between Two Servers
I have two Django-based servers where I want one to send a file.py to the other one via RESTful API. I do receive the POST request on the second server but I get a message like: Forbidden (no CSRF) POST http:\127.0.0.1 etc. server1 runs on http:\127.0.0.1:8000 and server2 runs on http:\127.0.0.1:8001. My intermediate goal is for server1 to send a POST request containing the file in binary to server2, whenever I go to the web address http:\127.0.0.1\8001\download, and I want server2 to save the file in a folder. The urls work fine so I do not include the code here. Here is the relevant code of server1: def execute_view(request, *args, **kwargs): files = {'file': open('testFile.py', 'rb')} req = HttpResponse.POST("http://127.0.0.1:8001/fileDownload/", files=files) and the relevant code of server2: def execution_view(request, *args,**kwargs): file = request.files['file'] with open('transferred.py','wb') as f: for chunk in file.iter_content(chunk_size=1892): if chunk: f.write(chunk) I saw I need to add, for example, @csrf_exempt over one of the functions but I do not even know on which. Either one does not work, even when I import the module. -
How do you remove the "XMLHttpRequest error" in Flutter? (Django backend, Flutter frontend)
I'm having trouble connecting my Django backend to my Flutter frontend on web.I have not tested on Android or iOS yet. I want to be able to do an API call and have it return a response that I can convert to a json. However it's been throwing errors no matter what I've tried. I've tried converting it into an https request with no avail. If anyone needs anything on the Django side please let me know This is what the error looks like: Error: XMLHttpRequest error. dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 909:28 get current packages/http/src/browser_client.dart 71:22 <fn> dart-sdk/lib/async/zone.dart 1613:54 runUnary dart-sdk/lib/async/future_impl.dart 155:18 handleValue dart-sdk/lib/async/future_impl.dart 707:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 736:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 533:7 [_complete] dart-sdk/lib/async/stream_pipe.dart 61:11 _cancelAndValue dart-sdk/lib/async/stream.dart 1219:7 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14 _checkAndCall dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39 dcall dart-sdk/lib/html/dart2js/html_dart2js.dart 37307:58 at Object.createErrorWithStack (http://localhost:63593/dart_sdk.js:5362:12) at Object._rethrow (http://localhost:63593/dart_sdk.js:39509:16) at async._AsyncCallbackEntry.new.callback (http://localhost:63593/dart_sdk.js:39503:13) at Object._microtaskLoop (http://localhost:63593/dart_sdk.js:39335:13) at _startMicrotaskLoop (http://localhost:63593/dart_sdk.js:39341:13) at http://localhost:63593/dart_sdk.js:34848:9 And this is a code snippet import 'package:http/http.dart' as http; var url2 = 'https://0.0.0.0:8809/test/'; try{ response = await http.get(Uri.parse(url2)); print(response.body); } catch(exception){ print('could not access'); response = await http.get(Uri.parse(url2)); } }, I had it print out the error. -
How to get rid of .pyc
I've been creating a Django app and I have a question about .pyc. I don't know exactly when, but I believe when I created a branch and moved into the branch, I always had a problem about .pyc. Three .pyc files always emerge to branch areas on VSCode. I want to even delete the three files, but I don't think it's the best way to solve this. Or maybe I can't delete them for another reason. -
how to count number of females and males per day (group by) in django
i'm trying to group by for dates and count number of field(choice field : male and female) this is what i tried genders = ( (male , _('male')), (female , _('female')), ) class MyModel(models.Model): gender = models.CharField(max_length=10,choices=genders,default=male) created_at = models.DateTimeField(auto_now_add=True) #others my views.py male= Q(gender='male') female= Q(gender='female') lists = MyModel.objects.annotate(day=TruncDay('created_at')).values('day').annotate(qnt=Count('id'),male=Count(male),female=Count(female) ).order_by('-day') i expect to return something like this : day : 1-8-2021 , qnt: 15 , male : 8 , female : 7 but it return total quantity qnt for both male and female ! is there a better approach to achieve that please ? -
Make order by function inside model class in Django
models: class Product(models.Model): product_model = models.CharField(max_length=255) price = models.DecimalField(default=0 , decimal_places=0 , max_digits=8) def product_all_price(self): if self.price > 0: ... return price else: .... return "0" my views: def products_list(request): products_list = Product.objects.filter(product_draft=False) products_list = products_list.order_by('-created_on') ... How can i order this list by product_all_price in models. show returned "price", above and all returned "0", below -
Heroku Node Js app will load (ex. https://appname-98115.herokuapp.com/) but the dns record is not
I have previously had this system running properly through google domains. I made some changes in Google domains and now my website and the DNS url itself will not work. I know the app is still running properly because the app will work in heroku (ex. https://appname-98115.herokuapp.com/) but the dns record will return site can not be reached (ex. http://www.fluffy-barracuda-vczoblygcndwilc4jl86qdra.herokudns.com/) Does this url loading rely on the google domain to be setup properly? Is this a sign that google domains is off? Or should the link work before it's setup in Google Domains and that's why the google domain is not currently working? At the moment it's hard for me to know where to start Thanks ! -
How can i check the model object is 30 days old or not in Django?
Info: I am trying to make monthly billing app. Where a customer can buy a property on a monthly basis payment. i want to change the pending attribute True to False if the customer last payment 30 days old. It is a schedule based app but i am not using django-crontab or celrey. i can use view funtion for it if user visit the pending_customers page the view can check the all and which customers the last payments date created_at if the created_at datetime is 30 days old. Then the view funtion can change the pending to False. pending_customers view is working fine but it is changed the pending to False when i visit the page pending_customers. It could not wait for 30 days. if the customer last payment is not 30 days old then how can i hold the view funtion until for 30 days? models.py class Customer(models.Model): """Customer Model""" name = models.CharField(max_length=255) prop_select = models.ForeignKey(Property, on_delete=models.SET_NULL, null=True) created_on = models.DateTimeField(auto_now_add=True) pending = models.BooleanField(default=False) class Payment(models.Model): """Payment Model""" customer = models.ForeignKey(Customer, null=True, on_delete=models.SET_NULL, related_name='payment') created_at = models.DateTimeField(auto_now_add=True) amount = models.DecimalField(max_digits=17, decimal_places=2, default=0.0) def save(self, *args, **kwargs): super(Payment, self).save(*args, **kwargs) self.customer.pending_customer = True self.customer.save() views.py def pending_customers(request): queryset = Customer.objects.all() … -
How to organize data in AWS S3 bucket during a web data migration?
I currently built a blog using Django. It involves creating a post where images are also uploaded to an AWS S3 bucket. However, I would like to rebuild the whole website in Node.js/the MERN stack in the near future. As I upload more photos to the S3 buckets, and build the website in Node.js- how should I keep track of organizing the data that I currently have in Django so that when I have the MERN stack website ready, I can seamlessly move both the post and photo info there? -
ModuleNotFoundError: No module named 'phonenumbers'
I am deploying an app which works well locally to Heroku for the first time, and I have the following error: ModuleNotFoundError: No module named 'phonenumbers' 2021-08-01T05:05:10.359150+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2021-08-01T05:05:10.359151+00:00 app[web.1]: django.setup(set_prefix=False) 2021-08-01T05:05:10.359151+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup 2021-08-01T05:05:10.359152+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS) 2021-08-01T05:05:10.359152+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 91, in populate 2021-08-01T05:05:10.359152+00:00 app[web.1]: app_config = AppConfig.create(entry) 2021-08-01T05:05:10.359153+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create 2021-08-01T05:05:10.359153+00:00 app[web.1]: module = import_module(entry) 2021-08-01T05:05:10.359153+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module 2021-08-01T05:05:10.359154+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2021-08-01T05:05:10.359154+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import 2021-08-01T05:05:10.359155+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load 2021-08-01T05:05:10.359155+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked 2021-08-01T05:05:10.359221+00:00 app[web.1]: ModuleNotFoundError: No module named 'phonenumbers' 2021-08-01T05:05:10.360272+00:00 app[web.1]: [2021-08-01 05:05:10 +0000] [9] [INFO] Worker exiting (pid: 9) 2021-08-01T05:05:10.416411+00:00 app[web.1]: [2021-08-01 05:05:10 +0000] [10] [ERROR] Exception in worker process 2021-08-01T05:05:10.416412+00:00 app[web.1]: Traceback (most recent call last): 2021-08-01T05:05:10.416413+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker 2021-08-01T05:05:10.416413+00:00 app[web.1]: worker.init_process() 2021-08-01T05:05:10.416414+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 134, in init_process 2021-08-01T05:05:10.416414+00:00 app[web.1]: self.load_wsgi() 2021-08-01T05:05:10.416415+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi 2021-08-01T05:05:10.416415+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2021-08-01T05:05:10.416419+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi 2021-08-01T05:05:10.416420+00:00 app[web.1]: self.callable = self.load() 2021-08-01T05:05:10.416420+00:00 … -
How to set mocked instance variable of class in python?
I'm writing a unit test for MyProducer class which produces the message on kafka topic. logic of testing is just mock the constructor of MyProducer class and set the manually created producer object to the instance of MyProducer class and then just verify if library methods of confluent-kafka are getting called correctly or not. I'm stuck in setting the manually created producer object to MyProducer. How can we set the manually created object to instance variable of MyClass by mocking init? # kafka_producer.py # actual code class MyProducer(object): def __init__(self, config: Dict[str, Any]={}): self.producer = Producer(config) def produce(self, *args, **kwargs): pass # test_kafka.py # testing def get_producer(*args, **kwargs): print(args,kwargs) conf = { "bootstrap.servers": 'localhost:9093' } producer = Producer(conf) def produce(*args, **kwargs): pass class KafkaTest(unittest.TestCase): def setUp(self): pass @mock.patch( "utils.kafka_producer.KafkaProducer.__init__", ) @mock.patch( "confluent_kafka.Producer.produce", ) def test_kafka_producer(self, produce, kafka_producer): produce.side_effect = produce kafka_producer.side_effect = get_producer kafkaProducer = MyProducer( {'bootstrap.servers': os.environ['KAFKA_BOOTSTRAP_SERVERS']} ) kafkaProducer.produce(fake_kafka_topic, value='test_data') It is giving error: AttributeError on 'MyProducer' has no attribute 'producer'. -
Google app engine disable request logging
I'm looking for a way to filter out request logging spam so I can more easily see warnings or errors. This seems to work locally: 'loggers': { 'django': { 'handlers': ['console'], 'level': 'WARNING', } } but fails on GAE According to this question this isn't possible and I need to use a log parser instead. However, that was 7 years ago, so I'm wondering if there's now a way to get this to work. Additionally, the answer links to a log parser which results in a 404, so if this isn't possible, I would like a link to a working log parser -
Adding new data to class in a Django model
I have a form which requires adding a standard name and if there is an option to add additional names to be added I want to create another input for it. I am not sure how to do that in regard to the Models, and migrating and creating the html related to the new name to take in the input. I have created the form with the following models: ownerName1= models.CharField(max_length=100,null=True, blank=True, verbose_name='Owner Name 1') ownerRole1= models.CharField(max_length=100,null=True, blank=True, verbose_name='Owner Role 1') ownershipPercentage1= models.IntegerField(null=True, blank=True, verbose_name='Business Phone 1') I added in the HTML template a button to add a new shareholder if available so I want if the button is created to create the following in the models.py ownerName2= models.CharField(max_length=100,null=True, blank=True, verbose_name='Owner Name 2') ownerRole2= models.CharField(max_length=100,null=True, blank=True, verbose_name='Owner Role 2') ownershipPercentage2= models.IntegerField(null=True, blank=True, verbose_name='Business Phone 2') and if pressed one more time the number changes to 3 and so on. Subsequently in needs to be updates in the form: class infoForm(ModelForm): class Meta: model = Info fields = ['ownerName1','ownerRole1','ownershipPercentage1'] Here is an example of the form: <div class="tab-pane fade" id="ownershipStructure" role="tabpanel" aria-labelledby="pills-3-tab"> <h2>Ownership Structure</h2> <div class="form-outline mb-4"> <input type="text" name="ownerName1" id="ownerName1" class="form-control" {% if form.is_bound %}value="{{ form.ownerName1.value }}"{% endif %}/> <label … -
Request from unknown party, Sogou
I am hosting a simple prototype on Amazon Lightsail and I saw some strange requests on my Django server. Is it anything to be concerned about? Invalid HTTP_HOST header: 'fuwu.sogou.com'. You may need to add 'fuwu.sogou.com' to ALLOWED_HOSTS. Invalid HTTP_HOST header: 'fuwu.sogou.com'. You may need to add 'fuwu.sogou.com' to ALLOWED_HOSTS. Bad Request: /http:/fuwu.sogou.com/404/index.html Bad Request: /http:/fuwu.sogou.com/404/index.html [01/Aug/2021 02:50:44] "GET http://fuwu.sogou.com/404/index.html HTTP/1.1" 400 63056 [01/Aug/2021 02:50:44] "GET http://fuwu.sogou.com/404/index.html HTTP/1.1" 400 63066 [01/Aug/2021 02:50:51] code 400, message Bad request syntax ('\x05\x01\x00') [01/Aug/2021 02:50:51] "" 400 - -
Connection refused when try convert html to pdf in AWS ubuntu, But works File in Local env
I am trying to convert HTML to pdf in a Django project it works fine on my local computer but when I uploaded it on my AWS ec2 instance it's giving me [Errno 111] Connection refused html_to_pdf function def render_to_pdf(template_src, context_dict={}): template = get_template(template_src) html = template.render(context_dict) result = BytesIO() pdf = pisa.pisaDocument(BytesIO(html.encode("ISO-8859-1")), result) if not pdf.err: return HttpResponse(result.getvalue(), content_type='application/pdf') return None Error in Django -
Django - Getting request instance in custom Template Backend
I've implemented a custom template backend (like django.template.backends.django.DjangoTemplates) where I need to determine a custom path for the template that needs to be used based on properties on the request object. That path is not/can't be added to TEMPLATES in settings.py in hard-coded manner, so it needs to be determined dynamically. Problem is that, I couldn't find a way to obtain the instance of request object within my class, it doesn't seem to be provided to the class at all. So I was wondering, whether this is even possible. I couldn't find anything in the docs. It's not possible or did I miss something? Thanks -
Nginx + uwsgi + Django + socket: web socket connection cannot be established
I am building a project that uses Nginx + uwsgi + Django. The project uses websocket. Everything works just fine when I run local tests, but things got out of hand when I am running it on a server. I am getting an error telling me that Websocket connection failed, and I am not receiving a status code. I suspect that the problem is not with my Django settings, but rather with the Nginx and uwsgi configuration. Nginx.conf: user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; # multi_accept on; } http { upstream django { server 127.0.0.1:8000; } server { listen 80; server_name 8.1**.1**.104; charset utf-8; location /static { alias /home/Pilot/main/static; } location / { uwsgi_pass 127.0.0.1:8000; include /etc/nginx/uwsgi_params; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } uwsgi.ini: [uwsgi] chdir =/home/Pilot module =Pilot.wsgi master =true processes =4 socket =127.0.0.1:8000 chmod-socket = 666 vacuum = true I thought I read something about Django that it uses asgi rather than … -
d3 voronoi from gejson
I've been trying to adapt a voronoi example code I found online,(originally works with an csv input) but I cant make it display on the map, and it doesn't report any error in the console, I'm generating a geojson with django, I'm not so versed in Javascript, so any help will be appreciated: this is what I have: showHide = function(selector) { d3.select(selector).select('.hide').on('click', function(){ d3.select(selector) .classed('visible', false) .classed('hidden', true); }); d3.select(selector).select('.show').on('click', function(){ d3.select(selector) .classed('visible', true) .classed('hidden', false); }); } voronoiMap = function(map, geoj) { var pointTypes = d3.map(), points = [], lastSelectedPoint; var voronoi = d3.geom.voronoi() .x(function(d) { return d.x; }) .y(function(d) { return d.y; }); var selectPoint = function() { d3.selectAll('.selected').classed('selected', false); var cell = d3.select(this), point = cell.datum(); lastSelectedPoint = point; cell.classed('selected', true); d3.select('#selected h1') .html('') .append('a') .text(point.properties.id) //.attr('href', point.properties) .attr('target', '_blank') } var drawPointTypeSelection = function() { showHide('#selections') labels = d3.select('#toggles').selectAll('input') .data(pointTypes.values()) .enter().append("label"); labels.append("input") .attr('type', 'checkbox') .property('checked', function(d) { return initialSelections === undefined }) .attr("value", function(d) { return d.type; }) .on("change", drawWithLoading); labels.append("span") .attr('class', 'key') .style('background-color', function(d) { return d.color; }); labels.append("span") .text(function(d) { return d.type; }); } var selectedTypes = function() { return d3.selectAll('#toggles input[type=checkbox]')[0].filter(function(elem) { return elem.checked; }).map(function(elem) { return elem.value; }) } var pointsFilteredToSelectedTypes … -
Kuberntes: Django + Gunicorn only / path working
I've been trying to deploy a Django project to EKS but I haven't been able to make it work. I installed ALB and I managed to get public access but now the only path working is / and everything else loads forever without giving an error. Here are my yamls: django-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: django-app labels: app: django spec: replicas: 3 selector: matchLabels: app: django template: metadata: labels: app: django spec: containers: - name: django image: <image-uri> imagePullPolicy: Always ports: - containerPort: 8000 name: gunicorn django-service.yaml apiVersion: v1 kind: Service metadata: name: django-service annotations: service.beta.kubernetes.io/aws-load-balancer-type: external service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing spec: ports: - port: 80 targetPort: 8000 protocol: TCP type: LoadBalancer selector: app: django Things that I've tried: Using default load balancer vs Ingress with its own yaml Using Fargate nodes vs managed nodes Different Gunicorn configs (never got an error apart from timeouts) -
UTF-8 when running management commands from script
I am using this command to dump data py -Xutf8 manage.py dumpdata app.ModelName --indent 4 --format=json --output app/fixtures/data.json which works perfectly fine. However when I try to run the command in script management.call_command( "dumpdata", indent=4, format="json", output=os.path.join(path, "app//fixtures//data.json"), verbosity=1, ) It ends up with this error: django.core.management.base.CommandError: Unable to serialize database: 'charmap' codec can't encode characters in position 1-2: character maps to <undefined> I have tried something like this yet it still doesn't work. Any solutions to this? -
Getting mistake after creating success_url with CreateView class
Sorry for my bad English in advance. I'm trying to discover django, so I decided to write my own sign in/sign up views. So I just wrote something like that - class RegisterView(CreateView): template_name = 'auth/user_create_form.html' model = User fields = ['username', 'password', 'email'] So, it's basically working with GET requests. We can see the form on specified url. But after altering all fields and submitting form, I've got a mistake what suggested to specify get_absolute_url for model to redirect after submitting. So I decided to give success_url to RegisterView - class RegisterView(CreateView): template_name = 'auth/user_create_form.html' model = User fields = ['username', 'password', 'email'] success_url = reverse('words:main_page') And got a mistake Exception in thread django-main-thread: Traceback (most recent call last): File "/home/yegor/.cache/pypoetry/virtualenvs/word-collector-g9LS8W6v-py3.9/lib/python3.9/site-packages/django/urls/resolvers.py", line 600, in url_patterns iter(patterns) TypeError: 'module' object is not iterable The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/linuxbrew/.linuxbrew/opt/python@3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/home/linuxbrew/.linuxbrew/opt/python@3.9/lib/python3.9/threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "/home/yegor/.cache/pypoetry/virtualenvs/word-collector-g9LS8W6v-py3.9/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/home/yegor/.cache/pypoetry/virtualenvs/word-collector-g9LS8W6v-py3.9/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run self.check(display_num_errors=True) File "/home/yegor/.cache/pypoetry/virtualenvs/word-collector-g9LS8W6v-py3.9/lib/python3.9/site-packages/django/core/management/base.py", line 419, in check all_issues = checks.run_checks( File "/home/yegor/.cache/pypoetry/virtualenvs/word-collector-g9LS8W6v-py3.9/lib/python3.9/site-packages/django/core/checks/registry.py", line 76, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/home/yegor/.cache/pypoetry/virtualenvs/word-collector-g9LS8W6v-py3.9/lib/python3.9/site-packages/django/core/checks/urls.py", … -
Django/AWS EB: [app-deploy] - [RunAppDeployPreBuildHooks] error (no such file or directory), BUT the file does exist?
I have a Django application and I'm trying to deploy to my AWS EB Environment. It's a project that my friend and I are working on. I an trying to run the command eb deploy however though I get this: Alert: The platform version that your environment is using isn't recommended. There's a recommended version in the same platform branch. Creating application version archive "app-3d19-210731_133226". Uploading Prod Rest API/app-3d19-210731_133226.zip to S3. This may take a while. Upload Complete. 2021-07-31 17:32:29 INFO Environment update is starting. 2021-07-31 17:32:33 INFO Deploying new version to instance(s). 2021-07-31 17:32:36 ERROR Instance deployment failed. For details, see 'eb-engine.log'. 2021-07-31 17:32:39 ERROR [Instance: i-05761282d68083a51] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. 2021-07-31 17:32:39 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1]. 2021-07-31 17:32:39 ERROR Unsuccessful command execution on instance id(s) 'i-05761282d68083a51'. Aborting the operation. 2021-07-31 17:32:39 ERROR Failed to deploy application. ERROR: ServiceError - Failed to deploy application. I checked the eb-engine.og and this is what I get: 2021/07/31 17:19:47.104584 [INFO] Executing instruction: StageApplication 2021/07/31 17:19:47.111204 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ 2021/07/31 17:19:47.111230 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/ 2021/07/31 … -
Django - setCustomValidity translation error
I need to translate error messages in setCustomValidity with Django i18n, but with code below it works only for the first input field. Something is messed with translation part. Could You take a look? enter code here <form action="" method="post" action=''> {% csrf_token %} <div class='message-area'> <div id='contact-form-name'> <input type='text' name='message-name' class='form-control' placeholder="{% trans 'Name' %}" required oninvalid='this.setCustomValidity("{% trans 'Fill in' %}")'> </div> <div id='contact-form-message'> <textarea type='text' name='message-message' id='form-control-message' placeholder="{% trans 'Message' %}" required oninvalid='this.setCustomValidity("{% trans "Fill in" %}")'></textarea> </div> <button id='search-button' type='submit'>{% trans 'Wyślij' %}</button> </div> </form> enter code here -
AttributeError: '_EnumDict' object has no attribute '_cls_name'
I have been receiving this error in several python based projects including my current one Shuup and i'm not sure how to resolve it. I have research other errors but none speak about this one. Any help to steer me in the right direction would be great. -
Django Http404 returns status=200
When my application raises Http404 the status-code returned is 200, which I find odd. It returns and renders my 404-template, so it should work, but the status-code is wrong. Please find the views and urls-file below: #views.py from django.http import Http404 def test_404_view(request): raise Http404 def error_404(request, exception): return render(request,"MyApp/404.html") #urls.py handler404 = 'myapp.views.error_404' . .