Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use filter #54

Closed
Scoppio opened this issue Jan 11, 2017 · 3 comments
Closed

Can't use filter #54

Scoppio opened this issue Jan 11, 2017 · 3 comments

Comments

@Scoppio
Copy link

Scoppio commented Jan 11, 2017

In this particular situation, I have selected the "Ada" language for the only entry that I have in my DB
image

My models.py is:

PROG_LANGUAGES = """Actionscript
	Ada
	Agda
	Android
	AppEngine"""

PROG_LANGUAGES = tuple([tuple([a,a]) for a in PROG_LANGUAGES.split()]) 
# the actual PROG_LANGUAGE is giant, 150+ entries, so I turn the long string into a nested tuple

class Profiles(models.Model):
    git_id = models.IntegerField()
    login = models.CharField(max_length=100)
    name = models.CharField(max_length=200)
    email = models.EmailField()
    location = models.CharField(max_length=100)
    date_added = models.DateTimeField('date published')
    organization = models.CharField(max_length=200, blank=True, null=True)
    avatar_url = models.CharField(max_length=200)
    languages = MultiSelectField(choices=PROG_LANGUAGES,
                                 max_choices=5)

and my admin.py

from .ExportCsv import export_as_csv_action
from django.contrib import admin
from .models import Profiles

class ProfilesModelAdmin(admin.ModelAdmin):

    actions = [
            export_as_csv_action("CSV Export"),
        ]

    list_display = ["name","email", "location", "date_added", "organization"]
    list_filter = ["location", "languages", "organization", "date_added"]
    saerch_fields = ["location", "languages", "name", "email", "login", "organization", "date_added"]
    class Meta:
        model = Profiles


admin.site.register(Profiles, ProfilesModelAdmin)

The admin view shows this normally
image

but if I try to select ONLY the languages that I want (in this case Ada language)

image

While that happens, this is the cmd output:


[11/Jan/2017 05:11:50] "GET /admin/gitprofiles/profiles/?languages__exact=Ada HT
TP/1.1" 200 13663
[11/Jan/2017 05:11:50] "GET /admin/jsi18n/ HTTP/1.1" 200 3189

@blag
Copy link
Collaborator

blag commented Jan 11, 2017

I know that this project doesn't play nicely with Django's built-in admin, and that's something I'm going to try to fix, but...

  • HTTP 200 is the "OK" status code, so all code seems to be working as advertised
  • There doesn't seem to be any debug information aside from "Can't use filter"; no description of how this isn't meeting your expectations/needs

Can you give me a full traceback or a description of what should be happening but isn't happening? Your screenshots and description are awesome (seriously, thank you), but I can't quite tell what the problem is without more context.

And is there any reason you're defining a constant string of PROG_LANGUAGES instead of simply creating tuples of tuples directly? It's probably easier to understand what the code is doing if you directly instatiate a tuple of tuples or list of tuples instead of defining a string and having Python split it up for you.

Thanks!

PS - you misspelled the search_fields attribute, and although I don't think that's contributing to this issue, it's something you'll want to fix.

@blag
Copy link
Collaborator

blag commented Feb 23, 2017

I may have fixed this in the master branch. Please test that and let me know if it's fixed or not.

@blag
Copy link
Collaborator

blag commented Mar 20, 2017

Since you haven't given me any more troubleshooting information or tested this against master, I'm going to close this issue.

Please feel free to reopen it - with the full traceback, a full description of expected/actual behavior, and test results against the master branch - if the issue isn't resolved.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants