I have a model with no primary key. it has the id's from other models. I want to call iid_ id.
For example iid_id = 1.
There are 21 rows with the number 1. I want to grab all the rows and display them on a HTML table.
The Model:
class QryDescChar(models.Model):
iid_id = models.IntegerField()
cid_id = models.IntegerField()
cs = models.CharField(max_length=10)
cid = models.IntegerField()
charname = models.CharField(max_length=50)
class Meta:
db_table = u'qry_desc_char'
This is the SQL for the Model:
CREATE VIEW qry_desc_char as
SELECT tbl_desc.iid_id,
tbl_desc.cid_id,
tbl_desc.cs,
tbl_char.cid,
tbl_char.charname
FROM tbl_desc, tbl_char
WHERE tbl_desc.cid_id = tbl_char.cid;
the view:
def itemdetail(request, iid):
i = get_object_or_404(Item, pk=iid) #this is from another model
row = ????????
return render_to_response('tbl/itemdetail.html', {'item': i, 'row': row})
I have tried everything and i cant get the rows on the HTML to display. This might be a stupid question. Im new at Django and cant make this work.