Python 提交按钮在django的模式注册表中不起作用

Python 提交按钮在django的模式注册表中不起作用,python,django,forms,form-submit,bootstrap-modal,Python,Django,Forms,Form Submit,Bootstrap Modal,我几乎试过了所有的方法,现在已经被这个愚蠢的问题困扰了好几天了。因此,我试图在Django1.8中创建一个模式弹出式登录/注册页面。我已经设法创建了所有东西,除了当我点击注册表的提交按钮时,它不起作用。谁能帮帮我吗。下面是我的代码: model.py forms.py views.py url.py index.html ###当您单击下面的链接时,将打开一个模式表单,然后完成注册 ###modal的代码从这里开始 #我尚未创建此视图 {%csrf_令牌%} {{form

我几乎试过了所有的方法,现在已经被这个愚蠢的问题困扰了好几天了。因此,我试图在Django1.8中创建一个模式弹出式登录/注册页面。我已经设法创建了所有东西,除了当我点击注册表的提交按钮时,它不起作用。谁能帮帮我吗。下面是我的代码:

model.py

forms.py

views.py

url.py

index.html

  • ###当您单击下面的链接时,将打开一个模式表单,然后完成注册
###modal的代码从这里开始
  • #我尚未创建此视图
{%csrf_令牌%} {{form.as_p}} 接近
表单操作属性为空,因此在提交表单时不会发生任何情况。您应该将表单更改为要传递数据的位置。

是。在将其留空之前,我尝试将其与视图链接。它仍然不起作用。在实际操作中,我添加了“/my_app/myRegistration/”,但提交按钮仍然不起作用:(像这样尝试/register/nope。它什么也没做。你认为我应该添加一个Javascript,让它调用视图吗?
class UserProfile(models.Model):
    user = models.OneToOneField(User)
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    def create_user_callback(sender, instance, **kwargs):
        UserProfile. new = UserProfile.objects.get_or_create(user=instance)
    post_save.connect(create_user_callback, User)
 class RegistrationForm(ModelForm):
    username = forms.CharField(help_text="Please Enter a Name")
    email = forms.EmailField(help_text="Please Enter your Email")
    password = forms.CharField(widget=forms.PasswordInput(), help_text="Please Enter a Password")
    password2 = forms.CharField(widget=forms.PasswordInput(), help_text="Verify Password")

    class Meta:
        model = UserProfile
        fields = ('username', 'email', 'password', 'password2')

    def clean_username(self):
        username = self.cleaned_data['username']
        try:
            User.objects.get(username=username)
        except User.DoesNotExist:
            return username
        raise forms.ValidationError("That username is already taken, Please try registering by a different username")

    def clean(self):
            if self.cleaned_data['password'] != self.cleaned_data['password2']:
                    raise forms.ValidationError("The passwords did not match.  Please try again.")
            return self.cleaned_data
def myRegistration(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/profile/')
    if request.method=='POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
                user = User.objects.create_user(username=form.cleaned_data['username'], email = form.cleaned_data['email'], password = form.cleaned_data['password'])
                user.save()
                launchers = user.get_profile()
                launchers.name = form.cleaned_data['name']
                launchers.save()
                return HttpResponseRedirect('/profile/')
        else:
                return render_to_response('index.html', {'form': form}, context_instance=RequestContext(request))
    else:
        '''user is not submitting the form. show them a blank registration form'''
        form=RegistrationForm()
        context = {'form':form}
        return  render_to_response('index.html', context, context_instance=RequestContext(request))
(r'^register/$', 'authentication.views.myRegistration'),
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>### when you click on the bellow link a modal form opens and then registration is done
                        <a class="page-scroll" data-toggle="modal" href="login.html" data-target="#myModal">Register/Login</a> 

                    </li>
                </ul>
            </div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-hidden="true"> ### The code for modal starts here
    <div class="modal-body">
        <ul id="myTab" class="nav nav-tabs">
            <li><a href="#signin" data-toggle="tab">Sign In</a></li> #I have yet to create this view
            <li><a href="#signup" data-toggle="tab">Register</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane fade" id="signup">
                <form id="user_form" class="form-horizontal" action="" method="post"
                        enctype="multipart/form-data">
                    {% csrf_token %}
                        {{ form.as_p }}
                        <div class="control-group">
                        <label class="control-label" for="confirmsignup"></label>
                            <div class="controls">
                                <input id="confirmsignup" type="submit" name="confirmsignup" class="btn btn-success" value="Submit" />
                            </div>
                        </div>
                </form>
            </div>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
</div