django-widget Questions

3

Solved

How can I access if a field has)errors at the level of widget? Using default I tried: {% if widget.attributes.has_errors %} or {% if widget.has_errors %} but are not working. I use custom widg...
Tabitha asked 2/2, 2019 at 9:25

3

Solved

I want to display my widget on the field at django admin when the field is readonly. admin.py class AudioTrackAdminInline(admin.StackedInline): model = AudioTrack form = AudioTrackForm readonl...
Casefy asked 12/2, 2013 at 12:36

4

Solved

Is there a way to apply css class to ALL fields instead of doing the following for every single field. forms.py class UserColorsForm(forms.ModelForm): class Meta: model = UserColors exclude =...
Crotchet asked 28/12, 2014 at 21:55

2

Solved

In my Django App I have the following model: class SuperCategory(models.Model): name = models.CharField(max_length=100,) slug = models.SlugField(unique=True,) class Category(models.Model): nam...
Aeronautics asked 5/3, 2011 at 1:3

7

Solved

I have an input field that is rendered with a template like so: <div class="field"> {{ form.city }} </div> Which is rendered as: <div class="field"> <input id="id_city" t...
Jordon asked 25/5, 2010 at 4:27

4

Solved

Which is the best way to create a django form field that accepts floats and has the same functionality as a NumberInput? What I mean with same functionality is that django's NumberInput has arrows ...
Thurman asked 14/1, 2015 at 18:3

5

Solved

I know that if I need a custom "selector" for a field in django-admin I need to create a custom widget. But what if the widget have to produce two values, for example X and Y coordinates, how can I...
Study asked 4/8, 2010 at 13:17

4

Solved

I have a model with a boolean value like that: class TagCat(models.Model): by_admin = models.BooleanField(default=True) This appears as a checkbox in admin. How could I use this as a radio ...
Chefoo asked 2/12, 2010 at 16:29

2

Solved

I am trying to make all of the fields in my Django form have the same size to look tidy. I have text input, drop down and text area. I am creating the form using the Ticket model so I am not defini...
Setter asked 21/8, 2018 at 21:10

2

Solved

I have in form.py SELECT_PRODUCT = [ ('item1', 'item1'), ('item2', 'item2'), ('item3', 'item3'), ('item4', 'item4'), ] class OrderBonus(forms.Form): select_product = forms.CharField(widget=f...
Inartistic asked 8/12, 2016 at 9:43

4

Solved

Is there a different widget or argument that will allow django to only show/take the year and month input instead of year, month and day? Currently using SelectDateWidget.
Doorpost asked 19/1, 2011 at 8:18

2

Solved

I have a form that is using NumberInput widget to accept a rating for a Song from the user. The number should be between 0-5. My Song model has a MaxValueValidator but I want the NumberInput widget...
Chimera asked 4/5, 2016 at 10:9

2

Solved

I have two models, Product and Category and ManytoMany field in Product. The Category appear as key on ProductCreate View. I need to customize the widget and field for Categories. I checked in D...
Ardyce asked 5/11, 2017 at 8:48

5

Solved

I have a DateTimeField field in my model. I wanted to display it as a checkbox widget in the Django admin site. To do this, I created a custom form widget. However, I do not know how to use my cust...
Buhl asked 14/11, 2010 at 7:36

16

Solved

I have a form for address information. One of the fields is for the address country. Currently this is just a textbox. I would like a drop down list (of ISO 3166 countries) for this. I'm a django n...

1

Solved

The official docs explain how to automatically adds assets for certain widgets., from their example: from django import forms class CalendarWidget(forms.TextInput): class Media: css = { 'all': ...
Anarthria asked 11/7, 2021 at 18:28

2

Solved

I have a Django Form Field with a MultiWidget that consists of two TextInputs. When rendering the form in a template there is the handy notation {{ formname.fieldname }} for rendering a single ...
Plebeian asked 21/7, 2014 at 13:58

3

I have defined a custom field and widget for a form that is being served by subclassing UpdateView. So, something like this: myapp/forms.py: from .form_fields import MyCustomField from .widgets i...
Carbo asked 10/12, 2013 at 18:6

2

I am about to add DurationField 's widget for admin site and want duration field's widget for input. Problem statement In below PromoCode class have DurationField namely duration. But in admin it s...
Tetrafluoroethylene asked 8/3, 2019 at 14:17

1

Solved

I need to add this widget to the django UpdateView, class tlistUpdate(LoginRequiredMixin,UpdateView): fields = ('title', 'thumbnail', 'content', 'tags') model = htmlpage template_name = 'blog/c...
Valeta asked 7/3, 2020 at 13:38

2

Solved

I am trying to display the 3 select fields that are rendered out using Django SelectDateWidget on one line. When I use crispy forms, they are all on separate rows. Is there a way to use the Layout ...

2

Solved

The current admin widget for ArrayField is one field, with comma as delimiter, like this (text list): This isn't ideal because I would have longer texts (even 20 words) and contain commas. I cou...
Furfuran asked 16/3, 2018 at 14:39

1

Solved

I want to override the Django (2.01) widget templates, because I need to add classes for each input, label, and position them differently app - templates - app - django - forms - widgets - ...
Parcae asked 12/1, 2018 at 12:28

2

Solved

I'm trying to use DateInput, but I get the following error Required argument 'year' (pos 1) not found here {{ form.incident_date_time_reported|add_class:"form-control"}} (line 52) forms.py from d...
Schoolteacher asked 10/7, 2015 at 16:51

2

Solved

Note: This question shouldn't be conflated with past questions that are similar but before Django 1.11, when they released template-based form rendering. I understand that Django now has template-...
Psychosocial asked 5/2, 2017 at 5:51

© 2022 - 2025 — McMap. All rights reserved.