我无法得到我的静态文件.我尝试了各种设置和目录配置等等,但它们只是变成404s.我安装了debug_toolbar,因此知道STATIC_URL正在到达我的请求上下文.
目录结构显示/静态(我还将目录放在饭菜app文件夹和用户内部,只是为了试一试.
/mealmate
/mealmate
/meals
/static
/css
/bootstrap.min.css
/templates
/users
Run Code Online (Sandbox Code Playgroud)
Settings.py(一些重要的设置,虽然我已尝试过各种其他设置):
MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media/')
STATIC_URL = '/static/'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
)
WSGI_APPLICATION = 'mealmate.wsgi.application'
Run Code Online (Sandbox Code Playgroud)
在base.html中呈现
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢
我正在拼命尝试在xampp上获取phpmyadmin访问Linux 1.8.0 for ubuntu 12.04 LTS.我知道这是一个常见的问题,但我已经在网上尝试了很多线程,而且我仍然坚持不懈.
Xampp似乎运行正常,localhost启动页面很好,包括侧栏中的phpmyadmin链接.当我按照该链接时,我收到403错误:
访问被禁止!
新的XAMPP安全概念:
只能从本地网络访问所请求的目录.
可以在文件"httpd-xampp.conf"中配置此设置.
如果您认为这是服务器错误,请与网站管理员联系.
错误403
localhost Apache/2.4.2(Unix)OpenSSL/1.0.1c PHP/5.4.4
我已经尝试了很多东西,包括修改httpd-xampp.conf,其相关部分现在看起来像:http://pastebin.com/J4f4tNVs
我的/opt/lampp/phpmyadmin/config.inc.php看起来像:http://pastebin.com/5PZPXK5s
按照其他说明,我改变了/ lampp的所有权:
chown -Rv nobody:root ./lampp/*
Run Code Online (Sandbox Code Playgroud)
请帮我!
谢谢,马特
我如何调试我的测试?例如,我POST以创建一个条目,并期望它验证并返回一个特定的页面.它适用于浏览器和shell,但测试是唯一失败的(具有讽刺意味!).我想将响应打印到控制台或其他东西,以便我可以读取错误或你有什么.但我只能看到我print在视图中看到的东西.
不确定是否有必要,但这里是有问题的测试代码tests.py:
resp = self.client.post('/meal/invite/',
{'summary': 'Test munch', 'when': now(), 'max_diners': '1', 'description': 'Munchies'}, follow=True)
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, 'Test munch', 1)
self.assertContains(resp, 'You are hosting this meal', 1)
Run Code Online (Sandbox Code Playgroud)
最后的断言是不正确的.如果我将其更改为原始表单页面中显示"字段必需"错误的值,则会通过.我只是看不到我错过的东西.
我有一些其他测试工作,但我只是不知道如何调试这个.
怎么做?
我试图应用第一次南迁移时遇到错误.我尝试了各种建议(比如在迁移文件夹中删除.pyc文件,转换应用程序以及尝试重新启动它,其他小提琴).这里有人可以建议我做什么吗?谢谢
(env)~/code/django/ssc/dev/ssc/ssc> python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 108, in handle
ignore_ghosts = ignore_ghosts,
File "/usr/local/lib/python2.7/dist-packages/south/migration/__init__.py", line 166, in migrate_app
Migrations.calculate_dependencies()
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 228, in calculate_dependencies
migration.calculate_dependencies()
File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 362, in calculate_dependencies
for migration …Run Code Online (Sandbox Code Playgroud) 我在ManyToMany关系中有两个模型(Event和UserProfile).我想只选择那些与其关联的用户数少于一定数量的事件.因此,应该选择迄今为止少于4人注册的活动.
在views.py中我有这样的东西,但它不起作用:
proposed_event_list = Event.objects.all().filter(userprofile__lt=4)
Run Code Online (Sandbox Code Playgroud)
models.py的相关部分如下所示:
class Event(models.Model):
name = models.CharField(max_length=100)
date = models.DateTimeField('Event date')
class UserProfile(models.Model):
user = models.OneToOneField(User)
event_commitments = models.ManyToManyField(Event, null=True, blank=True)
Run Code Online (Sandbox Code Playgroud)
我想我没有正确地过滤每个事件上的所有Userprofiles,但我不知道该怎么做.
你能帮我吗?
我试图根据以下内容扩展django-registration注册表:
Python/Django django-registration添加了一个额外的字段
但我得到了:
current transaction is aborted, commands ignored until end of transaction block
在调试中我在建议中添加了一个断点regbackend.py,表明破坏的代码位于:
from crewcal.models import UserProfile
from forms import *
def user_created(sender, user, request, **kwargs):
form = CustomRegistrationForm(request.POST)
data = UserProfile(user=user)
import ipdb; ipdb.set_trace();
data.locality = form.data["locality"]
data.save()
from registration.signals import user_registered
user_registered.connect(user_created)
Run Code Online (Sandbox Code Playgroud)
问题(如下)可能与我在我的定义中创建用户配置文件的方式有关models.py:
def create_user_profile(sender, instance, created, raw, **kwargs):
if created and not raw:
print vars(instance)
UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
User.profile = property(lambda u: UserProfile.\
objects.get_or_create(user=u)[0])
Run Code Online (Sandbox Code Playgroud)
在regbackend.py上面列出的断点产生的shell中,我可以产生:
> …Run Code Online (Sandbox Code Playgroud) 部署到 Heroku 时出现此错误:
2014-05-07T11:50:06.927955+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=staging.mysite.com request_id=eead056c-f89d-4fcd-b282-71a023631a71 fwd="80.237.234.148" dyno=web.1 connect=1ms service=4ms status=500 bytes=238
2014-05-07T11:50:06.925723+00:00 app[web.1]: 2014-05-07 06:50:06 [7] [ERROR] Error handling request
2014-05-07T11:50:06.925732+00:00 app[web.1]: Traceback (most recent call last):
2014-05-07T11:50:06.925746+00:00 app[web.1]: urlconf = settings.ROOT_URLCONF
2014-05-07T11:50:06.925735+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 126, in handle_request
2014-05-07T11:50:06.925738+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2014-05-07T11:50:06.925740+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
2014-05-07T11:50:06.925742+00:00 app[web.1]: response = self.get_response(request)
2014-05-07T11:50:06.925744+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 82, in get_response
2014-05-07T11:50:06.925751+00:00 app[web.1]: return func(self._wrapped, *args)
2014-05-07T11:50:06.925749+00:00 app[web.1]: File …Run Code Online (Sandbox Code Playgroud) 我正在尝试测试我的应用程序但不确定如何在测试环境中配置django-allauth.我正进入(状态:
ImproperlyConfigured: No Facebook app configured: please add a SocialApp using the Django admin
到目前为止,我的方法是tests.py使用实际的Facebook应用程序参数实例化app对象,这是一个在浏览器中本地正常运行的应用程序:
from allauth.socialaccount.models import SocialApp
apper = SocialApp.objects.create(provider=u'facebook',
name=u'fb1', client_id=u'7874132722290502',
secret=u'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
apper.sites.create(domain='localhost:8000', name='creyu.org')
Run Code Online (Sandbox Code Playgroud)
我怎样才能运行这些测试?谢谢
我想从 Meteor 集合中获取随机排序的集合。最好/最有效的方法是什么?
我目前正在使用下划线 _.shuffle,它非常简洁,例如:
Template.userList.helpers({
users: function() {
return _.shuffle(Meteor.users.find().fetch());
}
});
Run Code Online (Sandbox Code Playgroud)
我使用 Jade,所以也许模板级别有一个选项?
我的django项目有一个虚拟环境,但是当我点击时pip freeze,我会得到一个全球站点软件包列表,其中包括太多的软件包,例如ubuntu软件包和许多无关紧要的东西。无论virtualenv是否处于活动状态,都会发生这种情况。我的网站软件包列表看起来也有些苗条,所以我想知道venv是否一直在工作。
(env)~/code/django/ssc/dev/env/lib/python2.7/site-packages> ls
django
Django-1.4-py2.7.egg-info
easy-install.pth
pip-1.0.2-py2.7.egg
setuptools-0.6c11-py2.7.egg
setuptools.pth
Run Code Online (Sandbox Code Playgroud)
我怎么了
django ×7
python ×4
testing ×2
count ×1
django-south ×1
facebook ×1
filter ×1
heroku ×1
linux ×1
many-to-many ×1
meteor ×1
phpmyadmin ×1
pip ×1
postgresql ×1
random ×1
registration ×1
settings ×1
sorting ×1
static ×1
transactions ×1
ubuntu ×1
unit-testing ×1
views ×1
virtualenv ×1
xampp ×1