specialunderwear / django-easymode

Quickly build backends for flash/flex websites with Django.
GNU General Public License v3.0
35 stars 20 forks source link

Django 1.4 - Locale URL #8

Open python-force opened 12 years ago

python-force commented 12 years ago

Hello,

want to say great job on easymode, I made changes to it by your tutorial for 1.4 and it works great except 1 thing.

In 1.3.1 - Django admin was using links which basically made you to stay in admin on certain language, example:

  1. www.example.com/it/admin/...
  2. When I edit any of the records and click save it stays on /it/ - italian for example

Django 1.4:

  1. www.example.com/it/admin/...
  2. When I edit any of the records and click save it goes to /en/ - english - because thats default
  3. it happens because in source code admin has relative links "/admin/auth..." that means it strip entire url and load defaul language...

So I have 2 versions of website in 1.3.1 and 1.4 - I want to achieve that person with Italian language will stay on Italian, without

changing the 'localeurl' in the url every record he is changing...

I would like to do it without editing the core of django to be like in 1.3.1, I think there must be a proper way to do it with cookies

maybe not sure, I am not PRO in Django so if you already know if you can share how to achieve this, thanks a lot.

Great work by the way.

python-force commented 12 years ago

L10n is brilliant, works great.

1 more thing, is there a way to add to admin links for languages? That editor would choose language and stays on that language entire time while editing.

specialunderwear commented 12 years ago

Did you install the i18n middlewares? http://packages.python.org/django-easymode/middleware.html

I think these are obsolete though, because django ship with i18n-urls. I didn't really get to testing easymode proper with 1.4. I only managed to find time to fix very obvious bugs.

If you did use the middlewares and the issue stays, this will be fixed in the near future. As for language selection dropdowns, you need to build it yourself, easymode doesn't ship one yet.

python-force commented 12 years ago

If I add these - 1 or other or both I got this error: 'easymode.middleware.LocaleFromUrlMiddleWare', 'easymode.middleware.LocaliseUrlsMiddleware',

[Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] self.load_middleware() [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] File "/home/example/webapps/bb4/lib/python2.7/django/core/handlers/base.py", line 45, in load_middleware [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] mod = import_module(mw_module) [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] File "/home/example/webapps/bb4/lib/python2.7/django/utils/importlib.py", line 35, in import_module [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] import(name) [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] File "/home/example/lib/python2.7/easymode/middleware.py", line 46, in [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] settings.ADMIN_MEDIA_PREFIX[1:] [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] File "/home/example/webapps/bb4/lib/python2.7/django/utils/functional.py", line 185, in inner [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] return func(self._wrapped, *args) [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] AttributeError: 'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX'

I know that in 1.4 'ADMIN_MEDIA_PREFIX' doesnt exist anymore, when I remove those middlewares all is fine.

specialunderwear commented 12 years ago

The middlewares provide the functionality you want. Please add ADMIN_MEDIA_PREFIX = '/admin/media/' to your settings and test again. On 2 apr. 2012, at 23:03, rentgeeen wrote:

If I add these - 1 or other or both I got this error: 'easymode.middleware.LocaleFromUrlMiddleWare', 'easymode.middleware.LocaliseUrlsMiddleware',

[Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] self.load_middleware() [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] File "/home/example/webapps/bb4/lib/python2.7/django/core/handlers/base.py", line 45, in load_middleware [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] mod = import_module(mw_module) [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] File "/home/example/webapps/bb4/lib/python2.7/django/utils/importlib.py", line 35, in import_module [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] import(name) [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] File "/home/example/lib/python2.7/easymode/middleware.py", line 46, in [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] settings.ADMIN_MEDIA_PREFIX[1:] [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] File "/home/example/webapps/bb4/lib/python2.7/django/utils/functional.py", line 185, in inner [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] return func(self._wrapped, *args) [Mon Apr 02 15:42:35 2012] [error] [client 127.0.0.1] AttributeError: 'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX'

I know that in 1.4 'ADMIN_MEDIA_PREFIX' doesnt exist anymore, when I remove those middlewares all is fine.


Reply to this email directly or view it on GitHub: https://github.com/specialunderwear/django-easymode/issues/8#issuecomment-4888528

PermanentMarkers kvk 09170823 tel 026-3704887 mob 06-24352007 specialunderwear@gmail.com lars@permanentmarkers.nl

python-force commented 12 years ago

ok I did that and got error:

AttributeError at / 'WSGIRequest' object has no attribute 'set_cookie'

Request Method: GET Request URL: http://dev.example.com/en/ Django Version: 1.4 Exception Type: AttributeError Exception Value:
'WSGIRequest' object has no attribute 'set_cookie' Exception Location: /home/example/lib/python2.7/easymode/middleware.py in process_request, line 131 Python Executable: /usr/local/bin/python Python Version: 2.7.1 Python Path:
['/home/example/webapps/bb4', '/home/example/webapps/bb4/myproject', '/home/example/webapps/bb4/lib/python2.7', '/home/example/lib/python2.7/django_rosetta-0.6.2-py2.7.egg', '/home/example/lib/python2.7/django_localeurl-1.5-py2.7.egg', '/home/example/lib/python2.7/South-0.7.3-py2.7.egg', '/home/example/lib/python2.7/sorl_thumbnail-11.12-py2.7.egg', '/home/example/lib/python2.7/django_transmeta-0.6.7-py2.7.egg', '/home/example/lib/python2.7', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages/PIL'] Server time: Tue, 3 Apr 2012 14:38:23 -0500

specialunderwear commented 12 years ago

Probably you did not include session middleware or the order of your middle wares is incorrect. Look at the example application to find the correct order.

python-force commented 12 years ago

Ok great now fully functional:

  1. use only 1 middleware: 'easymode.middleware.LocaliseUrlsMiddleware',
  2. ADMIN_MEDIA_PREFIX = '/admin/media/'

all works on dajngo 1.4 - brilliant

Great work love it :)

Can you explain me 1 thing why I need to put

ADMIN_MEDIA_PREFIX = '/admin/media/'

in django 1.4 is deprecated, what easymode needs to use it? Isnt it only for symbolic link for css (contrib admin)?

Even my symbolic link is pointing to somewhere else in django 1.4 because of new structure.

Anyway awsome work :)

specialunderwear commented 12 years ago

Like I said, easy mode is not well tested with django 1.4. Some stuff needs to be removed, some issues might exist. Anyway, your comments are very helpful, because they show me where to look. If you find more stuff that seems weird or bugged, please make more tickets.

python-force commented 12 years ago

yes of course will test for sure so far its great :) thanks a lot