programming.dev
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Luis NorambuenaM to DjangoEnglish · 1 year ago

How to use Django database function expressions directly

www.jamesbeith.co.uk

external-link
message-square
0
link
fedilink
5
external-link

How to use Django database function expressions directly

www.jamesbeith.co.uk

Luis NorambuenaM to DjangoEnglish · 1 year ago
message-square
0
link
fedilink
Django has a many built-in database functions and a documented Func API for writing your own. Whilst writing a custom Func subclass may sometimes be necessary, I learnt that there’s many cases when you can instantiate Func with the necessary arguments to get what you need. For example, take the following model. from django.contrib.postgres.fields import ArrayField from django.db import models class Post(models.Model): tags = ArrayField(models.CharField(max_length=200)) Making use of the array_shuffle Postgres Array Function and an annotation, each of the post’s tags are in a randomised order.

via https://fosstodon.org/@jamesbeith/113236427252274335

alert-triangle
You must log in or # to comment.

Django

django

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Django Project

  • Django Project, the web framework for perfectionists with deadlines
  • Django Code of Conduct
  • Django Documentation
  • Django Blog/News
  • Support Django

Django Community

  • Discord
  • Unofficial Django Discord
  • Project forum
  • StackOverflow
  • #django IRC Channel
  • Django Users mailing list
  • Django Developers mailing list
  • Jazzband, a community maintaining Python projects
  • Django Commons, organization dedicated to supporting the community’s efforts to maintain packages
  • Djangonaut Space

Django Ecosystem

  • Built With Django
  • Django Packages
  • Django.WTF
  • djangosnippets
  • Awesome Django
  • Django News
  • Django Videos on pyvideo
  • Django TV
  • Upgrade Django
Jobs
  • Django Gigs
  • Django Jobs
Learning/Docs
  • Django Project tutorial
  • Django Girls Tutorial
  • DjangoBook
  • Classy Class-Based Views
  • Classy Django REST Framework
  • Classy DB
Podcasts:
  • Django Chat
  • Django Riffs
Related Fediverse communities
  • #django on Mastodon
  • c/Python on programming.dev
  • c/PostgreSQL on programming.dev
Feeds
  • Active c/Django posts
  • New c/Django posts
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1 user / day
  • 4 users / week
  • 13 users / month
  • 22 users / 6 months
  • 130 local subscribers
  • 528 subscribers
  • 250 Posts
  • 98 Comments
  • Modlog
  • mods:
  • Jason Novinger
  • Juanjo Salvador
  • Luis Norambuena
  • BE: 0.19.13
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org