开发者

mutli django admins with different db databases in django 1.2 - strange problem

开发者 https://www.devze.com 2023-01-04 05:11 出处:网络
I am using django 1.2 to create a multi site shop. I need multiple admin logins for each shop instance, e.g.

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. Thi开发者_StackOverflow社区s 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


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消