Python Django Tutorial: Full-Featured Web App Part 11 - Pagination

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 พ.ย. 2024

ความคิดเห็น • 537

  • @riturajjain5301
    @riturajjain5301 5 ปีที่แล้ว +440

    Corey: "And Django makes this easy for us."
    Me: "No, you make this easy for us :)"

    • @victoralarcontorres8629
      @victoralarcontorres8629 5 ปีที่แล้ว +7

      nice

    • @humayunkabir7925
      @humayunkabir7925 4 ปีที่แล้ว +4

      EXACTLY

    • @bharatjha
      @bharatjha 4 ปีที่แล้ว +3

      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 ....

    • @markothedev5773
      @markothedev5773 4 ปีที่แล้ว

      sooo true

  • @AnthonySherrill
    @AnthonySherrill 5 ปีที่แล้ว +143

    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!

  • @idugi
    @idugi 5 ปีที่แล้ว +225

    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.

  • @SliderHavoc
    @SliderHavoc 5 ปีที่แล้ว +61

    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.

  • @AymenLagha
    @AymenLagha 5 ปีที่แล้ว +22

    I really like it when Corey fids a mistake and fix it in seconds
    I spend hours debugging an indentation

    • @coreyms
      @coreyms  5 ปีที่แล้ว +58

      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

  • @michaelng1049
    @michaelng1049 6 ปีที่แล้ว +10

    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.

    • @jhodalouiseembodo4586
      @jhodalouiseembodo4586 5 ปีที่แล้ว

      TY!!!!!!!

    • @tanjaa9092
      @tanjaa9092 11 หลายเดือนก่อน

      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

  • @mrchi6611
    @mrchi6611 4 ปีที่แล้ว +7

    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.

  • @bentwite3093
    @bentwite3093 5 ปีที่แล้ว +41

    I would love to see a part 2 of this series

    • @sarthakbhutani7413
      @sarthakbhutani7413 4 ปีที่แล้ว +7

      there is a Part 2 of this series. You are currently on Part 11

    • @bentwite3093
      @bentwite3093 4 ปีที่แล้ว +1

      @@sarthakbhutani7413 Where can i find it?
      please help

    • @pavankabadi9359
      @pavankabadi9359 4 ปีที่แล้ว +2

      @@bentwite3093 hes joking

    • @rubel1477
      @rubel1477 3 ปีที่แล้ว +1

      He means Season 2, lol

  • @ankitpandey4602
    @ankitpandey4602 5 ปีที่แล้ว +22

    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.

  • @nicolasroosz
    @nicolasroosz 4 ปีที่แล้ว +4

    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 :
    >

    • @eamonburns9597
      @eamonburns9597 ปีที่แล้ว

      Doing it the way he did in the tutorial worked fine for me. Django 4.2.3 🤷‍♂

  • @berkayyalcn5149
    @berkayyalcn5149 5 ปีที่แล้ว +4

    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 :)

    • @coreyms
      @coreyms  5 ปีที่แล้ว +1

      Thanks!

  • @michaelcortes39
    @michaelcortes39 5 ปีที่แล้ว +4

    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.

  • @robmenon1922
    @robmenon1922 4 ปีที่แล้ว +2

    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!

  • @ritvikdayal3735
    @ritvikdayal3735 4 ปีที่แล้ว +2

    You are the only person who can teach complicated stuff in most simplest way.

  • @paramveermarwah862
    @paramveermarwah862 2 ปีที่แล้ว

    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.

  • @carekaro007
    @carekaro007 4 ปีที่แล้ว +15

    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.

    • @Ayasir-lo3ir
      @Ayasir-lo3ir 4 ปีที่แล้ว +1

      I'm 13 years old this is a best courses out there

    • @2024comingforyou
      @2024comingforyou 3 ปีที่แล้ว

      @@Ayasir-lo3ir I am 5 years old and i think you are right

    • @angelicking2890
      @angelicking2890 2 ปีที่แล้ว +1

      @@2024comingforyou I came straight off my dad's telescope and I'm already being genetically coded to learn from Corey Django's series.

    • @parthmadan671
      @parthmadan671 ปีที่แล้ว +1

      I'm still in the womb and this is the best course I have ever watched on django

  • @ivancarcallas5510
    @ivancarcallas5510 4 ปีที่แล้ว +9

    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

  • @pavankabadi9359
    @pavankabadi9359 4 ปีที่แล้ว +3

    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!

    • @coreyms
      @coreyms  4 ปีที่แล้ว

      Nice! Thanks!

  • @oyediranthanniquowiyyu5827
    @oyediranthanniquowiyyu5827 3 ปีที่แล้ว

    Simply the best Django tutorial you'll ever see on the internet

  • @srinadhk8071
    @srinadhk8071 5 ปีที่แล้ว +2

    I generally use Adblock but just for your videos I specifically disable Adblock.. really thank you very much. !!..

    • @coreyms
      @coreyms  5 ปีที่แล้ว

      Thanks!

  • @shashikalaraju5769
    @shashikalaraju5769 3 ปีที่แล้ว +2

    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.

  • @aliozreil23
    @aliozreil23 4 ปีที่แล้ว +1

    one of the best teachers on youtube

  • @junecnol79
    @junecnol79 4 ปีที่แล้ว +10

    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

  • @LegendHxz
    @LegendHxz 5 ปีที่แล้ว +17

    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!

    • @abdishakuraliisse3214
      @abdishakuraliisse3214 5 ปีที่แล้ว

      thanks alot

    • @shreshtharora
      @shreshtharora 5 ปีที่แล้ว

      Thanks A lot
      Found a solution

    • @shreshtharora
      @shreshtharora 5 ปีที่แล้ว

      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

    • @DannyhEvolution
      @DannyhEvolution 5 ปีที่แล้ว

      i had the same issue

    • @glambyha2263
      @glambyha2263 4 ปีที่แล้ว

      Thankyou so much ,i realized i wasn't able to create user after reading your comment :D

  • @thomasworkersen2972
    @thomasworkersen2972 3 ปีที่แล้ว +1

    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.

    • @parvejshahlabib9167
      @parvejshahlabib9167 2 ปีที่แล้ว

      I did the same and it worked. But I always follow documentation before writing code.

  • @lc5242
    @lc5242 4 ปีที่แล้ว

    Thank you so much for being patient with us, even without seeing us.

  • @davidblair1671
    @davidblair1671 4 ปีที่แล้ว

    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...!

  • @k.m.emonahmed4938
    @k.m.emonahmed4938 4 ปีที่แล้ว

    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

  • @judithtorres1767
    @judithtorres1767 2 ปีที่แล้ว

    Thank you for this tutorial, Corey. You're an angel. Hope you're doing fine wherever you are right now.

  • @thesciencethatilove8959
    @thesciencethatilove8959 4 ปีที่แล้ว +2

    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

  • @jonasc8569
    @jonasc8569 3 ปีที่แล้ว

    This is the best Heroku deployment tutorial ever!

  • @YasBars
    @YasBars 4 ปีที่แล้ว

    Thanks for always showing the errors and how we can fix them. This is the best Django tutorial I have watched so far. :)

  • @oli2034
    @oli2034 5 ปีที่แล้ว +3

    You don't know how many people appreciate your services

  • @haerrymarcel
    @haerrymarcel ปีที่แล้ว

    Awesome job sir! usually i'm on c# but this really makes appetite

  • @abishvijayan76
    @abishvijayan76 5 ปีที่แล้ว +1

    32:55; No need to replace post with object, Doing this can induce an error.
    btw Great Series, Great Work, Thanks a lot.

  • @drhastings
    @drhastings 4 ปีที่แล้ว

    Mr Corey Schafer Thank You for these awesome , informative tutorials

  • @dpapa2175
    @dpapa2175 4 ปีที่แล้ว +2

    The way this begins with importing JSON, is a neat touch. Django is amazing. Btw- Which beers improve your programming?

  • @randomuser5780
    @randomuser5780 3 ปีที่แล้ว

    man you're just Amazing! Really your courses are better than those Udemy paid ones

  • @sarveshgandhi4588
    @sarveshgandhi4588 4 ปีที่แล้ว +5

    Me: Watching corey's video
    Corey: I know that this is confusing especially when you're not actually doing it

  • @moebazzi8412
    @moebazzi8412 6 ปีที่แล้ว +3

    AMAZING AND CLEAR TUTORIALS WELL DONE COREY!!!

  • @2hourgameplay2minutereview52
    @2hourgameplay2minutereview52 2 ปีที่แล้ว +1

    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.

  • @giv123
    @giv123 4 ปีที่แล้ว +1

    2 and a half hours later to finally get it working and my head is about to burst! haha

  • @miraihibino2213
    @miraihibino2213 4 ปีที่แล้ว +2

    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

  • @waiitwhaat
    @waiitwhaat ปีที่แล้ว +6

    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
      @alexkoshy1999 ปีที่แล้ว +1

      importing User model...
      from django.contrib.auth.models import User
      right?

    • @alexkoshy1999
      @alexkoshy1999 ปีที่แล้ว

      but still shown error : User matching query does not exist.

    • @dihajnasah8077
      @dihajnasah8077 ปีที่แล้ว

      @@alexkoshy1999 did u solve bro..i am still stuck in this problem

    • @alexkoshy1999
      @alexkoshy1999 ปีที่แล้ว

      @@dihajnasah8077 no bro...i leaved it..and manually posted some gibberish post

    • @mightyprogrammer2899
      @mightyprogrammer2899 ปีที่แล้ว

      @@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

  • @abhishekk1231
    @abhishekk1231 4 ปีที่แล้ว +1

    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!

  • @paridhigupta2747
    @paridhigupta2747 2 ปีที่แล้ว

    Loving the series. Thanks Corey!

  • @lingxu3570
    @lingxu3570 4 ปีที่แล้ว

    Great lecture!! I experienced some error following along of the video, please refer to the code above if you experience error as well

  • @shazkingdom1702
    @shazkingdom1702 5 ปีที่แล้ว +2

    Thank you 🙏 -this JSON thing is extremely helpful

  • @miguelmyers9546
    @miguelmyers9546 6 ปีที่แล้ว +3

    I would love to see you do a flask api tutorial

  • @MagnusAnand
    @MagnusAnand 5 ปีที่แล้ว +1

    great video! And as others have mentioned, it's nice to see how you solve errors as well.

  • @jorgegonzaloalfaro5378
    @jorgegonzaloalfaro5378 3 ปีที่แล้ว

    I would pay around 20$ for an advanced django tutorial from Corey Schafer and I NEVER PAY for coding material.

  • @mohammadmasbahuddin2812
    @mohammadmasbahuddin2812 5 ปีที่แล้ว +3

    We want E-Commerce Tutorial :)

  • @cudanakiju0
    @cudanakiju0 4 ปีที่แล้ว +2

    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?

  • @1000marcelo1000
    @1000marcelo1000 3 ปีที่แล้ว +3

    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

    • @shemmuthanga6352
      @shemmuthanga6352 3 ปีที่แล้ว +1

      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

    • @1000marcelo1000
      @1000marcelo1000 3 ปีที่แล้ว +2

      ​@@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.

    • @1000marcelo1000
      @1000marcelo1000 3 ปีที่แล้ว +2

      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

  • @nmddiez6374
    @nmddiez6374 5 ปีที่แล้ว +2

    Hey Corey, maybe in the next tutorial you can show us how to use django-cities feature for the registration form?

  • @paulohsgoes1959
    @paulohsgoes1959 4 ปีที่แล้ว

    Once again, a great video of yours. Congrats!

  • @jaysonmartinez7026
    @jaysonmartinez7026 4 ปีที่แล้ว

    Hi Corey,
    Thank you for this great tutorial. I have learned a lot.

  • @boryskuczkowski
    @boryskuczkowski 6 ปีที่แล้ว +10

    @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!

  • @codenaman
    @codenaman 4 ปีที่แล้ว

    thanks corey.. you are the pure sole.. Someday I am really going to meet you.

  • @guitardave77
    @guitardave77 3 ปีที่แล้ว

    Love these tutorials man

  • @gregtuve1109
    @gregtuve1109 5 ปีที่แล้ว

    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.

    • @coreyms
      @coreyms  5 ปีที่แล้ว

      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.

  • @ai.201
    @ai.201 4 ปีที่แล้ว +1

    Corey, you are good.

  • @FreedomOverSafety
    @FreedomOverSafety 4 ปีที่แล้ว +1

    Thank you for these wonderful videos!

  • @shreyadeo315
    @shreyadeo315 3 ปีที่แล้ว

    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.

  • @adamploof3528
    @adamploof3528 4 ปีที่แล้ว +5

    35:35 "You won't believe these clickbait titles!" -- thought that was pretty funny.

  • @zommanderz3605
    @zommanderz3605 4 ปีที่แล้ว +2

    Thank you Corey!

  • @mahathirmohammad8635
    @mahathirmohammad8635 3 ปีที่แล้ว

    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.

  • @blackkissi
    @blackkissi 4 ปีที่แล้ว +2

    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 --> )

  • @JasonPavlas
    @JasonPavlas 2 ปีที่แล้ว

    Mr. Schafer! You are a boss!!!!
    That is all :)

  • @MaximRyzhenkov
    @MaximRyzhenkov 4 ปีที่แล้ว +1

    Thanks a lot for your lessons!

  • @yehonatan3000
    @yehonatan3000 ปีที่แล้ว +2

    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!

  • @ahmad-ali14
    @ahmad-ali14 5 ปีที่แล้ว +1

    this is the best toturial

  • @LizzyHanamiya
    @LizzyHanamiya 4 ปีที่แล้ว +9

    *Corey:* Apologizes for making two small mistakes.
    *Me who makes 10000+ typos even after watching his videos:* um....i-it's totally okay mate...

  • @andysondur
    @andysondur 3 ปีที่แล้ว

    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?

  • @investradelearn
    @investradelearn 4 ปีที่แล้ว +2

    smashed the liked like hulk and subscribed, excellent tutorial my friend many thanks! regards from Peru!

  • @daon23
    @daon23 ปีที่แล้ว +3

    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.

    • @verilogmusic
      @verilogmusic ปีที่แล้ว

      Thank you, sir 🎩

    • @paulnelson8009
      @paulnelson8009 8 หลายเดือนก่อน

      Thank you!! this fixed my issue

  • @maninandadeepmedicharla6213
    @maninandadeepmedicharla6213 4 ปีที่แล้ว +11

    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

    • @afonsosalbrecht
      @afonsosalbrecht 4 ปีที่แล้ว

      same error

    • @shivak6696
      @shivak6696 4 ปีที่แล้ว

      +1

    • @Reddithours1126
      @Reddithours1126 4 ปีที่แล้ว +7

      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.

    • @mahaheruka4966
      @mahaheruka4966 4 ปีที่แล้ว +14

      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.

    • @Whack777
      @Whack777 4 ปีที่แล้ว +2

      @@mahaheruka4966 Thank you for this .... you provided the solution for me...

  • @bennykhatri1156
    @bennykhatri1156 4 ปีที่แล้ว +2

    Hi corey, i am getting TypeError: 'dict' object is not callable error while calling the saving function.
    Can you please help?

  • @vatsa1732
    @vatsa1732 5 ปีที่แล้ว +1

    Thanks a lot for these video.

  • @Mia-vz6yt
    @Mia-vz6yt 5 ปีที่แล้ว +1

    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!

    • @vladusa
      @vladusa 4 ปีที่แล้ว +1

      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.

  • @eugenetuhaisr6829
    @eugenetuhaisr6829 9 หลายเดือนก่อน +3

    Hey, am getting anl template syntax error at line 24, time: 20:02.
    Could not parse remainder '|' from 'page_obj.number|'.
    Please help 🙏 🙏🙏🙏🙏🙏🙏🙏🙏

    • @TopPlayer17535
      @TopPlayer17535 6 หลายเดือนก่อน +1

      in the elif line make sure that the 'add' comes directly after | so it looks something like this '|add' this helped me

  • @actionphotopassion5082
    @actionphotopassion5082 4 ปีที่แล้ว

    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 👌

  • @alexanderten5497
    @alexanderten5497 6 ปีที่แล้ว +2

    you are the BEST of the BEST. thank youuuuuu:))

  • @r31n0ut
    @r31n0ut 11 หลายเดือนก่อน

    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.

  • @lukengirubiu6492
    @lukengirubiu6492 3 ปีที่แล้ว +1

    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

  • @ArseniyIvanov_The_Jabbson
    @ArseniyIvanov_The_Jabbson 5 ปีที่แล้ว

    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?

  • @user-tx1ip
    @user-tx1ip 6 ปีที่แล้ว +3

    You are awesome!!

  • @robertschmidt8624
    @robertschmidt8624 ปีที่แล้ว +1

    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.

  • @shashanksharmadon4295
    @shashanksharmadon4295 4 ปีที่แล้ว

    Awesome bro thanks best video ever.....

  • @hasan8267
    @hasan8267 5 ปีที่แล้ว

    Great tutorials! Thanks

  • @Yowmshot
    @Yowmshot 5 ปีที่แล้ว +2

    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

    • @coreyms
      @coreyms  5 ปีที่แล้ว

      You’re right. I fixed it at the 34:00 minute mark

    • @javaguitarist
      @javaguitarist 4 ปีที่แล้ว

      Thanks for that because without the fix it was returning all posts.

  • @headlikeahole6548
    @headlikeahole6548 6 ปีที่แล้ว +8

    Corey, could you elaborate on the variable {{ views.kwargs.username }} in the user_post.html file? What is 'views.kwargs' part ?

    • @Canda-fh4xc
      @Canda-fh4xc 5 ปีที่แล้ว +3

      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?

    • @fangle0121
      @fangle0121 5 ปีที่แล้ว

      Shouldn't it be views.py rather than view.py? @@Canda-fh4xc

    • @fangle0121
      @fangle0121 5 ปีที่แล้ว +1

      The answer probably is this: stackoverflow.com/questions/45098826/access-kwargs-from-a-url-in-a-django-template

    • @ebukagnwa9834
      @ebukagnwa9834 3 ปีที่แล้ว

      @@fangle0121 This link was helpful

  • @mehmetyuksel3217
    @mehmetyuksel3217 2 ปีที่แล้ว

    awesome tutorial!

  • @glaceondev4149
    @glaceondev4149 4 ปีที่แล้ว

    lmaooo F for those who bought couses from udemy...love ya corey youre so great! :D

  • @haenleinjane9594
    @haenleinjane9594 3 ปีที่แล้ว +2

    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

    • @GDLAPROD
      @GDLAPROD 2 ปีที่แล้ว +1

      hey did you find a workaround/solution for this?

    • @junhuama68
      @junhuama68 4 หลายเดือนก่อน

      Did you find the solution? Anyone?

  • @naveshelly2577
    @naveshelly2577 4 ปีที่แล้ว

    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

  • @Schmidt3k
    @Schmidt3k 4 ปีที่แล้ว

    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).

  • @inodecode7600
    @inodecode7600 4 ปีที่แล้ว

    I noticed, that if you are doing this in command prompt for windows users, @ 2:25 you need to tab twice!

    • @inodecode7600
      @inodecode7600 4 ปีที่แล้ว

      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

  • @muzamilmemon9690
    @muzamilmemon9690 2 ปีที่แล้ว +1

    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

  • @manikndn8
    @manikndn8 6 ปีที่แล้ว +2

    Wonderful