Skip to content

Commit bc06c9a

Browse files
authored
Merge pull request #250 from fabricio-aguiar/4681-related-name
dealing with pulpcore default_related_name
2 parents 47aa65a + 4f7a9f3 commit bc06c9a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGES/4681.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adopting related names on models.

pulp_python/app/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class PythonDistribution(PublicationDistribution):
9090

9191
TYPE = 'python'
9292

93+
class Meta:
94+
default_related_name = "%(app_label)s_%(model_name)s"
95+
9396

9497
class PythonPackageContent(Content):
9598
"""
@@ -146,6 +149,7 @@ def __str__(self):
146149
)
147150

148151
class Meta:
152+
default_related_name = "%(app_label)s_%(model_name)s"
149153
unique_together = ('filename',)
150154

151155

@@ -156,6 +160,9 @@ class PythonPublication(Publication):
156160

157161
TYPE = 'python'
158162

163+
class Meta:
164+
default_related_name = "%(app_label)s_%(model_name)s"
165+
159166

160167
class PythonRemote(Remote):
161168
"""
@@ -182,3 +189,6 @@ def excludes(self):
182189
Specify exclude list.
183190
"""
184191
return ProjectSpecifier.objects.filter(remote=self, exclude=True)
192+
193+
class Meta:
194+
default_related_name = "%(app_label)s_%(model_name)s"

pulp_python/app/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class PythonPublicationSerializer(core_serializers.PublicationSerializer):
373373
distributions = core_serializers.DetailRelatedField(
374374
help_text=_('This publication is currently being hosted as configured by these '
375375
'distributions.'),
376-
source="pythondistribution_set",
376+
source="python_pythondistribution",
377377
many=True,
378378
read_only=True,
379379
)

0 commit comments

Comments
 (0)