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
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
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
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
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
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'
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
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
> 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
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,
>
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
>
> >> 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
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.
[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
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
--~--~-~--~~~--
> 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
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
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
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
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
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
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
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
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
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)
>...
. 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
44 matches
Mail list logo