Re: Ovreeride django mptt admin queryset

2014-11-21 Thread Collin Anderson
Hi,

Try using get_queryset() instead of queryset().

Collin


On Tuesday, November 18, 2014 8:02:12 AM UTC-5, Neeraj Sharma wrote:
>
> Hi,
>
> I want to override django mptt admin queryset, i want to filter the the 
> queryset.
> I also tried the following method in admin.py  but its not working.
>
>
> def queryset(self, request):
> qs = super(DataField_NEWAdmin, self).queryset(request) 
> return qs.filter(game_event__id=10)
>
> In admin.py when i check queryset then it shows desired queryset but in 
> admin panel/dashboard, it display the all records.
> Please help
>

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e353c7d-d591-4bc6-bfb2-de53eadca026%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Override Django Mptt Admin Queryset

2014-11-18 Thread Neeraj Sharma
Hi,

I want to override django mptt admin queryset, i want to filter the the 
queryset.
I also tried the following method in admin.py  but its not working.


def queryset(self, request):
qs = super(DataField_NEWAdmin, self).queryset(request) 
return qs.filter(game_event__id=10)

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db59631b-9889-4cc6-8ccc-074d05da07fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Ovreeride django mptt admin queryset

2014-11-18 Thread Neeraj Sharma
Hi,

I want to override django mptt admin queryset, i want to filter the the 
queryset.
I also tried the following method in admin.py  but its not working.


def queryset(self, request):
qs = super(DataField_NEWAdmin, self).queryset(request) 
return qs.filter(game_event__id=10)

In admin.py when i check queryset then it shows desired queryset but in 
admin panel/dashboard, it display the all records.
Please help

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/905d05c0-2c47-4230-9cc6-6c95a6807643%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


override django mptt admin querset

2014-11-18 Thread Neeraj Sharma
Hi,

I want to override django mptt admin queryset, i want to filter the the 
queryset.
I also tried the following method in admin.py  but its not working.


def queryset(self, request):   

qs = super(DataField_NEWAdmin, self).queryset(request) 
qs.filter(game_event__id=request.GET.get("game_event__id"))



-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ee64a3d-6653-492f-95e7-be526094b4ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django MPTT Admin

2014-11-11 Thread Neeraj Sharma
Thanx for your quick response Matthias Kestenholz, but i actually i want to 
use MPTT Admin as an inline form, code you have written will work as a 
normal admin form

On Thursday, 26 February 2009 15:12:15 UTC+5:30, Matthias Kestenholz wrote:
>
> Hey,
>
> A topic which comes up on this list from time to time is an automatic
> admin interface for django-mptt. I'd like to advertise a piece of code
> we have written at our company a little bit, and I'd also like to invite
> everyone to give comments and feedbacks. I do have many more ideas
> floating around, and there are a couple of issues still open, but I think
> the code is ready for wider review and maybe usage, who knows?
>
>
> The current version of the code generates an interface with drag/drop
> capabilities for managing mptt-based trees. It's still very clear that the
> code was extracted from a `classical' page cms. All you need to do
> is the following:
>
>
> -- 8< --
>
> from django.db import models
>
> class Category(models.Model):
> title = models.CharField(max_length=200)
> parent = models.ForeignKey('self', related_name='children',
> blank=True, null=True)
>
> -- 8< --
>
> from django.contrib import admin
> from feincms.admin import editor
>
> class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
> pass
>
> admin.site.register(Category, CategoryAdmin)
>
> -- 8< --
>
> The generated admin interface looks like that:
>
> http://spinlock.ch/pub/feincms/category_tree_admin.png
>
> The page cms feeling is still very much there, but we'll see.
>
> In any case, you'll find the code on github:
> http://github.com/matthiask/feincms/tree/master
>
>
> Thanks,
> Matthias
>
>
> -- 
> "Programming is an art form, like the creation
> of poetry or music." (Donald E. Knuth, 1974)
>
>

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5031d94b-aa72-4607-b53c-b4818e7bd6fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django MPTT Admin

2014-11-11 Thread Neeraj Sharma
Thanx for your quick response Matthias Kestenholz, but i actually i want to 
use MPTT Admin as an inline form, code you have written will work as a 
normal admin.

On Thursday, 26 February 2009 15:12:15 UTC+5:30, Matthias Kestenholz wrote:
>
> Hey,
>
> A topic which comes up on this list from time to time is an automatic
> admin interface for django-mptt. I'd like to advertise a piece of code
> we have written at our company a little bit, and I'd also like to invite
> everyone to give comments and feedbacks. I do have many more ideas
> floating around, and there are a couple of issues still open, but I think
> the code is ready for wider review and maybe usage, who knows?
>
>
> The current version of the code generates an interface with drag/drop
> capabilities for managing mptt-based trees. It's still very clear that the
> code was extracted from a `classical' page cms. All you need to do
> is the following:
>
>
> -- 8< --
>
> from django.db import models
>
> class Category(models.Model):
> title = models.CharField(max_length=200)
> parent = models.ForeignKey('self', related_name='children',
> blank=True, null=True)
>
> -- 8< --
>
> from django.contrib import admin
> from feincms.admin import editor
>
> class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
> pass
>
> admin.site.register(Category, CategoryAdmin)
>
> -- 8< --
>
> The generated admin interface looks like that:
>
> http://spinlock.ch/pub/feincms/category_tree_admin.png
>
> The page cms feeling is still very much there, but we'll see.
>
> In any case, you'll find the code on github:
> http://github.com/matthiask/feincms/tree/master
>
>
> Thanks,
> Matthias
>
>
> -- 
> "Programming is an art form, like the creation
> of poetry or music." (Donald E. Knuth, 1974)
>
>

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/83c717f4-12a6-4d01-88e6-0e8a4a0d9425%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django MPTT Admin

2014-11-11 Thread Neeraj Sharma
*How to use Django Mttp Admin as an Inline in admin.py* *?*

On Thursday, 26 February 2009 15:12:15 UTC+5:30, Matthias Kestenholz wrote:
>
> Hey,
>
> A topic which comes up on this list from time to time is an automatic
> admin interface for django-mptt. I'd like to advertise a piece of code
> we have written at our company a little bit, and I'd also like to invite
> everyone to give comments and feedbacks. I do have many more ideas
> floating around, and there are a couple of issues still open, but I think
> the code is ready for wider review and maybe usage, who knows?
>
>
> The current version of the code generates an interface with drag/drop
> capabilities for managing mptt-based trees. It's still very clear that the
> code was extracted from a `classical' page cms. All you need to do
> is the following:
>
>
> -- 8< --
>
> from django.db import models
>
> class Category(models.Model):
> title = models.CharField(max_length=200)
> parent = models.ForeignKey('self', related_name='children',
> blank=True, null=True)
>
> -- 8< --
>
> from django.contrib import admin
> from feincms.admin import editor
>
> class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
> pass
>
> admin.site.register(Category, CategoryAdmin)
>
> -- 8< --
>
> The generated admin interface looks like that:
>
> http://spinlock.ch/pub/feincms/category_tree_admin.png
>
> The page cms feeling is still very much there, but we'll see.
>
> In any case, you'll find the code on github:
> http://github.com/matthiask/feincms/tree/master
>
>
> Thanks,
> Matthias
>
>
> -- 
> "Programming is an art form, like the creation
> of poetry or music." (Donald E. Knuth, 1974)
>
>

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8598b799-6371-4346-abd2-39c7726189a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-mptt

2014-08-07 Thread Collin Anderson
It should be pretty easy to upgrade your project from 1.4 to 1.4.2, as not 
much changed between those versions.

On Thursday, August 7, 2014 3:38:15 AM UTC-4, Akshay Mukadam wrote:
>
> Is there any way that I can install django-mptt for django 1.4.
> Currently django-mptt is available for django1.4.2. But I require it for 
> my old project which is based onn django 1.4 
> Please help
> Thank you
>

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6b28a67b-64e9-4420-835e-11d0d8daf523%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django-mptt

2014-08-07 Thread Akshay Mukadam
Is there any way that I can install django-mptt for django 1.4.
Currently django-mptt is available for django1.4.2. But I require it for my 
old project which is based onn django 1.4 
Please help
Thank you

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d3f7267a-813d-4e82-9233-144e3d74f27c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


example on django mptt

2013-05-28 Thread Randa Hisham
-- 
Randa Hesham
Software Developer

Twitter:@ro0oraa 
FaceBook:Randa Hisham 

ٍ

-- 
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 group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django MPTT - breadcrumb in view function

2012-10-13 Thread Cal Leeming [Simplicity Media Ltd]
Hi,

Personally, I tend to keep the breadcrumb logic completely separate from
any custom code logic.

Instead, I have something like this:

context['breadcrumb'] = ['menu1', 'sub menu 2', 'sub sub menu 3']

And then in the templates, you'd have something like;

{% if x.0 == 'menu1' %}
do something custom here
{% endif %}

{% for x in breadcrumb %}
{{x}}
{% endfor %}

{% include "breadcrumb.html" %}

Although many would probably disagree with this approach, I have found that
keeping breadcrumbs completely separate makes things easier down the line..
Otherwise you end up having to create a breadcrumb system that works with
every use case.. and it often gets ugly.

The above is just my personal opinion based on our own specific use cases,
and I would strongly recommend looking around at alternative ways of doing
it, then finding one that suits what you need.

Hope this helps.

Cal

On Sat, Oct 13, 2012 at 9:53 PM, enemybass  wrote:

> How to create breadcrumb in my view function?
>
> class Category(MPTTModel):
> name = models.CharField(max_length=50, verbose_name=u'Name')
> parent = TreeForeignKey('self', null=True, blank=True,
> related_name='children')
> slug = models.SlugField()
>
> class Product(models.Model):
> name = models.CharField(max_length=50, verbose_name=u'Name')
> slug = models.SlugField()
> category = models.ManyToManyField(Category,
> verbose_name=u'Category')
>
> #views
> def post_content(request, product_id):
> product = get_object_or_404(Product, id = product_id)
> return render_to_response('product_info.html',
> {'product':product},context_instance=RequestContext(request))
>
> product_info.html
>
> {{ product.name }}
>
>
> I want in my single post info (`post_content`) breadcrumb with category.
> Something like this:  Category > Subcategory > Sub-Subcategory .,,,
>
> Someone told me to use *get_ancestors:*
> *
> *
> *Example:*
> *
> *
> {% for parent in category.get_ancestors %}
>   {{ parent.name }} 
> {% endfor %}
> {{ category.name }}
>
> How to implement this with my model?
>
> Thank you. I would be grateful.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/ivQ6G2h8UT0J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Django MPTT - breadcrumb in view function

2012-10-13 Thread enemybass
How to create breadcrumb in my view function?

class Category(MPTTModel):
name = models.CharField(max_length=50, verbose_name=u'Name')
parent = TreeForeignKey('self', null=True, blank=True, 
related_name='children')
slug = models.SlugField()

class Product(models.Model):
name = models.CharField(max_length=50, verbose_name=u'Name')
slug = models.SlugField()
category = models.ManyToManyField(Category, 
verbose_name=u'Category')

#views
def post_content(request, product_id):
product = get_object_or_404(Product, id = product_id)
return render_to_response('product_info.html', 
{'product':product},context_instance=RequestContext(request))

product_info.html

{{ product.name }}


I want in my single post info (`post_content`) breadcrumb with category.
Something like this:  Category > Subcategory > Sub-Subcategory .,,,

Someone told me to use *get_ancestors:*
*
*
*Example:*
*
*
{% for parent in category.get_ancestors %}
  {{ parent.name }} 
{% endfor %}
{{ category.name }}

How to implement this with my model?

Thank you. I would be grateful.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ivQ6G2h8UT0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-mptt compared w/ django-treebeard

2012-02-03 Thread Aljoša Mohorović
On Thu, Feb 2, 2012 at 8:13 PM, creecode  wrote:
> I wouldn't assume that just because something hasn't been updated for awhile
> that it isn't good.

like i said, i've used treebeard w/o problems so i don't think it's bad.
my question/interest is mostly because i've noticed that most projects use mptt.

Aljosa

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



Re: django-mptt compared w/ django-treebeard

2012-02-03 Thread Matt Stevens
*I used django-mptt (combined with FeinCMS's TreeEditor) on a few of my
Django sites, it's brilliant.*
*Any questions I've had have been quickly answered, usually by the
maintainer** Craig de Stigter… he's pretty sharp.*
*
*
*
*
*Matt. Stevens | www.dirtymonkey.co.uk*

On Wed, Feb 1, 2012 at 5:46 PM, Aljosa Mohorovic <aljosa.mohoro...@gmail.com
> wrote:

> when using django-mptt or django-treebeard did anybody have bad
> experience?
> i've used treebeard before w/o problems but it looks like mptt is
> maintained and has newer releases and treebeard last release was in
> 2010.
>
> can anybody comment on possible future development/maintenance for
> these projects?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: django-mptt compared w/ django-treebeard

2012-02-02 Thread creecode
Hello Aljosa,

I wouldn't assume that just because something hasn't been updated for 
awhile that it isn't good.  It simply could be that the app does what it 
needs to and there hasn't been a reason to change it.  You might want to 
contact the app authors and ask if their projects are actively maintained.

Toodle-looo.
creecode

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/3wQ_QTSjmwEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-mptt compared w/ django-treebeard

2012-02-01 Thread Aljosa Mohorovic
when using django-mptt or django-treebeard did anybody have bad
experience?
i've used treebeard before w/o problems but it looks like mptt is
maintained and has newer releases and treebeard last release was in
2010.

can anybody comment on possible future development/maintenance for
these projects?

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



django-mptt-comments app error

2011-12-15 Thread cmc
I am trying to use `django-mptt-comments` app on my django project
however I'm running into problems when I try posting a comment.

I get the error : `AttributeError: 'NoneType' object has no attribute
'level'`

Here is the traceback: https://gist.github.com/1481179

You will notice in the traceback that the error occurs in the appp's
form.py at line 93. Here is what the code looks like: 
https://gist.github.com/1481191

Can anyone tell me what could be causing this problem and how I could
go about fixing it. Thanks.

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



django-mptt

2010-04-08 Thread gradja
Hello all,
I try to use django-mptt, i changed my country model in order to be a
tree

class Country(models.Model):
country_name = models.CharField(max_length=30)
parent= models.ForeignKey('self', null=True, blank=True,
related_name='children')

def __unicode__(self):
return u'%s' % self.country_name

class Customer(models.Model):
name = models.CharField(max_length=30)
address = models.CharField(max_length=30)
website = models.URLField(blank=True)
country = models.ForeignKey(Country, blank=True)

def __unicode__(self):
return self.name
def get_absolute_url(self):
return "/customer/%s/" % self.name
class Meta:
ordering = ['name']

class Field(models.Model):
field_name = models.CharField(max_length=100)
customer = models.ForeignKey(Customer)
country = models.ForeignKey(Country, blank=True)

def __unicode__(self):
return self.field_name
def get_absolute_url(self):
return "/field/%s/" % self.field_name
class Meta:
ordering = ['field_name']
mptt.register(Country, order_insertion_by=['country_name'])

i synchronize the database
CREATE INDEX "coltrane_country_parent_id" ON
"coltrane_country" ("parent_id");
CREATE INDEX "coltrane_country_lft" ON "coltrane_country" ("lft");
CREATE INDEX "coltrane_country_rght" ON "coltrane_country" ("rght");
CREATE INDEX "coltrane_country_tree_id" ON
"coltrane_country" ("tree_id");
CREATE INDEX "coltrane_country_level" ON "coltrane_country" ("level");
CREATE INDEX "coltrane_customer_country_id" ON
"coltrane_customer" ("country_id");
CREATE INDEX "coltrane_field_customer_id" ON
"coltrane_field" ("customer_id");
CREATE INDEX "coltrane_field_country_id" ON
"coltrane_field" ("country_id");

i have the coltrane_country_parent_id" column in the coltrane_country
table
but when i try to access the country page in the admin page , i obtain
this traceback
Caught an exception while rendering: no such column:
coltrane_country.parent_id
Request Method: GET
Request URL:http://127.0.0.1:8000/admin/coltrane/country/
Exception Type: TemplateSyntaxError
Exception Value:Caught an exception while rendering: no such column:
coltrane_country.parent_id
Exception Location: /Library/Python/2.6/site-packages/django/template/
debug.py in render_node, line 81

It s true i don' have the coltrane_country.parent_id, but on the other
hand i have coltrane_country_parent_id.

Can any body help me.
Thanks

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



django-mptt TreeNodeChoiceField

2010-02-11 Thread geraldcor
Sorry to ask such a seemingly silly question, but how do I use
TreeNodeChoiceField in a ModelForm. To create a new node, I created a
ModelForm, and, like other ModelForms, I thought I could just override
the normal form widget. Here are my classes

class Folder(models.Model):
parent = models.ForeignKey('self', null=True, blank=True,
related_name='children')
name = models.CharField(max_length=20, unique=True)

class FolderForm(ModelForm):
parent = TreeNodeChoiceField(queryset=Folder.tree.all(),
level_indicator=u'+--')

class Meta:
model=Folder

I get the error AttributeError: type object 'Folder' has no attribute
'tree'

If I move that statement to the Model class, I don't get the error,
but I can't use that 'tree' Manager.

if I change Folder.tree.all() to
Folder.objects.all().order_by('tree_id') it works mostly well, but
doesn't display the tree nicely like tree.all is supposed to. The docs
are a little ambiguous on the usage of this form field.

Any thoughts on a) how I can use tree manager appropriately or b) hack
it so that I get a queryset that mimics tree.all()?

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



Re: State of the Django MPTT Art?

2010-02-11 Thread Max Battcher

Jon Loeliger wrote:

Folks,

I'd like to add a few MPTT manged data-sets to my projects
so I am wondering what the current state of the MPTT art is.
I'm using Danjgo 1.1.1 right now, and would like to slap down
an MPTT manager in my project that is BSD-ish licensed, allows
multiple, different sets of nodes, and hopefully comes with a
good admin interface too!

Googling shows both django-mptt and -treebeard, but are there
good recommendations pro- or con- for either one?  Or is there
a better third choice out there now?


They both seem quite strong and useful. I think Treebeard edges out 
django-mptt for the fact that it provides a few other managers for tree 
storage besides MPTT. It makes it pretty easy to use the same methods to 
browse/query trees no matter which method they are stored in the 
database. (Plus you can switch between them relatively easily as your 
storage needs change.) I think its documentation does a pretty good job 
describing the trade-offs between the various storage methods it 
supports, and certainly the best form depends on the data being stored.


--
--Max Battcher--
http://worldmaker.net

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



State of the Django MPTT Art?

2010-02-10 Thread Jon Loeliger

Folks,

I'd like to add a few MPTT manged data-sets to my projects
so I am wondering what the current state of the MPTT art is.
I'm using Danjgo 1.1.1 right now, and would like to slap down
an MPTT manager in my project that is BSD-ish licensed, allows
multiple, different sets of nodes, and hopefully comes with a
good admin interface too!

Googling shows both django-mptt and -treebeard, but are there
good recommendations pro- or con- for either one?  Or is there
a better third choice out there now?

Thanks,
jdl

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



Trying to make django-mptt work with inherited models

2009-10-03 Thread phoebebright

Have spent quite a few hours on this one but not familiar enough with
django inerds to make much progress.

Here is the model:

class Stuff(models.Model):
name = models.CharField(max_length=140)
parent = models.ForeignKey('self', null=True, blank=True,
related_name='children')

mptt.register(Stuff)

class ToDo(Stuff):
status = models.CharField(_('status'), max_length=1,
choices=STATUS_CHOICES, default=1)

class Concept(Stuff):
priority = models.CharField(_('status'), max_length=1,
choices=PRIORITY_CHOICES,
default='C')


And the code where I am saving (tried many different options!)

obj = ToDo(**field_vals)
obj.tags = " ".join(set(self.keyw_used))
obj.save()

# add parent
if self.parent:
obj.move_to(self.parent)

obj.save()

Am getting the error  'Options' object has no attribute 'parent_attr'
when trying to add to ToDo.
Error occurring here:
def is_root_node(self):
return getattr(self, '%s_id' % self._meta.parent_attr) is None

This is because the ToDo model is not in the mptt registery.

I tried adding an attribute to register to say it was inherited so
that the __init__ method of mptt would add the ToDo and Concept models
to the registry but not all the fields.  ie.

in models:
mptt.register(Stuff)
mptt.register(ToDo, inherited=True)
mptt.register(Concept, inherited=True)

and hacked __init__:

if model in registry:
raise AlreadyRegistered(
_('The model %s has already been registered.') %
model.__name__)
registry.append(model)

#added by PHB
if not inherited:

# Add tree options to the model's Options
opts = model._meta
opts.parent_attr = parent_attr
opts.right_attr = right_attr


This got me past the first error but it's still putting the mptt
fields in the _meta of the ToDo model and failing in the models
pre_save with:

AttributeError: 'ToDo' object has no attribute 'lft'


I need to find some way of telling django these fields are in the
parent class and not the child.  Any suggestions very welcome as way
out of my depth there!




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



Re: Django MPTT Admin

2009-02-26 Thread Antoni Aloy

2009/2/26 Matthias Kestenholz <matthias.kestenh...@gmail.com>:
>
> Hey,
>
> A topic which comes up on this list from time to time is an automatic
> admin interface for django-mptt. I'd like to advertise a piece of code
> we have written at our company a little bit, and I'd also like to invite
> everyone to give comments and feedbacks. I do have many more ideas
> floating around, and there are a couple of issues still open, but I think
> the code is ready for wider review and maybe usage, who knows?
>
>
> The current version of the code generates an interface with drag/drop
> capabilities for managing mptt-based trees. It's still very clear that the
> code was extracted from a `classical' page cms. All you need to do
> is the following:
>
>
> -- 8< --
>
> from django.db import models
>
> class Category(models.Model):
>    title = models.CharField(max_length=200)
>    parent = models.ForeignKey('self', related_name='children',
> blank=True, null=True)
>
> -- 8< --
>
> from django.contrib import admin
> from feincms.admin import editor
>
> class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
>    pass
>
> admin.site.register(Category, CategoryAdmin)
>
> -- 8< --
>
> The generated admin interface looks like that:
>
> http://spinlock.ch/pub/feincms/category_tree_admin.png
>
> The page cms feeling is still very much there, but we'll see.
>
> In any case, you'll find the code on github:
> http://github.com/matthiask/feincms/tree/master
>
>
> Thanks,
> Matthias
>
>

It seems very nice. I'm going to give it a try. :)

Thank you!



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Django MPTT Admin

2009-02-26 Thread Matthias Kestenholz

Hey,

A topic which comes up on this list from time to time is an automatic
admin interface for django-mptt. I'd like to advertise a piece of code
we have written at our company a little bit, and I'd also like to invite
everyone to give comments and feedbacks. I do have many more ideas
floating around, and there are a couple of issues still open, but I think
the code is ready for wider review and maybe usage, who knows?


The current version of the code generates an interface with drag/drop
capabilities for managing mptt-based trees. It's still very clear that the
code was extracted from a `classical' page cms. All you need to do
is the following:


-- 8< --

from django.db import models

class Category(models.Model):
title = models.CharField(max_length=200)
parent = models.ForeignKey('self', related_name='children',
blank=True, null=True)

-- 8< --

from django.contrib import admin
from feincms.admin import editor

class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
pass

admin.site.register(Category, CategoryAdmin)

-- 8< --

The generated admin interface looks like that:

http://spinlock.ch/pub/feincms/category_tree_admin.png

The page cms feeling is still very much there, but we'll see.

In any case, you'll find the code on github:
http://github.com/matthiask/feincms/tree/master


Thanks,
Matthias




-- 
"Programming is an art form, like the creation
of poetry or music." (Donald E. Knuth, 1974)

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



django-mptt

2008-09-04 Thread peter_g


Hi!

Playing with the wonderful mptt code:
http://code.google.com/p/django-mptt/

I would like to ask if someone knows how to do this:
(I play with some kind of navigation for websites)

I have a tree where some nodes are marked "inactive"
or "deleted". Furthermore, some nodes are to be
displayed in different "places", to render many
navigations at once, e.g.
a horizontal, a vertical, a top, bottom etc. navigation.

One node could be placed in the top "place", wheras
it's children are placed in the vertical place.

Would it be sufficient to work over the "full_tree_for_model"
tag to allow arguments resulting actually in WHERE-clauses
that exclude certain nodes when building the tree?

Thanks!
Peter.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: django-mptt and fixtures

2008-09-03 Thread Martin Diers

The problem with fixtures in documented on the django-mptt page on  
Google code. There is a patch you need to apply to get them to work.  
The patch is not necessary for Trunk, however django-mptt does not  
work on trunk, as too much has changed - in particular, signals.

I would really caution you about this package. Too much magic. Dynamic  
model changes are highly problematic. Their custom manger does a lot  
of stuff in raw SQL (by necessity - it would be way to slow to use the  
ORM). Plus, it's very easy to break things if you are not very careful  
to use their custom manager for your query operations. mptt is great,  
but you should really understand what is going on before using this  
package.


On Sep 3, 2008, at 9:57 AM, pihentagy wrote:

>
> Hi all!
>
> Has anybody tried to load a fixture to a model class, which is
> registered with mptt?
>
> I tried and failed, all the internal columns need to be filled.
> Has anybody a solution how to dump and/or restore such tables?
>
> thanks
> Gergo
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



django-mptt and fixtures

2008-09-03 Thread pihentagy

Hi all!

Has anybody tried to load a fixture to a model class, which is
registered with mptt?

I tried and failed, all the internal columns need to be filled.
Has anybody a solution how to dump and/or restore such tables?

thanks
Gergo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



django mptt and fixtures

2008-04-09 Thread novice

HI,

I am using django mptt and I also want to use fixtures with my
registered model. However, since mptt inserts fields that are NOT
NULL, I was not able to do so.
I found this link
http://code.google.com/p/django-mptt/source/browse/trunk/docs/models.txt?r=100
where it was described that I have to patch django as in this ticket
http://code.djangoproject.com/attachment/ticket/5422/save-send-raw-flag.diff
in order for fixtures to work with django mptt...

I applied the patch but still I get an error like
"problem installing fixutre 'myfixture': mytable.lft may not be NULL

could anyone tell me how I can get past this problem?  [I also want
the hierachy issue taken care of while loading fixutres, i.e. I want
to make sure the "lft" "rght" "tree_id" and "level" field properly
populated while using the loadata]

thanks in advance,
Oumer

PS; while I was looking at the patch, I found that in my current
version of django,  the second line of dispatch to be changed was

dispatcher.send(signal=signals.post_save, sender=self.__class__,
instance=self, created=(not record_exists))

instead of
dispatcher.send(signal=signals.post_save, sender=self.__class__,
instance=self, created=(not record_exists))

so I still kept the created attribute but added raw=raw...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Displaying a Tree view in template using django-mptt

2008-02-25 Thread Manakel

Hello Dear all,

First let me say that i'm very new in term of web based developpemnt
(the HTML/CSS Part). i've always worked on backend logic (in java,
python, etc) never on the end user interface directly.

This said, i'm trying to use the django-mptt to install a simple
hierarchy in my first django app.
And I'm blocked at the view template / level
(ie rendering something for the end user)

At the model level, the integration is successful.
i've registered my Item model in mptt.
My Item has a 'parent' field that is used by mptt to discover parent/
child relation ship.

So i can create some Item hierarchy in a breezeAnd i can use it on
the python command line.

But i can't figure my self how to integrate this in a template.
What i'm looking for is a way to render the whole item Tree.
Each item would have it's own line with it's title
Each item would be a little more on the right side depending on the
depth in the hiearchy
Each item would have a link on the right to edit himself
Each item would have a link on the right to move himself

So i guess i should use the mptt template tag
{% full_tree_for_model myApp.Item as OneItem %}

But then, how do i display for each OneItem
1) OneItem deppth in the tree
2) OneItem title
3) OneItem pk id (to generate the right link)



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---