help, How can i solve this error please

2018-07-07 Thread Hambali Idrees Ibrahim






-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/667914ce-d796-4a75-9a55-654508c7ee7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


AttributeError:

2018-07-07 Thread Hambali Idrees Ibrahim
 

from django.conf.urls import url
from . import views
from django.contrib.auth import login, logout



urlpatterns = [
url(r'^$', views.home),
url(r'^login/$', login, {'template_name': 'accounts/login.html'}),
url(r'^logout/$', logout, {'template_name': 'accounts/logout.html'}),
url(r'^register/$', views.register, name='register')
]








File "C:\Users\Hambadrees\django\toturial\accounts\urls.py", line 11, in 

url(r'^register/$', views.register, name='register')
AttributeError: module 'accounts.views' has no attribute 'register'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a89b1e42-4a0f-4bf6-a9c5-34e724efbf8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to solve it view app.views.register didn't return an HttpResponse object. It returned None instead.

2018-07-13 Thread Hambali Idrees Ibrahim
i think you can use
forms.is_valid():
not
form.is_valid():

it may work

On Fri, Jul 13, 2018 at 11:33 AM, Jason  wrote:

> if form.is_valid():
> form.save()
> return redirect('home')
>
> You don't return anything when the form is invalid.  That's why it returns
> None
>
> On Friday, July 13, 2018 at 3:31:43 PM UTC-4, abhishek dadhich wrote:
>>
>> from django import forms
>> from django.contrib.auth.models import User
>> from django.contrib.auth.forms import UserCreationForm
>>
>> class RegistrationForm(UserCreationForm):
>> email=forms.EmailField(required=True)
>>
>> class Meta:
>> model=User
>> fields ={
>> 'username',
>> 'first_name',
>> 'last_name',
>> 'password1',
>> 'email',
>> }
>> def save(self,commit=True):
>> user = super(RegistrationForm,self).save(commit=False)
>> user.fisrt_name=self.cleaned_data['first_name']
>> user.last_name=self.cleaned_data['last_name']
>> user.emil=self.email.cleaned_data['email']
>>
>> if commit:
>> user.save()
>> return user
>> *This is my form.py file*
>>
>>
>> from django.shortcuts import render,redirect
>> from app.forms import RegistrationForm
>> from django.contrib.auth.forms import UserCreationForm
>> from django.http import HttpResponse
>> from django.views.generic import TemplateView
>> from django.template import loader
>>
>> def register(request):
>> if request.method =='POST':
>> form=RegistrationForm(request.POST)
>> if form.is_valid():
>> form.save()
>> return redirect('home')
>> else:
>> form=RegistrationForm()
>>
>> args={'form':form}
>> return render(request,'reg_form.html',args)
>> *And this is my view.py file*
>>
>>
>> *when I'm pressing the submit button it will show me "view
>> app.views.register didn't return an HttpResponse object. It returned None
>> instead"*
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b11278f8-3b98-4731-a938-029775bb1cf2%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMqGfDGR2hRyGaGfgNSUPi-fzdtnya8ubcRe%2B-fG8jtaO9Z%3DLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.