[Django] #34793: Django ORM returns None when field has value in BD

7 views
Skip to first unread message

Django

unread,
Aug 22, 2023, 11:23:17 PM8/22/23
to django-...@googlegroups.com
#34793: Django ORM returns None when field has value in BD
-------------------------------------+-------------------------------------
Reporter: Alexandre | Owner: nobody
Rodrigues Batista |
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have this model:
{{{
class Issue(models.Model):
is_active = models.BooleanField(default=True)
issue_id = models.IntegerField()
new_issue_id = models.IntegerField(null=True)
issue_name = models.CharField(max_length=50)
periodic = models.ForeignKey(to=Periodic, on_delete=models.SET_NULL,
null=True)
app = models.IntegerField(default=1)

def __str__(self) -> str:
return f'{self.issue_name} - {self.new_issue_id}'
}}}


and always I try to get field "new_issue_id", Django returns "None" to me
My db values

{{{
INSERT INTO public.issue_issue
(is_active,issue_id,issue_name,periodic_id,app,new_issue_id) VALUES
(true,13,'Issue A',18,1,13),
(true,12,'Issue B',19,1,12)

}}}

Issue.objects.raw_sql got same result as Issue.objets.all or
Issue.objets.find or Issue.objets.get...


My solution was to use psycopg2 directly.

I checked Django_migrations table, and migration was there


{{{
class Migration(migrations.Migration):

dependencies = [
('issue', '0002_issue_issue_app'),
]

operations = [
migrations.AddField(
model_name='issue',
name='new_issue_id',
field=models.IntegerField(null=True),
),
]
}}}

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

Django

unread,
Aug 23, 2023, 12:53:31 AM8/23/23
to django-...@googlegroups.com
#34793: Django ORM returns None when field has value in BD
-------------------------------------+-------------------------------------
Reporter: Alexandre Rodrigues | Owner: nobody
Batista |
Type: Bug | Status: closed
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: invalid
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 Mariusz Felisiak):

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


Comment:

TBH, I'm not sure what you're trying to report, but it looks like a
support question and Trac is not a support channel. If you're having
trouble understanding how Django works, see
TicketClosingReasons/UseSupportChannels for ways to get help.

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

Reply all
Reply to author
Forward
0 new messages