Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
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 Respostas
Responde à pergunta

0

use a lowercase profile as per the docs

<img src='{{user.profile.image}}'> 
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda