[Django] #25537: Model objects not showing after changing M2M to ForeinKey

9 views
Skip to first unread message

Django

unread,
Oct 10, 2015, 6:13:43 AM10/10/15
to django-...@googlegroups.com
#25537: Model objects not showing after changing M2M to ForeinKey
-------------------------------+--------------------
Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I've changed on a model one of the fields from Many2Many to nullable
ForeignKey.
After the migration when I enter the admin panel to the mentioned model I
don't see any of the existing objects from that model but I do see in
paginator the correct count amount.

--
Ticket URL: <https://code.djangoproject.com/ticket/25537>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 10, 2015, 6:14:06 AM10/10/15
to django-...@googlegroups.com
#25537: Model objects not showing after changing M2M to ForeinKey
---------------------------+----------------------------

Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------+----------------------------
Changes (by yaniv14):

* Attachment "Select Menu item to change - Django site admin.png" added.

Django

unread,
Oct 10, 2015, 7:43:45 AM10/10/15
to django-...@googlegroups.com
#25537: Model objects not showing after changing M2M to ForeinKey
-------------------------------+--------------------------------------

Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Could you please add more details such as a sample project so we can
reproduce the issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/25537#comment:1>

Django

unread,
Oct 10, 2015, 8:21:03 AM10/10/15
to django-...@googlegroups.com
#25537: Model objects not showing after changing M2M to ForeinKey
-------------------------------+--------------------------------------

Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by yaniv14):

First I had this in my models.py
{{{
#!python
class MenuTime(models.Model):
title = models.CharField(_('Title'), max_length=200)
order = models.PositiveSmallIntegerField(_('Order'), default=1)

class Meta:
verbose_name = _('Menu time')
verbose_name_plural = _('Menu times')
ordering = ['order', ]

def __unicode__(self):
return self.title


class MenuGroup(models.Model):
title = models.CharField(_('Title'), max_length=200)

class Meta:
verbose_name = _('Menu group')
verbose_name_plural = _('Menu groups')

def __unicode__(self):
return self.title


class HealthQuestionnaire(models.Model):
title = models.CharField(_('Name'), max_length=200)

class Meta:
verbose_name = _('Health questionnaire')
verbose_name_plural = _('Health questionnaires')

def __unicode__(self):
return self.title


class MenuItem(models.Model):
name = models.CharField(_('Name'), max_length=200)
time = models.ManyToManyField(MenuTime, related_name='menu_items')
group = models.ForeignKey(MenuGroup, related_name='menu_items')
male = models.BooleanField(_('For male?'), default=True)
female = models.BooleanField(_('For female?'), default=True)
image = ImageField(upload_to='menus', verbose_name=_("Menu image"),
blank=True, null=True)
not_allowed = models.ManyToManyField(HealthQuestionnaire,
verbose_name=_("Not allowed with"),
related_name='menu_items',
blank=True)

class Meta:
verbose_name = _('Menu item')
verbose_name_plural = _('Menu items')
ordering = ['-name']

def __unicode__(self):
return self.name

def admin_thumbnail(self):
return u'<img src="%s" width="120" height="auto" />' %
self.image.url if self.image else None

admin_thumbnail.short_description = _('Thumbnail')
admin_thumbnail.allow_tags = True

def not_allowed_list(self):
return ", ".join([x.title for x in self.not_allowed.all()])

not_allowed_list.short_description = _('Not allowed list')
}}}
And I had 11 MenuItem objects created from django admin, later I decided
to change the relation of time field from M2M to ForeignKey -> "time =
models.ForeignKey(MenuTime, related_name='menu_items', null=True)"

I ran manage.py makemigration and migrate and then I've started to notice
the issue.
All 11 objects are still accessible and the bug I have is only in the
django admin list display.
If i am adding to the url the object ID
(127.0.0.1:8000/admin14/core/menuitem/2/) I am able to see the correct
object in the admin panel.

Hope it helps to reproduce the bug

--
Ticket URL: <https://code.djangoproject.com/ticket/25537#comment:2>

Django

unread,
Oct 13, 2015, 8:30:45 AM10/13/15
to django-...@googlegroups.com
#25537: Model objects not showing after changing M2M to ForeinKey
-------------------------------+--------------------------------------

Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by timgraham):

I can't reproduce the issue. Maybe the issue is caused by certain data
you've created. Can you be more specific with the minimal steps to
reproduce it or provide a SQLite database that demonstrates the issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/25537#comment:3>

Django

unread,
Oct 13, 2015, 8:43:21 AM10/13/15
to django-...@googlegroups.com
#25537: Model objects not showing on admin changelist page after changing M2M to
ForeignKey
-------------------------------+--------------------------------------

Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/25537#comment:4>

Django

unread,
Oct 13, 2015, 9:59:12 AM10/13/15
to django-...@googlegroups.com
#25537: Model objects not showing on admin changelist page after changing M2M to
ForeignKey
-------------------------------+--------------------------------------
Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by yaniv14):

I already wrote the steps that I did.
I cannot attach the sqlite db file because I already modified that file
and it will not show the bug any more.
This is just a project in early stages of development.
I will try to reproduce this bug again in the future.
If you want to close the ticket or leave it open for now its up to you.

Thank you

--
Ticket URL: <https://code.djangoproject.com/ticket/25537#comment:5>

Django

unread,
Oct 13, 2015, 10:01:52 AM10/13/15
to django-...@googlegroups.com
#25537: Model objects not showing on admin changelist page after changing M2M to
ForeignKey
-------------------------------+--------------------------------------
Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by collinanderson):

Usually if the rows don't show up that means there's an error that's
getting silenced somewhere. Scale back (or disable) your `list_display`
and try to figure out which column is causing the error.

--
Ticket URL: <https://code.djangoproject.com/ticket/25537#comment:6>

Django

unread,
Oct 13, 2015, 10:19:49 AM10/13/15
to django-...@googlegroups.com
#25537: Model objects not showing on admin changelist page after changing M2M to
ForeignKey
-------------------------------+--------------------------------------
Reporter: yaniv14 | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => worksforme


--
Ticket URL: <https://code.djangoproject.com/ticket/25537#comment:7>

Reply all
Reply to author
Forward
0 new messages