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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:40:45+00:00 2026-06-02T13:40:45+00:00

I strongly suspect that this boils down to me needing to understand some language

  • 0

I strongly suspect that this boils down to me needing to understand some language construct better, but I don’t know where to start, so I’m just going to have to throw some code out.

models:

class BlogTag(models.Model):
    tag = models.CharField(max_length=255)

    def __unicode__(self):
        return self.tag

class BlogEntry(models.Model):
    title = models.CharField(max_length=255)
    body = models.TextField()
    date = models.DateTimeField()
    tags = models.ManyToManyField(BlogTag)

    def __unicode__(self):
        return self.title

form:

class BlogForm(ModelForm):
    class Meta:
        model = BlogEntry

view:

title='New Blog Entry'
if request.method=='POST':
    form=BlogForm(request.POST)
    if form.is_valid():
        cd=form.cleaned_data
        blogEntry=BlogEntry(**cd)
        blogEntry.save()
else:
    form=BlogForm();
return render_to_response('blog_add.html', locals())

By using **cd I was able to take the cleaned data directly into my object, which is obviously desireable because this way the view is loosely coupled to the other objects — I can change the model, and everything else changes with it without me having to do a thing.

Unfortunately, I’m getting an error that:

'tags' is an invalid keyword argument for this function

I could always break down the CD and build a manual dictionary approach of blogEntry=BlogEntry(title=cd[‘title’]…) and then just add the tags in one by one, but… I should have better options than that, and I just don’t know what they are 🙁

  • 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-02T13:40:47+00:00Added an answer on June 2, 2026 at 1:40 pm

    I think what it boils down to is that **cd will pass in the arguments as a dictionary. BlogEntry is expecting a BlogTag type for tags instead you are passing it the dictionary argument which is not the right type. First create a BlogTag object and then pass that in to BlogEntry

    This might help http://anubis.blasux.ru/books/Python/www.djangoproject.com/documentation/0.96/models/many_to_many/

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

Sidebar

Related Questions

I use some strongly-typed expressions that get serialized to allow my UI code to
I strongly suspect I shouldn't be using a static factory method here, but for
I strongly expect this to end up as a duplication, but I can't seem
For strongly-typed & type-safe solution, I have to do the following step. Create some
i have an strongly typed object that represents all of the textbox properties of
I strongly believe that, reading code and reading good code is key to great
I strongly try to follow general rules in coding styles. But when i look
I know this question is a duplicate of Execute method on startup in spring
I'm trying to generate KML using Builder. I know their are some options out
Suppose I have some code that would, in theory, compile against any version of

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.