Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to create a file-like wrapper that works just like a file but auto-delete on close/__del__?
def (): zip_fd = open(zip_path, mode="rb") file = _TemporaryFileWrapper(zip_fd) # Like the one inside tempfile.NamedTemporaryFile return FileResponse(file) # django I would like my file deleted when eventually django is done responsing it -
Database design for hotel rates
I'm designing a lodging management system for a client. Based on this answer I have organized rates on a per-day basis (Django model example): Rate( price=models.DecimalField(...), date=models.DateField(), room_type=models.ForeignKey(RoomType,...), min_nights = models.PositiveIntegerField() ) class Meta: unique_together = ('date', 'room_type') Using this format, the querying speed is acceptable, and implementing a 1-to-1 relationship on rates to dates makes the various calculations quite simple. Here's a screenshot of what a Django rates table might look like: The one stumbling block I've run into is when I attempt to enforce minimum nights. Consider the following: For two consecutive dates, the minimum nights requirement is 2 (e.g. weekend rates: Friday, Saturday). Starting on the next consecutive date (which would be Sunday in this example), the minimum nights requirement is 1 night. Given the above, when a user tries to create a reservation starting on Saturday, the minimum required nights for that rate will be 2. So booking Saturday/Sunday would work, but I want that to be disallowed due to the 2 night minimum starting on Friday. One option I considered was setting minimum nights to 0 when a rate's minimum nights was dependent on the prior day's rate (or maybe several days back if the … -
Django - If user is a certain value display element
I’m currently building a gaming app where a currently logged in user has access to play different games based on their rank in our application. So if a currently logged in user has a rank of let’s say 100 than all the games rank 100 and below will be displayed. The rest of the games will be locked. What would be the best way to achieve this? How can i display unlocked games based on the logged in user’s rank? The rank of each game is the game_rank field in the Game_Info model. The rank of the currently logged in user is the rank field in the User_Info model. My current HTML shows which games are locked and unlocked. Code is below. Any help is gladly appreciated. Thanks! models.py class Game_Info(models.Model): id = models.IntegerField(primary_key=True, unique=True, blank=True, editable=False) game_title = models.CharField(max_length=100, null=True) game_rank = models.CharField(max_length=1000, null=True, blank=True) game_image = models.ImageField(default='default.png', upload_to='game_covers', null=True, blank=True) locked_game = models.BooleanField(default=0) unlocked_game = models.BooleanField(default=0) class User_Info(models.Model): id = models.IntegerField(primary_key=True, blank=True) image = models.ImageField(default='/profile_pics/default.png', upload_to='profile_pics', null=True, blank=True) user = models.OneToOneField(settings.AUTH_USER_MODEL,blank=True, null=True, on_delete=models.CASCADE) rank = models.CharField(max_length=100, null=True, blank=True, default=1) user_games_enabled = models.ManyToManyField(Game_Info, blank=True, limit_choices_to={'unlocked_game': True}) home.html {% for content in user_profile_games %} {% if content.locked_game == True %} … -
Django not installing inside virtual environment
I am starting a project from scratch, and I noticed that when I run 'pip install django' on my main folder, it says 'requirement already satisfied'. However, when I try to run the 'python manage.py startproject ' it says 'Import error: Couldn´t import Django'. How do I solve this? It worked on another project I started 2 weeks ago, now is not working. When I check the env/lib/site-packages, there is nothing about django there actually. -
Django movable blocks layout
I wanted to know if anyone has ever done this before and if its even possible to do using django. I have a layout of information with 3 blocks of data, but i wanted to give the user the option to move the blocks around in the way that the user see how they would like the data displayed. Maybe user A would like the first 2 blocks to be on top and the last one to be on the bottom User B would like the bottom block to be on top and the other 2 to be on the bottom I can't really find any documentation on how to do something like that, does any one have any information to accomplish that? -
Invalid HTTP_HOST header: '172.12.2.90'. You may need to add '172.12.2.90'' to ALLOWED_HOSTS
When I deploy my django project to elasticbeanstalk I get the message in the log: "Invalid HTTP_HOST header: '172.12.2.90'. You may need to add '172.12.2.90'' to ALLOWED_HOSTS." and so on... I have to add 3 ip adresses like the one above in total for the health to be ok and no error/warning messages. Why is this the case? Where are these domains/IP addresses coming from? Is there any more convenient way to fix this so that I don't have to add random IP adresses to the array ALLOWED_HOSTS = ["mydomain.com"] in settings.py? I created a file and directories in .ebextensions/nginx/conf.d/myconf.conf. This was because according to https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-nginx.html, it says "To extend Elastic Beanstalk's default nginx configuration, add .conf configuration files to a folder named .ebextensions/nginx/conf.d/". myconf.conf: if ( $host !~* ^("mydomain.com"|"www.mydomain.com")$ ) { return 444; } This didn't work it still gives the same message as before. The way I interpret it is that my django project is on an AWS physical server somewhere and nginx is a middleman between that and my browser. My understanding of Django and AWS is quite basic so I would appreciate it if the answer was as simple as possible. Thanks in advance! -
Django with Postgres: Bulk insert objects ignoring conflicts, then bulk insert related objects
I have two models: Template and TemplateVersion. I want to bulk insert templates and versions so that if the template already exists, it stays as is, but only new version of this template is created. All fields of Template is guaranteed to be together unique. I know that Django can return pks of bulk created instances when using postgres, so I tried that: created_templates = Template.objects.bulk_create(templates_to_create, ignore_conflicts=True) # ... here goes the code to create version objects with pks from `created_templates` TemplateVersion.objects.bulk_create(versions_to_create) Surpisingly, returning pk's don't work together with ignore_conflicts so I don't get pk's in created_templates. So my question is: is it possible to have N templates and M versions created in less queries than N+1 (using loop to manually get_or_create templates and get their pk's) using Django ORM? -
Change <td> color based on number of days left to today [closed]
Below is my table and the data is from database. I am trying to change the td {{ server.daysleft }} /td to a different color based on number of days left to today. For example, the server warranty expiry date is May 16, 2024 and want it automatically change td color when the days less than 100 days. <table class=""> <tr> <th>Name</th> <th>Warranty</th> <th>Days Left</th> </tr> {% for server in server_list %} <tr> <td>{{ server.server_name }}</td> <td>{{ server.server_warrantyexpirydate }}</td> <td>{{ server.daysleft }}</td> </tr> {% endfor %} </table> I just started learning web development and need help. -
How can I correct this error in the project
The project is running but it's showing this error message as well I was not expecting an error message after installing all the directories. Please if there is anyone who can help me I will be greatful. I have tried to correct it for more than a week now but it's still the same error running on my terminal. -
In Django, in Version: 4.1, how to use a css by taking it from the static folder?
There are similar old questions, but they did not solve the problem. Reading the various answers, my code seems ok. In the Version: 4.1.11 of Django, how can i browse the static files folder? Having a path App1/static/css/style.css, i would like to use use in index.html: <link rel="stylesheet" type="text/css" href ="{% static 'css/style.css' %}"> The css file is not found. I'm using {% load static %} at the beginning of index.html and then in settings.py i'm using: BASE_DIR = Path(__file__).resolve().parent.parent STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') I tried too: STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),) In Installed_Apps, among other things, there is also 'django.contrib.staticfiles' What am I doing wrong? -
How do I not use the web part of Django?
I don't need the web part (for now), the objective is to make an ORM, django has to be a kafka consumer to receive and send to the postregres database I read the docs, but I didn't understand how not to use the web part struct: code (kafka_consumer.py): import pickle from django.shortcuts import render from kafka import KafkaConsumer import environ env = environ.Env() environ.Env.read_env() # def process_message(message: str) -> None: # print(f"message -- {message}") # class KafkaService: # @staticmethod # def kafka_consumer(): # consumer = KafkaConsumer(env("KAFKA_TOPIC"), bootstrap_servers=env("KAFKA_URI"), group_id="test") # for message in consumer: # process_message(message) # Create your views here. def cons(): consumer = KafkaConsumer(env("KAFKA_TOPIC", bootstrap_servers=[env("KAFKA_URI")], api_version=(0,10)) for message in consumer: deserialized_data = pickle.loads(message.value) print(deserialized_data) cons() code settings.py: import environ env = environ.Env() environ.Env.read_env() DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': env("DB_NAME"), 'USER': env("DB_USER"), 'PASSWORD': env("DB_PASSWORD"), 'HOST': env("DB_HOST"), 'PORT': env("DB_PORT"), } } I don't know if it's structured correctly, just follow the official doc: https://docs.djangoproject.com/en/5.0/intro/tutorial01/ -
Cloned rows using jQuery not submitting to post method
I need some help with javascript code im using for my django project. for context, I'm trying to implement a button that adds new rows of inputs. The button does work (currently using jQuery to clone the previous row), but I can't get new rows to submit to the backend via the post method. javascript code: function addRow_editProduct(currentRowCount, productPK) { var rowCounter = currentRowCount + 1; var container = document.getElementById(productPK + '_productMaterialContainer'); var templateRow = $('#' + productPK + '_productMaterial_row' + currentRowCount); var newRow = templateRow.clone(); newRow.attr('id', productPK + '_productMaterial_row' + rowCounter); newRow.find('[id^="' + productPK + '_product_material"]').attr('id', productPK + '_product_material' + rowCounter).attr('name', productPK + '_product_material' + rowCounter); newRow.find('[id^="quantity"]').attr('id', 'quantity' + rowCounter).attr('name', 'quantity' + rowCounter); newRow.find('[id^="unit"]').attr('id', 'unit' + rowCounter).attr('name', 'unit' + rowCounter); newRow.find('[id^="' + productPK + '_productMaterial_pk"]').val(''); newRow.find('select').val('delete'); newRow.find('input[name^="quantity"]').val(''); newRow.find('input[name^="unit"]').val(''); newRow.find('.delete-productMaterial').attr('data-select-element-id', productPK + '_product_material' + rowCounter); $(container).append(newRow); console.log('document', $('#' + productPK + '_productMaterial_row' + rowCounter).find('[id^="' + productPK + '_product_material"]').attr('name')); // var formData = new FormData($('#test')[0]); // for (var pair of formData.entries()) { // console.log(pair[0] + ': ' + pair[1]); // } } html: <div id="{{product_data.product.pk}}_productMaterialContainer"> {% for y in product_data.materials %} <div class="row align-items-center mt-2" id="{{product_data.product.pk}}_productMaterial_row{{ forloop.counter }}"> <input type="hidden" name="{{product_data.product.pk}}_productMaterial_pk{{ forloop.counter }}" id="{{product_data.product.pk}}_productMaterial_pk{{ forloop.counter }}" value="{{ y.pk }}"> <div class="col-4"> … -
Get weakly-referenced Error in Mongoengin
I use mongoengin in django app. each document in mongo has metadata that is dict and in it there is image address with out base_url. in django serializer I add base_url to it but it sometime get error def to_representation(self, instance): # when we search by image result has similarity and it`s milvus similarity and when search by text, # we show it`s reference similarity # obj.similarity: we had image and have similarity from milvus. # obj.metadata.get('similarity') :we don`t have similarity from milvus use matched item similarity. data = super(ResultSerializer, self).to_representation(instance) if instance.similarity is not None: data['similarity'] = decimal.Decimal(distance_to_score(instance.similarity)).quantize( decimal.Decimal('0.000'), rounding=decimal.ROUND_DOWN) else: data['similarity'] = instance.metadata.get('similarity') if frame_url := instance.metadata.get('frame_url'): data.get('metadata')['frame_url'] = SHAHIN_SETTING['base_url'] + frame_url return data Error: Jan 23 16:17:10.527 | develop-shahin-develop-86df584cf6-wtrcm | paginated_data['results'] = ResultSerializer(el_result, many=True).data Jan 23 16:17:10.527 | develop-shahin-develop-86df584cf6-wtrcm | File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 745, in data Jan 23 16:17:10.527 | develop-shahin-develop-86df584cf6-wtrcm | ret = super().data Jan 23 16:17:10.527 | develop-shahin-develop-86df584cf6-wtrcm | File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 246, in data Jan 23 16:17:10.527 | develop-shahin-develop-86df584cf6-wtrcm | self._data = self.to_representation(self.instance) Jan 23 16:17:10.527 | develop-shahin-develop-86df584cf6-wtrcm | File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 663, in to_representation Jan 23 16:17:10.527 | develop-shahin-develop-86df584cf6-wtrcm | return [ Jan 23 16:17:10.527 | develop-shahin-develop-86df584cf6-wtrcm | File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 664, in … -
Cannot Access django development server in google cloud VM instance
I am building a practice django application for CI/CD. I am using GitLab for CI/CD. I containerized the django app and pushed it to dockerhub. From dockerhub I am trying to run it on Google Cloud VM instance. In the dockerfile I made 0.0.0.0:8000 as the server out link. The build and deploy in the GitLab is successful. But I cannot access the server through Browser using google cloud IP address. When I tried docker ps it shows the container running on the port. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1c49ac3654d2 repo_name/image_name:V1 "python manage.py ru…" 11 minutes ago Up 11 minutes 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp laughing_hodgkin But if I go to aa.bb.cc.dd:8000 google cloud VM instance IP its not there. It just say **cannot reach this page** My Dockerfile looks like this, FROM python:3.9.18-slim-bullseye WORKDIR /usr/src/app COPY requirements.txt . RUN pip install --upgrade pip RUN curl https://sh.rustup.rs -sSf | sh RUN pip install --no-cache-dir -r requirements.txt COPY . . EXPOSE 8000 CMD python manage.py makemigrations CMD python manage.py migrate CMD python manage.py runserver aa.bb.cc.dd:8000 .gitlab-ci.yml file is, stages: - build - deploy build: stage: build image: docker:25.0.0-cli services: - docker:25.0.0-dind variables: DOCKER_TLS_CERTDIR: "/certs" before_script: - docker login -u $DOC_USER_NAME -p … -
Django Rest deployement on CPanel
I am working on django rest project and it's admin side is working fine and properly loading with their static files on local sever. I tried to deploy my project on CPanel where i setup my python setup application successfully but when i load django admin side with live url link it only shows textfields without classes applied. enter image description here Live django endpoint from where django admin tries to load static files is like (https://example.com/api/static/admin/css/base.css) whereas "api" is the Application url of my python app that i setup on CPanel. I also ran "python manage.py collectstatic" command but still server is not able to locate the files. I tried with all above solutions that i mentioned -
Django website trouble accessing models to make queries to the database
I am creating a dietary tracker website which will use Django, python, sql etc. When I try to access the models to make queries to the database, it gives a long error. I am running the test file in my vs code terminal and am using a macbook pro. /opt/anaconda3 /bin/python /Desktop/nea_project/dietary_app/tests.py Traceback (most recent call last): File "/Desktop/nea_project/dietary_app/tests.py", line 1, in \<module\> from models import Food_Table File "/Desktop/nea_project/dietary_app/models.py", line 4, in \<module\> class Participant(models.Model): File "/opt/anaconda3/lib/python3.9/site-packages/django/db/models/base.py", line 129, in **new** app_config = apps.get_containing_app_config(module) File "/opt/anaconda3/lib/python3.9/site-packages/django/apps/registry.py", line 260, in get_containing_app_config self.check_apps_ready() File "/opt/anaconda3/lib/python3.9/site-packages/django/apps/registry.py", line 137, in check_apps_ready settings.INSTALLED_APPS File "/opt/anaconda3/lib/python3.9/site-packages/django/conf/**init**.py", line 102, in **getattr** self.\_setup(name) File "/opt/anaconda3/lib/python3.9/site-packages/django/conf/**init**.py", line 82, in \_setup raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. Example program I used to make the queries: from models import Food_Table food_names = Food_Table.objects.all('food_name', flat=True) print(food_names) The model I am trying to pull data from: class Food_Table(models.Model): food_ID = models.AutoField(primary_key = True) food_name = models.CharField(max_length = 40) food_description = models.CharField(max_length = 1000) -
How to change the date format in the model history section in the Django admin panel from Gregorian to Jalali?
I changed the date and time of the admin panel using the Jalali-date package, and now if I go to the special page for each model in the admin panel It shows the date of manufacture in Jalali format. But if I go to the history section of that model, I see that the dates are displayed normally in the Django system. Note: Jalali Library transforms the world standard history into the conventional history in Islamic countries the package i have used: text my models: from django.db import models from django.contrib.auth.models import User from django_jalali.db import models as jmodels class Thought(models.Model): title = models.CharField(max_length=150, verbose_name = 'عنوان تسک') content = models.CharField(max_length=400, verbose_name = 'متن') date_posted = jmodels.jDateTimeField(auto_now_add=True, verbose_name='تاریخ') user = models.ForeignKey(User, max_length=10, on_delete=models.CASCADE, null=True, verbose_name = 'کاربر') class Meta: verbose_name = 'تسک' verbose_name_plural = 'تسک ها' def __str__(self): return self.title class Profile(models.Model): profile_pic = models.ImageField(null=True, blank=True, default='Default.png', verbose_name = 'عکس پروفایل') user = models.ForeignKey(User, max_length=10, on_delete=models.CASCADE, verbose_name = 'کاربر') class Meta: verbose_name = 'پروفایل' verbose_name_plural = 'پروفایل ها' def __str__(self): return self.user.username my admin file: from django.contrib import admin from .models import Thought, Profile from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from jalali_date import datetime2jalali from jalali_date.admin import ModelAdminJalaliMixin … -
plain text instead of HTML element in Django
I have a model like this: class FirstOne(models.Model): title = models.CharField(max_length=250) pretext = models.TextField(null=True, blank=True, default=None) first = models.PositiveIntegerField() last = models.PositiveIntegerField() and then another model is like this: class SecondOne(models.Model): def first_one_pretext(self): pk = self.firstone.pk a = FirstOne.objects.filter(pk=pk).get() return a.pretext And when I do this, I always get a "html element" and not the plain text stored in pretext of the object. How do I get rid of this? -
Embedding a document into chromadb using langchain
Im trying to embed a pdf document into a chromadb vector database using langchain in django. I want to do this using a PersistentClient but i'm experiencing that Chroma doesn't seem to save my documents. from rest_framework.response import Response from rest_framework import viewsets from langchain.chat_models import ChatOpenAI import chromadb from ..functions.load_new_pdf import load_new_pdf from ..functions.store_docs_vector import store_embeds import sys from ..models import Documents from .BaseView import get_user, strip_user_email from ..functions.llm import chosen_llm from langchain_community.vectorstores import Chroma from langchain.embeddings.openai import OpenAIEmbeddings from dotenv import load_dotenv import sys import os load_dotenv() OPENAI_API_KEY = os.getenv('OPENAI_API_KEY') embedding = OpenAIEmbeddings() llm = chosen_llm() def uploadDocument(self, request): user = get_user(request) base64_data = request.data.get('file') # Create a record of the document in the SQLite database. document = Documents.objects.create(name=request.data.get( "name"), user=user, content=base64_data) document.save() # Convert the pdf into a big string. cleaned_text, documents = load_new_pdf(document) # Initiliaze the persistent client. client = chromadb.PersistentClient(path="../chroma") # Strip the user email from the '@' and '.' characters and get or create a new collection for it collection_name = strip_user_email(user.email) client.get_or_create_collection(collection_name) # Embed the documents into the database Chroma.from_documents( documents=documents, embedding=embedding, client=client) # Retrieve the collection from the database chroma_db = Chroma(collection_name=collection_name, embedding_function=embedding, client=client) print(chroma_db.get()["documents"], file=sys.stderr) # This is now [], why?? … -
Celery error received unregistered task of type, some of the nodes didn't update
I have a Django app on dokku with celery tasks. After updating the code, I sometimes encounter the "error received unregistered task of type X" for certain tasks. Previously, everything was working fine. When I run celery -A my_app inspect registered I get: -> celery@4ae2d1ac0e16: OK * campaigns.tasks.task1 * campaigns.tasks.task2_new * my_app.celery.debug_task * my_app.celery.fail_task -> celery@46d837d1ffd2: OK * campaigns.tasks.task1 * campaigns.tasks.task2 * my_app.celery.debug_task * my_app.celery.fail_task -> celery@dad78368f410: OK * campaigns.tasks.task1 * campaigns.tasks.task2_new * my_app.celery.debug_task * my_app.celery.fail_task 3 nodes online. One node (1/3) doesn't have the task2_new, and instead, it has the old version of the task task2 So when I call the task task2_new sometimes I get the error "Received unregistered task of type 'my_app.tasks.task2_new'" The problem is consistent, so I guess it is because some of the nodes are up to date and one isn't updated. How can I ensure that all celery nodes are updated whenever I upload a new version? I checked a lot of questions, but couldn't find anything that helped me. KeyError Received unregistered task of type '' on celery while task is registered Python Celery Received unregistered task of type - import app error Celery Received unregistered task of type (run example) Thanks! -
Customize the form used by Staff user to change password
In my project I need to set some certain fields to ltr direction because the whole project is in rtl direction so this is what I do: admin.py class CustomUserCreationForm(UserCreationForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['email'].widget.attrs.update({'dir': 'ltr'}) self.fields['password1'].widget.attrs.update({'dir': 'ltr'}) self.fields['password2'].widget.attrs.update({'dir': 'ltr'}) class CustomUserChangeForm(UserChangeForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['email'].widget.attrs.update({'dir': 'ltr'}) class CustomAdminPasswordChangeForm(AdminPasswordChangeForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['password1'].widget.attrs.update({'dir': 'ltr'}) self.fields['password2'].widget.attrs.update({'dir': 'ltr'}) class CustomPasswordChangeForm(PasswordChangeForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['old_password'].widget.attrs.update({'dir': 'ltr'}) self.fields['new_password1'].widget.attrs.update({'dir': 'ltr'}) self.fields['new_password2'].widget.attrs.update({'dir': 'ltr'}) And then: class UserAdmin(UserAdmin): add_form = CustomUserCreationForm form = CustomUserChangeForm change_password_form = CustomAdminPasswordChangeForm The above 3 forms work as expected, however the CustomAdminPasswordChangeForm is for when the Superuser is changing the password. This form does not ask for Old Password. But when a Staff logs into Admin site, another form is used to change the password which asks for Old Password too. I have customized that form too (CustomPasswordChangeForm above) but I can't find how to set it in my UserAdmin class? -
Duplicate request with HTMX on the submit button of the form
with this code: <button class="button is-success" type="submit" hx-get="{% url 'refresh_navbar' %}" hx-target="#header" hx-trigger="submit" >Login</button> the post is executed (submited) (the post is done by the hx-post of the form actually) and this code without the hx-trigger: <button class="button is-success" type="submit" hx-get="{% url 'refresh_navbar' %}" hx-target="#header" >Login</button> executes the get request when i click in the button (but actually i want the get after the submission) and dosent execute the submission. How can i execute both requests after the form submission event. I can't put the get in the form, because it already has another target. <form class="form" name="form" hx-post = {{request.path}} hx-trigger="submit" hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}' hx-target="#login-modal" > Thank you guys the full form is this, it's a modal. and the #header is in another template <form class="form" name="form" hx-post = {{request.path}} hx-trigger="submit" hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}' hx-target="#login-modal" > {% csrf_token %} <div class="field"> <label class="label">Email</label> <div class="control"> {% render_field form.email class="input is-link" placeholder="user@example.com" name="email"%} {% if form.email.errors %} <p class="help is-danger">{{ form.email.errors|first }}</p> {% endif %} </div> </div> <div class="field"> <label class="label">Senha</label> <div class="control"> {% render_field form.password class="input is-link" placeholder="*********" name="password" %} {% if form.password.errors %} <p class="help is-danger">{{ form.password.errors|first }}</p> {% endif %} </div> </div> <div class="field"> <div class="control"> <button … -
AWS Elastic Beanstalk Django Project Health Check Fails
I have deployed a Django application to Elastic Beanstalk, in single instance type there is no problem and the health check is green, but when I choose the Load Balanced type and add HTTPs listener with a valid certificate from Amazon Certificate Manager,the health became Severe and also when I click on view causes it show me this (Process default has been unhealthy for 15 hours (Target.FailedHealthChecks)), I can access the website with the HTTPs and also HTTP, there is no problem, all settings are correct, I have the security group with inbound and outbound rules, but the health became severe. -
How to avoid LOGENTRIES_TOKEN spam logs in django?
When i run the python manage.py <somecmd>, i'm getting the below error: It appears the LOGENTRIES_TOKEN parameter you entered is incorrect! How can i disable this log, this log spamming across the access log. I've tried to control it using log_level as of now, but it's not working. -
Modify django action style
This's default action style. How shoul change it style to button, like this: I know it default rendering to <select>, but i wanted to rendering to each <button>. I tried custom ModelAdmin def get_action_choices but not succcess What should i do now?