小编mja*_*jaz的帖子

/ admin /中的Django ValueError

我正在生产的Red Hat Linux机器上运行带有mod_python的Django.不久之前,由于我不知道的原因,管理员停止工作,抛出500错误.错误如下:

ValueError at /admin/
Empty module name
Request Method: GET
Exception Type: ValueError
Exception Value: 
Empty module name
Exception Location: /usr/local/lib/python2.6/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /usr/bin/python
Python Version: 2.6.2
Run Code Online (Sandbox Code Playgroud)

有没有人遇到过这个?我完全不知道如何解决这个问题.

感谢您的任何帮助.

python django django-admin

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

Django在标题周围发送电子邮件

我在Django中为客户编写了一个简单的联系表单.但是,无论何时发送电子邮件,它都会将标头值包装在u''对象中.例如,From:标题是

From: (u'my@email.com',)
Run Code Online (Sandbox Code Playgroud)

这是发送消息的代码:

表格:

class ContactForm(forms.Form):
  name = forms.CharField(max_length=100)
  sender = forms.EmailField()
  subject = forms.CharField(max_length=255)
  message = forms.CharField(widget=forms.widgets.Textarea(attrs={'rows':15, 'cols': 72}))
Run Code Online (Sandbox Code Playgroud)

联系功能:

def contact(request):
  RECAPTCHA_PRIVATE_KEY = '******************'
  captcha_error = ''
  if request.method == 'POST':
    form = ContactForm(request.POST)
    captcha_response = captcha.submit(request.POST.get("recaptcha_challenge_field", None),
                      request.POST.get("recaptcha_response_field", None),
                      RECAPTCHA_PRIVATE_KEY,
                      request.META.get("REMOTE_ADDR", None))

    if not captcha_response.is_valid:
      captcha_error = "&error=%s" % captcha_response.error_code
    elif form.is_valid():
      name = form.cleaned_data['name'],
      sender = form.cleaned_data['sender'],
      subject = form.cleaned_data['subject'],
      message = form.cleaned_data['message']

      recipients = ['email@email.com']
      try:
        send_mail(subject, message, sender, recipients)
      except BadHeaderError:
        pass

      flash_message …
Run Code Online (Sandbox Code Playgroud)

python email django

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

标签 统计

django ×2

python ×2

django-admin ×1

email ×1