django-userena删除mugshot [英] django-userena removing mugshot

查看:151
本文介绍了django-userena删除mugshot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个网站,该网站使用userena作为个人资料和注册部分。问题是我正在尝试从编辑个人资料页面中删除mugshot上传部分和个人资料隐私(注册,打开,关闭),以便userena仅使用gravatar,所有个人资料都是公开的。但是在模板中只有

I am building a site which uses userena for the profile and registration part. The problem is that I am trying to remove the mugshot upload part and the profile privacy(registered,open,closed) from edit profile page so that userena uses gravatar only and the profiles are public for all. But in the template there is just

  <fieldset>
  <legend>{% trans "Edit Profile" %}</legend>
  {{ form.as_p }}
   </fieldset>
  <input type="submit" value="{% trans "Save changes" %}" />
  </form>

我正在尝试找出如何编辑这个或者从视图中删除mugshot和隐私的视图形式却没有成功。请帮助?

I am trying to find out how to edit this or the views to remove the mugshot and privacy from the form but without success. Please help?

推荐答案

而不是直接编辑userena表单,您应该将其分配到您自己的forms.py文件(accounts / forms)中。 py),如常见问题,并把usr的上面的url包括在内。这里有一个例子,我使用crispy-form来编辑配置文件表格,以获得良好的引导形式:

Instead of editing userena forms directly you should sub it in your own forms.py file (accounts/forms.py for example) as mentioned in the FAQ and put the url above the userena include. Here is an example where I use crispy-forms to sub class the edit profile form for nice bootstrap forms:

accounts / forms.py / p>

accounts/forms.py

class EditProfileFormExtra(EditProfileForm):
    class Meta:
        model = get_profile_model()
        exclude = ['user', 'mugshot', 'privacy', 'my_custom_field']

    def __init__(self, *args, **kwargs):
        super(EditProfileFormExtra, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_id = 'edit-profile-form'
        self.helper.form_class = 'form-horizontal'
        self.helper.form_method = 'post'
        self.helper.help_text_inline = True
        self.helper.add_input(Submit('submit', _('Save'), css_class='green'))
        self.helper.layout = Layout(
            Field('first_name', placeholder=_("First Name")),
            Field('last_name', placeholder=_("Last Name")),
            Field('language', css_class="chosen"),
            Field('timezone', css_class="chosen"),
        )

accounts / urls.py

urlpatterns = patterns(
    '',
    url(r'^signup/$', 'userena.views.signup', {'signup_form': SignupFormExtra}, name='signup'),
    url(r'^signin/$', 'userena.views.signin', {'auth_form': SigninFormExtra}, name='signin'),
    url(r'^(?P<username>[\.\w-]+)/edit/$', 'userena.views.profile_edit', {'edit_profile_form': EditProfileFormExtra}, name='edit-profile'),
    url(r'^', include('userena.urls')),
)

您可以使用上面的URL中可以看到的任何表单来执行此操作。基本上它在这个网址上说,使用原始模块视图,但用我自己的表单替换表单参数。

You can do this with just about any form as you can see in the urls above. Basically it says at this url, use the original modules view, but replace the form argument with my own form.

这篇关于django-userena删除mugshot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆