views:

25

answers:

1

Hey,

I am using django 1.2 to create a multi site shop. I need multiple admin logins for each shop instance, e.g.

site.com/au/admin
site.com/uk/admin
and so on.

I have a middleware class and a dbrouter that handles database connections based on the URL. This works fine.

I am trying to add some customisation per admin system based on what is available for that particular shop. So:

in admin.py :
if country == 'au':
admin.site.register(Orders)
admin.site.register(Payment)

if country == 'uk':
admin.site.register(Store_locator)
etc.

Hers's the problem: If I log into the AU version of the site the admin system displays the correct elements for AU. If I then log into UK, it still shows the AU version of the admin system, so the above code seems to only get used on the first load. if I kill the django server and restart it, then go into the different shop admin page, it will have reconfigured for that shop.

How I can get it to pick up a change in country each time the admin system loads? Why is this problem happening in the first place?

Any help would be greatly appreciated.

Thanks, imanc

A: 

I'd bet that Django doesn't read the admin config on each request, but on each time the server is restarted - that's why it 'sticks' to whichever you accessed first.

Why not do something with Django.contrib.auth's permissions to limit what a particular admin user can see in the admin, and register all the models in admin.py as standard?

stevejalim