liuyang1520 / django-command-extensions

Automatically exported from code.google.com/p/django-command-extensions
MIT License
0 stars 0 forks source link

invalid literal for int() with base 10: 'foreignkey_autocomplete' #103

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'v got this error, when I inherit my admin class from
ForeignKeyAutocompleteAdmin and try to submit ajax autocomplete request:

ValueError at /admin/movister/role/foreignkey_autocomplete/
invalid literal for int() with base 10: 'foreignkey_autocomplete'

I think, method __call__() by some reasons doesn't called, I don't know why.

Code of my admin class is simple:

class RoleAdmin(ForeignKeyAutocompleteAdmin):
    list_display = ('id', 'old_id', 'movie', 'person', 'amplua', 'role')
    list_display_links = ['movie', 'person']

    related_search_fields = {
        'movie': ('^title', '^title_original'),
        'person': ('^first', 'last'),
    }

Original issue reported on code.google.com by ramu...@gmail.com on 25 May 2009 at 8:27

GoogleCodeExporter commented 8 years ago
Check out author's page
http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields
/

You need to replace __call__() with

def get_urls(self):
 urls = super(MessageAdmin,self).get_urls()
 search_url = patterns('',
 (r'^search/$', self.admin_site.admin_view(self.search))
 )
 return search_url + urls

and include 'from django.conf.urls.defaults import *' in admin.py

Original comment by marko.dv...@gmail.com on 26 Aug 2009 at 11:36

GoogleCodeExporter commented 8 years ago
hi I run into the same issue but the fix above didn't work for me.. I get this 
error:
global name 'MessageAdmin' is not defined....

any solution?

Original comment by michele.pasin on 28 Sep 2009 at 5:15

GoogleCodeExporter commented 8 years ago
ops sorry!!  doing copy/paste without thinking never pays back does it? 
Obviously we need to modify the 
example above (which is applies to Jannis Leidel blog post) with the code in 
django-command-extensions... 
that is:

    def get_urls(self):
        urls = super(ForeignKeyAutocompleteAdmin,self).get_urls()
        search_url = patterns('',
            (r'^foreignkey_autocomplete/$', self.admin_site.admin_view(self.foreignkey_autocomplete))
        )
        return search_url + urls

Original comment by michele.pasin on 28 Sep 2009 at 5:32