Django django-smart-select: get TemplateSyntaxError during adding of data in admin site

I'm a Django newbie. I want to try this app django-smart-selects. I would like the "Customer" adress being auto-populated by choosing the appropiate "Customer" in the "Order" form of the admin site.

So I have defined the following

models.py

from smart_selects.db_fields import ChainedForeignKey 
from 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
from 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 I want to add the first entries into the "Order" table through the admin add-Button, I got the following error:

Request Method:   GET
Request URL:  http://127.0.0.1:8000/admin/test_app/order/add/
Exception Type:  TemplateSyntaxError
Exception Value:  

Caught an exception while rendering: Reverse for 'chained_filter' with arguments '()' and 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 for 'chained_filter' with arguments '()' and 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

Answers


Have you done step 2 from the installation instructions - adding the following into your urls.py?

url(r'^chaining/', include('smart_selects.urls')),

Need Your Help

Independent margin for list items

html css html-lists

As you can see in this fiddle: http://jsfiddle.net/h0qu4ffv/ I set the margin-top of 1 list item to be 50px, but all of them follow this style.