我有意见.py
def status_set(request):
ip_address= request.META['REMOTE_ADDR']
if request.method == "POST":
rform = registerForm(data = request.POST)
if rform.is_valid():
register = rform.save(commit=False)
register.user=request.user
register.save()
return render_to_response('home.html')
else:
rform = registerForm()
return render_to_response('status_set.html',{'rform':rform})
在 forms.py 我有
from django.contrib.gis.utils import GeoIP
class registerForm(forms.ModelForm):
class Meta:
model=register
fields = ('Availability', 'Status')
def save(self,ip_address, *args, **kwargs):
g = GeoIP()
lat, lon = g.lat_lon('ip_address')
user_location = super(registerForm, self).save(commit=False)
user_location.latitude = lat
user_location.longitude = lon
user_location.save(*args, **kwargs)
当我试图提交它说的表格时
/status-set/save() 处的 TypeError 至少需要 2 个非关键字参数(给定 1 个)我无法找到解决方案。这可能是什么原因我认为我必须将 IP 地址作为参数传递任何建议