On 9/02/2020 3:54 am, Bruckner de Villiers wrote:

Mike,

I tried id = model.AutoField(verbose_name=”Ticket #”).  Migrate didn’t like it – can’t have duplicate primaries.  I suspect this is because the Bug model already exists.

What I am trying to achieve is an auto-increment field whereby every time a user logs a bug/suggestion/comment it writes a unique ticket number in the background, which is used as a reference for subsequent actions like Fixed, Close, WiP, etc.  and as a ForeignKey in the Comment model.   I couldn’t find anything meaningful for this functionality and so thought that the ‘id’ is already fit for purpose, but merely requires an explanatory field text.


I think Jason is correct. The id field belongs to the DBMS and theoretically should never carry any human or real world meaning.

You would be better having an auto-incrementing field called "ticket" or similar

If you really must use the id field you can supply the model with your own id field (that's covered somewhere in the docs) with whatever name suits.

Cheers

Mike



Make sense?

Bruckner de Villiers

083 625 1086

*From: *<django-users@googlegroups.com> on behalf of Mike Dewhirst <mi...@dewhirst.com.au>
*Reply to: *<django-users@googlegroups.com>
*Date: *Saturday, 08 February 2020 at 13:48
*To: *<django-users@googlegroups.com>
*Subject: *RE: Adding a verbose_name to id field

I imagine you need to specify the id field in your model and give it a verbose name.

This is an unusual requirement. Why do you want to do such a thing?

Mike

-------- Original message --------

From: Bruckner de Villiers <bruckner.devilli...@gmail.com>

Date: 8/2/20 21:33 (GMT+10:00)

To: django-users@googlegroups.com

Subject: Adding a verbose_name to id field

Using Sqlite3 & Django 3.0.2 - I have searched high and low, but can’t find a way to add a verbose name to the id of a model.

Anyone have ideas, please?

Bruckner de Villiers

+27 83 625 1086

--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5e3e9fe6.1c69fb81.7cda5.a2fdSMTPIN_ADDED_MISSING%40gmr-mx.google.com <https://groups.google.com/d/msgid/django-users/5e3e9fe6.1c69fb81.7cda5.a2fdSMTPIN_ADDED_MISSING%40gmr-mx.google.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA217C44-C4FE-4CE8-8479-97B9F05939BE%40gmail.com <https://groups.google.com/d/msgid/django-users/CA217C44-C4FE-4CE8-8479-97B9F05939BE%40gmail.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2ad77dc8-e743-8241-7531-378bb7f717af%40dewhirst.com.au.

Reply via email to