Replaced `auth_user` fields 'first_name' and 'last_name' with 'name'; now getting errors

232 views
Skip to first unread message

Alec Taylor

unread,
Dec 28, 2012, 1:21:01 AM12/28/12
to web...@googlegroups.com
Replaced auth_user fields 'first_name' and 'last_name' with 'name';
now I am getting errors.

My reasoning for using a single 'name' field is to shorten the time it
takes for new users to sign up.

They are able to add more to their profile after this, but the concept
with my website is people will signup on "impulse" thus its signup
forms need to contain as few fields as possible.

I have done a grep of my entire app and 'first_name' is not mentioned
anywhere; except in my errors directory!

It seems that `gluon\tools.py` has hard-coded for you to use the
'first_name' with 'last_name' convention.

Can we make this a parameter instead?

Or is there another way I can get around this?

Thanks for all suggestions,

Alec Taylor

BTW: The error is: `<type 'exceptions.AttributeError'> 'Row' object
has no attribute 'first_name'`

Bruno Rocha

unread,
Dec 28, 2012, 1:28:25 AM12/28/12
to web...@googlegroups.com
Please provide a full ticket traceback for us to see where exactly it is happening.


--




Bruno Rocha

unread,
Dec 28, 2012, 1:33:11 AM12/28/12
to web...@googlegroups.com
I think your problem is in navbar()

navbar function uses a parameter user_identifier which is DEFAULT to %(first_name)s but you can change it.

go to your layout.html and replace

auth.navbar(mode="dropdown")

with

auth.navbar(mode="dropdown", user_identifier="%(name)s")

Bruno Rocha

unread,
Dec 28, 2012, 1:41:01 AM12/28/12
to web...@googlegroups.com

For the record:


If you use auth.signature it will raise an error do I propose to change it to:

return '%s %s' % (user.get("first_name", "email"), user.get("last_name", ""))

or some other check.

Alec Taylor

unread,
Dec 28, 2012, 2:10:34 AM12/28/12
to web...@googlegroups.com
Thanks, but that also isn't working: `<type
'exceptions.AttributeError'> 'Row' object has no attribute
'first_name'`

But I do get a different traceback, i.e., here:

web2py\gluon\tools.py", line 1285, in navbar
user_identifier = user_identifier % self.user
> --
>
>
>

Massimo Di Pierro

unread,
Dec 28, 2012, 3:03:23 PM12/28/12
to web...@googlegroups.com
{{=auth.navbar(user_identifier='%(email)s')}}

This defaults to user_identifier='%(first_name)s' but you do not have a first name.

Alec Taylor

unread,
Dec 28, 2012, 10:12:01 PM12/28/12
to web...@googlegroups.com
Thanks, but that still isn't working for me.

Interesting parts of the traceback:

<type 'exceptions.AttributeError'>('Row' object has no attribute 'first_name')

web2py\gluon\dal.py in __getitem__ at line 6453 code arguments variables
Function argument list

(self=<Row {'interests': ['chocolate'], 'registration_...1,
'name': '', 'email': 'alect...@gmail.com'}>, key='first_name')

Maybe there's some way to change the 'key' there?

On Sat, Dec 29, 2012 at 7:03 AM, Massimo Di Pierro
<massimo....@gmail.com> wrote:
> {{=auth.navbar(user_identifier='%(email)s')}}

Massimo Di Pierro

unread,
Dec 28, 2012, 11:45:49 PM12/28/12
to web...@googlegroups.com
We can fix this but.... can't you just leave the first_name and last_name fields alone, as suggested in the book, but make them invisible? readable=False, writable=False. And just change the field used in the navbar as in the example?

Alec Taylor

unread,
Dec 28, 2012, 11:49:38 PM12/28/12
to web...@googlegroups.com
That's what I've been doing so far (just 'first_name' was needed).

But if at all possible I would like as few fields as possible per table.

I also wanted to set the primary key of that table to 'email', but it
looks like you have to have the 'id' field no matter what.

> On Friday, 28 December 2012 21:12:01 UTC-6, Alec Taylor wrote:
>>
>> Thanks, but that still isn't working for me.
>>
>> Interesting parts of the traceback:
>>
>> <type 'exceptions.AttributeError'>('Row' object has no attribute
>> 'first_name')
>>
>> web2py\gluon\dal.py in __getitem__ at line 6453 code arguments
>> variables
>> Function argument list
>>
>> (self=<Row {'interests': ['chocolate'], 'registration_...1,
>> 'name': '', 'email': 'alect...@gmail.com'}>, key='first_name')
>>
>> Maybe there's some way to change the 'key' there?
>>
>> On Sat, Dec 29, 2012 at 7:03 AM, Massimo Di Pierro
>> <massimo....@gmail.com> wrote:
>> > {{=auth.navbar(user_identifier='%(email)s')}}
>
> --
>
>
>
Reply all
Reply to author
Forward
0 new messages