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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:24:44+00:00 2026-05-12T05:24:44+00:00

I have a model with a field that is required but not entered by

  • 0

I have a model with a field that is required but not entered by the user and i have a hard time saving the model without errors. My model definition looks like this:

class Goal(db.Model):
  author = db.UserProperty(required=True)
  description = db.StringProperty(multiline=True, required=True)
  active = db.BooleanProperty(default=True)
  date = db.DateTimeProperty(auto_now_add=True)

class GoalForm(djangoforms.ModelForm):
  class Meta:
    model = Goal
    exclude = ['author', 'active']

And i use django-forms in appengine to create and validate the form. When i try to save the result of this form however….

  def post(self):

    data = GoalForm(data=self.request.POST)

    if data.is_valid():

      goal = data.save(commit=False)
      goal.author = users.get_current_user()

      goal.put()
      self.redirect('/')

I get “ValueError: The Goal could not be created (Property author is required)”

Now i would think that by having commit=False, then adding the property for Goal, and then saving the object would allow me to do this but obviously it’s not working. Any ideas?

  • 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-12T05:24:44+00:00Added an answer on May 12, 2026 at 5:24 am

    Note that save() will raise a ValueError if the data in the form doesn’t validate

    You can find what you need about the save() method here:

    http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

    Edit: Instead of goal.put(), do a goal.save()

    Edit2: This should solve your problem:

    goal = Goal(author='Mr') #example
    data = GoalForm(data=self.request.POST, instance=goal)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have model Article it has field title with some text that may contain
I have a Django form that uses an integer field to lookup a model
I have model with ManyToManyField field. I also have ModelForm that uses this model.
In my model I have a particular field that is annotated in the following
I want to have a model with calculated fields that I can apply sorting
I have a model that contains one-to-one fields to other models. I over rid
I have model Foo which has field bar. The bar field should be unique,
I have a model with ContentType field in it. In any model method I
I have model: # encoding: utf-8 class Tag include Mongoid::Document field :name, type: String
I'd like to have access to one my model field verbose_name. I can get

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.