Re: FieldError: Cannot resolve keyword u'domain' into field. Choices are: children, content, date_create, date_update, domain__associations, id, level, lft, name, parent, parent_id, rght, tree_id, use

2016-05-17 Thread François GUÉRIN
Thanks very very very much !

Le mardi 17 mai 2016 14:51:05 UTC+2, Michal Petrucha a écrit :
>
> On Tue, May 17, 2016 at 05:44:24AM -0700, François GUÉRIN wrote: 
> > Hi all, 
> > 
> > I'm a django application dev for a few years, so I'm pretty familiar 
> with 
> > it. I have a problem with a new django 1.9.6 application. I'm writing a 
> > directory app, with a main model named "Association", which have 4 m2m 
> > related fields : 
> > 
> > 
> > class Association(models.Model): 
> > # ... other fields ... 
> > 
> > #: Activity domains. 
> > #: note:: An association **MUST** have at least 1 activity, it can 
> have some more. 
> > domains = models.ManyToManyField(Domain, verbose_name=_('domains'), 
> related_name='domain__associations') 
> > 
> > #: Targeted age groups 
> > target_groups = models.ManyToManyField(TargetGroup, 
> verbose_name=_('target groups'), 
> >blank=True, 
> related_name='target_group__associations') 
> > 
> > #: Locations where the activities of the association can take places 
> > locations = models.ManyToManyField(Location, 
> verbose_name=_('locations'), 
> >blank=True, 
> related_name='location__associations') 
> > 
> > #: Affiliations 
> > affiliations = models.ManyToManyField(Affiliation, 
> verbose_name=_('affiliations'), blank=True, 
> >   
> related_name='affiliation__associations') 
> > 
> > 
> > When I try to access to related data; I always have (aka, for each 
> related 
> > field) a Field Error exception, has given in title. The keyword allways 
> > asks for the field name in the relation table, and the field list 
> displayed 
> > are from the target table of the relation. Trlated tables are pretty 
> simple 
> > (name, description), but domain is a mptt table. 
> > 
> > With factory_boy, I can create new `Association` items and insert new 
> > relations to my related items, but I can't display them. 
> > 
> > I'm stuck with this problem for a few days, that why I ask... I really 
> > don't see what I didn't do... or understand ! 
> > 
> > Thanks for your help ! 
>
> Hi François, 
>
> At a quick glance, it seems the error is that you put double 
> underscores into related_names. That cannot work, because 
> related_names should follow the same restrictions as regular field 
> names, and field names cannot contain double underscores, since Django 
> uses those to separate fields when traversing relations. 
>
> Cheers, 
>
> Michal 
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f65016e9-cab6-4b6b-82e1-f9d2c600bf59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: FieldError: Cannot resolve keyword u'domain' into field. Choices are: children, content, date_create, date_update, domain__associations, id, level, lft, name, parent, parent_id, rght, tree_id, use

2016-05-17 Thread François GUÉRIN
Argh !! It works ! We could use double underscores in relation names, 
before, no ?

Le mardi 17 mai 2016 14:51:05 UTC+2, Michal Petrucha a écrit :
>
> On Tue, May 17, 2016 at 05:44:24AM -0700, François GUÉRIN wrote: 
> > Hi all, 
> > 
> > I'm a django application dev for a few years, so I'm pretty familiar 
> with 
> > it. I have a problem with a new django 1.9.6 application. I'm writing a 
> > directory app, with a main model named "Association", which have 4 m2m 
> > related fields : 
> > 
> > 
> > class Association(models.Model): 
> > # ... other fields ... 
> > 
> > #: Activity domains. 
> > #: note:: An association **MUST** have at least 1 activity, it can 
> have some more. 
> > domains = models.ManyToManyField(Domain, verbose_name=_('domains'), 
> related_name='domain__associations') 
> > 
> > #: Targeted age groups 
> > target_groups = models.ManyToManyField(TargetGroup, 
> verbose_name=_('target groups'), 
> >blank=True, 
> related_name='target_group__associations') 
> > 
> > #: Locations where the activities of the association can take places 
> > locations = models.ManyToManyField(Location, 
> verbose_name=_('locations'), 
> >blank=True, 
> related_name='location__associations') 
> > 
> > #: Affiliations 
> > affiliations = models.ManyToManyField(Affiliation, 
> verbose_name=_('affiliations'), blank=True, 
> >   
> related_name='affiliation__associations') 
> > 
> > 
> > When I try to access to related data; I always have (aka, for each 
> related 
> > field) a Field Error exception, has given in title. The keyword allways 
> > asks for the field name in the relation table, and the field list 
> displayed 
> > are from the target table of the relation. Trlated tables are pretty 
> simple 
> > (name, description), but domain is a mptt table. 
> > 
> > With factory_boy, I can create new `Association` items and insert new 
> > relations to my related items, but I can't display them. 
> > 
> > I'm stuck with this problem for a few days, that why I ask... I really 
> > don't see what I didn't do... or understand ! 
> > 
> > Thanks for your help ! 
>
> Hi François, 
>
> At a quick glance, it seems the error is that you put double 
> underscores into related_names. That cannot work, because 
> related_names should follow the same restrictions as regular field 
> names, and field names cannot contain double underscores, since Django 
> uses those to separate fields when traversing relations. 
>
> Cheers, 
>
> Michal 
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0c762479-2e01-49cb-bbbc-2b90257f8335%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


FieldError: Cannot resolve keyword u'domain' into field. Choices are: children, content, date_create, date_update, domain__associations, id, level, lft, name, parent, parent_id, rght, tree_id, user_cr

2016-05-17 Thread François GUÉRIN
Hi all, 

I'm a django application dev for a few years, so I'm pretty familiar with 
it. I have a problem with a new django 1.9.6 application. I'm writing a 
directory app, with a main model named "Association", which have 4 m2m 
related fields :


class Association(models.Model):
# ... other fields ...

#: Activity domains.
#: note:: An association **MUST** have at least 1 activity, it can have 
some more.
domains = models.ManyToManyField(Domain, verbose_name=_('domains'), 
related_name='domain__associations')

#: Targeted age groups
target_groups = models.ManyToManyField(TargetGroup, verbose_name=_('target 
groups'),
   blank=True, 
related_name='target_group__associations')

#: Locations where the activities of the association can take places
locations = models.ManyToManyField(Location, verbose_name=_('locations'),
   blank=True, 
related_name='location__associations')

#: Affiliations 
affiliations = models.ManyToManyField(Affiliation, 
verbose_name=_('affiliations'), blank=True,
  related_name='affiliation__associations')


When I try to access to related data; I always have (aka, for each related 
field) a Field Error exception, has given in title. The keyword allways 
asks for the field name in the relation table, and the field list displayed 
are from the target table of the relation. Trlated tables are pretty simple 
(name, description), but domain is a mptt table.

With factory_boy, I can create new `Association` items and insert new 
relations to my related items, but I can't display them.

I'm stuck with this problem for a few days, that why I ask... I really 
don't see what I didn't do... or understand !

Thanks for your help !

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/706f485f-5b6e-4cbc-bd59-a50765f6d2aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


model form and inlinemodelforset in a wizard

2015-04-21 Thread François GUÉRIN
Hi, 

I'm currently using django 1.8 with django-formtools 1.0, I only use CBV.

I'm trying to build a wizard for a `Manifestation` model. 

Each instance of `Manifestation` can have many Representations, which are 
basically a place and a start date, using a ForeignKey to the Manifestation 
instance.

My whole wizard is about those 2 models.

I can actually build the first forms of the wizard, based on ModelForm 
class, each form has model=models.Manifestation in its Meta class.
I want to use an inlineformset in one of them.
I've done tests without the formset, and data in saved to db an the end of 
wizard, which is OK.

That is my form : 

class ManifestationWizardForm4(BetterModelForm): # BetterModelForm 
implements fieldsets grouping for modeform
"""
`representation_formset` form
"""

class Meta:
model = models.Manifestation
fieldsets = [('infos', {'legend': u"Récapitulatif", 'fields': 
('champ_artistique', 'titre', 'evenement')}),
 # ('formset', {'legend': u'Représentations', 'fields': 
('formset',) }),
 ]
widgets = {'champ_artistique': u_widgets.ReadOnlySelect,
   'titre': u_widgets.ReadOnlyTextInput,
   'evenement': u_widgets.ReadOnlySelect, }

formset = RepresentationManifestationFormSet()

As viewed in a post form this forum, I add my inlineformset as an attribute 
of the form, I can display the (empty) whole form.
I've changed my form template to display the formset, it works perfectly.

I've questions about this :

* How can I get data from session to the `Manifestation` instance ? I would 
like to use kind on .save(commit=False) to UPDATE the 
`Manifestation` instance with data contained in the ModelForm, before 
saving with commit=True at the end of the wizard. I don't know where to put 
this...

* How to display my instance data in the *main* form ?
* how to initialize my formset with the `Manifestation` instance ? 

Thanks for your help !

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/17a69230-95c4-4e4b-9ef5-113fa6eeda94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Hidden fields in formsets

2015-03-31 Thread François GUÉRIN
Hi, 

I'm using multiple formsets in Create / Update views, and I want to set 
some *hidden* fields in it : user_create, date_create on creation, 
user_update, date_update on update.

I've created a MultiFormsetMixin, which provide machinery to initialize 
those formsets in my CreateView / UpdateView. 
Basicaly, the mixin fill a formset_list containing dicts with {'formset': 
, 'name': , 'verbose_name': }... The rendering of the formsets uses the same rendering than 
'normal' formsets, via a {%for formset in formset_list %}{# formset 
rendering #}[% endfor %}. The formsets display normaly.

Data initialization is performed through the 'initial' dict. Every forms in 
the formsets have the same values for those fields, at initialization, so I 
update each form of the formsets with those values.

My problem is that those hidden fields are not rendered in the template, 
even in a 'hidden_field'. I've tryed to set 'exclude' and 'hidden_fields' 
Meta option in my ModelForm object, but it doesn't work.

When I go through the 'form.hidden_fields' I have my formset administrative 
normal data (id, parent) but not my fields.

Is it possible to render those fields in the template ?

Thanks !

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/13de9082-3dd5-4b3c-bb72-7393e3f0884c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple Django Forms

2015-03-31 Thread François GUÉRIN
Hi Stephanie, 

Maybe you are french ? I'm sorry, but I've no time to make a screencast 
video. But the django doc is very good and in multiple languages : french 
is available if you change /en/ > /fr/ in the doc url.

1/ For generic views : 
https://docs.djangoproject.com/en/1.7/topics/class-based-views/

2/ For formsets : 
https://docs.djangoproject.com/en/1.7/topics/forms/formsets/

3/ For templates, you'd better to get a custom base_form.html. I use this 
one : 

https://gist.github.com/frague59/5c5450bf4d02643bc547

The code snippets depends on other templates, but they are not difficult to 
figure out.

Bye and good luck 
François

Le lundi 30 mars 2015 19:43:50 UTC+2, Stephanie Socias a écrit :
>
> Thank you for your suggestions!
>
> Unfortunately, as I am very green at the moment, I nee more help to 
> implement all of these new techniques. Given that what I'm trying to 
> accomplish requires more extensive Django and javascript knowledge, is 
> there anyone who would be willing to do a video screen share with me to 
> help me out?? I can pay you!
>
> Thank you,
> Stephanie
>
> On Monday, March 30, 2015 at 7:47:48 AM UTC-4, François GUÉRIN wrote:
>>
>> 1/ use generic views : ProcessFormView by example
>> 2/ use prefixes in your forms with there name (it's a param in form cctor)
>> 3/ in your template, use the {%for form in forms %}{% form.as_p 
>> %}{%endfor %} if you put your forms into a 
>> list form forms
>>
>> Good coding !
>>  
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f7f76f5b-e5ac-4040-8e50-9cc62f989fdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: FK relations hell : help with `_set` feature

2015-03-30 Thread François GUÉRIN


Le lundi 30 mars 2015 14:31:19 UTC+2, Daniel Roseman a écrit :
>
>
> On Monday, 30 March 2015 13:04:00 UTC+1, François GUÉRIN wrote:
>>
>> Hi all, 
>>
>> I'm using django for a couple of years, and I've a question about 
>> relations in the ORM and templates. I massively use class-based generic 
>> views.
>>
>> I' currently working with a model which have many other models FKing to 
>> it : 
>>
>>
>> class People(models.Model):
>> last_name = models.CharField(max_length=255)
>> ... other fields ...
>>
>> class PhoneNumber(models.Model):
>> people = models.ForeignKey("my_app.People")
>> number = models.CharField(max_length=255)
>> ... other fields ...
>>
>> According to documentation, it is possible to use a `People.phonenumber
>> _set` attribute from a people instance, queryset'ing related phone 
>> numbers from people.
>>
>> in may template "myapp/people_detail.html", when I query this attribute 
>> from my template, by using {% for phonenumber in object.phonenumber
>> _set.all %}[% endfor %}, I do not any phone number... 
>>
>> When I step -to-step debug the application, I can see a 
>> "myapp_phonenumber_related" related manager, but no phonenumber_set.
>>
>> Do I miss something ?
>>
>> Thanks for your great job...
>>
>>
>>
> You don't seem to be giving all the information here. If you have a  
> `myapp_phonenumber_related` 
> manager, that can only be because you've set that explicitly as the 
> `related_name` attribute of the ForeignKey. And having done so, that's what 
> you should be using in place of `phonenumber_set` anyway.
> --
> DR.
>

OK, it's working !

Thanks again !
FG. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f6732dca-1fe8-4eba-ae27-95019c041329%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


FK relations hell : help with `_set` feature

2015-03-30 Thread François GUÉRIN
Hi all, 

I'm using django for a couple of years, and I've a question about relations 
in the ORM and templates. I massively use class-based generic views.

I' currently working with a model which have many other models FKing to it 
: 


class People(models.Model):
last_name = models.CharField(max_length=255)
... other fields ...

class PhoneNumber(models.Model):
people = models.ForeignKey("my_app.People")
number = models.CharField(max_length=255)
... other fields ...

According to documentation, it is possible to use a `People.phonenumber_set` 
attribute from a people instance, queryset'ing related phone numbers from 
people.

in may template "myapp/people_detail.html", when I query this attribute 
from my template, by using {% for phonenumber in object.phonenumber_set.all 
%}[% endfor %}, I do not any phone number... 

When I step -to-step debug the application, I can see a 
"myapp_phonenumber_related" related manager, but no phonenumber_set.

Do I miss something ?

Thanks for your great job...


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a5b2a2a5-1385-48bb-a738-6e65b3a9106c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple Django Forms

2015-03-30 Thread François GUÉRIN
1/ use generic views : ProcessFormView by example
2/ use prefixes in your forms with there name (it's a param in form cctor)
3/ in your template, use the {%for form in forms %}{% form.as_p 
%}{%endfor %} if you put your forms into a 
list form forms

Good coding !
 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/daaed196-1642-41f2-a324-b0f6d7dd704e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.