Django Tutorial #11 - Model Methods

Поделиться
HTML-код
  • Опубликовано: 11 янв 2025

Комментарии • 54

  • @brandonlozano8114
    @brandonlozano8114 4 года назад +5

    By far some of the best tutorials I've ever seen - you explain everything clearly and concisely. Thank you!!

  • @jignathaker4673
    @jignathaker4673 4 года назад +3

    You can add
    {{ article.body|slice:":100" }} {{ '...' }}
    in your article_list.html in place of {{ article.body }}

  • @irfanharun
    @irfanharun 4 года назад +1

    i learnt django about 6 months ago using your videos. i was stuck at model method, cam back to your video and it all made sense instantly.. thanks

  • @mopar4881
    @mopar4881 3 года назад

    i dont know who even has the audacity to dislike this mans videos, these are the most helpful videos with the best way of delivering the information. Hats off to you Net Ninja, you are the best!

  • @iancarr3923
    @iancarr3923 6 лет назад +1

    Having seen other Django videos it has been very useful to pick up new bits of technique in yours, e.g. templates in the "root" app, Model methods etc. Many thanks

  • @mdrafiakhtar577
    @mdrafiakhtar577 7 лет назад +4

    2:24 Small correction. You said putting [:50] will extract the characters from 0 to 50, but actually it will extract from 0 to 49. That's how you'll get the first 50 characters.

  • @dbassett74
    @dbassett74 4 года назад

    I REALLY love this series. I like the short focused segments. Thanks!

  • @rushas
    @rushas 5 лет назад +1

    Was looking for a simple model method in use and I got one.
    This is great!
    Thanks for the content.

  • @jamescope2093
    @jamescope2093 4 года назад +1

    For anyone having trouble, make sure to use square brackets [:50] and not round brackets () on the slice/truncate

  • @vijay.e4228
    @vijay.e4228 3 года назад +1

    i think the less dislikes show how this content is good is it

  • @ctd100
    @ctd100 4 года назад +1

    Hey Shaun! Love your tutorials. Really hope you will do a series on connecting a django backend to a flutter app

  • @umaretiya
    @umaretiya 2 года назад

    Very nice explaining and best for learning

  • @joebegleycodes1347
    @joebegleycodes1347 6 лет назад

    There is so much functionality in this framework!

  • @kouyajia496
    @kouyajia496 7 лет назад +1

    Loving this. Looking forward to more.

  • @skalippanbalippan6972
    @skalippanbalippan6972 7 лет назад +5

    instead of snippet function we could use {{post.body|truncatewords:30}}

    • @dustbinsavesyou8283
      @dustbinsavesyou8283 7 лет назад +2

      no thanks
      I'm better off with the easy thing

    • @patrickknows2296
      @patrickknows2296 3 года назад +1

      @@dustbinsavesyou8283 yes true. Some dude just want to complicate easy things that works!

    • @kalilove4013
      @kalilove4013 2 года назад

      thanks so much....

  • @jlassichamseddine9660
    @jlassichamseddine9660 4 года назад

    {{post.content|slice:":200" }} bro you can use the slice method without the need of creating a new function by the way i like the way you deliver the infos it's so easy and wonderful thank you for everything

  • @KevinTempelx
    @KevinTempelx 4 года назад

    Question, is the snippet method you used a part of python or django or was it just a method you arbitrarily made?

  • @moe9647
    @moe9647 5 лет назад

    amazing approach with your teaching.

  • @azzedinetoufir3
    @azzedinetoufir3 4 года назад

    Well done and thanks for the video

  • @KevinTempelx
    @KevinTempelx 4 года назад

    Can someone explain to me what the point of putting the for loop variable article inside the div class? Thanks much!

  • @shahnooralamnilim891
    @shahnooralamnilim891 7 лет назад +3

    I also done this but its not work for me........ any reason?
    def snippet(self):
    return self.body[:50]

    • @Nomadvicky
      @Nomadvicky 6 лет назад

      I am facing the same issue.
      class Article(models.Model):
      body = '' #pylyint : unsubscriptable
      title = models.CharField(max_length=100)
      slug = models.SlugField()
      body = models.TextField()
      date = models.DateTimeField(auto_now=True)
      # add in thumbnail later
      # add author alter
      def __str__(self):
      return self.title
      def snippet(self):
      return self.body[0:100] + '...'

    • @Nomadvicky
      @Nomadvicky 6 лет назад +1

      Please also check you code indentation

    • @prod.radical720
      @prod.radical720 6 лет назад +1

      same problem, self.body is unsubscriptable

    • @ShubhamJaiswal-ng1mv
      @ShubhamJaiswal-ng1mv 4 года назад

      bro make sure that ur code is in next line n follows the proper indentation

  • @Genrobi
    @Genrobi 5 лет назад

    why is there no need to call the snippet function? Is it just how template tags work?

  • @kivanc5789
    @kivanc5789 2 года назад

    What is the name of your Atom font Shaun?

  • @JollyAZ
    @JollyAZ 4 года назад

    3:32 amen brother

  • @naheliegend5222
    @naheliegend5222 3 года назад

    Why can we leave out the brackets while calling this method? Thought @property would do this.

  • @yepan8321
    @yepan8321 4 года назад

    Hi, i have a quest. When you create a new article by admin page, where does it store??

    • @hydra1346
      @hydra1346 4 года назад

      in your db.sqlite3

  • @richardc9325
    @richardc9325 6 лет назад +1

    I added the … string without even looking at the video, it came naturally.

  • @Vromvrom01
    @Vromvrom01 4 года назад

    Why not need to call shippet function ?

  • @mohamedHANDAOUI
    @mohamedHANDAOUI 7 лет назад +1

    amazing video, thanks a lot,
    Is it possible to make a tutorial about GraphQL in the future? I think it's really interesting

    • @NetNinja
      @NetNinja  7 лет назад +4

      Thanks :). GraphQL is definitely on the radar for before the end of this year :)

  • @saadhameed3279
    @saadhameed3279 4 года назад +2

    Hey, i have done the same but instead of getting short line of 50 characters i 've got nothing just name and date this body line is disappeared,please help

  • @sbizay
    @sbizay 6 лет назад +1

    not working for me..

  • @aliijaz7551
    @aliijaz7551 4 года назад

    many are facing problem that is beacuse of indentation
    class Article(models.Model):
    title = models.CharField(max_length=100)
    slug = models.SlugField(max_length=50)
    body = models.TextField()
    date = models.DateTimeField(auto_now_add=True)
    def __str__(self):
    return self.title
    def snippet(self):
    return self.body[:20] + '...'
    add spaces before def
    class Article(models.Model):
    title = models.CharField(max_length=100)
    slug = models.SlugField(max_length=50)
    body = models.TextField()
    date = models.DateTimeField(auto_now_add=True)
    def __str__(self):
    return self.title
    def snippet(self):
    return self.body[:20] + '...'

  • @nepalcodetv6298
    @nepalcodetv6298 6 лет назад

    truncatechars=120

  • @Lbmaniak
    @Lbmaniak 6 лет назад

    thx

  • @hiteshchoudhary3412
    @hiteshchoudhary3412 7 лет назад +1

    Hi Shaun, sorry to say, this Django not that much interesting

    • @NetNinja
      @NetNinja  7 лет назад +4

      Hey it's ok. Django is not everyone's favourite, but a lot of people do like it as well.

    • @joka109
      @joka109 7 лет назад +1

      I have to say the way he teaches is amazing for beginners, very easy to grasp the concepts and follow along. I just hate waiting for the next tutorial (as it comes in drips and drabs)!!

    • @coconutoatmeal4830
      @coconutoatmeal4830 7 лет назад +1

      Are Instagram, Pinterest, Disqus, Chaturbate, Bitbucket and etc interesting? You have to start from small and basic things to create something big amigo.

    • @yassir3715
      @yassir3715 6 лет назад

      as Shaun said, django is not everyone's favorite so .... just because you're not totally comfortable working with it doesn't mean everyone feels the same as you do