Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Small fixes for compat

  • Loading branch information...
commit 619a81db739a16733d8c343cf26fecfbdb38f1e6 1 parent e981652
@coleifer authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 peewee.py
View
4 peewee.py
@@ -317,6 +317,7 @@ def add_to_class(self, model_class, name):
self.name = name
self.model_class = model_class
self.db_column = self.db_column or self.name
+ self.verbose_name = self.verbose_name or re.sub('_+', ' ', name).title()
model_class._meta.fields[self.name] = self
model_class._meta.columns[self.db_column] = self
@@ -489,7 +490,7 @@ def __init__(self, field, rel_model):
def get_object_or_id(self, instance):
rel_id = instance._data.get(self.att_name)
- if rel_id:
+ if rel_id or self.att_name in instance._obj_cache:
if self.att_name not in instance._obj_cache:
obj = self.rel_model.get(self.rel_model._meta.primary_key==rel_id)
instance._obj_cache[self.att_name] = obj
@@ -540,6 +541,7 @@ def add_to_class(self, model_class, name):
self.name = name
self.model_class = model_class
self.db_column = self.db_column or '%s_id' % self.name
+ self.verbose_name = self.verbose_name or re.sub('_+', ' ', name).title()
model_class._meta.fields[self.name] = self
model_class._meta.columns[self.db_column] = self
Please sign in to comment.
Something went wrong with that request. Please try again.