[Question] Why can't I assign a new model instance to a model's foreign-key field
That's an interesting point and has to do with the implementation of the descriptor. When the value is set (you assign the `File()` obj), the file has no primary key so peewee records `None` as the related object ID. The fact that the `File` later gets an ID is not caught by the field.

I think this warrants some investigation, thanks for bringing it up.

## Sample layout

``` python
class File(database.Model):
  pass


class User(database.Model):
    file = ForeignKeyField(File)
    pass
```
## The code that reproduces the _odd_ behavior

``` python
>> user = User.get(id=1)
>> user.file = File()
>> user.file.save()
>> user.save()
>> user = User.get(id=1)
>> user.file
None
```
## The behavior with an existing instance

``` python
>> file = File.get(id=1)
>> user = User.get(id=1)
>> user.file = file
>> user.save()
>> user = User.get(id=1)
>> user.file.id
1
```
## Observations
- The behavior in the first situation should be similar to that of the second.
- Could the lack of an ID in the first situation be the cause of the _odd_ behavior?
## Pip freeze

```
blinker==1.3
Flask==0.10.1
Flask-Login==0.2.11
Flask-Mail==0.9.1
Flask-Markdown==0.3
Flask-Principal==0.4.0
Flask-Security==1.7.4
Flask-WTF==0.12
ipython==3.2.1
itsdangerous==0.24
Jinja2==2.7.3
Markdown==2.6.2
MarkupSafe==0.23
passlib==1.6.2
peewee==2.6.3
Werkzeug==0.10.4
wheel==0.24.0
wtf-peewee==0.2.3
WTForms==2.0.2
```

---
## Update - Thu Jul 30 15:55:24 UTC 2015

I just put under test my first observation and it looks like I was right (maybe):

``` python
>> file = File()
>> file.save()
1
>> user = User.get(id=1)
>> user.file = file
>> user.save()
>> user = User.get(id=1)
>> assert user.file is not None
```
