django 1.6.1 raw_id_fields open a 'change' popup instead of 'select' popup

297 views
Skip to first unread message

Vittorio

unread,
Mar 4, 2014, 4:17:58 AM3/4/14
to django...@googlegroups.com

django==1.6.1
python==2.7.6
Mac OS X 10.7.5 (development) & UBUNTU Linux 13.04 (production -- Apache 2.2.server)
Browsers==(Mac OS X) Safari, Firefox,Chrome; (Linux) Firefox

To put in a nutshell in my app (I'm translating from Italian into English) 'warehouse' I have a model 'invoice' and a model 'items'. I use the admin interface only.
In an admin form I input all data for a specific invoice (client, date of issue, number of invoice) and, by means of inlines, the ordered items. In these inlines I defined a raw_id_fields referring to the 'items' model which is showing correctly in the form, BUT ... when I click on it a "change" page is often (not always) popping up instead of the expected "select" one.
Tis happens both in development and in production.

Surfing the net I saw a message with the same subject as mine http://stackoverflow.com/questions/21009319/django-1-6-1-raw-id-fields-open-a-change-popup-instead-of-select-popup with a somewhat cryptic only answer...

In my case the pop up window instead of being called by :
http://localhost:8000/warehouse/warehouse/items/?_popup=1 (which - I tested - works great showing a 'select' page)

is called by:
http://localhost:8000/warehouse/warehouse/items/?e=1 (which shows a change page)

Why is that and what should I do?

Thanks a lot
Vittorio


Camilo Torres

unread,
Mar 4, 2014, 9:54:22 PM3/4/14
to django...@googlegroups.com, ml-...@de-martino.it
On Tuesday, March 4, 2014 4:47:58 AM UTC-4:30, Vittorio wrote:
In an admin form I input all data for a specific invoice (client, date of issue, number of invoice) and, by means of inlines, the ordered items. In these inlines I defined a raw_id_fields referring to the 'items' model which is showing correctly in the form, BUT ... when I click on it  a "change"   page is  often (not always) popping up instead of the expected "select" one.
Tis happens both in development and in production.

Surfing the net I saw a message with the same subject as mine http://stackoverflow.com/questions/21009319/django-1-6-1-raw-id-fields-open-a-change-popup-instead-of-select-popup with a somewhat cryptic only answer...
Hello,

Try to delete your browser cache.

Regards,
Camilo 

Vittorio

unread,
Mar 5, 2014, 12:11:51 PM3/5/14
to django...@googlegroups.com
No, it isn't a matter of browser cache.
Let's narrow the problem focusing on the linux machine only where there's myapp and the apache2 server.
If I run my app via "python manage.py runserver 192.168.100.100:8000" it all works correctly:

"GET /warehouse/warehouse/invoice/ HTTP/1.1" 200 2145
"GET /warehouse/jsi18n/ HTTP/1.1" 200 2005
"GET /warehouse/warehouse/invoice/5/ HTTP/1.1" 200 22551
"GET /warehouse/warehouse/items/?t=code&_popup=1 HTTP/1.1" 200 21793

and the correct select popup window's shown.

Whilst, *** using the same settings.py file ***, and Apache2 (see the enabled-site conf file below) in production I get a change popup window only and a nasty
/?e=1 appears at the and of the http called page.

Please help, I'm really stranded here.
Thanks a lot
Vittorio

=====================================
#settings.py
import os
ABSOLUTE_PATH='%s/' % os.path.abspath(os.path.dirname(locals.__name__)).replace('\\','/')

DEBUG = True
ALLOWED_HOSTS=['*']
ADMINS = (
('Amministratore', 'wa...@gmail.com'),
)
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'wa...@gmail.com'
EMAIL_HOST_PASSWORD = 'AbsolutelyFake99'

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',#, 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'warehouse', # Or path to database file if using sqlite3.
'USER': 'mycompany', # Not used with sqlite3.
'PASSWORD': 'mycompany', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
},
'noematica': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'noematica', # Or path to database file if using sqlite3.
'USER': 'mycompany', # Not used with sqlite3.
'PASSWORD': 'mycompany', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
},
}

TIME_ZONE = 'Europe/Rome'

LANGUAGE_CODE = 'it-it'
DECIMAL_SEPARATOR=','
THOUSAND_SEPARATOR='.'

SITE_ID = 1
USE_I18N = True
USE_L10N = True

USE_TZ = True
MEDIA_ROOT=''
MEDIA_URL = '/media/'
STATIC_ROOT = ''
STATIC_URL = '/static/'

STATICFILES_DIRS = (
)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
SECRET_KEY = 'b(%_qs2$sk3_ht&+@9+6=%t1ff$ey@f9$rrydsqw&r$-z)xbk%*'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.gzip.GZipMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
)
ROOT_URLCONF = 'mywh.urls'
WSGI_APPLICATION = 'mywh.wsgi.application'

TEMPLATE_DIRS = (
'/home/wh/mywh/mywh/templates',
)

SESSION_EXPIRE_AT_BROWSER_CLOSE = True

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',# 'south',
'warehouse',
'noematica',
)

DATABASE_ROUTERS = ['warehouse.DBRouter.DBRouter']

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
================================================
#enabled-sites/django.conf
Listen 8000
WSGIScriptAlias / /home/wh/mywh/django.wsgi
WSGIPythonPath /home/wh/mywh

<VirtualHost 192.168.1.19:8000>
LogLevel warn
DocumentRoot /home/wh/mywh/mywh
AliasMatch ^/([^/]*\.css) /home/wh/mywh/mywh/static/
AliasMatch ^/itemslist/(.*)\.png$ /home/wh/mywh/mywh/media/$1.png
AliasMatch ^/([^/]*\.png) /home/wh/mywh/mywh/media/

Alias /media/ /home/wh/mywh/mywh/media/
Alias /static/ /home/wh/mywh/mywh/static/
Alias /templates/ /home/wh/mywh/mywh/templates/

<Directory /home/wh/mywh/mywh/static>
Order deny,allow
Allow from all
Require all granted
</Directory>

<Directory /home/wh/mywh/mywh/media>
Order deny,allow
Allow from all
Require all granted
</Directory>

<Directory /home/wh/mywh/mywh/templates>
Order deny,allow
Allow from all
Require all granted
</Directory>

ServerAdmin webmaster@localhost
....
<Directory /home/wh/mywh/>
<Files django.wsgi>
Order deny,allow
Allow from all
Require all granted
</Files>
</Directory>
</VirtualHost>


Reply all
Reply to author
Forward
0 new messages