Re: Returning submitted formset data to the template for further editing

2014-06-28 Thread Andrew Choi
Daniele,

It doesn't seem like there's an easier way to do what you're proposing. 
However, what's the form data manipulation that you need to do for some of 
these forms? Is there a way to separate that from the form set submission?

Andrew

On Saturday, June 28, 2014 12:26:34 AM UTC+9, Daniele Procida wrote:
>
> As far as I can tell, there doesn't seem to be an easy way to do this: 
>
> 1.  bind POST data from the request to a formset 
> 2.  loop over the forms in the formset 
> 3.  for each form, manipulate some of the form data 
> 4.  return the manipulated form data to the template 
> 5.  in the template, have useful access to the forms' is_valid(), 
> validation and so on 
>
> Form data are immutable, so can't be edited directly, so step 3 is 
> difficult. 
>
> We could copy the immutable form data to make them editable, but since 
> they are in one great big soup of a QueryDict and have prefixes, picking 
> them out one by one for each form and field to edit them is messy and 
> unpleasant. 
>
> We could instead process all the data in the usual way, then put each dict 
> of form.cleaned_data into a new list, and create a new formset using 
> my_formset=MyFormset(initial=all_my_cleaned_data_dicts), but now that's 
> unbound, which makes step 5 is impossible. 
>
> I think the answer has to be to get all of the cleaned_data dicts; loop 
> over the keys, add the prefixes to each one; dump the key/value pairs into 
> a new data dict; grab the formset management key/values and transfer those 
> too, and then do my_formset.data = my_new_data_dict. 
>
> But it seems like an awful lot of work for what must be a fairly usual 
> use-case. 
>
> Daniele 
>
>

-- 
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/21db66a8-68df-45ea-9b3b-128394462f14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Update user and user profile same form

2014-06-29 Thread Andrew Choi
Henrique,

It looks like what you're looking for is a formset: 
https://docs.djangoproject.com/en/1.6/topics/forms/formsets/

Andrew

On Saturday, June 28, 2014 11:28:35 PM UTC+9, Henrique Oliveira wrote:
>
> Hi Guys,
>
> I have this model:
>
> class Member(models.Model):
> user = models.OneToOneField(User, primary_key=True)
> date_of_birth = models.DateField('Date of Birth')
>
> class Meta:
> db_table = 'member'
>
> def member_email(self):
> return self.user.email
>
> def first_name(self):
> return self.user.first_name
>
> I'd like to update both, User and Member, in the same form, how can i do 
> that?
>

-- 
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/d8ac8517-30e9-4877-a77d-d5099d6899d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: admin ViewDoesNotExistError

2014-06-29 Thread Andrew Choi
Martin,

Perhaps try copying over the folder configuration from the 
non-error-triggering project and try to continue from there. Also, perhaps 
permissions are to blame?

Andrew

On Sunday, June 29, 2014 2:22:11 AM UTC+9, Martin Spasov wrote:
>
> Hello guys, I am following the Tango with Django tutorial and cant  access 
> my admin site. For the past hour and a half I was trying to figure out why 
> i get the following 
>
>
> 
>
> I also follow the Official Django Tut and i checked to see if i would get 
> the same error, but i didn't.. Everything worked fine and in there i dont 
> have the views file that is shown in this error. I checked both projects 
> files and they seem the same. Any advice?
>

-- 
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/8a74498e-3510-40d2-80c3-f244dbd9d717%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Returning submitted formset data to the template for further editing

2014-07-02 Thread Andrew Choi

Daniele,

Are you processing the formset on one page or on multiple? If multiple, 
then it seems that you don't need a formset and can just chain the form 
inputs into the next form.


For a single page, the first thing that comes to mind is doing the 
processing client-side, via Javascript and AJAX calls. This would only 
be feasible if the information that you're using to process does not 
need to be secret. Then again, writing a client-side data processor 
might be just as much work as writing formset validation code from scratch.


Andrew

On 07/02/2014 03:58 PM, Daniele Procida wrote:

On Sat, Jun 28, 2014, Andrew Choi  wrote:


It doesn't seem like there's an easier way to do what you're proposing.
However, what's the form data manipulation that you need to do for some of
these forms? Is there a way to separate that from the form set submission?

Each time the form is resubmitted to have the data processed, it needs to 
complete some fields based on others, and related data in the database.

Daniele



--
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/53B3FCA5.6060001%40gmail.com.
For more options, visit https://groups.google.com/d/optout.