inline-formset

Django inline formset error

穿精又带淫゛_ 提交于 2019-12-24 17:48:40
问题 I'm trying to add an inline formset to a form. Here's the minimal code for reproducing the error: models.py class Festival(Model): desc = TextField(max_length=1000) class FestivalAddress(Model): festival = ForeignKey(Festival, related_name="addresses") name = CharField(max_length="50") urls.py urlpatterns = patterns('', url('^add/$', FestivalCreateView.as_view(), name='festival_add'), ) views.py class FestivalCreateView(CreateView): model = Festival form_class = FestivalForm #Add

Using a Django FileField in an inline formset

守給你的承諾、 提交于 2019-12-24 11:17:04
问题 having issues getting the file to upload in my app. A User submits a report and can add attachments (through a foreign key relationship). I've got the inline form showing up and will work if I leave it blank, but when I try to upload a file then submit the form I get a 500 error. The base report is made, but the attachment that's getting inlined doesn't get saved. forms.py class ReportForm(forms.ModelForm): accidentDate = forms.DateField(widget=SelectDateWidget( empty_label=("Choose Year",

Django - Changing inline formset textInput size attribute

纵然是瞬间 提交于 2019-12-24 03:41:14
问题 I have an inline formset that only has three fields: class Estimate_Product_Details(models.Model): proposalID = models.ForeignKey(Estimate_Construction, verbose_name='Proposal ID') CID = models.ForeignKey(Product, verbose_name = 'CID') qty = models.DecimalField(max_digits = 7, decimal_places = 2, verbose_name = 'Quantity') def __unicode__(self): return u'%s -- %s' % (self.proposalID, self.CID) I then create a form from that model: class Product_Form(ModelForm): class Meta: model = Estimate

Saving formset with drop-down-menu Foreignkey: IntegrityError XXX_id may not be NULL

旧城冷巷雨未停 提交于 2019-12-24 03:35:13
问题 I am trying to have a formset where each form (PropertySelector) has a drop-down menu (PropertySelector.property) whereas each item of that menu is ForeignKey reference to another model (Property). Somehow when I am trying to submit and save the formset I am getting: Exception Type: IntegrityError Exception Value: testproj_propertyselector.property_id may not be NULL What is wrong with it and how can I get around it? My entire code is below. Thanks. EDIT: it looks like inline_formset problem

django inlineformset_factory extra attribute being ignored?

回眸只為那壹抹淺笑 提交于 2019-12-23 03:32:14
问题 I am trying to render an inlineformset but the "extra" attribute seems to be ignored. Consider the following models: class Foo_model(models.Model): fooName = models.CharField(max_length=LIL_STRING) bars = models.ForeignKey("Bar_model") class Bar_model(models.Model): barName = models.CharField(max_length=LIL_STRING) forms: class Foo_form(ModelForm): class Meta: model = Foo_model class Bar_form(ModelForm): class Meta: model = Bar_model Bar_formset = inlineformset_factory(Foo_model,Bar_model

Django : Inline editing of related model using inlineformset

荒凉一梦 提交于 2019-12-23 02:31:43
问题 I'm still stuck with the inline Tree-like-eiditing of related models on same page. I've got three models, A, B and C. Class A Class B fb = foreignkey(A) Class C fc = foreignkey(B) In admin.py I'm doing something like AdminA inlines = [inlineB] AdminB inlines = [inlineC] I want that when I edit/add model A, I should be able to add ModelB inline, and add Model B's related Model C entries. I was trying out inlineformsets, but can't find out how to use them for my purpose. Moreover, I found this

Inline formset factory - pass request to child form

99封情书 提交于 2019-12-22 17:50:00
问题 I'm facing a quite challenging taks: I need an inlineformset_factory connecting my ParentEntity to my foreign key-bound ChildEntities . My ChildEntity contains a foreign key relation I need to filter per logged-in user - so I need the request in the ChildForm . What I've tried so far: I tried to use the form= kwarg but I can't pass an instance - just a class. So no way for me to add the request here. I tried to use the formset= kwarg but when I try to pass the request=request as a kwarg of

Testing InlineFormset clean methods

让人想犯罪 __ 提交于 2019-12-22 04:37:37
问题 I have a Django project, with 2 models, a Structure and Bracket , the Bracket has a ForeignKey to a Structure (i.e. one-to-many, one Structure has many Brackets). I created a TabularInline for the admin site, so that there would be a table of Brackets on the Structure. I added a custom formset with some a custom clean method to do some extra validation, you can't have a Bracket that conflicts with another Bracket on the same Structure etc. The admin looks like this: class BracketInline(admin

Enable Django admin functionality at frontend with inlines

空扰寡人 提交于 2019-12-22 04:04:36
问题 I have decided to move some functionality from my admin website into the frontend. Functionality includes the administration of one model with some foreign key inlines. For that I have installed django-dynamic-formset JQuery plugin (link git) and struggling with it already for couple of days. Here is one of the problems. The same functionality is already implemented in Django admin. I can add, modify, remove inlines and modify model instance as I want. I am wondering why should I use this

Django admin: Inline straight to second-level relationship

独自空忆成欢 提交于 2019-12-20 20:01:18
问题 I have a three-levels Invoice model which I'd like to display on Django's admin area... in a "kind of special " way. Allow me to provide a bit of background: Each Invoice is conformed by several SubInvoice (s), and each SubInvoice is conformed by several InvoiceItem (s), which contain a break down of the Products purchased by a customer. Logically speaking, it'd be something like this (hopefully the ascii art works) +---------- Invoice id=3 -----------+ | Full total: $100.00 | | | | +-----