Thank you Emily For pointing me to right direction.

On Jul 24, 11:41 am, Emily Rodgers <emily.kate.rodg...@googlemail.com>
wrote:
> On Jul 23, 11:06 pm, urosh <uros.ga...@gmail.com> wrote:
>
>
>
> > Hi.
>
> > I want to create phone book. I want that this phone book list will be
> > ordered by number of dialing this number. I think of using two tables
> > one with phone numbers and one for phone dialing statistics (how many
> > times user dialed number). Each user has his own ordering rule based
> > on his user-name. I will populate this phonebook statistics with other
> > function regular running.
>
> > This is what I have so far.
>
> > class phonebook(models.Model):
> >         person_company = models.CharField(blank=True,max_length=30)
> >         address = models.CharField(blank=True,max_length=50)
> >         e_mail = models.EmailField(blank=True,max_length=70)
> >         number = models.CharField(unique=True,max_length=15)
> >         dialed = models.ForeignKey('phonebook_stat')
> >         def __unicode__(self):
> >                 return self.person_company
>
> > class phonebook_stat(models.Model):
> >         username = models.CharField(max_length=30)
> >         number = models.CharField(max_length=15)
> >         dialed_times = models.IntegerField(max_length=10)
> >         class Admin:
> >                 pass
> > in admin.py
> > class PhonebookAdmin(admin.ModelAdmin):
> >         def queryset(self, request):
> >                 qs = super(PhonebookAdmin, self).queryset(request)
> >                 global caller_id
> >                 caller_id = str(request.user)
> >                 return qs
> >         list_per_page = 20
> >         search_fields = ('person_company','number')
> >         list_display = ['person_company','number','address',]
> >         fields = ('person_company','number','address','e_mail',)
> >         #ordering = (order_common_used,)
>
> > THANK YOU in advance.
>
> Hello,
>
> Wouldn't you want the 'dialed' to be a many to many field so that one
> phonebook entry could be used for more than one user?
>
> class Phonebook(models.Model):
>         person_company = models.CharField(blank=True,max_length=30)
>         address = models.CharField(blank=True,max_length=50)
>         e_mail = models.EmailField(blank=True,max_length=70)
>         number = models.CharField(unique=True,max_length=15)
>         dialed = models.ManyToManyField('PhonebookStat')
>         def __unicode__(self):
>                 return self.person_company
>
> class PhonebookStat(models.Model):
>         username = models.CharField(max_length=30)
>         number = models.CharField(max_length=15)
>         dialed_times = models.IntegerField(max_length=10)
>         class Admin:
>                 pass
>
> I haven't really used the admin app for ages, so probably not the best
> person to advise on that, but I can't see how the code you have
> written would work. You need to have some kind of filter on the dialed
> field.
>
> HTH a bit,
> Em
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to