I Defined this model
from django.db import models
from django.db.models import CharField
# Create your models here.
class City(models.Model):
state = models.ForeignKey('state.State',on_delete=models.CASCADE,)
city_name = models.CharField(max_length=100, verbose_name=_('City Name'))
def __unicode__(self, ):
return str(self.city_name)
But when I want to use it I get this error in City
city_name = models.CharField(max_length=100, verbose_name=_('City Name'))
NameError: name '_' is not defined
I dont know where the problem is
You need to import the gettex or alternative function from django.utils.translation import gettext as _
. Take a look at django i18n documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With