RE: BaseModelFormSet > _construct_form

2019-04-03 Thread Matthew Pava
You may want to consider using the django-angular 
(https://github.com/jrief/django-angular) package and reading this question:
https://stackoverflow.com/questions/32978137/using-formsets-in-django-angular

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Nikolay Smirnov
Sent: Wednesday, April 3, 2019 1:53 AM
To: Django users
Subject: Re: BaseModelFormSet > _construct_form

I override add_prefix because on client side I use angularjs. In some cases it 
is impossible or not easy to use hyphens in the names.

I do not overwrite _construct_form! That was just a possibility to solve that. 
But at the moment, I see no other options for solving that.

I find it personally that generating variable pk_key within the _construct_form 
is a bad practice. And becomes not compatible with generating form field ID's 
and -field names.

On Tuesday, 2 April 2019 23:15:15 UTC+2, Matthew Pava wrote:
Why are overwriting add_prefix? Why are you overwriting _construct_form?

From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of nikolaysm
Sent: Tuesday, April 2, 2019 9:37 AM
To: Django users
Subject: BaseModelFormSet > _construct_form

Hello,

In function _construct_form variable "pk_key" is generated as:
 pk_key = "%s-%s" % (self.add_prefix (i), self.model._meta.pk.name) "

So pk_key is not flexible. Because if I overwrite function "add_prefix" from 
class "forms.ModelForm", I get error "MultiValueDictKeyError".

My add_prefix function:
def add_prefix(self, field_name):
  return '%s_%s' % (self.prefix, field_name) if self.prefix else field_name

I see a possibility to solve that for now. Overwrite function _construct_form.

Other options?
--
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...@googlegroups.com.
To post to this group, send email to djang...@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/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com<https://groups.google.com/d/msgid/django-users/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/95d37c13-d5da-4566-913d-cff89975f897%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95d37c13-d5da-4566-913d-cff89975f897%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/9ed9ee85429c4e73ae34335647f812ac%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: BaseModelFormSet > _construct_form

2019-04-03 Thread Nikolay Smirnov
I override add_prefix because on client side I use angularjs. In some cases 
it is impossible or not easy to use hyphens in the names.

I do not overwrite _construct_form! That was just a possibility to solve 
that. But at the moment, I see no other options for solving that.

I find it personally that generating variable pk_key within the 
_construct_form is a bad practice. And becomes not compatible with 
generating form field ID's and -field names.

On Tuesday, 2 April 2019 23:15:15 UTC+2, Matthew Pava wrote:
>
> Why are overwriting add_prefix? Why are you overwriting _*construct*_form?
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *nikolaysm
> *Sent:* Tuesday, April 2, 2019 9:37 AM
> *To:* Django users
> *Subject:* BaseModelFormSet > _construct_form
>
>  
>
> Hello,
>
>  
>
> In function _construct_form variable "pk_key" is generated as:
>
>  pk_key = "%s-%s" % (self.add_prefix (i), self.model._meta.pk.name) "
>
>  
>
> So pk_key is not flexible. Because if I overwrite function "add_prefix" 
> from class "forms.ModelForm", I get error "MultiValueDictKeyError".
>
>  
>
> My add_prefix function:
>
> def add_prefix(self, field_name):
>
>   return '%s_%s' % (self.prefix, field_name) if self.prefix else 
> field_name
>
>  
>
> I see a possibility to solve that for now. Overwrite function 
> _construct_form.
>
> Other options?
>
> -- 
> 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...@googlegroups.com .
> To post to this group, send email to djang...@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/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/95d37c13-d5da-4566-913d-cff89975f897%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: BaseModelFormSet > _construct_form

2019-04-02 Thread Kevin Jay
ke...@kjay.net

On Tue, Apr 2, 2019 at 4:12 PM nikolaysm  wrote:

> Hello,
>
> In function _construct_form variable "pk_key" is generated as:
>  pk_key = "%s-%s" % (self.add_prefix (i), self.model._meta.pk.name) "
>
> So pk_key is not flexible. Because if I overwrite function "add_prefix"
> from class "forms.ModelForm", I get error "MultiValueDictKeyError".
>
> My add_prefix function:
> def add_prefix(self, field_name):
>   return '%s_%s' % (self.prefix, field_name) if self.prefix else
> field_name
>
>
> I see a possibility to solve that for now. Overwrite function
> _construct_form.
>
> Other options?
>
> --
> 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/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAEtabwdvYoD4ypvo%3D3_14M%2BbvOHZoYTtAMNxfs0JcJfs-o1_dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: BaseModelFormSet > _construct_form

2019-04-02 Thread Matthew Pava
Why are overwriting add_prefix? Why are you overwriting _construct_form?

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of nikolaysm
Sent: Tuesday, April 2, 2019 9:37 AM
To: Django users
Subject: BaseModelFormSet > _construct_form

Hello,

In function _construct_form variable "pk_key" is generated as:
 pk_key = "%s-%s" % (self.add_prefix (i), self.model._meta.pk.name) "

So pk_key is not flexible. Because if I overwrite function "add_prefix" from 
class "forms.ModelForm", I get error "MultiValueDictKeyError".

My add_prefix function:
def add_prefix(self, field_name):
  return '%s_%s' % (self.prefix, field_name) if self.prefix else field_name

I see a possibility to solve that for now. Overwrite function _construct_form.

Other options?
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com<https://groups.google.com/d/msgid/django-users/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/a787d9eb08564642ba811f030080f69a%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


BaseModelFormSet > _construct_form

2019-04-02 Thread nikolaysm
Hello,

In function _construct_form variable "pk_key" is generated as:
 pk_key = "%s-%s" % (self.add_prefix (i), self.model._meta.pk.name) "

So pk_key is not flexible. Because if I overwrite function "add_prefix" 
from class "forms.ModelForm", I get error "MultiValueDictKeyError".

My add_prefix function:
def add_prefix(self, field_name):
  return '%s_%s' % (self.prefix, field_name) if self.prefix else 
field_name


I see a possibility to solve that for now. Overwrite function 
_construct_form.

Other options?

-- 
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/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.