可以将下一页指定为模态区域中的自模态区域吗?

时间:2017-08-27 12:08:19

标签: html django login modal-dialog self

在模板内部,登录泡沫区域被映射到模态药丸内。 如果正常登录是正常的,它通常会被移到home.However,如果它没有注册或者posal发生在Modal Div区域之外,请根据自定义表单标记泡沫。我想调用一个重新编写的页面如果是未注册的用户和光电,则进入Modal Div区域。 这可能是一个难题,因为它是一名翻译。 我可以解决这个问题吗?

我的酱油低于我。如有必要,可以发布其他帖子。

mysite.urls.py

    from django.conf.urls import url,include
    from django.conf.urls.static import static
    from django.conf import settings

urlpatterns = [
    url(r'^accounts/',include('django.contrib.auth.urls')),
    ] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

view.py

from blog.models import Post
from django.views.generic.base import TemplateView
from django.views.generic.edit import CreateView
from django.contrib.auth.forms import UserCreationForm
from django.core.urlresolvers import reverse_lazy
from django.contrib.auth.decorators import login_required
from django.contrib.auth import get_user_model

UserModel = get_user_model()

# --TemplateView
class HomeView(TemplateView):
    template_name = 'mysite/home.html'

    def get_context_data(self, **kwargs):
        User = get_user_model()
        context= super(HomeView, self).get_context_data(**kwargs)
        context['post_like'] = Post.objects.all()
        return context

class AboutView(TemplateView):
    template_name = 'mysite/about.html'


class UserCreateView(CreateView):
    template_name = 'registration/register.html'
    form_class = UserCreationForm
    success_url = reverse_lazy('register_done')

class UserCreateDoneTV(TemplateView):
    template_name = 'registration/register_done.html'

class LoginRequiredMixin(object):
    @classmethod
    def as_view(cls,**initkwargs):
        view = super(LoginRequiredMixin, cls).as_view(**initkwargs)
        return login_required(view)

base.html文件

<script type="text/javascript">


/* login modal */
     jQuery(function($){
    $('#loginmodalbutton').click(function(){
        $('#myModal').find('.modal-content').load("{% url 'login' %}");
        $('#myModal').modal();
        });
    });
</script>
<!---- base top menu -->>
<header>
    <div class="w3-top w3-text-orange w3-animate-opacity" style="z-index:100;">
        <div class="w3-bar" id="myNavbar">
            <a style="text-decoration:none" class="w3-bar-item w3-button w3-hide-small w3-right w3-hover-red" id="loginmodalbutton">로그인</a>
    </div>
</header>

登记/ login.html的

<div class="w3-card-4 w3-text-black w3-animate-top" style="max-width:auto">
    <div class="w3-center">
        <span onclick="document.getElementById('myModal').style.display='none'" class="w3-button w3-xlarge w3-transparent w3-display-topright" title="창닫기">×</span>
        <img src='' alt="회원 로그인" class="w3-margin-top">
        <br>
    </div>
    <br>
    <form class="w3-container" action="{% url 'login' %}" target="#myModal" method="post" id="login_form">
        {% csrf_token %}
        {% if form.errors %}
        <p class="errornote">비밀번호는 영문자를 포함한 8자리 이상으로 입력하세요.</p>
        {% endif %}
        <div class="w3-section">
            <label for="{{ form.username.id_for_label }}"><b>아이디</b></label>
            <input class="w3-input w3-border w3-margin-bottom" type="text" id="{{ form.username.id_for_label }}" name="{{ form.username.html_name }}" placeholder="아이디를 입력하세요.">
            <label for="{{ form.password.id_for_label }}"><b>비밀번호</b></label>
            <input class="w3-input w3-border" type="password" id="{{ form.password.id_for_label }}" name="{{ form.password.html_name }}" placeholder="비밀번호를 입력하세요.">
            <input type="submit" class="w3-button w3-block w3-green w3-section w3-padding" value="로그인"/>
        </div>
        <input class="w3-check w3-margin-top" type="checkbox" checked="checked"> 아이디 저장

        <div class="w3-container w3-border-top w3-padding-16 w3-light-grey">
            <button onclick="document.getElementById('modal').style.display='none'" type="button" class="w3-button w3-red">Cancel</button>
            <span class="w3-right w3-padding w3-hide-small"><a href="#">아이디와 비밀번호를 잊어 버리셨나요? </a></span>
        </div>
    </form>
</div>

0 个答案:

没有答案