hello I am attempting to relate two existing tables 

class Circuitinfotable(models.Model):
    id1 = models.AutoField(primary_key=True, null=False, unique=True)
    pid = models.CharField(max_length=255, blank=True, null=True)
    circuitid = models.CharField(max_length=255, blank=True, null=True)
    bandwidth = models.CharField(max_length=255, blank=True, null=True, 
choices=bandwidth_list)
    region = models.CharField(max_length=255, blank=True, null=True, 
choices=region_list)
    bw = models.IntegerField(blank=True, null=True)
    pathname = models.CharField(max_length=255, blank=True, null=True)
    handoffalocaddress = models.CharField(max_length=255, blank=True, 
null=True)
    handoffaloccity = models.CharField(max_length=255, blank=True, 
null=True)
    handoffalocst = models.CharField(max_length=255, blank=True, null=True)
    alocationaddress = models.CharField(max_length=255, blank=True, 
null=True)
    alocationcity = models.CharField(max_length=255, blank=True, null=True)

class Budgettable(models.Model):
    id = models.CharField(primary_key=True, max_length=255)
    circuitid = models.CharField(max_length=255, blank=True, null=True)
    pid = models.CharField(max_length=255, blank=True, null=True)
    monthnum = models.IntegerField(blank=True, null=True)
    yearnum = models.IntegerField(blank=True, null=True)
    budgetmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
    actualmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
    region = models.CharField(max_length=255, blank=True, null=True)
    circuitref = models.ForeignKey(Circuitinfotable, 
on_delete=models.CASCADE, to_field='id1')

    class Meta:
        managed = False

If open a shell and import Circuitinfotable and Budget and run the 
following code:
from finance.models import Circuitinfotable, Budget
c=Circuitinfotable.objects.get(id1=695)
c.budget
c.budget_set.all

I get an error:
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'Circuitinfotable' object has no attribute 'budget'

or 

Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'Circuitinfotable' object has no attribute 'budget_set'

I set up my budget file to have the circuitref populated with the id1 field 
of the Circuitinfotable.

In my code I can query these two objects and manually relate them myself in 
the view but I cannot get the django ORM to do this for me.  Any 
suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com.

Reply via email to