[Django] #30830: django custom relationship

3 views
Skip to first unread message

Django

unread,
Oct 2, 2019, 12:55:42 PM10/2/19
to django-...@googlegroups.com
#30830: django custom relationship
-----------------------------------------+------------------------
Reporter: bilnus1111 | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 2.2
Severity: Normal | Keywords: models
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
helo; supose i've tow models:


{{{
class Product(models.Model):
ref= models.CharField(max_length=12, unique=True)
code_prod= models.CharField(max_length=50)
description= models.CharField(max_length=150)

class Detail(models.Model):
ref = models.CharField(max_length=10)
year= models.IntegerField()
code = models.CharField(max_length=10)
month = models.IntegerField()
created_at = models.DateField()

class Meta:
db_table = 'details'
}}}


to make oneToMany relationship on Detail model, we can use ForeignKey.
this supose in Detail table there is column named product_id,
i want know if i can use another field for example "ref" to make this
relationship ?
also how can i perform this SQL query :

{{{
query = "select product.ref, product.description, details.year,
details.code from product left join details on details.ref = product.ref
where product.code = 'abcd' ; "
}}}

thank you very much.

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

Django

unread,
Oct 2, 2019, 1:00:52 PM10/2/19
to django-...@googlegroups.com
#30830: django custom relationship
-------------------------------------+-------------------------------------
Reporter: bill | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:

Keywords: models | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bill):

* component: Documentation => Database layer (models, ORM)
* type: Uncategorized => Bug


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

Django

unread,
Oct 2, 2019, 2:58:17 PM10/2/19
to django-...@googlegroups.com
#30830: django custom relationship
-------------------------------------+-------------------------------------
Reporter: bill | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution: invalid

Keywords: models | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

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


Comment:

Sorry, but the ticket system is not meant as a support channel.
Read wiki:/TicketClosingReasons/UseSupportChannels

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

Django

unread,
Oct 2, 2019, 3:37:04 PM10/2/19
to django-...@googlegroups.com
#30830: django custom relationship
-------------------------------------+-------------------------------------
Reporter: bill | Owner: nobody
Type: Uncategorized | Status: closed

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: models | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bill):

* type: Bug => Uncategorized


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

Reply all
Reply to author
Forward
0 new messages