V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
advid
V2EX  ›  Python

第11行总是提示invalid syntax错误,实在是找不出哪错了,大家帮忙看看,谢谢了

  •  
  •   advid · Oct 3, 2011 · 7673 views
    This topic created in 5332 days ago, the information mentioned may be changed or developed.
    def register_page(request):
    if request.method == 'POST':
    form = RegistrationForm(request.POST)
    if form.is_valid():
    user = User.objects.create_user(
    username=form.clean_data['username'],
    password=form.clean_data['password1'],
    email=form.clean_data['email']
    )
    return HttpResponseRedirect('/accounts/register/success/')
    else:
    form = RegistrationForm()
    variables = RequestContext(request, {'form': form})
    return render_to_response ('registration/register.html',variables)
    10 replies    1970-01-01 08:00:00 +08:00
    keakon
        1
    keakon  
       Oct 3, 2011
    第10行return的缩进错了,少了个tab
    advid
        2
    advid  
    OP
       Oct 3, 2011
    帖上来缩进乱了,我截的图:http://221.1.82.253/else.jpg
    morphinewan
        3
    morphinewan  
       Oct 3, 2011
    正如@keakon所说,少了缩进了
    chone
        4
    chone  
       Oct 3, 2011
    为什么不找一个语法检查器
    advid
        5
    advid  
    OP
       Oct 3, 2011
    第10行缩进改过来了,又出现错误提示“global name 'RegistrationForm' is not defined” ?晕菜了
    advid
        6
    advid  
    OP
       Oct 3, 2011
    @chone 额是菜鸟,推荐个语法检查器吧
    chone
        7
    chone  
       Oct 3, 2011
    @advid google不到么?你用的是什么编辑器?
    advid
        8
    advid  
    OP
       Oct 3, 2011
    @chone 我用的notepad++
    advid
        9
    advid  
    OP
       Oct 3, 2011
    封贴,找到错误了,谢谢大家,呵呵
    stillwater
        10
    stillwater  
       Apr 4, 2012
    我也遇到这个错误了 请问下是怎么解决的,谢谢。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3038 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 13:35 · PVG 21:35 · LAX 06:35 · JFK 09:35
    ♥ Do have faith in what you're doing.