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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:52:28+00:00 2026-06-08T20:52:28+00:00

I am using django profiles with having different types of profiles. My Profile Model

  • 0

I am using django profiles with having different types of profiles.

My Profile Model of Company is similar to:

from django.db import models
from django.contrib.auth.models import User
from accounts.models import UserProfile
from jobs.models import City
from proj import settings
from django.core.mail import send_mail

class Company(UserProfile):
    name=models.CharField(max_length=50)
    short_description=models.CharField(max_length=255)
    tags=models.CharField(max_length=50)
    profile_url=models.URLField()
    company_established=models.DateField(null=True,blank=True)
    contact_person=models.CharField(max_length=100)
    phone=models.CharField(max_length=50)
    address=models.CharField(max_length=200)
    city=models.ForeignKey(City,default=True)

    def send_activation_email(self):
        self.set_activation_key(self.username)
        email_subject = 'Your  '+settings.SITE_NAME+' account confirmation'
        email_body = """Hello, %s, and thanks for signing up for an                                                                                            
example.com account!\n\nTo activate your account, click this link within 48                                                                                       
hours:\n\nhttp://"""+settings.SITE_URL+"/accounts/activate/%s""" % (self.username,self.activation_key)
        send_mail(email_subject,
                  email_body,
                  'acccounts@site.com',
                  [self.email])

Here I am inheriting Company from UserProfile and in send activation email, I am trying to use properties and methods of parent classes user and userprofile. Its direct parent is userprofile while user has onetoone relation with userprofile. So I tried to call self.activation_key that is defined in userpofile and called self.username that is property of user class/table and getting error on self.username .

So seems like I am calling self.username in wrong way,so how can I access self.username ? Any detail will be helpful and appreciated.

  • 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-08T20:52:30+00:00Added an answer on June 8, 2026 at 8:52 pm

    Company inherits from UserProfile, but as you say UserProfile doesn’t inherit from User – it has a OneToOne relationship with it. So there’s no such thing as self.username – there’s simply a relationship from self to User.username. I’m going to guess that that relationship is via a field called user, in which case you want self.user.username.

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

Sidebar

Related Questions

Am using django social-auth authentication for my app.After login to facebook or twitter from
I extended the User model in Django by using Profiles. As you know, creating
I have extended Django's User Model using a custom user profile called UserExtension .
Hay, I'm using django's contrib.auth system which obviously allows me to create User objects,
I'm using django-profiles and django.contrib.comments and I am trying to display all comments for
I'm using the django-contrib package django-profiles , and everything is working great - my
Using django comments framework http://docs.djangoproject.com/en/dev/ref/contrib/comments/ Not sure is there option, to make all comments
Using Django 1.1, I am trying to select the maximum value from a varchar
using django 1.4 I have a model with a datetimefield. I imported django.utils.timezone to
I am using django-registration and would like to have a different page for failed

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.