Hello,
I have this view function:
def search(request):
if request.method == 'GET':
form = SearchForm(request.GET)
if form.is_valid():
last_name = form.cleaned_data['last_name']
first_name = form.cleaned_data['first_name']
lawyers = Lawyer.objects.all()
[ other if state...
Is there a way to give a form a special error rendering function in the form definition? In the docs under customizing-the-error-list-format it shows how you can give a form a special error rendering function, but it seems like you have to declare it when you instantiate the form, not when you define it.
So you can define some ErrorList...
I'm using django-ajax-selects, which is a freely available django app providing jquery autocomplete functionality.
I've got it working - i.e. it is autocompleting the form fields I want it to. But I have a problem... I'm using it in a ModelForm which adds Partnership objects to the database:
class Skater(models.Model):
name = model...
Hello guys,
I've looked at formset and model formset at Django many times, but I still can't figure the smart way to do this.
I have two models:
Group
Person
I have a queryset that contains all the persons trying to join a particular group: Person.objects.filter(wantsToJoinGroup=groupD)
Now, what I want to do, is display a page wit...
how do i order a the options of a form field by a translated field?
models.py:
class UserProfile(models.Model):
...
country=models.ForeignKey('Country')
class Country(models.Model):
class Translation(multilingual.Translation):
name = models.CharField(max_length=60)
...
template.html:
{# userprofileform is a ...
Hi everybody,
I want to change the shape of some fields showed in the admin site.
I found that the template that manage everything is change_form.html with fieldset.html but I cannot find where the fields are actually transformed in html.
Basically I want to change the field of the foreign key adding a link to another page.
Do you hav...
I cannot find which part of code print the "+" that is close to every foreign key field.
In fieldset.html there is only the call to {{ field.field }}, but in the file django/forms/widgets.py the code that prints the select, doesn't contain that code, so I suppose that there is a piece of code that manage the foreign key: where is it?
...
I want to change the way that the "+" icon for the foreign key in the admin site is shown.
I found that the widget that prints the code is RelatedFieldWidgetWrapper that is in django/contrib/admin/widgets.py.
So I wrote my version of this class and I changed its render function.
But now how can I use it? I mean... in the definition of...
I have UserProfile model defined in settings.py.
Now I want to create registration form that have fields both from User and UserProfile models. Is there easy way to do it?
I'm using uni_form to create nice looking forms if this helps.
...
Which is the widget that renders the foreign key in the admin site?
I saw that there is a widget called RelatedFieldWidgetWrapper (that print only the "+" icon) and another for the select, but I suppose that there is a widget that call both to render the entire field.
Thanks
...
I'm trying to solve a problem that I outlined in this question. At the moment it looks like I will have to override the to_python() method on the ForeignKey field. But as far as I can see in django's source code, the ForeignKey class doesn't actually have a to_python() method declared, so it must be inheriting it from the Field class, wh...
I have the data stored in a format different from the display format.
I've already worked out the form-to-db conversion in the clean_weight() method of the form, this gives me access to properly format data before saving it.
Now I pretend to manipulate the instances weight before the form is displayed but I fail to see a good place to...
I have a form that contains 5 pairs of locations and descriptions. I have three sets of validations that need to be done
you need to enter at least one location
for the first location, you must have a description
for each remaining pair of locations and description
After reading the Django documentation, I came up with the following...
I am building a web app that allows our field staff to create appointments. This involves creating a record that contains many foreign keys, of which some come from very large tables. For example, the staff will need to select one of potentially thousands of customers.
What's the best way of doing this in Django?
A pop-up box that a...
I'm trying to make a custom backend for my system and I've hit a bit of a snag....I want to give users the ability to add new makes/models/series that are not already in the system via a form. I'm wondering how I'll go about this...my models look as below:
class Manufacturer(models.Model):
MANUFACTURER_POPULARITY_CHOICES = (
('1',...
I'd like to have several fields in my form being rendered as ChoiceFields which get their content from the database.
I was thinking something like:
class SeriesForm(ModelForm):
series = forms.ChoiceField(choices=Series.objects.all())
class Meta:
model = Series
exclude = ('model', 'date_added',)
But the field series is no...
I'm using this code in one of my views:
if request.method == 'POST':
vehicle = VehicleForm(request.POST or None)
photos = PhotosFormSet(request.POST or None)
if vehicle.is_valid():
vehicle.save()
photos = PhotosFormSet(request.POST, instance=vehicle)
photos.save()
return HttpResponse...
Hi,
I'm using an inlineformset to present an object with all values read-only. can_delete is set to True and not read-only. The user should only be able to delete objects, but not change a value.
This is the code parts that I use:
view:
PMWPDRFormSet = inlineformset_factory(ProjectMembership, PMSWorkPlaceDayRate, form=ProjectMembersh...
I'd like to know how can I add .error class to input elements (to registration app) when the form validation fails.
...
Hi - I have a ModelForm in my Django app that uses a forms.ModelMultipleChoiceField, which displays as a forms.CheckboxSelectMultiple widget on the form. This ModelForm is used to select/de-select values for a many-to-many relation. Here's the problem: when you uncheck all of the checkboxes and save the form, it doesn't save. If you un...