Hi all, I'm trying to use messages framework, I've checked that
middleware, context processor and app is well configured (I'm running
django development version which a standard manage.py startproject
includes all needed stuff)

So, let me write a little bit of code, assume a model like:

class MyModel(models.Model):
    name            = models.TextField(max_length = 100)
    url             = models.URLField()

And a simple form:

class mymodelForm(forms.ModelForm):
    name = forms.CharField()
    url = forms.URLField()
    class Meta:
        model = MyModel

A basic view (assuming all needed imports in top of my views.py file):

def mymodel_create(request):
    from forms import mymodelForm
    if request.method == 'POST':
        form = mymodelForm(request.POST)
        if form.is_valid():
            form.save()
            messages.success(request, _('Model has been saved'))
    else:
        form = projectForm()

    return render_to_response('mymodel_create.html', {'form' : form})

and my template (basic as well)

        {% if messages %}
        <ul class="messages">
            {% for message in messages %}
            <li{% if message.tags %} class="{{ message.tags }}"{% endif %}
>{{ message }}</li>
            {% endfor %}
        </ul>
        {% else %}
        No messages to show
        {% endif %}

        <form action="." method="post">{% csrf_token %}
        <ul class="form">
                {{ form.as_ul }}
                <li class="submitbutton">
                        <button type="submit">Save</button>
                </li>
        </ul>

I load it, fill my form up in my browser, submit it and it saves my
model correctly but don't shows any messages, always goes to {% else
%} template part.

So, If I change my URL to /admin the login (or dashboard if logged in)
is showed and my messages appears there!

Someone can help me to fix this problem? I've been searching over
Django docs and Google with no helping topic.

Thanks in advance,

Gabriel

-- 
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.

Reply via email to