I have posted my question in stackoverflow

19 views
Skip to first unread message

sai Krishna

unread,
Jun 26, 2020, 5:02:31 AM6/26/20
to Django users

Cbh Bnh

unread,
Jun 26, 2020, 6:11:09 AM6/26/20
to Django users

Hi,

I'm not sure about what you are expecting from your template "home.html"
but as it is rendered from your view "home(request)", the data passed came from the user instance that is logged-in (cf the decorator '@login_required') as it is explained here (https://docs.djangoproject.com/en/2.2/ref/templates/api/#django-contrib-auth-context-processors-auth)
This instance seems to be defined from the default user model (cf "from django.contrib.auth.models import User")
in that case your custom fields "Business_name" and "mobile" are not defined in the default user model
if you want such fields pleaseyou will need to extend this model cf https://docs.djangoproject.com/fr/2.2/topics/auth/customizing/#extending-the-existing-user-model
```
    >home.html
    {% block content %}
        <p> {{ user.Business_name }} {{ user.first_name}} {{ user.last_name}} {{ user.email }} {{user.username}} {{ user.mobile }} </p>
    {% end block %}
 ```
Also in your stackoverflow message you show this UserCreationForm
If you actually want to use it in a template you actually need more work cf this quick note in this section: https://docs.djangoproject.com/fr/2.2/topics/forms/#working-with-forms

PS: keep your field name "Business_name" in it's lower case form 'buisness_name' as it's a variable and not a class

Hope this gave you some help

Cheers

Reply all
Reply to author
Forward
0 new messages