Re: How remove "__all__" from the beginnings of form error messages?

2020-08-03 Thread oba stephen
Alright, Nice to know.

Cheers.

On Mon, Aug 3, 2020 at 7:12 PM Christian Seberino 
wrote:

> I figured out the problem...If you only want the "global" errors to show
> up at the top of the form
> then you need to use {{form.non_field_errors}} instead of {{form.errors}}.
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8ec10188-d423-4dc0-af9f-38446f0c75bfo%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAJsLnoEr7-GDJ-J3Vd%3DNzAQnigQvcEqNjqh4RaXyv92_Qrg%2Bw%40mail.gmail.com.


Re: How remove "__all__" from the beginnings of form error messages?

2020-08-03 Thread Christian Seberino
I figured out the problem...If you only want the "global" errors to show up 
at the top of the form
then you need to use {{form.non_field_errors}} instead of {{form.errors}}.


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8ec10188-d423-4dc0-af9f-38446f0c75bfo%40googlegroups.com.


Re: How remove "__all__" from the beginnings of form error messages?

2020-08-03 Thread Christian Seberino
oba

Thanks.  Here are all the files you asked for...

=
forms.py:
=

class AppointmentForm(django.forms.Form):
customer = django.forms.IntegerField()
year = django.forms.CharField(min_length = 4, max_length = 4)
month= django.forms.CharField(max_length = 2)
day  = django.forms.CharField(max_length = 2)
hour = django.forms.CharField(max_length = 2,
  validators = [verify_hour])
minute   = django.forms.CharField(min_length = 2, max_length = 2)
am_or_pm = django.forms.CharField(max_length = 2,
  widget = AM_OR_PM,
  initial= "PM")

def clean(self):
cleaned_data = super().clean()
try:
year   = int(cleaned_data.get("year"))
month  = int(cleaned_data.get("month"))
day= int(cleaned_data.get("day"))
date   = datetime.date(year  = year,
   month = month,
   day   = day)
except (ValueError, TypeError):
raise django.forms.ValidationError("Invalid date")
if date < datetime.date.today():
raise django.forms.ValidationError("Invalid date")
try:
hour   = int(cleaned_data.get("hour"))
minute = int(cleaned_data.get("minute"))
datetime.time(hour = hour, minute = minute)
except (ValueError, TypeError):
raise django.forms.ValidationError("Invalid time")


=
view
=

CUST   = grandmas4hire.models.Customer
APPT   = grandmas4hire.models.Appointment

...

@django.contrib.auth.decorators.login_required
def admin_appt(request):
custs = CUST.objects.all()
custs = [(e.first + " " + e.last, e.id) for e in custs]
appts = [e for e in APPT.objects.all()]
appts = sorted(appts,
   key = lambda a : a.customer.last + a.customer.first 
+   \
str(a.date) + 
str(a.time))
if request.method == "POST":
form = grandmas4hire.forms.AppointmentForm(request.POST)
if form.is_valid():
cust  = form.cleaned_data["customer"]
cust  = CUST.objects.get(id = cust)
year  = int(form.cleaned_data["year"])
month = int(form.cleaned_data["month"])
day   = int(form.cleaned_data["day"])
date  = datetime.date(year  = year,
  month = month,
  day   = day)
hour  = int(form.cleaned_data["hour"])
min_  = int(form.cleaned_data["minute"])
time  = datetime.time(hour = hour, minute = min_)
if form.cleaned_data["am_or_pm"] == "PM":
time = datetime.time(hour   = time.hour + 
12,
 minute = time.minute)
appt  = APPT(customer = cust,
 user = request.user,
 date = date,
 time = time,
 status   = "in process",
 reminded = False,
 updated  = False)
appt.save()
reply = django.shortcuts.redirect("/admin_appt")
else:
reply = django.shortcuts.render(request,
"admin_appt.html",
{"form"  : form,
 "custs" : custs,
 "appts" : appts})
else:
form  = grandmas4hire.forms.AppointmentForm()
reply = django.shortcuts.render(request,
"admin_appt.html",
{"form"  : form,
 "custs" : custs,
 "appts" : appts})

return reply

=
template
=

Re: How remove "__all__" from the beginnings of form error messages?

2020-08-03 Thread oba stephen
Hi, could you share your forms.py, your views.py and the template.

On Mon, Aug 3, 2020 at 2:22 PM Christian Seberino 
wrote:

> I created a custom form error messag like so...
>
>  raise django.forms.ValidationError("Invalid date")
>
> However, when I do {{form.errors}} in a template I see this
>
> __all__
>
>- Invalid date
>-
>-
>- How remove that "__all__" part at beginning?
>-
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/be4065bb-2f54-4275-a216-a1767e1dc1d5o%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAJsLnr%3DqLK8U62KqZW2Cn4i0ezDknV5Qhosm5zSn8aJ-%3DC5Ew%40mail.gmail.com.


How remove "__all__" from the beginnings of form error messages?

2020-08-03 Thread Christian Seberino
I created a custom form error messag like so...

 raise django.forms.ValidationError("Invalid date")

However, when I do {{form.errors}} in a template I see this

__all__
   
   - Invalid date
   - 
   - 
   - How remove that "__all__" part at beginning?
   - 
   

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/be4065bb-2f54-4275-a216-a1767e1dc1d5o%40googlegroups.com.


Re: Error messages in SetPasswordForm

2020-02-05 Thread Daniel Germano Travieso
It is my belief, if I remember correctly, that the construct _()
allows for usage of unicode direct text, and such, makes it possible to
directly insert any special characters in the text. So for ease of
understanding, the special character was used in a way that does not
confuse the reader and spares them of trying to parse/remember what the
construction of escaped characters are.

But I could be wrong as I do not work on the belly of Django development.
*[]'s*
Daniel Germano Travieso

-BEGIN PGP PUBLIC KEY BLOCK-

mQINBF1hSUIBEAC56ve8/8fAt55s+PHuolumg8zvjqk0cpo36DXkntP1fqlY5DdP
36sfvL/pJgt+x480Wy6YVdj1T/N7c3WxcUx6D+oh8ZBmeG2eoeJli1BT/QDrLyt/
af0djw/VMc5ygV0Lg6zg8ynNn+mjhcDMFyl7ITZeYgXXX3fO7I87geAdWmb9sX4W
C7qfRi23PQZ/0vKlv9WSlzvOMDcB0g3aoxuYmhbZ5KlRlrQYVeW1rcQHP6CGrVFs
9/FAvjw2rj+vsS7w0CjmF1Q5XZ/MWrx3I17RXojkBeDQElLA7y732G4wk7WS60wE
NLuEclHieSs780bWdIRwYW7i0mmYAjnO9eRzMfhRtykcbJBy0Nodr1c15Qa2LKFr
ZUk9kil3utKTYaU3kUbe+M2VQXthw0Vvb5NWagsNAZdOwBWsHY56bvsy5pCUtS9a
NE8WZEt8UEU4IF93RATMXl+BxtIgQOWDPmXkt/bqLk4U01+70AFdszanGkyZgFyn
VOr44gBM9+78SEOf/exiKLnZuv4VEtt5fUniwRkSSRaMCuEVk3JlBAbVY22d9Lzu
c3i6g2yWZuqIXnsIwhw/g62uDE+yWGnYzM5Kn8fCAkmcyKG8qHSlqtiOnN0yzMj0
aV1DZ5pR3MESa0HWQnechUvnD0KdT/pD3qOvHZYsbOTXqDz6J+r3JK1+FQARAQAB
tE1EYW5pZWwgR2VybWFubyBUcmF2aWVzbyAoRGFuaWVsIFRyYXZpZXNvJ3MgSW5i
b3gpIDxkYW5pZWxndHJhdmllc29AZ21haWwuY29tPokCVAQTAQgAPhYhBAeImfqY
0eaSaZ3kJtqQme6v6yE1BQJdYUlCAhsDBQkJZgGABQsJCAcCBhUKCQgLAgQWAgMB
Ah4BAheAAAoJENqQme6v6yE1Yu8P/RK5CY5Pxo2u+0ulw1MDU0AeFyb8sHGqFHCG
LGjReaGmG3HY5rzEOYsgfcPCAUz5P03Qj3Peypr2QN4RAJnOXTUJINmPjxsDfp2O
2z4p6gt9rCDhschoIIJSuy3LyZdfNQN/8jMGMY5wslV6UA1s5+AEFNJ0H3n372Em
hvrAj2ZRG35/tSzkHNqPpNNJWxEQK/UL0JwBIdkf1OG3sTTphOoyuqjTtn1rRp42
7xBGHh8diidJazFY0gDLr9hoXZSDuj8MTvY5MsnT3rsaNnDfXQWqo+cJyySOGWLi
C03dQ0ynIbdRCWyKNsgPnxQAVxzGINxTmk2zk1M6RIO26y6oC1zEQ3WhZm2HnjlM
pnjb3gST2q5VshRToQ22eZc8JGFFldsRiNGh4rtgMu5xvtD36THz58lqXn4CcP9Z
TNoVBuSAd7V6RwZDi38fI4ePUxJQrywk4xcT8gr8tLNjadtcwgGpotoX7xVamP/I
Dj3URPWUW4dhXTHcXj2TQvw1+yFEGvwRqs2NPySlZA5xv5Z3oyQdoKXAD44Amcop
Tvaimw1599EtVMdy5mSNCXuSKckUT9E/lg2aqOJSDbZBJRO4F7ERK+Zl54mxrnKm
ESwM5P8WDUreYRTOLjNF0aONjcYrWYpNCEzxHKfKN0w6+oSv/oCZY3lgIgUz11Mo
9A20mUwDuQINBF1hSUIBEADAmuIB3JUmtpXuzYCEqGl3vLWokxVYsRBSyFE9UqOw
XEXgvBaVPtBoAaEPiYl1ZcjlWa1gVpKRs3uNzgpZq/tUwXXJ57Gb60FZIlysYTwK
AOIt6huTt+ePh3gV1V+8Q7avQxwnqkR17pllwuxT4YxUhiAownd+saHWzt4zvNkn
31jk3FlkJN7YHiW6qZYBfIqBhcRen/Jx4G7WjznGQrPcUW6xTw8yQePRKXMOqMHM
+Na2ZMKdAx+hV8ZVguwfYJd/D1LhyUZQJ+tZIjtrXAtX2piKgMP9mgjHDrm2gTjj
EMsVfeH+J5HzsRFNWW7BV4ZNt8IrmU8j9TFGYB+CbhNPLqFnSgV4MeMBDP86Nlkh
DK27CYguNqPb3+7SjA85V6+JzEjYz8Xc860VYiw6e953bByu2FsPGXanggM8+CQQ
qjd6ApT921h76raVXQ/VsHctE/DYDwdBppTMk23WMLyGR3rpTUINM7NmmhCuOK2i
LhWq09TE48byxImSnwRpTxCSumhApIi76edDjmlKNqO9hNBArHs+03ExbjOWaQre
xynThWwcVN9FdqGL6CfIVEgk4FihNIlvVeu1AN1YcwYBtgSyc8Iz6NymngqgYkOI
STZ3wrMXaA17bfT+OTPebxRBzW43/BeoHVXkwhY+h+pWdjaEvbJWAzVl+CGfrgUt
OQARAQABiQI8BBgBCAAmFiEEB4iZ+pjR5pJpneQm2pCZ7q/rITUFAl1hSUICGwwF
CQlmAYAACgkQ2pCZ7q/rITW09g//Zl3QOtt+e5swVD3Vp7sZiGiueiJQVieVdY1F
JJFnpgZxyLn3fBAyc1dgBP/k9hUVwQUP/415zr+6zRYROku7lLXGDTaDHbkAprEL
m8HTBfYdyhSk5JW8W1luylkzB/6beIytxG28Y02xG+1X0t3k86la8FGfYBIYcNrX
2RwFjUt5FGMcGOtoU45/RcDOUEOxdMcCJQhpgavONpBDMjEIPVYUi8CPnJR/HUkO
FRHf/9S22mnNG8m/+jMC4TaM2OzU70yfW7u3n9UcHracSc6CbdMayXD//NHpOQtL
hP/K1G+azAQKwb/+n22U7M7mQets6VVOu5x9VOkpsK26CwZ79pB7DaJicaunO8Nl
VG/DCRDGhk207ULQdA0jMr6XDofYA/9mleFRp3UVoIp5DTNa/eivXZQhzWtkW66s
RUB2Du3S2shyhuOIxRW5M4zgUNMe8pDTQRbm0oBfrFjoX7K+F5G4wgaEnXqp3d6O
WzzgvqYDzTqkJtyfF0A8PaiYWyBpOa6zTNtRwkrxsL+Ley/dRyMZeeCG20gsuHqy
DOLjz01uVuOg2B7+oJrYQkBMYc/n9s9z+O0GjQR+WKan1NgSwrSedPd52/FiPvT1
PPqlAem1Xs8EfBDgdVT4u1nbItbJGfR+5OU6xAgDH09ylwmV6bnOJtHFzjnqUK7P
4buoGc4=
=bYtC
-END PGP PUBLIC KEY BLOCK-



Em qua., 5 de fev. de 2020 às 14:40, One Above All <
the.one.above.all.ti...@gmail.com> escreveu:

> In *django.contrib.auth.forms* there is a class named *SetPasswordForm*
> which has a dictionary member *error_messages*. It is defined as follows:
> *error_messages = {*
> *'password_mismatch': _('The two password fields didn’t match.'),*
> *}*
> A special character has been used for apostrophe instead of \' . Is this a
> design decision? It might create extending this class further and
> development difficult for new comers.
> If I am missing something or it is already known kindly provide reference
> to that.
>
> Regards,
> Gagan Deep
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8847e13f-3d31-40e3-aed0-e5b06ce7b3f8%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To u

Error messages in SetPasswordForm

2020-02-05 Thread One Above All
In *django.contrib.auth.forms* there is a class named *SetPasswordForm* 
which has a dictionary member *error_messages*. It is defined as follows:
*error_messages = {*
*'password_mismatch': _('The two password fields didn’t match.'),*
*}*
A special character has been used for apostrophe instead of \' . Is this a 
design decision? It might create extending this class further and 
development difficult for new comers. 
If I am missing something or it is already known kindly provide reference 
to that.

Regards,
Gagan Deep

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8847e13f-3d31-40e3-aed0-e5b06ce7b3f8%40googlegroups.com.


Custom error messages not working in Django ModelForm - help needed

2019-08-08 Thread אורי
Django Users,

I want to release Speedy Net and Speedy Match to production in September or
October 2019. I need help with the following issue on GitHub and Stack
Overflow:
https://github.com/speedy-net/speedy-net/issues/3

Any suggestions?

There are other issues on Speedy Net which I also need help:
https://github.com/speedy-net/speedy-net/issues

אורי
u...@speedy.net

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABD5YeEO9VkOxVZiLt5Rq4%3DywkzkkyRFW5wAnYhT6Db4UFfnBQ%40mail.gmail.com.


Key error for error messages in case the check on unique fails.

2019-01-30 Thread 'Odile Lambert' via Django users

  
  
Hello
I have a field in my model which has unique = True.
If I specify an error message with a reference to the value of
  the field, Django crashes with Key error.
Yet this works for other error_messages. How wan I solve this?
Here is the code and the trace back
 https://dpaste.de/t5X8#
Is this a bug in admin?
I thank you in advance for your help.
  Piscvau




 



  




-- 
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/7fb7b0a0-7f36-7055-e751-16dbd2122fee%40laposte.net.
For more options, visit https://groups.google.com/d/optout.


Re: Logging debug & error messages to file

2019-01-12 Thread PASCUAL Eric
Hi,


That way you don't have to deal with rotating log files (not sure if

djangos file logger handles that though) and permission problems.

There is no "Django logger". Django uses the Python native logging module. This 
module defines several handler types, including the RotatingFileHandler one, 
which takes care of rotating logs files automatically on systems which don't 
support this out of the box (Windows for instance). Have a look at 
https://docs.python.org/3.7/library/logging.handlers.html#rotatingfilehandler 
for detail.


However, if your application is supposed to be deployed and executed on *nix 
servers, just log to standard files (or to stdout/stderr and redirect them to a 
log file) and add the involved log files in the logrotate configuration (see 
https://linux.die.net/man/8/logrotate). logrotate takes care of a lot of 
things, such as :

  *   rotating files
  *   purging oldest ones
  *   compress oldest ones

All these actions can be freely configured based on your retention policy for 
logs.


logrotate is rock solid and at the heart of *nix since ages.


Best


Eric



From: django-users@googlegroups.com  on behalf 
of Kasper Laudrup 
Sent: Saturday, January 12, 2019 2:14:39 PM
To: django-users@googlegroups.com
Subject: Re: Logging debug & error messages to file

Hi Uri,

On 12/01/2019 11.34, אורי wrote:
> I'm trying to log debug & error messages to a file. But I receive this
> exception on the server:
>
> ValueError: Unable to configure handler 'file': [Errno 13] Permission
> denied: '/var/log/speedy_net_django.log'
>

The user running django does not have write access to '/var/log'. This
is a good thing. You could give the user running django write access to
'/var/log' or run django as another user, but I definitely wouldn't
recommend that.

> If I change the path to '/tmp/speedy_net_django.log' then it works.
>

That's because every user on the system has write access to '/tmp'.

> How do I configure the server to write messages
> to '/var/log/speedy_net_django.log'? We use Ubuntu and nginx.
>

You could create a directory under '/var/log', eg. '/var/log/speedy_net'
and give the user/group your running django as write access to that
directory and write your logs to '/var/log/speedy_net/django.log'.

> Our logging settings:
> https://github.com/speedy-net/speedy-net/blob/staging/speedy/core/settings/base.py
>
> By the way, are there friendlier ways to view logging messages than with
> text files?
>

Yes indeed. A much better solution would be to use the log system
already available on the system (eg. syslog or journald).

That way you don't have to deal with rotating log files (not sure if
djangos file logger handles that though) and permission problems.

Something like this might be useful:

https://www.simonkrueger.com/2015/05/27/logging-django-apps-to-syslog.html

Kind regards,

Kasper Laudrup

--
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/a872ce04-115d-ec66-de7a-1a0212308d31%40stacktrace.dk.
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/AM0P193MB03081CFA385BDABBE8354B038C860%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Logging debug & error messages to file

2019-01-12 Thread Kasper Laudrup

Hi Uri,

On 12/01/2019 11.34, אורי wrote:
I'm trying to log debug & error messages to a file. But I receive this 
exception on the server:


ValueError: Unable to configure handler 'file': [Errno 13] Permission 
denied: '/var/log/speedy_net_django.log'




The user running django does not have write access to '/var/log'. This 
is a good thing. You could give the user running django write access to 
'/var/log' or run django as another user, but I definitely wouldn't 
recommend that.



If I change the path to '/tmp/speedy_net_django.log' then it works.



That's because every user on the system has write access to '/tmp'.

How do I configure the server to write messages 
to '/var/log/speedy_net_django.log'? We use Ubuntu and nginx.




You could create a directory under '/var/log', eg. '/var/log/speedy_net' 
and give the user/group your running django as write access to that 
directory and write your logs to '/var/log/speedy_net/django.log'.



Our logging settings:
https://github.com/speedy-net/speedy-net/blob/staging/speedy/core/settings/base.py

By the way, are there friendlier ways to view logging messages than with 
text files?




Yes indeed. A much better solution would be to use the log system 
already available on the system (eg. syslog or journald).


That way you don't have to deal with rotating log files (not sure if 
djangos file logger handles that though) and permission problems.


Something like this might be useful:

https://www.simonkrueger.com/2015/05/27/logging-django-apps-to-syslog.html

Kind regards,

Kasper Laudrup

--
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/a872ce04-115d-ec66-de7a-1a0212308d31%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Logging debug & error messages to file

2019-01-12 Thread אורי
Hi,

I'm trying to log debug & error messages to a file. But I receive this
exception on the server:

ValueError: Unable to configure handler 'file': [Errno 13] Permission
denied: '/var/log/speedy_net_django.log'

If I change the path to '/tmp/speedy_net_django.log' then it works.

How do I configure the server to write messages
to '/var/log/speedy_net_django.log'? We use Ubuntu and nginx.

Our logging settings:
https://github.com/speedy-net/speedy-net/blob/staging/speedy/core/settings/base.py

By the way, are there friendlier ways to view logging messages than with
text files?

אורי
u...@speedy.net

-- 
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/CABD5YeGfd%3DUJseZiUP7me52A61pWfn6%3DE1JJnCwk5VZ%2BoMYRNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I customize form error messages?

2017-12-03 Thread Tom Tanner
Nevermind, I figured out I needed to edit `forms.py`.

My custom login class...

class LoginForm(AuthenticationForm):
 error_messages= {
  "invalid_login": _("Incorrect %(username)s/password combo")
 }
 # more code here...
}


On Sunday, December 3, 2017 at 9:46:09 PM UTC-5, Tom Tanner wrote:
>
> In my login form, I have this code:
>
>  {% if login_form.non_field_errors %}
>   {{ login_form.non_field_errors.as_text|cut:"* 
> "|escape 
> }}
>  {% endif %}
>
> If a user enters the wrong username/password combo, the error reads like 
> this: 'Please enter a correct username and password. Note that both fields 
> may be case-sensitive." I'd like to change this message and other error 
> messages. How do I do this?
>

-- 
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/3ac863e5-c73b-4b86-ad40-9a30aa7dbe9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I customize form error messages?

2017-12-03 Thread Tom Tanner
In my login form, I have this code:

 {% if login_form.non_field_errors %}
  {{ login_form.non_field_errors.as_text|cut:"* "|escape 
}}
 {% endif %}

If a user enters the wrong username/password combo, the error reads like 
this: 'Please enter a correct username and password. Note that both fields 
may be case-sensitive." I'd like to change this message and other error 
messages. How do I do this?

-- 
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/0bcec941-56f1-4442-9436-2e7cb9411454%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Show error messages with verbose field names instead field names

2016-02-17 Thread Francisco Lopes
Hi,

I'm creating an update form. I want to show error messages using verbose 
field names instead field names itself. 

Source code:

http://dpaste.com/3DC214G

http://dpaste.com/2TB8SCD

When, for example, I leave the field 'estado_civil' empty, the message is 
'estado_civil: this field is required'. 

But i want to show this message using verbose name, like this: 'Estado Civil: 
this field is required'.

How can i do this?

Thanks.

-- 
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/8ce4fe4c-a5ac-464d-811d-b1ea3ee0bc30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form error messages not displayed

2014-07-16 Thread sarfaraz ahmed

>
> I tried {{form.errors}} in template.. but it still does not show up. When 
> I used the Werkeuq and print form it see the precise error in form. Not 
> sure what i am doing wrong.


Regards,
Sarfaraz Ahmed
 

-- 
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/5ca7714b-4bf3-4a8f-9073-53fbf7407042%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form error messages not displayed

2014-07-16 Thread Tom Evans
On Wed, Jul 16, 2014 at 10:26 PM, sarfaraz ahmed  wrote:
> I am trying to display form.erros. I am using bootstrap modal and using ajax
> form submit to send data async. Everything works fine... I can see the error
> messages returned in code. But it automatically goes to default error pages
> of django when form.is_valid returns false. When I print form in debug mode
> I see the specific error. I am using Werkzeug  for debugging.
>
> Here is my view.py code
>
> def register_user(request):
> #args=UserCreationForm()
>
> args={}
> args.update(csrf(request))
>
> if request.method=='POST':
> form = UserCreationForm(request.POST)
> print 'step 2'
> args['form']=form
> if form.is_valid:
> form.save()
> print 'step 3'
> return HttpResponseRedirect('/accounts/register_success/')
> else:
>
> return
> render_to_response('register.html',args,context_instance=RequestContext(request))
>
> #assert false
> #return
> render_to_response('register.html',args,context_instance=RequestContext(request))
> else:
> args['form'] = UserCreationForm()
> return
> render_to_response('register.html',args,context_instance=RequestContext(request))
>
>
> ==
> template code
>  method='post' role='form'>{%csrf_token%}
> 
>  aria-hidden="true">×
> Register
> 
> 
> {%if form.errors %}
> {{errors}}

 {{ form.errors }}

> {%endif%}


Cheers

Tom

-- 
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/CAFHbX1%2Bd%3DtTacNjGC1L%3DtbnkuYkuu_cXP0vr6y33zKxO2Wpmrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Form error messages not displayed

2014-07-16 Thread sarfaraz ahmed
I am trying to display form.erros. I am using bootstrap modal and using 
ajax form submit to send data async. Everything works fine... I can see the 
error messages returned in code. But it automatically goes to default error 
pages of django when form.is_valid returns false. When I print form in 
debug mode I see the specific error. I am using Werkzeug  for debugging. 

Here is my view.py code

def register_user(request):
#args=UserCreationForm()
   
args={}
args.update(csrf(request))

if request.method=='POST':   
form = UserCreationForm(request.POST)
print 'step 2'
args['form']=form
if form.is_valid:
form.save()
print 'step 3'
return HttpResponseRedirect('/accounts/register_success/')
else:

return 
render_to_response('register.html',args,context_instance=RequestContext(request))
   
#assert false
#return 
render_to_response('register.html',args,context_instance=RequestContext(request))
else:
args['form'] = UserCreationForm()
return 
render_to_response('register.html',args,context_instance=RequestContext(request))


==
template code
{%csrf_token%}

×
Register
   

{%if form.errors %}
{{errors}}
{%endif%}

{{form.username.errors.as_text}}
Choose 
Username






{{form.password1.errors.as_text }}
Choose 
Password

  






{{form.password2.errors.as_text }}
Re-Enter 
Password




 










 


 
   $(document).ready(function() { 
   // bind 'myForm' and provide a simple callback function
   
var form_options = { 
target: '#modalcontent'

  ,success: function() {
   
}


,type: 'post'
//,clearForm: true
} 
$('#signup').ajaxForm(form_options);
   
});
  
 
   
 

Please help

-- 
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/816d967e-60a6-46a2-b5c0-6f0073a62f7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Mysterious error messages

2013-09-23 Thread Joseph Mutumi
Don't use Satchmo but looks like `shop_config` is not defined when you
context_processors are called?

This is because from it looks like it gets the shop_config based on the
current site based on the host. If the domain name saved in the admin for
the site corresponding to the SITE_ID in your settings.py is incorrect or
different from the host header in the HTTP request, it could possible cause
this error.


On Sun, Sep 22, 2013 at 6:02 PM, kooliah <
kool...@djeve.sites.djangohosting.ch> wrote:

>  I'm sorry but i started to send this message at 12.09 ...and at 14.00
> google groups still does not show me neither on mail or web-interface. so i
> resend...
>
> Sorry again, next time i'll wait 24 hours, to see if a post is sent...
>
>
>
>
>
> On 09/22/2013 04:27 PM, Avraham Serour wrote:
>
> really? how many times do you need to send and resend and cross post?
>
>
> On Sun, Sep 22, 2013 at 1:23 PM,  wrote:
>
>>  Everyday i receive 5-10 mysterious error messages of this kind
>>
>> ... ERRORS.
>>
>>   File
>> "../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py",
>> line 31, in settings
>> 'shop_name': shop_config.store_name,
>>
>> AttributeError: 'NoneType' object has no attribute 'store_name'
>>
>>
>> > path:/plugins/tinymce_plugin/tiny_mce/plugins/more/editor_plugin.js,
>> GET:,
>> POST:,
>>
>> 
>>
>>   File
>> ".../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", line
>> 31, in settings
>> 'shop_name': shop_config.store_name,
>>
>> AttributeError: 'NoneType' object has no attribute 'store_name'
>>
>>
>> > path:/admin/login.aspx,
>> GET:,
>>
>> 
>>
>>   File "/django/db/backends/postgresql_psycopg2/base.py", line 52, in
>> execute
>> return self.cursor.execute(query, args)
>>
>> DatabaseError: server closed the connection unexpectedly
>> This probably means the server terminated abnormally
>> before or while processing the request.
>>
>>
>>
>> > path:/art_folder/text-image_Series-1.jpg,
>> GET:,
>> POST:,
>>
>> 
>>
>> 
>>
>> 
>>
>> ...END ERRORS..
>>
>> All of them do not depend by my code but by django/satchmo source code,
>> and never rise on developing serverbut the thing I don't understand is
>> paths I have no paths like them...Why it does not give "page not found"
>> but Errors ??
>> If i give that url in browser it correctly gives me "page not
>> found"
>>
>> Thank you
>>
>> Alkatron
>> --
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: Mysterious error messages

2013-09-22 Thread kooliah
I'm sorry but i started to send this message at 12.09 ...and at 14.00 
google groups still does not show me neither on mail or web-interface. 
so i resend...


Sorry again, next time i'll wait 24 hours, to see if a post is sent...




On 09/22/2013 04:27 PM, Avraham Serour wrote:

really? how many times do you need to send and resend and cross post?


On Sun, Sep 22, 2013 at 1:23 PM, <mailto:alkat...@gmail.com>> wrote:


Everyday i receive 5-10 mysterious error messages of this kind

... ERRORS.

  File
"../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py",
line 31, in settings
'shop_name': shop_config.store_name,

AttributeError: 'NoneType' object has no attribute 'store_name'


,
POST:,



  File
".../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py",
line 31, in settings
'shop_name': shop_config.store_name,

AttributeError: 'NoneType' object has no attribute 'store_name'


,



  File "/django/db/backends/postgresql_psycopg2/base.py", line
52, in execute
return self.cursor.execute(query, args)

DatabaseError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.



,
POST:,







...END ERRORS..

All of them do not depend by my code but by django/satchmo source
code, and never rise on developing serverbut the thing I don't
understand is paths I have no paths like them...Why it does
not give "page not found" but Errors ??
If i give that url in browser it correctly gives me "page not
found"

Thank you

Alkatron
-- 
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%2bunsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


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


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


Re: Mysterious error messages

2013-09-22 Thread Avraham Serour
really? how many times do you need to send and resend and cross post?


On Sun, Sep 22, 2013 at 1:23 PM,  wrote:

> Everyday i receive 5-10 mysterious error messages of this kind
>
> ... ERRORS.
>
>   File
> "../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py",
> line 31, in settings
> 'shop_name': shop_config.store_name,
>
> AttributeError: 'NoneType' object has no attribute 'store_name'
>
>
>  path:/plugins/tinymce_plugin/tiny_mce/plugins/more/editor_plugin.js,
> GET:,
> POST:,
>
> 
>
>   File
> ".../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", line
> 31, in settings
> 'shop_name': shop_config.store_name,
>
> AttributeError: 'NoneType' object has no attribute 'store_name'
>
>
>  path:/admin/login.aspx,
> GET:,
>
> 
>
>   File "/django/db/backends/postgresql_psycopg2/base.py", line 52, in
> execute
> return self.cursor.execute(query, args)
>
> DatabaseError: server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.
>
>
>
>  path:/art_folder/text-image_Series-1.jpg,
> GET:,
> POST:,
>
> 
>
> 
>
> 
>
> ...END ERRORS..
>
> All of them do not depend by my code but by django/satchmo source code,
> and never rise on developing serverbut the thing I don't understand is
> paths I have no paths like them...Why it does not give "page not found"
> but Errors ??
> If i give that url in browser it correctly gives me "page not
> found"
>
> Thank you
>
> Alkatron
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Mysterious error messages

2013-09-22 Thread alkatron
Everyday i receive 5-10 mysterious error messages of this kind 

... ERRORS. 

  File 
"../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", 
line 31, in settings 
'shop_name': shop_config.store_name, 

AttributeError: 'NoneType' object has no attribute 'store_name' 


, 
POST:, 

 

  File ".../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", 
line 31, in settings 
'shop_name': shop_config.store_name, 

AttributeError: 'NoneType' object has no attribute 'store_name' 


, 

 

  File "/django/db/backends/postgresql_psycopg2/base.py", line 52, in 
execute 
return self.cursor.execute(query, args) 

DatabaseError: server closed the connection unexpectedly 
This probably means the server terminated abnormally 
before or while processing the request. 



, 
POST:, 

 

 

 

...END ERRORS.. 

All of them do not depend by my code but by django/satchmo source code, and 
never rise on developing serverbut the thing I don't understand is 
paths I have no paths like them...Why it does not give "page not found" 
but Errors ?? 
If i give that url in browser it correctly gives me "page not 
found" 

Thank you 

Alkatron

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


Mysterious error messages

2013-09-22 Thread alkatron
Everyday i receive 5-10 mysterious error messages of this kind 

... ERRORS. 

  File 
"../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", 
line 31, in settings 
'shop_name': shop_config.store_name, 

AttributeError: 'NoneType' object has no attribute 'store_name' 


, 
POST:, 

 

  File ".../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", 
line 31, in settings 
'shop_name': shop_config.store_name, 

AttributeError: 'NoneType' object has no attribute 'store_name' 


, 

 

  File "/django/db/backends/postgresql_psycopg2/base.py", line 52, in 
execute 
return self.cursor.execute(query, args) 

DatabaseError: server closed the connection unexpectedly 
This probably means the server terminated abnormally 
before or while processing the request. 



, 
POST:, 

 

 

 

...END ERRORS.. 

All of them do not depend by my code but by django/satchmo source code, and 
never rise on developing serverbut the thing I don't understand is 
paths I have no paths like them...Why it does not give "page not found" 
but Errors ?? 
If i give that url in browser it correctly gives me "page not 
found" 

Thank you 
Alkatron

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


Mysterious error messages

2013-09-22 Thread kooliah

Everyday i receive 5-10 mysterious error messages of this kind

... ERRORS.

  File 
"../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", 
line 31, in settings

'shop_name': shop_config.store_name,

AttributeError: 'NoneType' object has no attribute 'store_name'


,
POST:,



  File 
".../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", 
line 31, in settings

'shop_name': shop_config.store_name,

AttributeError: 'NoneType' object has no attribute 'store_name'


,



  File "/django/db/backends/postgresql_psycopg2/base.py", line 52, 
in execute

return self.cursor.execute(query, args)

DatabaseError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.



,
POST:,







...END ERRORS..

All of them do not depend by my code but by django/satchmo source code, 
and never rise on developing serverbut the thing I don't understand 
is paths I have no paths like them...Why it does not give "page not 
found" but Errors ??
If i give that url in browser it correctly gives me "page not 
found"


Thank you

Kooliah

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


Mysterious error messages

2013-09-22 Thread kooliah

Everyday i receive 5-10 mysterious error messages of this kind

... ERRORS.

  File "../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", 
line 31, in settings
'shop_name': shop_config.store_name,

AttributeError: 'NoneType' object has no attribute 'store_name'


,
POST:,



  File ".../satchmo/satchmo/apps/satchmo_store/shop/context_processors.py", 
line 31, in settings
'shop_name': shop_config.store_name,

AttributeError: 'NoneType' object has no attribute 'store_name'


,



  File "/django/db/backends/postgresql_psycopg2/base.py", line 52, in 
execute
return self.cursor.execute(query, args)

DatabaseError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.



,
POST:,







...END ERRORS..

All of them do not depend by my code but by django/satchmo source code, 
and never rise on developing serverbut the thing I don't understand 
is paths I have no paths like them...Why it does not give "page not 
found" but Errors ??

If i give that url in browser it correctly gives me "page not found"

Thank you

Kooliah

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


Customize error messages for django-registration

2013-09-05 Thread Tony Lâmpada
Hi, I have a question about django-registration (
https://bitbucket.org/ubernostrum/django-registration), but I can't find 
their issue tracker or a mailing list for it, so I'll try mu luck here.

My application enables login via OpenID and login/password.

Some users "forget their password" on FS on try to reset it 
(here), 
but then they get the message:

The user account associated with this e-mail address cannot reset the 
> password.

 
With no further explanations.
(You can try and reset *my* password - just type my email (tonylampada at 
gmail dot com) there to see the error message.

I want to customize that message. A better message would be:

The user account associated with this e-mail address cannot reset the 
> password.
> This happens because the user account was created with an OpenID or OAuth 
> provider (tipically Google, Facebook, MyOpenID, etc). 

To see the login provider(s) associated with this account, take a look at 
> the user profile .


What is the easiest way to tell django-registration that?

Thanks!

PS: This issue on github: 
https://github.com/freedomsponsors/www.freedomsponsors.org/issues/191 (just 
in case you're feeling like making a pull request today :-))

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


Re: Is this a bug? - Translation in error messages django.forms.models._update_errors()

2012-04-03 Thread david_aa
Sorry, my django version: 1.4.0



El martes 3 de abril de 2012 12:33:32 UTC+2, david_aa escribió:
>
> First at all, my apologies if this message is off-topic. I'm not sure if 
> this is a bug and I can't find any related ticket in 
> code.djangoproject.com
>
> The problem is the following:
>
> I've defined in my model some fields with the attribute verbose_name 
> marked for translation:
>
> class Item():
> name = models.CharField(max_length=75, verbose_name=_('name'))
>
> When I access to validation errors, the field's name is not translated.
>
> I've found that editing the method _update_errors() in 
> django/forms/models.py the field names are properly translated, here is the 
> diff:
>
> 254c254
> < self._errors.setdefault(k, self.error_class()).extend(v)
> ---
> > self._errors.setdefault(_(k), 
> self.error_class()).extend(v)
>
> My question: is this a bug? Shall I report it?
>
> Thanks in advance and excuse my newbie questions.
>
> -- 
> David.
>
>
>
>
>

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



Is this a bug? - Translation in error messages django.forms.models._update_errors()

2012-04-03 Thread david_aa
First at all, my apologies if this message is off-topic. I'm not sure if 
this is a bug and I can't find any related ticket in code.djangoproject.com

The problem is the following:

I've defined in my model some fields with the attribute verbose_name marked 
for translation:

class Item():
name = models.CharField(max_length=75, verbose_name=_('name'))

When I access to validation errors, the field's name is not translated.

I've found that editing the method _update_errors() in 
django/forms/models.py the field names are properly translated, here is the 
diff:

254c254
< self._errors.setdefault(k, self.error_class()).extend(v)
---
> self._errors.setdefault(_(k), 
self.error_class()).extend(v)

My question: is this a bug? Shall I report it?

Thanks in advance and excuse my newbie questions.

-- 
David.




-- 
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/-/xMc7dDlU4iMJ.
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: How to interpret error messages

2012-03-10 Thread arapaho
That just says that your Entry class inherits from the Model class,
which is found in the models module. I am a relative noob also, and
found a hard copy Django book was my best initial source.

On Mar 10, 10:09 am, Rico  wrote:
> > Since you realize that the problem is in how you've registered the Entry
> > class, don't you think it would be a good idea to show us how you're doing
> > it in that admin.py?
> > --
> > DR.
>
> I've managed to solve the problem - it wasn't in the admin.py - it was with
> my models.py.
>
> *class Entry():*
> *    stuff*
> *
> *
> changed to:
>
> *class Entry(models.Model):*
> *    stuff*
> *
> *
> I don't understand what that did, but it was the root of my problem.

-- 
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: How to interpret error messages

2012-03-10 Thread Rico

>
> Since you realize that the problem is in how you've registered the Entry 
> class, don't you think it would be a good idea to show us how you're doing 
> it in that admin.py?
> --
> DR. 
>

I've managed to solve the problem - it wasn't in the admin.py - it was with 
my models.py.

*class Entry():*
*stuff*
*
*
changed to:

*class Entry(models.Model):*
*stuff*
*
*
I don't understand what that did, but it was the root of my problem.

 

-- 
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/-/hBFkCRHI6fQJ.
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: How to interpret error messages

2012-03-10 Thread Daniel Roseman
On Saturday, 10 March 2012 07:31:16 UTC, Rico wrote:
>
> I'm trying to learn Django and have been following several online 
> tutorials hoping to understand how to create my own projects. 
>
> I'm having trouble interpreting the error messages that are given when I 
> do something wrong. Unfortunately I don't seem to get much help when I try 
> and find a solution via Google since I don't really know enough about 
> Django to ask the right questions. Perhaps I can find help here? 
>
> I don't know where to start exactly - the code is spread out all over! 
> Let's start with the error message: 
>
> http://dpaste.com/714463/ 
>
> Clearly it's upset about how I've registered my Entry class. What is the 
> problem and how do I fix it?


Since you realize that the problem is in how you've registered the Entry 
class, don't you think it would be a good idea to show us how you're doing 
it in that admin.py?
--
DR. 

-- 
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/-/2m0WKmAvGWEJ.
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: How to interpret error messages

2012-03-10 Thread dummyman dummyman
can u paste the file's contents  ?

On Sat, Mar 10, 2012 at 1:01 PM, Rico  wrote:

> I'm trying to learn Django and have been following several online
> tutorials hoping to understand how to create my own projects.
>
> I'm having trouble interpreting the error messages that are given when I
> do something wrong. Unfortunately I don't seem to get much help when I try
> and find a solution via Google since I don't really know enough about
> Django to ask the right questions. Perhaps I can find help here?
>
> I don't know where to start exactly - the code is spread out all over!
> Let's start with the error message:
>
> http://dpaste.com/714463/
>
> Clearly it's upset about how I've registered my Entry class. What is the
> problem and how do I fix it?
>
> --
> 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/-/kzW8_UbAjKcJ.
> 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.



How to interpret error messages

2012-03-10 Thread Rico
I'm trying to learn Django and have been following several online tutorials 
hoping to understand how to create my own projects. 

I'm having trouble interpreting the error messages that are given when I do 
something wrong. Unfortunately I don't seem to get much help when I try and 
find a solution via Google since I don't really know enough about Django to 
ask the right questions. Perhaps I can find help here? 

I don't know where to start exactly - the code is spread out all over! 
Let's start with the error message: 

http://dpaste.com/714463/ 

Clearly it's upset about how I've registered my Entry class. What is the 
problem and how do I fix it?

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



Why does Django not pass on error messages with the default 404 view?

2011-10-14 Thread yakiimo
The docs (https://docs.djangoproject.com/en/dev/topics/http/views/
#customizing-error-views) state, "The page_not_found view should
suffice for 99% of Web applications, but if you want to override it,
you can specify handler404 in your URLconf".

The page_not_found view only passes on the requested URL and ignores
any message you provide when raising an exception. It seems to me that
having the *option* to provide helpful hints to the 404.html template
by default would be good for everyone.

Could someone explain the reasoning here? I'm currently making a
custom view, but maybe it's a bad idea in practice?

A more specific context: I'm using matrix URLs so the base resource is
a normal hierarchical URL followed by matrix options in the basic
format of:
;filter_type1=item:value,item:value;filter_type2=item:value...

So it is quite easy to provide helpful messages based on how far along
the parsing gets before having an error. Wouldn't it be good to pass
on a message such as the following examples?
"Allowed filter_types: type1, type2, type3." or "Allowed items for
filter_type a: item1, item2, item3."

Apologies if I missed this explanation elsewhere. I've looked.

-- 
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: Overide error messages in models

2011-05-15 Thread Mohd Kamal Bin Mustafa
There's self._meta._fields() that you can call to get a list of fields
defined in that models but all the error_messages property attached to
that field is just a proxy object to something else. I try the
following in model's __init__ but it doesn't has any effect:-

class Thread(models.Model):
field1 = models.CharField(max_length=255)
field2 = ...
def __init__(self, *args, **kwargs):
super(Thread, self).__init__(*args, **kwargs)
for f in self._meta._fields():
if 'blank' in f.error_messages:
f.error_messages['blank'] = 'Needed.'

sorry can't dig further ...

-- 
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: Overide error messages in models

2011-05-15 Thread Shawn Milochik

On 05/15/2011 08:03 PM, Daniel França wrote:

I don't know if I understood, but the example you posted is about forms,
right?
That's the point, I don't wanna need to write forms to modify error
messages.


Yeah, it looks like the link I posted was about forms. I got a bit 
turned around after looking at the code for the field class:

http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/__init__.py

If you look there you'll see that there's a default_error_messages 
property of the Field base class that's inherited by all of your fields. 
It's not clear to me from that code how you should be overriding your 
field, or whether you can do it from a standard model declaration, but 
play with that. If you don't get it working then re-post asking for 
specifics based on what you find. Or maybe some knowledgeable person 
will read my half-baked info here and jump in with exactly what you need.


Shawn


--
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: Overide error messages in models

2011-05-15 Thread Daniel França
I don't know if I understood, but the example you posted is about forms,
right?
That's the point, I don't wanna need to write forms to modify error
messages.

On Thu, May 12, 2011 at 10:54 PM, Shawn Milochik  wrote:

> On 05/12/2011 09:35 PM, Daniel França wrote:
>
>> I wanna change the error messages without to need to rewrite fields code,
>> to
>> be more specific I want to translate them...
>>
>>
> Did you try setting the error_messages value?
>
> http://docs.djangoproject.com/en/1.3/ref/forms/validation/#using-validators
>
> There's a full example in this document, using e-mail field as an example.
> It's also translation-friendly, if you follow the convention of importing
> ugettext_lazy as _ (underscore) and using it in your model.
>
>
>
>
>
>
> --
> 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.



Re: Overide error messages in models

2011-05-12 Thread Shawn Milochik

On 05/12/2011 09:35 PM, Daniel França wrote:

I wanna change the error messages without to need to rewrite fields code, to
be more specific I want to translate them...



Did you try setting the error_messages value?

http://docs.djangoproject.com/en/1.3/ref/forms/validation/#using-validators

There's a full example in this document, using e-mail field as an 
example. It's also translation-friendly, if you follow the convention of 
importing ugettext_lazy as _ (underscore) and using it in your model.






--
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: Overide error messages in models

2011-05-12 Thread Daniel França
I wanna change the error messages without to need to rewrite fields code, to
be more specific I want to translate them...


On Thu, May 12, 2011 at 10:25 PM, Shawn Milochik  wrote:

> On 05/12/2011 08:08 PM, Daniel França wrote:
>
>> no way? I'll need to create new model forms?
>>
>> 2011/5/12 Daniel França
>>
>>  Hi all,
>>> I need to override error messages (like for required fields) directly in
>>> Models, I don't wanna duplicate code declaring some fields again in
>>> forms,
>>> and in some cases I don't even create the forms, just using generic views
>>> for model...
>>>
>>> I was looking for a solution to change the default error messages
>>> (without
>>> write this in all fields), but I didn't find anything, so I look for a
>>> solution to write the error messages right in Models, I found this:
>>> http://docs.djangoproject.com/en/dev/ref/models/fields/#error-messages
>>> I'm running django 1.2.5
>>>
>>> I did that for some fields in my model, and the error message still is
>>> the
>>> default message "This field is required".
>>>
>>> Anyone know how can I solve that without need to duplicate code?
>>>
>>>
>>>
> What exactly did you change to attempt to override the error messages?
>
>
>
> --
> 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.



Re: Overide error messages in models

2011-05-12 Thread Shawn Milochik

On 05/12/2011 08:08 PM, Daniel França wrote:

no way? I'll need to create new model forms?

2011/5/12 Daniel França


Hi all,
I need to override error messages (like for required fields) directly in
Models, I don't wanna duplicate code declaring some fields again in forms,
and in some cases I don't even create the forms, just using generic views
for model...

I was looking for a solution to change the default error messages (without
write this in all fields), but I didn't find anything, so I look for a
solution to write the error messages right in Models, I found this:
http://docs.djangoproject.com/en/dev/ref/models/fields/#error-messages
I'm running django 1.2.5

I did that for some fields in my model, and the error message still is the
default message "This field is required".

Anyone know how can I solve that without need to duplicate code?




What exactly did you change to attempt to override the error messages?


--
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: Overide error messages in models

2011-05-12 Thread k4ml
On May 13, 8:08 am, Daniel França  wrote:
> no way? I'll need to create new model forms?
>
> 2011/5/12 Daniel França 
> > I did that for some fields in my model, and the error message still is the
> > default message "This field is required".

I can't see any string 'error_messages' in django/db/models/' files so
the error message must be from django.forms. Maybe the documentation
is incorrect ? There's also no reference regarding error_messages for
models's field in the linked release page.

-- 
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: Overide error messages in models

2011-05-12 Thread Daniel França
no way? I'll need to create new model forms?

2011/5/12 Daniel França 

> Hi all,
> I need to override error messages (like for required fields) directly in
> Models, I don't wanna duplicate code declaring some fields again in forms,
> and in some cases I don't even create the forms, just using generic views
> for model...
>
> I was looking for a solution to change the default error messages (without
> write this in all fields), but I didn't find anything, so I look for a
> solution to write the error messages right in Models, I found this:
> http://docs.djangoproject.com/en/dev/ref/models/fields/#error-messages
> I'm running django 1.2.5
>
> I did that for some fields in my model, and the error message still is the
> default message "This field is required".
>
> Anyone know how can I solve that without need to duplicate code?
>
>

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



Overide error messages in models

2011-05-11 Thread Daniel França
Hi all,
I need to override error messages (like for required fields) directly in
Models, I don't wanna duplicate code declaring some fields again in forms,
and in some cases I don't even create the forms, just using generic views
for model...

I was looking for a solution to change the default error messages (without
write this in all fields), but I didn't find anything, so I look for a
solution to write the error messages right in Models, I found this:
http://docs.djangoproject.com/en/dev/ref/models/fields/#error-messages
I'm running django 1.2.5

I did that for some fields in my model, and the error message still is the
default message "This field is required".

Anyone know how can I solve that without need to duplicate code?

-- 
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: URLs in error messages from form validation

2011-04-28 Thread Derek
On Apr 28, 12:33 pm, Tom Evans  wrote:
> On Mon, Apr 25, 2011 at 11:40 PM, Daniel Gerzo  wrote:
> > PS: I'm just wondering where did you find this? I was looking around the
> > documentation and was unable to get any trace of such a function...
>
> http://docs.djangoproject.com/en/1.3/ref/utils/#module-django.utils.s...
>

And if you have written your own tags, you would have come across it
here:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping

-- 
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: URLs in error messages from form validation

2011-04-28 Thread Tom Evans
On Mon, Apr 25, 2011 at 11:40 PM, Daniel Gerzo  wrote:
> PS: I'm just wondering where did you find this? I was looking around the
> documentation and was unable to get any trace of such a function...
>

http://docs.djangoproject.com/en/1.3/ref/utils/#module-django.utils.safestring

Cheers

Tom

-- 
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: URLs in error messages from form validation

2011-04-25 Thread Daniel Gerzo

On 25.4.2011 18:00, Jason Culverhouse wrote:


You only need to mark the string as safe as in:

http://docs.djangoproject.com/en/1.3/ref/utils/#module-django.utils.safestring

from django.utils.safestring import mark_safe

raise forms.ValidationError(mark_safe('We already have this
filehere'))


This indeed works, thank you very much!

PS: I'm just wondering where did you find this? I was looking around the 
documentation and was unable to get any trace of such a function...


--
Best regards
  Daniel Gerzo

--
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: URLs in error messages from form validation

2011-04-25 Thread Jason Culverhouse

On Apr 25, 2011, at 5:39 AM, Kane Dou wrote:

> * Daniel Gerzo  [2011-04-25 13:07:46 +0200]:
> 
>> On 25.4.2011 12:40, Kane Dou wrote:
>>> * Daniel Gerzo  [2011-04-24 17:52:13 +0200]:
>>> 
 Hello all,
 
 say I have a following form:
 
 class MyForm(forms.Form):
id = forms.IntegerField(max_length=9)
language = forms.CharField(max_length=10)
file = forms.FileField()
 
 And a following pseudo clean method:
 
def clean(self):
for file in self.files.values():
if file_exists(file):
raise forms.ValidationError('We already have this
 filehere')
return self.cleaned_data

 
 So I want to display a URL in the error message. The text is
 displayed fine, but the URL is being escaped by Django and thus is
 not clickable. Is there some way to disable it for this specific
 case?

You only need to mark the string as safe as in:

http://docs.djangoproject.com/en/1.3/ref/utils/#module-django.utils.safestring

from django.utils.safestring import mark_safe

raise forms.ValidationError(mark_safe('We already have this
filehere'))

Jason

-- 
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: URLs in error messages from form validation

2011-04-25 Thread Kane Dou
* Daniel Gerzo  [2011-04-25 13:07:46 +0200]:

> On 25.4.2011 12:40, Kane Dou wrote:
> >* Daniel Gerzo  [2011-04-24 17:52:13 +0200]:
> >
> >>Hello all,
> >>
> >>say I have a following form:
> >>
> >>class MyForm(forms.Form):
> >> id = forms.IntegerField(max_length=9)
> >> language = forms.CharField(max_length=10)
> >> file = forms.FileField()
> >>
> >>And a following pseudo clean method:
> >>
> >> def clean(self):
> >> for file in self.files.values():
> >> if file_exists(file):
> >> raise forms.ValidationError('We already have this
> >>filehere')
> >> return self.cleaned_data
> >>
> >>So I want to display a URL in the error message. The text is
> >>displayed fine, but the URL is being escaped by Django and thus is
> >>not clickable. Is there some way to disable it for this specific
> >>case?
> >>
> >>The form is being rendered like:
> >>
> >>  >>id="upload">{% csrf_token %}
> >> 
> >> {{ form.as_table }}
> >>  >>/>
> >> 
> >> 
>
> >
> >You may check the 'safe'[1] filter
> >
> >
> >[1]  http://docs.djangoproject.com/en/1.3/ref/templates/builtins/#safe
>
> Hello Kane,
>
> thanks for your reply. I already tried |safe previously, as
>
> {{ form.as_table|safe }}
>
> but that doesn't work, the hyperlink is still being escaped. Maybe I
> need to do something else in this case?
>
> I even tried:
>
> {% autoescape off %}
> {{ form.as_table }}
> {% endautoescape %}
>
> Doesn't work either. Maybe the validation errors are being escaped
> prior they being passed to the template itself? How can I turn that
> off?
>
> Thanks.
>

Try to render the form in separate parts:

{{ form..label }}
{{ form..errors|safe }}
{{ form. }}

This works, but I'm not sure if this is a good or right practice.

--
Kane

-- 
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: URLs in error messages from form validation

2011-04-25 Thread Daniel Gerzo

On 25.4.2011 12:40, Kane Dou wrote:

* Daniel Gerzo  [2011-04-24 17:52:13 +0200]:


Hello all,

say I have a following form:

class MyForm(forms.Form):
 id = forms.IntegerField(max_length=9)
 language = forms.CharField(max_length=10)
 file = forms.FileField()

And a following pseudo clean method:

 def clean(self):
 for file in self.files.values():
 if file_exists(file):
 raise forms.ValidationError('We already have this
filehere')
 return self.cleaned_data

So I want to display a URL in the error message. The text is
displayed fine, but the URL is being escaped by Django and thus is
not clickable. Is there some way to disable it for this specific
case?

The form is being rendered like:

 {% csrf_token %}
 
 {{ form.as_table }}
 
 
 




You may check the 'safe'[1] filter


[1]  http://docs.djangoproject.com/en/1.3/ref/templates/builtins/#safe


Hello Kane,

thanks for your reply. I already tried |safe previously, as

{{ form.as_table|safe }}

but that doesn't work, the hyperlink is still being escaped. Maybe I 
need to do something else in this case?


I even tried:

{% autoescape off %}
{{ form.as_table }}
{% endautoescape %}

Doesn't work either. Maybe the validation errors are being escaped prior 
they being passed to the template itself? How can I turn that off?


Thanks.

--
Kind regards
  Daniel Gerzo

--
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: URLs in error messages from form validation

2011-04-25 Thread Kane Dou
* Daniel Gerzo  [2011-04-24 17:52:13 +0200]:

> Hello all,
>
> say I have a following form:
>
> class MyForm(forms.Form):
> id = forms.IntegerField(max_length=9)
> language = forms.CharField(max_length=10)
> file = forms.FileField()
>
> And a following pseudo clean method:
>
> def clean(self):
> for file in self.files.values():
> if file_exists(file):
> raise forms.ValidationError('We already have this
> file  here')
> return self.cleaned_data
>
> So I want to display a URL in the error message. The text is
> displayed fine, but the URL is being escaped by Django and thus is
> not clickable. Is there some way to disable it for this specific
> case?
>
> The form is being rendered like:
>
>  id="upload">{% csrf_token %}
> 
> {{ form.as_table }}
>  />
> 
> 
>
> Thanks.
>
> --
> Kind regards
>   Daniel Gerzo
>
> --
> 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 may check the 'safe'[1] filter


[1]  http://docs.djangoproject.com/en/1.3/ref/templates/builtins/#safe

--
Kane

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



URLs in error messages from form validation

2011-04-24 Thread Daniel Gerzo

Hello all,

say I have a following form:

class MyForm(forms.Form):
id = forms.IntegerField(max_length=9)
language = forms.CharField(max_length=10)
file = forms.FileField()

And a following pseudo clean method:

def clean(self):
for file in self.files.values():
if file_exists(file):
raise forms.ValidationError('We already have this file 
 here')

return self.cleaned_data

So I want to display a URL in the error message. The text is displayed 
fine, but the URL is being escaped by Django and thus is not clickable. 
Is there some way to disable it for this specific case?


The form is being rendered like:

id="upload">{% csrf_token %}


{{ form.as_table }}
type="reset" value="Reset" />




Thanks.

--
Kind regards
  Daniel Gerzo

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



error codes for validation error messages

2010-11-11 Thread ajaishankar
Hi

New to django, and just loving it!

Got the basics working - had the following question.

What would be the preferred way to associate an error code with an
error message (so that say it can be given back to an api call)

class MyForm(forms.Form):
   email = forms.CharField(error_messages={'invalid' : _('10001 :
Email address is invalid')})

If form validation fails I would want to send associated error code to
api client, but on the web interface the error code need not appear.

If I stick the code in the translatable string a I have done then
localization files might look ugly?

Any suggestions on how the rest of the world does it would be very
helpful :)

Thanks a bunch

Ajai

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How can you change the color of the form's error messages

2010-10-27 Thread Shawn Milochik
The errors are given a standard 'error' class. You can just add CSS to
modify it to your tastes.


Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



How can you change the color of the form's error messages

2010-10-27 Thread Akn
Hi all,
How can I customize the error message that comes from a form from
(e.g. change the color)

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-us...@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: Different E-mail Settings for Error Messages

2010-10-14 Thread Matt_313
Thank you Russell, worked great!

Matt.


On Oct 14, 12:22 am, Russell Keith-Magee 
wrote:
> On Wed, Oct 13, 2010 at 11:59 PM, Matt_313  wrote:
> > Hi,
>
> > I have a Django site that gets on average 6,000 visits a day. We use a
> > white listed e-mail server to send out e-mails to our customers (order
> > notifications, password resets etc.)
> > This costs a fraction of a cent per e-mail - so all the details are in
> > settings.py.
>
> > Today, something happened that caused Django to send thousands of
> > error messages to my email account.
> > I love this feature, but today I ended up paying quite a lot for
> > identical error messages.
>
> > Is there any way at all to specify different e-mail server settings
> > for error messages?
>
> In 1.2 stable -- It's possible, but a little complex; you need to
> define your own 500 error handler, duplicating the logic of the
> default handler, but mailing using your preferred server.
>
> In trunk -- yes. In trunk, 500 error emails are now handled as a log
> handler, which makes it easier to write and install custom behavior.
>
> Yours,
> Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Different E-mail Settings for Error Messages

2010-10-13 Thread Russell Keith-Magee
On Wed, Oct 13, 2010 at 11:59 PM, Matt_313  wrote:
> Hi,
>
> I have a Django site that gets on average 6,000 visits a day. We use a
> white listed e-mail server to send out e-mails to our customers (order
> notifications, password resets etc.)
> This costs a fraction of a cent per e-mail - so all the details are in
> settings.py.
>
> Today, something happened that caused Django to send thousands of
> error messages to my email account.
> I love this feature, but today I ended up paying quite a lot for
> identical error messages.
>
> Is there any way at all to specify different e-mail server settings
> for error messages?

In 1.2 stable -- It's possible, but a little complex; you need to
define your own 500 error handler, duplicating the logic of the
default handler, but mailing using your preferred server.

In trunk -- yes. In trunk, 500 error emails are now handled as a log
handler, which makes it easier to write and install custom behavior.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Different E-mail Settings for Error Messages

2010-10-13 Thread Matt_313
Hi,

I have a Django site that gets on average 6,000 visits a day. We use a
white listed e-mail server to send out e-mails to our customers (order
notifications, password resets etc.)
This costs a fraction of a cent per e-mail - so all the details are in
settings.py.

Today, something happened that caused Django to send thousands of
error messages to my email account.
I love this feature, but today I ended up paying quite a lot for
identical error messages.

Is there any way at all to specify different e-mail server settings
for error messages?

Thank you,
Matt.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Help :django registration - the account activation gives error messages

2010-09-19 Thread failuch
HI All,

I still have a problem with the last step of django-registration v
0.8.
After I enter the activation code, the registration indeed sets user
account to active and even sent me activation signal. But the
activation_complete.html template checks the presence of the account
variable but can't find it
So it shows me a an errr message.
I scanned a source code and found that registratin calls
the  post_activation_redirect function to get redirection url and then
the default backend
empties all params before doing the redirect.


Please help

Lev



On Sep 16, 4:05 pm, failuch  wrote:
> Hello, all.
> I have a problem with django registration v 0.8.
>  I use register and activate signals and I indeed got these signals
> and my functions worked well, except that account activation produces
> an error message.
>
> This error message gets printed if template did not have account
> variable.
>
> I really do not understand this, please advice
>
> ThX

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Help :django registration - the account activation gives error messages

2010-09-16 Thread failuch
Hello, all.
I have a problem with django registration v 0.8.
 I use register and activate signals and I indeed got these signals
and my functions worked well, except that account activation produces
an error message.

This error message gets printed if template did not have account
variable.

I really do not understand this, please advice

ThX


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Validation error messages without post

2010-08-20 Thread JP
Here is my form code as well:
from django import forms
from django.contrib.auth.models import User
from djangoproject1.authentication.models import UserProfile

class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ('username','password','email',)

class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ('phonenumber',)

On Aug 20, 11:05 am, JP  wrote:
> My main page contains a form.  Because I want the form to appear when
> I load my page my view looks like this:
>
> from djangoproject1.authentication import forms
> from django.http import HttpResponseRedirect
> from django.shortcuts import render_to_response
>
> def main(request):
>     uf = forms.UserForm()
>     upf = forms.UserProfileForm()
>     return render_to_response("authentication/index.html", {'form1':
> uf, 'form2':upf})
>
> def register(request):
>     if request.method == 'POST':
>         uf = forms.UserForm(request.POST)
>         upf = forms.UserProfileForm(request.POST)
>         if uf.is_valid() and upf.is_valid():
>             user = uf.save(commit=False)
>             user.set_password(uf.cleaned_data["password"])
>             user.save()
>             userprofile = upf.save(commit=False)
>             userprofile.user = user
>             userprofile.save()
>             return HttpResponseRedirect("/register-success/")
>     return render_to_response("authentication/index.html", {'form1':
> uf,'form2':upf})
>
> When I visit the main page, my URLConf points me to main.  If I were
> to hit submit, I would be directed to register.  The problem is, when
> I visit the page, all of the validation error messages for my fields
> are already shown for username and password.
>
> Here's my html:
>
> Register
>     
>         {{ form1.as_p }}
>         {{ form2.as_p }}
>         
>     
>
> 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-us...@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.



Validation error messages without post

2010-08-20 Thread JP
My main page contains a form.  Because I want the form to appear when
I load my page my view looks like this:

from djangoproject1.authentication import forms
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response

def main(request):
uf = forms.UserForm()
upf = forms.UserProfileForm()
return render_to_response("authentication/index.html", {'form1':
uf, 'form2':upf})

def register(request):
if request.method == 'POST':
uf = forms.UserForm(request.POST)
upf = forms.UserProfileForm(request.POST)
if uf.is_valid() and upf.is_valid():
user = uf.save(commit=False)
user.set_password(uf.cleaned_data["password"])
user.save()
userprofile = upf.save(commit=False)
userprofile.user = user
userprofile.save()
return HttpResponseRedirect("/register-success/")
return render_to_response("authentication/index.html", {'form1':
uf,'form2':upf})

When I visit the main page, my URLConf points me to main.  If I were
to hit submit, I would be directed to register.  The problem is, when
I visit the page, all of the validation error messages for my fields
are already shown for username and password.

Here's my html:

Register

{{ form1.as_p }}
{{ form2.as_p }}



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



customizing emailed error messages

2010-05-06 Thread Chris Curvey
When I get an unexpected error in my mod_wsgi/Django application, I'm
emailed a very nice error message with a stack trace and all the HTTP
environment variables (GET, POST, META, etc.)

That's great, but it does not include the name of the logged-in user.
Is there a way for me to add that information (or other useful stuff)
to the error message that is emailed?  I'm guessing it's a template
somewhere, but I can't find it

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



comments : error messages not in page layout

2009-10-30 Thread Niels

Hello,

I implemented the comments module.  When all fields properly field and
after a post everything is fine. Still on the same page. But when I
don't enter all fields I get another page with the error messages not
in the current page.

http://emberapp.com/niels390/images/comments-form-not-in-original-page

some help?

Thanks,
Niels


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



How do I display custom error messages to users?

2009-07-05 Thread Rex

There are situations on my site where I'd like to show the a page
telling them what they did wrong: their browser doesn't support
cookies, they erroneously try to re-submit a form, and so on.

However, I want to be notified by email whenever a user encounters one
of these errors, since I want to monitor that these errors don't
happen too frequently.

I see two options for doing this:

(1) Throw a 404/500 error whenever this occurs, and include a custom
error message in the template (e.g. "You weren't supposed to resubmit
the form."). I already have email error reporting turned on. However,
it doesn't look like there's built-in support for passing custom
strings to 404/500 templates (although I think I could just stick it
somewhere in the request object, which I can pass to the 404/500
template).

(2) Instead of throwing an error, just write a function called
report_error that emails an alert to the admin, like this:

report_error('ad...@mysite.com', request)

And then render a template to the user:

render_to_response('my_error_page.html', 'you weren't supposed to
resubmit the form')

Is there a better way of doing this? What is the best practice?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Confused by error messages

2009-01-22 Thread phoebebright

I managed to set debug to false and spend an hour trying to understand
this error:


  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/template/defaulttags.py", line 880, in
load
(taglib, e))

TemplateSyntaxError: 'openid_tags' is not a valid tag library: Could
not load template library from django.templatetags.openid_tags, No
module named openid_tags

But I'm not using openid_tags and no reference to openid anywhere in
my code! Then discovered what I'd done and set Debug to true.  Now the
error is:

DoesNotExist at /
Category matching query does not exist.
Request Method: GET
Request URL:http://127.0.0.1:8000/
Exception Type: DoesNotExist
Exception Value:
Category matching query does not exist.

Now that makes sense, but why the difference??

--~--~-~--~~~---~--~~
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: what is the status of inline unique_together non-fatal error messages?

2008-10-21 Thread Karen Tracey
On Tue, Oct 21, 2008 at 2:35 PM, bobhaugen <[EMAIL PROTECTED]> wrote:

>
> On Oct 21, 12:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > Well then the next step I would try is testing out the current patch for
> > general model validation, which is ticket #6845:
> >
> > http://code.djangoproject.com/ticket/6845
> >
> > Status on this was most recently reported here, I think:
> >
> > http://groups.google.com/group/django-developers/browse_thread/thread...
>
> That status message says:
> > known Issues
> > =
> >
> > * InlineFormSet.save_as_new is broken
>
> I do see a change in the last patch
> http://code.djangoproject.com/attachment/ticket/6845/6845-against-9226.diff
> for BaseGenericInlineFormSet, to preserve the parent foreign key for
> validation.
> But I don't think that's what Admin uses.
>

I don't know -- this isn't a case I've looked at, and I haven't tried that
patch myself yet.  One other ticket I just noticed that you might want to
keep an eye on is:

http://code.djangoproject.com/ticket/8882

That may be the exact case you are concerned with and it may get fixed
sooner than overall model validation gets into the code, but I'm just
guessing, since I'm not actually working on either of them myself.

Karen

--~--~-~--~~~---~--~~
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: what is the status of inline unique_together non-fatal error messages?

2008-10-21 Thread bobhaugen

On Oct 21, 12:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> Well then the next step I would try is testing out the current patch for
> general model validation, which is ticket #6845:
>
> http://code.djangoproject.com/ticket/6845
>
> Status on this was most recently reported here, I think:
>
> http://groups.google.com/group/django-developers/browse_thread/thread...

That status message says:
> known Issues
> =
>
> * InlineFormSet.save_as_new is broken

I do see a change in the last patch
http://code.djangoproject.com/attachment/ticket/6845/6845-against-9226.diff
for BaseGenericInlineFormSet, to preserve the parent foreign key for
validation.
But I don't think that's what Admin uses.




--~--~-~--~~~---~--~~
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: what is the status of inline unique_together non-fatal error messages?

2008-10-21 Thread Karen Tracey
On Tue, Oct 21, 2008 at 12:36 PM, bobhaugen <[EMAIL PROTECTED]> wrote:

>
> On Oct 21, 10:59 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > Have you tried whatever scenario you are particularly interested in on
> 1.0
> > or current code?
> >
> > Though general model validation did not make it into 1.0, checking of
> unique
> > and unique_together was added in changeset [8805].  It may not cover the
> > inline/missing parent foreign key value case, though -- I haven't tried
> > that.
>
> Karen, thanks for the reply.  But no luck.
>
> Just downloaded revision 9240.
>
> Tried unique_together constraint in admin both plain and with a form
> that overrode clean().
> Parent foreign key value is still None.  Can't check unique_together.
>

Well then the next step I would try is testing out the current patch for
general model validation, which is ticket #6845:

http://code.djangoproject.com/ticket/6845

Status on this was most recently reported here, I think:

http://groups.google.com/group/django-developers/browse_thread/thread/6143408977f7ad/d09c52e1fb561469
?

If the case you are interested in isn't covered by the current patch and is
not called out as something that isn't handled yet in the status (which I
have not read closely, so I don't know one way or the other) you might want
to bring it up as an issue either in the ticket or as a response to that
status note.

Karen

--~--~-~--~~~---~--~~
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: what is the status of inline unique_together non-fatal error messages?

2008-10-21 Thread bobhaugen

On Oct 21, 10:59 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> Have you tried whatever scenario you are particularly interested in on 1.0
> or current code?
>
> Though general model validation did not make it into 1.0, checking of unique
> and unique_together was added in changeset [8805].  It may not cover the
> inline/missing parent foreign key value case, though -- I haven't tried
> that.

Karen, thanks for the reply.  But no luck.

Just downloaded revision 9240.

Tried unique_together constraint in admin both plain and with a form
that overrode clean().
Parent foreign key value is still None.  Can't check unique_together.
--~--~-~--~~~---~--~~
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: what is the status of inline unique_together non-fatal error messages?

2008-10-21 Thread Karen Tracey
On Tue, Oct 21, 2008 at 11:39 AM, bobhaugen <[EMAIL PROTECTED]> wrote:

>
> I mean the normal displayable and user-correctable form validation
> errors, not the fatal database IntegrityError.
>
> I found
> http://groups.google.com/group/django-users/browse_thread/thread/f0e245366b02411b/df6d03f32eb37f93
> and
> http://www.djangosnippets.org/snippets/338/
> both more than a year old.
>
> In the first thread, Malcom Tredinnick says it's waiting for model-
> aware validation.
>
> The problem with overriding clean() in a form to do this is that for
> inlines, the parent foreign key value is missing, so you can't check
> for an existing record with the unique_together values.
>
> This thread in django-developers explains the problem in more detail,
> but also says "'wait for model-aware validation".  It's also a year
> old.
>
> http://groups.google.com/group/django-developers/browse_thread/thread/276fae9d4132225b/90324852d4e95426
>
> Any more progress, workarounds or tips?
>

Have you tried whatever scenario you are particularly interested in on 1.0
or current code?

Though general model validation did not make it into 1.0, checking of unique
and unique_together was added in changeset [8805].  It may not cover the
inline/missing parent foreign key value case, though -- I haven't tried
that.

Karen

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



what is the status of inline unique_together non-fatal error messages?

2008-10-21 Thread bobhaugen

I mean the normal displayable and user-correctable form validation
errors, not the fatal database IntegrityError.

I found 
http://groups.google.com/group/django-users/browse_thread/thread/f0e245366b02411b/df6d03f32eb37f93
and
http://www.djangosnippets.org/snippets/338/
both more than a year old.

In the first thread, Malcom Tredinnick says it's waiting for model-
aware validation.

The problem with overriding clean() in a form to do this is that for
inlines, the parent foreign key value is missing, so you can't check
for an existing record with the unique_together values.

This thread in django-developers explains the problem in more detail,
but also says "'wait for model-aware validation".  It's also a year
old.
http://groups.google.com/group/django-developers/browse_thread/thread/276fae9d4132225b/90324852d4e95426

Any more progress, workarounds or tips?
--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-27 Thread adrian olaru

You can try this:

class AAForm(forms.ModelForm):
fullname = forms.CharField(max_length=20,
error_messages={'required': 'Be there no name?'})
class Meta:
model = AuthorArtist

On Sep 22, 11:59 am, Donn <[EMAIL PROTECTED]> wrote:
> Hi,
> I would like to change the 'already exists' message when one adds a record
> that duplicates a unique one in the table.
> Nearest I can tell, the fields.error_messages do not offer a way to alter that
> message.
>
> Here's my basic code:
>
> class AAForm( ModelForm ):
>         def __init__(self,*args,**kwargs):
>                 super(AAForm, self).__init__(*args,**kwargs)
>                 self.fields['fullname'].error_messages = {
>                         'required':'Be there no name?',
>                         'already_exists':'blah' #<-- this one is a dud
>                         }
>         class Meta:
>                 model = AuthorArtist
> \d



--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-23 Thread Donn

On Tuesday, 23 September 2008 18:16:19 barbara shaurette wrote:
> Question 1: What are you using in your template to display the errors?
In the render to response I put {'formbugs': form.non_field_errors() } and in 
the template {{formbugs}}.

It really looks like the self.validate_unique() in clean does not do anything. 
I have not had time to look at the source.

> Question 2: Did you start working on this app on Talk Like a Pirate
> Day?
A ye have me matey! :D

\d

--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-23 Thread barbara shaurette

Question 1: What are you using in your template to display the errors?

Question 2: Did you start working on this app on Talk Like a Pirate
Day?


On Sep 23, 3:13 am, Donn <[EMAIL PROTECTED]> wrote:
> On Tuesday, 23 September 2008 11:42:19 Daniel Roseman wrote:> The __all__ 
> error messages are available via form.non_field_errors().
>
> I sent that along to the template, but it's still oddly silent.
>
> Some code:
> def clean(self):
>         try:
>                 self.validate_unique()
>         except forms.ValidationError:
>                 raise forms.ValidationError("Here be sea monsters!")
>
>         # If I unremark below it does raise the error, so it's running clean()
>         # but self.validate_unique() seems to have no effect.
>         # My model's field does have unique = True
>         # And the normal form error for a violation shows up -- the one I want
>         # to change.
>
>         #raise forms.ValidationError("This one will work.")
>         return self.cleaned_data
>
> I'm sure I've done something daft :)
> \d
--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-23 Thread Donn

On Tuesday, 23 September 2008 11:42:19 Daniel Roseman wrote:
> The __all__ error messages are available via form.non_field_errors().
I sent that along to the template, but it's still oddly silent.

Some code:
def clean(self):
try:
self.validate_unique()
except forms.ValidationError:
raise forms.ValidationError("Here be sea monsters!")

# If I unremark below it does raise the error, so it's running clean()
# but self.validate_unique() seems to have no effect.
# My model's field does have unique = True
# And the normal form error for a violation shows up -- the one I want
# to change.

#raise forms.ValidationError("This one will work.")
return self.cleaned_data

I'm sure I've done something daft :)
\d

--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-23 Thread Daniel Roseman

On Sep 23, 10:08 am, Donn <[EMAIL PROTECTED]> wrote:
> On Tuesday, 23 September 2008 08:47:10 Daniel Roseman wrote:> meantime maybe 
> you could define a clean() method and catch and re-
> > raise the ValidationError there.
>
> I tried that idea of yours and it has no effect on the error message. Looking
> at the source I see it's adding an error for a field called __all__ but I am
> not sure how to use that in the template.
>
> How would one i18nize the error messages? perhaps I can change the string at
> that point.
>
> \d


The __all__ error messages are available via form.non_field_errors().
--
DR.
--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-23 Thread Donn

On Tuesday, 23 September 2008 08:47:10 Daniel Roseman wrote:
> meantime maybe you could define a clean() method and catch and re-
> raise the ValidationError there.
I tried that idea of yours and it has no effect on the error message. Looking 
at the source I see it's adding an error for a field called __all__ but I am 
not sure how to use that in the template.

How would one i18nize the error messages? perhaps I can change the string at 
that point.

\d

--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-22 Thread Donn

On Tuesday, 23 September 2008 08:47:10 Daniel Roseman wrote:
> self.validate_unique()
Ah! That's the magic.
Thanks.

\d

--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-22 Thread Daniel Roseman

On Sep 22, 9:59 am, Donn <[EMAIL PROTECTED]> wrote:
> Hi,
> I would like to change the 'already exists' message when one adds a record
> that duplicates a unique one in the table.
> Nearest I can tell, the fields.error_messages do not offer a way to alter that
> message.
>
> Here's my basic code:
>
> class AAForm( ModelForm ):
>         def __init__(self,*args,**kwargs):
>                 super(AAForm, self).__init__(*args,**kwargs)
>                 self.fields['fullname'].error_messages = {
>                         'required':'Be there no name?',
>                         'already_exists':'blah' #<-- this one is a dud
>                         }
>         class Meta:
>                 model = AuthorArtist
> \d

No, apparently not. There's a ticket in for this (#8913) but in the
meantime maybe you could define a clean() method and catch and re-
raise the ValidationError there.

class AAForm(ModelForm):
 ... blah 

def clean(self):
try:
self.validate_unique()
except ValidationError:
raise ValidationError('Hey guys, this one's already
there!')
return self.cleaned_data

--
DR.
--~--~-~--~~~---~--~~
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: Changing field error messages

2008-09-22 Thread Donn

bump...

--~--~-~--~~~---~--~~
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: Newbie Question: How to display only error messages when form validation fails?

2008-09-22 Thread Steve Holden

Hanne Moa wrote:
> On Fri, Sep 19, 2008 at 7:34 PM, Karthik Krishnan
> <[EMAIL PROTECTED]> wrote:
>   
>> It throws a debug error page.
>> 
>
> What Kenneth was trying to say was *which* error was in the debug error page.
>
>   
>> On Sep 18, 10:01 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>> 
>>> On Friday 19 Sep 2008 7:02:06 am Karthik Krishnan wrote:
>>>
>>>   
>>>> The premise is this: If the form validation fails, I want to display
>>>> all the validation error messages on the top of the page in a special
>>>> div tag that I have created.
>>>> 
>>>> {% for field, message in form.errors.items()%}
>>>>   {{message}}
>>>> 
>>>> {% endfor %}
>>>> 
>
> Unless you're using jinja you're misunderstanding what's possible in a
> template. You can't have the () at the end of form.errors.items for
> one and I'm not sure about automatic tuple-unpacking either (the
> "field, message"-bit.) Django-templates ain't python.
>   
Maybe I have to be even more explicit than the message I posted four
days ago.

Instead of writing

{% for field, message in form.errors.items()%}
  {{message}}
{% endfor %}

Write

{% for field, message in form.errors.items %}
  {{message}}
{% endfor %}

As Hanne points out, you cannot use function calls inside Django template 
expressions: if the value is callable (as form.errors.items is) then it will be 
called automatically. And don't forget the space after the opening {% *and* 
before the closing %}.

regards
 Steve




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



Changing field error messages

2008-09-22 Thread Donn

Hi,
I would like to change the 'already exists' message when one adds a record 
that duplicates a unique one in the table.
Nearest I can tell, the fields.error_messages do not offer a way to alter that 
message.

Here's my basic code:

class AAForm( ModelForm ):
def __init__(self,*args,**kwargs):
super(AAForm, self).__init__(*args,**kwargs)
self.fields['fullname'].error_messages = {
'required':'Be there no name?',
'already_exists':'blah' #<-- this one is a dud
}
class Meta:
model = AuthorArtist
\d

--~--~-~--~~~---~--~~
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: Newbie Question: How to display only error messages when form validation fails?

2008-09-22 Thread Hanne Moa

On Fri, Sep 19, 2008 at 7:34 PM, Karthik Krishnan
<[EMAIL PROTECTED]> wrote:
> It throws a debug error page.

What Kenneth was trying to say was *which* error was in the debug error page.

> On Sep 18, 10:01 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>> On Friday 19 Sep 2008 7:02:06 am Karthik Krishnan wrote:
>>
>> > The premise is this: If the form validation fails, I want to display
>> > all the validation error messages on the top of the page in a special
>> > div tag that I have created.
>>
>> > {% for field, message in form.errors.items()%}
>> >   {{message}}
>>
>> > {% endfor %}

Unless you're using jinja you're misunderstanding what's possible in a
template. You can't have the () at the end of form.errors.items for
one and I'm not sure about automatic tuple-unpacking either (the
"field, message"-bit.) Django-templates ain't python.


HM

--~--~-~--~~~---~--~~
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: Newbie Question: How to display only error messages when form validation fails?

2008-09-19 Thread Karthik Krishnan

It throws a debug error page.

On Sep 18, 10:01 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On Friday 19 Sep 2008 7:02:06 am Karthik Krishnan wrote:
>
> > The premise is this: If the form validation fails, I want to display
> > all the validation error messages on the top of the page in a special
> > div tag that I have created.
>
> > {% for field, message in form.errors.items()%}
> >   {{message}}
>
> > {% endfor %}
>
> > returns a compilation error.
>
> what error
>
> --
> regards
> KGhttp://lawgon.livejournal.com
--~--~-~--~~~---~--~~
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: Newbie Question: How to display only error messages when form validation fails?

2008-09-19 Thread Kenneth Gonsalves

On Friday 19 Sep 2008 7:02:06 am Karthik Krishnan wrote:
> The premise is this: If the form validation fails, I want to display
> all the validation error messages on the top of the page in a special
> div tag that I have created.
>
> {% for field, message in form.errors.items()%}
>   {{message}}
>
> {% endfor %}
>
>
> returns a compilation error.

what error

-- 
regards
KG
http://lawgon.livejournal.com

--~--~-~--~~~---~--~~
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: Newbie Question: How to display only error messages when form validation fails?

2008-09-18 Thread Steve Holden

Karthik Krishnan wrote:
> Hi,
>
> The premise is this: If the form validation fails, I want to display
> all the validation error messages on the top of the page in a special
> div tag that I have created.
>
> {% for field, message in form.errors.items()%}
>   {{message}}
>   
Shouldn't that be

  {% for field, message in form.errors.items %}
> {% endfor %}
>
>
> returns a compilation error.
>
> I don't want to display both the field name and the error message, but
> only the error message. If I were to display
>
> {{form.errors}} in the html page, this is what i get.
>
> * town
>   o Please enter town.
> * postal_code
>   o Please enter postal code.
>
>
> I would like to display only the error messages. Is there anything I
> am doing wrong?
>
>   
regards
 Steve


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



Newbie Question: How to display only error messages when form validation fails?

2008-09-18 Thread Karthik Krishnan

Hi,

The premise is this: If the form validation fails, I want to display
all the validation error messages on the top of the page in a special
div tag that I have created.

{% for field, message in form.errors.items()%}
  {{message}}

{% endfor %}


returns a compilation error.

I don't want to display both the field name and the error message, but
only the error message. If I were to display

{{form.errors}} in the html page, this is what i get.

* town
  o Please enter town.
* postal_code
  o Please enter postal code.


I would like to display only the error messages. Is there anything I
am doing wrong?

Thanks,

Karthik
--~--~-~--~~~---~--~~
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: Translating Model Form Error Messages

2008-08-30 Thread Aaron

Hi Malcolm,

Thanks for the info.  It'll save me a lot of time, now that I know
where to look.

Aaron

On Aug 30, 1:03 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2008-08-30 at 12:57 -0700, Aaron wrote:
> > Hi, I'm working on a non-English site and need to replace the
> > validation messages from ModelForm (e.g. 'This field is required.')
> > What are some approaches that I can take?
>
> All those strings should already be translated. They're defined in
> django/forms/fields.py and you can see they're all marked for
> translation. So providing you are using the LocaleMiddleware (or some
> other way of setting the locale), the messages will appear naturally in
> the active locale for each viewer.
>
> If you want to replace/change the messages entirely, you need to replace
> them on the instances of the field classes. This would require some
> poking about under the hood for ModelForms, but should be possible. For
> normal forms, you can pass in an error_messages dictionary when you
> specify the form field that controls the messages. Again, have a look at
> django/forms/fields.py for how the default setup is done.
>
> 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: Translating Model Form Error Messages

2008-08-30 Thread Malcolm Tredinnick


On Sat, 2008-08-30 at 12:57 -0700, Aaron wrote:
> Hi, I'm working on a non-English site and need to replace the
> validation messages from ModelForm (e.g. 'This field is required.')
> What are some approaches that I can take?

All those strings should already be translated. They're defined in
django/forms/fields.py and you can see they're all marked for
translation. So providing you are using the LocaleMiddleware (or some
other way of setting the locale), the messages will appear naturally in
the active locale for each viewer.

If you want to replace/change the messages entirely, you need to replace
them on the instances of the field classes. This would require some
poking about under the hood for ModelForms, but should be possible. For
normal forms, you can pass in an error_messages dictionary when you
specify the form field that controls the messages. Again, have a look at
django/forms/fields.py for how the default setup is done.

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



Translating Model Form Error Messages

2008-08-30 Thread Aaron

Hi, I'm working on a non-English site and need to replace the
validation messages from ModelForm (e.g. 'This field is required.')
What are some approaches that I can take?

Thank you.
--~--~-~--~~~---~--~~
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: Injecting error messages into ModelForm

2008-07-13 Thread Karen Tracey
On Mon, Jul 14, 2008 at 12:33 AM, Torsten Bronger <
[EMAIL PROTECTED]> wrote:

>
> Hallöchen!
>
> Karen Tracey writes:
>
> > On Sun, Jul 13, 2008 at 8:20 AM, Torsten Bronger <
> > [EMAIL PROTECTED]> wrote:
> >
> >> While ModelForm.is_valid() finds field validation errors, it
> >> cannot catch errors in uniqueness or referential integrity as far
> >> as I can see.  Thus, I have to check them in my view.py code
> >> separately before calling save().
> >>
> >> If such errors are detected, I'd like to display them the same
> >> way as the other validation errors are displayed.  Is it possible
> >> to inject additional errors into a form?  [...]
> >
> > Ticket #7444 (http://code.djangoproject.com/ticket/7444) requests
> > an official API to support this; [...]  I have a feeling this has
> > come up a few times and the answer has been "we don't need an
> > official API, just access _errors", [...]
>
> As far as I can see, an API is needed at least for Form-level
> errors.  For example, if a Pizza should have at least one Topping
> (many-to-one relationship, I'd like to tell the user about it.  But
> this is certainly not associated with any field.
>

This is documented, see
http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validationunder
the discussion of the form-level clean() method:

"Note that any errors raised by your Form.clean() override will not be
associated with any field in particular. They go into a special "field"
(called __all__), which you can access via the non_field_errors() method if
you need to."

So the 'field' for non-field-specific-errors is named '__all__'.

Karen

--~--~-~--~~~---~--~~
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: Injecting error messages into ModelForm

2008-07-13 Thread Torsten Bronger

Hallöchen!

Karen Tracey writes:

> On Sun, Jul 13, 2008 at 8:20 AM, Torsten Bronger <
> [EMAIL PROTECTED]> wrote:
>
>> While ModelForm.is_valid() finds field validation errors, it
>> cannot catch errors in uniqueness or referential integrity as far
>> as I can see.  Thus, I have to check them in my view.py code
>> separately before calling save().
>>
>> If such errors are detected, I'd like to display them the same
>> way as the other validation errors are displayed.  Is it possible
>> to inject additional errors into a form?  [...]
>
> Ticket #7444 (http://code.djangoproject.com/ticket/7444) requests
> an official API to support this; [...]  I have a feeling this has
> come up a few times and the answer has been "we don't need an
> official API, just access _errors", [...]

As far as I can see, an API is needed at least for Form-level
errors.  For example, if a Pizza should have at least one Topping
(many-to-one relationship, I'd like to tell the user about it.  But
this is certainly not associated with any field.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: Injecting error messages into ModelForm

2008-07-13 Thread Karen Tracey
On Sun, Jul 13, 2008 at 8:20 AM, Torsten Bronger <
[EMAIL PROTECTED]> wrote:

>
> Hallöchen!
>
> While ModelForm.is_valid() finds field validation errors, it cannot
> catch errors in uniqueness or referential integrity as far as I can
> see.  Thus, I have to check them in my view.py code separately
> before calling save().
>
> If such errors are detected, I'd like to display them the same way
> as the other validation errors are displayed.  Is it possible to
> inject additional errors into a form?  Or are there better ways to
> detect and report "inter-form" errors?
>

Ticket #7444  (http://code.djangoproject.com/ticket/7444) requests an
official API to support this; in the meantime it also illustrates the method
that works now -- just access the _errors dictionary directly.  I have a
feeling this has come up a few times and the answer has been "we don't need
an official API, just access _errors", but I could be misremembering and
don't have time at the moment to research it.

Karen

--~--~-~--~~~---~--~~
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: Injecting error messages into ModelForm

2008-07-13 Thread Torsten Bronger

Hallöchen!

Andrew Ingram writes:

> ModelForm is really just a convenient subclass of Form, so if you
> want additional validation methods you just have to
> implement/override the clean methods like you would with a normal
> form.

The problem is that at the time the relational integrity checks take
place, the is_valid methods have already been called.  Can one call
them multiple times?

Additionally, in order to test e.g. for uniqueness, I need the
complete set of forms which I don't have in a clean() method.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: Injecting error messages into ModelForm

2008-07-13 Thread Andrew Ingram

ModelForm is really just a convenient subclass of Form, so if you want 
additional validation methods you just have to implement/override the 
clean methods like you would with a normal form. The ease of validation 
that newforms allows is actually one of the main reasons I prefer Django 
over other frameworks i've tried.

- Andrew Ingram

Torsten Bronger wrote:
> Hallöchen!
>
> While ModelForm.is_valid() finds field validation errors, it cannot
> catch errors in uniqueness or referential integrity as far as I can
> see.  Thus, I have to check them in my view.py code separately
> before calling save().
>
> If such errors are detected, I'd like to display them the same way
> as the other validation errors are displayed.  Is it possible to
> inject additional errors into a form?  Or are there better ways to
> detect and report "inter-form" errors?
>
> Tschö,
> Torsten.
>
>   


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



Injecting error messages into ModelForm

2008-07-13 Thread Torsten Bronger

Hallöchen!

While ModelForm.is_valid() finds field validation errors, it cannot
catch errors in uniqueness or referential integrity as far as I can
see.  Thus, I have to check them in my view.py code separately
before calling save().

If such errors are detected, I'd like to display them the same way
as the other validation errors are displayed.  Is it possible to
inject additional errors into a form?  Or are there better ways to
detect and report "inter-form" errors?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: Validations and error messages

2008-07-12 Thread Jason S. Friedman

> Hi,
> 
> This is my second hour with django. I have been working Rails but now
> I am learnign some django too.
> 
> I wonder how do you validate numeric, alphabetic, mix, special
> characters data before calling save() ?
> 
> And do you get any return after calling save()? I didnt get any on
> Shell.
> I actually want to redirect the user based on validations.

Have a look at http://www.djangoproject.com/documentation/newforms/.

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



Validations and error messages

2008-07-12 Thread Will Rocisky

Hi,

This is my second hour with django. I have been working Rails but now
I am learnign some django too.

I wonder how do you validate numeric, alphabetic, mix, special
characters data before calling save() ?

And do you get any return after calling save()? I didnt get any on
Shell.
I actually want to redirect the user based on validations.

--~--~-~--~~~---~--~~
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: Really, realy strange MySQLdb problem, cycling through error messages.

2008-05-20 Thread Rishabh Manocha

There was a permission denied error 'cause if your webserver was
running under some user other than root (as it should be), it won't be
able to write to the root's home directory (as it shouldn't).

Assuming you are using Apache with mod_python, here is something you
could put in your httpd.conf:

SetEnv PYTHON_EGG_CACHE /tmp/python-eggs

Include this with the rest of your settings for the django app.

Best,

R

On Wed, May 21, 2008 at 3:04 AM, Rodrigo Culagovski
<[EMAIL PROTECTED]> wrote:
>
> For future reference: fixed, it stabilized to the 3rd error message. I
> added this to __init.py__ in the application's directory:
>
> import os
> os.environ['PYTHON_EGG_CACHE'] = '/tmp'
>
> Apparently there was some permission error on '/root/.python-eggs'
> >
>

--~--~-~--~~~---~--~~
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: Really, realy strange MySQLdb problem, cycling through error messages.

2008-05-20 Thread Rodrigo Culagovski

For future reference: fixed, it stabilized to the 3rd error message. I
added this to __init.py__ in the application's directory:

import os
os.environ['PYTHON_EGG_CACHE'] = '/tmp'

Apparently there was some permission error on '/root/.python-eggs'
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >