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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:22:27+00:00 2026-05-17T00:22:27+00:00

I use UserProfile model for keeping additional info about user and one of the

  • 0

I use UserProfile model for keeping additional info about user and one of the fields is subdomain variable that is by default should be set to username. Here is UserProfile model:

class UserProfile(models.Model):
    theme = models.ForeignKey(Theme, unique=True, null=True)
    user = models.ForeignKey(User, unique=True)
    subdomain = models.CharField(default=self.user.username, max_length=30)

I implemented Django signals feature to create UserProfile model instance automatically on user creation. Now I need to set subdomain variable to username. How can I do this?

  • 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-17T00:22:27+00:00Added an answer on May 17, 2026 at 12:22 am

    Since you are automatically creating an UserProfile using a signal you can explicitly set the User instance’s username as the UserProfile subdomain. For e.g.

    def create_user_profile(sender, instance, **kwargs):
        profile = UserProfile(user = instance, subdomain = instance.username, ...)
        profile.save()
    

    Another way to do this would be to override the save() method such that if no subdomain is supplied you can set it to user.username.

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

Sidebar

Related Questions

My site makes use of Django's User Authentication User model and a custom UserProfile
I'm currently trying to use ASP.Net Profiles to store additional user information about users
I have one model, and 3 different forms that use this model (of course,
class UserProfile(models.Model): project_assignments = models.ManyToManyField('drawingManager.Project', default=SetDefaultProject(self,default_assignment)) user = models.OneToOneField(User) default_project def SetDefaultProject(self,default_assignment): if default_assignment:
I have an extended UserProfile model in django: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True)
I have an application that makes use of Django's UserProfile to extend the built-in
I have a model with a DateField : class Info(models.Model): userprofile = models.OneToOneField(UserProfile, primary_key=True)
I used to put custom user-related fields in a new UserProfile class, but now
The design I have a User model that belongs to a profile through a
I have the following models: class Post(models.Model): message = models.TextField() (etc.) class UserProfile(models.Model): user

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.