I have a table called *Customers* that has a field *Booked_By* which 
references *auth_user,* when i attempt to display the details of Booked_By 
in one view* (viewBookings) *with *db(...).select(....)* all i get are 
their IDs but when i display them in another view* (Client_Updates)* with 
*SQLFORM(....).process(....) 
*their usernames are selected for me & displayed, when I try to use* 
{{=bookings.Booked_By.first_name}} *in* (viewBookings) *I get a message 
that * <type 'exceptions.AttributeError'> 'NoneType' object has no 
attribute 'first_name'. *How can i get the details that i want to be 
displayed in both of these views from the* Booked_By* field?

*MODEL CODE:*
db.define_table('Customer',
                Field('Name', requires=IS_NOT_EMPTY()),
                Field('Surname', requires=IS_NOT_EMPTY()),
                Field('ID_Number', requirs=IS_NOT_EMPTY()),
                Field('Contact_Number', requires=IS_NOT_EMPTY()),
                Field('Method_of_Payment', 'reference Method_of_Payment'),
                Field('Amount', 'integer'),
                Field('Booking_Date', 'datetime', default=request.now, 
writable=False),
                Field('Check_In', 'datetime'),
                Field('Check_Out', 'datetime'),
                Field('Room',  'reference Room', unique=True),
                Field('Room_Status', 'reference Status'),
                Field('Booked_By', 'reference auth_user', writable=False)
               )

*CONTROLLERS*
@auth.requires_login()
def index():
    form=SQLFORM(db.Customer)
    if auth.user:
        db.Customer.Booked_By.default = auth.user.id
    if form.accepts(request.vars, session):
        response.flash = T("CLIENT BOOKED")
    return locals();

def viewBookings():
    bookings=db(db.Customer).select(db.Customer.ALL, orderby=db.Customer.
Surname)
    return locals();

def Client_Updates():
    client=db.Customer(request.args(0))
    #details=db(db.Customer).select(db.Customer.ALL)
    clientDetails=SQLFORM(db.Customer, client.id).process()
    return locals()

*VIEWS:*
*view bookings*
{{for bookings in bookings:}}
    
    <tr>
        <td>
{{=A(bookings.Surname, _href=URL('Client_Update', args=bookings.id))}} {{=
bookings.Name}}
        </td>
    
        <td>
 Room {{=bookings.Room.Room_Number}}
        </td>
        <td>
<span id="status">{{=bookings.Room_Status.Room_Status}}</span>
        </td>
        
        <td>
            {{if auth.user:}}
     {{=bookings.Booked_By.first_name}}
            {{pass}}
            {{pass}}
        </td>
    </tr>


*Client_Updates:*
<div>
    <span class="formTitle">VIEW & UPDATE CLIENT DETAILS</span>
    {{=clientDetails}}
</div>


I could Use all the help i can get.

Regards

Mostwanted

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to