ModelAdmin dynamic fields

2016-07-14 Thread Bernat Bonet
I need to add dynamic fields to ModelAdmin fieldset that are not part of Model. This field is to show or hide certain fields. How can I do this? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this grou

Re: Form wizard and dynamic fields

2012-07-07 Thread Leandro Alves
Does anyone have any advice please? :) Thanks, Leandro On 7. juli 2012, at 02:33, Leandro Alves wrote: > Hello, > > I'm starting to use Django now and I would need some orientations in order to > create a Form Wizard. > > The idea is simple: > > The first form will contain only one field

Form wizard and dynamic fields

2012-07-06 Thread Leandro Alves
Hello, I'm starting to use Django now and I would need some orientations in order to create a Form Wizard. The idea is simple: - The first form will contain only one field to type the name of a directory. - The content of the second form, will depend on the directory name that wa

Form wizard and dynamic fields

2012-07-06 Thread Leandro Alves
Hello, I'm starting to use Django now and I would need some orientations in order to create a Form Wizard. The idea is simple: The first form will contain only one field to type the name of a directory. The content of the second form, will depend on the directory name that was entered and the

Re: Tough finding a form with dynamic fields out there

2012-05-30 Thread Mario Gudelj
Daniel has point out the issue, but have a look at this speech from Django Con last year http://blip.tv/djangocon/advanced-django-form-usage-5573287. It has some great stuff in there. -m On 31 May 2012 06:14, Daniel Roseman wrote: > So, compare this: > > > def __init__(self, mailboxes, *arg

Re: Tough finding a form with dynamic fields out there

2012-05-30 Thread Daniel Roseman
So, compare this: def __init__(self, mailboxes, *args, **kwargs): > with how you're calling it: > form = MboxReg(request.POST, int(mailboxes)) > > and you should see why you're getting this: > Error: > Exception Value: > > int() argument must be a string or a number, not 'QueryDict'

Tough finding a form with dynamic fields out there

2012-05-30 Thread Michael da Silva Pereira
Hi, Trying a form with dynamic fields, but having no luck. Also not finding any working examples out there :/ This is what I'm currently trying to use: class MboxReg(forms.Form): def __init__(self, mailboxes, *args, **kwargs): super(MboxReg, self).__init__(*args, **k

Dynamic Fields and Saving data per user

2010-12-13 Thread Dan
I am trying to make an app where each user will have like a mailing list for which they should be-able to create custom fields for any data they may want to hold and be able to save multiple rows of that data. I was thinking to use a model to hold the fields definitions and a key value system to h

Re: Forms with dynamic *fields*

2009-03-02 Thread Alex Gaynor
> This method has worked for me so far, I doubt that it would be > recommended for anything resembling a high volume site. > > Greg > > On Mar 2, 5:28 am, Martin Winkler wrote: > > Hi all, > > > > I want to create a form with dynamic fields. That is, I want to

Re: Forms with dynamic *fields*

2009-03-02 Thread GRoby
eld (required=False, widget=forms.TextInput(attrs={'size':'2.5'})) . return Dict This method has worked for me so far, I doubt that it would be recommended for anything resembling a high volume site. Greg On Mar 2, 5:28 am, Martin Winkler wrote: > Hi all, >

Forms with dynamic *fields*

2009-03-02 Thread Martin Winkler
Hi all, I want to create a form with dynamic fields. That is, I want to add the fields using the __init__ method of my form: 1 class MyForm(forms.Form): 2 def __init__(self, fieldnames=(), *args, **kw): 3 for fieldname in fieldnames: 4 self.XXXfieldnameXXX

Re: Are Dynamic fields possible?

2009-01-03 Thread Matias Surdi
I've done it, although it was not a trivial task. This helped me a lot: http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/ Xan wrote: > Hi, > > I just want to know if django support dynamic fields, that is the > option of not specied the type of field in the model and

Are Dynamic fields possible?

2009-01-03 Thread Xan
Hi, I just want to know if django support dynamic fields, that is the option of not specied the type of field in the model and that user could specify in application. I think for examples about an application for doing notes. In one note, one want to have: title, body, media, etc. but the

Re: Help with Forms (Dynamic Fields) - SOLVED

2008-07-16 Thread Srik
Solved On Jul 16, 3:39 pm, Srik <[EMAIL PROTECTED]> wrote: > Thanks Jeff. > > I also realized there is a provision to pass nested tuple like choices > to form while initalizing using field_list (Not documented but found > in django testing documents) > > http://code.djangoproject.com/browser/djan

Re: Help with Forms (Dynamic Fields) - SOLVED (Request to update documentation if possible)

2008-07-16 Thread Srik
Thanks Jeff. I also realized there is a provision to pass nested tuple like choices to form while initalizing using field_list (Not documented but found in django testing documents) http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/forms.py (lines 715 - 797 ) Thank

Re: Help with Forms (Dynamic Fields)

2008-07-16 Thread Jeff FW
In __init__, where you call form.Form's __init__, you need to pass data, *not* None. Also, you shouldn't try to duplicate all of the arguments. This should work better: def __init__(self, cat_slug, data=None, *args, **kwargs): forms.Form.__init__(self, data=data, *args, **kwargs) Also, I'm

Re: Help with Forms (Dynamic Fields)

2008-07-16 Thread Srik
Hi Jeff, I did try to move __init__ but the problem still exists. I tried to keep title and email along with other fields so that they will be appear in same order in Form. class MyForm(forms.Form): def __init__(self, cat_slug, data=None, files=None, auto_id='id_%s', prefix=None, initi

Re: Help with Forms (Dynamic Fields)

2008-07-15 Thread Jeff FW
You have to pass the data into the form when instantiating it, eg: form = MyForm(request.POST) However, that means (for your example), the fields wouldn't exist yet-- move them into __init__ instead. Some other things to note: you don't need to "title" and "email" to the form dynamically--might

Help with Forms (Dynamic Fields)

2008-07-15 Thread Srik
Hi Djangoers, I'm trying to generate a form dynamically using MyForm (Form class), but I'm stuck with validating or populating data. Form Class, View and template Code here: http://dpaste.com/65080/ (not too many lines I guess :) ) Good thing is I can see form (generating dynamically, based on

Re: dynamic fields

2007-12-03 Thread Marty Alchin
On 12/3/07, omat <[EMAIL PROTECTED]> wrote: > In the actual case I have more fields in the Record model, and > repeating those fields in the Review model is not DRY. Ah, I see now. Using just "a" "b" and "c", I didn't realize they actually mapped directly to the other model. > If I create a mode

Re: dynamic fields

2007-12-03 Thread omat
In the actual case I have more fields in the Record model, and repeating those fields in the Review model is not DRY. If I create a model with "new" and "comment" and relate it to the Review, what would be the type of the field of the "new"? I want them to be, say, DateField for date fields, and

Re: dynamic fields

2007-12-03 Thread Marty Alchin
I'm a bit confused as to what you're actually trying to accomplish here. Will there always only be three fields (a, b and c), or will they actually be dynamic (and you could have many of them). If three is just an arbitrary number, I think you're looking at creating a new Model, containing "new" a

dynamic fields

2007-12-03 Thread omat
Hi all, I have two models, such that, one holds a record, and the other holds reviews on that record, if any. The (simplified) models look like this: class Record(models.Model): a = models.CharField(max_length=10) b = models.DateField() c = models.IntegerField() class Review(models

Re: dynamic fields in models

2007-06-05 Thread Lic. José M. Rodriguez Bacallao
problem resolved, here is how I did it, just a little change to my original code, setattr by add_to_class, with this, I can add common attributes to a lot of models without having to inherit more than once or having a base class for all of them, beside, it just create one table, not two: def commo

Re: dynamic fields in models

2007-06-05 Thread Lic. José M. Rodriguez Bacallao
problem resolved, here is how I did it, just a little change to my original code, setattr by add_to_class, with this, I can add common attributes to lot of models without having to inherit more than once or having a base class for all my models : def common_attrs(cls, common): attrs = dir(comm

Re: dynamic fields in models

2007-06-05 Thread Branton Davis
Cool! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more

Re: dynamic fields in models

2007-06-04 Thread Malcolm Tredinnick
On Mon, 2007-06-04 at 18:36 -0400, Lic. José M. Rodriguez Bacallao wrote: > hi people, I want to do a little thing, I want to add fields > dynamically to a model so when I run python manage.py syncdb, > those fields get added to the database table, for example: > > def common_attrs(cls, comm

Re: dynamic fields in models

2007-06-04 Thread sansmojo
syncdb will not automatically add new fields in a model. You have to add the new fields to the database yourself. 'python manage.py sql' will give you the new sql statements to recreate your models, and you can pick out the part regarding your new fields. Also, if you don't care about existing

dynamic fields in models

2007-06-04 Thread Lic. José M. Rodriguez Bacallao
hi people, I want to do a little thing, I want to add fields dynamically to a model so when I run python manage.py syncdb, those fields get added to the database table, for example: def common_attrs(cls, common): attrs = dir(common) for attr in attrs: if isinstance( getattr(co

Re: Newforms - Dynamic Fields from a queryset

2007-03-16 Thread Tipan
> > >> number_of_meds = kwargs.pop('number_of_meds', 4) > > This is how I optionally passed the number of > fields I wanted to display in the form. If there's > no 'number_of_meds' in kwargs, a minimum of 4 fields > are displayed. The trick is to use kwargs.pop() before > super is called, or you

Re: Newforms - Dynamic Fields from a queryset

2007-03-15 Thread Rubic
On Mar 15, 12:30 pm, "Tipan" <[EMAIL PROTECTED]> wrote: > Realised my daft error in creating the dictionary. I've resolved that > now and can happily pass the queryset data to the Form class by > creating the dict. However, I'm still not sure how to pass the number > of records to the Form class.

Re: Newforms - Dynamic Fields from a queryset

2007-03-15 Thread Rubic
[reference: http://www.djangosnippets.org/snippets/82 ] Tipan, >From your code I think you may be confusing a dictionary key with a list index. > data_list=UserPoints.objects.filter(user = myuser) > for i in data_list: > k='type_%d' % i > l='points_%d' % i Note in line #28 how I'm defi

Re: Newforms - Dynamic Fields from a queryset

2007-03-15 Thread Tipan
Realised my daft error in creating the dictionary. I've resolved that now and can happily pass the queryset data to the Form class by creating the dict. However, I'm still not sure how to pass the number of records to the Form class. Can you advise? Tim --~--~-~--~~~--

Re: Newforms - Dynamic Fields from a queryset

2007-03-15 Thread Tipan
> I've posted a code snippet that I think addresses your > issue:http://www.djangosnippets.org/snippets/82/ > Jeff, this was very helpful and I've moved on a bit, I can make your form do exactly what it's supposed to. Howver I'm still struggling to pass my information to the Form class. I note t

Re: Newforms - Dynamic Fields from a queryset

2007-03-14 Thread Rubic
Tipan, I've posted a code snippet that I think addresses your issue: http://www.djangosnippets.org/snippets/82/ -- Jeff Bauer Rubicon, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To

Newforms - Dynamic Fields from a queryset

2007-03-14 Thread Tipan
I wonder if anyone can give me some pointers. I've been working with new forms with reasonable results, but I've come across a problem when creating a form with dynamic fields and rendering to an HTML template. I want to create a form using data from a queryset which extracts data for

Re: rendering dynamic fields in newforms

2007-02-18 Thread Rubic
On Feb 18, 12:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Looks like you are rendering out the form class itself rather than an > instance of the form. Monster, Thanks, but Honza had the correct reply. I need to access the individual fields in the template, and BoundField is the way

Re: rendering dynamic fields in newforms

2007-02-18 Thread [EMAIL PROTECTED]
f.fields[k]) def test(request): Form = MedForm() return HttpResponse(Form.as_p()) (example .py file at http://www.pukkapeople.com/django/how-to-s/django_newforms.py/ ) On Feb 17, 4:22 am, "Rubic" <[EMAIL PROTECTED]> wrote: > Hi, I'm the 985th person to at

Re: rendering dynamic fields in newforms

2007-02-17 Thread Honza Král
ED]> wrote: > > Hi, I'm the 985th person to attempt dynamic fields > in newforms. ;-) > > Actually I've been able to do lots of dynamic stuff > in newforms. It's rendering the forms in templates > that sometimes confuses me. For example, given > the

rendering dynamic fields in newforms

2007-02-16 Thread Rubic
Hi, I'm the 985th person to attempt dynamic fields in newforms. ;-) Actually I've been able to do lots of dynamic stuff in newforms. It's rendering the forms in templates that sometimes confuses me. For example, given the following code to build a form based on an arbi

Re: Newforms dynamic fields (good to know)

2007-01-25 Thread Felix Ingram
On 25/01/07, Håkan Johansson <[EMAIL PROTECTED]> wrote: > > On 20 jan 2007, at 17:36, [EMAIL PROTECTED] wrote: > > > > Håkan Johansson wrote: > > > >> While working on a complex form using 'newforms' I had some problem > >> with 'initial' data. > >> I have multiple forms using the 'prefix' argumen

Re: Newforms dynamic fields (good to know)

2007-01-25 Thread Håkan Johansson
ct >>>>> class DaForm(forms.Form): >>... def __init__(self, obj, *args, **kw): >>... super(DaForm, self).__init__(*args, **kw) >>... self.fields = SortedDict() >>... self.fields['time'] = forms.Time

Re: Newforms dynamic fields (good to know)

2007-01-20 Thread [EMAIL PROTECTED]
ect: >>>> import django.newforms as forms >>>> from django.utils.datastructures import SortedDict >>>> class DaForm(forms.Form): >... def __init__(self, obj, *args, **kw): >... super(DaForm, self).__init__(*args, **kw) >...

Newforms dynamic fields (good to know)

2007-01-04 Thread Håkan Johansson
. def __init__(self, obj, *args, **kw): ... super(DaForm, self).__init__(*args, **kw) ... self.fields = SortedDict() ... self.fields['time'] = forms.TimeField(initial=obj.time) ... self.fields['name'] = forms.CharField(initial=obj.n