Hi everyone, 

this is probably a trivial issue but I'm struggling with it! When I try and 
reference a field from another table I can get it to reference the id of 
the desired row, however I can't get it to reference the name associated 
with that id. I've highlighted the lines of code that are causing me issues.

This is my code atm:
*In views:*

  <tr>
            <td><a href="{{=URL('editdevtasklist', 
args=row.devtasklist.id)}}">{{=row.auth_user.FullName}}</a></td>
            <td>{{=row.devtasklist.jobtype}}</td>
            <td>{{=row.devtasklist.priority}}</td>
            <td>{{=row.devtasklist.projectid}}</td>
            <td>{{=row.devtasklist.heading}}</td>
            <td>{{=row.devtasklist.attachment}}</td>
            <td>{{=row.devtasklist.duedate}}</td>
        </tr>

# When the above code is referenced  I get only the 'id number'
# When the code below is used I receive an attribute error...

<td>{{=row.Project.ProjectName}}</td>

*In controller:*
def listdevtasklist():
    
    print_time = datetime.now()
    rows = db(db.devtasklist.userid == 
db.auth_user.id).select(orderby=db.auth_user.FullName)
    db(db.devtasklist.projectid == 
db.Project.id).select(db.Project.ProjectName)
    return locals()

*In db:*
db.define_table('devtasklist',
                Field("userid", "reference auth_user", label="User", 
requires=IS_IN_DB(db, db.auth_user.id, '%(first_name)s %(last_name)s')),
                Field('projectid', 'reference Project', label="Project", 
requires=IS_IN_DB(db, db.Project.id, '%(ProjectName)s')),
                Field("jobtype", requires = IS_IN_SET(("Admin", "Data 
analysis", "Data upload", "Fulcrum", "GIS", "Survey rep", "Programming", 
"Reports"))),
                Field("priority", label="Priority Level", requires = 
IS_IN_SET(task_priorities)),
                Field("duedate", "date", label="Due on", requires = 
IS_DATE(format=('%d-%m-%Y'))),
                Field("attachment","upload", autodelete=True, 
uploadseparate=True),
                Field("heading", label="Heading"),
                Field('completed', "boolean")
               )



The confusing thing for me is that the userid converts into a 'FullName' 
absolutely fine, but the projectid won't convert into a 'ProjectName'...

Any help greatly appreciated.

J

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/52634cc1-3585-4ce1-b945-1ff7750043ab%40googlegroups.com.

Reply via email to