user=Profile.objects. get (user=request.user) .save () redirect (self.get_absolute_url ())
get_absolute_url (self): reverse («profile», kwargs={})
ProfileView (CreateView): _ name=«profile/profile.html» _class=BlogFormcreate_object_profile (self, pk):=User.objects.get (pk=pk)=Profile (). user_id=vector.id.first_name=vector.first_name.last_name=vector.last_name.save () objectget_context_data (self, ** kwargs):=super (ProfileView, self) .get_context_data (** kwargs) (self.request.user.is_authenticated ( )) and (Profile.objects.get (pk=self.request.user.id) .party == True) and (not pk in self.kwargs ): _ obj=self.request.userProfile.objects.filter (pk=person_obj.id) .count () == 0: .create_object_profile (person_obj.id) _pk=person_obj.idself.request.user.is_authenticated () and laquo ; pk in self.kwargs and self.kwargs [ pk ]: _ pk=self.kwargs [ pk raquo ;] Profile.objects.filter (pk=person_pk) .count () == 0: .create_object_profile (person_pk) _obj=User.objects.get (pk=person_pk) :. template_name=«profile/error.html» [ laquo ; ErrorText ]=u" Ви не авторизовані »
context [ blog ]=Blog.objects.filter (author=person_obj.username) .order_by ( -number raquo ;, ) [ person ]=Profile.objects.get (pk=person_pk) [ form_file ]=FileFormcontextform_valid (self, form): _ obj_tags=[] _ ??tags=self.request.POST [ tag ]. split ( laquo ;, or laquo ;, ) elem in all_tags: _num_tags=Tags.objects.all (). order_by ( -number ) [0] _tag=Tags (number=max_num_tags.number + 1 , name=elem) _tag.save () _ obj_tags.append (obj_tag)=form.save (commit=False)=Blog.objects.filter (author=self.request.user.username) .order_by ( -number ) blogs.count () gt; 0: .number=blogs [0] .number + 1: .number=1.author=self.request.user.username.date_of_publication=datetime.datetime.now ()=default_storage.save ( uploads/mar.jpg raquo ;, ContentFile (self.request.FILES [ thumbnail ]. read ())) _ image=FileObject (path) .version_generate ( admin_list_blog ). image =obj_image.save () elem in arr_obj_tags: .tags.add (elem) redirect (self.get_absolute_url ()) get_absolute_url (self): reverse («profile», kwargs={}) ProfileSettingView (TemplateView, View): _ name= «user_profile/user_settings.html» _method_names=[ get raquo ;, post ] post (self, request, * args, ** kwargs):=Profile.objects.get (user=request.user)=ProfileForm ( request.POST, request.FILES, instance=object) # A form bound to the POST data ??i> form.is_valid () :. save (commit=False)=default_storage.save ( uploads/mar.jpg raquo ;, ContentFile (request.FILES [ image ]. read ())) _ image=FileObject (path) .version_generate ( profile_photo ). thumbnail=obj_image.save ()
# Новий пароль і подвержденном пароля _password=request.POST [ new_password ] _ password=request.POST [ confirm_password ]
# Вибираємо обьект User для изменеия пароля
index=User.objects.get (pk=request.user.id) .set_password (new_password) new_password == «:
mes= Поле ( новий пароль ) порожньо :
else: confirm_password == new_password:= Паролі збігаються ! .save ( ):
mes= Паролі не збігаються !
form.save () redirect (reverse («profile», kwargs={})) get_context_data (self, ** kwargs):=super (ProfileSettingView, self) .get_context_data (** kwargs) self.request.user.is_authenticated () and Profile.objects.get (pk=self.request.user.id) .party == True:=Profile.objects.get (user=self.request.user) [ object ]=object_id=self.request.user [ form ]=ProfileForm (instance=object) not Profile.objects.filter (pk=user_id.id):=Profile (). pk=user_id.id.user =user_id.save () context: _name=«profile/error.html» [ ErrorText ]=u" Ви не авторизовані »
return context
@ csrf_exemptsearch_person (request):=Nonerequest.user.is_authenticated () and Profile.objects.get (pk=request.user.id) .party == True: ContactFor...