Sunday 15 February 2015

python - Problems with urls.pyc files generated in django, how to fix it? -



python - Problems with urls.pyc files generated in django, how to fix it? -

we have made ​​an application in django 1.6.4 upgraded django 1.7, utilize nginx , gunicorn serve application.

randomly app returns next error:

typeerror @ /admin/ihs_booking/occupancydiscount/add/ 'tuple' object not callable request method: post request url: http://localhost/admin/ihs_booking/occupancydiscount/add/ django version: 1.7 exception type: typeerror exception value: 'tuple' object not callable exception location: /usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py in message_user, line 1016 python executable: /usr/bin/python python version: 2.7.6

we tried changing apache seek still same problem.

after investigating concluded problem occurs urls.pyc generated.

we delete pyc, restart server (apache or nginx + gunicorn) , works.

after while problem starts again.

this content of urls.py:

#-*- coding=utf-8 -*- django.conf import settings django.conf.urls import patterns, include, url django.contrib import admin .views import home, search, book, confirm_payment, gestion, contact_ihs, test_calendar admin.autodiscover() urlpatterns = patterns('', # examples: # url(r'^blog/', include('blog.urls')), url(r'^$', home, name='home'), url(r'^calendar/$', test_calendar, name='test_calendar'), url(r'^search/$', search, name='search'), url(r'^gestion/$', gestion, name='gestion'), url(r'^book/$', book, name='search'), url(r'^confirm-payment/$', confirm_payment, name='confirm'), url(r'^contact/', contact_ihs, name='contact'), url(r'^admin/', include(admin.site.urls),) ) #defining urls upload media files if settings.debug: urlpatterns += patterns( 'django.views.static', (r'media/(?p<path>.*)', 'serve', {'document_root': settings.media_root}), )

we must run app nginx + gunicorn because need run django , php in same server.

any idea? thanks!

here admin/options.py around 1061 line.

def render_change_form(self, request, context, add=false, change=false, form_url='', obj=none): opts = self.model._meta app_label = opts.app_label preserved_filters = self.get_preserved_filters(request) form_url = add_preserved_filters({'preserved_filters': preserved_filters, 'opts': opts}, form_url) view_on_site_url = self.get_view_on_site_url(obj) context.update({ 'add': add, 'change': change, 'has_add_permission': self.has_add_permission(request), 'has_change_permission': self.has_change_permission(request, obj), 'has_delete_permission': self.has_delete_permission(request, obj), 'has_file_field': true, # fixme - should check if form or formsets have filefield, 'has_absolute_url': view_on_site_url not none, 'absolute_url': view_on_site_url, 'form_url': form_url, 'opts': opts, 'content_type_id': get_content_type_for_model(self.model).pk, 'save_as': self.save_as, 'save_on_top': self.save_on_top, 'to_field_var': to_field_var, 'is_popup_var': is_popup_var, 'app_label': app_label, })

we've got "," @ end of list_display in admin.py, removed error still occurs.

this class of admin.py:

class promcodediscountadmin(admin.modeladmin): list_display = ('code', 'hotel', 'name', 'discount_percentage', 'start', 'end', 'is_active', 'promotional_group') form = promocodeadminform admin.site.register(promcodediscount, promcodediscountadmin)

i know it's yearago question future reference, delete lastly comma url(r'^admin/', include(admin.site.urls),)

python django nginx gunicorn

No comments:

Post a Comment