<div
id="user"
data-username="{{ user.username }}">
<script>
var _user = document.getElementById('user');
var username = _user.dataset.username;
TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
# insert your TEMPLATE_DIRS here
os.path.join(BASE_DIR, 'templates')
],
# 'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
"django.template.context_processors.i18n",
"django.template.context_processors.request",
"django.template.context_processors.csrf",
"django.template.context_processors.media",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
'loaders': [
# insert your TEMPLATE_LOADERS here
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
],
},
}]
class RegistrationForm(UserCreationForm):
email = forms.EmailField(required=True, widget=forms.TextInput(attrs={'placeholder': 'Электронный адрес'}))
class Meta:
model = User
fields = ('first_name', 'last_name', 'email', 'password1', 'password2')
# clean email field
def clean_email(self):
email = self.cleaned_data["email"]
try:
User.objects.get(email=email)
except User.DoesNotExist:
return email
raise forms.ValidationError('Такой адрес электронной почты уже зарегестрирован.')
# modify save() method so that we can set user.is_active to False when we first create our user
def save(self, commit=True):
user = super(RegistrationForm, self).save(commit=False)
user.username = self.cleaned_data['email']
user.email = self.cleaned_data['email']
if commit:
user.is_active = False # not active until he opens activation link
user.save()
return user
def form_invalid(self, form):
form.add_error(None, u'Вы кто такие? Я вас не звал!');
return super(LoginFormView, self).form_invalid(form)
import requests
from bs4 import BeautifulSoup
url='http://www.yarregion.ru/'
r=requests.get(url+'depts/dcul/default.aspx').text
dcul=BeautifulSoup(r)
img_news=dcul.find('div',{'id': 'WebPartWPQ3'}).find('img').get('src')
file=open('1.jpg', 'wb')
p=requests.get(url+img_news)
file.write(p.content)
file.close()
Я не волшебник я только учусь
var mylist = ["first", "second", "thrid", "fourth", "fifth"];
for (var i = 0; i < mylist.length; i++) {
var button = document.createElement("button");
button.className = mylist[i];
button.textContent = mylist[i];
document.querySelector(".button-list").appendChild(button);
}