I want to make a primary key from 2 fields in Django.
Fields are below
- current Time
- userId
How Can I do
If the key has to be single-column:
id is added "out-of-the-box" (variable.id) and for current time just add
from django.db import models
date = models.DateTimeField( auto_now_add=True)
in yourapp/models.py
so you have your 2 values, out of witch you can make your key in any shape you want.
if you want multi-column-key then read the other answer. Hope to help you.