On 2013-08-21, at 7:25 AM, Gerd Koetje <deonlinefotogr...@gmail.com> wrote:

> He Thomas, ur right i didnt explain myself very well.
> 
> 
> What im trying todo is this.
> 
> I have a mode that holds all my form field values in difrant group , name: 
> Keuzes  
> Now i want to populate multiple form fields with these values based on wich 
> groep i want them to be.
> I onloy seem to get this to work if i make a difrant model for each field, 
> cant i just use 1 model with a group field and select the value bases on the 
> group i ask for?
> 
> I think im still a bit confused what i should do i models and what i should 
> do in forms.
> 

Models set up the relationships and forms pull those together for presentation 
or manipulation. I think ;)

So now I'm not sure what you are asking for. Perhaps I could understand from 
the names you have chosen for fields and models, but I am still uncertain.

So you have a set of possible field values, and want to be able to group those 
into different sets for a form, right?

class FieldValues(models.Model):
  name = CharField()
  pass

class FieldGroups(models.Model):
  group_name = CharField()
  values = ManyToManyField(FieldValues, related_name="groups")
  pass

Unless I've got myself turned around, I think you can access fields from the 
groups model and groups from the fields model. Something like

MyGroups = FieldGroups.objects.all()
MyFields = FieldValues.objects.filter(groups__group_name="the group I want")

hth

                  - Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to