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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:45:48+00:00 2026-06-13T10:45:48+00:00

I defined an ImageField in my models.py, with a default image. Each time I

  • 0

I defined an ImageField in my models.py, with a default image. Each time I create a new user, I can see in the admin that the default image is associated to the user, as I wanted.

The problem is, when I try to render it in my templates, with something like:

{{user.userprofile.profilpic.url}}

it does not work. The image is not displayed.

But if I go into my admin and change it manually, even with the exact same image, it works. It looks like the image is not saved into the db when I create the user.

Here is my models.py:

    class UserProfile(FacebookProfileModel):
       user = models.OneToOneField(User)
       profilpic = models.ImageField(upload_to="profilpics/", default="/my/picture.jpeg")

I wonder how I can fix that. Thank you for your help.

  • 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-13T10:45:49+00:00Added an answer on June 13, 2026 at 10:45 am

    You can add a method to your model:

    class UserProfile(FacebookProfileModel):
        ... 
        profilepic = ...
    
        def profilepic_or_default(self, default_path="/images/..."):
            if self.profilepic:
                return self.profilepic
            return default_path
    

    and use it in your tempalte:

    {{ myuser.profilepic_or_default }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

User Defined Function (UDFs) are functions that one can program and can be dynamically
I'm creating an image gallery with albums. The gallery owner can first create one
I defined these 3 models in Rails3. class User < ActiveRecord::Base has_many :questions has_many
models.py: class Item(models.Model): name = models.CharField(max_length=50) class ItemImage(models.Model): image = models.ImageField(upload_to='item_pics') item = models.ForeignKey(Item,
I have 2 models named Tour and Agency each Tour and each Agency can
I defined: a mongoose schema (Type1) to save an object 2 others that extends
I defined image dimensions in media (WP) and in functions.php addedd some 2 custom
I defined a global variable that is called from other view and it is
Defined a SQL Server, which only user x (in the domain) is allowed to
Defined this way, we can do neither ++x++ nor ++x-- . But on the

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.