On Mon, Feb 29, 2016 at 4:51 AM, Simon Gunacker
wrote:
> @Mike: the attempts (at least the ones I have seen) to store hierarchical
> data in relations [1] don't seem very intuitive to me. At least when it
> comes to query the data. Anyway: I would appreciate to be
On 7/03/2016 2:17 AM, Mike Dewhirst wrote:
On Thursday, March 3, 2016 at 3:22:04 AM UTC+11, Simon Gunacker wrote:
Inspired by Mike Dewhirsts suggestion on building hierachical
structures,
Not sure we are on the same page regarding "hierarchical". In the early
days hierarchical
On Thursday, March 3, 2016 at 3:22:04 AM UTC+11, Simon Gunacker wrote:
>
> Inspired by Mike Dewhirsts suggestion on building hierachical structures,
>
Not sure we are on the same page regarding "hierarchical". In the early
days hierarchical databases only had 1:n relationships IOW foreign keys
Inspired by Mike Dewhirsts suggestion on building hierachical structures,
I've made up another model:
class Part(models.Model):
parts = models.ForeignKey('Part', null=True, blank=True, default=None,
related_name='pieces')
name = models.CharField(max_length=200)
Then I made my view:
Thank you James. Taking your suggestion, I solved it!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this
On Mon, Feb 29, 2016 at 5:57 AM, Simon Gunacker
wrote:
> Thank you Florian. After James pointed out that I can access my steps (and
> the ingredients in some way) by just passing the recipe object to the
> templates context, I thought of reducing the view to a
Thank you Florian. After James pointed out that I can access my steps (and
the ingredients in some way) by just passing the recipe object to the
templates context, I thought of reducing the view to a DetailView again.
But I have to somehow access the ingredients from my template for now ...
--
On 28/02/16 20:14, Simon Gunacker wrote:
> |
> def detail(request, pk):
> recipe = Recipe.objects.get(id=pk)
> recipe['steps'] = Steps.objects.filter(recipe_id=pk)
> template = loader.get_template('recipe/recipe_detail.html')
> context = {
> 'recipe': recipe,
> }
>
@Mike: the attempts (at least the ones I have seen) to store hierarchical
data in relations [1] don't seem very intuitive to me. At least when it
comes to query the data. Anyway: I would appreciate to be convinced by
something else. However, I am afraid to kick off a completely different
(yet
On 29/02/2016 8:54 PM, Simon Gunacker wrote:
Well, as far as I know hierarchical relationships are hard to model in
relational databases;
Definitely incorrect. Hierarchical is merely a subset of relational.
Relational can handle hierarchical 1:n:m very easily plus n:1, n:m as well.
Ok ... but how can I access the additional information stored in
StepIngredient then?
And - to ask more general - is there a way to find all the "nested objects"
attached to my current objects? Something to enter in the shell to see
__all__ attributes; not just _meta.fields?
--
You received
> Thank you James for pointing me at how to do my queries with django; I
can finally list my steps using:
>
> {% for step in recipe.steps.all %}
>
> within my template. However, given the model above I am still not sure
how to access a single steps ingredients ... any ideas or suggestions on my
Hey everybody,
thank you very much for your answers. I think I have already learned a lot
from you! Well - there is quite a difference between stepping through a
tutorial and trying to do something on my own. Regarding Mikes question
whether a step of a recipe should be a sub-recipe. Well, as
On Sun, Feb 28, 2016 at 11:45 PM, Rahul Gandhi
wrote:
> I might be wrong here, but this is what I understand:
>
> Let's say you have something like this:
>
>
> class Recipe(models.Model):
> name = models.CharField(max_length=255)
> description =
I might be wrong here, but this is what I understand:
Let's say you have something like this:
class Recipe(models.Model):
name = models.CharField(max_length=255)
description = models.TextField()
class Step(models.Model):
step_number = models.IntegerField()
description =
On 29/02/2016 2:09 PM, James Schneider wrote:
Again, I'm making some assumptions about your models. If the above code
snippets don't work (aside from typos), please post up your models.py
file(s) so that we can adjust accordingly.
I think James is right. Maybe the answer to the above question
On Sun, Feb 28, 2016 at 12:23 PM, Simon Gunacker
wrote:
> Thank you Rahul,
>
> I actually tried that an this is possible for the relationship between a
> recipe and its steps. But when it comes to the ingredients for a single
> step, I cannot do this any more since the
On Sun, Feb 28, 2016 at 11:47 AM, Rahul Gandhi
wrote:
> You could do something like this:
>
> def detail(request, pk):
> recipe = Recipe.objects.get(id=pk)
> steps = Steps.objects.filter(recipe_id=pk)
> template =
On Sun, Feb 28, 2016 at 11:14 AM, Simon Gunacker
wrote:
> Dear Django Community,
>
> as a first django project I tried to write a site to manage cooking
> recipes. My model is quite simple:
>
> * 1 recipe has n steps
> * 1 step has a description and n ingredients, each
Thank you Rahul,
I actually tried that an this is possible for the relationship between a
recipe and its steps. But when it comes to the ingredients for a single
step, I cannot do this any more since the ingredients depend on steps
again. After reading your suggestion I thought about it once
You could do something like this:
def detail(request, pk):
recipe = Recipe.objects.get(id=pk)
steps = Steps.objects.filter(recipe_id=pk)
template = loader.get_template('recipe/recipe_detail.html')
context = {
'recipe': recipe,
'steps': steps
}
return
You could do something like this:
Instead of
recipe['steps'] = Steps.objects.filter(recipe_id=pk)
Do this:
steps = Steps.objects.filter(recipe_id=pk)
context = {
'recipe': recipe,
}
On Monday, February 29, 2016 at 1:00:25 AM UTC+5:30, Simon Gunacker wrote:
>
> Dear Django
Dear Django Community,
as a first django project I tried to write a site to manage cooking
recipes. My model is quite simple:
* 1 recipe has n steps
* 1 step has a description and n ingredients, each of a certain amount
defined by a certain unit
all in all, I have 5 tables (Recipe, Step,
23 matches
Mail list logo