Я не знаю, что здесь происходит ... Я просто хочу проверить значение поля модели и затем обновить его соответствующим образом ... любая помощь или понимание приветствуется!1003 *
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
beta = models.CharField(max_length=1, blank=True, null=True)
просмотр:
from internal.accounts.models import UserProfile
from django.contrib.auth.models import User
@login_required
def beta_testers(request):
user = User.objects.get(username=request.user.username)
user_profile = user.get_profile()
count = UserProfile.objects.filter(beta='1').count()
if count < 50 and not user_profile['beta']:
user_profile['beta'] = '1'
user_profile.save()
ошибка:
TypeError at /utilities/beta-signup/
'UserProfile' object is unsubscriptable
Request Method: GET
Request URL: http://localhost/utilities/beta-signup/?x=1&y=15
Django Version: 1.2.1
Exception Type: TypeError
Exception Value:
'UserProfile' object is unsubscriptable
Exception Location: C:/django\internal\cms_helper\views.py in beta_testers, line 284