Re: enforce login on generic views

2005-11-12 Thread Ian Holsman

Hi Adrian.
would it be too hard to just stick the 'user login' views in the main codebase?

regards
ian

On 11/13/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 11/12/05, Bryan Murdock <[EMAIL PROTECTED]> wrote:
> > How do I limit access to a generic view to logged in users?
>
> Hey Bryan,
>
> I've added a section to the docs for you:
>
> Limiting access to generic views
> http://www.djangoproject.com/documentation/authentication/#limiting-access-to-generic-views
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: enforce login on generic views

2005-11-12 Thread Bryan Murdock

On 11/12/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 11/12/05, Bryan Murdock <[EMAIL PROTECTED]> wrote:
> > How do I limit access to a generic view to logged in users?
>
> Hey Bryan,
>
> I've added a section to the docs for you:

All for me?  I'm...I'm touched.

:-)

After that kind of generosity, I hate to ask more annoying questions,
but is it possible to customize the url of the login page that the
login_required decorator uses?  Glancing at the source it doesn't look
like it.

The problem is, I set up my test site with www.example.com/appname so
that plain old apache serves www.example.com/anything_but_appname. 
The default of /accounts/login doesn't get sent to django at all for
me.

It's not a huge deal, I put a test for anonymous user in the generic
view wrapper myself.  It works very nicely.

Bryan


Re: enforce login on generic views

2005-11-12 Thread Adrian Holovaty

On 11/12/05, Bryan Murdock <[EMAIL PROTECTED]> wrote:
> How do I limit access to a generic view to logged in users?

Hey Bryan,

I've added a section to the docs for you:

Limiting access to generic views
http://www.djangoproject.com/documentation/authentication/#limiting-access-to-generic-views

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


Re: problem with sessions docs?

2005-11-12 Thread Bryan Murdock

On 11/12/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
> Hey Bryan,
>
> This technically isn't an error in the docs; it's just a bit
> misleading. The "user" in that example wasn't intended to be the user
> from the authentication framework -- it's just some generic concept of
> "user."
>
> I've changed the example to use "member" instead of "user," to
> underscore the fact that it's some random concept of "member" -- not
> the "users" from the authentication system.

Ahhh, now I see.  Thanks!

Bryan


Re: problem with sessions docs?

2005-11-12 Thread Adrian Holovaty

On 11/12/05, Bryan Murdock <[EMAIL PROTECTED]> wrote:
> The example code for logging a user in here:
>
> http://www.djangoproject.com/documentation/sessions/
> [...]
> It doesn't work for me.  I googled and found some code here:
> [...]
> Is this an error in the docs?  Maybe I need to svn up?

Hey Bryan,

This technically isn't an error in the docs; it's just a bit
misleading. The "user" in that example wasn't intended to be the user
from the authentication framework -- it's just some generic concept of
"user."

I've changed the example to use "member" instead of "user," to
underscore the fact that it's some random concept of "member" -- not
the "users" from the authentication system.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


enforce login on generic views

2005-11-12 Thread Bryan Murdock

How do I limit access to a generic view to logged in users?

Bryan


problem with sessions docs?

2005-11-12 Thread Bryan Murdock

The example code for logging a user in here:

http://www.djangoproject.com/documentation/sessions/

is this:

def login(request):
u = users.get_object(username__exact=request.POST['username'])
if u.check_password(request.POST['password']):
request.session['user_id'] = u.id
return HttpResponse("You're logged in.")
else:
return HttpResponse("Your username and password didn't match.")

It doesn't work for me.  I googled and found some code here:

http://cvd.cidev.nl/wordpress/?p=245

That basically makes one small change resulting in this:

def login(request):
u = users.get_object(username__exact=request.POST['username'])
if u.check_password(request.POST['password']):

# CHANGE: different key used:
request.session[users.SESSION_KEY] = u.id
return HttpResponse("You're logged in.")
else:
return HttpResponse("Your username and password didn't match.")

Which then works for me.  Is this an error in the docs?  Maybe I need to svn up?

Thanks,

Bryan


Re: Using strftime() in datetime fields

2005-11-12 Thread Eric Walstad

On Friday 11 November 2005 06:56 pm, Jeffrey E. Forcier wrote:
> One trick I've found that helps in debugging is to throw out all  
> assumptions, and to work backwards from a traceback while doing so.
>
> In your case, Python is telling you that what you *think* and what  
> *really ought to be* a DateTime object is instead a string. So,  
> double-check--print out the value of type(object.datetimefield)  
> sometime just prior to where the traceback hits. Do a dir() on it.  
> Stuff like that. It seems dumb and simple but it often helps.
>
> The other thing is to look at the differences between the two  
> environments, or between what you're doing in the prompt and what's  
> happening in the view. Again, throw out assumptions and double-check  
> *everything* surrounding the problem object.
>
> One thing that might help us target specific things going wrong is if  
> you pasted the model class definition, and what specifically you're  
> doing in the prompt to try and simulate the problematic view code.
>
> Regards,
> Jeff

Well said, Jeff.  Thanks for taking the time to give Pedro related tips.  I 
want to help, but am very busy lately so my responses, when I have time to 
give them are terse (hopefully, consise as well).
Best,
Eric.


Re: broken admin links to logout and change password

2005-11-12 Thread Bryan Murdock

On 11/12/05, Grigory Fateyev <[EMAIL PROTECTED]> wrote:
>
> Hello Bryan Murdock!
> On Sat, 12 Nov 2005 07:34:42 -0800 you wrote:
>
> >
> > My site is set up with mod_python so that to get to the admin page you
> > go to:
> >
> > example.com/appname/admin
> >
> > In the admin view the links for logging out and changing password are
> > broken.  They use example.com/admin/..., leaving out the appname.  How
> > can I fix this?
>
> Maybe in admin template?

Yes, I can go into django/contrib/admin/templates/base.html and fix it
there, but that just doesn't seem as clean as how the branding stuff
was able to be modified.  I was hoping for something more like that.

Bryan


use admin features in external applications

2005-11-12 Thread frank h.

hello,
how can i reuse some features of the admin app in my external
applications?
the search_fields and date_hierarchy features are so nice!
is there a simple way?
-frank



Re: broken admin links to logout and change password

2005-11-12 Thread Grigory Fateyev

Hello Bryan Murdock!
On Sat, 12 Nov 2005 07:34:42 -0800 you wrote:

> 
> My site is set up with mod_python so that to get to the admin page you
> go to:
> 
> example.com/appname/admin
> 
> In the admin view the links for logging out and changing password are
> broken.  They use example.com/admin/..., leaving out the appname.  How
> can I fix this?

Maybe in admin template?

-- 
Всего наилучшего!
greg [at] anastasia [dot] ru Григорий.


broken admin links to logout and change password

2005-11-12 Thread Bryan Murdock

My site is set up with mod_python so that to get to the admin page you go to:

example.com/appname/admin

In the admin view the links for logging out and changing password are
broken.  They use example.com/admin/..., leaving out the appname.  How
can I fix this?

Thanks,

Bryan