Re: BUG USING modelformset_factory MODULE

2023-01-24 Thread Michael Maina
Resolved: Using parameters max_num=1, extra=0 https://docs.djangoproject.com/en/3.2/topics/forms/modelforms/#max_num Mea culpa On Sunday, January 22, 2023 at 10:49:01 PM UTC+3 Michael Maina wrote: > Hello, > > > > I have a challenge using the modelformset_factory m

BUG USING modelformset_factory MODULE

2023-01-22 Thread Michael Maina
Hello, I have a challenge using the modelformset_factory module ( https://docs.djangoproject.com/en/3.2/topics/forms/modelforms/) and invite your advice. I can automatically generate a pre-populated webpage with a select dataset from the database, but the generated template creates

Re: two modelformset_factory in one view , both model relates to each other

2021-11-27 Thread namo
please is there any solution ? On Saturday, November 27, 2021 at 2:31:40 PM UTC+3 namo wrote: > Hi , i'm trying to implement two formset in one view , one of the > formsets should be pop up modal form : here is the models > *note : if it requires i'll pay for that task * > > *class MobileCollec

two modelformset_factory in one view , both model relates to each other

2021-11-27 Thread namo
Hi , i'm trying to implement two formset in one view , one of the formsets should be pop up modal form : here is the models *note : if it requires i'll pay for that task * *class MobileCollection(models.Model): * *mobile = models.ForeignKey(ModelCategory,on_delete=models.PROTECT,related_name='m

Re: How to populate fields generated by modelformset_factory with data from database

2020-08-08 Thread Integr@te System
t, I see that I can filter and find the > responses, but how do I get Django to fill the form fields with the > responses? > > Thank you! > > On Friday, August 7, 2020 at 10:24:21 AM UTC-4, Integr@te System wrote: >> >> Hi Michael, >> >> You can read que

Re: How to populate fields generated by modelformset_factory with data from database

2020-08-08 Thread Michael Klassen
ith model in modelformset_factory() method > to get exact user and/or any fields you need as existed instance or base on > cookies or sth like that to identify your user, depend on your use case(ex > trigger events or choose one option...). Hope it helpful. > > > > On Fri, Aug 7, 2020,

Re: How to populate fields generated by modelformset_factory with data from database

2020-08-07 Thread Integr@te System
Hi Michael, You can read queryset combine with model in modelformset_factory() method to get exact user and/or any fields you need as existed instance or base on cookies or sth like that to identify your user, depend on your use case(ex trigger events or choose one option...). Hope it helpful

How to populate fields generated by modelformset_factory with data from database

2020-08-07 Thread Michael Klassen
Hello: I am using modelformset_factory to generate my form based on a model. If the user submits a page, then returns to it later, I would like to populate the fields with what they previously answered. I can only find examples of pre-populated fields with the extra forms; is there a way to

Django modelformset_factory with prefix not scaling

2018-07-08 Thread martinnn2019
Hello, I have been trying to scale modelformset_factory and run into the issue that modelformset_factory is working correctly when I implement with just 2 formsets. Code here: https://gist.github.com/martin1007/6474f3a7f14540bae729e8b4d31f8ca2 But when I try to scale it using lists it does

Modelformset_factory does not save to database

2018-07-05 Thread martinnnn2019
Hello, I am trying to scale multiple modelforms by using modelformset_factory and save them to database to their respective models. Even though code creates different forms for different models but it does not save them to database. The relevant code parts can be found here https

Re: What determines initial number of forms in Django modelformset_factory?

2016-12-28 Thread Duane Gregory
ike to alter that number, but cannot see how. >> view and form for ref: >> >> def micro_log_create(request): >> MicroLogFormSet = modelformset_factory(Micro_Log, form=MicroLogForm, >> max_num=4, extra=0) >> if request.method == 'POST': >> f

Re: What determines initial number of forms in Django modelformset_factory?

2016-12-28 Thread Farhan Khan
7 forms, as seen here: > > value="7" /> type="hidden" value="7" /> > > I would like to alter that number, but cannot see how. > view and form for ref: > > def micro_log_create(request): > MicroLogFormSet = modelformset_factory(Micro_Log

What determines initial number of forms in Django modelformset_factory?

2016-12-28 Thread Duane Gregory
My model formset is producing an initial 7 forms, as seen here: I would like to alter that number, but cannot see how. view and form for ref: def micro_log_create(request): MicroLogFormSet = modelformset_factory(Micro_Log, form=MicroLogForm, max_num=4, extra=0) if request.method

modelformset_factory generating "object has no attribute instance" error

2016-05-14 Thread Farhan Khan
I am trying to display a modelformset_factory in a view, but am running into this error and unable to figure out why. builtins.AttributeError AttributeError: 'IPAddressForm' object has no attribute 'instance' This seems to happen when I include this in my view: {{ ipadd

How to convert modelformset_factory function view to CBV?

2015-12-17 Thread Richard Brockie
= raceday.categories_in_order() formset_cats_in_events = modelformset_factory(model=racereg_models.CategoriesInEvent, form=racereg_forms.CatsInEventForm, extra=0

help with modelformset_factory and createview

2014-05-10 Thread LaPerl
Hello, I'm trying to send a form with modelformset_factory inside a CreateView. For the moment I only have this code inside the CreateView: def get(self, request, *args, **kwargs): self.object = None local_pk = LiveTool.objects.get(pk=self.kwargs[

SOLVED: modelformset_factory not validating multiple forms

2013-08-01 Thread Chris Ryan
t-small' > form.fields['middle_name'].widget.attrs['class'] = 'input-mini' > form.fields['last_name'].widget.attrs['class'] = 'input-small' > > form.fields['state'].widget.attrs['clas

modelformset_factory not validating multiple forms

2013-08-01 Thread Chris Ryan
7;input-mini' form.fields['last_name'].widget.attrs['class'] = 'input-small' form.fields['state'].widget.attrs['class'] = 'input-mini' form.fields['zip_code'].widget.attrs['class']

Re: Question modelformset_factory with initial values

2013-03-08 Thread carlos
s(request): > > initial_one = [{'field2':'one'}, > > {'field2':'two'}, > > {'field2':'three '}, > > {'field2':' four'}, >

Re: Question modelformset_factory with initial values

2013-03-08 Thread Tom Evans
name_views(request): > initial_one = [{'field2':'one'}, > {'field2':'two'}, > {'field2':'three '}, > {'field2':' four'}, >] > fo

Question modelformset_factory with initial values

2013-03-07 Thread carlos
ude = ('field_fk',) -- views.py -- def name_views(request): initial_one = [{'field2':'one'}, {'field2':'two'}, {'field2':'three '}, {'

modelformset_factory

2012-03-09 Thread Xavier Pegenaute
Hi, I am using modelformset_factory and I want to show all the ocurrences of the class Event, but I want to add a field to the fromset. I have this code: forms.py - from django import forms from django.forms.formsets import BaseFormSet class

Re: modelformset_factory instance not saving

2011-05-19 Thread piker
gt; I have a modelformset_factory instance displaying beautifully, but not > > saving to the database. > > If anyone can spot any mistake i've made in the code it would be much > > appreciated.(i'm using Django 1.3 by the way). > > > def warning_entry (request): > >

Re: modelformset_factory instance not saving

2011-05-19 Thread Daniel Roseman
On Wednesday, May 18, 2011 11:46:14 PM UTC+1, piker wrote: > > I have a modelformset_factory instance displaying beautifully, but not > saving to the database. > If anyone can spot any mistake i've made in the code it would be much > appreciated.(i'm using Django

modelformset_factory instance not saving

2011-05-18 Thread piker
I have a modelformset_factory instance displaying beautifully, but not saving to the database. If anyone can spot any mistake i've made in the code it would be much appreciated.(i'm using Django 1.3 by the way). def warning_entry (request): SpeciesFormSet = modelformset_factory(Spec

Re: modelformset_factory, initial, and queryset

2010-10-17 Thread Tim Valenta
> The only thing I can think of is that the choices for the field are > not being set correctly to start with - in the bit where you write > `(choices=[yada yada]`, what is 'yada yada'? Obviously, this must > contain *all* possible values for the codes across all responses, so > that the relevant o

Re: modelformset_factory, initial, and queryset

2010-10-17 Thread Tim Valenta
Sir, I just re-examined my code and realized that the integers I was plugging into `initial` was the wrong value, semantically speaking. IDs from the wrong model were being used for initial values... Simplifying my example for this explanation helped me see that pretty quickly when I pulled my code

Re: modelformset_factory, initial, and queryset

2010-10-17 Thread Daniel Roseman
cessing as I see fit. > > But when it comes time to instantiate my formset, I can't find a way > to pump my own values into this "codes" field on the form.  Here is > the relevant part of the view: >     responses = Response.objects.filter( yada yada) >     Response

Re: modelformset_factory, initial, and queryset

2010-10-15 Thread Tim Valenta
ld gets POSTed back to my view, which I happily read from my form's cleaned_data attribute, processing as I see fit. But when it comes time to instantiate my formset, I can't find a way to pump my own values into this "codes" field on the form. Here is the relevant part of the view:

Re: modelformset_factory, initial, and queryset

2010-10-14 Thread Daniel Roseman
On Oct 14, 10:32 am, Tim Valenta wrote: > This is driving me mad, so I must ask the community, in hopes of a > workaround: > > I've got a simple formset of models on a page, generated by > modelformset_factory.  This particular page will never create forms-- > it only

modelformset_factory, initial, and queryset

2010-10-14 Thread Tim Valenta
This is driving me mad, so I must ask the community, in hopes of a workaround: I've got a simple formset of models on a page, generated by modelformset_factory. This particular page will never create forms-- it only modifies existing ones. Therefore the queryset I pass into the fo

Re: Django 1.2 modelformset_factory fails with meta: widgets

2010-09-01 Thread refreegrata
for > > future reference. Basically you need to specify a formfield_callback > > kwarg to modelformset_factory that just passes along any kwargs it > > receives (namely, in this case, the 'widget' argument) to > > Field.formfield(): > > > d

Re: Django 1.2 modelformset_factory fails with meta: widgets

2010-09-01 Thread Jason
Thanks! I'll give that a try. On Aug 13, 8:55 am, Matthew R wrote: > I got hit by this same bug and here's the workaround I used, for > future reference. Basically you need to specify a formfield_callback > kwarg to modelformset_factory that just passes along any kwargs it >

Re: convert textinput in label or text for a modelform and modelformset_factory

2010-08-16 Thread refreegrata
{{ form.instance.field of the model }} is a way to access. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr.

Re: convert textinput in label or text for a modelform and modelformset_factory

2010-08-16 Thread refreegrata
somebody have an idea ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more option

Re: Django 1.2 modelformset_factory fails with meta: widgets

2010-08-13 Thread Matthew R
I got hit by this same bug and here's the workaround I used, for future reference. Basically you need to specify a formfield_callback kwarg to modelformset_factory that just passes along any kwargs it receives (namely, in this case, the 'widget' argument) to Field.fo

Re: convert textinput in label or text for a modelform and modelformset_factory

2010-08-13 Thread refreegrata
the idea isn't depend of javascript. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. Fo

Re: convert textinput in label or text for a modelform and modelformset_factory

2010-08-13 Thread refreegrata
i'm sorry,but i don't understand the question. the model is only an example. My idea is a model like this: -- class Format(models.Model): code = models.CharField(max_length=10) name = models.CharField(max_length=30

Re: convert textinput in label or text for a modelform and modelformset_factory

2010-08-12 Thread Boguslaw Faja
Hi, fast question: why fields = ['nombre'] instead of fields = ['name2'] ? Best regards On Wed, Aug 11, 2010 at 3:59 PM, refreegrata wrote: > with a model like this: > -- > class Format(models.Model): >    name1 = models.CharField(max_length=5) >    name2 = m

convert textinput in label or text for a modelform and modelformset_factory

2010-08-11 Thread refreegrata
with a model like this: -- class Format(models.Model): name1 = models.CharField(max_length=5) name2 = models.CharField(max_length=5) -- and a modelform like this: - M

Re: Django 1.2 modelformset_factory fails with meta: widgets

2010-07-29 Thread Jason
Can anyone confirm that passing in a form with Meta.widgets set to modelformset_factory() does in fact work? I've tried stripping my code down to the basics and still get the same exception. Debugging Django code doesn't help me because it fails during a lamda function that I d

Re: Django 1.2 modelformset_factory fails with meta: widgets

2010-07-28 Thread Jason
; in manage_articles 174. form = ArticleForm) File "C:\Python25\lib\site-packages\django\forms\models.py" in modelformset_factory 669. formfield_callback=formfield_callback) File "C:\Python25\lib\site-packages\django\forms\models.py"

Re: Django 1.2 modelformset_factory fails with meta: widgets

2010-07-28 Thread Daniel Roseman
CalendarWidget(attrs={'class':'date- > pick'}) >         } > > And in a view function: > ... >     ArticleFormSet = modelformset_factory(Article, >                                           form = ArticleForm, >                                           extra=0) > .

Django 1.2 modelformset_factory fails with meta: widgets

2010-07-28 Thread Jason
a view function: ... ArticleFormSet = modelformset_factory(Article, form = ArticleForm, extra=0) ... Removing 'widgets' from the Meta in ArticleForm fixes the error. The new widgets convention here i

Re: Custom Form in a ModelFormset_Factory?

2010-05-18 Thread Ian Lewis
I'm pretty sure that modelformset_factory is not documented. 2010/5/19 Michael Davis : > Thanks! I found that by looking at the source shortly after I posted > the question. I'm surprised I didn't stumble across that option in the > documentation. Do you have a link t

Re: Custom Form in a ModelFormset_Factory?

2010-05-18 Thread Michael Davis
te: > Pass the form class to modelformset_factory() in the form argument. > The factory will then use the AuthorForm class as the base form class > when it creates the modelform class for the formset. > > modelFormset = modelformset_factory(Author, form=AuthorForm) > > On Tue, M

Re: Custom Form in a ModelFormset_Factory?

2010-05-18 Thread Ian Lewis
Pass the form class to modelformset_factory() in the form argument. The factory will then use the AuthorForm class as the base form class when it creates the modelform class for the formset. modelFormset = modelformset_factory(Author, form=AuthorForm) On Tue, May 18, 2010 at 7:08 AM, Michael

Custom Form in a ModelFormset_Factory?

2010-05-17 Thread Michael Davis
I am new to Django and am trying to get a custom modelForm to work in a ModelFormset_factory. For example: class Author(models.Model): name = models.CharField() address = models.CharField() -- You received this message because you are subscribed to the Google Groups "Django

Custom Form in a ModelFormset_Factory?

2010-05-17 Thread Michael Davis
I am new to Django and am trying to get a custom modelForm to work in a ModelFormset_factory. For example: # in models.py class Author(models.Model): name = models.CharField() address = models.CharField() phone = models.CharField() class AuthorForm(ModelForm): class Meta

Re: Odd problem with modelformset_factory, a missing field

2009-11-16 Thread Malcolm MacKinnon
in my template below. > {{form.m}}. When I do not exclude='prim', the field {{form.m}} is rendered > perfectly. In my view i have defined my formset as: > > Transpecform = modelformset_factory(Sotranspec, max_num=16, extra=16, > exclude='prim') > > Her

Re: Strange error using modelformset_factory

2008-12-18 Thread marty3d
t; > > Hi! > > > > > I've been stuck with this for some days now, and can't find any > > > > answers whatsoever. Please bare with me since I'm a newbie with Python/ > > > > Django. > > > > (English nitpick: the word is bear

Re: Strange error using modelformset_factory

2008-12-18 Thread alex.gay...@gmail.com
. > > > (English nitpick: the word is bear, not bare, that you're looking for in > > that idiom.) > > > > I have this form that's created and populated using > > > 'modelformset_factory'. What it's supposed to do is to > > > 1.

Re: Strange error using modelformset_factory

2008-12-18 Thread marty3d
; > Django. > > (English nitpick: the word is bear, not bare, that you're looking for in > that idiom.) > > > > > I have this form that's created and populated using > > 'modelformset_factory'. What it's supposed to do is to > > 1. show

Re: Strange error using modelformset_factory

2008-12-17 Thread Karen Tracey
hat you're looking for in that idiom.) > > I have this form that's created and populated using > 'modelformset_factory'. What it's supposed to do is to > 1. show a number of sets so the user can add several at one time. Also > show the added ones, with the p

Re: Strange error using modelformset_factory

2008-12-17 Thread Daniel Roseman
On Dec 17, 12:49 pm, marty3d wrote: > Hi! > > I've been stuck with this for some days now, and can't find any > answers whatsoever. Please bare with me since I'm a newbie with Python/ > Django. > > I have this form that's created and populated using >

Strange error using modelformset_factory

2008-12-17 Thread marty3d
Hi! I've been stuck with this for some days now, and can't find any answers whatsoever. Please bare with me since I'm a newbie with Python/ Django. I have this form that's created and populated using 'modelformset_factory'. What it's supposed to do is to 1. sh

Re: modelformset_factory error: (Hidden field id) with this None already exists.

2008-12-08 Thread Karen Tracey
t; > Lastly, I've simplified my code producing the problem: > > > > > my model: > > > > > class StatusReport(models.Model): > > > vehicle = models.IntegerField() > > > report_date = models.DateField() > > > status= models.CharF

Re: modelformset_factory error: (Hidden field id) with this None already exists.

2008-12-08 Thread cyberjack
> > Lastly, I've simplified my code producing the problem: > > > my model: > > > class StatusReport(models.Model): > >   vehicle       = models.IntegerField() > >   report_date   = models.DateField() > >   status        = models.CharField(max_length=10) > > > and my

Re: modelformset_factory error: (Hidden field id) with this None already exists.

2008-12-04 Thread Karen Tracey
(request, vehicle_id): >limited_reports = StatusReport.objects.filter(vehicle=vehicle_id) > >StatusFormSet = modelformset_factory(StatusReport, extra=0) >if request.method == 'POST': >formset = StatusFormSet(request.POST) > i

Re: modelformset_factory error: (Hidden field id) with this None already exists.

2008-12-03 Thread cyberjack
port_date = models.DateField() status= models.CharField(max_length=10) and my view: def detail(request, vehicle_id): limited_reports = StatusReport.objects.filter(vehicle=vehicle_id) StatusFormSet = modelformset_factory(StatusReport, extra=0) if request.method == 'POS

modelformset_factory error: (Hidden field id) with this None already exists.

2008-12-02 Thread cyberjack
this week reports = StatusReport.objects.filter( vehicle__exact=vehicle_id ).filter( date__gte = week_start ).filter( date__lte = week_end ).order_by("date") ReportFormSet = modelformset_factory(StatusReport, extra=0) if request.met

modelformset_factory or formset_factory for registration form that writes to two models?

2008-09-18 Thread MrJogo
Hi, I want to make a registration form that writes to two models: User and a custom Preferences. It seems that model formsets would be the best way to do that, but all the documentation I can find seems to say that modelformset_factory gets associated with a queryset. If I want to create a new