python - appending foreign key reference in django json response -


during appending result (appending foreign key ) causes key error

models.py

class table1     id = models.integerfield( primary key=true)     ref = models.foreignkey('table2')  class table2     name = models.charfield()     id = models.integerfield(primarykey= true)     address = models.charfield() 

views.py

def relation(request) """     stuff """     query = "query set makes object of table 1"      result['content'].append([query['ref__address']) 

the error

keyerror @ /url ref__address 

def relation(request, pk):     item = get_object_or_404(table1, pk=pk)     context= {'content': item}     return render(request, 'table1/relation.html', context)  urlpatterns = patterns('',     url(r'^table1/(?p<pk>\d+)/$', relation, name='relation'), ) 

your problem seems none of python valid.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -