Re: Django 1.4 - how to display a success message on form save

2015-08-04 Thread Sammy
I'm pretty sure you have to use AJAX to display the message without reloading.

-- 
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/c8ddd5c1-19cf-4527-8551-d27c354fd2b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.4 - how to display a success message on form save

2015-08-03 Thread Iyengar8
But the message gets displayed only after I reload the page, the page isn't 
updated.

On Tuesday, 26 June 2012 08:46:04 UTC-4, JirkaV wrote:
>
> >> @Jirka - thanks. I saw something about the messaging framework and even 
> >> tried one example which did not work. 
>
> Using the messaging framework is actually very simple. 
>
> You need to enable the messaging framework (see the steps here: 
> https://docs.djangoproject.com/en/1.4/ref/contrib/messages/ ) 
>
> In your template, you need this (I have that in my base template so 
> it's included in all pages): 
>
>   {% if messages %} 
> {% for message in messages %} 
>   {{ message }} 
> {% endfor %} 
>   {% endif %} 
>
> Obviously, you'll need some formatting/CSS around it. 
>
> And in your views.py (or forms.py, ...) 
>
> from django.contrib import messages 
>
>if form.is_valid(): 
>  messages.success(request, 'Your form was saved') 
>
> And that's it! 
>
>
>Jirka 
>

-- 
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/a76615b9-077a-4ccb-a278-158e1cd7f755%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.4 - how to display a success message on form save

2013-04-04 Thread Zach Mance
Hi Kurtis,

I saw your SO post, and I'm trying trigger success messages from my CBV's, 
and I'm just wondering how your "MessageMixin" methods work with your 
CBV's. For example, where/how does the form_valid() get called to pass the 
success_message from the CBV's. 

Also, will this work with 1.4? 


On Tuesday, June 26, 2012 10:31:17 AM UTC-5, Kurtis wrote:
>
> We do it all over our site. I use class-based views but you can checkout 
> my "MessageMixin". I have the code on this stackoverflow page:
>
>
> http://stackoverflow.com/questions/5531258/example-of-django-class-based-deleteview/10903943#10903943
>
> It will show up wherever you send the user to next, as long as your 
> template is coded to display the message.
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.4 - how to display a success message on form save

2012-06-26 Thread Kurtis Mullins
We do it all over our site. I use class-based views but you can checkout my
"MessageMixin". I have the code on this stackoverflow page:

http://stackoverflow.com/questions/5531258/example-of-django-class-based-deleteview/10903943#10903943

It will show up wherever you send the user to next, as long as your
template is coded to display the message.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django 1.4 - how to display a success message on form save

2012-06-26 Thread maumercado
Go with @JirkaV suggestion, also, you can add some jquery effect so that 
the div appears then fades out on success or on error... its pretty simple 
and really great!

On Tuesday, June 26, 2012 4:48:31 AM UTC-5, Lloyd Dube wrote:
>
> Hi everyone,
>
> I have a form on which I'm calling save() and if it is successful I would 
> like to display 'your post has been saved' or similar in the template. How 
> would one go about that in Django 1.4?
>
> I am sifting through the docs and cannot seem to find a definitive answer.
>
> Thanks in advance.
>
> -- 
> Regards,
> Sithembewena Lloyd Dube
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/jIYGL0QUR30J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django 1.4 - how to display a success message on form save

2012-06-26 Thread Jirka Vejrazka
>> @Jirka - thanks. I saw something about the messaging framework and even
>> tried one example which did not work.

Using the messaging framework is actually very simple.

You need to enable the messaging framework (see the steps here:
https://docs.djangoproject.com/en/1.4/ref/contrib/messages/ )

In your template, you need this (I have that in my base template so
it's included in all pages):

  {% if messages %}
{% for message in messages %}
  {{ message }}
{% endfor %}
  {% endif %}

Obviously, you'll need some formatting/CSS around it.

And in your views.py (or forms.py, ...)

from django.contrib import messages

   if form.is_valid():
 messages.success(request, 'Your form was saved')

And that's it!


   Jirka

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django 1.4 - how to display a success message on form save

2012-06-26 Thread Sithembewena Lloyd Dube
I did do:
#if form.save():
success = form.errors['success']

On Tue, Jun 26, 2012 at 2:35 PM, Sithembewena Lloyd Dube
wrote:

> @newkedison, thank you for the suggestion. I wish to stay on the page
> without doing any redirects.
>
> @Jirka - thanks. I saw something about the messaging framework and even
> tried one example which did not work.
>
> I ended up doing the following (which worked):
>
> In view:
> success = default value here
> if form.is_valid():
> form.errors['success'] = 'Saved'
> 
> return self.render_to_response(request, template_name, {
> 'tomatoes': tomatoes,
> 'success': success,
> })
>
> ... and in template:
>
> {{ success }}
>
> Regards.
>
>
> On Tue, Jun 26, 2012 at 2:20 PM, Jirka Vejrazka 
> wrote:
>
>> Hi,
>>
>>  have you checked the messaging framework in Django?
>>
>>  HTH
>>
>>Jirka
>>
>> --
>> 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
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Regards,
> Sithembewena Lloyd Dube
>



-- 
Regards,
Sithembewena Lloyd Dube

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django 1.4 - how to display a success message on form save

2012-06-26 Thread Sithembewena Lloyd Dube
@newkedison, thank you for the suggestion. I wish to stay on the page
without doing any redirects.

@Jirka - thanks. I saw something about the messaging framework and even
tried one example which did not work.

I ended up doing the following (which worked):

In view:
success = default value here
if form.is_valid():
form.errors['success'] = 'Saved'

return self.render_to_response(request, template_name, {
'tomatoes': tomatoes,
'success': success,
})

... and in template:

{{ success }}

Regards.

On Tue, Jun 26, 2012 at 2:20 PM, Jirka Vejrazka wrote:

> Hi,
>
>  have you checked the messaging framework in Django?
>
>  HTH
>
>Jirka
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django 1.4 - how to display a success message on form save

2012-06-26 Thread Jirka Vejrazka
Hi,

  have you checked the messaging framework in Django?

  HTH

Jirka

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django 1.4 - how to display a success message on form save

2012-06-26 Thread 罗健忠
you may use HttpResponseRedirect to redirect to another page to display the
successful message

On 26 June 2012 17:48, Sithembewena Lloyd Dube  wrote:

> Hi everyone,
>
> I have a form on which I'm calling save() and if it is successful I would
> like to display 'your post has been saved' or similar in the template. How
> would one go about that in Django 1.4?
>
> I am sifting through the docs and cannot seem to find a definitive answer.
>
> Thanks in advance.
>
> --
> Regards,
> Sithembewena Lloyd Dube
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django 1.4 - how to display a success message on form save

2012-06-26 Thread Sithembewena Lloyd Dube
Hi everyone,

I have a form on which I'm calling save() and if it is successful I would
like to display 'your post has been saved' or similar in the template. How
would one go about that in Django 1.4?

I am sifting through the docs and cannot seem to find a definitive answer.

Thanks in advance.

-- 
Regards,
Sithembewena Lloyd Dube

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.