django-admin doesn't display choices and it's not possible to select one

166 views
Skip to first unread message

Mariangeles Mendoza

unread,
Sep 13, 2021, 9:13:48 AM9/13/21
to Django users
Hi,
I'm very new in Django. I'm making a cv, but I don't get select a choice through the django-admin web. I've searched solutions in the community but I cant't solve it.

My code is:

Models.py
""""
class Article(models.Model):
    
    year = models.PositiveIntegerField(
            validators=[
                MinValueValidator(1900), 
                MaxValueValidator(datetime.now().year)], null=True, blank=True)
   
    title = models.CharField(max_length=200)
    author = models.ManyToManyField(Author)
    journal = models.ForeignKey(Journal, models.CASCADE)
    summary = models.TextField(max_length=1000, null=True, blank=True, 
                               help_text="Brief description of the article")
   
    PUB_TYPE = (
        ('r', 'refereed'),
        ('t', 'technical report'),
        ('p', 'proceeding'),
        ('b', 'book'),
        ('c', 'book chapter'),
    )

    status = models.CharField(max_length=1, choices=PUB_TYPE, default='refereed', 
                               help_text='publication type')
    
    class Meta:
        ordering = ['year']
        
    def get_absolute_url(self):
        return reverse('article-detail', args=[str(self.id)])    

    def __str__(self):
        return self.title
""""

admin.py
"""
@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'journal', 'year', 'status')
    list_filter = (("year", "journal")
    ordering = ('-year',)
    search_fields= ('author',)
    filter_horizontal = ('author',)
    raw_id_fields = ('journal',)
"""
When I click in the status button (attached image), the  choices aren't displayed and i can't seletc one.
I would be very grateful for any idea.

Thanks in advance,
Maria
statusNotWorking.jpg

bnmng

unread,
Sep 20, 2021, 7:59:25 AM9/20/21
to Django users
Hi.  I don't see anything in your code samples that would cause this.   One line in admin.py caused the server to stop because of the extra parenthesis, and the default for status should be 'r' instead of  'refereed', but those don't cause the problem you're describing.  Maybe a browser issue?  Maybe there's something with a custom widget that isn't the samples?

Mariangeles Mendoza

unread,
Sep 21, 2021, 3:41:18 AM9/21/21
to Django users
Thank you very much!!!

I will try other browsers. I have used Firefox and Brave.
No, I am not using other custom widget.

Thanks again,
Maria 

Mariangeles Mendoza

unread,
Sep 22, 2021, 4:18:14 AM9/22/21
to Django users
Hi,

Eureka!!! 
Benjamin, you are right. I changed my browser and it worked.

Thank for you advice.

Best wishes,
Maria

bnmng

unread,
Sep 22, 2021, 8:48:51 AM9/22/21
to Django users
Fantastic!  But now I wonder why it's not working on some of your browsers
Reply all
Reply to author
Forward
0 new messages