Re: How to process 1 form data to another form??

2008-09-30 Thread Malcolm Tredinnick


On Tue, 2008-09-30 at 00:30 -0700, laspal wrote:
> 
> >>In other words, why can't you just call it directly as a Python function 
> >>and pass it the list of mail ids you want to send?
> 
> I tried returning the python function.

I didn't say *return* a Python function. I said *call* a Python
function.

[...]
> The problem here is I want my url to change
> step1 - >/contacts/
> step 2 -> /contacts/selectesmail/sendmail/


You are trying to do two steps at once: (1) sending the mail, (2)
returning the user to a particular view. Instead, carry out step (1) by
calling a function and then, after it returns, use an
HttpResponseRedirect to do step (2) and return them to whichever view
you like.

Don't mix up what your server-side code is trying to do with the what
the end-user sees in their browser. They presumably do not care how you
send the email. They only care that after submitting the form from URL
#1, then end up at URL #2.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to process 1 form data to another form??

2008-09-30 Thread laspal


>>In other words, why can't you just call it directly as a Python function and 
>>pass it the list of mail ids you want to send?

I tried returning the python function.

View  contact( request):
   if request.method == 'POST':
return SendMail_Selected(request, new_mailing_list)

view SendMail_Selected(request, new_mailing_list):
  mailing_list = new_mailing_list
   if request.method == 'POST':
form = SendMailForm(request.POST)
if form.is_valid():
subject = form.cleaned_data['subject']
message = form.cleaned_data['message']
try:
send_mail(subject, message, sender, mailing_list)
request.user.message_set.create(message="Mail sent
successfully.")
return HttpResponseRedirect('../')

The problem here is I want my url to change
step1 - >/contacts/
step 2 -> /contacts/selectesmail/sendmail/

If I am passing python function as an return from my step 1 the url
does not changes and my form is already getting posted. I mean its
showing me  field error  as when I click send button in step 1.
how to solve this problem and most important is to change my url.

Thanks.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to process 1 form data to another form??

2008-09-30 Thread Thomas Guettler

laspal schrieb:
> So my problem is right now  I am sending the mailing_list in the url.
> which is not the right way of doing it as I might have more then 100
> mail id in my url.
>
> So I wanted to know how can I solve this problem???
>   
Hi,

you could sent the IDs as GET parameter: 
http://.../myview?mail_id=1&mail_id=2 

In myview:
  request.GET.getlist('mail_id') --> ['1', '2', ...]

 HTH,
Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to process 1 form data to another form??

2008-09-30 Thread Malcolm Tredinnick


On Mon, 2008-09-29 at 23:51 -0700, laspal wrote:
> Hi,
> I have a listing of contact from which I choose contact and get the
> mailid.
> Now I want to send mail to the selected mailid by using another form.
> 
> So right now what I am doing is :
> 
> view contacts( request):
>   if request.method == 'POST':
> return HttpResponseRedirect(reverse('mailing_list',
> args=[string]))
> 
> and my urls are :
> (r'^contacts/$', contacts),
> 
>  url(r'^contacts/selected/(?P[a-z.@, ]+)/sendmail/$',
> SendMail_Selected, name ="mailing_list"),
> 
> def SendMail_Selected(request, mailing_list):
> 
>process the  Mailform() form here
> 
> So my problem is right now  I am sending the mailing_list in the url.
> which is not the right way of doing it as I might have more then 100
> mail id in my url.
> 
> So I wanted to know how can I solve this problem???

Maybe you're approaching this a little backwards. Why are you wanting to
enter the "sending" function through an HTTP call? In other words, why
can't you just call it directly as a Python function and pass it the
list of mail ids you want to send?

That approach is still going to have a slight problem with scale, since
it takes a small amount of time to send each piece of mail, so
eventually the time taken will be longer than you want to wait before
returning from the view. But that's unrelated to your current and is a
standard issue when sending mail from a view (the solution is to store
the details of the mail to be sent and have some background process -- a
cronjob for example -- do the actual sending).

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to process 1 form data to another form??

2008-09-29 Thread laspal

Hi,
I have a listing of contact from which I choose contact and get the
mailid.
Now I want to send mail to the selected mailid by using another form.

So right now what I am doing is :

view contacts( request):
  if request.method == 'POST':
return HttpResponseRedirect(reverse('mailing_list',
args=[string]))

and my urls are :
(r'^contacts/$', contacts),

 url(r'^contacts/selected/(?P[a-z.@, ]+)/sendmail/$',
SendMail_Selected, name ="mailing_list"),

def SendMail_Selected(request, mailing_list):

   process the  Mailform() form here

So my problem is right now  I am sending the mailing_list in the url.
which is not the right way of doing it as I might have more then 100
mail id in my url.

So I wanted to know how can I solve this problem???

Thanks
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---