class Category(models.Model):
code = models.CharField(maxlength=200, unique=True)
products = models.ManyToManyField('Product')
class Product(models.Model):
parent = models.ForeignKey('Post')
code = models.CharField(maxlength=200, unique=True)
I've also read that you can specify signals for most operations on a
model (Like when a model is inserted, updated or deleted from the
database) though I can't find the URL right now. There's some mention
of it here:
http://www.djangoproject.com/documentation/db-api/
something similar yes. What I'm after is an Django implementation of
an directed acyclic graph. I understand there's some complexity
involved to ensure no cycles can be created (which I understand is the
graph equivalent of an endless loop). There's plenty of good examples
of DAG out there, but I'm not sure how to implement one that works
with RDMS (or Django for that matter!)
Paul
On Sep 17, 4:56 pm, Julio César Carrascal Urquijo
Does someone knows how to do a loop on a int inside template, e.g. :
<div align="left"><font size="-1">Result Page: </font>:
{% for p in pages %}
{% ifequal p page %}
<font color="brown"><strong> {{p}} </strong></font>
{% else %}
<a href="/page/{{p}}/" target="resultframe"> {{p}} </a>
{% endifequal %}
{% endfor %}
</div>
Where pages is an int. Do i have to use a special filter function ?
Cheers,
Vincent.
--
-----------------------<vincent...@cern.ch>------------------------
Vincent Garonne http://cern.ch/vincent.garonne
CERN PH, CH-1211, Geneva 23, Switzerland
Tel. +41 22 76 71181 Fax. +41 22 76 78350
----------------------------------=-------------------------------------
There is a validator IsNotCircular, which does the obvious.
There is code to do serialization (currently just a pickle), but there
are plans to add json to communicate to the client.
The (poor) documentation on using the navbar is here:
https://pycon.coderanger.net/wiki/PyCon08/NavBar
I have other examples of true DAG's in DB form, but they are very
domain specific and take advantage of the
limitations in the data. (like the divided room problem where a
conference room might have 3 parts which can
make a total of 6 'rooms', but have special meaning for room
scheduling). But the NavBar is closest to what
you are trying to do.
Well - looping in Django templates is quite similar to looping in
Python, so you can't 'loop on an int'. You can loop on a range, though
- so if you make pages = range(0,max_page), you will be able to use
the template you describe.
There was some talk over the sprint weekend about adding a 'repeat'
tag, or some equivalent syntax for 'iterate n times'; however, I'm not
sure how far that discussion went.
Yours,
Russ Magee %-)
I also wonder how much a DAG implementation should rely on RDMS
functions to minimize the chatter between the application and
database. For instance, it would be terrible to get a node from the
DB, determine it's parent(s), fetch each parent from the DB, determine
*its* parents, etc. etc. Now I could serialize the parents into the
node data, but don't know if that is going to be effective because if
the parent relationships change you're going to have a lot of
processing to update all your nodes.
I know that a DAG is a subset of a digraph, which is what an RDBMS is,
so I'm sure that there's a very elegant way of doing it. But the
problem for me is (a)determining how to do it from the database
perspective, and (b)how to do it in Django.
Cheers,
Paul
On Sep 18, 8:34 am, "doug.napole...@gmail.com"
<doug.napole...@gmail.com> wrote:
> We use a Tree for the navigation bar (not a true DAG, but there are
> circular checks):https://pycon.coderanger.net/browser/django/trunk/pycon/navbar/models.py
>
> There is a validator IsNotCircular, which does the obvious.
>
> There is code to do serialization (currently just a pickle), but there
> are plans to add json to communicate to the client.
> The (poor) documentation on using the navbar is here:https://pycon.coderanger.net/wiki/PyCon08/NavBar
>
> I have other examples of true DAG's in DB form, but they are very
> domain specific and take advantage of the
> limitations in the data. (like the divided room problem where a
> conference room might have 3 parts which can
> make a total of 6 'rooms', but have special meaning for room
> scheduling). But the NavBar is closest to what
> you are trying to do.
>
> On Sep 17, 4:08 pm, "paul.dorman" <paul.dor...@gmail.com> wrote:
>
> > Thanks for your response Julio,
>
> > something similar yes. What I'm after is an Django implementation of
> > andirectedacyclic graph. I understand there's some complexity
> > involved to ensure no cycles can be created (which I understand is the
> > graph equivalent of an endless loop). There's plenty of good examples
> > of DAG out there, but I'm not sure how to implement one that works
> > with RDMS (or Django for that matter!)
>
> > Paul
>
> > On Sep 17, 4:56 pm, Julio César Carrascal Urquijo
>
> > <jcarras...@gmail.com> wrote:
> > > I'm a newbie on Django my self but maybe this is what you are looking
> > > for:
>
> > > class Category(models.Model):
> > > code = models.CharField(maxlength=200, unique=True)
> > > products = models.ManyToManyField('Product')
>
> > > class Product(models.Model):
> > > parent = models.ForeignKey('Post')
> > > code = models.CharField(maxlength=200, unique=True)
>
> > > I've also read that you can specify signals for most operations on a
> > > model (Like when a model is inserted, updated or deleted from the
> > > database) though I can't find the URL right now. There's some mention
> > > of it here:
>
> > >http://www.djangoproject.com/documentation/db-api/
>
> > > On Sep 16, 9:54 pm, "Paul Dorman" <paul.dor...@gmail.com> wrote:
>
> > > > Hi all,
>
> > > > definite newbie here. I'd like to implement a category type system in
> > > > Django. I've looked in the cookbook and Googled a bit, but to no avail. What
> > > > I'm after should be pretty simple: adirectedgraph for categories, where