我认为它起源于这个视图,因为它正在被转移到主视图(见下文):
@login_required
def HomePage(request):
if request.user.get_profile().phone == "":
return HttpResponseRedirect('/phone')
else:
add_list = add.objects.all()
ctx = {'last_login':request.session.get('social_auth_login_backend')}
return render_to_response("homepage.html", {'add_list': add_list, 'ctx':ctx}, context_instance=RequestContext(request))
和模型:
class customuser(models.Model):
last_login = models.DateTimeField(blank=True, null=True)
is_active = models.BooleanField()
nickname = models.CharField(max_length=255)
regdate = models.DateField(auto_now=True)
phone = models.CharField(max_length=255)
user = models.OneToOneField(User)
city = models.ForeignKey(locations, null=True)
def __str__(self):
return "%s user " % self.user
def create_user_profile(sender, instance, created, **kwargs):
if created:
profile, created = customuser.objects.get_or_create(user=instance)
post_save.connect(create_user_profile, sender=User)
class Admin:
pass