Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:58+00:00 2026-05-23T15:58:58+00:00

I’m experimenting with django-nonrel on appengine and trying to use a djangotoolbox.fields.ListField to implement

  • 0

I’m experimenting with django-nonrel on appengine and trying to use a djangotoolbox.fields.ListField to implement a many-to-many relation. As I read in the documentation a ListField is something that you can use to make a workaround for djamgo-nonrel not supporting many-to-many relations.

This is an excerpt from my model:

class MyClass(models.Model):
    field = ListField(models.ForeignKey(AnotherClass))

So if I am getting this right I am creating a list of foreign keys to another class to show a relationship with multiple instances of another class

With this approach everything works fine … No Exceptions. I can create `MyClass’ objects in code and views. But when I try to use the admin interface I get the following error

No form field implemented for <class 'djangotoolbox.fields.ListField'>

So I though I would try something that I haven’t done before. Create my own field. Well actually my own form for editing MyClass instances in the admin interface. Here is what I did:

class MyClassForm(ModelForm):
    field = fields.MultipleChoiceField(choices=AnotherClass.objects.all(), widget=FilteredSelectMultiple("verbose_name", is_stacked=False))
    class Meta:
        model = MyClass

then I pass MyClassForm as the form to use to the admin interface

class MyClassAdmin(admin.ModelAdmin):
    form = MyClassForm

admin.site.register(MyClass, MyClassAdmin)

I though that this would work but It doesn’t. When I go to the admin interface I get the same error as before. Can anyone tell what I am doing wrong here … or if you have any other suggestions or success stories of using the ListField, SetField, etc. from djangotoolbox.fields in the admin interface it would be very much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:58:58+00:00Added an answer on May 23, 2026 at 3:58 pm

    OK, here is what I did to get this all working …
    I’ll start from the beginning

    This is what what my model looked like

    class MyClass(models.Model):
        field = ListField(models.ForeignKey(AnotherClass))
    

    I wanted to be able to use the admin interface to create/edit instances of this model using a multiple select widget for the list field. Therefore, I created some custom classes as follows

    class ModelListField(ListField):
        def formfield(self, **kwargs):
            return FormListField(**kwargs)
    
    class ListFieldWidget(SelectMultiple):
        pass
    
    class FormListField(MultipleChoiceField):
        """
        This is a custom form field that can display a ModelListField as a Multiple Select GUI element.
        """
        widget = ListFieldWidget
    
        def clean(self, value):
            #TODO: clean your data in whatever way is correct in your case and return cleaned data instead of just the value
            return value
    

    These classes allow the listfield to be used in the admin. Then I created a form to use in the admin site

    class MyClassForm(ModelForm):
        def __init__(self, *args, **kwargs):
            super(MyClasstForm,self).__init__(*args, **kwargs)
            self.fields['field'].widget.choices = [(i.pk, i) for i in AnotherClass.objects.all()]
            if self.instance.pk:
                self.fields['field'].initial = self.instance.field
    
        class Meta:
            model = MyClass
    

    After having done this I created a admin model and registered it with the admin site

    class MyClassAdmin(admin.ModelAdmin):
        form = MyClassForm
    
        def __init__(self, model, admin_site):
            super(MyClassAdmin,self).__init__(model, admin_site)
    
    admin.site.register(MyClass, MyClassAdmin)
    

    This is now working in my code. Keep in mind that this approach might not at all be well suited for google_appengine as I am not very adept at how it works and it might create inefficient queries an such.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.