Re: Models and relationships

2015-07-07 Thread Rafael E. Ferrero
Nice!! Chris good work !! -- Rafael E. Ferrero 2015-07-06 20:15 GMT-03:00 Chris Strasser : > WOO HOO !.. success ... thanks everyone... > just needed a nudge in the right direction I will tackle the > templates tomorrow and see where that takes me. > > On Mon, Jul 6, 2015 at 2:24 PM, Rafae

Re: Models and relationships

2015-07-06 Thread Chris Strasser
WOO HOO !.. success ... thanks everyone... just needed a nudge in the right direction I will tackle the templates tomorrow and see where that takes me. On Mon, Jul 6, 2015 at 2:24 PM, Rafael E. Ferrero wrote: > contacts = Contacts.objects.select_related() > > -- > Rafael E. Ferrero > > 201

Re: Models and relationships

2015-07-06 Thread Rafael E. Ferrero
contacts = Contacts.objects.select_related() -- Rafael E. Ferrero 2015-07-06 13:51 GMT-03:00 Florian Schweikert : > On 06/07/15 14:04, Chris Strasser wrote: > > my problem is with reverse lookups (i think it is called) the docs say > that i can access entries through blog.entry,(by lowercaseing

Re: Models and relationships

2015-07-06 Thread Florian Schweikert
On 06/07/15 14:04, Chris Strasser wrote: > my problem is with reverse lookups (i think it is called) the docs say that i > can access entries through blog.entry,(by lowercaseing the class) > it appears to me that i have the same setup with contact and location but i > am getting errors ?? I thin

Re: Models and relationships

2015-07-06 Thread Vijay Khemlani
Try with Contact.objects.all()[0] On Mon, Jul 6, 2015 at 1:03 PM, Chris Strasser wrote: > I tried and this happens: > > from main.models import Contact > > >>> contact = Contact.all()[0] > > Traceback (most recent call last): > > File "", line 1, in > > AttributeError: type object 'Contact'

Re: Models and relationships

2015-07-06 Thread Chris Strasser
I tried and this happens: from main.models import Contact >>> contact = Contact.all()[0] Traceback (most recent call last): File "", line 1, in AttributeError: type object 'Contact' has no attribute 'all' >>> ?? any ideas ? On Mon, Jul 6, 2015 at 8:43 AM, Sadaf Noor wrote: > If you ha

Re: Models and relationships

2015-07-06 Thread Rafael E. Ferrero
For start you don't need to specify the primary key (orgid for example) [1] In foreingkeys you need to use related names [2] In views use select_related() [3] [1] https://docs.djangoproject.com/en/1.8/ref/models/fields/#primary-key [2] https://docs.djangoproject.com/en/1.8/ref/models/fields/#fore

Re: Models and relationships

2015-07-06 Thread Sadaf Noor
If you have at least one entry in contact with a valid location, then it should work: from app.models import Contact > contact = Contact.all()[0] > print contact.locationid.locationname 2015-07-06 18:04 GMT+06:00 Chris Strasser : > Hi ,I am fairly new to Django and am struggling with models hop

Models and relationships

2015-07-06 Thread Chris Strasser
Hi ,I am fairly new to Django and am struggling with models hope someone can sort me out. Models: class Organization(models.Model): #customer or vendor person or company orgid = models.AutoField(db_column='OrgID', primary_key=True) is_company = models.NullBooleanField(db_column='Is