exactly ... This is second time I going through corey sir videos and cant tell how easy django looks to me ... Thanks millions and zillions to corey sir ....
I appreciate that you don't cut out when you do mistakes. I think it's important for beginners like me to see how you debug them and that even a professional like you can have a typo. Great videos. Thanks a lot!
Corey, there is a serious lack of quality Django tutorials out there. You are the only one pumping them out. Your series is incredible. I know you must be busy with so many project ideas already, but could you try extending this series into an advanced series next? I feel like I've learned a lot, but I would like to see you tinker around with the styling, or integrating new apps from Django Packages. I still don't feel fully confident in straying off the path you've laid out for us. I'm sure there are many others like me who would love to see more examples of customization now. I also looked into Mezzanine and Wagtail as CMS options, but again, there are very few tutorials on either of those platforms either. If you're ever looking for other ideas for further series, maybe one on using a CMS would be cool too :). You're the best man, and I'm going to forever point people looking to learn python, to your TH-cam.
I really enjoy how you not only show how to do things, but explain some of the processes behind the operations. If gives inspiration for other creative ideas and uses.
Oh I get stuck for hours on mistakes all the time. It just doesn’t seem that way in the videos because I’ll edit them out to save viewers time. But it definitely happens
For those that are having trouble with adding the extra posts from the posts.json, make sure you have the user id exists for id 1 and id 2 and you did not delete that user. You can check with this command in the shell: from django.contrib.auth.models import User User.objects.get(id=1) # make sure this returns a user User.objects.get(id=2) # make sure this returns a user If no user is returned, make a new user with the : User.objects.create_user(username='missing', email='missing@email.com', password='testing321', id=) Hope this helps. Corey is the bomb.
it gives an error of TypeError: Profile.save() got an unexpected keyword argument 'force_insert' I just edited the json file to go around that. For now
Corey. Your tutorials are premium quality. Anyone who says otherwise is just insane. I would love it if you can make a tutorial on how you learn(Especially going through documentation) because I don't know how you dig out some deep concepts but I would love to learn.
Probably the best tutorials on Django. Thanks-a-lot Corey, your content is not less than magic simple, detailed and obviously well explained. Thanks a-lot.
Big thumb up for all this tutorial ! It's really simple and clear to understand ! For those like me who are using django in version > 3, for the order_by in the get_queryset method, we need to do it before the filter call like : >
Many times I refused to watch youtube tutorials because I think that they are useless.Today I watched your 11 videos continuously thank you I wish you will get a fair shot :)
This whole tutorial series is beast mode. It would be amazing if you could make a tutorial series on building a simple ML app. Something like the user gives some text input and the output is some sentiment score or something using scikit-learn, tensor flow, or pytorch. I would love to see how you would design the layout of that kind of website/web-app using Django.
I may have downloaded your c. 80 videos using youtube-dl but I'm still coming back to hit that like button, you're a saint to aspiring devs everywhere, keep it up!
You making videos with an actual sense of spreading knowledge instead of buying likes and shares. One of the best Django tutorials available on internet. Thankyou from Germany.
Honestly Bro! I was doing your django series after that I took udemy course and realised that first two projects were real shit. Got only 2 to 3 different pieces of information from those udemy videos. Did your series again and understood the concepts in more clearity. You are the only one out there carrying this quality stuff out there. There is serious lack of quality stuff out there. It would be very helpful if you could make a course on DJANGO REST FRAMEWORK. Need guidance in that part. Thank you for everything you are doing for us and we also make sure that we will watch all the ads and visit the pages as a support to this channel. Love for your dog from India.
Thanks for this Corey :) I tried to add a functionality to display all my post by visiting my profile page and clicking the profile picture. :) And successfully done it. Hehe So proud of myself. Thanks Corey sir. :) Just sharing. Hehe
YOOOOO!! My dream just came true. I like the video at 2.9k likes and made it 3k. Lets GO! I am just 14, but Corey Schafer you are amazing. Thank you so much for these videos and I am truly thankful that you are helping me further my programming journey. Thank you so much!
I spent 2 hours figuring out it was supposed to be get_queryset() not get_query_set() and just when I planned on sharing this valuable info in comments, as I moved ahead of video to get the screen he explained this. Oh god.. don,t know if jumping ahead is good or bad anymore.:( But greatful for the content Corey. Almost everything I know in Django is because of you. Thank you.
1:40 getting data from json in shell 4:45 Paginator 8:45 using Paginator with class based view (CBV) 11:30 adding pagination UI in templates 23:00 filtered data Paginator with class based view (CBV) get_queryset 25:05 get_object_or_404
After overriding the save function in users/models.py I was unable to create new users. a fix to this was changing: def save(self): super().save() to: def save(self, *args, **kwargs): super().save(*args, **kwargs) Hope it helps somebody! Thank you for everything that you do Corey. Keep it up. Your tutorial has restored my motivation!
The save method update solved creation of Profile Problem but new error generates saying default.jpg doesn't exists in media folder even though it exists. Tried even restating the development server . problem still persists
For anyone stuck with pagination, yeah, this changed in newer versions of django. with Django 3.0 i get pagination on the users-post page, but the not post page itself. As corey said, this part of the code is not DRY(repeated code in both html files regarding actual pagination) but still they behave differently.
No words to say beyond other viewer comments! Creating personal Operations Manual step by step for a foundation of future projects thanks to you! Ready to complete this and dive into other topics by you...!
You are love, Thank's for making Django easy for us, I will never able to complete my final year project(B.Sc) without your loving playlist of Django, it helped me a lot
I found this tutorial to be pretty helpful, thank you. I was wondering if you will do another part on many-to-many relationships for models particularly in relation to CRUD. Maybe for example for your blogs, you can have tags.
Hi corey, this entier tutorial is incridible and understandable , but can you extend this series a bit and let us know how to implement chat feature so that users can chat as well after logging in
To anyone getting an error when creating posts: I have noticed there is a small error maybe due to changing of Django versions When creating posts, providing author_id = post['user_id'] gives an error. Just do a user = User.objects.get(id=post['user_id']) before making the post and instead of author_id, do author = user. Of course you will need to import User model as explained in previous videos.
@@alexkoshy1999 No bro no need to add gibberish post its not good practice this is how i identify my users id from shell , because at the first i have created some users and deleted for some resons thats why i has been facing this issue here is the shell code which i have used >>> user = User.objects.all() >>> user >>> user = user.first() >>> user >>> user.id 9 >>> user = User.objects.all() >>> user >>> user = User.objects.get(username='NewUser') >>> user >>> user.id 10 >>> i hope this would help
Thank you so much for this video!!! I was stuck on this problem from a long time and was thinking to apply concept of Lazy Loading, but this solves my problem. Thankyou!
At 22:00 in the end of paginations. I did some changes on the pagination buttons I hope you like it: {% if is_paginated %} {% if page_obj.has_previous %} First Previous {% else %} First Previous {% endif %} {% for num in page_obj.paginator.page_range %} {% if page_obj.number == num %} {{ num }} {% elif not page_obj.has_previous %} {% if num = page_obj.number|add:'-2' %} {{ num }} {% endif %} {% elif num >= page_obj.number|add:'-1' and num
Hi Marcelo, this part is not right I'm afraid {% else %} First Previous {% endif %} because it will be visible even if there isn't a previous page, which should not be the case. same with this: {% else %} Next Last {% endif %} it will appear even when there isn't a next page. Also, their href attributes are '#', meaning they will not change to a particular page
@@shemmuthanga6352 To be honest I don't know exactly what's going on in that piece of code, but anyway, here's what i meant with this code: I wanted the buttons to appear even if there is no previous page before the first one and even if there is no later page after the last one.
And to avoid confusion I changed the colors by changing the class from "btn btn-outline-info mb-4" to "btn btn-outline-secondary mb-4". Try it in your django code see what you think :P
@4:08 well, could you please please show how to add images to posts, I was thinking about django-ckeditor, or maybe just a simple form one image per post plus thumbnail in the listview on home.html along with search section would spice up the blog even further. Thank you for this tutorial, it's great!
Corey, if you could bottle this and sell it... but then, you're probably already rich from working as a programmer. It would be pretty cool if you could find someone who knows as much as you do--but about other computer topics, then teach them how to plan a recording session. You could sell it as a documentation service to companies with products like Django and Git. Anthony Sherrill says you don't edit your mistakes out, but the vast majority of them appear to be planned mistakes--not mistakes at all. I was using another set of tutorials, but that guy wasted oodles of time just chit chatting. I love the way you plan, follow your plan, and get to the next point.
I perform a lot of edits on my videos. I'll leave mistakes in if I feel like they have some value to the viewer, but if they are mistakes that won't give any value then I try to edit them out.
I have question if anyone can answer, how to get familiar with all these methods. We can't remember all these methods right? Where to check for them if we forgot ? Great Series Corey. I am learning more from you than my university lecturers. And thank you!! AS Soon AS I will get my first job, I am gonna contribute to your channel through patreon.
To any of you who get an error of django.db.utils.IntegrityError: FOREIGN KEY constraint failed. That can be happening for some reasons (most of them are detailed in the comments), but I didn't see any comment addressing the problem I had. Because I played with the creation of the user a little bit, my user_ids weren't 1, 2, and 3. However, the JSON file contains user_id of 1, 2, and 3, so I basically tried to upload a post to an unexisting user. To check the user_id of each user you can do the following: from django.contrib.auth.models import User users = User.objects.all() for user in users: print(user.id) After that, you need to update the user_id in the JSON file to one of the numbers you have. Hope it helps!
if anyone is following this tutorial at the date of this comment and having trouble with the json file, you can: from django.contrib.auth.models import User and then modify the query a bit i did for p in posts_json: post = Post(title=p['title'], content=p['content'], author=User.objects.get(pk=p['user_id'])) post.save() django expects a user object instead of just the primary key, at least in django 4.2.1 which is what I'm using.
after loading the JSON file and saving every post in it I am getting a django.db.utils.IntegrityError: FOREIGN KEY constraint failed Error please help me with this issue
having error because of user_id value.. in database user_id for each user doesn't restore if you delete a user from database. I mean if you delete a user whose user_id was 2, if you create new user, then index 2 will not be assigned to any user, it will remain null and new_user id will be 3.
As pointed out: Whenever you delete and create a new user, primary key (pk) and user id (id) will continue and not be reset. Therefore, if you followed the tutorial, chances are high you don't have users with id 2 anymore. Hence, in posts.json you need to replace id 2 with a corresponding value. To find good id values you need to query the db. First, open a shell: python manage.py shell Second, in the Python shell run these commands to find all ids of all users: from django.contrib.auth.models import User users = User.objects.all() for user in users: print(user.id) Third, in posts.json replace the ids with valid ids from your db.
Hi Corey, thanks for the awesome video. Could you please help to teach how to control the length of post? I mean, just display part of them, and the rest of the post will be hidden since the post is long. Thanks!
Hi Mia! Since Corey won't respond, I will :) Just search truncatechars:200 on the internet and read the documentation. You can shorten posts by going to post.content, putting a | character, and typing truncatechars: with however many characters to display. You can add a read more below that links to post detail view.
Hello Corey, Great tutorials. In this tutorial you talk about something called "sub-template". Do you intend to make a tutorial about this topic? Thank you for all the knowledge you share this is goldmine 👌
That small heart attack you get when you test something and it doesn't work because you swear you followed the instructions but then it turns out Corey made the same mistake and it's fixed 2 minutes later.
I was unable to to add he posts.json using the import json... I have a Mid 2010 macbook pro laptop for what it's worth. I'd like to add those addiional profiles if possible.
I would like to inform you guys, instead of using get_query_set function, it should be get_queryset function (only one underscore '_') to successfully filter out the username in counting the number of post and display its posts. I don't know if it has something to do with the django versioning but, if you were using get_query_set function, it will not work. Sir Corey, please double check this. Thankss! Anyone correct if i'm wrong - 24:39
views.kwargs means : kwargs stands for keyword arguments. It is a lookups on dictionary in template. Referring to the function get_queryset inside {view.py .... username=self.kwargs.get('username'} file. Basically, it is asking the function get_queryset from view.py file to pass the username as an argument to it. view.kwargs.username Please Corey correct me if i'm wrong?
Thanks for this tutorial, I really enjoy the way you teach. But I have a problem with the if elif statement in home.html: throws this error :"TemplateSyntaxError at / Invalid block tag on line 32: 'elif', expected 'empty' or 'endfor'. Did you forget to register or load this tag?" I've bee through my code several times, even erased that part and started all over again, checked all my templates, but not working... any idea? thanks
It only blew my mind that the terms of the pagination because the filters is within and not actually greater and smaller? I got it , But it blew my mind
IntegrityError: FOREIGN KEY constraint failed hey, i am following along all the tutorials I am getting this error when I am hitting post.save() ..please help me it's only ading 1 post not 25 posts
Corey: "And Django makes this easy for us."
Me: "No, you make this easy for us :)"
nice
EXACTLY
exactly ... This is second time I going through corey sir videos and cant tell how easy django looks to me ... Thanks millions and zillions to corey sir ....
sooo true
I appreciate that you don't cut out when you do mistakes. I think it's important for beginners like me to see how you debug them and that even a professional like you can have a typo. Great videos. Thanks a lot!
Corey, there is a serious lack of quality Django tutorials out there. You are the only one pumping them out. Your series is incredible. I know you must be busy with so many project ideas already, but could you try extending this series into an advanced series next? I feel like I've learned a lot, but I would like to see you tinker around with the styling, or integrating new apps from Django Packages. I still don't feel fully confident in straying off the path you've laid out for us. I'm sure there are many others like me who would love to see more examples of customization now. I also looked into Mezzanine and Wagtail as CMS options, but again, there are very few tutorials on either of those platforms either. If you're ever looking for other ideas for further series, maybe one on using a CMS would be cool too :). You're the best man, and I'm going to forever point people looking to learn python, to your TH-cam.
I really enjoy how you not only show how to do things, but explain some of the processes behind the operations. If gives inspiration for other creative ideas and uses.
I really like it when Corey fids a mistake and fix it in seconds
I spend hours debugging an indentation
Oh I get stuck for hours on mistakes all the time. It just doesn’t seem that way in the videos because I’ll edit them out to save viewers time. But it definitely happens
For those that are having trouble with adding the extra posts from the posts.json, make sure you have the user id exists for id 1 and id 2 and you did not delete that user.
You can check with this command in the shell:
from django.contrib.auth.models import User
User.objects.get(id=1) # make sure this returns a user
User.objects.get(id=2) # make sure this returns a user
If no user is returned, make a new user with the :
User.objects.create_user(username='missing', email='missing@email.com', password='testing321', id=)
Hope this helps. Corey is the bomb.
TY!!!!!!!
it gives an error of TypeError: Profile.save() got an unexpected keyword argument 'force_insert'
I just edited the json file to go around that. For now
Corey. Your tutorials are premium quality. Anyone who says otherwise is just insane. I would love it if you can make a tutorial on how you learn(Especially going through documentation) because I don't know how you dig out some deep concepts but I would love to learn.
I would love to see a part 2 of this series
there is a Part 2 of this series. You are currently on Part 11
@@sarthakbhutani7413 Where can i find it?
please help
@@bentwite3093 hes joking
He means Season 2, lol
Probably the best tutorials on Django. Thanks-a-lot Corey, your content is not less than magic simple, detailed and obviously well explained. Thanks a-lot.
Big thumb up for all this tutorial ! It's really simple and clear to understand !
For those like me who are using django in version > 3, for the order_by in the get_queryset method, we need to do it before the filter call like :
>
Doing it the way he did in the tutorial worked fine for me. Django 4.2.3 🤷♂
Many times I refused to watch youtube tutorials because I think that they are useless.Today I watched your 11 videos continuously thank you I wish you will get a fair shot :)
Thanks!
This whole tutorial series is beast mode. It would be amazing if you could make a tutorial series on building a simple ML app. Something like the user gives some text input and the output is some sentiment score or something using scikit-learn, tensor flow, or pytorch. I would love to see how you would design the layout of that kind of website/web-app using Django.
I may have downloaded your c. 80 videos using youtube-dl but I'm still coming back to hit that like button, you're a saint to aspiring devs everywhere, keep it up!
You are the only person who can teach complicated stuff in most simplest way.
You making videos with an actual sense of spreading knowledge instead of buying likes and shares. One of the best Django tutorials available on internet. Thankyou from Germany.
Honestly Bro! I was doing your django series after that I took udemy course and realised that first two projects were real shit. Got only 2 to 3 different pieces of information from those udemy videos. Did your series again and understood the concepts in more clearity.
You are the only one out there carrying this quality stuff out there.
There is serious lack of quality stuff out there. It would be very helpful if you could make a course on DJANGO REST FRAMEWORK. Need guidance in that part.
Thank you for everything you are doing for us and we also make sure that we will watch all the ads and visit the pages as a support to this channel.
Love for your dog from India.
I'm 13 years old this is a best courses out there
@@Ayasir-lo3ir I am 5 years old and i think you are right
@@2024comingforyou I came straight off my dad's telescope and I'm already being genetically coded to learn from Corey Django's series.
I'm still in the womb and this is the best course I have ever watched on django
Thanks for this Corey :)
I tried to add a functionality to display all my post by visiting my profile page and clicking the profile picture. :) And successfully done it. Hehe So proud of myself. Thanks Corey sir. :) Just sharing. Hehe
YOOOOO!! My dream just came true. I like the video at 2.9k likes and made it 3k. Lets GO! I am just 14, but Corey Schafer you are amazing. Thank you so much for these videos and I am truly thankful that you are helping me further my programming journey. Thank you so much!
Nice! Thanks!
Simply the best Django tutorial you'll ever see on the internet
I generally use Adblock but just for your videos I specifically disable Adblock.. really thank you very much. !!..
Thanks!
I spent 2 hours figuring out it was supposed to be get_queryset() not get_query_set() and just when I planned on sharing this valuable info in comments, as I moved ahead of video to get the screen he explained this. Oh god.. don,t know if jumping ahead is good or bad anymore.:( But greatful for the content Corey. Almost everything I know in Django is because of you. Thank you.
one of the best teachers on youtube
1:40 getting data from json in shell
4:45 Paginator
8:45 using Paginator with class based view (CBV)
11:30 adding pagination UI in templates
23:00 filtered data Paginator with class based view (CBV) get_queryset
25:05 get_object_or_404
After overriding the save function in users/models.py I was unable to create new users. a fix to this was changing:
def save(self):
super().save()
to:
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
Hope it helps somebody! Thank you for everything that you do Corey. Keep it up. Your tutorial has restored my motivation!
thanks alot
Thanks A lot
Found a solution
The save method update solved creation of Profile Problem but new error generates saying default.jpg doesn't exists in media folder even though it exists. Tried even restating the development server . problem still persists
i had the same issue
Thankyou so much ,i realized i wasn't able to create user after reading your comment :D
For anyone stuck with pagination, yeah, this changed in newer versions of django. with Django 3.0 i get pagination on the users-post page, but the not post page itself. As corey said, this part of the code is not DRY(repeated code in both html files regarding actual pagination) but still they behave differently.
I did the same and it worked. But I always follow documentation before writing code.
Thank you so much for being patient with us, even without seeing us.
No words to say beyond other viewer comments! Creating personal Operations Manual step by step for a foundation of future projects thanks to you!
Ready to complete this and dive into other topics by you...!
You are love, Thank's for making Django easy for us, I will never able to complete my final year project(B.Sc) without your loving playlist of Django, it helped me a lot
Thank you for this tutorial, Corey. You're an angel. Hope you're doing fine wherever you are right now.
i really felt bad when you are saying sorry, we are all learning because of you, so you can make as many as u want
This is the best Heroku deployment tutorial ever!
Thanks for always showing the errors and how we can fix them. This is the best Django tutorial I have watched so far. :)
You don't know how many people appreciate your services
Awesome job sir! usually i'm on c# but this really makes appetite
32:55; No need to replace post with object, Doing this can induce an error.
btw Great Series, Great Work, Thanks a lot.
Mr Corey Schafer Thank You for these awesome , informative tutorials
The way this begins with importing JSON, is a neat touch. Django is amazing. Btw- Which beers improve your programming?
man you're just Amazing! Really your courses are better than those Udemy paid ones
Me: Watching corey's video
Corey: I know that this is confusing especially when you're not actually doing it
AMAZING AND CLEAR TUTORIALS WELL DONE COREY!!!
I found this tutorial to be pretty helpful, thank you. I was wondering if you will do another part on many-to-many relationships for models particularly in relation to CRUD. Maybe for example for your blogs, you can have tags.
2 and a half hours later to finally get it working and my head is about to burst! haha
Hi corey, this entier tutorial is incridible and understandable , but can you extend this series a bit and let us know how to implement chat feature so that users can chat as well after logging in
To anyone getting an error when creating posts:
I have noticed there is a small error maybe due to changing of Django versions
When creating posts, providing author_id = post['user_id'] gives an error.
Just do a user = User.objects.get(id=post['user_id']) before making the post and instead of author_id, do author = user.
Of course you will need to import User model as explained in previous videos.
importing User model...
from django.contrib.auth.models import User
right?
but still shown error : User matching query does not exist.
@@alexkoshy1999 did u solve bro..i am still stuck in this problem
@@dihajnasah8077 no bro...i leaved it..and manually posted some gibberish post
@@alexkoshy1999 No bro no need to add gibberish post
its not good practice
this is how i identify my users id from shell , because at the first i have created some users and deleted for some resons thats why i has been facing this issue
here is the shell code which i have used
>>> user = User.objects.all()
>>> user
>>> user = user.first()
>>> user
>>> user.id
9
>>> user = User.objects.all()
>>> user
>>> user = User.objects.get(username='NewUser')
>>> user
>>> user.id
10
>>>
i hope this would help
Thank you so much for this video!!!
I was stuck on this problem from a long time and was thinking to apply concept of Lazy Loading, but this solves my problem.
Thankyou!
Loving the series. Thanks Corey!
Great lecture!! I experienced some error following along of the video, please refer to the code above if you experience error as well
Thank you 🙏 -this JSON thing is extremely helpful
I would love to see you do a flask api tutorial
great video! And as others have mentioned, it's nice to see how you solve errors as well.
I would pay around 20$ for an advanced django tutorial from Corey Schafer and I NEVER PAY for coding material.
We want E-Commerce Tutorial :)
I love that series, actually I've learned most of my Django skills here;)
Is there a chance that you'll make one on cookies handling/ session storing?
At 22:00 in the end of paginations.
I did some changes on the pagination buttons I hope you like it:
{% if is_paginated %}
{% if page_obj.has_previous %}
First
Previous
{% else %}
First
Previous
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
{{ num }}
{% elif not page_obj.has_previous %}
{% if num = page_obj.number|add:'-2' %}
{{ num }}
{% endif %}
{% elif num >= page_obj.number|add:'-1' and num
Hi Marcelo, this part is not right I'm afraid
{% else %}
First
Previous
{% endif %}
because it will be visible even if there isn't a previous page, which should not be the case.
same with this:
{% else %}
Next
Last
{% endif %}
it will appear even when there isn't a next page. Also, their href attributes are '#', meaning they will not change to a particular page
@@shemmuthanga6352 To be honest I don't know exactly what's going on in that piece of code, but anyway, here's what i meant with this code:
I wanted the buttons to appear even if there is no previous page before the first one and even if there is no later page after the last one.
And to avoid confusion I changed the colors by changing the class from "btn btn-outline-info mb-4" to "btn btn-outline-secondary mb-4". Try it in your django code see what you think :P
Hey Corey, maybe in the next tutorial you can show us how to use django-cities feature for the registration form?
Once again, a great video of yours. Congrats!
Hi Corey,
Thank you for this great tutorial. I have learned a lot.
@4:08 well, could you please please show how to add images to posts, I was thinking about django-ckeditor, or maybe just a simple form one image per post plus thumbnail in the listview on home.html along with search section would spice up the blog even further. Thank you for this tutorial, it's great!
I need this as well
thanks corey.. you are the pure sole.. Someday I am really going to meet you.
Love these tutorials man
Corey, if you could bottle this and sell it... but then, you're probably already rich from working as a programmer. It would be pretty cool if you could find someone who knows as much as you do--but about other computer topics, then teach them how to plan a recording session. You could sell it as a documentation service to companies with products like Django and Git. Anthony Sherrill says you don't edit your mistakes out, but the vast majority of them appear to be planned mistakes--not mistakes at all. I was using another set of tutorials, but that guy wasted oodles of time just chit chatting. I love the way you plan, follow your plan, and get to the next point.
I perform a lot of edits on my videos. I'll leave mistakes in if I feel like they have some value to the viewer, but if they are mistakes that won't give any value then I try to edit them out.
Corey, you are good.
Thank you for these wonderful videos!
I have question if anyone can answer, how to get familiar with all these methods. We can't remember all these methods right? Where to check for them if we forgot ? Great Series Corey. I am learning more from you than my university lecturers. And thank you!! AS Soon AS I will get my first job, I am gonna contribute to your channel through patreon.
35:35 "You won't believe these clickbait titles!" -- thought that was pretty funny.
Thank you Corey!
Corey Schafer
made 2 mistakes in one video. It is 8th wonder to me. really, It is more rare than human goes to the moon. I'm really impressed.
I have been watching Corey's videos more or less all day, but this is the first time he has made a misstate :D (34:00 --> )
Mr. Schafer! You are a boss!!!!
That is all :)
Thanks a lot for your lessons!
To any of you who get an error of django.db.utils.IntegrityError: FOREIGN KEY constraint failed.
That can be happening for some reasons (most of them are detailed in the comments), but I didn't see any comment addressing the problem I had.
Because I played with the creation of the user a little bit, my user_ids weren't 1, 2, and 3.
However, the JSON file contains user_id of 1, 2, and 3, so I basically tried to upload a post to an unexisting user.
To check the user_id of each user you can do the following:
from django.contrib.auth.models import User
users = User.objects.all()
for user in users:
print(user.id)
After that, you need to update the user_id in the JSON file to one of the numbers you have.
Hope it helps!
THANK you!
thanks
this is the best toturial
*Corey:* Apologizes for making two small mistakes.
*Me who makes 10000+ typos even after watching his videos:* um....i-it's totally okay mate...
Hi Corey,
Great videos. I'm learning a lot here
Could you also teach how to show post's excerpts instead of the full post on the home page?
smashed the liked like hulk and subscribed, excellent tutorial my friend many thanks! regards from Peru!
if anyone is following this tutorial at the date of this comment and having trouble with the json file, you can:
from django.contrib.auth.models import User
and then modify the query a bit
i did
for p in posts_json:
post = Post(title=p['title'], content=p['content'], author=User.objects.get(pk=p['user_id']))
post.save()
django expects a user object instead of just the primary key, at least in django 4.2.1 which is what I'm using.
Thank you, sir 🎩
Thank you!! this fixed my issue
after loading the JSON file and saving every post in it I am getting a django.db.utils.IntegrityError: FOREIGN KEY constraint failed Error
please help me with this issue
same error
+1
having error because of user_id value.. in database user_id for each user doesn't restore if you delete a user from database. I mean if you delete a user whose user_id was 2, if you create new user, then index 2 will not be assigned to any user, it will remain null and new_user id will be 3.
As pointed out: Whenever you delete and create a new user, primary key (pk) and user id (id) will continue and not be reset. Therefore, if you followed the tutorial, chances are high you don't have users with id 2 anymore. Hence, in posts.json you need to replace id 2 with a corresponding value. To find good id values you need to query the db.
First, open a shell:
python manage.py shell
Second, in the Python shell run these commands to find all ids of all users:
from django.contrib.auth.models import User
users = User.objects.all()
for user in users:
print(user.id)
Third, in posts.json replace the ids with valid ids from your db.
@@mahaheruka4966 Thank you for this .... you provided the solution for me...
Hi corey, i am getting TypeError: 'dict' object is not callable error while calling the saving function.
Can you please help?
Thanks a lot for these video.
Hi Corey, thanks for the awesome video. Could you please help to teach how to control the length of post? I mean, just display part of them, and the rest of the post will be hidden since the post is long. Thanks!
Hi Mia! Since Corey won't respond, I will :) Just search truncatechars:200 on the internet and read the documentation. You can shorten posts by going to post.content, putting a | character, and typing truncatechars: with however many characters to display. You can add a read more below that links to post detail view.
Hey, am getting anl template syntax error at line 24, time: 20:02.
Could not parse remainder '|' from 'page_obj.number|'.
Please help 🙏 🙏🙏🙏🙏🙏🙏🙏🙏
in the elif line make sure that the 'add' comes directly after | so it looks something like this '|add' this helped me
Hello Corey,
Great tutorials.
In this tutorial you talk about something called "sub-template".
Do you intend to make a tutorial about this topic?
Thank you for all the knowledge you share this is goldmine 👌
you are the BEST of the BEST. thank youuuuuu:))
That small heart attack you get when you test something and it doesn't work because you swear you followed the instructions but then it turns out Corey made the same mistake and it's fixed 2 minutes later.
Hello? How would i go about inserting new posts using the shell in windows? Mine is showing that it's running perfectly but no post is added
Corey, first of all thanks for the great content. 👍
I wanted to ask, if you think this would be a good place to show how to use Fixtures in Django?
You are awesome!!
I was unable to to add he posts.json using the import json... I have a Mid 2010 macbook pro laptop for what it's worth. I'd like to add those addiional profiles if possible.
Awesome bro thanks best video ever.....
Great tutorials! Thanks
I would like to inform you guys, instead of using get_query_set function, it should be get_queryset function (only one underscore '_') to successfully filter out the username in counting the number of post and display its posts. I don't know if it has something to do with the django versioning but, if you were using get_query_set function, it will not work. Sir Corey, please double check this. Thankss! Anyone correct if i'm wrong - 24:39
You’re right. I fixed it at the 34:00 minute mark
Thanks for that because without the fix it was returning all posts.
Corey, could you elaborate on the variable {{ views.kwargs.username }} in the user_post.html file? What is 'views.kwargs' part ?
views.kwargs means :
kwargs stands for keyword arguments.
It is a lookups on dictionary in template.
Referring to the function get_queryset inside
{view.py .... username=self.kwargs.get('username'} file.
Basically, it is asking the function get_queryset from view.py file to pass the username as an argument to it.
view.kwargs.username
Please Corey correct me if i'm wrong?
Shouldn't it be views.py rather than view.py? @@Canda-fh4xc
The answer probably is this: stackoverflow.com/questions/45098826/access-kwargs-from-a-url-in-a-django-template
@@fangle0121 This link was helpful
awesome tutorial!
lmaooo F for those who bought couses from udemy...love ya corey youre so great! :D
Thanks for this tutorial, I really enjoy the way you teach.
But I have a problem with the if elif statement in home.html: throws this error :"TemplateSyntaxError at /
Invalid block tag on line 32: 'elif', expected 'empty' or 'endfor'. Did you forget to register or load this tag?"
I've bee through my code several times, even erased that part and started all over again, checked all my templates, but not working...
any idea? thanks
hey did you find a workaround/solution for this?
Did you find the solution? Anyone?
It only blew my mind that the terms of the pagination because the filters is within and not actually greater and smaller?
I got it , But it blew my mind
At 28:40, remember to add the forward slash in the end of the string. I did not and ran in to some 404-issues for certain users (not all).
I noticed, that if you are doing this in command prompt for windows users, @ 2:25 you need to tab twice!
Also, I noticed if you make errors as typing this, even fixed it wont work, you have to start over from command prompt and start from import json
IntegrityError: FOREIGN KEY constraint failed
hey, i am following along all the tutorials I am getting this error when I am hitting post.save() ..please help me it's only ading 1 post not 25 posts
Wonderful