How to store a reference to model type in another model instance

So this is a little exercise in the meta meta.. I want to be able to store model reference as a row in a table associated with another model. Something like this:

class Widget(models.Model):
  related = models.Model() # data model associated with this widget
  identifier = models.CharField(max_length=500) # human-friendly descriptor

This doesn't validate.. I've found an acceptable workaround, but I'm wondering if there's a more proper/graceful way of doing this.

Thanks, django wizards!

Answers


If I understand your question correctly then GenericForeignKey is what you need. Have you looked at it?


Need Your Help

Image doesn't show up in picture control

ms-access vba image

I have a report in MS Access with 4 image controls. In the format event of the detail section I have code that sets the picture property based on the values of fields in DAO.recordset. Below is an

Wrapping a ByteBuffer with an InputStream

java nio inputstream bytebuffer

I have a method that takes an InputStream and reads data from it. I would like to use this method with a ByteBuffer also. Is there a way to wrap a ByteBuffer so it can be accessed as a stream?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.