This is my template tag in a forloop
{{ product.feature_set.all.1.value }}
i want to change the number 1 to the forloop.counter. is this posible?
like:
{{
product.feature_set.all.forloop.counter.value
}}
It does not work like that, but is there a way to do this?
...
Situation:
Table book is associated with one or more authors via the _author_book table. It is also associated with one or more genres via the _book_genre table.
When selecting all the books, and all their genres, and all their authors, the number of rows returned is (assume each book has at least one genre and author):
PROBLEM:
book...
I'm in the midst of creating an alarm/notification system for a small Sales CRM app.
I have a Lead_Contact model that is used to store a client's name, address, etc. as well as a Contact_Notifier models that is being used to keep track of when a client was first contacted, the last contact, and when we are going to next contact them.
F...
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 ...
Hi all,
I have an object (User) which has none or many Tags. Any User can have any number of Tags, so there's a join table, user_tags which has a user_id and tag_id field.
In User.hbm.xml, this is mapped as:
<set name="Tags" table="user_tags">
<key column="user_id"/>
<many-to-many column="tag_id"
unique...
I'm building an ecommerce site using S#arp Architecture.
I'm trying to map a hierachy of categories and retrieve the top level categories.
I'm using NHibernate.Linq for this.
I have the following entity:
public class Category : Entity
{
#region Properties
[DomainSignature]
[NotNullNotEmpty]
public virtual string Name {...
I am trying to get a list of product id's that do not have certain colors (database is mysql)
Here are my tables:
product
+------------+-------------+
| product_id | description |
+------------+-------------+
| 1 | Widget 1 |
| 2 | Widget 2 |
| 3 | Widget 3 |
| 4 | Widget 4 |
| 5...
Hi!
I have the following model:
class MyUser(User):
# some fields...
contact = models.ManyToManyField("self", through='Contact', symmetrical=False, related_name="contact_set" )
class Contact(models.Model):
user1 = models.ForeignKey( MyUser, related_name="contact_set1")
user2 = models.ForeignKey( MyUser, related_name="...
I'm facing a problem where I cannot permanently decide which columns one of my models will have.
A use case will be this:
An admin creates a new dataset, he wants users to answer. In the dataset the admin defines several data points of different format and units.
I could imagine the classes to look similar to this:
class Dataset < ...
I'm having some issues with a many-to-many relationship I am trying to create. The goal is to save a customer and which products they are allowed to purchase. The products are not unique to a customer and will ALWAYS exist in the database before we try to associate a customer to them.
My mapping for the association currently looks lik...
I have such database on SQLite:
CREATE TABLE [ArtTag] (
[article_id] integer NOT NULL,
[tag_id] integer NOT NULL,
CONSTRAINT [FK_ArtTag_article_id_Articles_id] FOREIGN KEY ([article_id]) REFERENCES [Articles] ([id]),
CONSTRAINT [FK_ArtTag_tag_id_Tags_id] FOREIGN KEY ([tag_id]) REFERENCES [Tags] ([id])
);
CREATE TABLE [A...
Basic model breakdown:
Movie and MovieGenre models. The Movie model has a field called genres, which is declared as:
genres = models.ManyToManyField(MovieGenre, blank=True)
Here is the issue:
In [42]: frank = Movie.objects.get(id=122)
In [43]: frank.genres.count()
Out[43]: 2
In [44]: frank.genres.all()
Out[44]: [<MovieGenre: Conc...
Considering the following models, knowing a family, how do I select Kids with no buyers?
class Family...
class Kid(models.Model):
name = models.CharField(max_length=255)
family = models.ForeignKey(Family)
buyer = models.ManyToManyField(Buyer, blank=True, null=True)
family = get_object_or_404(Family, pk=1)
for_sale = family...
Django doesn't support displaying of related objects from a many-to-many relation in the changelist for a good reason. It would result in a lot of database hits.
But sometimes it is inevitable and necessary to e.g. display an object's categories, which have a many-to-many relation to the object, in the changelist. Given that case, does ...
My object model is the following:
Item has many Tags and a Tag could belong to many Items
I'd like to execte the following query using criteria's.
SELECT * FROM Item item
where item.Id in (Select it.ItemId from dbo.ItemToTags it where it.Tag_id = 'ONE')
and item.Id in (Select it.ItemId from dbo.ItemToTags it where it.Tag_id = 'TWO')
...
Suppose I have the following models -
class Item(models.Model):
name = models.CharField(max_length=150)
value = models.DecimalField(max_digits=12,decimal_places=2)
class Organization(models.Model):
name = models.CharField(max_length=150)
items = models.ManyToManyField(Item, through='Customizable')
class Customizable(m...
I know there are a lot of other SO entries that seem like this one, but I haven't found one that actually answers my question so hopefully one of you can either answer it or point me to another SO question that is related.
Basically, I have the following query that returns Venues that have any CheckIns that contain the searched Keyword ...
I'm trying to create a many-to-many association between an entity and another many-to-many association. How can that be done?
I followed the Customer/Order/Product example to attach custom properties to a many-to-many association between two of my entities (Categories and Tags). That worked like a charm.
The problem is that now I need ...
I've taken over an application that has a SQL backend. There are multiple tables, but the two that I'm concerned about are these:
QAProfile
---------
ProfileID <pk> -int
ProfileName
SecurityGroups -varchar(max)
SecurityGroups
--------------
GroupID <pk> -int
GroupName
My issue is that the the SecurityGroups field is a comma delimit...
I am working on a Google App Engine application and I am relatively new at this.
I have built an app already in Django and have a model using a field type of ManyToMany.
I am aware that django-nonrel does not support many-to-many field types of Django. So I am considering using ListField instead.
Questions:
- What is the implication ...