Hi,
I have two simple models:
class Country(models.Model):
name = models.CharField(_("Name"), max_length=50,
unique=True)
class Profile(models.Model):
name = models.CharField(_("Name"), max_length=50,
unique=True)
country = models.ForeignKey(Country)
If I want to
On Mon, Feb 2, 2009 at 10:11 PM, Markus T. wrote:
>
> Hi,
>
> I have two simple models:
>
> class Country(models.Model):
> name = models.CharField(_("Name"), max_length=50,
> unique=True)
>
> class Profile(models.Model):
> name = models.CharField(_("Name"), max_length=50,
> un
On Mon, Feb 2, 2009 at 11:59 PM, Martin Conte Mac Donell
wrote:
> If you need country_id/country_name:
>
Profile.objects.values('country__id',
'country__name').select_related('country').distinct()
> [{'country__name': u'Country1', 'country__id': 1}, {'country__name':
> u'Country3', 'co
Thanks for your reply!
Your approach returns a list of dictionaries (or tuples if values_list
() is used).
Do you know of a straight forward way that returns a list of model
objects, like filter() or all()?
(I mean something smarter than looping the returned list of tuples and
creating a new list
> I have two simple models:
>
> class Country(models.Model):
> name = models.CharField(_("Name"), max_length=50,
> unique=True)
>
> class Profile(models.Model):
> name = models.CharField(_("Name"), max_length=50,
> unique=True)
> country = models.ForeignKey(Country)
>
That's it - thanks a lot!!!
--~--~-~--~~~---~--~~
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
djang
6 matches
Mail list logo