Re: Adding a verbose_name to id field

2020-02-10 Thread Jason
Hmm.  TIL about https://code.djangoproject.com/ticket/8576

Would a a uuid for this, rather than an integer?  If not, you'll have to 
implement a save override to handle the incrementing yourself.

In addition, it might be worthwhile bringing this ticket up for discussion 
at https://groups.google.com/forum/#!forum/django-developers

-- 
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/dc686528-0a8d-43ff-9973-d478cc765959%40googlegroups.com.


Re: Adding a verbose_name to id field

2020-02-10 Thread Bruckner de Villiers
 

Thank you Jason.  However, I get the following error - AssertionError: Model 
bugs.Bugs can't have more than one auto-generated field.  Before adding the 
underlined bug_ticket field everything worked.  Is the error because the model 
already exists and I am adding the AutoField?

 

My models.py:

 

class Bugs(models.Model):

    FUNCTION_CHOICES = [

    ('C', 'Contacts'),

    ('E', 'Execs'),

    ('I', 'Sector/Industry'),

    ('G', 'General'),

    ('L', 'Clients'),

    ('O', 'Organisations'),

    ('P', 'Opportunities'),

    ('S', 'Account Type'),

    ('T', 'Training Material'),

    ('U', 'Currencies'),

    

]

    BUGTYPE_CHOICES = [

    ('B', 'Bug'),

    ('C', 'Comment'),

    ('S', 'Suggestion'),

    ]

    CLOSED_CHOICES = [

    ('N', 'No'),

    ('W', 'Work in Progress'),

    ('Y', 'Yes'),

    ]

    bug_ticket = models.AutoField(primary_key=False)

    bug_author = models.ForeignKey('auth.User', on_delete=models.CASCADE, 
verbose_name="Issue Author")

    bug_title = models.CharField(max_length=200, verbose_name="Brief 
Description:")

    bug_type = models.CharField(max_length=1, choices=BUGTYPE_CHOICES, 
verbose_name="Issue Type")

    bug_function = models.CharField(max_length=1, default="G", 
choices=FUNCTION_CHOICES, verbose_name="Function")

    bug_text = models.TextField()

    bug_status = models.CharField(max_length=1, default="N", 
choices=CLOSED_CHOICES, verbose_name="Issue addressed?")

    bug_created_date = models.DateTimeField(auto_now_add=True)

    bug_published_date = models.DateTimeField(blank=True, null=True)

    bug_update_date = models.DateTimeField(auto_now=True, verbose_name="Last 
Updated:")

 

    class Meta:

    verbose_name_plural="Bugs"

    

 

    def publish(self):

    self.published_date = timezone.now()

    self.save()

 

    def approve_comments(self):

    return self.comments.filter(approved_comment=True)

 

    def get_absolute_url(self):

    print(self.pk)

    return reverse("bugs/bug_detail",kwargs={'pk':self.pk})

 

    def __str__(self):

    return self.bug_title

 

 

Thanks for your attention to date.

 

Bruckner de Villiers

083 625 1086

 

From:  on behalf of Jason 
Reply to: 
Date: Monday, 10 February 2020 at 01:21
To: Django users 
Subject: Re: Adding a verbose_name to id field

 

You just need to use AutoField

-- 
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/3f0ecd5b-9493-47dd-bf85-382e87c3efd9%40googlegroups.com.


-- 
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/5986FDFB-B039-465C-BA2A-04EF9816A190%40gmail.com.


Re: Adding a verbose_name to id field

2020-02-09 Thread Jason
You just need to use AutoField 


-- 
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/3f0ecd5b-9493-47dd-bf85-382e87c3efd9%40googlegroups.com.


Re: Adding a verbose_name to id field

2020-02-09 Thread Bruckner de Villiers
Thank you Mike & Jason.

I agree - messing around with the id is not the brightest idea I've ever 
conceived.
However, the Django 3 documentation is somewhat mute on auto-incrementing, but 
I'll continue searching Stack & Mozilla.  Have a great evening (I am GMT+2).
Regards,

Bruckner de Villiers
083 625 1086

On 2020/02/09, 08:28, "Mike Dewhirst"  wrote:

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: * on behalf of Mike Dewhirst 
> 
> *Reply to: *
> *Date: *Saturday, 08 February 2020 at 13:48
> *To: *
> *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 
    >
> 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_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_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.



-- 
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/7DF8F99B-92E1-4DFA-84A7-FD63ECCC06E6%40gmail.com.


Re: Adding a verbose_name to id field

2020-02-08 Thread Mike Dewhirst

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: * on behalf of Mike Dewhirst 


*Reply to: *
*Date: *Saturday, 08 February 2020 at 13:48
*To: *
*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 

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_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_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.


Re: Adding a verbose_name to id field

2020-02-08 Thread Jason
Sounds to me you'd like a separate auto-increment field?

On Saturday, February 8, 2020 at 11:55:48 AM UTC-5, 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.
>
>  
>
> Make sense?
>
>  
>
> Bruckner de Villiers
>
> 083 625 1086
>
>  
>
> *From: *> on behalf of Mike 
> Dewhirst >
> *Reply to: *>
> *Date: *Saturday, 08 February 2020 at 13:48
> *To: *>
> *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 > 
>
> Date: 8/2/20 21:33 (GMT+10:00) 
>
> To: django...@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...@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_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/0627cb8d-c308-4ef0-85f9-14de135a2270%40googlegroups.com.


Re: Adding a verbose_name to id field

2020-02-08 Thread Bruckner de Villiers
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.

 

Make sense?

 

Bruckner de Villiers

083 625 1086

 

From:  on behalf of Mike Dewhirst 

Reply to: 
Date: Saturday, 08 February 2020 at 13:48
To: 
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  

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.
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.


-- 
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/CA217C44-C4FE-4CE8-8479-97B9F05939BE%40gmail.com.


RE: Adding a verbose_name to id field

2020-02-08 Thread Mike Dewhirst
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 
 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.
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.


Adding a verbose_name to id field

2020-02-08 Thread Bruckner de Villiers
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62D60B90-C46E-41AB-AF46-4CD1BEA89D14%40gmail.com.