Reputation: 5730
In Django
, I can name each field of model like this(In Korean):
description = models.CharField("설명", max_length=100, blank=True)
image = ImageField("이미지", upload_to=upload_location)
but in case of ForeignKey
, it doesn't work.
album = models.ForeignKey("앨범", Album)
Why does it not work only on ForeignKey
?
Upvotes: 4
Views: 2883
Reputation: 43300
Because the first parameter of a ForeignKey
is the model it is linking to, this can be a string such as 'self'
which is why it allows strings.
If you want to specify a verbose_name
then you should use the keyword arg
album = models.ForeignKey(Album, verbose_name="앨범")
For more on verbose_names
, see the docs for Verbose field names
ForeignKey
,ManyToManyField
andOneToOneField
require the first argument to be a model class, so use the verbose_name keyword argument:
Upvotes: 10