Reputation: 2324
Strange error. When I am trying to add some data to my charfield it shows me error like this: invalid literal for int() with base 10:
Here is my models:
class Follower(models.Model):
follower = models.CharField(max_length=140)
def __unicode__(self):
return self.follower
class Following(models.Model):
following = models.CharField(max_length=140)
def __unicode__(self):
return self.following
class UserProfile(models.Model):
# This line is required. Links UserProfile to a User model instance.
user = models.OneToOneField(User)
# The additional attributes we wish to include.
website = models.URLField()
followers = models.ManyToManyField(Follower)
following = models.ManyToManyField(Following)
Views:
if request.GET.get('follow'):
author = UserProfile.objects.get(user__username__iexact=username)
b = "AAA"
author.followers.add(b)
What to do?
Upvotes: 0
Views: 46
Reputation: 599610
followers
is not a CharField, it is a ManyToManyField. You can't just add text to it: you need to create an instance of Follower, or get an existing one, and add it.
Upvotes: 2