关于Windows问题的Git(Git on Windows problems)
我正在Windows 8上运行Git。 我有Git bash工作没有问题bitbucket。 但是,我只想使用命令提示符。 我可以从命令提示符运行git命令,但由于某种原因,感觉ssh键不同步,几乎如果命令提示符试图使用bash正在使用的东西。 尝试从命令提示符执行简单的git pull时得到的错误是
Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
我从git bash运行命令没有任何问题。 更令人抓狂的是,这是几周前的工作。 我不记得做任何会改变这种情况的事情。 也许最多重启一次。
有任何想法吗?
I am running Git on my Windows 8 vm. I have Git bash working no problem with bitbucket. However, I just want to use Command Prompt. I can run git commands from Command Prompt but for some reason it feels like the ssh keys are out of sync, almost if the command prompt is trying to use something other than what bash is using. The error I get when trying to do a simple git pull from command prompt is
Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
I don't have any issues running the command from git bash. What is even more maddening is that this was working a couple weeks ago. I don't recall doing anything that would have changed this. Maybe a reboot at most.
Any ideas?
原文:https://stackoverflow.com/questions/30769308
最满意答案
正如AKS所说,您需要在django模型中为BMI创建字段,然后使用保存更新视图中的字段。 这是你如何做到的:
class Health(models.Model): Name = models.CharField(max_length=30,null=True,blank=True) Age = models.IntegerField(null=True,blank=True) Weight = models.FloatField(null=True,blank=True) Height = models.FloatField(null=True,blank=True) Sugar = models.FloatField(null=True,blank=True) BMI = models.FloatField(null=True,blank=True) def __str__(self): return self.Name
在你的观点中这样做:
@api_view(['GET']) def my_view(request,id): qs = Health.objects.filter(id = id) df = read_frame(qs) df['x-Mean'] = abs(df['Age'] - df['Age'].mean()) df['1.96*std'] = 1.96*df['Age'].std() df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std() df['BMI'] = df['Weight']/(df['Height']/100)**2 # once the BMI is caluculated update the DB row with the value qs.BMI = df['BMI'] qs.save() a = df.fillna(0) a = a.to_dict(orient = 'records') return Response(a)
尝试这个:
查看功能:
@api_view(['GET']) def my_view(request,id): qs = Health.objects.filter(id = id) l = len(qs) if l>0: for x in qs: df = read_frame(x) df['x-Mean'] = abs(df['Age'] - df['Age'].mean()) df['1.96*std'] = 1.96*df['Age'].std() df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std() df['BMI'] = df['Weight']/(df['Height']/100)**2 # once the BMI is caluculated update the DB row with the value x.BMI = df['BMI'] x.save() a = df.fillna(0) a = a.to_dict(orient = 'records') else: print "no rows exists for the query "
希望这是有用的。
As said by AKS you need to create field for BMI in django models then updat e that field in your views using save. Here is how you do it:
class Health(models.Model): Name = models.CharField(max_length=30,null=True,blank=True) Age = models.IntegerField(null=True,blank=True) Weight = models.FloatField(null=True,blank=True) Height = models.FloatField(null=True,blank=True) Sugar = models.FloatField(null=True,blank=True) BMI = models.FloatField(null=True,blank=True) def __str__(self): return self.Name
In your views do this:
@api_view(['GET']) def my_view(request,id): qs = Health.objects.filter(id = id) df = read_frame(qs) df['x-Mean'] = abs(df['Age'] - df['Age'].mean()) df['1.96*std'] = 1.96*df['Age'].std() df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std() df['BMI'] = df['Weight']/(df['Height']/100)**2 # once the BMI is caluculated update the DB row with the value qs.BMI = df['BMI'] qs.save() a = df.fillna(0) a = a.to_dict(orient = 'records') return Response(a)
Try this:
view function:
@api_view(['GET']) def my_view(request,id): qs = Health.objects.filter(id = id) l = len(qs) if l>0: for x in qs: df = read_frame(x) df['x-Mean'] = abs(df['Age'] - df['Age'].mean()) df['1.96*std'] = 1.96*df['Age'].std() df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std() df['BMI'] = df['Weight']/(df['Height']/100)**2 # once the BMI is caluculated update the DB row with the value x.BMI = df['BMI'] x.save() a = df.fillna(0) a = a.to_dict(orient = 'records') else: print "no rows exists for the query "
Hope this was useful.
相关问答
更多-
在model.py中 from django.db import models # Create your models here. class Teachers(models.Model): teacher_name = models.CharField(max_length=255) def __str__(self): return self.teacher_name class Students(models.Model): teacher = mode ...
-
你真的不能为模型添加字段; 但是你可以将任何属性添加到模型实例中,因为这就是Python的工作原理 - 可以“动态”为对象分配属性; 但这并不是您在场景中所需要的。 您需要构建自定义数据集并将其发送到模板,这在您的视图中很容易完成: results = [] # This is what you will send to the template for location in address.objects.select_related(): data = {} # an empty dicti ...
-
如果你检查CharField class CharField(Field): description = _("String (up to %(max_length)s)") def __init__(self, *args, **kwargs): super(CharField, self).__init__(*args, **kwargs) self.validators.append(validators.MaxLengthValidator(self ...
-
没有内置的方式来做到这一点。 然而,有一些第三方项目将为您做。 两个领先的人称为南方和django进化 ,虽然还有其他各种(包括我参与的一些),分散。 我一定会推荐南方 - 它有一些非常整洁的功能和作品真的很好。 There's no built-in way to do this. However there are a number of third-party projects that will do it for you. The two leading ones are called South ...
-
按模型字段过滤,Django(Filter by model field, Django)[2023-11-24]
“Article.objects.filter(country = country_name)”将返回所有带有country = country_name的Article对象。 "Article.objects.filter(country=country_name)" will return all the Article objects with country = country_name. -
我认为选择应该做什么? class Cast(TimeStampedModel): user = models.ForeignKey(User, unique=True) count = models.PositiveIntegerField(default=1) kind = models.CharField( max_length=7, choices=( ("up", "Up"), ("down", ...
-
正如AKS所说,您需要在django模型中为BMI创建字段,然后使用保存更新视图中的字段。 这是你如何做到的: class Health(models.Model): Name = models.CharField(max_length=30,null=True,blank=True) Age = models.IntegerField(null=True,blank=True) Weight = models.FloatField(null=True,blank=True) ...
-
您必须在增加self.save()之后添加它,以便它实际保存您的更改: def activate(self, license=None): if self.activate_count != 2 and self.license == license: import pdb; pdb.set_trace() self.activate_count += 1 self.save() return T ...
-
用南 pip install South 首先,让你的django模型与你当前的数据库表完全匹配,然后运行: python manage.py schemamigration myapp --initial python manage.py migrate myapp --fake #Make changes to your django model (add new field) python manage.py schemamigration myapp --auto python manage. ...
-
info = Batch.objects.create(season_title ='foo', .....) info2= AssetMetadata.objects.create(material_id ='some') info.material_id.add(info2) 尝试这样的事情 info = Batch.objects.create(season_title ='foo', .....) info2= AssetMetadata.objects.create(material_id =' ...