Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-03 Thread Michael Molloy
Thank you for your help. --M On Sunday, January 3, 2016 at 7:53:02 AM UTC-6, Vijay Khemlani wrote: > > Well, it's not supposed to be bound if you don't pass any data to it > > the "instance" in the ModelForm (if i remember correctly) just sets the > initial values for the fields when you render

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-03 Thread Michael Molloy
That makes sense. Thank you. --M On Sunday, January 3, 2016 at 8:05:21 AM UTC-6, knbk wrote: > > >>> uf = UsersForm(u) > > Here you are passing the user instance as if it were the POST data. The > form expects a dictionary or None as the first argument. `form.is_bound` > simply checks `data is

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-03 Thread knbk
>>> uf = UsersForm(u) Here you are passing the user instance as if it were the POST data. The form expects a dictionary or None as the first argument. `form.is_bound` simply checks `data is not None`, which is True in this case. If you want a bound form, you should pass a dictionary with the

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-03 Thread Vijay Khemlani
Well, it's not supposed to be bound if you don't pass any data to it the "instance" in the ModelForm (if i remember correctly) just sets the initial values for the fields when you render the form in HTML and modifies that instance when you call "save" on the ModelForm. On Sun, Jan 3, 2016 at 1:29

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-02 Thread Michael Molloy
Thank you for your help. I apologize for the typo, but I am calling is_valid() with the parenthesis: >>> uf = UsersForm(u) >>> uf.is_valid() Traceback (most recent call last): File "", line 1, in File "/var/lib/openshift/5678c24389f5cff0330001cd/python/virtenv/venv/lib64/python3.3/site-p

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-02 Thread Michael Molloy
Not studying; I’m working on a website that will be used to register people for an event, but it is my first Django site. I’m aware that I can add to the existing user model, and I may. However, this is just my first attempt to create a model and form and save data to the database. I don’t thi

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-02 Thread Vijay Khemlani
"First, why does uf.is_valid() return" because you called "uf.is_valid" (note the lack of parenthesis), that's just a reference to the method and does not call it. "Second, why does uf.save() return that stacktrace the first time I call it, but the second time I call it, the object saves? " As f

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-02 Thread Sergiy Khohlov
Sorry I missed. You have valid unknown at the start. Why are you not used django user model and author? Study purpose ,? 3 січ. 2016 05:53 "Michael Molloy" пише: > I'm not sure what could be wrong with the database settings. If I just > create an instance of the model and save it, it saves to the

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-02 Thread Michael Molloy
I'm not sure what could be wrong with the database settings. If I just create an instance of the model and save it, it saves to the database: >>> u.email

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-02 Thread Sergiy Khohlov
Is_valid is working. You have problem with save. Check database setting. 3 січ. 2016 04:18 "Michael Molloy" пише: >ve > This is running in Openshift with Python 3.3 and Django 1.8.4 > > Here's my model: > > class Users(models.Model): > first_nm = models.CharField('First Name', max_length=100)

ModelForm.is_valid() doesn't work the first time but does the second

2016-01-02 Thread Michael Molloy
This is running in Openshift with Python 3.3 and Django 1.8.4 Here's my model: class Users(models.Model): first_nm = models.CharField('First Name', max_length=100) last_nm = models.CharField('Last Name', max_length=100) email = models.CharField('Email Address', max_length=200, unique=