• Skip to primary navigation
  • Skip to content
  • Skip to footer
>>> import diegor just another special module
  • CV
  • Posts
    Diego Russo

    Diego Russo

    Software Engineer

    • Cambridge, UK
    • GitHub
    • LinkedIn
    • BlueSky
    • X
    • Facebook
    • Instagram
    • Email

    HOWTO: getting distinct rows using Django ORM

    less than 1 minute read

    Pretty simple:

    Author.objects.values('surname').distinct()
    

    You have a list of all authors with no duplication.
    If you use .orderby() together with .values(), you’ll have to specify in the order a field that is in .values()

    Any comment or suggestion are appreciate :)

    Tags: django, python

    Categories: english, howto

    Updated: June 26, 2012

    Share on

    X Facebook LinkedIn Bluesky
    Previous Next

    Comments

    You May Also Enjoy

    Help with COVID-19 research - protein folding on Raspberry Pi4

    2 minute read

    Hello, it has been a while since I wrote here last time.

    The must-read Python’s PEPs

    6 minute read

    As Python developer, you should know what a PEP is. In case you don’t, “PEP stands for Python Enhancement Proposal. A PEP is a design document providing i...

    Goodbye Wordpress, hello Github (Jekyll)

    2 minute read

    It has been a while I’m not writing in this blog. I have my reasons but the main one is because I’ve been busy migrating the whole website from Wordpress to ...

    Having fun with micro:bit and micropython

    1 minute read

    Last night I attended the usual CamPUG monthly meeting and the main topic was about micro:bit and micropython.


    • GitHub
    • LinkedIn
    • BlueSky
    • X
    • Facebook
    • Instagram
    • Feed
    © 2025 >>> import diegor. Powered by Jekyll & Minimal Mistakes.