Re: admin page doesn't auto-refresh

2012-06-27 Thread Matt Schinckel
I've found that this is a fairly common situation. For instance, Location 
has an FK to Company,
and then ManyToMany to StaffMember. But, only StaffMembers that have their 
FK set to
the same Company should be selectable in their inline.

This need not just be a ManyToMany thing, either. The Manager of a Location 
should also
be a StaffMember, but may only be one who is associated with the same 
Company.

This is one example: another, perhaps more common one, is Country & 
State/Province.

The available choices for a State/Province depend upon which Country is 
selected.

For the OP: the only way to do this requires JavaScript on the client end, 
and creating
views to return the limited set of objects you wish to be able to select 
from. When your
user changes Country, for instance, you then fetch the available list of 
States for that
country, and use that to populate the State field options.

I have an example (of exactly this) in my fork of django-countries: 
https://bitbucket.org/schinckel/django-countries/src

Specifically, have a look at the JS: 
https://bitbucket.org/schinckel/django-countries/src/0482ff867b4c/django_countries/static/countries/js/update_provinces_select.js

It's not especially well documented, and the JS only works for country 
field being 
called country, and province field being called province, but it might be a 
nice start for you
to see how to do it.


Matt.

-- 
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/-/qIbITxaVnUcJ.
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: admin page doesn't auto-refresh

2012-06-26 Thread Melvyn Sopacua
On 26-6-2012 11:15, ledzgio wrote:
> Hi,
> 
> I have a problemi with the admin page. In my admin page I have 3 fields 
> that refers to the same table called Team: when I want to add a new Team by 
> pressint the green "+" button, the popoup shows up and I can fill the form 
> and adding a new Team. When I click save, the pop up disappears and I have 
> the new value close to the "+" button I have pressed upon. But the problem 
> is that the other fields that refers to the table Team in the page are 
> empty, so I have to refresh the page in order to see the just added Team 
> show. 
> 
> How can I fix this behavior?

You can't. You should fix your models or use an InlineAdminModel. It
sounds like you're duplicating fields from the foreign key table Team in
other parts of the model.
Either that, or you're using both an InlineAdminModel and have the
foreign key available in admin model.

Without seeing the model definitions and the admin model definitions, we
can only guess.

-- 
Melvyn Sopacua


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



admin page doesn't auto-refresh

2012-06-26 Thread ledzgio
Hi,

I have a problemi with the admin page. In my admin page I have 3 fields 
that refers to the same table called Team: when I want to add a new Team by 
pressint the green "+" button, the popoup shows up and I can fill the form 
and adding a new Team. When I click save, the pop up disappears and I have 
the new value close to the "+" button I have pressed upon. But the problem 
is that the other fields that refers to the table Team in the page are 
empty, so I have to refresh the page in order to see the just added Team 
show. 

How can I fix this behavior?

thanks

-- 
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/-/0Kq0BYBK3M0J.
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.