items = request.user. a11m1_user_itmes_set.all() works correctly
thank you buddies
On Wed, Jan 23, 2013 at 4:40 PM, Rafael E. Ferrero wrote:
> Sorry, but select_related() dont work for you??
>
>
> 2013/1/23 Pankaj Singh
>
>> items = request.user. a11m1_user_itmes_set.all()
>>
>> is equivalent
Sorry, but select_related() dont work for you??
2013/1/23 Pankaj Singh
> items = request.user. a11m1_user_itmes_set.all()
>
> is equivalent to
>
> items = A11M1_user_itmes.objects.filter(user=request.user)
>
> `items` will contain all items A11M1_user_itmes related to currently
> logged in user.
items = request.user. a11m1_user_itmes_set.all()
is equivalent to
items = A11M1_user_itmes.objects.filter(user=request.user)
`items` will contain all items A11M1_user_itmes related to currently
logged in user.
Now, if you want to get `content_object` for a particular item, do
something like fol
i dont found any query related to this model bro
On Wed, Jan 23, 2013 at 4:01 PM, Pankaj Singh wrote:
> If you want to get all `A11M1_user_items` objects then following query
> should work
>
>
> --
> Pankaj Singh
> http://about.me/psjinx
>
>
> On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahm
Sorry for last reply. I sent uncompleted email by mistake, while
looking at other laptop.
If you want to get all `A11M1_user_itmes ` objects then following
query should work
objects = request.user. a11m1_user_itmes_set.all()
You can use `content_object` attribute on each object in objects list
t
If you want to get all `A11M1_user_items` objects then following query
should work
--
Pankaj Singh
http://about.me/psjinx
On Wed, Jan 23, 2013 at 3:53 PM, Sarfraz ahmad wrote:
> i have the same model having one foreignkey to User and second to the
> ContentType
>
> class A11M1_user_itmes(model
i have the same model having one foreignkey to User and second to the
ContentType
class A11M1_user_itmes(models.Model):
A11M1F1_user=models.ForeignKey(User)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForei
So, you have a custom model like following
class MyModel(models.Model):
...
content_type = models.ForeignKey(ContentType)
...
And you want to run a query on MyModel which should return objects
from various apps related to currently logged in User.
Is this what you want to achieve?
P
thanx buddy bt i wish to do it in a manner that a model which has a foreign
key to ContentType, when i make a query on this model it returns all the
objects from various apps related to current logged in user
On Wed, Jan 23, 2013 at 3:00 PM, Pankaj Singh wrote:
> Hey Sarfraz,
>
> If you have a
Hey Sarfraz,
If you have an user object, then you can get all related objects using
following code
user = User.objects.get(username="psjinx")
related_links = [rel.get_accessor_name() for rel in
user._meta.get_all_related_objects()]
## above code will give a list of attribute names for each rela
Hey Sarfraz,
You can use any of following methods:
User._meta.get_all_related_m2m_objects_with_model()
User._meta.get_all_related_objects()
User._meta.get_all_related_many_to_many_objects()
User._meta.get_all_related_objects_with_model()
get_all_related_objects() is the one I guess you may want
hello friends
i have a project with 7 applications installed in it and
i want to get all the objects related to a particular user from all the
applications of ma project. please tell me how can i get all these
objects using ContentType framework
thank you all
--
You
12 matches
Mail list logo