inline-formset

How to add custom fields to InlineFormsets?

I'm trying to add custom fields to an InlineFormset using the following code, but the fields won't show up in the Django Admin. Is the InlineFormset too locked down to allow this? My print "ding" test fires as expected, I can print out the form.fields and see them all there, but the actual fields are never rendered in the admin. admin...

Inline formset in Django - removing certain fields

I need to create an inline formset which a) excludes some fields from MyModel being displayed altogether b) displays some some fields MyModel but prevents them from being editable. I tried using the code below, using values() in order to filter the query set to just those values I wanted returned. However, this failed. Anybody wit...

[Django] inlineformset_factory custom form id

I am writing a web application that uses ajax to add new forms on the page. Existing forms are made using inlineformset_factory. When client side gets the form it inserts it in the right position and updates the value of #id_form_type-TOTAL_FORMS" (form_type is name of the form in this example). Existing forms have name for each field l...

dynamically populating fields in a formset

I have two models that looks like this: class RouteBase(models.Model): base = models.ForeignKey("Base") route = models.ForeignKey("Route") sequence = models.IntegerField() class Route(models.Model): bases = models.ManyToManyField("Base", through="RouteBase", blank=True) description = models.TextField(blank=True) #and a few oth...

Django Formset without instance

Hi. In this Django Doc explain how to create a formset that allows you to edit books belonging to a particular author. What I want to do is: Create a formset that allows you to ADD new book belonging to a NEW author... Add the Book and their Authors in the same formset. Can you gime a light? thanks. ...

Multiple django forms posted fromsame page, inlines and adding/removing those inlines.

There are several questions about more or less same issue in stackoverflow, but none of them seems to cover the issues i can foresee. Since my django knowledege is limited i might be overreacting... so.. What i want to accomplish, with django, is to edit 2 models, List and ListItem in same view. List as common form and listitem as inlin...

Django: Aquiring form id from formset

Hello I am not sure if title describes what i want accurately. What i want is to achieve something like that: http://stackoverflow.com/questions/1405587/django-add-remove-form-without-multiple-submit/1406819#1406819. But i have not list of items i have formset and forms. The form of this formset does contain information i could use for...

How do I use inline formsets to link two or more forms?

Hi, I have the following models and I'd like to use them to generate a contact form...now I know I'm suppossed to use inline formsets, but I've never been able to make heads or tails of how to make this work...I want to have the first name, last name, email, phone number, best time to contact, and the message in my view. class BestTi...

Django inlineformsetfactory - What is it good for?

Sorry for a newbie question but... Can someone shed some light on what is the use case for inlineformset_factory? I have followed example from Django documentation: #Models class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): author = models.ForeignKey(Author) title = models.CharFi...

Imagefield in Inline formset not populated

I have this piece of code: vehicle = get_object_or_404(Vehicle, stock_number=stock_number) if request.method == 'POST': vehicle_form = VehicleForm(request.POST, instance=vehicle) photos = PhotosFormSet(request.POST, request.FILES, instance=vehicle) if vehicle_form.is_valid() and photos.is_valid(): vehicle = vehicle_...

InlineFormSet - Get a User ModelForm when the relationship is in the User.Profile model

My end result is to provide a User Permissions Matrix. (django.contrib.auth.models.Permission) Working with three models in this scenario: Office, User, and UserProfile. Users are related to an Office model through the UserProfile model. See below for my model setup: class User(models.Model): # the included django User model class Use...

Django Inline formset for editing multiple related records at once - the right way to go?

Hi, When using inline formsets, how does one do paging? I'm using django 1.1. The situation I'm in, is that the user needs to be able to edit the related objects quickly and easily (which is why I think I should be using an inline formset). However, there can be a more than a hundred objects to edit, which makes a pretty large formset,...

Django multiple generic_inline_formset in a view

We have a bunch of formsets: EmailAddressInlineFormSet = generic_inlineformset_factory( EmailAddress, extra=1, exclude=["created_by","last_modified_by"]) emailaddressformset = EmailAddressInlineFormSet( instance=person, prefix="emailaddress") # [ more definitions ] and, in the view, we process them as: emailaddressfo...

Django inlineformset validation and delete

Hi, Can someone tell me if a form in an inlineformset should go through validation if the DELETE field is checked. I have a form that uses an inlineformset and when I check the DELETE box it fails because the required fields are blank. If I put data in the fields it will pass validation and then be deleted. Is that how it is supposed t...

Display correct choice text for Django inline formset with two foreign keys

I have successfully used inline formsets to create a recipe input form that consists of a Recipe form (just a model form) and a RecipeIngredient formset. The models are: #models.py class Recipe(models.Model): title = models.CharField(max_length=255) description = models.TextField(blank=True) directions = models.TextField() ...

Initial Data for Django Inline Formsets

I have put together a form to save a recipe. It makes use of a form and an inline formset. I have users with text files containing recipes and they would like to cut and paste the data to make entry easier. I have worked out how to populate the form portion after processing the raw text input but I cannot figure out how to populate th...

How do I detect if a formset has any errors at all in a template?

Thanks to the fantastic inline model formsets in django I have a pretty advanced form with 4 inline formsets. In the template I display each formset in a tab. Everything works really slick but I would like to color a tab red if the formset in that tab has any validation errors at all. So I tried this: <div id="tabs"> <ul> <l...

How to clean a certain field in a InlineFormSet ?

I need to clean a specific field in an inline formset, and I can't figure out how to do it. I've tried with the formsets def clean(self) method but don't know where to save the cleaned value. If I try to set the cleaned value to forms[0].data['field'] I get "This QueryDict instance is immutable" error. In "normal" forms it works by us...

Make inlineformset in django required

Hi, I am new to django (until now, I used the symfony PHP Framework). My problem is this: I have a model Event and model Date. The Date has a foreign key to Event, so that an Event may (or should) have one or more Dates. Now I want to have a form to create Events and this form should include a subform for adding one corresponding Date ...