This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clean(self): | |
try: | |
User.objects.get(first_name=self.cleaned_data['first_name'], | |
last_name=self.cleaned_data['last_name']) | |
raise forms.ValidationError("Exists already!") | |
except User.DoesNotExist: | |
pass | |
return self.cleaned_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clean_email(self): | |
email = self.cleaned_data.get('email') | |
username = self.cleaned_data.get('username') | |
if email and User.objects.filter( | |
email=email).exclude(username=username).count(): | |
raise forms.ValidationError( | |
"A user with that email already exists") | |
return email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Three methods of getting object's url: | |
<a href='/posts/{{ post.id }}'><p>{{ post.title }}</p></a> (#static) | |
<a href='{% url 'detail' id=post.id %}'><p>{{ post.title|title }}</p></a> | |
<a href='{{ post.get_absolute_url }}'><p>{{ post.title|title }}</p></a> |
NewerOlder