from django import forms
from django.core.validators import RegexValidator

from bigsansar.contrib.sites.models import domains


class create_domainform(forms.ModelForm):
    domain = forms.CharField(max_length=100, min_length=3, validators=
        [RegexValidator('^[a-z0-9.]+\.[a-z0-9]{1,5}$', message='Please enter your correct domain name')],
                             widget=forms.TextInput(attrs={'autofocus': True, 'class': 'form-control', }))


    class Meta:
        model = domains
        fields = ('user', 'domain',)
