Re: Pulling a user to save a form

2010-02-07 Thread Daniel Roseman
On Feb 6, 10:11 pm, kamilski81 wrote: > No I am not, once the user is logged in I just want to pull the user > from there...sort of like this > >   if request.method == 'POST': >         instance = request.user >         goal = Goal(user=instance) >         form =

Re: Pulling a user to save a form

2010-02-06 Thread kamilski81
No I am not, once the user is logged in I just want to pull the user from there...sort of like this if request.method == 'POST': instance = request.user goal = Goal(user=instance) form = GoalForm(request.POST, goal) if form.is_valid(): form.save()

Re: Pulling a user to save a form

2010-02-06 Thread Daniel Roseman
On Feb 6, 7:00 pm, kamilski81 wrote: > Basically I am doing the following: > >   u=User.objects.get(username="kamilski81") >   goal = Goal(user=u) >   form = GoalForm(request.POST, goal) > > and get this error: > > (1048, "Column 'user_id' cannot be null") > > FROM THE

Re: Pulling a user to save a form

2010-02-06 Thread kamilski81
Basically I am doing the following: u=User.objects.get(username="kamilski81") goal = Goal(user=u) form = GoalForm(request.POST, goal) and get this error: (1048, "Column 'user_id' cannot be null") FROM THE front-end... Kamil On Feb 5, 10:43 pm, Dylan Evans

Re: Pulling a user to save a form

2010-02-06 Thread kamilski81
It pulls the User correctly, and there is an object there...but it won't let me store it on the front-end form, cause user_id is not set or something of that sort. On Feb 5, 10:43 pm, Dylan Evans wrote: > user = User.objects.get(username__exact='bob') > Works fine for

Re: Pulling a user to save a form

2010-02-05 Thread Dylan Evans
user = User.objects.get(username__exact='bob') Works fine for me, you may want to try get since it will throw an exception if there is no matching user. Then you know the problem is elsewhere. On Sat, Feb 6, 2010 at 11:30 AM, kamilski81 wrote: > I would like to save a form

Pulling a user to save a form

2010-02-05 Thread kamilski81
I would like to save a form by doing the following: #Goal has a User ForeignKey (django.contrib.auth.models.User) - class GoalForm(ModelForm): class Meta: model = Goal --- class Goal(models.Model): user = models.ForeignKey(User, editable=False) -- view.py