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: <django-users@googlegroups.com> on behalf of Jason <jjohns98...@gmail.com>
Reply to: <django-users@googlegroups.com>
Date: Monday, 10 February 2020 at 01:21
To: Django users <django-users@googlegroups.com>
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.

Reply via email to