Re: Saving Child Records via ForeignKeyField

2010-04-29 Thread Atamert Ölçgen
You initialize (__init__) your ZoneType model instead of create()'ing. When you save an initialized it doesn't get an id magically. I suggest you to use ZoneType.objects.create() whenever possible. But if you must init your model first; make sure you get() it again to retrieve its id. Remember

Re: Saving Child Records via ForeignKeyField

2010-04-29 Thread bheathr
elated.get_accessor_name()) for child_object in r[1][rd]: query_set.add(child_object) Thanks for pointing me in the right direction with the query set. It still seems like the models could do this for me when it looks up the values from ForeignKeyField objects. If they d

Re: Saving Child Records via ForeignKeyField

2010-04-28 Thread akonsu
hello, it would be easier to help if you provided your modes. are you missing this: http://docs.djangoproject.com/en/dev/ref/models/relations/#ref-models-relations for example: >>> b = Blog.objects.get(id=1) >>> e = b.entry_set.create( ... headline='Hello', ... body_text='Hi', ... p

Saving Child Records via ForeignKeyField

2010-04-28 Thread Robinson B. Heath
I believe I have done my due diligence, but point me in the right direction if I am missing something. I am working on a generic importing engine to import various file formats(csv, fixed length, etc) into django models based on json formatted file definitions. It needs to do something like th

Re: ForeignKeyField

2010-03-26 Thread Asim Yuksel
You know what I am trying to solve this for about 2 days. Thank you so much it worked :) All my respects to your brain :) On 26 Mart, 20:04, Karen Tracey wrote: > On Fri, Mar 26, 2010 at 8:00 PM, Asim Yuksel wrote: > > > I've tried this. > > The model is > > > class Advisors(models.Model): > >  

Re: ForeignKeyField

2010-03-26 Thread Karen Tracey
On Fri, Mar 26, 2010 at 8:00 PM, Asim Yuksel wrote: > I've tried this. > The model is > > class Advisors(models.Model): > advisorid = models.IntegerField(primary_key=True, > db_column='advisorId') # Field name made lowercase. >maphdid = models.ForeignKey(Tblmaphds, db_column='maPhDId') # >

Re: ForeignKeyField

2010-03-26 Thread Asim Yuksel
I've tried this. The model is class Advisors(models.Model): advisorid = models.IntegerField(primary_key=True, db_column='advisorId') # Field name made lowercase. maphdid = models.ForeignKey(Tblmaphds, db_column='maPhDId') # Field name made lowercase. rank = models.SmallIntegerField()

Re: ForeignKeyField

2010-03-26 Thread Karen Tracey
On Fri, Mar 26, 2010 at 4:31 PM, Asim Yuksel wrote: > here is the list display > > > http://picasaweb.google.com/110428031719333287170/BaslKsZAlbum#5453042316004332754 > > I want that to appear in a list display, because that is what the > client wants :) > > I tried writing unicode method , but i

Re: ForeignKeyField

2010-03-26 Thread Asim Yuksel
here is the list display http://picasaweb.google.com/110428031719333287170/BaslKsZAlbum#5453042316004332754 I want that to appear in a list display, because that is what the client wants :) I tried writing unicode method , but it has no effect.I dont know why.And when I try to use maphdid_id, it

Re: ForeignKeyField

2010-03-26 Thread Daniel Roseman
On Mar 26, 4:44 pm, Asim Yuksel wrote: > Yes foreignkey is an object but there must be a way to display the > value in a list_display. I am a newbie too. self.maphdid.id doesnt > work The underlying id field is called "maphdid_id", so you should be able to use that. But I have no idea why you'd w

Re: ForeignKeyField

2010-03-26 Thread Asim Yuksel
Yes foreignkey is an object but there must be a way to display the value in a list_display. I am a newbie too. self.maphdid.id doesnt work On 26 Mart, 06:05, Thierry Chich wrote: > Le vendredi 26 mars 2010 04:14:51, Asim Yuksel a écrit : > > > I have a question about model.ForeignKey field.Foreig

Re: ForeignKeyField

2010-03-26 Thread Thierry Chich
Le vendredi 26 mars 2010 04:14:51, Asim Yuksel a écrit : > I have a question about model.ForeignKey field.Foreign key fields are > shown as object in admin page. How can I show them in other types like > integer type > for example I have a Model like this: > > class Advisor(models.Model): > >

Re: ForeignKeyField

2010-03-25 Thread Asim Yuksel
I cant show the foreignkey values in a list_display. I tried raw_id_fields but didnt work On 25 Mart, 23:18, Shawn Milochik wrote: > This should help: > > http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#raw-id-fields > > Shawn -- You received this message because you are subscribed to t

Re: ForeignKeyField

2010-03-25 Thread Shawn Milochik
This should help: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#raw-id-fields Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, s

ForeignKeyField

2010-03-25 Thread Asim Yuksel
I have a question about model.ForeignKey field.Foreign key fields are shown as object in admin page. How can I show them in other types like integer type for example I have a Model like this: class Advisor(models.Model): advisorid = models.IntegerField(primary_key=True, db_column='advisorId')

Re: Forms ForeignKeyField does not populate with initial value

2009-12-08 Thread bruno desthuilliers
On 8 déc, 13:26, Michael wrote: > ^ Thanks for that.  Have been scratching my head for a while as .id is > not a field/property for model.user, according to the doco I am > reading anyway (http://docs.djangoproject.com/en/dev/topics/auth/ > #topics-auth). When no primary key is explicitely defi

Re: Forms ForeignKeyField does not populate with initial value

2009-12-08 Thread Michael
^ Thanks for that. Have been scratching my head for a while as .id is not a field/property for model.user, according to the doco I am reading anyway (http://docs.djangoproject.com/en/dev/topics/auth/ #topics-auth). I should have just tried .id in the first place : \ ... actually you'd think chil

Re: Forms ForeignKeyField does not populate with initial value

2009-11-26 Thread Todd Blanchard
OK, this did lead me to the solution though. It seems that, for the ForeignKeyField the initial value should be the primary key of the record and not the object referenced. So changing >> form = IncidentForm(initial={ >>'reporter': request.user, to

Re: Forms ForeignKeyField does not populate with initial value

2009-11-26 Thread Todd Blanchard
I want it to be possible to be changed. But I also want the initial selection to be the current user. So this isn't really a solution. Thanks anyway. On Nov 26, 2009, at 10:27 AM, esatterwh...@wi.rr.com wrote: > in your IncidentForm definition set reporter to a ModelChoiceField > (User.object

Re: Forms ForeignKeyField does not populate with initial value

2009-11-26 Thread esatterwh...@wi.rr.com
in your IncidentForm definition set reporter to a ModelChoiceField (User.objects.all(), widget=forms.HiddenInput()) then it should work out ok. I usually hide fk fields to a user if i want the current request.user object, because I don't want to allow the possibility for it to be changed. On Nov

Forms ForeignKeyField does not populate with initial value

2009-11-25 Thread Todd Blanchard
I have a (simplified) model class Incident(models.Model): title = models.CharField(max_length=128) when_reported = models.DateTimeField(auto_now_add=True) reporter = models.ForeignKey(User) Where User is from auth. When used with a ModelForm, this creates a popup button with a list