Django django-smart-select: get TemplateSyntaxError during adding of data in admin site -
i'm django newbie. want try app django-smart-selects. "customer" adress being auto-populated choosing appropiate "customer" in "order" form of admin site.
so have defined following
models.py
from smart_selects.db_fields import chainedforeignkey django.db import models # adress model class adresse (models.model): strasse = models.charfield(max_length=50) plz = models.integerfield(max_length=5) ort = models.charfield(max_length=50) def __unicode__(self): return self.strasse # customer model class customer (models.model): name = models.charfield(max_length=50) adresse = models.foreignkey(adresse) def __unicode__(self): return self.name # order model class order (models.model): name = models.charfield(max_length=50) delivery_time = models.datetimefield() created_at = models.datetimefield(auto_now_add=true) kunde = models.foreignkey(customer, related_name="kunde") adresse = chainedforeignkey( customer, chained_field="kunde", chained_model_field="strasse", show_all=false, auto_choose=true ) class meta: db_table = 'order' ordering = ['-created_at'] def __unicode__(self): return self.name
admin.py
from django.contrib import admin customer_order.test_app.models import adresse, customer, order class adresseadmin(admin.modeladmin): list_display = ('strasse', 'plz', 'ort',) class customeradmin(admin.modeladmin): list_display = ('name', 'adresse',) list_per_page = 50 class ordersadmin(admin.modeladmin): list_display = ('name', 'delivery_time', 'created_at', 'kunde', 'adresse',) list_display_links = ('name',) list_per_page = 50 ordering = ['-created_at'] admin.site.register(adresse, adresseadmin) admin.site.register(customer, customeradmin) admin.site.register(order, ordersadmin)
now when want add first entries "order" table through admin add-button, got following error:
request method: request url: http://127.0.0.1:8000/admin/test_app/order/add/ exception type: templatesyntaxerror exception value: caught exception while rendering: reverse 'chained_filter' arguments '()' , keyword arguments '{'field': 'strasse', 'app': 'test_app', 'model': 'customer', 'value': '1'}' not found. original traceback (most recent call last): file "c:\python25\lib\site-packages\django\template\debug.py", line 71, in render_node result = node.render(context) file "c:\python25\lib\site-packages\django\template\debug.py", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) file "c:\python25\lib\site-packages\django\utils\encoding.py", line 71, in force_unicode s = unicode(s) file "c:\python25\lib\site-packages\django\forms\forms.py", line 356, in __unicode__ return self.as_widget() file "c:\python25\lib\site-packages\django\forms\forms.py", line 391, in as_widget return widget.render(name, data, attrs=attrs) file "c:\python25\lib\site-packages\django\contrib\admin\widgets.py", line 231, in render output = [self.widget.render(name, value, *args, **kwargs)] file "h:\customer_order\smart_selects\widgets.py", line 36, in render url = "/".join(reverse("chained_filter", kwargs={'app':self.app_name,'model':self.model_name,'field':self.model_field,'value':"1"}).split("/")[:-2]) file "c:\python25\lib\site-packages\django\core\urlresolvers.py", line 350, in reverse *args, **kwargs))) file "c:\python25\lib\site-packages\django\core\urlresolvers.py", line 300, in reverse "arguments '%s' not found." % (lookup_view_s, args, kwargs)) noreversematch: reverse 'chained_filter' arguments '()' , keyword arguments '{'field': 'strasse', 'app': 'test_app', 'model': 'customer', 'value': '1'}' not found. exception location: c:\python25\lib\site-packages\django\template\debug.py in render_node, line 81 python executable: c:\python25\python.exe python version: 2.5.0
have done step 2 installation instructions - adding following urls.py?
url(r'^chaining/', include('smart_selects.urls')),
Comments
Post a Comment