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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:14:10+00:00 2026-05-31T15:14:10+00:00

I have a Profile model: class Profile(db.Model): user = db.UserProperty(auto_current_user=True) bio = db.StringProperty() I’d

  • 0

I have a Profile model:

class Profile(db.Model):
    user = db.UserProperty(auto_current_user=True)
    bio = db.StringProperty()

I’d like to display the user’s existing bio in this view. If the user has no profile yet, I’d like to create it. Here’s what I have so far, which doesn’t work yet:

class BioPage(webapp2.RequestHandler):
    def get(self):
        user = users.get_current_user()
        if user:
            profile = Profile.get_or_insert(user=user) #This line is wrong
            profile.bio = "No bio entered yet."
            profile.save()
            self.response.headers['Content-Type'] = 'text/plain'
            self.response.out.write('Hello, ' + user.nickname() + '<br/>Bio: ' + profile.bio)
        else:
            self.redirect(users.create_login_url(self.request.uri))

How do I fix the incorrect line above? I know that get_or_insert() should take a key name, but I can’t figure out what that would be.

(Should the user field in Profile even be a db.UserProperty?)

  • 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-31T15:14:12+00:00Added an answer on May 31, 2026 at 3:14 pm

    You have to pass the key_name to get_or_insert(), in this case, like so:

    profile = Profile.get_or_insert(key_name=user.email())
    

    Note that since the user property is auto-populated because of the auto_current_user=True you don’t need to pass it to the get_or_insert() call. In your case you don’t need to pass anything but the key name.

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

Sidebar

Related Questions

I have a profile class: class profile(db.Model): user = db.stringProperty() # Other properties ...
Given these two models: class Profile(models.Model): user = models.ForeignKey(User, unique=True, verbose_name=_('user')) about = models.TextField(_('about'),
I have following model: class UserProfile(models.Model): User profile model, cintains a Foreign Key, which
I have user profile model with M2M field class Account(models.Model): ... friends = models.ManyToManyField('self',
I have two models Profile and Avatar. models.py class Profile(models.Model): user = models.ForeignKey(User) profile_name
I have two models: User (email:string) Profile (name:string) class User < ActiveRecord::Base has_one :profile
I have the following models: class Profile(models.Model): verified = models.BooleanField(default=False) primary_phone = models.OneToOneField('Phone', related_name='is_primary',
I have a Profile model and two ActiveRecord::Relations of this model. SQL request of
In my CakePHP 1.2.5 app, I have a Profile model that belongsTo a User
I have 3 model class User < ActiveRecord::Base has_many :profiles has_many :companies, :through =>

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.