Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django CKEditor not working on Production
I am implementing the CKEditor on my website and it's working absolutely fine on development, but as soon as I try to update it on production,the Editor is not working at all. Any idea as to why this is happening? P.S-> I have tried collectstatic I am using nginx and aws s3 in production. -
Why isn't call_command( ... stdout=f ) intercepting stdout? At my wits end
Help! I am unable to get testing for my management command to work. The command works fine when tested manually: $ ./manage.py import_stock stock/tests/header_only.csv Descriptions: 0 found, 0 not found, 0 not unique StockLines: 0 found, 0 not found, 0 not unique but not in a test. It's outputting to stdout despite call_command specifying stdout=f (f is a StringIO()). Running the test, I get $ ./manage.py test stock/tests --keepdb Using existing test database for alias 'default'... System check identified no issues (0 silenced). Descriptions: 0 found, 0 not found, 0 not unique StockLines: 0 found, 0 not found, 0 not unique Returned "" F ====================================================================== FAIL: test_001_invocation (test_import_stock_mgmt_cmd.Test_010_import_stock) make sure I've got the basic testing framework right! ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/nigel/django/sarah/silsondb/stock/tests/test_import_stock_mgmt_cmd.py",line 32, in test_001_invocation self.assertIn('Descriptions: 0', text) # do-nothing AssertionError: 'Descriptions: 0' not found in '' ---------------------------------------------------------------------- Ran 1 test in 0.006s FAILED (failures=1) Preserving test database for alias 'default'... The test code which generates this is as follows. print(f'Returned\n"{text}"') shows that I'm getting a null string back from do_command (which creates the StringIO() and invokes call_command ). What I'm trying to intercept is being written to the console, just as when I invoke the command … -
In Django: Even after using "queryset = objects.none()" in forms.py, I still see the dropmenu with all the options
While rendering the form in web browser, the dropdown menu of CPA_Clients should be empty since I've used "self.fields['name'].queryset = CPA_Client.objects.none()" (Since I'll be making it chained dropdown) in forms.py file, but I still see all the contents of CPA_Clients in dropdown. Where did I go wrong? forms.py from django import forms from .models import Task, CPA_Client class TaskDetails(forms.Form): class Meta: model = Task fields = '__all__' def __init__(self, *args, **kwargs): super(TaskDetails, self).__init__(*args, **kwargs) self.fields['name'].queryset = CPA_Client.objects.none() models.py . . . class CPAsList(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name class Meta: verbose_name_plural = 'CPAs' class CPA_Client(models.Model): CPA = models.ForeignKey(CPAsList,on_delete=models.CASCADE, null=True) name = models.CharField(max_length=100) def __str__(self): return self.name class Meta: verbose_name_plural = 'CPA\'s Clients' class Task(models.Model): CPA = models.ForeignKey(CPAsList, on_delete=models.SET_NULL, null=True) Client_of_CPA = models.ForeignKey(CPA_Client, on_delete=models.SET_NULL, null=True) def __str__(self): return self.Subject_Line def get_absolute_url(self): return reverse('task-detail', kwargs={'pk': self.pk}) . . . -
Django extra + where: how to escape identifiers
I have an extra filter in Django with a where clause, but the table name is dynamic. filtered_queryset = queryset.extra( where=[ f'({table_name}.modified_on, {table_name}.id) > (%s, %s)', ], params=(after_ts, after_id), ) How can I best avoid the f-string to make really sure it's not open to SQL injection? -
Model filed values are not updating in django
Am building this voting platform, users will have to but the votes. They will input the number of votes to they want to buy, then make payment. After a successful payment, The number of votes they just bought should be added to their old votes in the database. For instance, say a user buys 2 votes and have 3 votes already, the 2 should should be added to the 3 to make it 5. My problem is that the new votes fails to the added. models.py class Nomination(models.Model): Fullname = models.CharField(max_length=120) Nominee_ID = models.CharField(max_length=100) Category = models.ForeignKey(Category, on_delete=models.CASCADE) image = models.ImageField(upload_to='nominations_images') slug = models.SlugField(max_length=150) votes = models.IntegerField(default=0) date = models.DateTimeField(auto_now_add=True) def __str__(self): return self.Fullname views.py def process_payment(request, slug, amount): trans_id = request.GET.get('transaction_id') status = request.GET.get('status') reason = request.GET.get('reason') transaction_id = request.GET.get('transaction_id') if status == 'approved': transaction = SuccessfulTransactionHistory( nominee_name=slug, transaction_id=transaction_id, amount=amount ) transaction.save() nomination = Nomination.objects.filter(slug=slug).values('votes') Nomination.objects.filter(slug=slug).update(votes=int(nomination[0]['votes']) + int(amount[:-2])) return redirect('/success') else: context = { 'error': reason } transaction = FailedTransactionHistory( nominee_name=slug, transaction_id=transaction_id, amount=amount ) transaction.save() return render(request, 'payment_error.html', context=context) -
Django request not recognized
I am currently learning Django with video tutorials and I came across a problem I can't get rid of. I am in the views file of one of my apps and when I try to use "request" it tells me '"request" is not definedPylancereportUndefinedVariable' from django.http import HttpResponse from django.shortcuts import render # Create your views here. def home_view(*args, **kwargs): return render(request, "home.html", {}) def contact_view(*args, **kwargs): return HttpResponse("<h1>contact page</h1>") view code I tried importing HttpRequests and modifying the code to fit but it then tells me that it doesn't have a META attribute when I run the server runserver error I'd like to use "request" and not import a new library for it as it should come with django, the guy in the tutorial I watch just types in request and it works.I couldn't find anything in the Django docs and it seems like using request shouldn't even be an issue. -
How can i round an Sum in Django ojbect
My code: verloningsoverzicht_cumulatief_dagen = Overzicht.objects.filter(periode=periode, jaar=jaar) .values('testcontract', 'contract') .annotate(aantal=Sum('aantal')) Now lets say the .annotatie Sum is 6.3500000, i want it rounded to 6.35 The round method is not working, how can i solve this .annotate(aantal=round(Sum('aantal'),2)) -
How to create a persistent html5 audio player?
I have the following code to open a player on my website for audio playback using Django: {% if track.file.hls_stream %} <a type="button" class="btn btn-outline-primary" href="{% url 'stream' pk=track.file.pk|safe|cypher_link_stream %}" target="_blank"><i class="fad fa-play-circle"></i></a> ... Currently this opens a new tab and uses VideoJS to play the HLS stream. But actually this is not what I want. I would like to hit the play button, and a audio player pop's up at the bottom of the page and stays there while navigating on the site. I already searched for such a solution but didn't had that much luck. Can someone maybe give me a hint where to look at? Thanks in advance. -
Django - Create a Profile model based to built-in User model
Im creating a car rental system in Django, where every logged in users can place their car for Rent. To create Users, im using the Django's built in User model and UserCreationForm. Although this is not what i need because i have to assign a car_for_rent variable to the User model What i would like to do is when i register a user(Based on User Model), to actually create a Person Instance, based on that User model, if this makes sense. Im trying something like this Models.py from django.db import models from django.contrib.auth.models import User class Car(models.Model): model_car= models.CharField(max_length=200) description = models.TextField() car_image = models.ImageField(null=True, blank=True) date_created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.model_car class Person(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE) car_for_rent = models.ForeignKey(Car,on_delete=models.CASCADE) forms.py #authentication from django.contrib.auth.forms import UserCreationForm from django import forms from django.contrib.auth.models import User class CreateUserForm(UserCreationForm): class Meta: model = User fields=[ 'username', 'email', 'password1' ,'password2' ] So right now it just creates a user based only on User Model -
Reverse for 'printReports' with arguments '('',)' not found. 1 pattern(s) tried
My app currently runs through settings that are saved to the database in-order to print financial documents. I am using the pk variable to fetch the correct forms etc. However now when I am trying to redirect to the pk for 'printReports' in my project. It returns the above error. I am trying to figure out where I have mapped this wrongly , but I can't seem to find any errors Please see the below code: Views.py: def printReports(request , reports_pk): pkForm = get_object_or_404(SettingsClass , pk=reports_pk) form= SettingsClass(instance=pkForm) ### Printing Trial Balance PDF response = HttpResponse(content_type= 'application/pdf') response['Content-Disposition']= 'attachment; filename=TrialBalance' + \ str(datetime.now()) + '.pdf' response['Content-Transfer-Encoding'] = 'binary' content = {"arr_trbYTD":arr_trbYTD , 'xCreditTotal':xCreditTotal , 'xDebitTotal':xDebitTotal , 'complexName':complexName , 'openingBalances': openingBalances ,'printZero':printZero} html_string=render_to_string('main/pdf-trialbalance.html' , content) html=HTML(string=html_string) result=html.write_pdf() with tempfile.NamedTemporaryFile(delete=True) as output: output.write(result) output.flush() output.seek(0) response.write(output.read()) return response else: printTrialBalance = False return render(request , 'main/printReports.html') URLS.PY: #Reports path('reportsHome' , views.reportsHome, name='reportsHome'), path('accConnect/printReports/<int:reports_pk>' , views.printReports , name='printReports') reportsHome.html: {% extends "main/base.html"%} {% block content%} <h1 style=" text-align: center">Reports</h1> <hr> <br> <div class="list-group"> <a href="#" class='list-group-item active'>Print Single Complex's</a> {% for x in model %} <a href="{% url 'printReports' reports.pk %}" class="list-group-item list-group-item-action" >{{ x.Complex }} Reports</a> {% endfor %} </div> {% endblock … -
Why isn't my .Dockerignore file not ignoring files?
When I build the container and I check the files that should have been ignored, most of them haven't been ignored. This is my folder structure. Root/ data/ project/ __pycache__/ media/ static/ app/ __pycache__/ migrations/ templates/ .dockerignore .gitignore .env docker-compose.yml Dockerfile requirements.txt manage.py Let's say i want to ignore the __pycache__ & data(data will be created with the docker-compose up command, when creating the container) folders and the .gitignore & .env files. I will ignore these with the next .dockerignore file .git .gitignore .docker */__pycache__/ **/__pycache__/ .env/ .venv/ venv/ data/ The final result is that only the git & .env files have been ignored. The data folder hasn't been ignored but it's not accesible from the container. And the __pycache__ folders haven't been ignored either. Here are the docker files. docker-compose.yml version: "3.8" services: app: build: . volumes: - .:/django-app ports: - 8000:8000 command: /bin/bash -c "sleep 7; python manage.py migrate; python manage.py runserver 0.0.0.0:8000" container_name: app-container depends_on: - db db: image: postgres volumes: - ./data:/var/lib/postgresql/data environment: - POSTGRES_DB=${DB_NAME} - POSTGRES_USER=${DB_USER} - POSTGRES_PASSWORD=${DB_PASSWORD} container_name: postgres_db_container Dockerfile FROM python:3.9-slim-buster ENV PYTHONUNBUFFERED=1 WORKDIR /django-app EXPOSE 8000 COPY requirements.txt requirements.txt RUN apt-get update \ && adduser --disabled-password --no-create-home userapp \ && apt-get -y … -
Serializers.validated_data fields got changed with source value in DRF
I am trying to create an api, where user can create programs and add rules to them. Rules has to be executed in order of priority. I am using Django rest framework to achieve this and I am trying to achieve this using Serializer without using ModelSerializer. Provide your solution using serializers.Serializer class One program can have many rules and one rule can be in many programs. So, I am using many_to_many relationship and also I want the user to change the order of rules in a program, to achieve this I am using a through table called Priority, where I keep track of relationship between a rule and a program using priority field models.py class Program(models.Model): name = models.CharField(max_length=32) description = models.TextField(blank=True) rules = models.ManyToManyField(Rule, through='Priority') class Rule(models.Model): name = models.CharField(max_length=20) description = models.TextField(blank=True) rule = models.CharField(max_length=256) class Priority(models.Model): program = models.ForeignKey(Program, on_delete=models.CASCADE) rule = models.ForeignKey(Rule, on_delete=models.CASCADE) priority = models.PositiveIntegerField() def save(self, *args, **kwargs): super(Priority, self).save(*args, **kwargs) serializers.py class RuleSerializer(serializers.Serializer): name = serializers.CharField(max_length=20) description = serializers.CharField(allow_blank=True) rule = serializers.CharField(max_length=256) def create(self, validated_data): return Rule.objects.create(**validated_data) def update(self, instance, validated_data): instance.name = validated_data.get('name', instance.name) instance.description = validated_data.get('description', instance.description) instance.rule = validated_data.get('rule', instance.rule) instance.save() return instance class PrioritySerializer(serializers.Serializer): rule_id = serializers.IntegerField(source='rule.id') rule_name … -
Django Model's DateTimeField is taking UTC even when timezone is Asia/Calcutta everywhere. I can't set USE_TZ = False
My Django Server is storing time in UTC format. I want them in IST. But the problem is I can't set USE_TZ = False. Otherwise, it throws more errors and warnings. Pls, help me!!! TIME_ZONE = 'Asia/Calcutta' USE_I18N = True USE_L10N = True USE_TZ = True -
How to remove results with same value with django ORM?
I have a query that returns data that will be displayed in the browser as a line chart. Depending on the period chosen, this can represent a rather huge number of results (~25K max). Most of the time these values do not change, on average on 25 000 results I have about 8000 different values. I think it would be a real optimization if I only return these 8000 values instead of the 25 0000. My Model: class TechnicalData(models.Model): name = models.CharField(_('Name'), max_length=80) value = models.CharField(_('Value'), max_length=80) value_type = models.CharField(_('Value type'), max_length=20) date_time = models.DateTimeField(_("timestamp")) machine = models.ForeignKey("machine.Machine", verbose_name = _("machine"), related_name="technical_data_machine", on_delete=models.CASCADE) class Meta: verbose_name = _("TechnicalData") verbose_name_plural = _("TechnicalDatas") ordering = ["-date_time"] def __str__(self): return self.name If the "value" field does not change during a given period (date_time), I would like to remove the "duplicate/same" values. Today I have this view: class TechnicalDataViewSet(viewsets.ViewSet): """ A simple ViewSet for listing or retrieving technical data. """ permission_classes = [permissions.IsAuthenticated] pagination_class = LargeResultsSetPagination def list(self, request): id_machine = self.request.query_params.get('id_machine') name = self.request.query_params.get('name') only_last = self.request.query_params.get('only_last') names = self.request.query_params.get('name__in') date_start = self.request.query_params.get('date_start') date_end = self.request.query_params.get('date_end') queryset = TechnicalData.objects.all() if id_machine: queryset = queryset.filter(machine__id=id_machine) if name: queryset = queryset.filter(name=name) if names: names = … -
In this how i want to multiply quantity and unit_price to show in total?
class orderdetails(models.Model): product = models.CharField(max_length=100,default='') quantity = models.IntegerField() unit_price = models.IntegerField() total= () -
How to disiable BIGGERkeysses into an authentication application builded in django?
I want only to create users with lowercases into an authentication app login page -
Save Form after successful stripe Payment
I have a model form that the user fills. This form contains a file field as well. After filling in the form once the user presses the submit button, the form is saved to the database using POST after getting verified. What I would like to do is once the user clicks the submit button, they should be taken to another page to make a payment. The payment page will be created using Stripe Payment Intent and not Stripe Checkout. Once they have successfully paid I would like to save the data that the user have filled in the form.I have created the Stripe Payment page and I can see payments being made on the Stripe dashboard but I would like to save the data that the user has filled in the form after successful payment. How do I go about doing this in Python3 , Django? -
Django sales campaign model with list of foreign keys that can only appear in one sales campaign?
I want to create a sales campaign which stores a list of books (Items). But the book should only be applied to one sales campaign — ie. it should not be able to appear in two campaigns. I have the following model: class Campaign(models.Model): campaign_name = models.CharField(max_length=50, null=False, blank=False, default='Special Offer') included_items = models.ManyToManyField(Item, blank=True) active = models.BooleanField(default=True) fixed_price = models.DecimalField(max_digits=6, blank=True, null=True, decimal_places=2) But I think the included_items field might be of the wrong field type. From reading other questions and the Django manual, I think I may be approaching this back to front. Perhaps I should be tackling this from the Item model instead? (Shown below for reference) class Item(models.Model): sku = models.CharField( max_length=10, null=True, blank=True, default=create_new_sku) title = models.CharField(max_length=254) genre = models.ManyToManyField('Genre', blank=True) author = models.ManyToManyField('Author', blank=True) description = models.TextField() age_range = models.ManyToManyField( 'Age_range') image_url = models.URLField(max_length=1024, null=True, blank=True) image = models.ImageField(null=True, blank=True) price = models.DecimalField(max_digits=6, decimal_places=2, default=0.00) discount = models.DecimalField(max_digits=2, decimal_places=0, default=0) set_sale_price = models.DecimalField(max_digits=6, decimal_places=2, default=0.00) original_sale_price = models.DecimalField(max_digits=6, decimal_places=2, null=True, blank=True) final_price = models.DecimalField(max_digits=6, decimal_places=2, null=True, blank=False, editable=False) -
Django how to pass arguments from views.py to websocket "on_open" function in another file
In my Django in tasks.py file I am using websocket connection - on_open_socket function: def on_open__socket(ws): print("Socket connected") My connection: ws.on_open = on_open_socket How can I pass additional arguments dynamically to "on_open_socket" from views.py, like following: def on_open__socket(ws, {new arguments -> name, date}): print("Socket connected") stream = { "name" = name "date" = date } I tried using partial, but I cannot figure out how to do this from views.py. -
Adding the first product in cart returns intergrity error
In the views.py logic, as you can see that i have printed three characters x, y and z for the outer else block which create a new order with the first product being added. However if the cart is empty and try to add a product , it throws an error saying: null value in column "order_id" of relation "onlineshopping_order" violates not-null constraint DETAIL: Failing row contains (2021-09-23 07:49:55.861471+00, 2021-09-23 07:49:55.861471+00, f, 2, null, null, null, null). views.py: @login_required def add_to_cart(request, slug): item = get_object_or_404(AffProduct, slug=slug) order_item, created = OrderItem.objects.get_or_create( item=item, user=request.user, ordered=False ) order = Order.objects.filter(user=request.user, ordered=False).first() if order: # check if the order item is in the order if order.items.filter(item__slug=item.slug).exists(): order_item.quantity += 1 order_item.save() messages.info(request, "This item quantity was updated.") else: order.items.add(order_item) messages.info(request, "This item was added to your cart.") else: # ordered_date = timezone.now() print('x') order = Order.objects.create(user=request.user) print('y') order.items.add(order_item) print('z') messages.info(request, "This item was added to your cart.") return render(request, 'cart.html', {'order_item': order_item, 'object': order}) -
Reverse for 'printReports' with arguments '('',)' not found. 1 pattern(s) tried
My app currently runs through settings that are saved to the database in-order to print financial documents. I am using the pk variable to fetch the correct forms etc. However now when I am trying to redirect to the pk for 'printReports' in my project. It returns the above error. I am trying to figure out where I have mapped this wrongly , but I can't seem to find any errors Please see the below code: Views.py: def printReports(request , reports_pk): pkForm = get_object_or_404(SettingsClass , pk=reports_pk) form= SettingsClass(instance=pkForm) complexName = form.Complex printTrialBalance = True includeOpeningBalance = '' useMainAccounts = 'len(Master_Sub_Account) < 5 ' printNullValues = '' # else it will print null values printDescription = '' # if false it wil remove the print description line printAccount = '' # if false it wil remove the print account line OrderByAccount = 'ORDER BY iAccountType ' #CHECKING TRIAL BALANCE SETTINGS if form.Trial_balance_Year_to_date == True: printTrialBalance = True baseTRBYear = 'Inner JOIN [?].[dbo].[Accounts] '\ 'on Accounts.AccountLink = genLedger.AccountLink '\ 'Inner JOIN [?].[dbo].[_etblGLAccountTypes] as AccountTypes '\ 'on Accounts.iAccountType = AccountTypes.idGLAccountType '\ 'WHERE genLedger.AccountLink not in (161,162,163,164,165,166,167,168,122) '\ 'AND genLedger.TxDate > ?'\ op1 = '' op2 = '' op3 = '' op4 = '' … -
Problem with dynamic media in django project when i deploy on server with docker and nginx
I have a problem with an image that I upload to django-admin. Photos are added to the media folder in the running container, but it seems that the photos are trying to be taken from local files where they are not present. All working on my own computer, but i have faced with this problem when tried to deploy on server That's how it's looking in site enter image description here nginx can't find it enter image description here i have tried something like this Django static files not served with Docker but its not work for me This is my files structure: booking2 assets media main-app booking2 docker nginx Dockerfile nginx.conf docker-compose.yml Dockerfile entrypoint.sh .env main Dockerfile FROM python:3.8-alpine ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 WORKDIR /app RUN apk --update add RUN apk add gcc gcc python3-dev libc-dev libffi-dev jpeg-dev zlib-dev libjpeg libxml2-dev libxml2 libxslt-dev gettext RUN apk add postgresql-dev RUN pip install --upgrade pip COPY ./requirements.txt . RUN pip install -r requirements.txt COPY . . RUN chmod +x entrypoint.sh ENTRYPOINT ["/app/entrypoint.sh"] docker-compose.yml version: "3.7" services: web: build: context: . dockerfile: Dockerfile ports: - "8000:8000" entrypoint: - ./entrypoint.sh depends_on: - postgresdb postgresdb: build: context: ./docker/postgres dockerfile: Dockerfile environment: - … -
Does not show the login page
I am totally new in django. I tried to make a login form .whenever i press submit button i get the login/login URL it doesn't exist. This is my method in View.py(where i think the problem happens hereenter image description here) (when i go to the login page it shows me the page correctly but button do something wrong) def login(req): if req.method=='post': username=req.POST['username'] password=req.POST['password'] print(username,password) user=auth.authenticate(username=username,password=password) if user is not None: auth.login(req,user) return redirect("/") else: return redirect("task:all") else: return render(req, "Login.html") this is in urls.py path("login/", views.login, name='login'), path("logout/", views.logout, name='logout'), and this is my HTML <form action="login" method="post"> {% csrf_token %} <label for="username"><b>Userame</b></label> <input type="text" placeholder="Enter Username" name="username" required> <label for="psw"><b>Password</b></label> <input type="password" placeholder="Enter Password" name="password" required> <div class="row justify-content-center "> <button type="submit" class="signupbtn btn btn-primary" name="btn">Login</button> </div> </form> -
Convert Django framework to Django rest framework
To make the curl post request work, I am converting my existing Django project to Django REST framework. I have installed djangorestframework==3.12.4. My settings.py INSTALLED_APPS = [ .... 'rest_framework', ] REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' ] } My views.py from django.shortcuts import render from . import forms from . import student_details_module from django.http import HttpResponseRedirect def student_details(request): submitted = False print (request) if request.method == 'POST': form = forms.studentDetailsForm(request.POST) if form.is_valid(): cd = form.cleaned_data return_message,return_code = student_details_module.show_data(cd['name']) return HttpResponseRedirect('/student_details?submitted=True') else: form = forms.studentDetailsForm() if 'submitted' in request.GET: submitted = True return render(request, 'student_details.html', {'form': form, 'submitted': submitted} ) How do I convert my view so it works well with djangorestframework. Please suggest. -
How do you customize dropdown container of option in html/css? please help i'm a beginner
i would like to change the border radius and border of the thing that is pointed by an arrow Here's my code: HTML- I use django forms and defined the class there: <div class="container-form"> <h1>ADD ISSUE</h1> <form action="" method="POST"> {% csrf_token %} {% for form in forms %} {{ form|safe }} {% endfor %} <input type="submit" value="create" class="submit-form"> </form> </div> Django forms: class IssueForm(ModelForm): project_bug = forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'bug_form_text', 'placeholder':'Write your issue here'})) status = forms.ChoiceField(choices=Issue.StatusType.choices, required=True, widget=forms.Select(attrs={'class':'bug_form_dropdown'})) difficulty = forms.ChoiceField(choices=Issue.DifficultyType.choices ,required=True, widget=forms.Select(attrs={'class':'bug_form_dropdown'})) Css: .bug_form_text{ margin-top: 1em; border: none; border-bottom: 2px solid black; padding-bottom: .5em; outline: none; font-size: 1rem; background-color: transparent; } .bug_form_dropdown{ margin-top: 1em; border: none; outline: none; height: 4vh; background-color: #262626; color: #f2f2f2; border-radius: 3px; width: 70%; overflow: hidden; transition: ease-in 1s; } .submit-form{ margin-top: 1em; border: none; border-radius: 3px; outline: none; padding: .7em 2em; background-color: #e50914; color: #f2f2f2; } Attempted: I tried .bug_form_dropdown option{} it didn't work please help