无法从git安装Django应用程序 [英] Can't install Django app from git
问题描述
我尝试通过以下方式安装它:
< blockquote>
pip安装
git + https://github.com /mjbrownie/django-admin_action_mail.git
但是当我将它添加到<$ c时,Django没有选择它$ c> settings.INSTALLED_APPS 。
我错过了什么吗?
该应用的管理代码已被注释掉(请参阅: https://github.com/mjbrownie/django-admin_action_mail/blob/master/admin_action_mail/admin.py )所以没有任何内容会出现在管理页面上 - 即使它是工作和启用。
看起来您需要创建自己的模型来处理邮件功能纳秒。查看自述,它告诉您添加类似在您的应用程序的 admin.py
中:
from admin_action_mail.actions import mail_action
$ b $ class MyModelAdmin(admin.ModelAdmin):
注意所有参数都是可选的
操作= [
mail_action(
'description ':发送电子邮件给相关用户,
'email_dot_path':'email',#点到邮件字段的路径字符串(例如'user.email')
'email_template_html':'admin_action_email / email。 html'
'reply_to':'noreply@example.com'#默认为request.user.email
)
]
admin.site.register(MyModel ,MyModelAdmin)
您是否已将类似模型添加到您自己的应用程序的 admin .py
?
编辑:由于问题似乎与安装有关,因此以下内容应该有所帮助:
您可以为wsgi路径规范添加任意路径,这意味着它会选择Python应用程序模块在其他地方。假设您的应用安装在 / home / user2161049 / myapp
中,您可以将您的外部模块放置在 / home / user2161049 / myapp / external
。在这种情况下,将该应用程序的内容复制到 / home / user2161049 / myapp / external / admin_action_mail /
中。
要添加到 settings.py
:
SITE_ROOT = os。 path.dirname(os.path.realpath(__ file__))
$第一行根据当前正在运行的脚本定义
sys.path.append(os.path.join(SITE_ROOT,'external'))
SITE_ROOT
(setup.py $ b> / code>)。第二个将
外部
文件夹添加到搜索路径中。你可以放任何你想要的东西,甚至可以在别的地方定义一个特定的文件夹,如果你想让你的外部文件脱离你的应用文件夹。重新启动服务器,它应该可以找到应用程序。I'm having trouble installing django-admin_action_mail from git.
I tried to install it via:
pip install git+https://github.com/mjbrownie/django-admin_action_mail.git
But Django did not pick it up when I added it to
settings.INSTALLED_APPS
.Did I miss something?
解决方案The admin code for that app is commented out (see here: https://github.com/mjbrownie/django-admin_action_mail/blob/master/admin_action_mail/admin.py ) so nothing is going to show up on the admin page - even if it's working and enabled.
It looks as though you need to create your own models to handle the mailing functions. Take a look at the README where it tells you to add something like the following in your app's
admin.py
:from admin_action_mail.actions import mail_action class MyModelAdmin(admin.ModelAdmin): #Note all args are optional actions = [ mail_action( 'description' : "Send Email to Related Users", 'email_dot_path' : 'email', # dot path string to email field (eg 'user.email') 'email_template_html' : 'admin_action_email/email.html' 'reply_to' : 'noreply@example.com' # defaults to request.user.email ) ] admin.site.register(MyModel, MyModelAdmin)
Have you added a model like that to your own app's
admin.py
?EDIT: As the problem appears to be with installation, the following should help:
You can add arbitrary paths to your wsgi path spec, that means it will pick up Python app modules in other locations. Assuming your app is installed in
/home/user2161049/myapp
you can put your external modules under/home/user2161049/myapp/external
. In this case copy the contents of that app into/home/user2161049/myapp/external/admin_action_mail/
.To add this to your
settings.py
:SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(SITE_ROOT, 'external'))
The first line defines
SITE_ROOT
based on the current running script (setup.py
) at startup. The second adds theexternal
folder into the search path. You can put anything you want in there, and even define a specific folder somewhere else if you want to keep your externals out of your app folder. Restart the server and it should find the app just fine.这篇关于无法从git安装Django应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!