Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to generate multiple 'datetimes' within the same day using 'Faker' library in Django?
I need to generate dummy data for two datetime fields. Currently I'm using Faker library to achieve this: date1= factory.Faker('date_time_this_month') date2= factory.Faker('date_time_this_month') This generates dummy data of 'datetime' type but I want the date to be same in both the fields and the time of date2 must be greater than the date1. Simply put, I need to generate two 'datetime' type data within same day where date1 < date2. -
How to add custom user fields of dj_rest_auth package
Here is the post to add first_name, last_name to the registration view. I want to add some other custom user field beside first_name or last_name. As these field already exist in the user model, He didn't have to edit the user model. But for my case what to do to edit the user model provided by the dj_rest_auth and add some new models? -
Why Django form choice field don't showing initial value from model as selected
Cant get model value to be represented as selected in form choice field. In template I have edit option for my object, and I want to populate all current object values in form fields, but chose fields always will show model default values. Any knowledge how to fix this thought django functionality? So what I have now: my model: class ClientPriceSelection(models.Model): A_B_choice = ( (50.00, 50.00), (25.00, 25.00) ) ... p_four = models.DecimalField(choices=A_B_choice, max_digits=6, decimal_places=2, default=50.00, verbose_name="...", help_text="(---)") my view: addon = get_object_or_404(ClientPriceSelection, id=addon_id) # print(addon.p_four) form = ClientPriceListSelectionForm(request.POST or None, initial={ 'p_one': addon.p_one, 'p_two': addon.p_two, 'p_three': addon.p_three, 'p_four': addon.p_four, 'p_five': addon.p_five, 'p_seven': addon.p_seven, 'p_eight': addon.p_eight, 'p_nine': addon.p_nine, 'p_ten': addon.p_ten, 'p_eleven': addon.p_eleven, 'internal_notes': addon.internal_notes}) context = {"form": form, 'client': get_object_or_404(Client, id=addon.agreement.client.id)} my form: class ClientPriceListSelectionForm(forms.ModelForm): class Meta: model = ClientPriceSelection fields = ['p_one', 'p_two', 'p_three', 'p_four', 'p_five', 'p_seven', 'p_eight', 'p_nine', 'p_ten', 'p_eleven', 'internal_notes'] widgets = { 'internal_notes': forms.Textarea( attrs={'class': 'vLargeTextField', 'cols': '40', 'rows': '10', 'maxlength': '500'}), } -
Django sorting queryset with nested querysets in python
I have a queryset (Group) with a nested queryset (Memberships) with a nested queryset (Credits). This is the output: group = [ { "name": "Group2", "memberships": [ { "username": "test1", "credits": [ { "credits": 1000, "year": 2020, "week": 42, "game_count": 1, "last_game_credits": 10, } ], }, { "username": "test2", "credits": [ { "credits": 1500, "year": 2020, "week": 42, "game_count": 1, "last_game_credits": 0, } ], }, { "username": "test", "credits": [ { "credits": 1000, "year": 2020, "week": 42, "game_count": 1, "last_game_credits": 0, } ], } ] } ] I want to rank the member in Memberships the following way: credits (amount) game_count (amount) last_game_credits (amount) Hence, if two players have an equal amount of credits the one with the highest game_count wins. If that is the same the one with the highest last_game_credits wins. I want the same structure to be returned. Models: class Group(models.Model): name = models.CharField(max_length=128, unique=True) members = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name="memberships", through='Membership') class Membership(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="membership", on_delete=models.CASCADE) group = models.ForeignKey(Group, on_delete=models.CASCADE) class Credits(models.Model): credits = models.IntegerField() year = models.IntegerField(default=date.today().isocalendar()[0]) week = models.IntegerField(default=date.today().isocalendar()[1]) user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="credits", on_delete=models.CASCADE) game_count = models.IntegerField(default=0) last_game_credits = models.IntegerField(null=True) class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(max_length=255, unique=True) username = NameField(max_length=25, unique=True, View: class GroupSet(generics.ListAPIView): … -
I'm Getting an ApiError while using dropbox as a django storage
I'm using dropbox as a django storage to serve media files and while uploading to dropbox all working fine the files are uploading to the root directory as expected but the uploaded image won't render on the templates, The error that showing ApiError at /index ApiError('304328f4c8384ce99352fc8e9c338f71', GetTemporaryLinkError('path', LookupError('not_found', None))) Request Method: GET Request URL: http://127.0.0.1:8000/index Django Version: 3.1.2 Exception Type: ApiError Exception Value: ApiError('304328f4c8384ce99352fc8e9c338f71', GetTemporaryLinkError('path', LookupError('not_found', None))) Exception Location: /home/raam124/.local/share/virtualenvs/rattota-GtEiaCOf/lib/python3.8/site-packages/dropbox/dropbox.py, line 337, in request Python Executable: /home/raam124/.local/share/virtualenvs/rattota-GtEiaCOf/bin/python Python Version: 3.8.5 Python Path: ['/home/raam124/Documents/rattota', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/raam124/.local/share/virtualenvs/rattota-GtEiaCOf/lib/python3.8/site-packages'] Server time: Fri, 23 Oct 2020 10:02:16 +0000 my static and media files setting os.path.join(BASE_DIR, "static"), os.path.join(BASE_DIR, "media"), ] STATIC_URL = '/static/' MEDIA_URL = '/' STATIC_ROOT = os.path.join(BASE_DIR, 'static_cdn') MEDIA_ROOT = os.path.join(BASE_DIR, 'media_cdn') my dropbox storage settings DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage' DROPBOX_OAUTH2_TOKEN = 'token here' DROPBOX_ROOT_PATH = '/' and I'm rendering the image using <img alt="" class="card-img img-fluid geeks" src="{{topstory.image.url}}" /> -
STATIC FILES (CSS NOT FOUND) WITH DJANGO
I'm using Django to build a dashboard. The structure of my project is the one below : │ db.sqlite3 │ manage.py │ ├───dashboard │ asgi.py │ settings.py │ urls.py │ wsgi.py │ __init__.py │ │ │ ├───projects │ admin.py │ apps.py │ models.py │ tests.py │ views.py │ __init__.py │ │ ├───static │ ├───css │ │ main.css │ │ sb-admin.css │ │ sb-admin.min.css │ │ │ ├───js │ │ │ │ │ ├───media │ │ │ ├───scss │ │ │ └───vendor │ ├───upload_log │ │ admin.py │ │ apps.py │ │ forms.py │ │ models.py │ │ tests.py │ │ urls.py │ │ views.py │ └───__init__.py │ └───templates about.html base.html basedraft.html home.html index.html navigationbar.html upload_log.html ` My settings are as below : STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static_cdn') #add MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static/media/') #static/ add STATIC_DIRS = [ os.path.join(BASE_DIR, "static"), ] My problem is whenever I try to had css into my template I get the error "http://localhost:8000/static/css/main.css net::ERR_ABORTED 404 (Not Found)". Is there something I didn't understand using static files ? I've through documentation and questions on stackoverflow but I've not been able to fixe the problem. However, my upload_log application actually finds it's way … -
DJANGO gte, lte not showing any results
My Problem: i wan't to check for upcoming events. I saw some posts about gte, lte etc. But if create a model query its not showing any results. My code: @login_required def aufträge(request): aufträge = Aufträge.objects.filter(start_date__gt=datetime.now()) context = {"aufträge":aufträge} return render(request, "aufträge/aufträge.html") my model: class Aufträge(models.Model): creator = models.IntegerField() vehicle = models.ForeignKey(Cars, on_delete=models.CASCADE) customer = models.IntegerField() title = models.CharField(max_length=30) desc = models.TextField(blank=True) start_date = models.DateTimeField() created_on = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title any solutions? -
How to change date formet using Python?
I want to change date formet using Python. i Dont know How to do that. i have date formet shown as below 2020-10-22 12:14:41.293000+00:00 I want to change above date formet into below formet date(2020, 10, 22) i want this formet beacause i want to get different between two dates. with above formet i can get diference by using following code, d0 = date(2017, 8, 18) d1 = date(2017, 10, 26) delta = d1 - d0 print(delta.days) So how to Change date formet as i discussed above.or else if you any other method to find difference between these two dates 2020-10-22 12:14:41.293000+00:00 and 2020-10-25 12:14:41.293000+00:00 without changing formet.let me know that also.I will be thankfull if anyone can help me with this issue. -
Deploying django in repl.it shows 400 error
I get a 400 error when i try to host django in repl.it.I tried googling everything but couldn't find an answer. Please solve it. Thanks -
Make certain fields non mandatory when using a model form in inline formsets Django
I have a Parent Model RouteCard to which I want to add related child line items ProcessOperation(s). For this I am using inline formsets. I have a separate Modelform for the creation of ProcessOperation. I want to be able to create a ProcessOperation with or without certain fields present. ex, stage_drawing and setup_sheet. Therefore I have specified in the __init__ function of the model form that these fields are not required. But when I try to create the ProcessOperation using inline formset, it always gives a validation error that these two fields are required. I am using Django 2.0. Code: Model: class RouteCard(models.Model): routeCardNumber = models.AutoField(primary_key=True) customer = models.ForeignKey(Customer, related_name='process_route_cards', on_delete='PROTECT', null= True, default= None) purchaseOrder = models.ForeignKey(PurchaseOrder, related_name='process_route_cards', on_delete='PROTECT', null= True, default= None) initial_item = models.ForeignKey(Item, related_name='route_card_raw_material', on_delete='PROTECT', null= True, default= None) initial_rawmaterial = models.ForeignKey(Material, related_name='route_card_raw_material', on_delete='PROTECT', null=True, default=None) final_item = models.ForeignKey(Item, related_name='route_card_finished_material', on_delete='PROTECT', null= True, default= None) planned_quantity =models.PositiveIntegerField(default=0) inprocess_quantity = models.PositiveIntegerField(default=0) completed_quantity= models.PositiveIntegerField(default=0) rejected_quantity=models.PositiveIntegerField(default=0) created_by = models.ForeignKey(User, related_name='process_route_cards', on_delete='PROTECT') create_date = models.DateField(null=True) final_inspection_report = models.FileField(upload_to=get_file_save_path_rc, null=True, default=None, max_length=500) uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True) class ProcessOperation(models.Model): OPERATION_STATUS_CHOICES = ( (1, 'CREATED'), (2, 'ASSIGNED'), (3, 'STARTED'), (4, 'COMPLETED'), (5, 'ON_HOLD'), (6, 'CANCELLED'), (7, 'PARTIALLY_COMPLETED'), (0, 'WITHDRAWN'), ) routeCard=models.ForeignKey(RouteCard, related_name='process_operations', … -
How to create Client Assertion JWT token when connecting to Azure AD?
My issue is that I'm not sure what to use to sign the JWT token to make Client assertion when sending back authorized code to the Azure AD to get access token. The supported auth method is "private_key_jwt". -
Django Group objects by foreign Key field value
class Publisher(models.Model): name = CICharField("Name", max_length=200, unique=True) description = models.TextField("Description", blank=True) class Category(models.Model): name = CICharField("Name", max_length=200, unique=True) description = models.TextField("Description", blank=True) class Book(models.Model): name = CICharField("Name", max_length=200, unique=True) description = models.TextField("Description", blank=True) category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name="books", blank=True, null=True) publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE, related_name="books", blank=True, null=True) I want to get all Books objects filter by publisher and group by Category. For eg. books = Books.objects.all().filter(publisher=1).group_by('category') Output be like, [ { category 1: [book1, book2, ...] }, { category 2: [book3, book4,... ] }, ] Can anyone tell me, How can I achieve that? Thank you. -
Django settings: auto detect ROOT_URLCONF value
I'm working on splitting my settings.py into generic and project-specific configurations, and I was wondering if there was a "Django" way to get the root url configuration for the "app", that is to say, can Django auto-detect the app name such that I can do something such as the following: from django.apps import apps ROOT_APP = apps.get_root_app() ROOT_URLCONF = f'{ROOT_APP}.urls' Or should I just settle for an environment variable approach: ROOT_APP = os.environ.get('DJANGO_ROOT_APP') ROOT_URLCONF = f'{ROOT_APP}.urls' -
Django's Custom Authentication Middleware & Authentication Backend
I'm writing a custom Authentication middleware that check the incoming requests for the "Authorization" key in the header, which contains a token. I'm using this token to check with a third-party (Microsoft Graph) for the validity of the user. MS Graph will respond with an object like below # the response object { '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#users/$entity', 'businessPhones': ['xxx'], 'displayName': 'xxx', 'givenName': 'xxx', 'id': 'xxx', 'jobTitle': None, 'mail': 'xxx', 'mobilePhone': None, 'officeLocation': None, 'preferredLanguage': 'xxx', 'surname': 'xxx', 'userPrincipalName': 'xxx' } I then append this object to the request: request.custom_user = response.json() Now I want to design this to work just like Django's default authentication backend with proper group and permission. How can I work on a LazyObject to be able to check for user's group membership and permission? -
I'm trying to load map in div using same class in each row but unable to do that
We are rendering the data from django in html page. Then using the GET text function to get MAP Address and placed to the address option for marker(For reference Pls check the below Jquery). If i have 10 records in single page. In 1st record able to add the marker after that i coudn't do that. Can anyone help me out kindly find the attachements for reference. $(document).on('click','.google-map', function(){ var get_text = $(this).closest('.col').find('.map-address').text(); var split_text = $.trim(get_text); $(".map").googleMap({}); $(".map").addMarker({ address: split_text, // Postale Address title: split_text, }); }); {% for result in current_page %} {% ifchanged result.provider_npi and result.tax_id %} <div class="panel panel-default" id="panel{{result.id}}"> <div class="panel-heading" > <div class="panel-title"> <div class="col"> <div class="provider-addr-column border-right"> <div class="wow fadeInUp contact-info" data-wow-delay="0.4s"> <div class="section-title"> <p class="map-address"><i class="fa fa-map-marker"></i> {{result.address|title}} <span class="break"> {{result.city|title}}, {{result.state|upper}}, {{result.zip_code}}</span></p> <p class="morelocations"> <a data-toggle="modal" data-target="#map-details" data-url = "{% url 'prsearch:more_location' result.id %}" id= "mul_loc" class=" center-block more-locations">More Locations</a></p> </div> </div> </div> <div class="view-details"> <a href="#collapse{{result.id}}" data-toggle="collapse" href="#collapse{{result.id}}" aria-expanded="true" aria-controls="collapse{{result.id}}"> <button type="button" class="btn btn-outline-secondary rounded-0 mb-1 google-map slide-toggle">View Details</button> </a> </div> </div> </div> </div> <div id="collapse{{result.id}}" class="panel-collapse collapse " data-parent="#accordion"> <div class="panel-body"> <div class="view-content-details"> <div class="details-right"> <div class="col-maps" > <div class="map"></div> </div> </div> </div> </div> </div> </div> {% endifchanged %} … -
Django Rest, SessionAuthentication - CSRF token can be modfied?
I have a Vue SPA connecting to a Django Rest application, using Session Authentication (and I want to keep it that way). I use Axios, and set the instance like this: var instance = axios.create({ baseURL: API_URL, withCredentials: true, xsrfCookieName: "csrftoken", xsrfHeaderName: "X-CSRFTOKEN", }); It is all working and when I remove the csrf cookie in Developer Console, I am not allowed to do unsafe requests - perfect. It also does not work if I remove or add a character to the cookie. But, if I change the token manually to any string that has the correct length, like: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - it still works? I guess I have misunderstood something, what? -
How to show the price at the index (page home) in the form of 1.0 lac i.e 100000 as 1 lac
here is my models.py file class ProductPage(models.Model): item=models.CharField(max_length=100) price=models.IntegerField(null=True, blank=True) @property def price_tag(self): if price>=100000 or price<=9999999: price=price//100000 return self.str(price)+ 'lac' my view.py file. def product(request): object1=ProductPage.objects.all() return render(request,'item.html',{'object1':object1}) and index.html file... {% for i in object1 %} <tr> <td>{{i.id}}</td> <td>{{i.item}}</td> <td>{{i.price_tag}}</td> {% endfor%} In my admin panel price is in form of integer field i.e 100000 . I want to convert it into a form as '1 lac' at the display page . Please help me how to do? -
Cannot change the Django field from mandatory to optional input
Cannot change the Django field from mandatory to optional input I have a sign up form that requires the users to fill in their phone num. Then , now ,I want to change it from mandatory to optional .But it fails and makes it disable to submit the form .How to fix? The web is written in Django .I just want to change the field from mandatory to optional input HTML <div style="margin-bottom: 25px" class="input-group"> <span class="input-group-addon"><i class="fa fa-phone"></i></span> <input id="phone_no" type="text" class="form-control" name="phone_no" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" maxlength="8" placeholder="phoneno*"> </div> .... var form = $("#form_data")[0]; var data_item = new FormData(form); data_item.append("profile_img",document.getElementById("imgInp").files[0]) data_item.append("username",username) data_item.append("password",password) data_item.append("cnf_password",cnf_password) data_item.append("email",email) data_item.append("phone_no",phone_no) $.ajax({ method : "POST", url : "/signup/", enctype : "mutipart/form_data", processData : false, contentType : false, cache : false, data : data_item, success : function(response){ console.log(response) $("#loading").hide() if (response == "success") swal("Registration Saved Successfully", { icon: "success", button: "Ok", closeOnClickOutside: false, }).then(function() { location.href = "/signin/"; }); model.py class Signup(models.Model): phoneno=models.CharField(max_length=15,null=True,blank=True) view.py @csrf_exempt def signup(request): username=request.POST.get('username') email=request.POST.get('email') password=request.POST.get('password') phone_no=request.POST.get('phone_no') dob=request.POST.get('dob') gender=request.POST.get('gender') profile_img=request.FILES.get('profile_img') email_all=request.POST.get('email_all') phone_all=request.POST.get('phone_all') bio=request.POST.get('bio') if email_all=="false": email_all=False else: email_all=True if phone_all=="false": phone_all=False else: phone_all=True if Signup.objects.filter(username=username,).exists(): return HttpResponse("user_name_exists") elif Signup.objects.filter(email=email).exists(): return HttpResponse("email exists") else: if dob: user_obj=Signup(username=username,email=email,password=password,phoneno=phone_no,dob=dob,gender=gender,profile_image=profile_img,email_status=email_all,pwd_status=phone_all,bio=bio) user_obj.save() else: user_obj=Signup(username=username,email=email,password=password,phoneno=phone_no,gender=gender,profile_image=profile_img,email_status=email_all,pwd_status=phone_all,bio=bio) user_obj.save() … -
Django and React : Error Message " You need to enable JavaScript to run this app. " instead of Json
I'm new to React and I try to make Django Rest and react work together. I have a simple view : class StudentView(generics.ListCreateAPIView): queryset = Student.objects.all() serializer_class = StudentSerializer I try to fetch it from react with : useEffect(() =>{ fetch("http://127.0.0.1:8000/secretariat/get_student/", { method: 'GET', headers: { 'Content-Type': 'application/json', } }) .then( resp => resp.json()) .then( resp => setStudents(resp)) .catch(error => console.log(error)) }, []) When i check in browser network the response this is what i have : I dont think that i have a CORS Header problem but here my CORS settings. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'corsheaders', 'common_app', 'rest_framework', 'rest_framework.authtoken', 'allauth.account', 'rest_auth.registration', 'ldap', 'rest_auth', 'simple_history', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'simple_history.middleware.HistoryRequestMiddleware', ] CORS_ORIGIN_ALLOW_ALL = False CORS_ORIGIN_WHITELIST = ( 'http://127.0.0.1' ) CORS_ALLOW_METHODS = ( 'DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT', ) CORS_ALLOW_HEADERS = ( 'accept', 'accept-encoding', 'authorization', 'content-type', 'dnt', 'origin', 'user-agent', 'x-csrftoken', 'x-requested-with', ) I assume i'm doing something wrong but i have no clue. Thanks -
Running an App (Mayan EDMS) on Linux (Ubuntu) OS
I have an app installed on my pc. It is Django based. Its called: Mayan EDMS The link to install it on Linux is: https://docs.mayan-edms.com/chapters/deploying.html I was able to successfully install it by following their guide. But I cannot run the app. Please help. -
Showing the result of "python manage.py test" inside template
I am writing views.py function which it should return "python manage.py test" and render it to the template views.py @login_required def Test_Case(request): output = os.popen("python manage.py test").read() return render(request, 'Test-Case.html',{'output':output} ) above code return nothing but when i do @login_required def Test_Case(request): output = os.popen("dir").read() return render(request, 'Test-Case.html',{'output':output} ) it work fine , is there any idea how can i do that thanks for your help -
How to unittest uploading a file
I have a User model and a usercreation form. I wrote a unittest to test if the form validates. I also would like to validate if a profilepicture has been uploaded to the form. This is the model: class User(AbstractUser): profilepicture = ImageField(verbose_name="profielfoto", upload_to='profielpictures') This is the test: from django.contrib.auth.forms import AuthenticationForm import pytest from aegir.users.forms import UserCreationForm from aegir.users.tests.factories import UserFactory pytestmark = pytest.mark.django_db class TestUserCreationForm: def test_clean_username(self): # A user with proto_user params does not exist yet. proto_user = UserFactory.build() form = UserCreationForm( { "email": proto_user.email, "first_name": proto_user.first_name, "last_name": proto_user.last_name, "password1": proto_user._password, "password2": proto_user._password, } ) assert form.is_valid() # Creating a user. form.save() Any ideas how the test the uploading of the profilepic? Thanks in advance. -
varchar column type in cassandra cqlengine
How to define a varchar field in my django cassandra model. I have the model as follows from cassandra.cqlengine import columns from django_cassandra_engine.models import DjangoCassandraModel class ChatEvent(DjangoCassandraModel): interview_id = columns.UUID(partition_key=True) fire_time = columns.DateTime(primary_key=True, clustering_order="DESC") id = columns.UUID(primary_key=True) type = //to be varchar type data = columns.Text(required=True) created_by = columns.UUID(required=True) this documentation lists all possible data types but it does not have a varchar type https://docs.datastax.com/en/drivers/python/2.5/api/cassandra/cqlengine/columns.html#:~:text=Columns%20in%20your%20models%20map,one%20non%2Dprimary%20key%20column. -
How to scale Heroku Django Celery app with Docker
I'm trying to deploy my Django app to Heroku and i have several doubts about dynos, workers and deploy configuration. In my heroku.yml file I have 2 types of processes, one for the web and the other for celery, I would like them to both have only 1 dyno but with several workers and to be scalable if necessary. heroky.yml: build: docker: web: Dockerfile-django celery: Dockerfile-django run: web: gunicorn project.wsgi --log-file - celery: celery -A project worker -B --loglevel=INFO Dockerfile-django: FROM python:3.7-alpine ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 RUN apk update && apk add --no-cache bash postgresql postgresql-dev gcc python3-dev musl-dev jpeg-dev zlib-dev libjpeg RUN mkdir /dilains COPY ./project /dilains/ COPY ./requirements.txt /dilains/ WORKDIR /dilains RUN pip install -r requirements.txt EXPOSE 8000 I tried scale with this commands to scale each process type with 4 workers: $ heroku ps -a app_name === celery (Standard-1X): /bin/sh -c celery\ -A\ project\ worker\ -B\ --loglevel\=INFO (1) celery.1: up 2020/10/23 08:05:31 +0200 (~ 41m ago) === web (Standard-1X): /bin/sh -c gunicorn\ project.wsgi\ --log-file\ - (1) web.1: up 2020/10/23 08:05:40 +0200 (~ 41m ago) $ heroku ps:scale web=1 worker=4 -a app_name $ heroku ps:scale celery=1 worker=4 -a app_name I'm paying Stardar-1X and tells: number of … -
Django messages not rendering properly
I am making a project in Django and want to render a styled message if a user fails to input their username/password correctly. The message does render, but it doesn't render using the CSS provided for it: ul.messages li.error{ border: 1px solid; margin: 10px auto; padding: 15px 10px 15px 50px; background-repeat: no-repeat; background-position: 10px center; max-width: 460px; color: #D8000C; background-color: #FFBABA; } I'm pretty sure doing ul.messages is overkill, but it's just something I tried. I've also tried .messages .error, .error, etc... The relevant template code: {% if messages %} <ul class="messages"> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> {% endfor %} </ul> {% endif %} Again, the message renders, just not with the relevant CSS. The message call looks like this: messages.error(request, "Login failed due to incorrect username/password")