327 questions
0
votes
1
answer
48
views
Django SelectDateWidget default values for month and year only
I use the SelectDateWidget in my form and want to give default values for year and month, but show the empty_label (----) on day. I either get all three fields to be empty_label, or all fields showing ...
1
vote
1
answer
117
views
Custom Widget for Search Bar
I am on Django 5.0.7. I wanted to define a custom widget SearchBar, which when associated with a CharField, would automatically render a text input box for search, followed by a search button. I ...
1
vote
2
answers
227
views
instantiate a django form in readonly mode in a view function
I have a django 4 form having some widgets for the user to select some values:
from django import forms
from .app.model import MyModel
from bootstrap_datepicker_plus.widgets import DatePickerInput
...
0
votes
1
answer
470
views
How to insert placeholder in Django Admin autocomplete input?
I don't want to use my own JS or alter the template when Django has other mechanisms.
I've tried three methods, first as described in
how-to-add-placeholder-text-to-a-django-admin-field and in the ...
0
votes
0
answers
55
views
Django form image field mandatory error even when filled
I have a form that works both for when creating a new instance or editing one, on django. The problem is that no matter what scenario, even when I fill the input file fields, it always returns error ...
0
votes
1
answer
453
views
Override the template of a widget and pass values to it with Django 4.0
I am creating a simple app to do product reviews.
I have a Product, Manufacturer and Review models which I will now summarize
class Manufacturer(models.Model):
name = models.CharField()
class ...
2
votes
1
answer
202
views
How to 'check' a value in a radio button by default in Django?
I wrote a model form. I used widgets to make radio buttons and I want a particular radio button to be checked by default while rendering the form in my html file.
Model:
class Room(models.Model):
...
1
vote
2
answers
711
views
How do I get rid of labels in django Form?
I have dealt with only ModelForm previously, so it is my first time using Form.
I'd like to get rid of labels from my form, however, how I get rid of labels in ModelForm does not seem to work with ...
0
votes
1
answer
265
views
How to use JavaScript client-side encryption/decryption in django forms / crispy forms? Is there any python package available which can do this
Django Form fields needs to be encrypted at server side and needs to be decrypted in client browser while rendering and vice versa for form submission
One approach is using JS cryptographic libraries ...
2
votes
1
answer
123
views
django-filter looking for templates only in venv
Tried to make custom widget for RangeFilter. Every time django raises
TemplateDoesNotExist
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django....
1
vote
1
answer
1k
views
change field type in django forms
I have a model for a group that has two fields: leader and description.
models.py
class Group(models.Model):
leader = models.ForeignKey(User, on_delete=models.CASCADE)
description = models....
0
votes
1
answer
1k
views
forms.Select(attrs={'class': 'form-control' Edit form and get numbers 1-5 in dropdown
Am wondering how i can get this html code into a forms.py in my ReviewForm as widgets.
This code: 'rating': forms.Select(attrs={'class': 'form-control',}),
Should be as the html code under with 1-5. ...
0
votes
1
answer
226
views
How can I add Datepicker in DjangoCreateView
#view.py
class JobCreateView(CreateView):
model = Job
template_name = 'Job_create.html'
fields = ['Company' ,'Job_title','Department','Start_date','end_date','Consent']
def form_valid(...
2
votes
2
answers
2k
views
Django DateInput widget format
I am trying to change the date format from mm/dd/yyyy to dd/mm/yyyy in a DateInput widget. I am trying to change the format the following way.
class Meta:
model = Patient
fields = '__all__'
...
0
votes
1
answer
96
views
How can I implement the same widget that Django uses to ManyToMany fields in the admin page?
My models:
class Ingredient(models.Model):
BASE_UNIT_CHOICES = [("g", "Grams"), ("ml", "Mililiters")]
CURRENCY_CHOICES = [("USD", "US ...
0
votes
0
answers
1k
views
How do I add a class to a custom widget?
I've defined the following custom widget in forms.py, which over rides the standard HTML to create a "live search" select menu (user can enter free text to search options, useful when there ...
1
vote
1
answer
1k
views
Using jQuery DateTimePicker in Django Admin (jazzmin) get error - Enter a list of values
Plugged in TempusDominus widget for DateTimeField in Django admin. The task is to enable date selection with scaling by months and years. The standard widget doesn't have that option. But Django, when ...
1
vote
1
answer
1k
views
Django Admin FilteredSelectMultiple Widget selection doesn't work
I am trying to use the FilteredSelectMultiple widget from the admin widgets library. I was able to get the widget displayed on the web page. However, I cannot get the buttons to move the selections to ...
0
votes
2
answers
633
views
How to find out current logged-in user in widget in Django Wagtail
I have been looking for a way to find out who the current logged-in user is in Django Wagtail so that I could create a widget to render a base setting field to be editable/non-editable. I was able to ...
0
votes
1
answer
2k
views
Django Widgets with Bootstrap
I am trying to stylize my form using bootstrap. As you know bootstrap uses a lot of classes in order to do what it does. By googling I have found to inject some new classes into my form I could use ...
0
votes
1
answer
652
views
django django-yearmonth-widget display month as month name
I have used package "django-yearmonth-widget" to have year and month selection and not complete date. Here, day is fixed i.e. 1st of every month. This implementation is working fine.
Package:...
1
vote
0
answers
152
views
how do I change the date format on selectDate django widget?
I have a date field of a form and I want it to have a format like '21 jan 2020' but I can't find a way to pass it on the selectDate widget
class MemoryForm(ModelForm):
class Meta:
model = ...
0
votes
1
answer
235
views
Error -Undefined variable: 'ModelSelect2Widget'
I am new to this field. I am working on Dependent Dropdowns for which i took reference from here. On replicating the same with the following code:
Forms.py
class AddressForm(forms.ModelForm):
class ...
1
vote
0
answers
352
views
Django forms foreign key field read only gives value error during Update form
models.py
class MyModel(models.Model):
company = models.ForeignKey(Company, db_column="company", default=None, on_delete=models.DO_NOTHING, null=True)
forms.py
class myform(forms....
0
votes
1
answer
483
views
Django - Enter a list of values - ForeignKey
For a M2O relation what field should I be using in forms?
models.py
class Studio(models.Model):
name = models.SlugField(max_length=100)
rating = models.CharField(max_length=10, default=None)
...