Accessing Data Linked in One-To-One to Current User from a Table

2023-01-05 Thread G Daniel
Hello All! I need your help. I have a table, PersonWife, that's linked in a one-to-one fashion with the users (using Django's user authentication system). See attached models and admin control panel screenshots. I can get the username of the currently logged in user ( attached screenshots). W

Re: Get current user in model signal pre_save

2022-11-28 Thread Pankaja Withanachchi
for obj in queryset: > if obj.is_superuser: > if request.user.is_superuser: > # obj.delete() > else: > raise PermissionDenied > else: > # obj.delete() > d

Re: How to create current user field in dango rest framework

2022-07-28 Thread Abdul Qoyyuum
A quick search on Stack overflow shows me this: https://stackoverflow.com/a/43032332 Abdul Qoyyuum Bin Haji Abdul Kadir System Engineer at Card Access Services HP: +673 720 8043 On Thu, Jul 28, 2022, 4:19 AM Ashok garsulla wrote: > Please tell me how can I create current User in dango R

Re: How to create current user field in dango rest framework

2022-07-28 Thread Ammar Mohammed
Hi Ashok Do you wabt to use the current user or creating a new user ? Is it like signing up a new user ? On 27 Jul 2022 22:19, "Ashok garsulla" wrote: > Please tell me how can I create current User in dango Rest Framework > > -- > You received this message because you

How to create current user field in dango rest framework

2022-07-27 Thread Ashok garsulla
Please tell me how can I create current User in dango Rest Framework -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@google

How Notify Current user ,your insurance is going expiry within 5 days in django

2022-03-01 Thread Gautam Ankul
I am stuck in one problem and i want to notify current logged user for it's insurance will be expired within 5 days ago. class Vehicle(models.Model): vehicle_no = models.CharField(max_length=100, blank=False, null=False) chasis_no = models.

Re: Log out all sessions for current user logged in

2021-03-01 Thread Ryan Nowakowski
; On February 25, 2021 9:42:55 PM CST, Salima Begum < >>>> salim...@rohteksolutions.com> wrote: >>>>> >>>>> Logout all sessions belong to logged in user Can you please how >can I >>>>> achieve this? >>>>> >>>>

Re: Log out all sessions for current user logged in

2021-02-28 Thread Salima Begum
lutions.com> wrote: >>>> >>>> Logout all sessions belong to logged in user Can you please how can I >>>> achieve this? >>>> >>>> Thanks >>>> ~salima >>>> >>>> On Fri, Feb 26, 2021 at 4:56 AM Ryan

Re: Log out all sessions for current user logged in

2021-02-27 Thread Ryan Nowakowski
belong to logged in user Can you please how can >I >>> achieve this? >>> >>> Thanks >>> ~salima >>> >>> On Fri, Feb 26, 2021 at 4:56 AM Ryan Nowakowski > >>> wrote: >>> >>>> On Wed, Feb 17, 2021 at 08:2

Re: Log out all sessions for current user logged in

2021-02-26 Thread Salima Begum
;> On Wed, Feb 17, 2021 at 08:23:08AM +0530, Salima Begum wrote: >>> > Logout all sessions based on current user id and clear django sessions >>> > table based on user id. It is logging off all sessions. >>> > >>> > ``` >>> > # Logout al

Re: Log out all sessions for current user logged in

2021-02-26 Thread Ryan Nowakowski
ote: > >> On Wed, Feb 17, 2021 at 08:23:08AM +0530, Salima Begum wrote: >> > Logout all sessions based on current user id and clear django >sessions >> > table based on user id. It is logging off all sessions. >> > >> > ``` >> > # Logout

Re: Log out all sessions for current user logged in

2021-02-25 Thread Salima Begum
Logout all sessions belong to logged in user Can you please how can I achieve this? Thanks ~salima On Fri, Feb 26, 2021 at 4:56 AM Ryan Nowakowski wrote: > On Wed, Feb 17, 2021 at 08:23:08AM +0530, Salima Begum wrote: > > Logout all sessions based on current user id and clear django

Re: Log out all sessions for current user logged in

2021-02-25 Thread Ryan Nowakowski
On Wed, Feb 17, 2021 at 08:23:08AM +0530, Salima Begum wrote: > Logout all sessions based on current user id and clear django sessions > table based on user id. It is logging off all sessions. > > ``` > # Logout all devices in account security page. > def logoff_all(r

Re: how to pass the current user in reverse_lazy()

2018-06-24 Thread Saloni Kalra
Thanks much! On Sun, 24 Jun 2018, 5:50 pm Daniel Ale, wrote: > Great. > > On Sun, Jun 24, 2018, 13:18 Saloni Kalra > wrote: > >> Yes it did! Thanks much! >> >> On Sunday, 24 June 2018 17:14:31 UTC+5, Daniel Ale wrote: >>> >>> Override the get_success_url(self) instead... That will work >>> >>>

Re: how to pass the current user in reverse_lazy()

2018-06-24 Thread Daniel Ale
Great. On Sun, Jun 24, 2018, 13:18 Saloni Kalra wrote: > Yes it did! Thanks much! > > On Sunday, 24 June 2018 17:14:31 UTC+5, Daniel Ale wrote: >> >> Override the get_success_url(self) instead... That will work >> >> On Sun, Jun 24, 2018, 07:13 Saloni Kalra wrote: >> >>> *DeleteView:* >>> >>> c

Re: how to pass the current user in reverse_lazy()

2018-06-24 Thread Saloni Kalra
Yes it did! Thanks much! On Sunday, 24 June 2018 17:14:31 UTC+5, Daniel Ale wrote: > > Override the get_success_url(self) instead... That will work > > On Sun, Jun 24, 2018, 07:13 Saloni Kalra > wrote: > >> *DeleteView:* >> >> class DeletePost(LoginRequiredMixin, SelectRelatedMixin, >> generic.

Re: how to pass the current user in reverse_lazy()

2018-06-24 Thread Daniel Ale
Override the get_success_url(self) instead... That will work On Sun, Jun 24, 2018, 07:13 Saloni Kalra wrote: > *DeleteView:* > > class DeletePost(LoginRequiredMixin, SelectRelatedMixin, > generic.DeleteView): > username = self.object.user.username > model = models.Post > select_relat

how to pass the current user in reverse_lazy()

2018-06-23 Thread Saloni Kalra
*DeleteView:* class DeletePost(LoginRequiredMixin, SelectRelatedMixin, generic.DeleteView): username = self.object.user.username model = models.Post select_related = ("user","teacher","subject") success_url = reverse_lazy("posts:for_user", kwargs={'username': self.request.user.user

Cannot assign the current user to the ForeignKey field in my model.

2018-06-23 Thread Saloni Kalra
I am trying to build a feedback application for the teachers by the students. I have a proxy User that will the student. But I am not able to assign the user to the feedback model. I am a newbie. Please help. Thanks and regards, Saloni *models.py:* class User(auth.models.User, auth.models.Permiss

Re: Current user ip address on form.py

2018-04-27 Thread Andréas Kühne
from the request. See here: >>> https://stackoverflow.com/questions/4581789/how-do-i- >>> get-user-ip-address-in-django >>> >>> Regards, >>> >> >>> Andréas >>> >>> 2018-04-27 14:28 GMT+02:00 lakshitha kumara : >>> >

Re: Current user ip address on form.py

2018-04-27 Thread James Farris
>> Regards, >> > >> Andréas >> >> 2018-04-27 14:28 GMT+02:00 lakshitha kumara : >> > Hello Guys >>> >>> Is there way to get current user ip address on form.py >>> >>> Thanks >>> >> -- >>> You rece

Re: Current user ip address on form.py

2018-04-27 Thread lakshitha kumara
verflow.com/questions/4581789/how-do-i-get-user-ip-address-in-django > > Regards, > > Andréas > > 2018-04-27 14:28 GMT+02:00 lakshitha kumara >: > >> Hello Guys >> >> Is there way to get current user ip address on form.py >> >> Thanks

Re: Current user ip address on form.py

2018-04-27 Thread Andréas Kühne
Hi, You can get the IP address from the request. See here: https://stackoverflow.com/questions/4581789/how-do-i-get-user-ip-address-in-django Regards, Andréas 2018-04-27 14:28 GMT+02:00 lakshitha kumara : > Hello Guys > > Is there way to get current user ip address on form.py &

Current user ip address on form.py

2018-04-27 Thread lakshitha kumara
Hello Guys Is there way to get current user ip address on form.py Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-user

Showing only current user in Django admin

2018-03-17 Thread 'Simon Connah' via Django users
I'm just making my first Django app in a very long time, and I have forgotten most of what I learnt. I'm using the built-in admin panel for ease of use, and it seems to be working well, with one exception. I have a BlogPost model with the usual things in it. One of the fields is a FK to the User

Django rest framework filtering foreign key value and setting userId = current user

2018-01-03 Thread cherngyorng
So i have a family and schedule model. Family is to add family member and schedule is to create schedule with family as a foreign key in it. But in both api, userId field is a drop down field to select which a user instead of using fix at the current userId. The code and more specific about my

Re: Hello - need help on accessing current user in django forms.

2016-09-27 Thread Ricardo Daniel Quiroga
> Hello, >> >> I need filter a queryset based on current user in Django forms. >> >> kindly help me if you find any. >> >> Thanks, >> >> Naresh >> > -- > You received this message because you are subscribed to the Google Groups > "D

Re: Hello - need help on accessing current user in django forms.

2016-09-23 Thread Tim Graham
Try a web search for "django passing request to a form". Here's the first result: http://stackoverflow.com/questions/6325681/passing-a-user-request-to-forms On Friday, September 23, 2016 at 7:17:32 AM UTC-4, Naresh Kumar wrote: > > Hello, > > I need filter a querys

Hello - need help on accessing current user in django forms.

2016-09-23 Thread Naresh Kumar
Hello, I need filter a queryset based on current user in Django forms. kindly help me if you find any. Thanks, Naresh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from i

Re: How can I get current user in my ModelForm, using inlineformset?

2015-10-19 Thread Mark Steadman
if you're still stuck (as it's possibly one of those things that's easier to show rather than tell). On Thursday, 15 October 2015 20:05:24 UTC+1, Fellipe Henrique wrote: > > Hello, > > I have my ModelForm... and I need to filter my products with Current > User.. if a c

How can I get current user in my ModelForm, using inlineformset?

2015-10-15 Thread Fellipe Henrique
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,

Re: Get current user in model signal pre_save

2015-09-10 Thread Xavier Palacín Ayuso
if obj.is_superuser: if request.user.is_superuser: # obj.delete() else: raise PermissionDenied else: # obj.delete() delete_model.short_description = 'Eliminar usuario/s seleccionados

Get current user in model signal pre_save

2015-09-09 Thread Xavier Palacín Ayuso
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

Re: FORM: How to specify current user as value for a form ForeignKey referencing logged on user

2015-03-09 Thread felix
w based on the input. Model as below: class Accounts(models.Model): authid = models.CharField(max_length=128) authtoken = models.CharField(max_length=128) provider = models.ForeignKey(Provider) user = models.ForeignKey(User, unique=True) How do I feed the current user va

Re: FORM: How to specify current user as value for a form ForeignKey referencing logged on user

2015-03-08 Thread Vijay Khemlani
based on the > input. Model as below: > > class Accounts(models.Model): > authid = models.CharField(max_length=128) > authtoken = models.CharField(max_length=128) > provider = models.ForeignKey(Provider) > user = models.ForeignKey(User, unique=True) > > > How

FORM: How to specify current user as value for a form ForeignKey referencing logged on user

2015-03-08 Thread Ryan Alexander
class Accounts(models.Model): authid = models.CharField(max_length=128) authtoken = models.CharField(max_length=128) provider = models.ForeignKey(Provider) user = models.ForeignKey(User, unique=True) How do I feed the current user value to the form? Form code: class AccountForm(forms.ModelFo

Re: set current user value in Django admin for Foreign Key

2014-12-11 Thread Collin Anderson
ged in user in for foreign key in > Django admin. Following are the approach used buy me: > > 1-> def formfield_for_foreignkey(self, db_field, request, **kwargs): > if db_field.name == "user": > "set the current user as a default val

Re: set current user value in Django admin for Foreign Key

2014-12-10 Thread Vijay Khemlani
key in > Django admin. Following are the approach used buy me: > > 1-> def formfield_for_foreignkey(self, db_field, request, **kwargs): > if db_field.name == "user": > "set the current user as a default value for drop down" >

set current user value in Django admin for Foreign Key

2014-12-10 Thread Akshay Mukadam
Hi, I just want to show the current logged in user in for foreign key in Django admin. Following are the approach used buy me: 1-> def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "user": "set the current user as a defa

Re: How do I get the current user in a model?

2013-02-11 Thread frocco
t > # method. > return evaluated_price > > On Mon, 2013-02-11 at 07:05 -0800, frocco wrote: > > What I am trying to do, is I have four price fields in my model and > > need to return just one based on current user logged in. > > > > > > price_a

Re: How do I get the current user in a model?

2013-02-11 Thread Bill Freeman
On Mon, Feb 11, 2013 at 10:05 AM, frocco wrote: > What I am trying to do, is I have four price fields in my model and need > to return just one based on current user logged in. > > price_a > price_b > price_c > price_d > > I want to always return a field named price, b

Re: How do I get the current user in a model?

2013-02-11 Thread Brad
return evaluated_price On Mon, 2013-02-11 at 07:05 -0800, frocco wrote: > What I am trying to do, is I have four price fields in my model and > need to return just one based on current user logged in. > > > price_a > price_b > price_c > price_d > > > I want

Re: How do I get the current user in a model?

2013-02-11 Thread frocco
What I am trying to do, is I have four price fields in my model and need to return just one based on current user logged in. price_a price_b price_c price_d I want to always return a field named price, based on one of those fields. On Monday, February 11, 2013 9:51:47 AM UTC-5, frocco wrote

Re: How do I get the current user in a model?

2013-02-11 Thread frocco
Ok, but is request available in models.py? On Monday, February 11, 2013 9:49:47 AM UTC-5, sandy wrote: > > On Mon, Feb 11, 2013 at 7:42 PM, frocco > > wrote: > > Hello, > > > > I have some logic I want to put in a model, but it requires know the > current

Re: How do I get the current user in a model?

2013-02-11 Thread Sandeep kaur
On Mon, Feb 11, 2013 at 7:42 PM, frocco wrote: > Hello, > > I have some logic I want to put in a model, but it requires know the current > user logged in. > Is there a way to get this? > This gets the current logged in user : current_user = request.user -- Sandeep Kau

How do I get the current user in a model?

2013-02-11 Thread frocco
Hello, I have some logic I want to put in a model, but it requires know the current user logged in. Is there a way to get this? The template would have to display the results of the field returned from the model. Thanks -- You received this message because you are subscribed to the Google

Re: Retrieve current user id in urls.py

2012-11-28 Thread Peter Edström
Thank you. It's quite logical when you know it. :-) > This isn't something you do in the urlconf. You do that in your view, > where the current user is available already as `request.user`. > -- > DR. > -- You received this message because you are subscribed to t

Re: Retrieve current user id in urls.py

2012-11-27 Thread Daniel Roseman
) >> > > In App1 I have a OneToOneField to my user profile, I want to list > everything in App1 filtered on the currently logged in user (employee = > current_user). > Every example I find in the docs uses the request.user.username, but I > have no request method here. &g

Retrieve current user id in urls.py

2012-11-27 Thread Peter Edström
Hello, I've set up a user profile according to thisand now I'm trying to access the id of the currently logged in user in my urls.py, like this: # urls.py > from django.contrib.auth.decorators impo

Re: retrieving current user in view

2011-05-19 Thread Tom Evans
On Thu, May 19, 2011 at 7:33 AM, Michel30 wrote: > This gives me a file field, a browse button and a submit button. What > I'd like to have is a submit button only, click that opens a file > dialog. > Any ideas? You cannot do that. File controls are strictly only opened by browsers under direct u

Re: retrieving current user in view

2011-05-18 Thread Michel30
This is the traceback: Traceback: File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/ decorators.

Re: retrieving current user in view

2011-05-18 Thread Oscar Carballal
As Daniel said, I dont' think also that the entire view is that, but if it helps, I'll let you a piece of my code for a form (gpl, no problem if you copy it). @permission_required('spaces.add_space') def create_space(request): """ Create new spaces. In this view the author field is automa

Re: retrieving current user in view

2011-05-18 Thread Daniel Roseman
On Wednesday, May 18, 2011 2:16:00 PM UTC+1, Michel30 wrote: > > Hey all, > > I have a Django 1.3 app that retrieves user credentials from LDAP. > Most views require the user to be authenticated so I use the > @login_required decorator. > > Now, in a form a user can upload a document using a fo

retrieving current user in view

2011-05-18 Thread Michel30
Hey all, I have a Django 1.3 app that retrieves user credentials from LDAP. Most views require the user to be authenticated so I use the @login_required decorator. Now, in a form a user can upload a document using a form: {% csrf_token %} {{ form }} I want to log the user's first and lastname

Re: AW: Current user

2011-02-10 Thread Daniel Roseman
On Thursday, February 10, 2011 2:27:15 PM UTC, Szabo, Patrick (LNG-VIE) wrote: > > I imorted from django.contrib.auth.models import User but when i do > > Mitarbeiter = request.user.id > > It tells me that NameError: name 'request' is not defined > > What am i doing wrong ?! > The first thing yo

Re: AW: AW: Current user

2011-02-10 Thread xordoquy
On Thu, 10 Feb 2011 15:29:09 +0100, "Szabo, Patrick \(LNG-VIE\)" wrote: > Oh okay, so this only works for views ?! > Can't i use that in my models.py ?! There are places where you can use models without being logged or having any idea of what a user can be. For example, when you use the loaddata

AW: AW: Current user

2011-02-10 Thread Szabo, Patrick (LNG-VIE)
- 146 -Ursprüngliche Nachricht- Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im Auftrag von Shawn Milochik Gesendet: Donnerstag, 10. Februar 2011 15:18 An: django-users@googlegroups.com Betreff: Re: AW: Current user If you have the contrib.auth and session middl

AW: Current user

2011-02-10 Thread Szabo, Patrick (LNG-VIE)
2011 15:04 An: django-users@googlegroups.com Betreff: AW: Current user Might be a stupid question but do i have to import to do that !? . . . . . . . . . . . . . . . . . . . . . . . . . . Patrick Szabo XSLT-Entwickler LexisNexis Marxergasse 25, 1030 Wien mailto:patrick.sz...@lexisnexis.at Te

Re: AW: Current user

2011-02-10 Thread Shawn Milochik
If you have the contrib.auth and session middleware installed (which you do by default) then that will be available in you views without any additional imports. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send emai

AW: Current user

2011-02-10 Thread Szabo, Patrick (LNG-VIE)
-Ursprüngliche Nachricht- Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im Auftrag von Shawn Milochik Gesendet: Donnerstag, 10. Februar 2011 14:42 An: django-users@googlegroups.com Cc: Betreff: Re: Current user Set the field value to request.user.id. -- You received this

Re: Current user

2011-02-10 Thread Shawn Milochik
Set the field value to request.user.id. -- 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 django-users+unsubscr...@googlegroups.co

Current user

2011-02-10 Thread Szabo, Patrick (LNG-VIE)
Hi, I want to assign the id of the user that is currently logged in to a field of a model. How do I do that ?! Kind regards . . . . . . . . . . . . . . . . . . . . . . . . . . Patrick Szabo XSLT-Entwickler LexisNexis Marxergasse 25, 1030 Wien mailto:patrick.sz...@lexisnexis.at Tel

Re: Getting object representing the current user

2010-05-09 Thread Paul
On May 5, 10:12 pm, Daniel Roseman wrote: > On May 5, 9:30 pm, Paul wrote: > > > > > I have the following model (stripped of comments and __unicode__ for > > brevity) which defines  a comment in my Django app (I'm not using the > > comment module provided with Django for various reasons): > > > c

Re: Getting object representing the current user

2010-05-05 Thread Daniel Roseman
On May 5, 9:30 pm, Paul wrote: > I have the following model (stripped of comments and __unicode__ for > brevity) which defines  a comment in my Django app (I'm not using the > comment module provided with Django for various reasons): > > class Comment(models.Model): >   comment = models.TextField(

Getting object representing the current user

2010-05-05 Thread Paul
I have the following model (stripped of comments and __unicode__ for brevity) which defines a comment in my Django app (I'm not using the comment module provided with Django for various reasons): class Comment(models.Model): comment = models.TextField() added_by = models.ForeignKey(User) ad

Re: Saving a ModelForm for the current user?

2010-04-18 Thread David Lindquist
>     url = models.URLField() > > > > > >     class Meta: > > > > >         unique_together = (('user', 'url'),) > > > > > > And an equally simple ModelForm: > > > > > > class SiteForm(forms.ModelForm): > &

Re: Saving a ModelForm for the current user?

2010-04-18 Thread David Lindquist
> >     class Meta: > > > >         model = Site > > > >         exclude = ('user',) > > > > > I exclude the user field because I want to be able to save a Site > > > > object for the currently logged in user. But no matter how I t

Re: Saving a ModelForm for the current user?

2010-04-18 Thread ge...@aquarianhouse.com
Site > > >         exclude = ('user',) > > > > I exclude the user field because I want to be able to save a Site > > > object for the currently logged in user. But no matter how I try to > > > set the user in the view, form.save() raises an IntegrityErro

Re: Saving a ModelForm for the current user?

2010-04-18 Thread David Lindquist
27;,) > > > I exclude the user field because I want to be able to save a Site > > object for the currently logged in user. But no matter how I try to > > set the user in the view, form.save() raises an IntegrityError > > ("Column 'user_id' cannot be null

Re: Saving a ModelForm for the current user?

2010-04-18 Thread ge...@aquarianhouse.com
> ("Column 'user_id' cannot be null"). > > I know I could include the user field and generate the form with a > hidden field using the pk of the current user, but that seems like it > could be easily altered. > > What is the best approach for this? > >

Saving a ModelForm for the current user?

2010-04-17 Thread David Lindquist
ry to set the user in the view, form.save() raises an IntegrityError ("Column 'user_id' cannot be null"). I know I could include the user field and generate the form with a hidden field using the pk of the current user, but that seems like it could be easily altered. What is

Re: Get current user outside a view / without an request object

2009-08-20 Thread Julienoune
e, but I can' figure out where? For information, I'm working with the django admin site . Any idea? On 7 août, 03:28, Julián C. Pérez wrote: > Bingo!!! > :D > I follow > this:http://oebfare.com/blog/2008/feb/23/changing-modelchoicefield-queryset/ > and now I'm

Re: Get current user outside a view / without an request object

2009-08-06 Thread Julián C . Pérez
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): recipien

Re: Get current user outside a view / without an request object

2009-08-06 Thread Paulo Almeida
iew. > > > > - Paulo > > > > 2009/8/6 Julián C. Pérez > > > > > > > > > My real problem it that the field should looks like: > > > --- > > > recipientUser = ShowValidContactList(currentUser=_something_, > > > label=u'Se

Re: Get current user outside a view / without an request object

2009-08-06 Thread Julián C . Pérez
2009/8/6 Julián C. Pérez > > > > > 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...

Re: Get current user outside a view / without an request object

2009-08-06 Thread Paulo Almeida
init method like... > --- > def __init__(self, *args, **kwargs): >self.currentUser = kwargs.pop('currentUser', None) >super(SendMessageForm, self).__init__(*args, **kwargs) > --- > it won't change the current user already defined in the field > > Now

Re: Get current user outside a view / without an request object

2009-08-06 Thread Julián C . Pérez
er', None) super(SendMessageForm, self).__init__(*args, **kwargs) --- it won't change the current user already defined in the field Now, I want to make something like... --- recipientUser = ShowValidContactList(currentUser=getCurrentUser, label=u'Send to') --- where 'getC

Re: Get current user outside a view / without an request object

2009-08-06 Thread Daniel Roseman
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= forms.CharField(label=u'Subj

Re: Get current user outside a view / without an request object

2009-08-06 Thread Julián C . Pérez
1:40 am, Daniel Roseman wrote: > 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 curr

Re: Get current user outside a view / without an request object

2009-08-06 Thread krylatij
> ..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 mista

Re: Get current user outside a view / without an request object

2009-08-06 Thread Malcolm Tredinnick
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 probl

Re: Get current user outside a view / without an request object

2009-08-06 Thread krylatij
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 django-users

Re: Get current user outside a view / without an request object

2009-08-06 Thread Daniel Roseman
On Aug 6, 9:14 am, krylatij 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 message because you a

Re: Get current user outside a view / without an request object

2009-08-06 Thread krylatij
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, sen

Re: Get current user outside a view / without an request object

2009-08-05 Thread Daniel Roseman
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 de

Get current user outside a view / without an request object

2009-08-05 Thread Julián C . Pérez
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): recipien

Re: Current user in model.save() context

2009-07-21 Thread Bartłomiej Górny
Joshua Russo wrote: > On Mon, Jul 20, 2009 at 9:23 AM, Matthias Kestenholz > mailto:matthias.kestenh...@gmail.com>> > wrote: > > thread locals have all the problems which are generally associated > with global variables. They might be overwritten by other code, they > make testing e

Re: Current user in model.save() context

2009-07-21 Thread Bartłomiej Górny
rovide the complete environment including the > variables from the threadlocals space in your testsuite. More code is > needed, and the probability that the code and the testsuite (and > eventual documentation) get out of sync gets bigger and bigger. Actually, not necessarily - in testing en

Re: Current user in model.save() context

2009-07-20 Thread Joshua Russo
On Mon, Jul 20, 2009 at 9:23 AM, Matthias Kestenholz < matthias.kestenh...@gmail.com> wrote: > thread locals have all the problems which are generally associated > with global variables. They might be overwritten by other code, they > make testing extremely difficult because the behavior of method

Re: Current user in model.save() context

2009-07-20 Thread Matthias Kestenholz
On Mon, Jul 20, 2009 at 9:26 AM, Bartłomiej Górny wrote: > [...] >> there is a cookbook recipe for achieving this sort of thing: >> >> http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > > Yep, that's exactly what I did :) > >> >> That's deep in the category of 'give them rope to hang

Re: Current user in model.save() context

2009-07-20 Thread Bartłomiej Górny
Matthias Kestenholz wrote: > On Fri, Jul 17, 2009 at 4:24 PM, Bartłomiej Górny wrote: >> Phil wrote: >>> Hi Josh, >>> >>> unfortunately it seems that there is no way to do so. As you've >>> noticed that correctly you can use request (request.user) in any place >>> but model save. >> Yes, I bumped

Re: Current user in model.save() context

2009-07-18 Thread Joshua Russo
On Sat, Jul 18, 2009 at 8:06 AM, Matthias Kestenholz < matthias.kestenh...@gmail.com> wrote: > If you really need to do that (or if you are just extremely lazy) > there is a cookbook recipe for achieving this sort of thing: > > http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > > Tha

Re: Current user in model.save() context

2009-07-18 Thread Matthias Kestenholz
On Fri, Jul 17, 2009 at 4:24 PM, Bartłomiej Górny wrote: > > Phil wrote: >> Hi Josh, >> >> unfortunately it seems that there is no way to do so. As you've >> noticed that correctly you can use request (request.user) in any place >> but model save. > > Yes, I bumped into the same problem and came t

Re: Current user in model.save() context

2009-07-17 Thread Shawn Milochik
I think you still have to pass the user, but you can tell if the item is modified or new by whether its id has a value. If it's brand new and has never been saved, then it won't have one. --~--~-~--~~~---~--~~ You received this message because you are subscribe

Re: Current user in model.save() context

2009-07-17 Thread Bartłomiej Górny
add options. >> >> The user has been much trickier. I can't figure out how (if possible) >> to get access to the current user information in the context of a >> model. The work around that I've implemented is a method that takes >> the model, user id, and a b

Re: Current user in model.save() context

2009-07-16 Thread Phil
easy with auto_now and > auto_now_add options. > > The user has been much trickier. I can't figure out how (if possible) > to get access to the current user information in the context of a > model. The work around that I've implemented is a method that takes > the model, use

Current user in model.save() context

2009-07-16 Thread Joshua Russo
possible) to get access to the current user information in the context of a model. The work around that I've implemented is a method that takes the model, user id, and a boolean indicating modification or new. I then use this in location where I still have a request object (and thus request.user

Re: access to id of current user on admin

2009-05-18 Thread Martin Ostrovsky
om/en/dev/ref/contrib/admin/#modeladmin-methods On May 18, 7:01 am, Alfredo Alessandrini wrote: > Hi, > > I'm write a model for a post. > > Can I access to id of current user on admin site? > > I'm trying with: > > author = models.ForeignKey(User, default=U

access to id of current user on admin

2009-05-18 Thread Alfredo Alessandrini
Hi, I'm write a model for a post. Can I access to id of current user on admin site? I'm trying with: author = models.ForeignKey(User, default=User.id, blank=True, null=True) But don' work... Thanks, Alfredo -- from django.db imp

Re: Get Current User

2009-03-09 Thread Alex Gaynor
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 the fields being the current user that is logged in. > > > http://docs.django

  1   2   >