I had an issue where the password field didn't match the password field
used in the default User Model Admin.
This fixed that issue:
https://stackoverflow.com/questions/73816296/password-field-is-visible-and-not-encrypted-in-django-admin-site
Hope it helps somebody else!
On Thursday, September
I think the answer you need is available through the docs,
at
https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#changing-the-queryset
(I point to that because it does a much better job of explaining the answer
than I can).
You're passing in an object - an instantiated form -
Hello,
I have my ModelForm... and I need to filter my products with Current User..
if a change my modelform init, doesn't show me any error, but when I use
in my inlineformset, show me on error..
Here is my code:
View:
ofertasinlineformset = inlineformset_factory(Assinatura, Ofertas,
Finally overrite a UserAdmin ModelAdmin:
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.utils.translation import ugettext, ugettext_lazy as _
from django.core.exceptions import PermissionDenied
class UserAdmin(admin.ModelAdmin):
I want to collects current user in model signal pre_save, to prevent remove
super user permission to current super users.
As I have now so I can not give administrative privileges to a normal user.
from django.db.models.signals import pre_delete, pre_save, post_save
from
Hello, I'have a little problem with this code??
when I'l trying to put :
" def __init__(self, inputUser, *args, **kwargs):"
I have the following error :
__init__() takes at least 2 non-keyword arguments (1 given)
So, I suppose I need to set the inputUser in a specific place, but I
can' figure
Bingo!!!
:D
I follow this:
http://oebfare.com/blog/2008/feb/23/changing-modelchoicefield-queryset/
and now I'm happy with mi desired current user based queryset
Thank you all!
BTW, my form class finally looks like...
---
class SendMessageForm(forms.Form):
recipientUser =
But why don't you put:
recipientUser = ShowValidContactList(currentUser=self.user)
inside the __init__?
- Paulo
2009/8/6 Julián C. Pérez
>
> Thanks for reply, Paulo
> But if I...
> ---
> class SendMessageForm(forms.Form):
>
>recipientUser =
Thanks for reply, Paulo
But if I...
---
class SendMessageForm(forms.Form):
recipientUser = ShowValidContactList(currentUser=self.user,
label=u'Send to')
messageSubject= forms.CharField(label=u'Subject')
messageContent = forms.CharField(label=u'Content',
It doesn't have to be a callable, you can just do something like:
recipientUser = ShowValidContactList(currentUser=self.currentUser)
I never used that kwargs.pop function (I didn't know you could do that),
but I have code like this:
class ExperimentForm(ModelForm):
""" Generate form to
My real problem it that the field should looks like:
---
recipientUser = ShowValidContactList(currentUser=_something_,
label=u'Send to')
---
and if I have a form's init method like...
---
def __init__(self, *args, **kwargs):
self.currentUser = kwargs.pop('currentUser', None)
On Aug 6, 3:34 pm, Julián C. Pérez wrote:
> Hi
> I tried doing that...
> But it does not work
> For example, if I do something like...
> ---
> class SendMessageForm(forms.Form):
> recipientUser = ShowValidContactList(label=u'Send to')
> messageSubject=
Hi
I tried doing that...
But it does not work
For example, if I do something like...
---
class SendMessageForm(forms.Form):
recipientUser = ShowValidContactList(label=u'Send to')
messageSubject= forms.CharField(label=u'Subject')
messageContent = forms.CharField
> ..go back and read the original poster's
> message. Having the user in threadlocals doesn't solve any problem,
> since he's trying to create a form class based on information in the
> request and that only happens at import time, not every time something
> in the file is looked at.
Yes, my
On Thu, 2009-08-06 at 03:33 -0700, krylatij wrote:
> Why do you think so?
It's bad encapsulation practice, for a start. It breaks Python's
namespacing habits.
In this particular case, however, go back and read the original poster's
message. Having the user in threadlocals doesn't solve any
Why do you think so?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
On Aug 6, 9:14 am, krylatij <kryla...@gmail.com> wrote:
> You can also use threadlocals middleware (ask google about it =))
> to get current user without request object
No, really, don't. Just don't.
--
DR.
--~--~-~--~~~---~--~~
You received this mes
You can also use threadlocals middleware (ask google about it =))
to get current user without request object
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group,
On Aug 6, 2:24 am, Julián C. Pérez wrote:
> Hi everyone
> I'm in trouble because of a form class
> I have a form class with attributes defined, but with one thing:
> One of the attributes requires the current user, or al least its
> username
>
> The form definition in as shown
Hi everyone
I'm in trouble because of a form class
I have a form class with attributes defined, but with one thing:
One of the attributes requires the current user, or al least its
username
The form definition in as shown below:
---
class SendMessageForm(forms.Form):
recipientUser =
On Mon, Mar 9, 2009 at 12:03 PM, Rajesh D wrote:
>
>
>
> On Mar 9, 12:48 pm, Adam Schmitz wrote:
> > Hey All,
> >
> > I just setup my webapp to use the django user authentication and
> everything
> > works smoothly so far. The one thing I'm
On Mar 9, 12:48 pm, Adam Schmitz wrote:
> Hey All,
>
> I just setup my webapp to use the django user authentication and everything
> works smoothly so far. The one thing I'm wondering is: after the user logs
> in, how do you access the user object from another app?
>
> The
You can get the current user through the request object: request.user.
If that fails, you need to have if you have AuthenticationMiddleware
installed probably.
~Briel
On 9 Mar., 17:48, Adam Schmitz wrote:
> Hey All,
>
> I just setup my webapp to use the django user
Hey All,
I just setup my webapp to use the django user authentication and everything
works smoothly so far. The one thing I'm wondering is: after the user logs
in, how do you access the user object from another app?
The main thing I'm trying to accomplish is I want to save a model with one
of
I wouldn't use it.
For the admin, I find myself using javascript just fine to do what I
want. I usually have a middleware that sets the current user id as a
cookie, then run something like the following javascript in the admin
on window load: (requires jquery with cookie plugin)
/*
i'm using admin app and found myself in situation where i need to
store current user when saving item so i've overwritten save method on
model and with threadlocals middleware fetched current user.
threadlocals middleware url:
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
is
Gacha wrote:
> I created a simple model "articles" and I added field:
> author= meta.ForeignKey(User,editable=False)
>
> When I add new artcicle I want to assign to this field the current user
> ID, but so far no luck :(
>
> I tryed:
> def _pre_save(self):
> from
I solved this problem by this patch:
http://code.djangoproject.com/attachment/ticket/1132/current_user_field_patch.2.diff
Now I use:
author = meta.CurrentUserField(update_on_edit=False)
--
But the problem about User management is not solved :(
I created a simple model "articles" and I added field:
author = meta.ForeignKey(User,editable=False)
When I add new artcicle I want to assign to this field the current user
ID, but so far no luck :(
I tryed:
def _pre_save(self):
from django.models.auth.users import User
self.author =
29 matches
Mail list logo