Django admin site display (None) even when values are non-null/empty

117 views
Skip to first unread message

Aditya Sriram M

unread,
Apr 30, 2012, 9:52:11 PM4/30/12
to django...@googlegroups.com

I have been trying a lot but could not make out why it happens,

class FortressUserAdmin(admin.ModelAdmin):    
list_display
(. . . , get_my_schema)    
def get_my_schema(self, obj):
    sql_query
= "select prop_val from customer_property where customer_id = %d and property_value like '%%%%SCHEMA%%%%'" % obj.customer_id.customer_id    
    property_value
= connection.cursor().execute(sql_query).fetch_one()        
   
print sql_query        
   
return 1
   
# return "aditya"
get_my_schema
.short_description = 'Schema Instance'

  • why the column values are always (None)
  • why the print 1 or print 'aditya' won't print anything to the console

Screen shot of the column admin site: enter image description here

Aditya Sriram M

unread,
May 1, 2012, 9:24:50 AM5/1/12
to django...@googlegroups.com
Okay!! My bad.. was using the wrong function to fetch. Use fetchone() instead.
Reply all
Reply to author
Forward
0 new messages