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 8421491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:10:01+00:00 2026-06-10T03:10:01+00:00

I have an ‘inlineformset_factory’, and I’m trying figure out how to set attributes for

  • 0

I have an ‘inlineformset_factory’, and I’m trying figure out how to set attributes for the individual fields. I haven’t come up with any way to add them besides using javascript (which would be hacky and bad).

In the end I’d like something like:

<input id="id_authorbook_set-0-title" type="text" name="authorbook_set-0-title" maxlength="255" placeholder="Title" autofocus="autofocus">

I know adding custom attributes is possible when using normal Forms or even ModelForms with attrs={'foo': 'bar', 'placeholder': 'Username'}, but haven’t been able to find any way to do the same with formset factories.

Is there a solution?
Thanks for the help.

  • 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-10T03:10:04+00:00Added an answer on June 10, 2026 at 3:10 am

    What you describe as working, the attrs argument, is passed to a form widget, which means you need form fields and thus a form.

    inlineformset_factory is a formset_factory for ModelForms.

    Tying the two together, you need to define a custom ModelForm and pass that to the factory as the form argument.

    You could also define a custom formset which iterates through the active forms, does the same overrides, and pass that to the inlineformset_factory.

    class MyMF(forms.ModelForm):
        class Meta:
            model = Foo
    
        def __init__(self, *args, **kwargs):
            super(MyMF, self).__init__(*args, **kwargs)
            self.fields['foo'].widget.attrs = {'foo': 'bar'}
    
    inlineformset_factory(form=MyMF)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have you any idea how to find out if spell check suggestions dialog is
Have done quite a bit of searching for a guide (of any substance) for
Have a painfully simple blog Post creator, and I'm trying to check if the
have a nice day. I got problem when trying to create an image from
have been trying couple of hours now to make my iphone app universal. The
have Googled the cr*p out of this one so apologies if the answer is
Have any one tried to activate fancybox thumbnail gallery using a button or an
have span that may or may not have text content. is there a way
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you guys had any experiences (positive or negative) by placing your source code/solution

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.