Comments (4)
@masdot π
Can you expand a little bit more - perhaps with an example of what you are trying to achieve, so I can help you better?
Cheers!
from django-styleguide.
@RadoRado π€
Yes, of course! Sorry if I have expressed myself inaccurately.
I need some kind of custom ID or numbering for my project. This needs to be built according to the scheme <year><ascending number>
.
This numbering is based on the records, which means that the creation date of the record is the basis for generating the numbering. For example, the records in 2020 are
20200001 - 202100563.
and in 2021
20210001, 20210002, ...
However, I see it somewhat critical to solve this numbering via a
@Property since this probably affects the scalability.
from django-styleguide.
@masdot Sorry for the late answer! Catching up with the issues.
This sounds more like a database field and not a property.
And in order to generate sequential numbers, you might want to look into some kind of table locking or using F expressions ( https://docs.djangoproject.com/en/3.2/ref/models/expressions/#f-expressions )
Especially if you want to search or sort by those ids.
If you need them just for visual purposes, then a @property
would do.
Hope that helps!
from django-styleguide.
Thank you! π
from django-styleguide.
Related Issues (20)
- Socket Programming HOT 4
- Does the following image depict it correctly? HOT 2
- Error structuring according to RFC7807 HOT 4
- Issue with `InputSerializer` Classes and Schema Generation HOT 15
- UUIDs are bad primary keys HOT 2
- Examples with larger models HOT 5
- maybe link is errorοΌ HOT 1
- Add a couple of paragraphs about migrations
- Use ViewSet instead of APIView HOT 3
- Main problems with Openapi schema generation HOT 6
- Different endpoints for different permissions HOT 3
- Why not use APIException HOT 1
- Business logic and test factories HOT 2
- Why Overloaded POST over PUT/PATCH/DELETE? HOT 9
- People can't use labels HOT 5
- Service for bulk_create HOT 3
- Third party APIs HOT 5
- Convince me about selectors? HOT 2
- One Api - One Service HOT 4
- Style guide beginner comments HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-styleguide.