Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Django profile model

I am beginner on django and trying to create a profile model that interrelate "User" built-in model via One-To-One relation field, it results impossible to span the user model properties by profile model instance and vise versa.
Can someone help me.

models.py

from django.db import models     
from django.contrib.auth.models import User

 class Profile(models.Model):
     users=models.OneToOneField(User, on_delete=models.CASCADE)
     image=models.ImageField(default='profilepic.jpg',upload_to='profile_pictures')
     location=models.CharField(max_length=100)

   def __str__(self):
     return self.users.username

profileTemplate.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Profile</title>
</head>
<body>  
    <h2>{{user.username}}</h2>
    <img src='{{user.Profile.image}}'> 
</body>
</html>

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

use a lowercase profile as per the docs

<img src='{{user.profile.image}}'> 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!