Join my free course on working with the database and models in Django: prettyprinted.com/djangodata
@liorbm14 жыл бұрын
Hi, You have a mistake: Slice[from : to : Step] - this is the correct Slice
@janekmuric6 жыл бұрын
The x[5:10] syntax simply means "get items from 5th index to 10th index". I don't know why you complicated it so much.
@Kamel4197 жыл бұрын
Thanks for all of your videos Anthony, great work as always! I've never understood Django's ORM
@prettyprinted7 жыл бұрын
Thanks!
@digisocialmedia44036 жыл бұрын
Where are the joins queries can you also tell that
@xtremehackerzpro95117 жыл бұрын
It's would be nice to mention that exist OR statement in filtering over object for example: result = Item.objects.filter(item.creator = owner) | Item.objects.filter(item.moderated = False) Also great way in Django is a extracting year or month of date attribute for example: result = Item.objects.filter(date__created__year='2018') Keep going with great tutorial :)
@prettyprinted7 жыл бұрын
Yeah, I completely forget about OR queries. I guess I'll have to cover them in a future video. Same thing with dates.
@blakef.85665 жыл бұрын
Thank you, much better than reading the documentation.
@prettyprinted5 жыл бұрын
You're welcome! Thanks for watching.
@mekkismart71984 жыл бұрын
Blake F. Reading the documentation is effective when you know the basics, the documentation is for advanced things
@Ccviewcom4 жыл бұрын
pretty smooth for a brazillian like me got easy to understand and pretty complete as you said!!! thank you so much sir, ill definitely recommend for coworkers and try the free course you said. Awesome!! keep going calm like this!!
@jomarsalazar25725 жыл бұрын
Been looking for solution on how to combine tables in django for 2 days already. And I thank God i found your tutorial
@jomarsalazar25725 жыл бұрын
can you help me pls how to combine 3 models?
@Elmaco75 жыл бұрын
Hi pretty printed. How can I create queries and view them on the site(when I do runserver) and not on the terminal's shell?
@hughe294 жыл бұрын
You need to put the query into your template.
@indianmongoose3 жыл бұрын
Very clear and concise explanation , thank you !
@rajaryan75664 жыл бұрын
sir you are the best teacher
@marthavanorshoven19424 жыл бұрын
This was VERY HELPFUL to me. I am new to Django and was wrestling with the query functionality
@prettyprinted4 жыл бұрын
I'm glad it helped. Thanks for watching!
@sumanbanik33396 жыл бұрын
if its [:5], it simply means get the first five elements of the list, that is; 0,1,2,3,4....exclude 5, same with [5:10].
@meghashahri55275 жыл бұрын
DO YOU HAVE VIDEO FOR QUERIES WITHOUT MODELS?
@buncha14995 жыл бұрын
Thanks Pretty Printed! Very useful introduction for me. Love the ORM compared to raw SQL :)
@amolgode98433 жыл бұрын
Hello Sir...! I have two models A and B which having many to many relation and form third model E with extra attributes . so i want to perform following sql query using django : select * from A , B , E where A.id = E.id and B.id = E.id and A.id = '107'; how i can do..? A.objects().filter(e__aid=107) geves me only content from A model. Plzz Help..?
@GraceandWisdom5 жыл бұрын
Just curious. What software app is being used for your command prompt? The one with the Reddish-Orange circle.
@prettyprinted5 жыл бұрын
That's Ubuntu on Windows
@WaradeRahul1214 жыл бұрын
Thank you. I appreciate your effort. 30 minutes back i was unsure how to understand querying a model in easy ways, you just :D ! Respect :)
@codewithkg90964 жыл бұрын
Something I was looking for from long time!! Precious!
@mohaamiin87676 жыл бұрын
1:18 can you tell what that app is and what is used for plz
@prettyprinted6 жыл бұрын
JADE. It's in the Chrome Chrome app store.
@mohaamiin87676 жыл бұрын
@@prettyprinted thanks can you make video how to use
@prettyprinted6 жыл бұрын
Here you go: kzbin.info/www/bejne/gGqbeqeLZs-Fp5Y
@StevenSmith688284 жыл бұрын
Can you specify types? Like say that that age must be an int instead of a string
@suburbanblackboyradio26634 жыл бұрын
Awesome vid. I am just having an issue with using the & query. OR works just fine, but & is returning nothing and I'm stumped.
@pedrofolch97866 жыл бұрын
Thanks Anthony, this is very helpful, I need to know if and how can we save the results of the query into the same model or another model? Could you provide an example, Lets say using boolean field and a list of Integers to save the average of the list, if the boolean is True. Or do you have another video with that kind of example?
@prettyprinted6 жыл бұрын
If I understand you correctly then all you'd need to do is check if that boolean is true before saving the model. If it doesn't true, then you don't have to do anything.
@MindJargon5 жыл бұрын
Hi. Would using model queries and using CRUD MySQL methods be different? Thanks
@KrishnaManohar80214 жыл бұрын
can you tell me how DateTime field u did?
@danielm39775 жыл бұрын
Pretty Printed , briefly. It was awesome and well-articulated. THANk U
@Cam-p2z4 жыл бұрын
This video really helped me out a lot. Thanks!
@liorbm14 жыл бұрын
We still using Postgres. Can you provide some output file that we can duplicate your DB ?
@ankurmishra84634 жыл бұрын
Hey, How we can query related to joins in django
@annettemaza39226 жыл бұрын
Hi there! Thanks for the video! Is there a way to filter by next id? If I want to display the name of my next model on the current one? :)
@prettyprinted6 жыл бұрын
I've never done something like that before. My approach would be to do it manually. Maybe this well help you: stackoverflow.com/questions/6021694/getting-next-and-previous-objects-in-django
@HawkwardPause6 жыл бұрын
Hi Anthony, can you filter from an offset all the way to the end of the table? i.e: Programmer.objects.all()[5:] in order to get the remainder? Thanks for these videos, they really help me focus down on the basics and remove roadblocks while I get used to Django.
@prettyprinted6 жыл бұрын
If I understand you correctly, then yeah you can. An offset just skips the first n records. Limits to restrict the number of results, but with no limit, you'll get everything to the end.
@mikef67852 жыл бұрын
How do you return a table value from a another user select table value. For instance returning firstName when selecting LastName from a People table. The value returned from the user selected lastName would populate a select field in a form. As well as the char field to hold the firstName after the user selects the lastName.
@olliewelsh1234 жыл бұрын
simple, clear and useful to beginners. thanks!
@sarveshwarpandey95163 жыл бұрын
sir how to create model objects inside the code itself, not using shell or the admin panel
@yashwardhan90144 жыл бұрын
Is it possible to join two tables without using foreign key
@jafarhussain13044 жыл бұрын
how to get the id of the particular object for example i need the id of python in the language model can we get it directly if we can what is the syntax for it can u plz help me out
@jaydevpatil9213 жыл бұрын
Your videos have been a great source of information. Actually I need to query a foreign data wrapper (foreign table) of my Postgres db using Django. Is there any way I could do that. Any leads would be highly appreciated. Thanks!!
@romanp15214 жыл бұрын
where can I find all filters for queries
@nick_way4 жыл бұрын
Very clearly explained, thank you
@dziurappa6 жыл бұрын
Hi Anthony ! Great tutorials ! Thanks a lot ! I have a problem which I can't solve by myself since I'm a beginner. For a example I'm making a website with some articles about dogs and cats. My question is: How to make some kind of button where USER (not admin) can select all the articles about dogs only. Where (which file) should I make a function with sql logic and how should I use it in .html ? Thank you in advance. Paul
@prettyprinted6 жыл бұрын
You can start by creating two views. One for cats and one for dogs. In each view, you'll query for the category you want and return the results to some html template. Once you get that down, you should see the similarity between the two and you can think of ways you can combine the two views into one.
@ishikajain81143 жыл бұрын
Thank you for the great explaination!
@nandrajmeshram87553 жыл бұрын
Very usefull stuff. Thank you! Please add query's using "in" fuction.
@bijarnia_vikash6 жыл бұрын
Django's pick up lines( easy way to get records) works well on Models. Thank you It was great.
@prettyprinted6 жыл бұрын
Thanks for watching.
@darkdraconium4 жыл бұрын
This was super helpful, thank you!
@180doman6 жыл бұрын
It would be great if you publish .sql file of your bases as well. Or fixture. Offcourse filling them by hand can be good excercise but in case of Programmers table it can be quite daunting task. Other than that - awesome tutorial!
@prettyprinted6 жыл бұрын
I forgot to add the code link. You can download it here: s3.us-east-2.amazonaws.com/prettyprinted/django_model_queries.zip
@santanasta827 жыл бұрын
Great video again, Anthony! Thanks for your videos! Please keep on doing! One doubt: what is the program you use to see your database tables? Is that JADE? Where can I get it? I like the way you check your database. Thanks man! Congratulations!
@prettyprinted7 жыл бұрын
Yeah, that's JADE. You can get it in the Chrome web store here: chrome.google.com/webstore/detail/javascript-based-database/bponbdjkefbmgkfiiphhabghkkfocook?hl=en
@santanasta827 жыл бұрын
Perfect! Thank you very much! I love it!
@deepakprakash89406 жыл бұрын
Hey great and nice video for basics but how you were clearing the shell so quickly was that some trick or shortcut plz share
@prettyprinted6 жыл бұрын
ctrl + l
@deepakprakash89406 жыл бұрын
Thanks a lot
@EpoKeins3 жыл бұрын
Can someone tell me where to find all these filter keywords (in the documentation)?
@sumitmishra8484 жыл бұрын
very helpful stuffs . THANKS A LOT !!!
@azamatuzbekov1175 жыл бұрын
I'm wondering when we upload data to db should we enter ID or name itself? For example Programmer table column Language. Do you have any videos related to this?
@prettyprinted5 жыл бұрын
It depends on your situation. For the most part, I like IDs better, but names can work too if they're unique.
@anthonyhumphreys96803 жыл бұрын
dang bro ur awsome thank you for all your content
@shadiismailalzouabi10354 жыл бұрын
lPlease sir, python.programmers_set this command create many to many relationship between programmers module and ( programme language ) module?
@muhsinkhalif36215 жыл бұрын
Thanks bro such a helpful video!
@prettyprinted5 жыл бұрын
You're welcome! Thanks for watching.
@Fire_Fly_1015 жыл бұрын
Pretty good info bro .. you have really helped me a lot in my personal project.. your videos are actually really informative n helpful..!!!
@prettyprinted5 жыл бұрын
I'm glad my videos have helped you. Thanks for watching!
@ChaosArtist5 жыл бұрын
Nice overview, very helpful to see the most common Django model queries.
@harshthakkar80814 жыл бұрын
can we use startwith = '[a-z]' like this ??
@mostafizurrahmanshohan90756 жыл бұрын
Thank you... can u show us how we can make class-based URL slug?
@prettyprinted6 жыл бұрын
I'll add that to my list. Thanks for the idea.
@shubhangidutt50803 жыл бұрын
In my project. Objects.all() is throwing error Please help
@sushilraverkar0074 жыл бұрын
Why objects.all() not giving all columns ?
@betelhemtesfaye78383 жыл бұрын
Thank you Sir. You are the best.
@MrDevZero5 жыл бұрын
Thank you. Very helpful.
@prettyprinted5 жыл бұрын
You're welcome! Thanks for watching.
@neelesh.vishwakarma5 жыл бұрын
I'm getting an error in the following expression Message.objects.filter(ishandled == True) 'ishandled' is a field in the Message table and I'm getting error that ishandled is not defined. can you please help?
@prettyprinted5 жыл бұрын
One equals sign instead of two.
@as-youtuber62155 жыл бұрын
Any video regarding django ORM joins????
@prettyprinted5 жыл бұрын
Not yet, I'll consider making a video on that.
@santoshkumar-xq6wx4 жыл бұрын
Nice vedio, thanks for making our work more easy, can you say how to user "OR" filter here.
@JS-lw4ks4 жыл бұрын
Does anyone have any resources on connecting to an MSSQL database? I can connect to the DB and run a stored procedure but struggling with parameters
@AliHasanov4 жыл бұрын
Probably, you forgot : First object: Model.objects.filter("name").first() Last object: Model.objects.filter("name").last() To get random objects: Model.objects.order_by('?') and Q objects for complex lookups Thanks for everything :)
@kakumbanassirissa39725 жыл бұрын
Thanks for the video i however tried to filter a column from one of my models which has a foreign key but i had to reference it with the primary key instead of the real word. is there a way i can look up for something with out using the primary key. for example Programmer.objects.filter(company__exact='Microsoft') - returned the error but Programmer.objects.filter(company__exact='1') where 1 is the primary key Id for microsoft return no errors how can i make the first statement work. Note: i just used the above example thanks
@prettyprinted5 жыл бұрын
You would use __ to get into the child model. So company__name__exact='Microsoft'
@kakumbanassirissa39725 жыл бұрын
@@prettyprinted Thanks will try that and revert. do u have any videos on writing templates?
@prettyprinted5 жыл бұрын
@@kakumbanassirissa3972 Check out my Jinja playlist. It's for Flask, but it's very similar to the default Django template language.
@kakumbanassirissa39725 жыл бұрын
Pretty Printed thanks
@shiv77patil6 жыл бұрын
can u help me i querying foreignkey
@junaidtariq32654 жыл бұрын
I have three table a,b,c. A have many to many relation with b and b have many to many relation to c. I have problem when I click on a its show all relative b but I want when I click on a it will show b table entries and all c entries which relative to b
@harshraj22_5 жыл бұрын
Thanks A Lot ! The video was very helpful 😁😊 Do you have any video explaining more about foreign keys ? It seems little confusing ☹️
@nowyouknow22494 жыл бұрын
Very useful Thanks
@harpalsinhjadeja25686 жыл бұрын
how am i supposed to run sql queries in shell like lets say i want to insert then how do i insert something in the table using sql in django shell
@prettyprinted6 жыл бұрын
Here's more information on that: docs.djangoproject.com/en/2.1/topics/db/sql/#executing-custom-sql-directly
@manishkumar-db5xm5 жыл бұрын
Very useful video, Thanks
@prettyprinted5 жыл бұрын
You're welcome!
@AnimatedHooman6 жыл бұрын
Amazing video sir. Very informative
@pranavkhandelwal84745 жыл бұрын
Simple and Good Explanation :)
@RizwanAli-bu5oy6 жыл бұрын
how can i retrieve database tables and all the the data from mysql. if you like, make me a video on mysql, i'm using xampp server. please give me all the details about mysql and how to query data. i have made database using phpmyadmin, now i want to use that data in django app
@AjaySharma-jv6qn5 жыл бұрын
Thanks for your work
@mrmuranga5 жыл бұрын
well explained...thank you
@victorkeynote63016 жыл бұрын
works the same, if i use filter.name, instead of filter.name__exact. so why not just use name??
@prettyprinted6 жыл бұрын
You don't have to. I'm not sure why I did it here. Sometimes I get tunnel vision.
@alnoneatall3 жыл бұрын
any Project with django sir?
@shashidhardevraj6 жыл бұрын
Thanks for the video! Its very clear.
@prettyprinted6 жыл бұрын
You're welcome!
@ROMAN-zu3wu2 жыл бұрын
Thank u so much bro
@glassy57163 жыл бұрын
thanks Great video
@mzgz42167 жыл бұрын
Great video thanks Anthony
@prettyprinted7 жыл бұрын
Thanks for watching!
@naimurrahman23675 жыл бұрын
can anyone help to solve this ImportError: cannot import name 'get_user_object' from 'django.contrib.auth'
@Smoonwalkerm6 жыл бұрын
When I type Company.objects.all().. I'm getting this: ....Why not the names of companies ?
@prettyprinted6 жыл бұрын
You have to define __str__ in your model class.
@aniketmlk65 жыл бұрын
Thanks! Extremely High quality content
@prettyprinted5 жыл бұрын
Thanks for watching!
@taihatranduc86133 жыл бұрын
It's a very good video
@footballfan77966 жыл бұрын
Hey can I email you need your help in creating something I been using django for some time now and want to test out my skills but I got stuck and don't know how to move on so I hope you can help me thank you
@prettyprinted6 жыл бұрын
I might be able to help. My email is anthony@prettyprinted.com
@footballfan77966 жыл бұрын
@@prettyprinted ok i will message you now thanks
@xtremehackerzpro95117 жыл бұрын
Great video again... Go ahead :)
@prettyprinted7 жыл бұрын
Thanks for watching!
@rvenu89325 жыл бұрын
super brooooooo Exlente
@saharamanson19704 жыл бұрын
thanks bro..
@nehalbhosale56633 жыл бұрын
Grt ❣️❣️❣️❣️
@keerthivasang11786 жыл бұрын
Thank U very much sir!!!!!!!!
@prettyprinted6 жыл бұрын
You're welcome! Thanks for watching.
@nickt4235 жыл бұрын
I didnt watch the full video because some reason this is hard to follow along without the IDE. views.py, models.py, ect. dont matter here?
@prettyprinted5 жыл бұрын
The video covers the basics of the queries, so I use the console instead of the web app so you can see the results instantly. But when you're creating a real app, you'd use the same statements within your views.py file as you do in the console here.
@bastiaanvandenabeele86456 жыл бұрын
Thanks !
@prettyprinted6 жыл бұрын
You're welcome! Thanks for watching.
@BehruzbekOtayev4 жыл бұрын
Why do you call it 'Jango'? Its with D 'Django'.
@KaranKumar-wb5bn4 жыл бұрын
I love you🖤
@prettyprinted4 жыл бұрын
I love you too 😘
@openmindjustdoit13063 жыл бұрын
mypost=post.objects.filter(id__topboard=self).count() print(mypost) return mypost i want to get acount all post for this board get Error like this >>>> ValueError at / Cannot query "Schoole": Must be "topic" instance.
@jarettchaiken14926 жыл бұрын
name__exact and name__iexact are doing the same thing for me. >>> Language.objects.filter(name__exact='Java') >>> Language.objects.filter(name__iexact='Java')
@shreyesbasutkar92065 жыл бұрын
how to add values of 2 objects? say suppose age .. i want to add 2 people age .. how can i do it?