Re: GET parameters in admin "add" model page

2014-05-12 Thread Russell Keith-Magee
Hi,

On Sun, May 11, 2014 at 11:42 PM, ?manu*  wrote:

> I noticed that django admin "add" page reads GET parameters and uses them
> as initial values in the form. However I was not able to pass DateTime
> values in this way. In particular if I try to pass a DateTime value I get a
> "server error".
>
> See
> http://stackoverflow.com/questions/23559771/django-admin-add-page-initial-datetime-from-get-parametersfor
>  more details.
>
> 1. is it possible to pass DateTime values this way?
>

Yes, but not "out of the box". I've responded on the SO thread; but the
short answer is that you need to override get_changeform_initial_data() in
your ModelAdmin class.

2. isn't it a bug if a user is able to generate a server error by messing
> with GET parameters?
>
>
Not necessarily. It's only a bug if, when *using the APIs as documented*, a
user is able to generate a server error by providing faulty GET arguments.
Taking the extreme case of the argument - if you write a view that
knowingly does divide by zero, it's not a bug in Django that the user is
able to generate a 500 by visiting that view. In your case, the argument is
much more subtle, but you still have code that is "wrong", and as a result,
it's raising a 500.

Yours,
Russ Magee %-)

-- 
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/CAJxq848E1_aWzdkDzfUfDFWJRxkzwUkU5ySuUbHhF8_TeP%2BXng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


GET parameters in admin "add" model page

2014-05-11 Thread ?manu*
I noticed that django admin "add" page reads GET parameters and uses them 
as initial values in the form. However I was not able to pass DateTime 
values in this way. In particular if I try to pass a DateTime value I get a 
"server error". 

See 
http://stackoverflow.com/questions/23559771/django-admin-add-page-initial-datetime-from-get-parameters
 
for more details. 

1. is it possible to pass DateTime values this way?

2. isn't it a bug if a user is able to generate a server error by messing 
with GET parameters?

thanks
E.

-- 
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/4021a36d-81d2-41ff-a160-f04fe0fc8513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.