Re: Associating Form Data with Users

2012-02-21 Thread Kelly Nicholes
And by "API" do you mean "ORM?" On Feb 21, 10:45 pm, Kelly Nicholes wrote: > errr-- > > django.contrib.auth.models import User > > class YourModel(models.Model): >     user = models.ForeignKey(User) > > On Feb 21, 10:42 pm, Kelly Nicholes wrote: > > > > > > > > > Your YourModelForm is a modelfor

Re: Associating Form Data with Users

2012-02-21 Thread Kelly Nicholes
errr-- django.contrib.auth.models import User class YourModel(models.Model): user = models.ForeignKey(User) On Feb 21, 10:42 pm, Kelly Nicholes wrote: > Your YourModelForm is a modelform of a model.  If you're setting a > property of that model, AND YOU WANT IT TO PERSIST IN THE DATABASE, >

Re: Associating Form Data with Users

2012-02-21 Thread Kelly Nicholes
Your YourModelForm is a modelform of a model. If you're setting a property of that model, AND YOU WANT IT TO PERSIST IN THE DATABASE, you set the property equal to the request.user and save that object. If you don't have a foreignkeyfield to User, there's no way you're going to associate that mode

Re: Associating Form Data with Users

2012-02-21 Thread ds39
I just have one final question. The method suggested by Thorsten appears to work. But, is the attached user object an accessible filter parameter in the API now ? For instance, I don't see it listed as a part of the actual model in the API. How would I go about accessing it ? On Feb 20, 5:25 pm, T

Re: Associating Form Data with Users

2012-02-20 Thread Thorsten Sanders
You could do for example: exclude the user field from the form and in your view something like this: form = YourModelForm(request.POST) #fill the modelform with the data if form.is_valid(): # check if valid mynewobject = form.save(commit=False) #save it to create the object

Re: Associating Form Data with Users

2012-02-20 Thread ds39
I hate to keep bringing this issue up, but I'm still not entirely sure how to implement this. I've tried a number of different ways to connect some kind of user ID with form data without much success. Is the idea that after authenticating the user in the view, request.user be set to some variable t

Re: Associating Form Data with Users

2012-02-19 Thread Shawn Milochik
On 02/19/2012 09:29 PM, ds39 wrote: Thanks for your response. But, would you mind expanding on it a little bit ? How about you give it a try and see what you can figure out? In your view, request.user will return the currently logged-in user (or an AnonymousUser if they're not logged in). Si

Re: Associating Form Data with Users

2012-02-19 Thread ds39
Thanks for your response. But, would you mind expanding on it a little bit ? On Feb 19, 9:21 pm, Shawn Milochik wrote: > When you process the form in your view, you'll have access to > request.user. Just use that. -- You received this message because you are subscribed to the Google Groups "Dj

Re: Associating Form Data with Users

2012-02-19 Thread Shawn Milochik
When you process the form in your view, you'll have access to request.user. Just use that. -- 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

Associating Form Data with Users

2012-02-19 Thread ds39
Hi All, I was wondering if someone could tell me the correct method for associating submitted form data with a user. I would like to access user-submitted form information with the API (or a template) via user identification. I'm making use of a ModelForm in a forms.py file which corresponds to a