I have something like this:
class Translation1(models.Model):
code = models.IntegerField(primary_key=True)
description = models.CharField()
class Translation2(models.Model):
code = models.IntegerField(primary_key=True)
description = models.CharField()
class TranslationN(models.Model):
code = models.IntegerField(primary_key=True)
description = models.CharField()
class MainDB (models.Model):
tr1_code = models.IntegerField() #code from Translation1
tr2_code = models.IntegerField() #code from Translation2
tr3_code = models.IntegerField() #code from Translation3
name = models.CharField()
model = models.CharField ()
some_field1 = models.CharField ()
some_fieldN = models.CharField ()
How can I get info from MainDB, but code1 description instead of
tr1_code, code2 description instead of tr2_code
For limiting fields I've created a manager for MainDB, and it works
fine. Then I've tried to do like this:
class my_MainDB (MainDB):
tr1_value = models.ForeignKey (Translation1)
#views.py
result = my_MainDB.gos_req.select_related() #gos_req - my manager
but I see it is wrong, because djando doesn't know that tr1_value must
be related to tr1_code field...
The raw sql query is look like this:
SELECT
A1,A2,A20,A18,A45,A4,A5,A41,A36,A38,K1,K2,A27,A25,FED.RA,FED.N1,EC.RA,EC.N1,A34
FROM C12B,RKA,C014P FED,C014P EC WHERE A34='02100' AND A38=K1 AND
A41=FED.RA AND A36=EC.RA ORDER BY A1
c12b - is MainDB; RKA, C014P... - are like translation1 (2,3,...)
Is my only way is using this RAW SQL?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---