Hello,


I have created my own ManyToMany table, but am getting an error when I
attempt to get a related item from one of my Models. Any insight would be
greatly appreciated.  I am on Django 1.3.1. *models/restuarant_hood_map.py*

<import restaurant and hood>
class RestaurantHoodMap(models.Model):
    restaurant = models.ForeignKey(Restaurant)
    hood = models.ForeignKey(Hood)

    class Meta:
        db_table="restaurant_hood_map"
        app_label="delivery"





Error:

AttributeError at <URL>
'str' object has no attribute '_default_manager'



*models/hood.py*

class Hood(models.Model):
    name = models.CharField(unique=True)
    restaurants=models.ManyToManyField("restaurant.Restaurant",
through="restaurant_hood_map.RestaurantHoodMap")

    class Meta:
        db_table = "hoods"
        app_label="delivery"



*models/restaurant.py*

class Restaurant(models.model):
    name=models.ForeignKey(CompanyName)
    is_active=models.BooleanField(default=True)
    hoods=models.ManyToManyField("hood.Hood",
through="restaurant_hood_map.RestaurantHoodMap")

    class Meta:
        db_table="restaurants"
        app_label="delivery"



Now, I know what the problem is.....when I attempt to get the related
restaurants off of Hood, I am getting this error. That's because it's
treating the "restaurant.Restaurant" as a string value. However, I thought
it was accepted to use string values in order to avoid circular
dependencies? At least thats what I thought from the docs:

https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey

However, that doesn't seem to work when you get a Hood object and do
hood.restaurants....it barfs.



Thanks for the help!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to