Rendering Data to Templates | Template Tags | Django (3.0) Crash Course Tutorials (pt 8)
ฝัง
- เผยแพร่เมื่อ 24 ส.ค. 2024
- Check out my Complete Django course! dub.sh/NvGboTI
Rendering data from view to template using built in django template tags.
Follow me on Twitter: / dennisivy11
LinkedIn: / dennis-ivanov
Source code + Live Demo: dennis-sourcec...
Don't forget to check out my Complete Django course! dub.sh/NvGboTI
Just getting into these after digging through some other tutorials. Got to say, these are the best I've seen by far! I found your "I sold my Django app" video, and searched your uploads to see this. Great job! Thank you for your efforts here!
The same as I, Dennis is a really good teacher.
I was about to give up. I came back again after watching Ivy's videos. Thanks bro.
The things got more complicated from the time to time. But Im really eager to learn from your videos. Never expect to get known of the html, bootstrap, css and javascript things. Im glad you covered those things and explained them concisely from the begining.
Keep up the hard work Rakka, so glad my videos are helping :)
My young intelligent man, THANK YOU!
It's astonishing how hard it has been finding a simple, yet brilliant, tutorial like this one. I'm actually quite confident in python programming in general but since I began to learn Django (or web development in general) this summer I've been completely lost due to the logic -the relationship - between views, templates and models. Yes, I've read the docs quite a lot but find them inconsistent in some regards but after this tutorial most, if not all, of my frustration disappeared.
Wish you all the best!
Great tutorial. Best one I've found yet. Thank you, Dennis!
My pleasure Juan! and thanks for the comment :)
@@DennisIvy you are the best, I love you for your courses, I am really learning with them.
I've taken a lot of tutorials which just wasted my time, this tutorial was helpful and on point.
Best Django tutorial so far, detailed and understandable, thank you for making this videos, appreciate a lot man
I have watched several tutorials on Django, but these are the best of all!!
learned so efficiently. No messy code ,clean and easy to understand. Thank You
I was having a hard time making sense of Django but you made it really easy! Thank you for this! :)
Better than many paid tutorials in Udemy. Double thumbs up!!
well explained and solved many of my problems.. appreciate the effort Dennis.
Dennis, thanks a lot for your effort and dedication! Great tutorial with clear explanations of core concepts.
I have got a suggestion)) It would be great if there would be a video tutorial which shows how to render data from 2 database tables, which have the one-to-many relationship, into one table on the webpage (it would be great if custom-template tags could also be covered)
Bro you explain very very good. Thank you!
Thank you!
thank you so much .you really helped me in my project .your manner of explain is very simple and easy to follow
Sir I am facing issues on products = Product.objects.all() That is showing "Class 'Product' has no 'objects' member" Please help me !
me too , if you find it out please let me know where the problem is
@@elnazdehkharghani6121 It's a VS Code's problem. You can leave it like that because your code is ok, it'll work fine. I did this. Or you can change your editor Or you can find other solutions here - stackoverflow.com/questions/45135263/class-has-no-objects-member
Products.objects.all(). you omit s
@@caohuyphuongI have the same error the code is not working too Please help !
add ----------------- orders = Order.objects.all()-------------- inside-------------------------- def home(): -------class------------------ works fine.
I learned a whole lot from just this one video. Thanks fam.
Hi Dennis, why in views.py its saying like Costumer, Product, Order is not defined. This kind of error comes often. pls look into this
Very helpful dennis!! Gave me solid grasp of template logics Thanks again
Yep, best tutor so far. Thanks a lot :)
All your videos helped me a lot to know django. Keep it up
Thanks, Dennis for making this tutorial. kudos
great effort continue with the series boss
Uploading now :)
I believe that you have a high skill to teaching
De los mejores cursos que he visto.
my number of orders delivered and pending is not updating and stucked on 1 since beginning need help
too many values to unpack (expected 2) the peding and delivered variables..help me
use column name instead of direct value. like same as
total_delivered = orders.filter(status='Delivered').count()
i was juz curious and wanted to know how did u learn django and everything related to it. Would be grateful if u could answer that.
Thanks Dennis for the tutorial, it really helps. GBU
me to very curious
for those who have trouble with order when implementing them in dashboard.html, ,make sure that you migrated all the changes and write the correct name. i've been struggled with that for 30 minutes lol
Bro your skill is very good , i liked your courses .If you upload API rest framework courses, i think it will be amazing job for us your followers and your students , thank you .
What I don't understand is how you decide to place "for example" the code for total orders, pending order, etc in the views.py section/file. I guess it's obvious so everything is organized, but still, have trouble understanding the decision-making on naming the files.
Thank Dennis, learned a lot in these past days of going through your channel and courses!
Understood clearly Well explained 😊
This is awesome django tutorial! Im appreciated for uploading your video.
You just saved my life. Thanks
Thanks for the awesome tutorials man.
Great material... I'm really impressed . It is very helpful
Классный туториал
0 dislikes, just the way I like it !
Exception Value:
no such column: accounts_order.customer_id
really good content! learnt a lot from you, thank you so much!
I got an error
ValueError at /
too many values to unpack (expected 2) in part 8 while fetching the
delivered = orders.filter('Delivered').count()
pending = orders.filter('Pending').count()
Thank you. can you Post the link of the video that Expalins how to render the amount of orders for each customer !
Hi, did you figure it out in the end? I just went through the course and it's still missing :)
Not getting orders name....
In return showing order object (1) and so on
Thank you so much sir.Great Work
HI Dennis, great tutorial and thoroughly enjoying it. Curious to know how would you show show the name of a foreign key instead of its Class_ID_value
This was Great ! Thank you.
Thank you , very helpful tutorial
nice tutorial. how to compute total price in costumer can you make some tutorial
Just awesome!
and jhonsnow is handsome
Just awesome! Thank You!
Hi Denis, this is very useful , But I have one doubt, In rendering data to templates, I passed the data to status template with all total_orders, orders_delivered, orders_pending, but I am not able to display those values, what ever value i am passing to the template, I am not able to see the values in the template
Dennis,
Thank you for the great tutorial, I have a question how we can have a for loop in a table from two or more model,
Let's say we have a table and we like to have a product name and customer name and order status on it.
Thank you again.
Thanks very useful tutorial pls can you make the total count for customers or orders just display the count for the day or month or something instead just displaying the overall count thanks..... would be very grateful
I might do something like that after I close out the series :)
Hey Dennis! Thanks for the wonderful series. Really helped me a lot. Just wondering if you've already made a tutorial on how to render the number of orders against each customer (as was shown in the initial demo). Really looking forward to it. Thanks
bro i got an error in home page like 'function' object has no attribute 'objects' when i add customers=customer.objects.all() can you plz help me
I am also getting same error,
@@aaudhachhabria7491 customers=Customer.objects.all()
model name is case sensitive so use Customer instead of customer
very clear, thank you.
Excellent course
12/07/2020
Hi, Dennis!
First of all thanks for this awesome course!
I have a question, let’s say after a series of orders, we update a product's price in the Product Model. It would also affect all of our past orders, isn't that right? How can we go around that?
Thanks again!
is it important to create and write query as u have written as Demosquery??
Type object Customers has no attribute 'count' attribute error coming can anyone help
Really good one . Have a question here though - how would we change the height of the raws ? The width would be 12 from what In understood , but I`ve tried standard html editing for the rows ( ) and didn`t work really ).
Thanks so much for this so informative materials i just have one question in template data example {{data.id}} can it span across multiple related table being some reverse relationships {{Product.Customer,Country.City.City_population)
Thank you sir
I'm a laravel developer...... I wish a long time ago to learn Django, But it's possible with You...
Thank for
what does your experience with both language say....does django seem easier and less complicated??
@@tanvirashraf728 so i have already some skills with Python but , I want to learn python to study data mining and AI. Now I develop with PHP and Laravel my applications. I want to increase my skills
I'm not able to access the source code, could someone please help?
it shows Application Error and in console its 503 error
After running for loop in the Order oobject I cant fetch the details in the dashboard
i did the same thing that you did but it shows me that ('function' object has no attribute 'count')
plz help me to solve this problem i am stuck at it :(
Great ..
thank you very much
delivered = orders.filter(status="Delivered").count()
would you please explain this line of code once again? specially this:- status="Delivered".
So because we are using the "filter()" method instead of "all()" we can filter by the "Order" models "status" attribute. So we are saying "Give us all orders that have the value of "Delivered" in the status field."
Then because "orders.filter(status="Delivered")" returns a queryset/list with all the orders containing the status of "Delivered" we can use the count method to total up how many orders are in that queryset/list and return the total number. Its the equivalent of running the python len() method on a list.
Does that make sense?
@@DennisIvy status is an attribute from Order models..yeah i got it now..thanks a lot..
Rabab Mahdi awesome :)
How can I use SQL commands to retrieve, update and delete data in django?
Hi Dennis, can you help me out with the way that we can actually see total number of orders for each customer in home page. Looks like that was your initial plan on this video but since we have to use model method for that you skipped it... i would appreciate your input on this
Hi, did you figure it out in the end? I just went through the course and it's still missing :)
I am unable to add tags to the products. I also cannot add tags because it won't show in admin panel. Please help!
I have added the Tag class to model.
Awesome
perfect
Hi Eng.Dennis
I have some issue according to Query Set :
once I try as per you above tutorial to rendering data to Template and also I already imported the data using by Shell
like this way :
from motor.models import*
vehicle = Cars_details.objects.all()
print(vehicle)
it will show all the data from table and I don't have any issue.
but when I rendering data to Template it not show and I get message mentions :
AttributeError at /Cars_details/
'function' object has no attribute 'objects'
Request Method: GET
Request URL: 127.0.0.1:8000/Cars_details/
Django Version: 3.0.7
Exception Type: AttributeError
Exception Value:
'function' object has no attribute 'objects'
Exception Location: C:\Users\Administrator\Desktop\carsystem\motor\views.py in Cars_details, line 14
Python Executable: C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe
Python Version: 3.8.3
Python Path:
['C:\\Users\\Administrator\\Desktop\\carsystem',
'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip',
'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python38\\DLLs',
'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python38\\lib',
'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python38',
'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-pack
so plz can you solve it for me >
thanks
Dennis how we can relate two models to a single class based view ? Can any one help
Can someone share the cheat sheet with me?
products = Product.objects.filter this works
products = Product.objects.filter.all() and this doesn't
why?
Thanks!
sir ,all the queries u have written in views.py like total_customers =customers.count()...is these queries are same if i changed the database..let say mongoDB.?
mongo isnt sql database so possibly there are other queries
Good man
Thankyou sir for inspiration in programming nd i found an error while following your series plz help me to sort out
As i define the path('customer//',views.customer,name='customer'),
And error out to be current path,Customer/ didn't match any of these
While all other path are correct sir i m a newbie in django...
Even when i used in 127.0.01:8000/customer/2 its running but when i run the path only to customer it errors out
Hey Dennis, how do I get my Last 5 orders to display only the last 5? I have about 15 orders in the table to test but I can't seem to figure out how to only display the last 5 orders in the table. Thanks for the great videos!
orders = Orders.objects.all()[:5]. and in models you order_by date_created
you can user order by with query also to display
can any one help me
for product template it gives "no such table" as error.
makemigrations first bro
then migrate
Hey Dennis, i'm stuck and really i don't know why. When i set on views orders and customers with ***.objects.all(), i get this error "Exception Value:
'function' object has no attribute 'objects'". Maybe is something stupid, but i cannot understand where's my mistake.
Just check which model gave that error then Just change the model name,it conflicts on the naming convention,so just change the model name.💯 Fix.I fixed it in that way.
@@deepanshudutta4443 please explain more
I am having so may errors where I can ask you
hey i tried using __str__(return self.customer ,self.product) in the Order class
that worked just fine till now.Now, it shows type error (returned non string type "tuple")
but without that chunk the code works fine!
why so?
You can only return a string. In the order model both customer and product are foreign key references to their respective models. I haven't tried it but you could probably make it valid by using "return self.customer.name, self.product.name". This way it is a string as both the name fields are strings.
@@tonyd9120 still the same error !
You can convert them to string using string formatting
def __str__(self):
return f'{self.status}_{self.customer.name}_{self.product.name}'
Hi Dennis& Thank you so much for your tutorials. It helps me a lot. But you know, when z I start to code my project I faced with following problem. Sent few days in google, but didn't find anything. So if it is possible, will be very thankful if you can help me.
I try to doo link in my table to database info, as in your video:
{% for order in orders %}
{{order.contract.client_contr.company_name}}
And it is work. when try to get info from child table into Parent table, without any problem.
But when I need to get the same result from parent table to Child, I can't do that. example:
{{order.statusesorder_set.num_waybill}}
I didn't get any info from it. I even try to use related_name and still didn't get any info
This table StatusesOrder has ForeignKey to Orders
class StatusesOrder(models.Model):
order_stat = models.ForeignKey(Orders, null=True, on_delete=models.PROTECT, related_name='statorder')
So I will be very thankful if you can give me advice!
Bro.. This course is not for beginners
Everyone has their own learning style. Funny thing is, I’ve been told it’s too basic from others. Find what fits you.
@@DennisIvy ayo dennis youre a savage lol