Managing hierarchial data, with Django

2008-03-09 Thread Tim Adler

Hey everybody,

Django is a wonderful tool. It gives you so much freedom of thought.
Still I got a problem that I can't figure out up to now.

What is the best way for Django to manage hierarchial data? It is
totally possible to add a self-referential foreign-key to every model.
I also was pointed to django-mptt (http://code.google.com/p/django-
mptt/) by some users referring hierarchial data.

Problem is: How does the automated admin (after all djangos killer-
feature) handle these hierarchial models? I'm searching for a solution
for users to easily manage a tree of pages, like in Wordpress, but I
see now way that the automated admin would display such a tree.

I'd be glad for any advise that you guys could give me!


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problems using mptt

2008-03-09 Thread Tim Adler

Hey everybody,

I'm trying to added mptt to my django project for managing a simple
page-tree. It doesn't seem to work, as it is supposed too.

My model looks like this:

from django.db import models
import mptt

class Page(models.Model):
title = models.CharField(maxlength=200)
body = models.TextField()
parent = models.ForeignKey('self', null=True, blank=True,
related_name='pages')

class Meta:
ordering = ['parent']

class Admin:
pass

def __str__(self):
indent = ""
for i in range(self.lvl()):
indent += "-"

return '%s %s' % (indent,self.title)

def level(self):
if(self.parent == None):
return 0
else:
return self.parent.lvl() + 1;

But even in this stage, without the mptt.register, my development
server gives me a

> Validating models...
> djangotree.content: cannot import name ugettext
> 1 error found.

I guess that is related to the mptt, but I have no idea, what might be
causing this.
Can somebody help out?



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Accessing a ManyRelatedManager by introspection for JSON/AJAX ?

2008-06-20 Thread Tim Adler

Hey everybody,

I'm currently trying to build an AJAX-JSON-processor with Django,
which receives a JSON-encoded request and then writes those values to
the database.

Here is what I basically looks like:

{"class":"pages.page",
"id":"1",
"show_more_on_topic":"0",
"show_archive":"1",
"title":"Homepage lala",
"show_global_teasers":"1",
"show_infos":"0",
"show_keywords":"1",
"show_next_dates":"0",
"content":[{"class":"pages.leadcontainer",
"id":"15",
"type":"standard",
"sortKey":"1",
"leads":[{"class":"pages.lead",
"id":"2",
"headline":"value",
"subline":"value",
"anreisser-text":"Lorem ipsum dolor sit amet"},
{"class":"pages.lead ..

I already got it managed to create and save simple Django-objects and
setting their respective attributes. Now I would like to process the
collections that come inside of some of those JSON-arrays. I accessed
the simple attributes through the __dict__-array. Now I need a way to
access those collections and add/delete/recreate them.

How would I do that?

BTW: I know that there is a JSON-(de)serializer. But since in this
case Django shall be the backend of a more sophisticated AJAX-
interaction, I need a little more functionality than just saving and
serializing.
--~--~-~--~~~---~--~~
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: Accessing a ManyRelatedManager by introspection for JSON/AJAX ?

2008-06-26 Thread Tim Adler

This is a sad self-reply. I got around this problem by using eval()
and accessing the collection that way. Be careful with security
though!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Overwriting the save-function in automatic admin?

2006-12-02 Thread Tim Adler

Hey guys,

I've written my blog in Django and am quite happy with it. Yesterday I
implement trackbacks, so that Django kann accept them for posts. Next
goal is to be able to send trackbacks. Since I put all my stuff into my
blog through the automatic admin, my question is: Is there a way to
overwrite the save-function for certain Models?

Here is what I'd like to do: Add a "Trackbacks"-field to my
"Post"-Model and when somebody pushes "Save" in the Admin, it starts
pinging the trackbacks and then save the object afterwards.

Or is there a better way to do that?

Thx in advance. 

Tim


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---