Exception value name is not defined

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Exception value name is not defined

Kean Dumba
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K









--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

RONAK JAIN
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K









--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

N'BE SORO
Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K









--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

Kean Dumba
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

N'BE SORO
you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

Kean Dumba
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

N'BE SORO
Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

Kean Dumba
Hi, N’BE,

The code you sent, when i apply using my model and substitute the objects for those defined in my model, in the context, the browser,  throws up unidentified error for the object defined in the context, i.e. my object name.

Please see example below which better explains what I am trying to achieve:

Example, 

I have one table in models,

Models.py 

class Test(request):
Name = models.CharField(max_length=10)
Surname = models.CharField(max_length=10)
Father_name = models.CharField(max_length=10)
Mother_name = models.CharField(max_length=10)
Brother_name = models.CharField(max_length=10)
Sister_name = models.CharField(max_length=10)

 def__self__(self):
return self. name

------
When I use your “working' code in views

I only see the result of one object: Name: John Smith

I would like to see the results of all the objects stored in the database: Name: John Smith, Father name: Sam Smith,
Mother name: Angela Smith, Brother name: James Smith and Sister name: Sarah Smith.

All 6 objects, would need to appear in the view,

Is there a way to code this?

Best,

K


On 15 Aug 2019, at 20:36, N'BE SORO <[hidden email]> wrote:

Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79C2E086-056C-4C06-A2D7-B64916A694C7%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

N'BE SORO
Ok. 

Use this code: 

data = Test.objects.all() 

context = {
    'data': data, 
}


in Your template use: 


data.broname
... 



Le jeu. 15 août 2019 à 19:56, Kean <[hidden email]> a écrit :
Hi, N’BE,

The code you sent, when i apply using my model and substitute the objects for those defined in my model, in the context, the browser,  throws up unidentified error for the object defined in the context, i.e. my object name.

Please see example below which better explains what I am trying to achieve:

Example, 

I have one table in models,

Models.py 

class Test(request):
Name = models.CharField(max_length=10)
Surname = models.CharField(max_length=10)
Father_name = models.CharField(max_length=10)
Mother_name = models.CharField(max_length=10)
Brother_name = models.CharField(max_length=10)
Sister_name = models.CharField(max_length=10)

 def__self__(self):
return self. name

------
When I use your “working' code in views

I only see the result of one object: Name: John Smith

I would like to see the results of all the objects stored in the database: Name: John Smith, Father name: Sam Smith,
Mother name: Angela Smith, Brother name: James Smith and Sister name: Sarah Smith.

All 6 objects, would need to appear in the view,

Is there a way to code this?

Best,

K


On 15 Aug 2019, at 20:36, N'BE SORO <[hidden email]> wrote:

Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79C2E086-056C-4C06-A2D7-B64916A694C7%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-79bc9OsYPee_0eDtN%2BDdsv15RN1%3Dr-kJss-_X1xNR%3DA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

N'BE SORO
I'll put an example on GitHub and send you the link

Le jeu. 15 août 2019 à 20:29, N'BE SORO <[hidden email]> a écrit :
Ok. 

Use this code: 

data = Test.objects.all() 

context = {
    'data': data, 
}


in Your template use: 


data.broname
... 



Le jeu. 15 août 2019 à 19:56, Kean <[hidden email]> a écrit :
Hi, N’BE,

The code you sent, when i apply using my model and substitute the objects for those defined in my model, in the context, the browser,  throws up unidentified error for the object defined in the context, i.e. my object name.

Please see example below which better explains what I am trying to achieve:

Example, 

I have one table in models,

Models.py 

class Test(request):
Name = models.CharField(max_length=10)
Surname = models.CharField(max_length=10)
Father_name = models.CharField(max_length=10)
Mother_name = models.CharField(max_length=10)
Brother_name = models.CharField(max_length=10)
Sister_name = models.CharField(max_length=10)

 def__self__(self):
return self. name

------
When I use your “working' code in views

I only see the result of one object: Name: John Smith

I would like to see the results of all the objects stored in the database: Name: John Smith, Father name: Sam Smith,
Mother name: Angela Smith, Brother name: James Smith and Sister name: Sarah Smith.

All 6 objects, would need to appear in the view,

Is there a way to code this?

Best,

K


On 15 Aug 2019, at 20:36, N'BE SORO <[hidden email]> wrote:

Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79C2E086-056C-4C06-A2D7-B64916A694C7%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9qsMshJdc-36qBPpcKeEvwEjp7YA4WTY2j426btFP-Ww%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

Kean Dumba
In reply to this post by N'BE SORO

Hi, pls see the result of the code, no objects, just the ID number, and the model name, plus query set,
not sure what issue is here.


On 15 Aug 2019, at 21:29, N'BE SORO <[hidden email]> wrote:

Ok. 

Use this code: 

data = Test.objects.all() 

context = {
    'data': data, 
}


in Your template use: 


data.broname
... 



Le jeu. 15 août 2019 à 19:56, Kean <[hidden email]> a écrit :
Hi, N’BE,

The code you sent, when i apply using my model and substitute the objects for those defined in my model, in the context, the browser,  throws up unidentified error for the object defined in the context, i.e. my object name.

Please see example below which better explains what I am trying to achieve:

Example, 

I have one table in models,

Models.py 

class Test(request):
Name = models.CharField(max_length=10)
Surname = models.CharField(max_length=10)
Father_name = models.CharField(max_length=10)
Mother_name = models.CharField(max_length=10)
Brother_name = models.CharField(max_length=10)
Sister_name = models.CharField(max_length=10)

 def__self__(self):
return self. name

------
When I use your “working' code in views

I only see the result of one object: Name: John Smith

I would like to see the results of all the objects stored in the database: Name: John Smith, Father name: Sam Smith,
Mother name: Angela Smith, Brother name: James Smith and Sister name: Sarah Smith.

All 6 objects, would need to appear in the view,

Is there a way to code this?

Best,

K


On 15 Aug 2019, at 20:36, N'BE SORO <[hidden email]> wrote:

Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79C2E086-056C-4C06-A2D7-B64916A694C7%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-79bc9OsYPee_0eDtN%2BDdsv15RN1%3Dr-kJss-_X1xNR%3DA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0522ADDD-B8A7-4A79-A8A1-43CD327E2DDC%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

N'BE SORO
This is normal in the view.py file is what appears. Now if you want to use the data in the template You must use a loop to browse the items. I will send you a Github link or I will better explain.

Le jeu. 15 août 2019 à 20:49, Kean <[hidden email]> a écrit :

Hi, pls see the result of the code, no objects, just the ID number, and the model name, plus query set,
not sure what issue is here.


On 15 Aug 2019, at 21:29, N'BE SORO <[hidden email]> wrote:

Ok. 

Use this code: 

data = Test.objects.all() 

context = {
    'data': data, 
}


in Your template use: 


data.broname
... 



Le jeu. 15 août 2019 à 19:56, Kean <[hidden email]> a écrit :
Hi, N’BE,

The code you sent, when i apply using my model and substitute the objects for those defined in my model, in the context, the browser,  throws up unidentified error for the object defined in the context, i.e. my object name.

Please see example below which better explains what I am trying to achieve:

Example, 

I have one table in models,

Models.py 

class Test(request):
Name = models.CharField(max_length=10)
Surname = models.CharField(max_length=10)
Father_name = models.CharField(max_length=10)
Mother_name = models.CharField(max_length=10)
Brother_name = models.CharField(max_length=10)
Sister_name = models.CharField(max_length=10)

 def__self__(self):
return self. name

------
When I use your “working' code in views

I only see the result of one object: Name: John Smith

I would like to see the results of all the objects stored in the database: Name: John Smith, Father name: Sam Smith,
Mother name: Angela Smith, Brother name: James Smith and Sister name: Sarah Smith.

All 6 objects, would need to appear in the view,

Is there a way to code this?

Best,

K


On 15 Aug 2019, at 20:36, N'BE SORO <[hidden email]> wrote:

Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79C2E086-056C-4C06-A2D7-B64916A694C7%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-79bc9OsYPee_0eDtN%2BDdsv15RN1%3Dr-kJss-_X1xNR%3DA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0522ADDD-B8A7-4A79-A8A1-43CD327E2DDC%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp8B4gx%2BWToJMFgSuaGu84xLG4Zydteb4zovcOmazLnzKQ%40mail.gmail.com.

Screen Shot 2019-08-15 at 21.46.47.png (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

N'BE SORO

Le jeu. 15 août 2019 à 22:54, N'BE SORO <[hidden email]> a écrit :
This is normal in the view.py file is what appears. Now if you want to use the data in the template You must use a loop to browse the items. I will send you a Github link or I will better explain.

Le jeu. 15 août 2019 à 20:49, Kean <[hidden email]> a écrit :

Hi, pls see the result of the code, no objects, just the ID number, and the model name, plus query set,
not sure what issue is here.


On 15 Aug 2019, at 21:29, N'BE SORO <[hidden email]> wrote:

Ok. 

Use this code: 

data = Test.objects.all() 

context = {
    'data': data, 
}


in Your template use: 


data.broname
... 



Le jeu. 15 août 2019 à 19:56, Kean <[hidden email]> a écrit :
Hi, N’BE,

The code you sent, when i apply using my model and substitute the objects for those defined in my model, in the context, the browser,  throws up unidentified error for the object defined in the context, i.e. my object name.

Please see example below which better explains what I am trying to achieve:

Example, 

I have one table in models,

Models.py 

class Test(request):
Name = models.CharField(max_length=10)
Surname = models.CharField(max_length=10)
Father_name = models.CharField(max_length=10)
Mother_name = models.CharField(max_length=10)
Brother_name = models.CharField(max_length=10)
Sister_name = models.CharField(max_length=10)

 def__self__(self):
return self. name

------
When I use your “working' code in views

I only see the result of one object: Name: John Smith

I would like to see the results of all the objects stored in the database: Name: John Smith, Father name: Sam Smith,
Mother name: Angela Smith, Brother name: James Smith and Sister name: Sarah Smith.

All 6 objects, would need to appear in the view,

Is there a way to code this?

Best,

K


On 15 Aug 2019, at 20:36, N'BE SORO <[hidden email]> wrote:

Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79C2E086-056C-4C06-A2D7-B64916A694C7%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-79bc9OsYPee_0eDtN%2BDdsv15RN1%3Dr-kJss-_X1xNR%3DA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0522ADDD-B8A7-4A79-A8A1-43CD327E2DDC%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-69gT2xtcwtbu6YYg0y-ytvmncehsZw2gPudx4EvLcpA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

Tosin Ayoola
In reply to this post by Kean Dumba
Can u screenshot d error,  that will b more explanatory 

On Aug 15, 2019 19:07, "Kean" <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K









--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHLKn70nK_QS_6E%2Bui7Gx4Q4xfE9sv4fbweEQ7Rc0snsa7YkEw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

Kean Dumba
In reply to this post by N'BE SORO
Hi N’BE,

The github code you provided worked.
I now see all the records.

Thank you for the help.

Best, 

K

On Thu, 15 Aug 2019 at 22:14, N'BE SORO <[hidden email]> wrote:

Le jeu. 15 août 2019 à 22:54, N'BE SORO <[hidden email]> a écrit :
This is normal in the view.py file is what appears. Now if you want to use the data in the template You must use a loop to browse the items. I will send you a Github link or I will better explain.

Le jeu. 15 août 2019 à 20:49, Kean <[hidden email]> a écrit :

Hi, pls see the result of the code, no objects, just the ID number, and the model name, plus query set,
not sure what issue is here.


On 15 Aug 2019, at 21:29, N'BE SORO <[hidden email]> wrote:

Ok. 

Use this code: 

data = Test.objects.all() 

context = {
    'data': data, 
}


in Your template use: 


data.broname
... 



Le jeu. 15 août 2019 à 19:56, Kean <[hidden email]> a écrit :
Hi, N’BE,

The code you sent, when i apply using my model and substitute the objects for those defined in my model, in the context, the browser,  throws up unidentified error for the object defined in the context, i.e. my object name.

Please see example below which better explains what I am trying to achieve:

Example, 

I have one table in models,

Models.py 

class Test(request):
Name = models.CharField(max_length=10)
Surname = models.CharField(max_length=10)
Father_name = models.CharField(max_length=10)
Mother_name = models.CharField(max_length=10)
Brother_name = models.CharField(max_length=10)
Sister_name = models.CharField(max_length=10)

 def__self__(self):
return self. name

------
When I use your “working' code in views

I only see the result of one object: Name: John Smith

I would like to see the results of all the objects stored in the database: Name: John Smith, Father name: Sam Smith,
Mother name: Angela Smith, Brother name: James Smith and Sister name: Sarah Smith.

All 6 objects, would need to appear in the view,

Is there a way to code this?

Best,

K


On 15 Aug 2019, at 20:36, N'BE SORO <[hidden email]> wrote:

Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79C2E086-056C-4C06-A2D7-B64916A694C7%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-79bc9OsYPee_0eDtN%2BDdsv15RN1%3Dr-kJss-_X1xNR%3DA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0522ADDD-B8A7-4A79-A8A1-43CD327E2DDC%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-69gT2xtcwtbu6YYg0y-ytvmncehsZw2gPudx4EvLcpA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKvrVZP%3DOUAPwMbtXmVEwNvWbam1cHfR2PvC_8RqprkpP5Wqtg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

DANIEL URBANO DE LA RUA
In reply to this post by Kean Dumba
There is not object defined

On Thu, 15 Aug 2019, 20:07 Kean <[hidden email] wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K









--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAO_yRT0ab50n-%2BwCagpU8zLfLipPiJnyRrLXOTp1C4TV2GtMDA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Exception value name is not defined

N'BE SORO
In reply to this post by Kean Dumba
Ok.  Thank you

Le ven. 16 août 2019 à 11:31, Kean Dumba <[hidden email]> a écrit :
Hi N’BE,

The github code you provided worked.
I now see all the records.

Thank you for the help.

Best, 

K

On Thu, 15 Aug 2019 at 22:14, N'BE SORO <[hidden email]> wrote:

Le jeu. 15 août 2019 à 22:54, N'BE SORO <[hidden email]> a écrit :
This is normal in the view.py file is what appears. Now if you want to use the data in the template You must use a loop to browse the items. I will send you a Github link or I will better explain.

Le jeu. 15 août 2019 à 20:49, Kean <[hidden email]> a écrit :

Hi, pls see the result of the code, no objects, just the ID number, and the model name, plus query set,
not sure what issue is here.


On 15 Aug 2019, at 21:29, N'BE SORO <[hidden email]> wrote:

Ok. 

Use this code: 

data = Test.objects.all() 

context = {
    'data': data, 
}


in Your template use: 


data.broname
... 



Le jeu. 15 août 2019 à 19:56, Kean <[hidden email]> a écrit :
Hi, N’BE,

The code you sent, when i apply using my model and substitute the objects for those defined in my model, in the context, the browser,  throws up unidentified error for the object defined in the context, i.e. my object name.

Please see example below which better explains what I am trying to achieve:

Example, 

I have one table in models,

Models.py 

class Test(request):
Name = models.CharField(max_length=10)
Surname = models.CharField(max_length=10)
Father_name = models.CharField(max_length=10)
Mother_name = models.CharField(max_length=10)
Brother_name = models.CharField(max_length=10)
Sister_name = models.CharField(max_length=10)

 def__self__(self):
return self. name

------
When I use your “working' code in views

I only see the result of one object: Name: John Smith

I would like to see the results of all the objects stored in the database: Name: John Smith, Father name: Sam Smith,
Mother name: Angela Smith, Brother name: James Smith and Sister name: Sarah Smith.

All 6 objects, would need to appear in the view,

Is there a way to code this?

Best,

K


On 15 Aug 2019, at 20:36, N'BE SORO <[hidden email]> wrote:

Ok. 

Simple exemple. 

data_1 = Model_1.objects.all() 
data_2 = Model_2.objects.all() 
data_3 = Model_3.objects.all() 
data_4 = Model_4.objects.all() 
data_5 = Model_5.objects.all() 
data_6 = Model_6.objects.all() 

context = {

   'data_1':  data_1, 
   'data_2':  data_2, 
   'data_3':  data_3, 
   'data_4':  data_4, 
   'data_5':  data_5, 
   'data_6':  data_6, 
}

return render(request, 'yourpage.html, context) 


####

Replaces Model_1 ... Model_6 by your models you want to send in your view.


Invite your template use data_1,..., data_6



Le jeu. 15 août 2019 à 19:28, Kean <[hidden email]> a écrit :
Hi N’BE,

If I have 6 objects in my dbase model, I would want all six to be returned to the view, via template.

However, the code you sent is only returning 1 object, so i am missing 5

how can I  use the view code, to ensure all 6 are returned o the template?

Best,

K


On 15 Aug 2019, at 20:21, N'BE SORO <[hidden email]> wrote:

you want to send what model on your view?

Le jeu. 15 août 2019 à 19:04, Kean <[hidden email]> a écrit :
Hi N’BE,

Thanks, the code worked, the problem is I wanted to use the context to return all objects in the database to 
the defined html view, 

However, I am still  only getting the self defined str and returning to view, is there any way to get all records in the table to display?

Best,

Kea

On 15 Aug 2019, at 19:50, N'BE SORO <[hidden email]> wrote:

Hello Use this code


def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'data': data, 
}
return render(request, 'editremovebusiness.html', context)

Le jeu. 15 août 2019 à 18:45, RONAK JAIN <[hidden email]> a écrit :
Hey Kean,

What is the object here?




On Thu, Aug 15, 2019 at 11:37 PM Kean <[hidden email]> wrote:
Hi,

I have written the following code in views.py

def editremovebusiness(request):
data = Businessownercreate.objects.all()
context = {
'Creator': obj.Creator, 
'Micro_Small_Medium': obj.Micro_Small_Medium,
}
return render(request, 'editremovebusiness.html', context={"data":data})

when I save it and check the url

it returns 

Exception Type:NameError
Exception Value:
name 'obj' is not defined


Is anyone familiar with this issue, please advise cause and fix?

Best,

K










--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79C2E086-056C-4C06-A2D7-B64916A694C7%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-79bc9OsYPee_0eDtN%2BDdsv15RN1%3Dr-kJss-_X1xNR%3DA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0522ADDD-B8A7-4A79-A8A1-43CD327E2DDC%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-69gT2xtcwtbu6YYg0y-ytvmncehsZw2gPudx4EvLcpA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKvrVZP%3DOUAPwMbtXmVEwNvWbam1cHfR2PvC_8RqprkpP5Wqtg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9uhoKGu0NGXc-1J4mvQ5vUydawHA_0SY1ihvXEfVg3jQ%40mail.gmail.com.