Re: Nested Relationships between tables in Django Database API

2006-12-09 Thread Russell Keith-Magee

On 12/10/06, Darin Lee <[EMAIL PROTECTED]> wrote:
> In the console, if I populate the Contest, the instance produces a
> "category_set" method/property (as expected and documented). However,
> if you "dir(c.category_set)" there is no "finalist_set" method/
> property in the category_set's namespace...

That's because c.category_set is a manager object describing a _set_
of categories. Each item in the set will have its own unique
finalist_set member: for example:

for cat in c.category_set.all():
   print cat.finalist_set.all()

or

c.category_set.all()[0].finalist_set.all()

> So, am I correct in
> surmising that the current implementation of the ORM will not
> currently work with this type of DB model (2 level indirection)? Is
> there a workaround? Any thoughts or suggestions are most welcome.

Django _does_ support multiple levels of relations, in both the object
structure and the query language - you just have to keep a careful
track of when you have an object, and when you have a list of objects.

Yours,
Russ Magee %-)

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



How to change the representation of newline?

2006-12-09 Thread zhongke chen
When I input some text with newline characters in TextField under
admin page, I found that the newline character in database is
represented as \r\n. My django site is running at linux, other program
under linux always treat newline as \n. This cause some compatible
problems. How can I change the representation of newline?

-- 
Yours, Zhongke Chen 陈忠克

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



newforms: MultipleChoiceField with CheckboxSelectMultiple

2006-12-09 Thread Ceph

I'm toying around with converting my forms over to newforms and have
come across a problem which may be just user error.

I have a form:

class AddForm(Form):
flags = MultipleChoiceField(choices=[("A", "Aquatic"), ("C",
"Canopy")])

I have a view, which for the moment, is just trying to redisplay the
contents of the form:

def view(request):
form = AddForm(request.POST)
return render_to_response("test.html", {"form": form})

The problem is coming from request.POST. It doesn't handle same-named
fields. The data is there in request.raw_post_data.

This worked before when the checkbox fields had unique names, but now
they all have identical names.

Am I approaching this wrong?


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



Nested Relationships between tables in Django Database API

2006-12-09 Thread Darin Lee

Hi All,

Just curious, does the Django Database API support nested  
relationships more than one level deep? It's starting to look like it  
doesn't... for example, let's say I have three tables: Contest,  
Categories, and Finalists; related as such: Contest, Category foreign  
keys to Contest, Finalist foreign keys to Category (a nested  
relationship).

Let's continue with the example of a "talent contest":
A (Contest) contains the actual contest details (date and time it  
occurred, judges, a description, location, etc.)
B (Category) contains the contest's associated categories (juggling,  
music, tight-rope-walking, etc.)
C (Finalist) contains the finalists for each category (1st place, 2nd  
place, 3rd place).

As you can see, table C is related to A, but only indirectly via B  
(hence the nested relation). Here is an extremely simplified model  
for the purpose of illustration:

class Contest(models.Model):
 name = models.CharField(maxlength=100)

 def __str__(self):
 return "Contest: %s" % self.name

 class Admin:
 pass

class Category(models.Model):
 name = models.CharField(maxlength=100)
 contest = models.ForeignKey(Contest)

 def __str__(self):
 return self.name

class Finalist(models.Model):
 name = models.CharField(maxlength=100)
 category = models.ForeignKey(Category)

 def __str__(self):
 return self.name

In the console, if I populate the Contest, the instance produces a  
"category_set" method/property (as expected and documented). However,  
if you "dir(c.category_set)" there is no "finalist_set" method/ 
property in the category_set's namespace... So, am I correct in  
surmising that the current implementation of the ORM will not  
currently work with this type of DB model (2 level indirection)? Is  
there a workaround? Any thoughts or suggestions are most welcome.

Hopefully all of this makes sense... thanks in advance,
-D






--~--~-~--~~~---~--~~
 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: Extending User

2006-12-09 Thread [EMAIL PROTECTED]

Sorry. Can't believe I forgot to mention that part!

The error was that theid could not be found in the database. Which made
no sense to me since I was trying to create a new user.

I was able to do this, however, after much experimentation:

new_user = user_profile.objects.create(user_id=the_user.id)

Thanks though.

-Dougal

On Dec 9, 10:58 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 12/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > new_profile = user_profile(user=some_user)
>
> > but it gives me an error.What error? Without seeing the exact error 
> > message, it's hard to debug ;)
>
> --
> "May the forces of evil become confused on the way to your house."
>   -- George Carlin


--~--~-~--~~~---~--~~
 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: Re: Extending User

2006-12-09 Thread James Bennett

On 12/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> new_profile = user_profile(user=some_user)
>
> but it gives me an error.

What error? Without seeing the exact error message, it's hard to debug ;)

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

--~--~-~--~~~---~--~~
 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: Extending User

2006-12-09 Thread [EMAIL PROTECTED]

I am having this exact issue. How does one instantiate a userprofile
object?

I've tried something like

new_profile = user_profile(user=some_user)

but it gives me an error.

I'm really not sure what to do, I follow the guide linked above but now
I'm stuck.

Thanks in advance.

-Dougal

On Dec 2, 6:00 pm, "scum" <[EMAIL PROTECTED]> wrote:
> > 1. You have to explicitly instantiate and save aUserProfileobject
> > before get_profile() will do anything -- Django will not implicitly
> > create objects for you in the shell like that.This is what I need to know.  
> > Thanks James.


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



forms and one-to-many relationships

2006-12-09 Thread mfremont

I'm trying to create a simple invoice application where an Invoice has
(0..n) LineItems.

I've created form that contains a few entries for line items, and using
the standard AddManipulator I'm able to save a new invoice and its line
items to the database.

But I would like to add some code that performs a few calculations
before the new objects are saved to the database:

1. for each LineItem, compute extended = quantity * unit_price

2. Invoice.subtotal = sum(LineItem.extended)

3. Invoice.taxAmount = sum(LineItem.extended if LineItem.isTaxable) *
taxRate

4. Invoice.total = Invoice.subtotal + Invoice.taxAmount

Writing recalc methods that perform these operations on the model
objects is pretty simple, but how can I invoke such logic before the
objects are actually saved in the database?

Overriding save() in the model class doesn't work because
db.models.manipulators.AutomaticManipulator.save() creates and saves
the parent (Invoice) before creating the related children (LineItem).

Is there a method to extract a new instance of a model object from the
POST data without calling save()?


Thanks for your help,

Matthew


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



Newforms and composite widgets

2006-12-09 Thread Brian Victor

One of the things I was hoping for in newforms but haven't found is a
way to do a composite form field that uses multiple  elements
that reduce to a single python object.  E.g.,

>>> class MyForm(Form):
... postdate = CompositeField(ChoiceField(choices=['Jan', ...]),
...   ChoiceField(choices=range(1,32)),
...   ChoiceField(choices=range(2000,2010)))
...
>>> str(MyForm())
'PostdateJan'
(and so forth, with select fields for all three before closing the td/tr))

If clean() were called on my hypothetical composite field above, it
would return a single datetime object.

Is there a way to obtain this behavior?

-- 
Brian

--~--~-~--~~~---~--~~
 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: Template extending problem

2006-12-09 Thread Don Arbow

On Dec 9, 2006, at 10:56 AM, mezhaka wrote:
>
> try
> {% extends "/blog/base.html" %}
> instead of
> {% extends "/blog/base" %}



In addition, he should remove the leading '/' from the path in the  
extends clause. If you code a leading slash, os.path.join() ignores  
the template path.

Don



--~--~-~--~~~---~--~~
 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: Template extending problem

2006-12-09 Thread Kai Kuehne

Hi Baurzhan,

On 12/10/06, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote:
> Hello Kai,
>
> On Sun, Dec 10, 2006 at 12:23:09AM +0100, Kai Kuehne wrote:
> > > {% extends "/blog/base" %}
> > Doesn't work.
>
> {% extends "blog/base.html" %} works for me.

Ok, it was the leading slash, thanks! :)


> With kind regards,

Kai

--~--~-~--~~~---~--~~
 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: Template extending problem

2006-12-09 Thread Baurzhan Ismagulov

Hello Kai,

On Sun, Dec 10, 2006 at 12:23:09AM +0100, Kai Kuehne wrote:
> > {% extends "/blog/base" %}
> Doesn't work.

{% extends "blog/base.html" %} works for me.

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.com/

--~--~-~--~~~---~--~~
 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: Template extending problem

2006-12-09 Thread Kai Kuehne

Sorry, forget to paste the blog/base.html. So, here it is:

{% load comments.comments %}

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
http://www.w3.org/1999/xhtml";>

My django blog: {% block title %}Generic Page{%
endblock %}


{% block extrahead %}{% endblock %}





Home
Archives
About Me



{% block content %}{% endblock %}





Greetings
Kai

--~--~-~--~~~---~--~~
 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: problem with django settings module

2006-12-09 Thread Baurzhan Ismagulov

On Sat, Dec 09, 2006 at 03:03:15PM -0800, Snirp wrote:
> That does not work Baurzhan, still the same error.
> 
> [C:\temp\mysite] has now been set in the following locations:
> 
> - As a value of the system variable "DJANGO_SETTINGS_MODULE"
> - In sys.path
> - As a PYTHONPATH windows registry value

Have you tried setting both variables in the system settings to the
values from my last e-mail and restarting the cmd shell you are starting
manage.py from? If you did and it didn't work for you, send the output
of the "set" command in cmd and the error message from manage.py.

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.com/

--~--~-~--~~~---~--~~
 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: Template extending problem

2006-12-09 Thread Kai Kuehne

Hi,

On 12/9/06, mezhaka <[EMAIL PROTECTED]> wrote:
>
> try
> {% extends "/blog/base.html" %}
> instead of
> {% extends "/blog/base" %}

Doesn't work.
Kai

--~--~-~--~~~---~--~~
 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: problem with django settings module

2006-12-09 Thread Snirp

That does not work Baurzhan, still the same error.

[C:\temp\mysite] has now been set in the following locations:

- As a value of the system variable "DJANGO_SETTINGS_MODULE"
- In sys.path
- As a PYTHONPATH windows registry value

None of this works.


--~--~-~--~~~---~--~~
 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: cyrillic text garbled if used as question in polls example

2006-12-09 Thread Baurzhan Ismagulov

Hello Anton,

On Sat, Dec 09, 2006 at 08:49:25PM +0200, Anton Daneika wrote:
> I tried entering a Cyrillic text for the poll question attribute, while
> playing with example polls application. This resulted in a bunch of question
> marks on the view page, instead of the expected "Как дела?" poll question,
> which was in Cyrillic.

In my experience, text can get broken on each and every step.

First, I would try to see whether the browser sends it correctly using a
dumping HTTP proxy (netcat or a simple perl script). Then, check whether
it is written correctly to the database (e.g., issue a SELECT in mysql).
Then, see if it is displayed correctly.

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.com/

--~--~-~--~~~---~--~~
 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: problem with django settings module

2006-12-09 Thread Baurzhan Ismagulov

Hello Snirp,

On Sat, Dec 09, 2006 at 08:20:02AM -0800, Snirp wrote:
> environment variable DJANGO_SETTINGS_MODULE undefined

I assume mysite is the project you've created under c:\temp using
"django-admin.py startproject mysite". To use the shell, you need to
have the following environment variables set:

PYTHONPATH = c:/temp
DJANGO_SETTINGS_MODULE = mysite.settings

I haven't tested this, so you may have to play with the PYTHONPATH
format (slashes, etc.).


> >>>import sys
> >>>sys.path.append('c:/temp/mysite')
> 
> This appends the directory to sys.path, but it does not save it I to
> the path module I guess.

sys.path.append affects only the process it is called in. Setting
PYTHONPATH should work for you.


With kind regards,
Baurzhan.

--~--~-~--~~~---~--~~
 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: problem with django settings module

2006-12-09 Thread Snirp

Well, i succeeded in importing the path into sys.path by making a
".PTH" file. This however did not solve anything yet.


--~--~-~--~~~---~--~~
 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: M2M - 'backward' relationship

2006-12-09 Thread conrad22

It's ok. I've found the answer in another post from tonight (on
'combining' generic views).


http://groups.google.com/group/django-users/browse_thread/thread/609a869092acf42c/e7690f2b19812003?#e7690f2b19812003


--~--~-~--~~~---~--~~
 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: Template extending problem

2006-12-09 Thread mezhaka

try
{% extends "/blog/base.html" %}
instead of
{% extends "/blog/base" %}
by the way what does the blog/base.html looks like?

On Dec 9, 8:10 pm, "Kai Kuehne" <[EMAIL PROTECTED]> wrote:
> Hi list!
> I've got a problem:
>
> settings.py:
> TEMPLATE_DIRS = ( '/home/kai/Projekte/kaikuehne/templates' )
>
> home.html:
> {% extends "/blog/base" %}
>
> I get the following error:
>  "Template '/blog/base' cannot be extended, because it doesn't exist"
>
> But, the file does exist:
> $ ls -l /home/kai/Projekte/kaikuehne/templates/blog/base.html
> -rw-r--r-- 1 kai kai 1109 2006-12-09 19:19
> /home/kai/Projekte/kaikuehne/templates/blog/base.html
>
> Did I make a mistake? What's wrong here?
>
> Thank you :)
> Kai
> 
> PS: Both base.html and home.html are stored in the same folder.


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



cyrillic text garbled if used as question in polls example

2006-12-09 Thread Anton Daneika
Hello, django users.

I tried entering a Cyrillic text for the poll question attribute, while
playing with example polls application. This resulted in a bunch of question
marks on the view page, instead of the expected "Как дела?" poll question,
which was in Cyrillic.
My firefox character encoding is set to UTF-8;
the following command:
$ env | grep -i utf
yields to
LANG=en_AU.UTF-8

Has anyone faced that problem before?
Am I supposed to switch something else in django or MySQL to get the
cyrillic text or am I doing something stupid?

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



problem with django settings module

2006-12-09 Thread Snirp

I am following the tutorials from the Dajngo book. At chapter four, i
am first getting the following error after runnning
>>>from django.template import Template
in the python shell.

environment variable DJANGO_SETTINGS_MODULE undefined


Next i tried to fix this by adding a Windows system variable:

variable:  DJANGO_SETTINGS_MODULE
path:  c:/temp/mysite  (this is where my project lives)

Now after running the above command I get the following errors:

raise EnvironmentError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings 'c:\temp\mysite' (Is it on
sys.path? Does it have syntax errors?): No module named c:\temp\mysite


I tried adding the path to mysite to the sys.path of python.

>>>import sys
>>>sys.path.append('c:/temp/mysite')

This appends the directory to sys.path, but it does not save it I to
the path module I guess. The next time I imported sys, it was gone
again. How do I do this. Will it solve my problem?

Thx


--~--~-~--~~~---~--~~
 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: is there a way to combine generic views?

2006-12-09 Thread machineghost

>> I want a page which displays both the details of an object and the list of
>> the objects.
Really important question: is the object you want the details of
related to the list of objects, via a ForeignKey or ManyToManyField?
Because if so, you don't need to do any view combination at all. (Of
course, if they are unrelated, everything everyone else said about
extending generic views is dead on).

One thing that no one here has mentioned, and which the documentation
also does a poor job of mentioning (presumably because it explains
models before it explains templates, and thus doesn't want to get in to
template details when it explains model realtionships) is that if you
define relationships between objects, you can access related objects in
templates.  For instance, let's say you have these models:
class UL(models.Model):
pass
class LI(models.Model):
UL = models.ForeignKey(UL)
name = models.TextField()
Using the object detail generic view on UL will give you an "object"
variable in your template for the given UL.  This variable will have an
attribute (my terminology may be a little off here, but I'm too lazy to
look up the correct phrase, so just look at my examples if you're
confused): "li_set".  This attribute in turn has two attributes: "all",
and "count".  You can use these attributes to access the related LI's.
For instance, using:
{{ object.li_set.count }}
in your template will return the number of LI objects that have a
foreign key of this particular UL object's ID.  Similarly, using:
{% for li in object.li_set.all %}
{{ li.name }}
{% endfor %}
will return the names of all of the LI's associated with this
particular UL object.

Hope that helps.

Jeremy


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



Template extending problem

2006-12-09 Thread Kai Kuehne

Hi list!
I've got a problem:

settings.py:
TEMPLATE_DIRS = ( '/home/kai/Projekte/kaikuehne/templates' )

home.html:
{% extends "/blog/base" %}

I get the following error:
 "Template '/blog/base' cannot be extended, because it doesn't exist"

But, the file does exist:
$ ls -l /home/kai/Projekte/kaikuehne/templates/blog/base.html
-rw-r--r-- 1 kai kai 1109 2006-12-09 19:19
/home/kai/Projekte/kaikuehne/templates/blog/base.html

Did I make a mistake? What's wrong here?

Thank you :)
Kai

PS: Both base.html and home.html are stored in the same folder.

--~--~-~--~~~---~--~~
 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: TemplateDoesNotExist, in spite of "File Found" message

2006-12-09 Thread Dave Lowe

Ahah! I was sure I had already gone through the template files and
checked permissions, but this time around home.html wasn't correct. I
changed it along with all the css and image files and the site works
again. Thanks Jeremy.


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



startup code

2006-12-09 Thread Joseph Wenninger

Hi !

I have some tasks to do at startup time, or at the first access of an 
application (some cleanup of "persistent" ajax states). How do I implement 
that best in a way that it works with the development server and with 
mod_python ?

I tried putting it into the __init__.py of my application, but for instance 
the development server executes the statements two times (reloader and real 
process)

I thought about caching a value in a memcache, but I'm not sure that is the 
best way.  Is there a way to define some startup handlers, which I have 
missed ?

Kind regards
Joseph Wenninger

-- 
Do not dream your life but live your dreams!
KATE developer - Joseph Wenninger <[EMAIL PROTECTED]>

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



M2M - 'backward' relationship

2006-12-09 Thread conrad22

In the API documentation it says:
Many-to-many relationships

"Both ends of a many-to-many relationship get automatic API access to
the other end. The API works just as a "backward" one-to-many
relationship.
The only difference is in the attribute naming: The model that defines
the ManyToManyField uses the attribute name of that field itself,
whereas the "reverse" model uses the lowercased model name of the
original model, plus '_set' (just like reverse one-to-many
relationships)."

Problem is, the examples it goes on to give of all the things that you
can do with a M2M model need more knowledge of Python than I have. So
can somebody point me in the right direction?

Here are my models(abbreviated):


class Category (models.Model):

category = models.CharField (maxlength = 100)
slug = models.CharField(maxlength=50, unique=True,
prepopulate_from=('category',))
class Meta:
verbose_name_plural = "categories"


def __str__(self):
return self.category

def get_absolute_url(self):
return self.slug


class Organisation (models.Model):

org_name = models.CharField ('Organisation', maxlength = 200)
categories = models.ManyToManyField (Category, filter_interface
=models.HORIZONTAL)

def __str__(self):
return self.org_name

def get_absolute_url(self):
return self.slug




Now, using the category_list and/or category_detail GENERIC templates,
what on earth do I put in to return a list of Organisations by
Category?

The site's (half)-live here:
http://www.ketteringcommunity.com/directory

(Just so that all the kind folks who have helped me so far on this list
can see I'm getting somewhere...)


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



How to restrict, in "delete confirmation", the affected objects list?

2006-12-09 Thread Mario Graziosi

Is it possible to restrict the list of "would be deleted" objects when 
asking to delete a  specific object using the admin interface?

I have several thousand records related to the object to be deleted. Is 
is quite useless (and time consuming) to display the list of 3000+ 
records to ask for confirmation. It would suffice to just say "and 
other  3000+ objects of type XXX will be deleted... want confirm?"

Even if I change the delete_confirmation form and comment-out the 
"deleted_objects|unordered_list" the Django admin interface takes a lot 
of time to read the "would-be-deleted" records.

Does anyone know if there's an easy out-of-the-box way of doing it?




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



model problem "matching query does not exist"

2006-12-09 Thread Rob Slotboom

After solving a problem described at:
http://groups-beta.google.com/group/django-users/browse_frm/thread/b453f0c91e29cc04?hl=nl

I continued developping my model. Unfortunately a new problem arose.
Given the following model, I get an error message in admin after
successfully saving an article and then selecting it.

MenuItem matching query does not exist.

The model describes an article 1to1 to menuitem
and a menuitem Mt1 to itself.
This way I try to get some kind of menustructure.
What causes the problem?

# model #
from django.db import models
from django.core import validators

class Article(models.Model):
   headline = models.CharField(maxlength=200)
   body = models.TextField()
   art_image = models.CharField(maxlength=200, help_text="FileBrowser:
/", blank=True, null=True)
   pub_date = models.DateTimeField('date published')
   published = models.BooleanField()

   def __str__(self):
  return self.headline
   class Admin:
  fields = (
 (None, {'fields': ('headline','body','art_image')}),
 ('Publication information', {'fields':
('pub_date','published'), 'classes': 'collapse'}),
  )
  date_hierarchy = 'pub_date'
  list_filter = ['pub_date']
  search_fields = ['headine']
  js = (
 'js/tiny_mce/tiny_mce.js',
 'js/textareas.js',
 'js/AddFileBrowser.js',
  )

class MenuItem (models.Model):
   article = models.OneToOneField(Article, edit_inline=models.TABULAR,
num_in_admin=1)
   caption = models.CharField(maxlength=40, db_index=True, core=True)
   parent = models.ForeignKey('self', blank=True, null=True,
related_name='child', core=True)

   def __str__(self):
  return self.caption


--~--~-~--~~~---~--~~
 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: Cannot resolve keyword 'caption' into field

2006-12-09 Thread Rob Slotboom

After many many trail and error I maybe found a 'bug'.

I simplefied the above model till it worked again. Then I added the
next field option and the error arose.

"unique=True" in MenuItem > name

Complete simplefied model with error:
###

from django.db import models

class Article(models.Model):
   headline = models.CharField(maxlength=200)
   body = models.TextField()
   pub_date = models.DateTimeField('date published')
   published = models.BooleanField()

   def __str__(self):
  return self.headline
   class Admin:
  pass

class MenuItem (models.Model):
   article = models.OneToOneField(Article, edit_inline=models.TABULAR,
num_in_admin=1)
   naam = models.CharField(maxlength=200, unique=True, core=True)
   def __str__(self):
  return self.caption


replace
   naam = models.CharField(maxlength=200, unique=True, core=True)
with
   naam = models.CharField(maxlength=200, core=True)
and it works again.


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



gotapi.com - python there, no django (yet)

2006-12-09 Thread tonemcd

http://www.gotapi.com/ - very neat, lots of APIs to go through (HTML,
Javascript etc) and now including python.

No django as yet. :(

However, you can't download copies of XML formats to see how others
have done it (eg python).

Cheers,
Tone


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