Tuesday, April 9, 2013

Re: How to rename objects (Urgent)

On Tue, Apr 9, 2013 at 1:23 AM, Giorgos Kontogiorgakis
<shortgeorgeaek@yahoo.com> wrote:
> Hi Serdar!
>

Hi!

>
> class Links(models.Model):
> interfacein = models.CharField(max_length=20L, db_column='InterfaceIn')
> interfaceout = models.CharField(max_length=20L,
> db_column='InterfaceOut')
> capacity = models.FloatField(null=True, db_column='Capacity',
> blank=True)
> delay = models.FloatField(null=True, db_column='Delay', blank=True)
> class Meta:
> db_table = 'Links'
>
> So,on my interface when i click on the "Links" i can see the objects that
> are into my database,all of them have the name "Links objects" and then when
> i click on 1 of them THEN i can see my fields.I don't want to change the
> name on any field or something but the name of "Link objects"
>

So, If I understood you right, you should define __unicode__ method in
the Links table. And return the representation of the objects.

> Links-->Links object(multiple times)[i want to change
> that]-->interfacein,interfaceout,capacity,delay(with their values)
> Thx for ur time and i hope you can help me :))
>

Add this method to your List Class.
def __unicode__(self):
return "%s, %s, %s, %s" % (self.interfacein, self.interfaceout,
self.capacity, self.delay)

The values will be casted to string. If you want, you can change the
format of the floating numbers while creating the return string.

My suggestion is, just write a __unicode__ method, and start playing
with it. :) Btw, no need to syncdb ;)

I hope this helps.

--
- Serdar Dalgıç <sd@serdardalgic.org>
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate