Re: Empty template_name for login

2008-08-26 Thread Ludwig
Well spotted, that was it. Not sure where I got the (.*) from, it is
certainly not in the documentation.

Thanks
Ludwig

2008/8/26 Karen Tracey <[EMAIL PROTECTED]>

> On Tue, Aug 26, 2008 at 7:21 AM, Ludwig <[EMAIL PROTECTED]>wrote:
>
>>
>> ('^accounts/login/(.*)', 'django.contrib.auth.views.login'),
>> ('^accounts/profile/(.*)', 'django.contrib.auth.views.profile'),
>> ('^accounts/logout/(.*)', 'django.contrib.auth.views.logout',
>> {'next_page': '/'}),
>>
>
> OK, I see what the problem is now.  You've specified these urlpatterns to
> capture a parameter at the end.  So anything that follows the trailing slash
> of 'login' (in your case, an empty string) will be passed as the first
> parameter (template_name) to login.  If you try to go to
> 'accounts/login/xyzzy/', e.g. you will see that the template name it looks
> for will be 'xyzzy'.  You need to removethe '(.*)' on the end of all these
> urlpatterns.
>
> 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: Empty template_name for login

2008-08-26 Thread Karen Tracey
On Tue, Aug 26, 2008 at 7:21 AM, Ludwig <[EMAIL PROTECTED]> wrote:

>
> ('^accounts/login/(.*)', 'django.contrib.auth.views.login'),
> ('^accounts/profile/(.*)', 'django.contrib.auth.views.profile'),
> ('^accounts/logout/(.*)', 'django.contrib.auth.views.logout',
> {'next_page': '/'}),
>

OK, I see what the problem is now.  You've specified these urlpatterns to
capture a parameter at the end.  So anything that follows the trailing slash
of 'login' (in your case, an empty string) will be passed as the first
parameter (template_name) to login.  If you try to go to
'accounts/login/xyzzy/', e.g. you will see that the template name it looks
for will be 'xyzzy'.  You need to removethe '(.*)' on the end of all these
urlpatterns.

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: Empty template_name for login

2008-08-26 Thread Ludwig
Apologies for subjecting people to my debugging effort, but I have now tried
to replicate the problem with a minimal installation.

I create a new project with django-admin.py, and simply edit the database
settings to fit my DB, then run syncdb.
Then I create a minimal urls.py like this:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^tt/', include('tt.foo.urls')),

# Uncomment the next line to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
('^accounts/login/(.*)', 'django.contrib.auth.views.login'),
('^accounts/profile/(.*)', 'django.contrib.auth.views.profile'),
('^accounts/logout/(.*)', 'django.contrib.auth.views.logout',
{'next_page': '/'}),

)

Going to /accounts/login will now try to load the template u'', which it
cannot find of course because the string is empty. (Call stack as in my
previous post).

Now if I change my urls.py to set the template_name directly, I get
TypeError at /accounts/login/

login() got multiple values for keyword argument 'template_name'


The urls.py for this is (nothing changed but the explict template_name
parameter  for login)

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^tt/', include('tt.foo.urls')),

# Uncomment the next line to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
('^accounts/login/(.*)', 'django.contrib.auth.views.login',
{'template_name' : '/registration/login.html'}),
('^accounts/profile/(.*)', 'django.contrib.auth.views.profile'),
('^accounts/logout/(.*)', 'django.contrib.auth.views.logout',
{'next_page': '/'}),

)

Can someone else recreate this problem with SVN trunk (or beta1)? or is it
somehow a strange setup problem on my machine here?

Ludwig


2008/8/26 Ludwig <[EMAIL PROTECTED]>

> I just tried the same with a fresh installation from SVN trunk and get the
> same error.
>
> 2008/8/26 Ludwig <[EMAIL PROTECTED]>
>
> Try again:
>>
>> If I do this in urls.py
>>
>> ...
>> ('^accounts/login/(.*)', 'django.contrib.auth.views.login'),
>> ...
>>
>> I get TemplateDoesNotExist exception, because the template parameter is
>> empty. The full snippet is
>> http://dpaste.com/73893/
>> The template name is empty already at the callback (line 33) - so it gets
>> lost rather early.
>>
>>
>> If I do this (nothing else changed at all):
>> ...
>> ('^accounts/login/(.*)', 'django.contrib.auth.views.login',
>> {'template_name': 'registration/login.html'}),
>> ...
>>
>> I get
>> TypeError at /accounts/login/ login() got multiple values for keyword
>> argument 'template_name' (one of them seems to be empty, the other one the
>> one I pass in).If I hardcode the template name in the django code as a
>> hack, it works, so there is nothing wrong with my template.
>>
>> It is a straight django 1.0 beta1 installation on Python 251 on XP.
>>
>> Bizarre.
>>
>> Ludwig
>>
>> 2008/8/25 Karen Tracey <[EMAIL PROTECTED]>
>>
>> 2008/8/25 Ludwig <[EMAIL PROTECTED]>
>>>
 I am using the 1.0 beta 1 release.

 I think I am following the documentation, when I set

 ('^accounts/login/(.*)', 'django.contrib.auth.views.login', {}),

 in my urls.py

 But then I get a TemplateDoesNotExist exception when opening
 /accounts/login.

 The template (standard registration/login.html) does exist, but somehow
 the template name gets lost in Django and it looks for an empty template
 name u''.
 Below is the relevant snippet from the error page:

>>> [snip]
>>>
>>> The snippet is a bit too abbreviated to be of use.  It would be better if
>>> you selected the "Switch to copy-and-paste view" link and then the "Share
>>> this traceback on a public web site" button to post the traceback to
>>> dpaste.com and then post the link.
>>>
>>>
 If I set the template name explicitly, I get the error that the kw arg
 is doubly defined.
 (If in auth.views.login I set the template_name explictly to my
 template, overriding the empty string, it works, so my template is ok)


>>>  You should be able to set the template name explicitly like so:
>>>
>>> ('^accounts/login/(.*)', 'django.contrib.auth.views.
>>> login', {'template_name': 'path/login_template_name'}),
>>>
>>> If that is what you tried and you got some error about a kwarg being
>>> doubly defined that is rather mysterious.
>>>
>>> Karen
>>>
>>> >>>
>>>
>>
>

--~--~-~--~~~---~--~~
You received this message because you a

Re: Empty template_name for login

2008-08-26 Thread Ludwig
I just tried the same with a fresh installation from SVN trunk and get the
same error.

2008/8/26 Ludwig <[EMAIL PROTECTED]>

> Try again:
>
> If I do this in urls.py
>
> ...
> ('^accounts/login/(.*)', 'django.contrib.auth.views.login'),
> ...
>
> I get TemplateDoesNotExist exception, because the template parameter is
> empty. The full snippet is
> http://dpaste.com/73893/
> The template name is empty already at the callback (line 33) - so it gets
> lost rather early.
>
>
> If I do this (nothing else changed at all):
> ...
> ('^accounts/login/(.*)', 'django.contrib.auth.views.login',
> {'template_name': 'registration/login.html'}),
> ...
>
> I get
> TypeError at /accounts/login/ login() got multiple values for keyword
> argument 'template_name' (one of them seems to be empty, the other one the
> one I pass in).If I hardcode the template name in the django code as a
> hack, it works, so there is nothing wrong with my template.
>
> It is a straight django 1.0 beta1 installation on Python 251 on XP.
>
> Bizarre.
>
> Ludwig
>
> 2008/8/25 Karen Tracey <[EMAIL PROTECTED]>
>
> 2008/8/25 Ludwig <[EMAIL PROTECTED]>
>>
>>> I am using the 1.0 beta 1 release.
>>>
>>> I think I am following the documentation, when I set
>>>
>>> ('^accounts/login/(.*)', 'django.contrib.auth.views.login', {}),
>>>
>>> in my urls.py
>>>
>>> But then I get a TemplateDoesNotExist exception when opening
>>> /accounts/login.
>>>
>>> The template (standard registration/login.html) does exist, but somehow
>>> the template name gets lost in Django and it looks for an empty template
>>> name u''.
>>> Below is the relevant snippet from the error page:
>>>
>> [snip]
>>
>> The snippet is a bit too abbreviated to be of use.  It would be better if
>> you selected the "Switch to copy-and-paste view" link and then the "Share
>> this traceback on a public web site" button to post the traceback to
>> dpaste.com and then post the link.
>>
>>
>>> If I set the template name explicitly, I get the error that the kw arg is
>>> doubly defined.
>>> (If in auth.views.login I set the template_name explictly to my template,
>>> overriding the empty string, it works, so my template is ok)
>>>
>>>
>>  You should be able to set the template name explicitly like so:
>>
>> ('^accounts/login/(.*)', 'django.contrib.auth.views.
>> login', {'template_name': 'path/login_template_name'}),
>>
>> If that is what you tried and you got some error about a kwarg being
>> doubly defined that is rather mysterious.
>>
>> 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: Empty template_name for login

2008-08-26 Thread Ludwig
Try again:

If I do this in urls.py

...
('^accounts/login/(.*)', 'django.contrib.auth.views.login'),
...

I get TemplateDoesNotExist exception, because the template parameter is
empty. The full snippet is
http://dpaste.com/73893/
The template name is empty already at the callback (line 33) - so it gets
lost rather early.


If I do this (nothing else changed at all):
...
('^accounts/login/(.*)', 'django.contrib.auth.views.login',
{'template_name': 'registration/login.html'}),
...

I get
TypeError at /accounts/login/login() got multiple values for keyword
argument 'template_name' (one of them seems to be empty, the other one the
one I pass in).If I hardcode the template name in the django code as a hack,
it works, so there is nothing wrong with my template.

It is a straight django 1.0 beta1 installation on Python 251 on XP.

Bizarre.

Ludwig

2008/8/25 Karen Tracey <[EMAIL PROTECTED]>

> 2008/8/25 Ludwig <[EMAIL PROTECTED]>
>
>> I am using the 1.0 beta 1 release.
>>
>> I think I am following the documentation, when I set
>>
>> ('^accounts/login/(.*)', 'django.contrib.auth.views.login', {}),
>>
>> in my urls.py
>>
>> But then I get a TemplateDoesNotExist exception when opening
>> /accounts/login.
>>
>> The template (standard registration/login.html) does exist, but somehow
>> the template name gets lost in Django and it looks for an empty template
>> name u''.
>> Below is the relevant snippet from the error page:
>>
> [snip]
>
> The snippet is a bit too abbreviated to be of use.  It would be better if
> you selected the "Switch to copy-and-paste view" link and then the "Share
> this traceback on a public web site" button to post the traceback to
> dpaste.com and then post the link.
>
>
>> If I set the template name explicitly, I get the error that the kw arg is
>> doubly defined.
>> (If in auth.views.login I set the template_name explictly to my template,
>> overriding the empty string, it works, so my template is ok)
>>
>>
>  You should be able to set the template name explicitly like so:
>
> ('^accounts/login/(.*)', 'django.contrib.auth.views.
> login', {'template_name': 'path/login_template_name'}),
>
> If that is what you tried and you got some error about a kwarg being doubly
> defined that is rather mysterious.
>
> 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: Empty template_name for login

2008-08-25 Thread Karen Tracey
2008/8/25 Ludwig <[EMAIL PROTECTED]>

> I am using the 1.0 beta 1 release.
>
> I think I am following the documentation, when I set
>
> ('^accounts/login/(.*)', 'django.contrib.auth.views.login', {}),
>
> in my urls.py
>
> But then I get a TemplateDoesNotExist exception when opening
> /accounts/login.
>
> The template (standard registration/login.html) does exist, but somehow the
> template name gets lost in Django and it looks for an empty template name
> u''.
> Below is the relevant snippet from the error page:
>
[snip]

The snippet is a bit too abbreviated to be of use.  It would be better if
you selected the "Switch to copy-and-paste view" link and then the "Share
this traceback on a public web site" button to post the traceback to
dpaste.com and then post the link.


> If I set the template name explicitly, I get the error that the kw arg is
> doubly defined.
> (If in auth.views.login I set the template_name explictly to my template,
> overriding the empty string, it works, so my template is ok)
>
>
 You should be able to set the template name explicitly like so:

('^accounts/login/(.*)', 'django.contrib.auth.views.login',
{'template_name': 'path/login_template_name'}),

If that is what you tried and you got some error about a kwarg being doubly
defined that is rather mysterious.

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



Empty template_name for login

2008-08-25 Thread Ludwig
I am using the 1.0 beta 1 release.

I think I am following the documentation, when I set

('^accounts/login/(.*)', 'django.contrib.auth.views.login', {}),

in my urls.py

But then I get a TemplateDoesNotExist exception when opening
/accounts/login.

The template (standard registration/login.html) does exist, but somehow the
template name gets lost in Django and it looks for an empty template name
u''.
Below is the relevant snippet from the error page:

for middleware_method in self._view_middleware:
response = middleware_method(request, callback, callback_args,
callback_kwargs)
if response:
return response
try:

response = callback(request, *callback_args, **callback_kwargs) ...

except Exception, e:
# If the view raised an exception, run it through exception
# middleware, and if the exception middleware returns a
# response, use that. Otherwise, reraise the exception.
for middleware_method in self._exception_middleware:
response = middleware_method(request, e)

▼ Local vars
Variable Value
callback

callback_args
(u'',)
callback_kwargs
{}
e
TemplateDoesNotExist(u'',)


If I set the template name explicitly, I get the error that the kw arg is
doubly defined.
(If in auth.views.login I set the template_name explictly to my template,
overriding the empty string, it works, so my template is ok)

Any idea what is going on here?

Ludwig

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