小编Yan*_*ick的帖子

Ruby gem权限使用Ubuntu拒绝/ var/lib/gems

我正在尝试使用Gem安装Rails并从终端执行以下操作:

sudo apt-get install ruby-full build-essential
sudo apt-get install rubygems
export PATH=/var/lib/gems/1.8/bin:$PATH
gem install rails
Run Code Online (Sandbox Code Playgroud)

然后我收到以下消息:

错误:执行gem时...(Errno:EACCES)权限被拒绝 - /var/lib/gems

我遵循了Ubuntu帮助指南中的说明,我使用Oracle VM VirtualBox在Windows 7下运行Ubuntu,并使用RubyGems v1.8.15.

ruby ubuntu gem

40
推荐指数
1
解决办法
3万
查看次数

关系"django_content_type"的Django列"名称"不存在

我在进行迁移时遇到以下错误(python manage.py migrate):

django.db.utils.ProgrammingError: column "name" of relation "django_content_type" does not exist
Run Code Online (Sandbox Code Playgroud)

我已经做了以下尝试修复它但没有成功:

  1. 我删除了每个模型的所有迁移文件
  2. 删除了django_migrations中的所有记录
  3. 运行python manage.py migrate --fake-initial

运行Django 1.8.2.

python manage.py showmigrations
admin
 [ ] 0001_initial
auth
 [ ] 0001_initial
 [ ] 0002_alter_permission_name_max_length
 [ ] 0003_alter_user_email_max_length
 [ ] 0004_alter_user_username_opts
 [ ] 0005_alter_user_last_login_null
 [ ] 0006_require_contenttypes_0002
contenttypes
 [X] 0001_initial
 [ ] 0002_remove_content_type_name
hashtags
 [ ] 0001_initial
 [ ] 0002_hashtagvisit_user
posts
 [ ] 0001_initial
 [ ] 0002_auto_20150530_0715
sessions
 [ ] 0001_initial
users
 [ ] 0001_initial
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助.

django django-models

29
推荐指数
4
解决办法
3万
查看次数

元素的SELECT SELECT = yes

我希望能够在select元素的倍数为false时为其定义高度

select{height: 30px;}
Run Code Online (Sandbox Code Playgroud)

但是当select具有multiple = yes时,我不希望它被应用.

可以在CSS中定义吗?

css css-selectors

27
推荐指数
1
解决办法
5万
查看次数

gunicorn.errors.HaltServer:<HaltServer'Worker无法启动.3>

我已经在我的virtualenv中安装了gunicorn.

从这个目录:

manage.py
/onbytes/wsgi.py
Run Code Online (Sandbox Code Playgroud)

我执行以下操作:

gunicorn onbytes.wsgi:application
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Traceback (most recent call last):
  File "/home/ymorin007/.virtualenvs/onbytes.com/bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==19.0.0', 'console_scripts', 'gunicorn')()
  File "/home/ymorin007/.virtualenvs/onbytes.com/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/home/ymorin007/.virtualenvs/onbytes.com/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 166, in run
    super(Application, self).run()
  File "/home/ymorin007/.virtualenvs/onbytes.com/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
    Arbiter(self).run()
  File "/home/ymorin007/.virtualenvs/onbytes.com/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 169, in run
    self.manage_workers()
  File "/home/ymorin007/.virtualenvs/onbytes.com/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
    self.spawn_workers()
  File "/home/ymorin007/.virtualenvs/onbytes.com/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 537, in spawn_workers
    time.sleep(0.1 * random.random())
  File "/home/ymorin007/.virtualenvs/onbytes.com/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
    self.reap_workers()
  File "/home/ymorin007/.virtualenvs/onbytes.com/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, …
Run Code Online (Sandbox Code Playgroud)

python gunicorn

22
推荐指数
3
解决办法
3万
查看次数

django为admin.TabularInline管理多个ForeignKey

我正在尝试在管理部分中实现带有子表单的表单.

form = Fighter()
subform = FighterFightHistory() //All of his fights
Run Code Online (Sandbox Code Playgroud)

我的问题如下:

<class 'fighters.admin.Fights'>: (admin.E202) 'fighters.FighterFightHistory' has more than one ForeignKey to 'fighters.Fighter'.
Run Code Online (Sandbox Code Playgroud)

那么如何让表单显示每个外键(fighter,opponent)的下拉列表.

2个外键是(见下文):

  • 战斗机的链接(fighter)
  • 对手的链接(opponent)

战士/ models.py

class FighterFightHistory(TimeStampedModel):
    event = models.ForeignKey('events.Event', null=True)
    fight = models.ForeignKey('fights.Fight', null=True)
    fighter = models.ForeignKey(Fighter, related_name='%(app_label)s_%(class)s_fighter', null=True)
    howitended = models.ForeignKey('fights.HowItEnded', null=True)
    opponent = models.ForeignKey(Fighter, related_name='%(app_label)s_%(class)s_opponent', null=True)

    ended_in_round = models.IntegerField(blank=True, null=True)
    youtube_code = models.CharField(max_length=50, null=True, blank=True)
    win = models.NullBooleanField(blank=True, null=True)
Run Code Online (Sandbox Code Playgroud)

战士/ admin.py

class Fights(admin.TabularInline):
    model = …
Run Code Online (Sandbox Code Playgroud)

django django-admin

15
推荐指数
1
解决办法
6398
查看次数

Django'dict'对象没有属性'user_id'

我得到以下错误'dict'对象没有属性'user_id'但不确定我理解错误.由于user_id可从查询集中获得.

错误发生在最后一行代码中

users_who_played = UserEvent.objects\
            .values('user_id')\
            .annotate(total_season_points=Sum('points'))\
            .filter(event__season_id=season.id)\
            .order_by('-total_season_points')\

    for i, user_who_played in enumerate(users_who_played):

        try:
            user = UserSeason.objects.
                   get(user=user_who_played.user_id, season=season.id)
Run Code Online (Sandbox Code Playgroud)

django django-views

10
推荐指数
1
解决办法
2万
查看次数

Django NameError:未定义名称"bPath"

我正在运行Django 1.7,当我运行python manage.py migrate时,我收到以下错误

      File "/home/ymorin007/workspace/sites/jantiyes.com/src/deeds/migrations/0006_auto_20141204_1631.py", line 9, in <module>
    class Migration(migrations.Migration):
  File "/home/ymorin007/workspace/sites/jantiyes.com/src/deeds/migrations/0006_auto_20141204_1631.py", line 19, in Migration
    field=models.ImageField(storage=django.core.files.storage.FileSystemStorage(location=bPath('/home/ymorin007/workspace/sites/jantiyes.com/src/media')), max_length=255, null=True, upload_to=deeds.models.picture_name, blank=True),
NameError: name 'bPath' is not defined
Run Code Online (Sandbox Code Playgroud)

这是我的行为/ models.py

from jantiyes.settings.base import MEDIA_ROOT

upload_storage = FileSystemStorage(location=MEDIA_ROOT)

def picture_name(self, filename):

    ext = filename.split('.')[-1]
    deedname = re.sub('[ ]', '-', self.text.lower())
    filename = "DEED-%s-%s.%s" % (self.id, deedname, ext)

    url = "%s" % filename

    return url


class Deed(TimeStampedModel):

    picture = models.ImageField(upload_to=picture_name, null=True, blank=True, storage=upload_storage, max_length=255)
    text = models.CharField(max_length=500)
    when = models.DateField(unique=True)
Run Code Online (Sandbox Code Playgroud)

我的媒体宣言: …

django django-models

6
推荐指数
1
解决办法
894
查看次数

Django:字段模型实例的默认值

我正在尝试获取新创建的用户的last_name和first_name,并使用这两个值创建foldername.

但我得到类型对象'用户'没有属性'first_name'

这是我的用户型号:

def create_folder_name(first_name, last_name):
    return first_name + last_name


class User(AbstractUser):
    folder_name = models.CharField(max_length=255, unique=True,
                                   default=create_folder_name(User.first_name, User.last_name))
Run Code Online (Sandbox Code Playgroud)

如何将User.first_name传递给我的函数

django django-models

5
推荐指数
1
解决办法
1750
查看次数

jquery从特定id中删除特定元素

我有2个像这样的div:

<div id="container1"><input class="1"><input class="2"></div>

<div id="container2"><input class="1"><input class="1"><input class="2"></div>
Run Code Online (Sandbox Code Playgroud)

现在我如何删除所有class ="1"但仅从container2中删除.

jquery

4
推荐指数
1
解决办法
2万
查看次数

使用CSS重现图像形状

我正在尝试仅使用css重现此图像

在此输入图像描述

我玩过半径属性,但你会看到我没有得到相同的角度效果.

.shape{
background-color: black;
opacity:0.9;
filter:alpha(opacity=90); /* For IE8 and earlier */    
    color:white;
    font-weight:bold;
    padding: 30px 30px 30px 50px;
    text-align:center;
    position:absolute;
    right:0;
    bottom:0;
    z-index:1003;
    font-size: 20px;    
    border-top-left-radius: 125px;
    -moz-border-radius-topright: 125px;
}
?
Run Code Online (Sandbox Code Playgroud)

你可以在http://jsfiddle.net/ymorin007/7qX4U/看到我的尝试.

谢谢.

css css3 css-shapes

4
推荐指数
1
解决办法
533
查看次数