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

  • SEARCH
  • Home
  • 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 9323403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:20:05+00:00 2026-06-19T04:20:05+00:00

I try to use grappelli to get a widget for generic foreign key. This

  • 0

I try to use grappelli to get a widget for generic foreign key. This is what i need to get: http://code.google.com/p/django-grappelli/wiki/generic_2_1.
I’ve got a model:

class Circuit(models.Model):
    circuit_id = models.PositiveIntegerField(verbose_name=_("Circuit ID"), blank=True, null=True)
    model = models.ForeignKey(Versiiplates, verbose_name=_("Model"))
    date_created = models.DateField(blank=True, null=True, verbose_name=_("Date Created"), default=datetime.date.today())
    manufacturer = models.ForeignKey(Manufacturer, null=True, blank=True, verbose_name="Производитель")
    manufacturer_comments = models.TextField(max_length=2500, null=True, blank=True, verbose_name="Комментарии производителя")
    keeper_type = models.ForeignKey(ContentType, blank=True, null=True, related_name="keeper_type")
    keeper_id = models.PositiveIntegerField(blank=True, null=True)
    keeper = generic.GenericForeignKey('keeper_type', 'keeper_id')
    status = models.PositiveIntegerField(verbose_name=_("Status"), choices=STATUS_TYPE, default=0)
    status_history = models.ManyToManyField(Status, blank=True, null=True)
    status_comment = models.TextField(max_length=2500, blank=True, null=True, verbose_name="Комментарий")

    def __unicode__(self):
        return u"%s #%d" % (self.model, self.circuit_id)

    class Meta:
        verbose_name = _("Circuit")
        verbose_name_plural = _("Circuits")

and AdminModel for it:

class CircuitAdmin(admin.ModelAdmin):
    fieldsets = [
        (None, {'fields': ['circuit_id', 'model', 'date_created']}),
        (_("Manufacturer"), {'fields':['manufacturer', 'manufacturer_comments']}),
        (_("Status"), {'fields': ['status', 'status_comment']})
    ]
    list_display = ('circuit_id', 'model', 'date_created', 'keeper', 'status')
    search_fields = ('circuit_id', )
    list_filter = ('model', 'status')
    related_lookup_fields = {
        'generic': [['keeper_type', 'keeper_id']]
    }

But there is still no widget for my GenericForeignKey in admin. And why in grapelli’s example of using it there are two GenericForeignKey fields?

  • 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-06-19T04:20:07+00:00Added an answer on June 19, 2026 at 4:20 am

    The answer is really simple. I just needed to add keeper_id and keeper_type fieldsets, like this:

    fieldsets = [
            (None, {'fields': ['circuit_id', 'model', 'date_created', 'keeper_type', 'keeper_id']}),
            (_("Manufacturer"), {'fields':['manufacturer', 'manufacturer_comments']}),
            (_("Status"), {'fields': ['status', 'status_comment']})
        ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to generate random number in this code? I try use $RANDOM, but the
I try to get TO: user@mail.com field from mime mail message. I have code:
I try use a integer array in java with the code below: public static
I try to use a variable in my kshell script but can't get a
i try to use TBXML and getting this error TBXML class method +tbXMLWithURL not
I try to use this: xml2struct when I use this xml: <XMLname attrib1=Some value>
I have this code: @app.route('/login/', methods=['GET', 'POST']) def login(): error = None if request.method
I try use reCaptcha and integrated with php, so if code is correct email
Hi i try use Nlog in with caliburn micro, I have use this tutorial
I need tree file at my asp.net site. For getting icons I try use

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.