Wednesday, November 2, 2011

Django + Ajax/Javascript

Hi,

I have the following model layout:

class A(models.model):
options = models.ManyToManyField(OptionSet, blank=True, null=True)
values = models.ManyToManyField(Value, blank=True, null=True)

class OptionSet(models.model):
name = models.TextField(unique=True)
values = models.ManyToManyField(Value)

def __unicode__(self):
return '%s' % self.name

class Value(models.Model):
name = models.TextField()
key = models.ForeignKey(Key, related_name='values')

class Key(models.Model):
name = models.TextField(unique=True)

And my forms.py looks like this:

class A_Form(ModelForm):
values =
forms.ModelMultipleChoiceField(queryset=Value.objects.all(),
widget=CheckboxSelectMultiple, label="Einzelne Werte", required=False)
options =
forms.ModelMultipleChoiceField(queryset=OptionSet.objects.all(),
widget=CheckboxSelectMultiple, label="Optionen Sets", required=False)

Template:

<form action="." method="POST">{% csrf_token %}
{{ form.as_table }}
<input type="submit" value="Update"/>
</form>

I use that form with a generic update view! I'm new to javascript/ajax
to be honest never did something in javascript/ajax. What I want to do
is on mouseover on the options name it should show all the values for
that option set. How would one accomplish this (either with or without
ajax)?

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment