through

how to avoid duplicates in a has_many :through relationship?

Hey guys, how can I achieve the following? I have two models (blogs and readers) and a JOIN table that will allow me to have an N:M relationship between them: class Blog < ActiveRecord::Base has_many :blogs_readers, :dependent => :destroy has_many :readers, :through => :blogs_readers end class Reader < ActiveRecord::Base has_many :...

How can I have the user create a has_many :through table without any user-input attributes?

I have two models (users and courses) and a JOIN table that allows enrollments in the course: class User < ActiveRecord::Base has_many :enrollments, :dependent => :destroy has_many :courses, :through => :enrollments end class Course < ActiveRecord::Base has_many :enrollments, :dependent => :destroy has_many :users, :throu...

Polymorphic has_many self-referential

Hello there, I am having trouble getting this to work. My problem is. I have A number of models (Article, Video, Photo) Now I am trying to create a related_to association, such that An article can have many other articles, videos and photos related to it. As can videos and photos. Heres what I have tried module ActsAsRelatable def...

LINQ To SQL - What is the most efficient way to loop through master/detail?

The only thing I can find when dealing with master/detail and LINQ is through databinding. However, I am using LINQ to query my data and will need to manually loop through results without the need for databinding. My final intent is to loop through a master result set, get a grouped list of children, and output the master/detail data as ...

Ordering on a field in the 'through' Model of recursive ManyToMany relation in Django.

Assuming the following model: class Category(models.Model): related = models.ManyToManyField('self', symmetrical = False, through = 'CategoryRelation', null = True, blank = True) Assuming the following intermediate 'through' relation: class CategoryRelation(models.Model): source = models.ForeignKey('Category', null = False, b...

Django: many-to-many relations, and through

I want to store which user invited another user to a group... but django is telling me this is ambigous and against the rules (which makes sense). groups.group: Intermediary model Group_to_Member has more than one foreign key to User, which is ambiguous and is not permitted. So how do I do this correctly? Maybe a generic rel...

iframes modifications

Hi, i have a website which uses top in javascript to show bookshops in a panel. Now i want to add this website into another website using a frame. But when i fix the url in the src of the frame , it changes the hierarchy of the pages or images and the bookshops are not shown. Can anybody sugget me the solution for this. Khushi ...

Django: Exclude on a many-to-many relationship through a third table

I have a problem making "exclude" querys on tables which have a many-to-many relationship through a third table. I have a table with projects, a table with people and a relationsship table with the flags "is_green, is_yellow, is_red", like: class Project(models.Model): ... class Person(models.Model): projects = models.ManyToMan...

looping through an image folder in a wpf application

I currently am loading all images in a folder in my "MyPictures" folder on my machine which works fine... foreach (string filename in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures))) What I really want to be able to do, though, is load all the images in my Images folder within my solution project. C...

Call webservice through Javascript

Hello, I am calling websevice through javascript by using SOAPClient and its working in Internet Explorer But not working in Firefox. Actually Its working in firefox also when a webservice within same folder or same project. But it not working in firefox if the webservice is not within same project. For Internet Explorer it works in ...

Query for a ManytoMany Field with Through in Django

Hi All, I have a models in Django that are something like this: class Classification(models.Model): name = models.CharField(choices=class_choices) ... class Activity(models.Model): name = models.CharField(max_length=300) fee = models.ManyToManyField(Classification, through='Fee') ... class Fee(models.Model): activity = m...

ActiveRecord::HasManyThroughAssociationNotFoundError in UserController#welcome

I have a many to many relationship in rails. All database tables are named accordingly and appropriately. All model files are plural and use underscore to seperate words. All naming comventions are followed by ruby and rails standards. I'm using has many through in my models like this: has_many :users, :through => :users_posts #Post...

How to distuingish between Django's automatically created ManyToMany through-models and manually defined ones?

Hi. Say we have models from django.db import models class AutomaticModel(models.Model): others = models.ManyToManyField('OtherModel') class ManualModel(models.Model): others = models.ManyToManyField('OtherModel', through='ThroughModel') class OtherModel(models.Model): pass class ThroughModel(models.Model): pblm = mo...

Include or Exclude existing files/directories from current solution

Hi thr..How can i include or exclude existing files/directories from current solution in c sharp through code.. ...

Set properties of a class only through constructor

Hi , I am trying to make the properties of class which can only be set through the constructor of the same class ...

django aggregation with objects

model: class Product(models.Model): name = models.CharField(max_length = 128) (...) def __unicode__(self): return self.name class Receipt(models.Model): name = models.CharField(max_length=128) (...) components = models.ManyToManyField(Product, through='ReceiptComponent') def __unicode__(self): return self.nam...

django m2m form save " through " table

i'm having trouble in saving a m2m data, containing a 'through' class table. I want to save all selected members (selected in the form) in the through table. But i don't know how to initialise the 'through' table in the view. my code: class Classroom(models.Model): user = models.ForeignKey(User, related_name = 'classroom_creator')...

Window appears "see-through" when trying to append a line of text - Java

I am trying to append a percentage to a text area in java. It involves a loop that determines the percentage and then appends that to another JFrame with the text area in it. The "pro" class simply has a window with a JtextArea. The problem that I am encountering is that the window appears to show the window underneath, as if it were ...

Django - how to access fields in a customized many-to-many through object in templates

Consider the following models: class Person(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') class Membership(models.Model): person = models.ForeignKey(Person) group = models.Forei...

Django: Validation on a Many-to-Many Through model

I have the following models (simplified example): class Book(models.Model): users = models.ManyToManyField(User, through=Permission) class Permission(models.Model): user = models.ForeignKey(User) role = models.ForeignKey(Group) active = models.BooleanField() book = models.ForeignKey(Book) What I need is that for a Book instance ...