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
class RegisterForm(forms.ModelForm): | |
first_name = forms.CharField(max_length=User._meta.get_field('first_name').max_length) |
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
class Form(FormView): | |
template_name = 'template.html' | |
form_class = FormClassName | |
success_url = reverse('my_url_name') |
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
class Form(FormView): | |
template_name = 'template.html' | |
form_class = FormClassName | |
success_url = reverse_lazy('my_url_name') |
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
from django import forms | |
from app.models import User | |
from app.forms.widgets import * | |
class RegisterBaseForm(forms.ModelForm): | |
username = forms.CharField(max_length=User._meta.get_field('username').max_length) | |
email = forms.CharField(max_length=User._meta.get_field('email').max_length, widget=HTML5EmailInput()) | |
password = forms.CharField(min_length=6, max_length=16, widget=forms.PasswordInput()) |
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
from django import forms | |
from base import * | |
from app.models import User | |
class RegisterEmailForm(RegisterBaseForm): | |
first_name = forms.CharField(max_length=User._meta.get_field('first_name').max_length) | |
last_name = forms.CharField(max_length=User._meta.get_field('last_name').max_length) |
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
from django.db import models | |
class BlogManager(models.Manager): | |
def get_tags(self): | |
# get just the tags | |
tags = self.values('tags') |
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
<?php | |
namespace NewCoInc\AppBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use NewCoInc\AppBundle\Lib\FormattingLib; | |
/** | |
* Blog |
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
<?php | |
namespace NewCoInc\AppBundle\Entity; | |
use Doctrine\ORM\EntityRepository; | |
class BlogRepository extends EntityRepository | |
{ | |
public function getTags() | |
{ |
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
class RegisterView(FormView): | |
template_name = 'register.html' | |
form_class = RegisterForm | |
success_url = reverse_lazy('home') | |
# add the request to the kwargs | |
def get_form_kwargs(self): | |
kwargs = super(RegisterView, self).get_form_kwargs() | |
kwargs['request'] = self.request |
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
class RegisterForm(forms.ModelForm): | |
username = forms.CharField(max_length=User._meta.get_field('username').max_length) | |
email = forms.CharField(max_length=User._meta.get_field('email').max_length, widget=HTML5EmailInput()) | |
password = forms.CharField(min_length=6, max_length=16, widget=forms.PasswordInput()) | |
# the request is now available, add it to the instance data | |
def __init__(self, *args, **kwargs): | |
self.request = kwargs.pop('request') | |
super(RegisterForm, self).__init__(*args, **kwargs) |