ManyToMany relationship with intermediate model and admin list display with each realtion with value as diferent column

2012-07-24 Thread Ignacio Soto
Hey guys

i have an issue, i don know if it really can be done.

im using django 1.3

i have a model producto(product) and Tienda(store)

and a product could be in one or more stores, so i created a many to many 
relationship but y have a stock in each store, so i use the intermediary 
model ProductStore.

i want to create this, in the admin , product's  list display, i want to 
show each manutomany relationship as a diferent column qith the stock as 
the value.





as shown in the picture, this i could do by add a method in the model 
getTienda1 and return the stock and do it for each store, but i want it to 
be created dinamically because the user could create a new store and it 
will not be there.

so this is my cuestion: can i do that?

(Sorry for my bad english)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/whHmIGyht_IJ.
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.



Re: ManyToMany relationship with intermediate model and admin list display with each realtion with value as diferent column

2012-07-24 Thread Ignacio Soto
ok, it looks very nice i will try and let you know.. thanks

2012/7/24 Tomas Neme 

>
> > as shown in the picture, this i could do by add a method in the model
> > getTienda1 and return the stock and do it for each store, but i want it
> to
> > be created dinamically because the user could create a new store and it
> will
> > not be there.
> >
> > so this is my cuestion: can i do that?
>
> Interesting question. You COULD try the following:
>
> in the ProductAdmin ModelAdmin's class' __init__ you can define
> list_display like
>
> from store.models import Tienda
> for store in Tienda.objects.all():
> self.list_display.append('stock_tienda_{id}'.format(id=store.id))
>
> this would give you the list of existing stores at server init time.
> and then you could define your Product model's __getattr__ method
> something like this:
>
> def __getattr__(self, attr):
>  base = 'stock_tienda_'
>  if attr[:len(base)] == base:
>  return
> Product.objects.filter(tienda=Tienda.objects.get(id=attr[len(base):]))
>  return super(Product, self).__getattr__(self, attr)
>
> this should make the ModelAdmin's hack work
>
> finally, you need a way to add new columns for newly created stores, so
> maybe a post_save signal on Tienda objects
>
> @receiver(post_save, sender=Tienda)
> def add_to_product_list_display(sender, instance, new, **kwargs):
>   if new:
>   # I don't know how to get the ModelAdmin's instance for a given
> class,
>   #  but it must be something in django.contrib.admin.site
>   product_admin.list_display.append('stock_tienda_{id}'.format(id=
> instance.id))
>
> you probably need another listener before .delete of stores, and I'm not
> certain the __getattr__ hack will work, but this sounds interesting.
>
> Please try on those lines, and let me know if this worked, I'm most
> interested
>
> --
> "The whole of Japan is pure invention. There is no such country, there are
> no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
>
> --
> 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.
>



-- 
__

Ignacio Soto Reveco
Staff IngeHost

-- 
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.



combobox prepopulated to only related objects to "self"

2012-07-31 Thread Ignacio Soto
Hi everyone

i have this model

GROUP and Product


product has a group field thath is foreignkey to GROUP.


and Group has foreignKey to Product to select primary product.

so i want to have a group with many products and one is the "primary 
product".


so...i could do this by select inline products with "trough" and search an 
intermediary Model (boolean field).

but it let me select  more than one promary, 


the solution is the model this way:.

product has a group field thath is foreignkey to GROUP.


and Group has foreignKey to Product to select primary product.

so i want to have a group with many products and one is the "primary 
product".

but the primaryproduct field in group will be prepopulated with only the 
related products to this group.


how i prepopulate the select(combobox) with the reverse query ?






-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/d3UpfhONEWwJ.
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.



Re: combobox prepopulated to only related objects to "self"

2012-08-01 Thread Ignacio Soto
interesting!!! i will give it a try, and let you know.

thanks

2012/8/1 Anton Baklanov 

> you can try something like that:
>
> group = ...
> choices = [(product.pk, product.name) for product in
> group.product_set.all()]
> form.fields["myfield"].choices = choices
>
>
> On Wed, Aug 1, 2012 at 1:17 AM, Ignacio Soto  wrote:
>
>> Hi everyone
>>
>> i have this model
>>
>> GROUP and Product
>>
>>
>> product has a group field thath is foreignkey to GROUP.
>>
>>
>> and Group has foreignKey to Product to select primary product.
>>
>> so i want to have a group with many products and one is the "primary
>> product".
>>
>>
>> so...i could do this by select inline products with "trough" and search
>> an intermediary Model (boolean field).
>>
>> but it let me select  more than one promary,
>>
>>
>> the solution is the model this way:.
>>
>> product has a group field thath is foreignkey to GROUP.
>>
>>
>> and Group has foreignKey to Product to select primary product.
>>
>> so i want to have a group with many products and one is the "primary
>> product".
>>
>> but the primaryproduct field in group will be prepopulated with only the
>> related products to this group.
>>
>>
>> how i prepopulate the select(combobox) with the reverse query ?
>>
>>
>>
>>
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/d3UpfhONEWwJ.
>> 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.
>>
>
>
>
> --
> Regards,
> Anton Baklanov
>
>  --
> 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.
>



-- 
__

Ignacio Soto Reveco
Staff IngeHost

-- 
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.



Multiple UserProfile

2011-06-11 Thread Ignacio Soto
Hi there...

i want to create 2 user profile: cutomer and seller with diferents fields
and quantity of fields

but there is a problem with Get_Profile()
i've reading about it and i found some inheritance hacks.. but i doubt it
was the good way?

what is the right way to do it?

thanks
-- 
__

Ignacio Soto Reveco
Staff IngeHost

-- 
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.



Re: Multiple UserProfile

2011-06-11 Thread Ignacio Soto
Ok, thannks i will try, and let you know...

Cheers

ignacio Soto Reveco
Staff IngeHost

El 11-06-2011 11:41, "Shawn Milochik"  escribió:

Oops, correction: You'd use user.seller_profile and user.customer_profile if
you've set it up as a OneToOneField -- the get() is unnecessary (and won't
work).

You'd use get() if you used a ForeignKey with unique = True, but that's
silly because a OneToOneField does exactly that but more explicitly.




-- 
You received this message because you are subscribed to the Google Groups
"Django users" grou...
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/0weLEapbyMYJ.


To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group,...

-- 
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.



Re: help plz to install Django

2011-06-11 Thread Ignacio Soto
Hi

There is an idle called aptana, that include the pydev enviorement.

And  a better. Option is install eclipse and a
Pydev as a plugin.

Cheers

ignacio Soto Reveco
Staff IngeHost

El 11-06-2011 14:46, "ihsan mokhlisse"  escribió:

thnks Sergiy . and plz how can i cinfigure the django to work with it
plz . if they r an IDLE exist and support Django Plz without the
Problem of configure it plz



On 11 juin, 08:57, Sergiy Khohlov  wrote:
> sudo apt-get search django
> sudo ...
> 2011/6/11 ihsan mokhlisse :> hi all . i'm so
exited to be a member in this wonderful group . i

> > wanna start learn Django but the problem is . that i need who can
> > guide me to accomplish the...
> > For more options, visit this group athttp://
groups.google.com/group/django-users?hl=en.


-- 
You received this message because you are subscribed to the Google Groups
"Django users" group

-- 
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.



Re: Multiple UserProfile

2011-06-11 Thread Ignacio Soto
No, the same person cant be costumer and seller.

ignacio Soto Reveco
Staff IngeHost

El 11-06-2011 21:37, "Kenneth Gonsalves"  escribió:

On Fri, 2011-06-10 at 23:51 -0400, Ignacio Soto wrote:
> i want to create 2 user profile: cutomer an...
can the same person be both customer and seller?
--
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

--
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 op...

-- 
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.



Re: help plz to install Django

2011-06-11 Thread Ignacio Soto
Yes kennet is right, the version that is in the repos..maybe is not the
latest release version.

In ubuntu 11.04 is the 1.2 in repos,  you have to follow the install
instructions form the web page djangoproject.

Cheers

ignacio Soto Reveco
Staff IngeHost

El 11-06-2011 21:42, "Kenneth Gonsalves"  escribió:

On Sat, 2011-06-11 at 15:57 +0300, Sergiy Khohlov wrote:
> sudo apt-get search django
> sudo apt-get...
not good advice - *never* use the packaged version
--
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

--

You received this message because you are subscribed to the Google Groups
"Django users" group.
To p...

-- 
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.



Re: Multiple UserProfile

2011-06-11 Thread Ignacio Soto
Ok, kenneth i havent seen it that way.

I will use your model.

I really apreciate it

Thanks

ignacio Soto Reveco
Staff IngeHost

El 12-06-2011 0:39, "Kenneth Gonsalves"  escribió:

On Sat, 2011-06-11 at 21:12 -0400, Ignacio Soto wrote:
> No, the same person cant be costumer and se...
I have a basic profile with information common to both customer and
seller called Person and separate models called customer and seller with
foreign key to person. Thus one person may have multiple roles.
--

regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You re...

For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

-- 
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.