Django Model Properties & Methods | @property decorator | get_absolute_url() method

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

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

  • @bugbytes3923
    @bugbytes3923  9 หลายเดือนก่อน +1

    ORM Playlist link: th-cam.com/video/EsBqIZmR2Uc/w-d-xo.html

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

    I like before I Watch. Please more django content. Thank you for all the great content.

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      Thanks a lot, much appreciated! It'll be a lot of Django in the next month ;)

    • @amine63404
      @amine63404 9 หลายเดือนก่อน

      @bugbytes3923 That's great, we already learned a lot from you.
      Perhaps you could make a kind of complete course about django with begginer, intermediate and advanced level.
      I am sure knowing the quality of your job that many people (me included) will be ready to pay for it.

  • @peterholzer98
    @peterholzer98 9 หลายเดือนก่อน +5

    Thanks a lot and YES please make a video about model managers.

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +2

      Will do, thanks a lot Peter!

  • @_esplor
    @_esplor 9 หลายเดือนก่อน +2

    Would love to see some processing of data before saving to database/disk.
    I have a model with filefield for uploading gpx files. I want to save the original file, but also extract metadata into different fields of the model.
    For example number of points for the track, elevation of each point, calculate the length of the track...
    I appreciate your django/python content very much. And I hope you will be doing more with django gis, and hopefully "djangorestframework-gis".

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      Thanks a lot! There will be lots of GIS stuff on this channel in the future, with GeoDjango too - a big part of my working background is in GIS. I'll need to set some time aside to prepare it though, probably over the summer.
      Are there any GPX file examples that you could point me to for a video like this? I'd be happy to try a small video on this in the near future.
      Thanks again for the kind words, much appreciated!

    • @_esplor
      @_esplor 9 หลายเดือนก่อน

      @@bugbytes3923 Nice! Much appreciated, let the countdown begin :)
      I'm a noob in GeoDjango/GIS, even building up models and deciding where to store the data was a struggle.
      My goal is to setup GeoDjango+rest as a backend for serving hiking tracks and hiking related pois (parking, viewpoints, shelter, fresh water).
      Maybe using Nextjs as frontend. I know this is a hairy goal for me, but man I'm learning a lot!
      Let me prepare a gh repo to share. Is it OK for you I make a private GH repo where I can invite you to join?

  • @adkocol
    @adkocol 9 หลายเดือนก่อน +2

    great content, well explained... more django practical hints please :)

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

      Thanks! Coming up soon ;)

  • @dmitrymikhailovnicepianomu8688
    @dmitrymikhailovnicepianomu8688 9 หลายเดือนก่อน +2

    Great as usual.

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน

      Thanks a lot!

  • @leboyoyo
    @leboyoyo 9 หลายเดือนก่อน +1

    Thank you so much for all this useful content!!! Could you please tell me where you're from? I've been following your videos for over a year now, and this accent is starting to drive me crazy!

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

      Thank you for the support! The accent is from Glasgow, Scotland!

    • @leboyoyo
      @leboyoyo 9 หลายเดือนก่อน

      @@bugbytes3923 thanks for the reply :)

  • @developershub2024
    @developershub2024 9 หลายเดือนก่อน +1

    A great content, thank you so much!

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      Thanks a lot, much appreciated!

    • @developershub2024
      @developershub2024 9 หลายเดือนก่อน

      @@bugbytes3923 Hello, can you please do a video on hxhtml2pdf, PLEASE, because there is a function provided in the documenention about how to Convert HTML URIs to absolute system paths so xhtml2pdf can access those
      resources, it returns an error, i have tried to find the problem but i havent got the solution, I HOPE YOU WILL CONSIDER THIS!!!!

  • @hack727
    @hack727 9 หลายเดือนก่อน +1

    i love your content, please make videos on custom user model, groups and permission and django signals.

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      Great suggestions, thanks! Will try and prepare soon.

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

    I came here after 4h coding Django ❤

  • @anouarben779
    @anouarben779 9 หลายเดือนก่อน

    some django content again, thank you !

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +2

      Thanks! The next month will be full of Django ;)

  • @ntwarioscar
    @ntwarioscar 9 หลายเดือนก่อน +1

    thanks for your videos but I want to ask you there's video you have done about notification with channels and websocket is it possible to do notofication with django by using htmx, alpine, hyperscript with wsgi or it is not possible?
    please tell me

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      I would recommend ASGI + django-channels for this, if possible. Or some other WebSocket package.
      With WSGI, it is definitely possible, I would think - but I've no experience with that, to be honest.

  • @edmfestivals6066
    @edmfestivals6066 9 หลายเดือนก่อน

    NO idea what your doing but I love your Scottish accent

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      Haha glad you like the accent!

  • @ka_vez
    @ka_vez 10 วันที่ผ่านมา +1

    can you make a video on how to override the default save and delete functions on a model

    • @bugbytes3923
      @bugbytes3923  10 วันที่ผ่านมา +1

      Great idea - will do!

  • @dmitrymikhailovnicepianomu8688
    @dmitrymikhailovnicepianomu8688 9 หลายเดือนก่อน +1

    Can you create video about docker + django? And maybe then deploying a project to Ubuntu. Not on heroku or netlify but to classical clean Ubuntu server. That would be very interesting.

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      Great suggestion! I've got plans for deployment videos, and deploying to an Ubuntu instance would definitely be interesting. I'll see what I can do soon!

  • @seydinaoumarsamabaly1806
    @seydinaoumarsamabaly1806 9 หลายเดือนก่อน

    Very great content !

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      Thanks as always!

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

    nice content🤯

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

      Thanks a lot!

  • @kunaltakalkar6647
    @kunaltakalkar6647 9 หลายเดือนก่อน

    Thank you for django videos.
    Can you create a video how to perform each type of sql joins in django...I would be great help

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +2

      Thanks! Great suggestion, will add it to the list.

  • @rns10
    @rns10 9 หลายเดือนก่อน

    Hi
    thanks for this, I have been following this series for quite some time.
    I would like to know if you plan to also push the code to github.

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน

      Thanks! I could put the final models.py file on there, if that would be helpful?

    • @rns10
      @rns10 9 หลายเดือนก่อน

      @@bugbytes3923 Thanks for replying back. Yes that would suffice the need. Thank you.

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

    am trying to figure it out, i have a rural and a urban properties, how do i build my models? should i create a models for each of than and them apply a foreing key to a listing models ?

  • @frameff9073
    @frameff9073 9 หลายเดือนก่อน +2

    good thank you

  • @anouarben779
    @anouarben779 9 หลายเดือนก่อน

    I have a question regarding database management, what is the best way to create database tables for multiple clients (small businesses), is creating a business model enough to separate the databases between them or is there a better practical way ?

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      I'd recommend a package like django-tenants for separation of tables for each client. This basically works by using a single database, but creating multiple schemas within the database - one per client. Each client can therefore have the same tables, but separated into their own schema.
      pypi.org/project/django-tenants/
      Would a video on this be useful?

    • @anouarben779
      @anouarben779 9 หลายเดือนก่อน

      @@bugbytes3923 thanks for the reply, it sure will be helpful thank you again I appreciate the effort

  • @kushalpy
    @kushalpy 9 หลายเดือนก่อน

    Could you make a latest way on like setting up social logins like with google and facebook using DRF. Many libraries are being broked.

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน

      Good suggestion! Will add it to the list.

  • @SapereAude1490
    @SapereAude1490 9 หลายเดือนก่อน

    I never knew about the @property decorator in models - if I were using FastAPI as a microservice and SQLAlchemy, could I do the same? Is it inadvisable to have more complicated methods as @property?
    Also, for some reason, your accent makes me pay attention better.

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน

      Thanks! Yes - properties are something provided by Python classes, so they can also be used with SQLAlchemy in exactly the same manner.
      I would advise against doing anything too complicated in a property, particularly if it involves reaching beyond the model class for external dependencies or performing additional SQL queries, etc. For simple stuff, it's perfect though.

  • @juanbetancourt5106
    @juanbetancourt5106 9 หลายเดือนก่อน

    Thank you

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน

      Thanks for watching!

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

    thank you

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

      Thanks a lot for watching!

  • @Yarkanlaki
    @Yarkanlaki 9 หลายเดือนก่อน

    My problem is I can use property for indexing and filtering

  • @developershub2024
    @developershub2024 9 หลายเดือนก่อน

    Hello @bugbytes3923, can you please do a video on hxhtml2pdf, PLEASE, because there is a function provided in the documenention about how to Convert HTML URIs to absolute system paths so xhtml2pdf can access those
    resources, it returns an error, i have tried to find the problem but i havent got the solution, I HOPE YOU WILL CONSIDER THIS!!!!

  • @myoji5580
    @myoji5580 9 หลายเดือนก่อน +1

    Problem
    CharField need blank=True, null=False
    Because db have two value ‘’, None
    Confuse read db
    Restaurant.objects.filter(nickname=‘’) or Restaurant.objects.filter(nickname_isnull=True)

    • @bugbytes3923
      @bugbytes3923  9 หลายเดือนก่อน +1

      The solution for a CharField would be to disallow Null values, and make the default an empty string.

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

      Even though it is a CharField, I prefer to set NULL values on the database side.
      CharField(null=True)
      Storing a blank string still constitutes a value, whereas NULL itself signifies the absence of a value. If you store blanks in the database for a CharField where there should be no value, you will end up with various types of empty strings:
      (i) ""
      (ii) " "
      (iii) " "
      (iv) " "
      (v) " "
      It's better to use null=True even with CharField type of field.
      When you use Django's save method or objects.create()
      , it checks for values in this sequence for any absent field :
      First priority: Use the default value if provided in the model field.
      Second priority: Use NULL if null=True is provided in the model field.
      Third priority: Use an empty blank string (irrespective of whether blank=True is provided or not), because you can't prevent Django from storing nothing on the database side. Django is frustrated now.