python - Attaching extra information to model instance - django -


I have a dynamic model that I want to attach an additional piece of information, depending on the environment according to the example (The user who is logged in) For this reason, I do not want to do this at the database level.

Is that okay? Or there are problems that I'm not predicting

"Type 'foo' or 'bar'" "def __init __ (auto, type): self.type = type

views.py

FooChat (FooOrBar): "" "" "never saved the database" def __init __ (self, foo_or_bar): self .__ dict__ = foo_or_bar .__ dict __copy () def check_type ( Self, external_type): If external_type == 'foo': self.is_foo = any other is true: self.is_foo = false foos_or_bars = FooOrBar.objects.all () foochecks = map (FooCheck, foos_or_bars) in foochecks For foocheck: foocheck.check_type ('foo')

Additional credit questions: Is there a more efficient method of calling a method on many items i.e. the last with some clever To change the line?

OK, it does not work to destroy a Trying FooOrBar objects about a complaint

throws
  / OperationalError on such a table: test_FooCheck  

get around this I just fuoraba Inherit'm not going to happen, but if anyone has any suggestions on better ways to do it so I'd be interested in hearing it


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

c# - Create dynamic LINQ query expression at runtime which translates into a parameterized SQL query for nullable types -

cmake - cpack generates RPMs with %files entries that conflict with the RPM spec. How to fix? -