Monday, April 30, 2012

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


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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/liHNhbNpk_QJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment