After hammering everything and starting over from scratch, it occurs to
me... far, far too late... that I might not have restarted apache
before retrying the admin site.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Unfortunately, this is happening even after I dropped the table and
re-sync'd. That's pretty much my SOP after changing a model, to avoid
earlier brushes with what you describe.
Appreciate the reply in any case!
--~--~-~--~~~---~--~~
You received this message
After running ./manage.py syncdb, I have three tables/objects. Admin
index page shows all three. Clicking on two of those tables results in
an error that reads (in part):
"Something's wrong with your database installation. Make sure the
appropriate database tables have been created, and make
So, a solution... or maybe better called a workaround... would be to
have num_in_admin a large enough number to never need paginating. That
doesn't help when I need to update the ingredients, but at least I
could make it work.
Thanks for the heads up!
So, label_ingredient.ingredient.get_absolute_url will work. That's
astonishing, both in it's coolness factor and in the fact I never
picked up on it while reading docs, tutorials and forums.
I'm still not sure I understand how Django manages to know to go get
the Ingredient object, but I'm
Derek,
I appreciate the followup. That works, but I have to say, I don't
understand *why* it works! It's as if Django automagically follows
ForeignKeys, without having to call select_related().
It's also highly confusing that you call
'labelingredient.ingredient.name' and not
I'm not sure I understand. Would the template have it's ingredient info
when it gets to the template? I'm off to mess about with this now, but
I don't see...
Err, wait. Are you suggesting grabbing all the Ingredients in a hash...
err, dict, whatever Python calls it, then pulling
Actually, that leaves out the order information from LabelIngredients.
I had tried to do this with select_related(), but I couldn't get it to
follow the ForeignKey into Ingredients.
Further wizardy (and explanation) would be greatly appreciated!
That looks to have gotten me what I wanted, thanks.
Would you mind explaining how that does what I want, though? I... well,
I don't get it ;)
The actual line was:
Ingredients.objects.filter( labelingredients__baked_good = 4 )
--~--~-~--~~~---~--~~
You received
BakedGoods, LabelIngredients, Ingredients are my tables.
LabelIngredients holds baked_goods_id, ingredients_id and an order
field. I can get the LabelIngredient objects with:
labelingredients = LabelIngredients.objects.filter( baked_good =
self.id ).order_by( 'order' )
... but what I would
As an interesting aside, the following portion of the class
LabelIngredients *does* seem to have an effect:
class Meta:
verbose_name = 'Label Ingredient'
ordering = [ 'order' ]
So the ordering is at least possible!
Yep, but that doesn't work for intermediary tables, because the field
isn't BakedGoods.ingredient, it's LabelIngredients.ingredient_id. Or if
it does work, it has to reference a different table somehow.
I tried adding all that to the intermediary table, but nothing seemed
to have any effect.
Fixed, but not understood...
Another post suggested that the order of the class declaration inside
models.py was important, so I changed mine to reflect that. Order
became Ingredients, BakedGoods, LabelIngredients.
Also based on reading that post, I changed the LabelIngredients class
to:
Nope, you understood just fine. I was trying to order it in the M2Mi
model.
Thanks for the assist!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
Actually, for a further while I'm at it, is there a way to add class:
collapse to the M2M field?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
I have models for baked goods and their ingredients, imaginatively
named BakedGoods and Ingredients. I need to save the order of the
ingredients for purposes of making informative labels. So, there's a
third model, LabelIngredients, that is described by:
baked_good = models.ForeignKey(
Okay, ./manage.py syncdb before ./manage.py sql goods is apparently a
good idea.
So, I've now got a very basic index page loading up as expected.
I'm off for a couple drinks to see if I can wrap my head around how
Django compartmentalizes things and then will endeavor to not bring
many more
I've got my output at least resembling yours now, thanks to your
explanation about the difference between URL config and apps.
I'm using this for urlpatterns:
( r'^$' , 'django.views.generic.simple.direct_to_template' , {
'template' : 'index.html' } ) ,
However, there's a new wrinkle. While
So, what you were *really* suggesting was that PYTHONPATH should
include the project directory, not the django_src directory? I saw that
while skimming through the docs.
I changed PYTHONPATH to reflect that (apparently, adding both
directories in a fit of crankiness doesn't help matters):
Malcolm Tredinnick wrote:
> That should be easy enough to diagnose. My initial guess would be that
> bbg is in django_projects/, rather than django_src/, just from the way
> you named your directories. Remember that .bash_profile is obviously not
> going to be run by Apache (it's not bash,
I'm covering all the bases. Or trying to.
re: django_source: Wow. Uh, thanks. I have no idea why I typed that out
fully in httpd.conf. Fixing that leads to a new error:
EnvironmentError: Could not import settings 'bbg.settings' (Is it on
sys.path? Does it have syntax errors?): No module named
21 matches
Mail list logo