How do I manage the order of related objects?

2009-01-14 Thread scelerat

I've got a part/collection pairing of objects tables, and I'd like to
know the best way to manage the order of things inside the table.

Briefly:

class Activity(models.Model):
# etc...

class ActivityPart(models.Model):
order   = models.IntegerField("order in parent", default=1)
activity   = models.ForeignKey( Activity )
# etc.

What I want to do is, upon creation of an ActivityPart, figure out the
other parts already pointing to an Activity, and increase the order
number before saving the part if there are already ones with that
number. I also want the parent object to know about all its Parts. I'm
not sure what the best way to do either of these is... it seems like I
could do some or all of this in the ArrayPart's __init__ method, but
maybe there's a more Django-ish way?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Duplicating sitemap dictionary with a get variable

2009-01-14 Thread Alessandro Ronchi
I have a sitemap dictionary.
I want to add in my sitemap.xml an url for every url of my sitemap with a
?lang=en ending. Is it possible?

So, if my sitemap contains:
http://www.detectorpoint.com/
http://www.detectorpoint.com/about/

I want my sitemap to contain:
http://www.detectorpoint.com/
http://www.detectorpoint.com/?lang=en
http://www.detectorpoint.com/about/
http://www.detectorpoint.com/about/?lang=en

I have hundreds of pages, so I cannot do that by hand...

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

--~--~-~--~~~---~--~~
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: Mod-Python = Headaches (cannot find my settings file)

2009-01-14 Thread Malcolm Tredinnick

On Wed, 2009-01-14 at 20:44 -0800, mclovin wrote:
> Here is my new revised:
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE caliber.settings
> PythonDebug On
> PythonPath "['C:/projects/'] + sys.path"
> 
> 
> still does not work. gives the same error

When you test importing caliber.settings at the command line, with your
Python path set to exactly the above, what happened?

Malcolm



--~--~-~--~~~---~--~~
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: Model manager natural sort order

2009-01-14 Thread Malcolm Tredinnick

On Wed, 2009-01-14 at 21:14 -0800, Delta20 wrote:
> Is there a way to make a model manager get_query_set function return
> items sorted in natural alphanumeric order? order_by returns things in
> rather than the ASCII order, which is not generally what users expect.

Depends very much on which users you're talking about, and since the set
of "natural expectations" of all users contains contradictory elements
(different users expect opposite things), it's not really a good
measure.

In any case, Django's order_by() is a proxy for database sorting, which
is typically lexicographic using ASCII (or unicode, depending on the
setup of the database).

> For example, sorting by name for a set of objects with names: img10,
> img1, img103, img2, img3a, img3b

You've left out a few words from your sentences, so it's unclear if this
is what you're seeing or what you're hoping to see.  If I insert those
values into a table and order by that field, I get back the results in
this order:

 img1
 img10
 img103
 img2
 img3a
 img3b

That isn't going to be amazingly unclear to anybody who's ever used a
computer, since that's the way filenames are sorted pretty much
everywhere. Sure, it might be nice to say you want it to read img1,
img2, img3, etc, but the current output isn't vastly inferior. Also,
this "alphanumeric" sorting that you're after (and it's not really a
good name which is why I've quote it; the current sorting is a logical
sort on alphanumeric values as well) requires some "smarts" from the
sorter to know which digits are actually numbers and which are simple
characters as part of the name and you still end up having to sort
digits relative to letters (for example, think about sorting "a23b" and
"abc". Or, where do "img03" or "imgxyz" sort in the above list? How
about "img1.2"?).

To do things differently at the database level would require passing the
output column names through functions (at the database level). Right
now, there's no way to do that via Django's ORM (and no really concrete
plans to add anything like that, either). Even doing it at the raw SQL
level, unless your database contains some special function to handle
this, would be quite fiddly. The type of sorting function you're after
is very uncommon, since it requires a lot of extra processing for each
element.

Sorry that that sounds like a bunch of bad news, but that's the way
things are. Humans are very adjustable. The lexicographic sorting that
happens now tends to be fairly readable and not particularly confusing.
The alternative is computationally intensive.

Regards,
Malcolm



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



Model manager natural sort order

2009-01-14 Thread Delta20

Is there a way to make a model manager get_query_set function return
items sorted in natural alphanumeric order? order_by returns things in
rather than the ASCII order, which is not generally what users expect.

For example, sorting by name for a set of objects with names: img10,
img1, img103, img2, img3a, img3b

--~--~-~--~~~---~--~~
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: Mod-Python = Headaches (cannot find my settings file)

2009-01-14 Thread mclovin

Here is my new revised:

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE caliber.settings
PythonDebug On
PythonPath "['C:/projects/'] + sys.path"


still does not work. gives the same error
--~--~-~--~~~---~--~~
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: Mod-Python = Headaches (cannot find my settings file)

2009-01-14 Thread Malcolm Tredinnick

On Wed, 2009-01-14 at 20:33 -0800, mclovin wrote:
> I have my project settings file in:
> 
> 'C:/projects/caliber/settings.py"
> 
> I have mod_python activated (latest version as of today) along with
> Apache (latest version as of today)
> 
> Now this is at the bottom of my httpd.conf file:
> 
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE caliber.settings
> PythonDebug On
> PythonOption django.root 'C:/projects/caliber/'

For a start, this line is just plain wrong. The django.root option has
nothing to do with file paths. Remove the line. You don't need it for a
Location of "/".

> PythonPath "['C:/projects/''] + sys.path"

At a minimum, there's a typo here. Count the number of single quotes
you've got there. It should be an even number (one to start the string
inside the list and one -- not two -- to finish it). Once you fix that,
I suspect things will work.

Regards,
Malcolm



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



Mod-Python = Headaches (cannot find my settings file)

2009-01-14 Thread mclovin

I have my project settings file in:

'C:/projects/caliber/settings.py"

I have mod_python activated (latest version as of today) along with
Apache (latest version as of today)

Now this is at the bottom of my httpd.conf file:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE caliber.settings
PythonDebug On
PythonOption django.root 'C:/projects/caliber/'
PythonPath "['C:/projects/''] + sys.path"


I have also tried:

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE caliber.settings
PythonDebug On
PythonOption django.root 'C:/projects/caliber/'
PythonPath "['C:/projects/caliber''] + sys.path"




Both of them give me teh same error:
---
ImportError: Could not import settings 'caliber.settings' (Is it on
sys.path? Does it have syntax errors?): No module named
caliber.settings
---



I only have installed and used apache and modpython under ubuntu
before and everything went great. This is the first time I am
installing it in Vista (i cant change OS's) and it is giving me this
error!
--~--~-~--~~~---~--~~
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: no objects found

2009-01-14 Thread Brian

On Jan 15, 1:57 pm, Malcolm Tredinnick 
wrote:
> Please open a ticket for this and assign it to me (mtredinnick in Trac),

Ok, done. Thanks.



Brian May
--~--~-~--~~~---~--~~
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: How does django.contrib.auth.views.login work?

2009-01-14 Thread scelerat



On Jan 9, 9:16 am, Brian Neal  wrote:
> If you use RequestContext and have the settings in your
> TEMPLATE_CONTEXT_PROCESSORS, then the user variable will be available
> for use in your templates. Check out:
>
> http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-c...

I just want to follow up and say thanks, this worked... on to more
stuff!
--~--~-~--~~~---~--~~
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: request.user objects in base.html

2009-01-14 Thread Igor Sobreira
On Wed, Jan 14, 2009 at 9:28 PM, izzy_dizzy  wrote:

>
> Hi,
>
> I'm new to django and I would like to know how to make request.user
> objects available in context of base.html template. I wonder if
> someone can give me a full code for a custom template tag for it.
>

Hi,

You need this template context processor [1], witch is there by default. And
you need to use RequestContext in your views too [2].

[1]
http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-auth
[2] http://docs.djangoproject.com/en/dev/ref/templates/api/#id1

-- 
Igor
www.igorsobreira.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How can I process ajax code post encodeURI string ?

2009-01-14 Thread K*K

Hi, All.

I'm using the Ajaxmethod to post some string after encodeURI function
processed to the Django server, How can I decodeURI in the server
side ?

Very simple question, But I'm a newbie of Django for process multi-
language program.

So thank you very much.
--~--~-~--~~~---~--~~
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: no objects found

2009-01-14 Thread Malcolm Tredinnick

On Wed, 2009-01-14 at 16:54 -0800, Brian wrote:
> Django 1.0.2-1
> 
> If I do:
> 
> >>> object=models.software.objects.get(id=267)
> >>> print models.software_installation.objects.filter(software=object)
> []
> >>> print models.software_installation.objects.filter(software=object).count()
> 10
> 
> Huh? First statement says there are no results, next one says there
> are 10.
> 
> 
> 
> If I spy on the packets, I see this in the SQL for the first
> statement:
> 
> ... LEFT OUTER JOIN `inventory_license_key` ON
> (`inventory_software_installation`.`license_key_id` =
> `inventory_license_key`.`id`)  INNER JOIN `inventory_license` ON
> (`inventory_license_key`.`license_id` = `inventory_license`.`id`) ...
> 
> If I remove the inner join part (and the reference to it in the order
> part), and run the SQL on the server, then it works.
> 
> `inventory_software_installation`.`license_key_id` == NULL on the rows
> in question (the model specifies null=True).
> 
> I have a suspicion that the above SQL doesn't work because it requires
> a inventory_license object, however there is no inventory_license_key
> object there is no inventory_license object.
> 
> The relevant definitions (I can provide more details on request) are:
> 
> class software_installation(models.Model):
> [...]
> software = models.ForeignKey(software)
> [...]
> license_key = models.ForeignKey(license_key,null=True,blank=True)
> [...]
> 
> class license_key(models.Model):
> [...]
> license  = models.ForeignKey(license)
> [...]
> 
> class license(models.Model):
> [...]
> 

The SQL you've posted certainly looks wrong and I thought I'd spent
enough hours making sure we never constructed something like that. So
there's some edge-case you're hitting that isn't being catered for. No
big deal; we can fix that. However, the model fragments you've posted
don't support the SQL that's being generated. Thus, some of the stuff
you've trimmed is likely to be relevant. Filtering a
"software_installation" model on the "software" field isn't going to
involve selections on the license_key table at all. 

Please open a ticket for this and assign it to me (mtredinnick in Trac),
since these tend to be the bugs that I get to fix. However, first,
pleaes create a small, complete example that demonstrates the problem in
a repeatable fashion. Simplest way to do that is to take your existing
models and start removing as many fields as possible until the problem
goes away. You can view the SQL that Django will generate by looking at 

qs.query.as_sql()

where "qs" is any queryset (such as
software_installation.objects.filter(...)). You can't do this with
something that returns an immediate result (such as .count()), but
that's because count() doesn't return a queryset; it returns an integer.

The fragment you've posted above doesn't meet the "complete" definition,
since (a) it doesn't have anything for the "software" model, although
that's referred to and (b) if I was to create an empty software model
and run the query, license_key wouldn't show up in the query.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: list all context variables?

2009-01-14 Thread Malcolm Tredinnick

On Wed, 2009-01-14 at 13:01 -0700, David Lindquist wrote:
> Is there an easy way to see a list of all the context variables and  
> their values available in a given template?

Have a look at the "debug" template tag.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: how/where to constrain the relationships in a model?

2009-01-14 Thread Margie

Thanks Ariel!  That makes sense ...

On Jan 14, 1:52 pm, Ariel Mauricio Nunez Gomez
 wrote:
> Margie,
>
> My best bet would be to override the model's save method and do your
> validation there.
>
> http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddo...
>
> Ariel
>
> On Wed, Jan 14, 2009 at 3:37 PM, Margie  wrote:
>
> > Supose I want to model the following: A Task is owned by a family but
> > may additionally have specific owners that are within that family.
> > The model would look like this:
>
> > class Family(models.Model):
> >   surName=models.CharField()
>
> > class Task(models.Model):
> >   ownerFamily=models.ForeignKey(Family)
> >   owners = models.ManyToManyField(Person, blank=True, null=True)
>
> > class Person(models.Model):
> >   family = models.ForeignKey(Family)
>
> > I want to enforce that the if a Task has owners, that each owner be in
> > the Family specified by that task's ownerFamily.
>
> > Could someone tell me where is the appropriate location in the code to
> > enforce this?  I'm not sure if there is a way to enforce this within
> > the model itself.  If not, then is the appropriate thing to do to just
> > check it in my public interface when I, for example, add an owner to a
> > task?
>
> > Thanks!
>
> > Margie
> > Margie
--~--~-~--~~~---~--~~
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: post_syncdb signal: Called several times

2009-01-14 Thread Malcolm Tredinnick

On Wed, 2009-01-14 at 10:42 +0100, Thomas Guettler wrote:
> Hi,
> 
> I read the docs for the sync_db signal:
>http://docs.djangoproject.com/en/dev/ref/signals/#post-syncdb
> 
> The signal gets fired several times. Since my app has several model classes.


The "since" bit doesn't follow. The post_syncdb signal is only emitted
once by the syncdb management command.
> 
> But how can you know that the tabel for a particular model was just created?

There's a slight oddity in the way the post_syncdb signal is emitted
(it's not a completely silly idea, but it takes some getting used to and
we could have maybe done it differently). It sends all the models that
were created, not matter what application they're in, but it emits the
signal once for each application (setting the "app" and "sender"
parameters to the different application name each time).

However, this does mean you have to check, for each model in the
"created_models" parameter, whether it's a model in the application you
care about or not.

> Or do you need to write the callback method the way, that it can be called
> several times (for example: check if change was already done before
> changing something)

You need to do this if your action doesn't depend on particular models.
The post_syncdb signal is sent for every application in your
INSTALLED_APPS list, regardless of whether or not they were changed.
However, you can tell if some model in the application was affected by
looking to see if it is in the created_models parameter list.

So, if you're writing a post_syncdb handler that doesn't act on
particular models, but does something for the entire application, you
need to check whether you've done it before.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: temporary user model

2009-01-14 Thread Malcolm Tredinnick

On Tue, 2009-01-13 at 22:39 +, Mengsong Chen wrote:
> Just wonder if anyone have achieved such a temporary user model to
> allow unregistered user to use some features,
> but will clean up the data after the session completed if the user is
> not going to register.

You could use a user profile model to help with this (see [1]). In your
user profile, have a flag that indicates whether the user is registered
or not. Then periodically go around and clean up (delete) any users that
do have registered=True in the user profile.

You cannot automatically do this "when the session is completed", since
you won't know when that is. Most users don't bother to log out of
websites or anything like that. How can you tell the difference between
"user has gone to lunch and will be back in 20 minutes" and "user has
finished using the site and will never be back"? You can't. You just
have to do something like deleting temporary users after 24 hours.

[1]
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Regards,
Malcolm


--~--~-~--~~~---~--~~
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 / memcached / pickle / Unicode = confusion + UnicodeDecodeError

2009-01-14 Thread Malcolm Tredinnick

On Tue, 2009-01-13 at 19:30 +, Rachel Willmer wrote:
> I've just upgraded some code to Django 1.0 and the caching stopped working.
> 
> I have found a fix but I don't understand what's happening so if
> anyone can explain, I'd be grateful.
> 
> My code used to look somthing like this (simplified for clearer reading)
> 
> cached=cache.get(key)
> if cached:
> list=pickle.loads(cached)
> else:
> list = Banks.objects()
> pickled = pickle.dumps(list,pickle.HIGHEST_PROTOCOL)
> cache.set(key,pickled)
> 
> pickled is of type 'str', my default encoding appears to be 'ascii'.
> 
> When I call cache.set, I get a UnicodeDecodeError.

Which cache backend are you using? UnicodeDecodeError occurs when
converting from bytestrings to unicode and, as far as I can see, none of
the set() methods for caches should be doing this.

[...]
> So what I don't understand is, why 'iso_8859_1'? As far as I know, the
> python default encoding is 'ascii' and the django DEFAULT_CHARSET is
> 'utf-8'. So where's this coming from?

It's difficult to be certain about this without knowing where the
contents of "cached" came from originally, but I'll guess it's loaded
from the database.

Right now, Django doesn't have any concept of "binary data" for database
storage. So it treats everything as strings and converts them to unicode
objects upon loading. That the conversion happens is well understood
these days (I hope). Your call to smart_str() essentially says "convert
this from a unicode object back to a str object" and by using
iso-8859-1, you're indicating that the full range of bytes might well
occur (ascii data is only going to occupy the lower 7 bits, whereas the
binary pickle protocol uses all 8 bits in the byte.

In a fashion, you can think of iso-8859-1 as the identity transformation
for bytestrings. In Python, it actually just maps every byte to itself
(even those that aren't valid iso-8859-1 characters). That's for
historical reasons, but it's also guaranteed behaviour and is quite
useful as a way to change the type from unicode to a bytestring.

That explains why iso-8859-1 can be used to change types (unicode ->
bytestring and back), but it doesn't explain why the original error is
occurring in the first place. I may have missed something when browsing
the code there, though.

Malcolm


--~--~-~--~~~---~--~~
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: Adding a view inside a view?

2009-01-14 Thread Eric Abrahamsen


On Jan 15, 2009, at 2:42 AM, Bradley wrote:

>
> I'm new to Django and I'm trying to modify an existing django website
> for a local newspaper.  They would like to have a polls on the their
> website.  I just used the tutorial from the djangoproject website to
> create the polls module.  It works fine, except that I need it to work
> inside a  section on the front page, not multiple pages like is
> used in the tutorial.  What is the standard procedure for something
> like this?
>
> The tutorial had me create entries for /polls/ in urls.py  I probably
> don't need those.
> Do I somehow Integrate the polls function into already existing
> function that are used to display the front page?  Not really sure how
> to proceed

If I'm understanding this correctly, you might want to look at  
template tags:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags

This would allow you to make calls to the database to retrieve  
whatever poll and related answers you want, render them as a stand- 
alone chunk of html, and then insert that html into an existing  
template. You could put it into the template as:


  {% get_poll_question some_poll %}


Where 'some_poll' was a variable that originates in your view.

Hope that helps,
Eric


>
> Any help would be appreciated.
>
> Thanks,
> Brad
>
> >


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



no objects found

2009-01-14 Thread Brian

Django 1.0.2-1

If I do:

>>> object=models.software.objects.get(id=267)
>>> print models.software_installation.objects.filter(software=object)
[]
>>> print models.software_installation.objects.filter(software=object).count()
10

Huh? First statement says there are no results, next one says there
are 10.



If I spy on the packets, I see this in the SQL for the first
statement:

... LEFT OUTER JOIN `inventory_license_key` ON
(`inventory_software_installation`.`license_key_id` =
`inventory_license_key`.`id`)  INNER JOIN `inventory_license` ON
(`inventory_license_key`.`license_id` = `inventory_license`.`id`) ...

If I remove the inner join part (and the reference to it in the order
part), and run the SQL on the server, then it works.

`inventory_software_installation`.`license_key_id` == NULL on the rows
in question (the model specifies null=True).

I have a suspicion that the above SQL doesn't work because it requires
a inventory_license object, however there is no inventory_license_key
object there is no inventory_license object.

The relevant definitions (I can provide more details on request) are:

class software_installation(models.Model):
[...]
software = models.ForeignKey(software)
[...]
license_key = models.ForeignKey(license_key,null=True,blank=True)
[...]

class license_key(models.Model):
[...]
license  = models.ForeignKey(license)
[...]

class license(models.Model):
[...]


Any ideas?

Is this a django bug? If so is it a known issue?


Thanks

Brian May

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



request.user objects in base.html

2009-01-14 Thread izzy_dizzy

Hi,

I'm new to django and I would like to know how to make request.user
objects available in context of base.html template. I wonder if
someone can give me a full code for a custom template tag for it.


Thanks in advance
--~--~-~--~~~---~--~~
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: pizzas toppings, and subs

2009-01-14 Thread mamco

disregard, turns out it is quite simple.

create another mantytomanyfield on the sub model.

class Sub(models.Model):
# ...
toppings = models.ManyToManyField(Topping)

I had this earlier, but got an error.  I mis-read it to mean I
couldn't do just this, but turns out I had another issue altogether.


On Jan 14, 7:52 pm, mamco  wrote:
> in the documentation the many to many relationship between toppings
> and pizzas is well presented (http://docs.djangoproject.com/en/dev/
> topics/db/models/#many-to-many-relationships).  My question has to do
> with something else that would have toppings, subs for example.
>
> If in my toppings model, I've got my vendor, expected cost, minimum
> order qty, etc, my pizza I have a description, box size,  and a price
> to customer.  How would I integrate a 'subs' model which uses the same
> toppings model, but also has some special details only about subs.
>
> In my actual dilemma I'm converting an app to Django, and we have an
> 'address' table which stores the addresses for employees, vendors,
> customers, along with an effective date for the address (which allows
> us to hold the history of the addresses).  In the previous app, I
> decided to go this route to have one bit of code that handled address
> validation.
>
> can I have a pizzas-pizzas-toppings and a subs-subs-toppings, as well
> as perhaps some other things that use the ingrediants eg: donairs-
> donairs-toppings?  Is there something in the documentation or django
> book that covers this?  I haven't found it as of yet but still
> digging.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problems with (Model)ChoiceField and the like

2009-01-14 Thread James Smagala

Hey All,

There is a discussion here about building dynamic form select fields
using __init__ on the form.  This, by itself, is not hard.

http://groups.google.com/group/django-users/browse_thread/thread/98bde0a6d818e627

Problem:  I have a formset that needs each form in it to be created in
this dynamic sort of manner.

Possible solutions:

- Create the formset containing no forms, add them individually, and
update the management form.  I had this mostly implemented, but I
don't know how to actually update the values on the management form.
Where do they live?

- Figure out some tricky syntax that lets me pass both the queryset
for a modelchoicefield (and an initial choice for said field) to a
form.  Also figure out how to pass it though a formset to correctly
init all those dynamic forms.  Not having much luck here.

- Post about it, and get told I'm doing it all wrong.  Suggestions are
welcome!

Please help!

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



pizzas toppings, and subs

2009-01-14 Thread mamco

in the documentation the many to many relationship between toppings
and pizzas is well presented (http://docs.djangoproject.com/en/dev/
topics/db/models/#many-to-many-relationships).  My question has to do
with something else that would have toppings, subs for example.

If in my toppings model, I've got my vendor, expected cost, minimum
order qty, etc, my pizza I have a description, box size,  and a price
to customer.  How would I integrate a 'subs' model which uses the same
toppings model, but also has some special details only about subs.

In my actual dilemma I'm converting an app to Django, and we have an
'address' table which stores the addresses for employees, vendors,
customers, along with an effective date for the address (which allows
us to hold the history of the addresses).  In the previous app, I
decided to go this route to have one bit of code that handled address
validation.

can I have a pizzas-pizzas-toppings and a subs-subs-toppings, as well
as perhaps some other things that use the ingrediants eg: donairs-
donairs-toppings?  Is there something in the documentation or django
book that covers this?  I haven't found it as of yet but still
digging.


--~--~-~--~~~---~--~~
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: Slow application performance...

2009-01-14 Thread Graham Dumpleton

As before, if you can move to mod_wsgi and use its daemon mode try
that as first step. This will eliminate memory swapping issues and
other issues around startup cost of Apache child processes loading
Django. Also gives a more predictable environment in which can then
start doing testing as to how long requests are actually taking inside
your application/database.

Graham

On Jan 15, 5:35 am, SnappyDjangoUser  wrote:
> I am having a similar problem with super slow performance in my
> production environment (Apache with mod_python).  Does anyone have
> suggestions of settings that I can try tweaking?
>
> Graham has provided a lot of useful information earlier in the post,
> but I am with Vernon in that I am unsure exactly how to start
> debugging the root cause of the slow performance.
>
> Thanks,
>
> Brian
>
> On Jan 2, 1:53 am, vernon  wrote:
>
> > Thanks for both of your replies. It looks like what I'm experiencing
> > isn't entirely abnormal and would also explain why the "first group of
> > concurrent requests" are slower.
>
> > That said, coming from the comparatively easy worlds of PHP/mod_php
> > and even Java and Tomcat, getting Django properly deployed feels like
> > something of a minefield. I can follow along with what you're saying,
> > but I don't really feel confident in making these decisions for
> > myself. I'll start reading up on WSGI but are there any resources out
> > there for understanding the implications of all these different server
> > technologies, multithreaded vs. single threaded processes, etc...
> > short of taking an operating systems class? :) I'd like to understand
> > and experiment without necessarily having to wait for the "perfect
> > setup" to eventually emerge, but I'm feeling a little out of my
> > league.
>
> > Thanks again,
> > Vernon
--~--~-~--~~~---~--~~
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: mod_python 3.3.1, Python 2.4.6, Apache 2.2.9 (MacPorts) on Mac OS X 10.5.6 (Leopard)

2009-01-14 Thread Graham Dumpleton

Use mod_wsgi instead, it should set up compiler flags correctly even
for fussy MacPorts. I can't remember if I rolled those changes into
mod_python in subversion trunk. If still want to try mod_python though
use:

  svn co https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk
mod_python-trunk

and use that version.

For other MacOSX/MacPort issues, see mod_wsgi documentation at:

  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX

Some of these also affect mod_python.

With mod_wsgi, even if picks up correct framework, but wrong lib
files, you can override it to some degree using WSGIPythonHome
directive.

Anyway, use mod_wsgi if you can as am at point where can't be bothered
helping with mod_python problems anymore. ;-)

Graham

On Jan 15, 4:52 am, peterandall  wrote:
> I've also tried doing this:
>
> $  cd /System/Library/Frameworks
> $  sudo mv Python.framework XXX_Python.framework
>
> $  cd  
> $  ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/
> opt/local/bin/python2.4 --with-max-locks=32
>
> Then editing the src/Makefile and updating the LDFLAGS to this:
>
> LDFLAGS= -Wl,-F/opt/local/Library/Frameworks -Wl,-framework,Python  -u
> _PyMac_Error $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$
> (PYTHONFRAMEWORK)   -L/opt/local/lib
>
> Then continuing to make and install mod_python
>
> $  make
> $  sudo make install
> $  cd /System/Library/Frameworks
> $  sudo mv XXX_Python.framework Python.framework
>
> Still no luck, when i run: 'otool -L /opt/local/apache2/modules/
> mod_python.so' i get the following:
>
>   /opt/local/apache2/modules/mod_python.so:
>         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
> version 111.1.3)
>         /System/Library/Frameworks/Python.framework/Versions/2.5/Python
> (compatibility version 2.5.0, current version 2.5.1)
>         /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
> version 1.0.0)
>
> So its still building against the 2.5 version, this is really starting
> to confuse me now, i've run out of things to try.
>
> Thanks in advance for any help...
--~--~-~--~~~---~--~~
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: Adding a view inside a view?

2009-01-14 Thread Briel

I'm not sure exactly what you want. Do you want a single poll, that
the admins can choose? Should users be able to create polls ect.
Anyways, in case you only want to display a single poll, the easiest
way to accomplish that would probably to create a boolean field called
display or front_page. Then you can import your poll model and filter
on it and get the one(s) that have True value for front_page. If you
want to make sure that only one can be displayed on the front page at
a time, you can create a method instead, that also will hold True/
False, but only allow one to be True at a time. You could also go with
the boolean field and just add the code in a view to make sure only
one is True at a time.

Hope this helps.
-Briel

On 14 Jan., 19:42, Bradley  wrote:
> I'm new to Django and I'm trying to modify an existing django website
> for a local newspaper.  They would like to have a polls on the their
> website.  I just used the tutorial from the djangoproject website to
> create the polls module.  It works fine, except that I need it to work
> inside a  section on the front page, not multiple pages like is
> used in the tutorial.  What is the standard procedure for something
> like this?
>
> The tutorial had me create entries for /polls/ in urls.py  I probably
> don't need those.
> Do I somehow Integrate the polls function into already existing
> function that are used to display the front page?  Not really sure how
> to proceed
>
> Any help would be appreciated.
>
> Thanks,
> Brad
--~--~-~--~~~---~--~~
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: auth: get_profile(): create if it does not exist.

2009-01-14 Thread jweinstein

Where does this code go? I want to create a user profile for every
user created.

On Dec 18 2008, 2:37 am, "James Bennett" 
wrote:
> On Wed, Dec 17, 2008 at 5:21 PM, Malcolm Tredinnick
>
>  wrote:
> > This would be the "standard" solution. I thought James Bennett's
> > django-profiles app did this, but apparently I'm mistaken (it would be
> > slightly duplicated work if it did, in any case).
>
> django-profiles kicks you to a profile-creation view if you try to
> edit your profile and don't have one already.
>
> django-registration, on the other hand, supports passing a callback to
> create an initial profile for a newly-registered user (in other words,
> a function which just knows how to create an instance of your profile
> model with all blank/default values).
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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: the last line is plone\Python\lib\site-packages\django\db\backends\sqlite3\base.py

2009-01-14 Thread Briel

Yes, that should work.
All you need is to create the db-file, and then give the name/path to
it in settings.py

-Briel

On 14 Jan., 21:18, bconnors  wrote:
> my bad. i read that sqlite3 was supplied by python 2.5. i have python
> 2.4. the base.py says sqlite2 is correct for prior to python 2.5, but
> that didn't work either. tomorrow i install python 2.5. will that
> work?
>
> On Jan 14, 2:16 pm, bconnors  wrote:
>
> > In the settings.py it says “ If you're new to databases, we recommend
> > simply using SQLite (by setting DATABASE_ENGINE to 'sqlite3').”
>
> > I did that but get this error:
>
> > C:\PROGRA~1\plone\Python\jan13django\mysite>..\..\python manage.py
> > syncdb
>
> > Traceback (most recent call last):
> >   File "manage.py", line 11, in ?
> >     execute_manager(settings)
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\__init
> > __.py", line 340, in execute_manager
> >     utility.execute()
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\__init
> > __.py", line 295, in execute
> >     self.fetch_command(subcommand).run_from_argv(self.argv)
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\base.p
> > y", line 195, in run_from_argv
> >     self.execute(*args, **options.__dict__)
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\base.p
> > y", line 221, in execute
> >     self.validate()
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\base.p
> > y", line 249, in validate
> >     num_errors = get_validation_errors(s, app)
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\valida
> > tion.py", line 22, in get_validation_errors
> >     from django.db import models, connection
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\db
> > \__init__.py", line
> > 16, in ?
> >     backend = __import__('%s%s.base' % (_import_path,
> > settings.DATABASE_ENGINE),
> >  {}, {}, [''])
> >   File "C:\PROGRA~1\plone\Python\lib\site-packages\django\db\backends
> > \sqlite3\ba
> > se.py", line 28, in ?
> >     raise ImproperlyConfigured, "Error loading %s module: %s" %
> > (module, exc)
> > django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
> > module: No module named sqlite3
>
> > C:\PROGRA~1\plone\Python\jan13django\mysite>
>
> > Any ideas?
--~--~-~--~~~---~--~~
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: Help with m2m relationships through intermediary tables

2009-01-14 Thread felix
open a shell with ./manage.py shell

from models import *

fetch one of your Authors (one that has a job already)

dir(author)

that will list all the ways you can poke at it.
always useful


you should see some way to access the AuthorNewspaper directly from the
Author object

to display a whole page of these positions you can fetch them directlly

AuthorNewspaper.objects.all()

an.author an.newspaper an.date


-felix
http://crucial-systems.com



On Mon, Jan 12, 2009 at 11:35 AM, Asif  wrote:

>
> I've created a few models that have m2m relationships with
> intermediary tables.  I'm storing some extra data in the fields of the
> intermediary tables.  For example, I have a model called Author and
> model called Newspaper that are related to each other through a model
> called AuthorNewspaper.  In AuthorNewspaper, I am storing the date for
> which that author joined the newspaper.
>
> I'd like to create a view that can display those dates and I can't
> seem to figure out a way to do it elegantly.  The only way I've
> figured out is by using the extra method to add a bunch SQL that
> includes the fields from the intermediary table.  Am I missing
> something really obvious?
>
> Thanks in advance for your help,
>
> Asif
>
> P.S. If you haven't figured out already, I'm a Django newbie.
>
> >
>

--~--~-~--~~~---~--~~
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: how/where to constrain the relationships in a model?

2009-01-14 Thread Ariel Mauricio Nunez Gomez
Margie,

My best bet would be to override the model's save method and do your
validation there.

http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#overriding-default-model-methods

Ariel


On Wed, Jan 14, 2009 at 3:37 PM, Margie  wrote:

>
> Supose I want to model the following: A Task is owned by a family but
> may additionally have specific owners that are within that family.
> The model would look like this:
>
> class Family(models.Model):
>   surName=models.CharField()
>
> class Task(models.Model):
>   ownerFamily=models.ForeignKey(Family)
>   owners = models.ManyToManyField(Person, blank=True, null=True)
>
> class Person(models.Model):
>   family = models.ForeignKey(Family)
>
> I want to enforce that the if a Task has owners, that each owner be in
> the Family specified by that task's ownerFamily.
>
> Could someone tell me where is the appropriate location in the code to
> enforce this?  I'm not sure if there is a way to enforce this within
> the model itself.  If not, then is the appropriate thing to do to just
> check it in my public interface when I, for example, add an owner to a
> task?
>
> Thanks!
>
> Margie
> Margie
> >
>

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



how/where to constrain the relationships in a model?

2009-01-14 Thread Margie

Supose I want to model the following: A Task is owned by a family but
may additionally have specific owners that are within that family.
The model would look like this:

class Family(models.Model):
   surName=models.CharField()

class Task(models.Model):
   ownerFamily=models.ForeignKey(Family)
   owners = models.ManyToManyField(Person, blank=True, null=True)

class Person(models.Model):
   family = models.ForeignKey(Family)

I want to enforce that the if a Task has owners, that each owner be in
the Family specified by that task's ownerFamily.

Could someone tell me where is the appropriate location in the code to
enforce this?  I'm not sure if there is a way to enforce this within
the model itself.  If not, then is the appropriate thing to do to just
check it in my public interface when I, for example, add an owner to a
task?

Thanks!

Margie
Margie
--~--~-~--~~~---~--~~
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: the last line is plone\Python\lib\site-packages\django\db\backends\sqlite3\base.py

2009-01-14 Thread bconnors

my bad. i read that sqlite3 was supplied by python 2.5. i have python
2.4. the base.py says sqlite2 is correct for prior to python 2.5, but
that didn't work either. tomorrow i install python 2.5. will that
work?


On Jan 14, 2:16 pm, bconnors  wrote:
> In the settings.py it says “ If you're new to databases, we recommend
> simply using SQLite (by setting DATABASE_ENGINE to 'sqlite3').”
>
> I did that but get this error:
>
> C:\PROGRA~1\plone\Python\jan13django\mysite>..\..\python manage.py
> syncdb
>
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
>     execute_manager(settings)
>   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> \management\__init
> __.py", line 340, in execute_manager
>     utility.execute()
>   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> \management\__init
> __.py", line 295, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> \management\base.p
> y", line 195, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> \management\base.p
> y", line 221, in execute
>     self.validate()
>   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> \management\base.p
> y", line 249, in validate
>     num_errors = get_validation_errors(s, app)
>   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> \management\valida
> tion.py", line 22, in get_validation_errors
>     from django.db import models, connection
>   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\db
> \__init__.py", line
> 16, in ?
>     backend = __import__('%s%s.base' % (_import_path,
> settings.DATABASE_ENGINE),
>  {}, {}, [''])
>   File "C:\PROGRA~1\plone\Python\lib\site-packages\django\db\backends
> \sqlite3\ba
> se.py", line 28, in ?
>     raise ImproperlyConfigured, "Error loading %s module: %s" %
> (module, exc)
> django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
> module: No module named sqlite3
>
> C:\PROGRA~1\plone\Python\jan13django\mysite>
>
> Any ideas?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



list all context variables?

2009-01-14 Thread David Lindquist

Is there an easy way to see a list of all the context variables and  
their values available in a given template?

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



Fwd: [wingide-users] Integrating with django's unit tests

2009-01-14 Thread James Matthews
-- Forwarded message --
From: Philip Gatt 
Date: Wed, Jan 14, 2009 at 7:10 AM
Subject: [wingide-users] Integrating with django's unit tests
To: wingide-us...@wingware.com


Does anyone know how to integrate Wing with Django's unit tests? With my
django projects, I usually run my unit tests with the following command:

./manage.py test

I tried running unit tests within WingIDE, but the problem is that django
does some setup & cleanup work that needs to run before the tests can be
run. I'm not an expert here, but I suspect that we need to tie WingIDE into
django's test runner.

Thanks in advance,
Philip Gatt
_
Wing IDE users list
http://wingware.com/lists/wingide



-- 
http://www.goldwatches.com/

http://www.jewelerslounge.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



the last line is plone\Python\lib\site-packages\django\db\backends\sqlite3\base.py

2009-01-14 Thread bconnors

In the settings.py it says “ If you're new to databases, we recommend
simply using SQLite (by setting DATABASE_ENGINE to 'sqlite3').”

I did that but get this error:

C:\PROGRA~1\plone\Python\jan13django\mysite>..\..\python manage.py
syncdb

Traceback (most recent call last):
  File "manage.py", line 11, in ?
execute_manager(settings)
  File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
\management\__init
__.py", line 340, in execute_manager
utility.execute()
  File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
\management\__init
__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
\management\base.p
y", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
\management\base.p
y", line 221, in execute
self.validate()
  File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
\management\base.p
y", line 249, in validate
num_errors = get_validation_errors(s, app)
  File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
\management\valida
tion.py", line 22, in get_validation_errors
from django.db import models, connection
  File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\db
\__init__.py", line
16, in ?
backend = __import__('%s%s.base' % (_import_path,
settings.DATABASE_ENGINE),
 {}, {}, [''])
  File "C:\PROGRA~1\plone\Python\lib\site-packages\django\db\backends
\sqlite3\ba
se.py", line 28, in ?
raise ImproperlyConfigured, "Error loading %s module: %s" %
(module, exc)
django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
module: No module named sqlite3


C:\PROGRA~1\plone\Python\jan13django\mysite>



Any ideas?

--~--~-~--~~~---~--~~
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 VBulletin auth backend

2009-01-14 Thread Chris H.

Has anybody done any work on writing a Django auth backend for an
existing VBulletin[1] website?  I have a need to utilize the existing
user database in a Django project and would appreciate not having to
reinvent the wheel.  My google-fu has failed me on this one, so it may
not exist.

Any other examples of writing an auth backend for existing PHP apps
would also be appreciated.  Particularly implementations of single
sign-on using the PHP/VBulletin generated cookie.

[1] http://www.vbulletin.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Adding a view inside a view?

2009-01-14 Thread Bradley

I'm new to Django and I'm trying to modify an existing django website
for a local newspaper.  They would like to have a polls on the their
website.  I just used the tutorial from the djangoproject website to
create the polls module.  It works fine, except that I need it to work
inside a  section on the front page, not multiple pages like is
used in the tutorial.  What is the standard procedure for something
like this?

The tutorial had me create entries for /polls/ in urls.py  I probably
don't need those.
Do I somehow Integrate the polls function into already existing
function that are used to display the front page?  Not really sure how
to proceed

Any help would be appreciated.

Thanks,
Brad

--~--~-~--~~~---~--~~
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: Slow application performance...

2009-01-14 Thread SnappyDjangoUser

I am having a similar problem with super slow performance in my
production environment (Apache with mod_python).  Does anyone have
suggestions of settings that I can try tweaking?

Graham has provided a lot of useful information earlier in the post,
but I am with Vernon in that I am unsure exactly how to start
debugging the root cause of the slow performance.

Thanks,

Brian

On Jan 2, 1:53 am, vernon  wrote:
> Thanks for both of your replies. It looks like what I'm experiencing
> isn't entirely abnormal and would also explain why the "first group of
> concurrent requests" are slower.
>
> That said, coming from the comparatively easy worlds of PHP/mod_php
> and even Java and Tomcat, getting Django properly deployed feels like
> something of a minefield. I can follow along with what you're saying,
> but I don't really feel confident in making these decisions for
> myself. I'll start reading up on WSGI but are there any resources out
> there for understanding the implications of all these different server
> technologies, multithreaded vs. single threaded processes, etc...
> short of taking an operating systems class? :) I'd like to understand
> and experiment without necessarily having to wait for the "perfect
> setup" to eventually emerge, but I'm feeling a little out of my
> league.
>
> Thanks again,
> Vernon
--~--~-~--~~~---~--~~
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: trying to install a database for settings.py what should i do?

2009-01-14 Thread Prashanth

On Wed, Jan 14, 2009 at 11:37 PM, bconnors  wrote:
>
>  i'm trying for a free download of mysql from the internet. the 1st 3
> tries i've failed on.
>

You dint bother to explain how you tried and beyond that you are
asking this in the django mailing list which is no way related to
Mysql.



-- 
regards,
Prashanth

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



trying to install a database for settings.py what should i do?

2009-01-14 Thread bconnors

 i'm trying for a free download of mysql from the internet. the 1st 3
tries i've failed on.
--~--~-~--~~~---~--~~
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 Continuous Integration

2009-01-14 Thread Adam V.

> Revision Control: How do you layout your development repository?  I'm
> using Subversion for my setup but would be interested in hearing what
> else others are using (Mercurial, Bazaar, Git, etc)

We're using Subversion. We have one big repository, but we treat it
like two top-level repository, one for the website files themselves,
and one for build scripts and other tools. We're a small shop (<6
devs), so SVN is fine for what we're doing.

> Packaging:  Django has an aversion to using setuptools and opts to
> stick with the basics in distutils.  What are you using for packaging
> your application?

We're doing in-house development, so we don't package our project/app.

> Buildbot:  Do you use Buildbot or something similar for your Django
> development?  How does that work for you?  What other options are
> there that would work well?

We use CruiseControl.NET as our CI tool, since we're using that for
our .NET development anyway.
It watches SVN for changes and calls custom scripts written in Python
that look a little like this:
http://code.google.com/p/adamv/source/browse/python/buildsystem/

> Versioning: How do you mark versions of your Django project?
We're running against Django-trunk so far.

> Migrations: What do you use to track database migrations?
We're using MS SQL Server (since that's what our other stuff is in),
and we're using a 3rd party commercial tool called "RedGate SQL
Compare" to do schema upgrades. We keep our DB schema in source
control as a set of SQL files that gets run to create a new, empty
database.

Since we're doing Django on top of a "legacy" database, our Django
models don't own the bulk of the database, and SQL Compare is what our
main .NET apps are using to update schemas when we deploy that stuff.

--~--~-~--~~~---~--~~
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: GeoDjango: Extract Latitude and Longitude from PointField

2009-01-14 Thread Ariel Mauricio Nunez Gomez
...
point = models.PointField()...
Longitude: {{point.x}}
Latitude: {{point.y}}

--~--~-~--~~~---~--~~
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: GeoDjango: Extract Latitude and Longitude from PointField

2009-01-14 Thread J. Cliff Dyer

On Wed, 2009-01-14 at 09:49 -0800, Alfonso wrote:
> Hey,
> 
> Must be missing something extraordinarily simple - how do I
> individually parse the latitude and longitude values from a PointField
> entry into my app's templates?  I just want...
> 
> 
> Latitude:
> Longitude:
> 
> 
> Thanks,
> 
> Al

{{ Point.y }}
{{ Point.x }}

should do the trick.

Cheers,
Cliff



--~--~-~--~~~---~--~~
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: mod_python 3.3.1, Python 2.4.6, Apache 2.2.9 (MacPorts) on Mac OS X 10.5.6 (Leopard)

2009-01-14 Thread peterandall

I've also tried doing this:

$  cd /System/Library/Frameworks
$  sudo mv Python.framework XXX_Python.framework

$  cd  
$  ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/
opt/local/bin/python2.4 --with-max-locks=32

Then editing the src/Makefile and updating the LDFLAGS to this:

LDFLAGS= -Wl,-F/opt/local/Library/Frameworks -Wl,-framework,Python  -u
_PyMac_Error $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$
(PYTHONFRAMEWORK)   -L/opt/local/lib

Then continuing to make and install mod_python

$  make
$  sudo make install
$  cd /System/Library/Frameworks
$  sudo mv XXX_Python.framework Python.framework


Still no luck, when i run: 'otool -L /opt/local/apache2/modules/
mod_python.so' i get the following:

  /opt/local/apache2/modules/mod_python.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 111.1.3)
/System/Library/Frameworks/Python.framework/Versions/2.5/Python
(compatibility version 2.5.0, current version 2.5.1)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
version 1.0.0)

So its still building against the 2.5 version, this is really starting
to confuse me now, i've run out of things to try.

Thanks in advance for any help...
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



GeoDjango: Extract Latitude and Longitude from PointField

2009-01-14 Thread Alfonso

Hey,

Must be missing something extraordinarily simple - how do I
individually parse the latitude and longitude values from a PointField
entry into my app's templates?  I just want...


Latitude:
Longitude:


Thanks,

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



User Messages

2009-01-14 Thread Tim

Hi all -

I am using the messages framework to notify users when another user
has commented on their profile or on an item they've posted. I was
pretty excited to see that such an infrastructure was included with
the authentication system out of the box. However, I was disappointed
to see that the only way to retrieve messages was via a get _and_
delete operation, so each get (or reference to "messages" in a
template) emptied the queue.

I'd like to add some persistence to the messaging so that the queue is
flushed only when I specifically request it. But I'm not sure how best
to do it. My inclination would be to add something to my Profile model
and populate it with calls to get_and_delete_messages() at appropriate
times and never use "messages" in my templates at all, but rather just
pass the persistent object to the template.

Is there a better way to support Message persistence? Or should I just
build my own model to support this kind of thing? Rolling my own seems
fairly trivial since I'm already grabbing all the required information
anyway. But if it's not necessary, I'm not gonna do it.

- 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mod_python 3.3.1, Python 2.4.6, Apache 2.2.9 (MacPorts) on Mac OS X 10.5.6 (Leopard)

2009-01-14 Thread peterandall

Hi All,

I've been playing around with this for days and getting nowhere.

I've got python2.4 installed via macports along with the standard
Python2.3 and 2.5 installed in '/Library/Python/2.x'. I want to get
mod_python working for the macports version of python(2.4)

I've downloaded mod_python 3.1.1 and run the following commands (from
another post on django-users) to build it and install it:

$  cd /System/Library/Frameworks
$  sudo mv Python.framework XXX_Python.framework

$  cd  
$  ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/
opt/local/bin/python2.4 --with-max-locks=32
$  make
$  sudo make install

$  cd /System/Library/Frameworks
$  sudo mv XXX_Python.framework Python.framework

I've followed these steps to stop mod_python building against the
wrong version of python, yet in my apache error logs i get the
following errors:

[Wed Jan 14 16:14:50 2009] [notice] SIGHUP received.  Attempting to
restart
[Wed Jan 14 16:14:51 2009] [error] python_init: Python version
mismatch, expected '2.4.5', found '2.5.1'.
[Wed Jan 14 16:14:51 2009] [error] python_init: Python executable
found '/usr/bin/python'.
[Wed Jan 14 16:14:51 2009] [error] python_init: Python path being used
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python25.zip:/System/Library/Frameworks/Python.framework/Versions/2.5/
lib/python2.5/:/System/Library/Frameworks/Python.framework/Versions/
2.5/lib/python2.5/plat-darwin:/System/Library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/plat-mac:/System/Library/
Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-
scriptpackages:/System/Library/Frameworks/Python.framework/Versions/
2.5/lib/python2.5/../../Extras/lib/python:/System/Library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/lib-tk:/System/Library/
Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload'.
[Wed Jan 14 16:14:51 2009] [notice] mod_python: Creating 8 session
mutexes based on 256 max processes and 0 max threads.
[Wed Jan 14 16:14:51 2009] [notice] mod_python: using mutex_directory /
tmp
[Wed Jan 14 16:14:51 2009] [notice] Digest: generating secret for
digest authentication ...
[Wed Jan 14 16:14:51 2009] [notice] Digest: done
[Wed Jan 14 16:14:51 2009] [notice] Apache/2.2.9 (Unix) mod_ssl/2.2.9
OpenSSL/0.9.7l DAV/2 PHP/5.2.6 mod_python/3.3.1 Python/2.5.1
configured -- resuming normal operations

So mod_python is still referencing the wrong version of python(2.5),
despite following the instructions to try and stop that happening.

Also to double check that, i restarted apache whilst i had the python
framework renamed (to XXX_Python.framework) and recieved the following
error:

Pete:~ Pete$ sudo apachectl restart
httpd: Syntax error on line 116 of /opt/local/apache2/conf/httpd.conf:
Cannot load /opt/local/apache2/modules/mod_python.so into server:
dlopen(/opt/local/apache2/modules/mod_python.so, 10): Library not
loaded: /System/Library/Frameworks/Python.framework/Versions/2.5/Python
\n  Referenced from: /opt/local/apache2/modules/mod_python.so\n
Reason: image not found

So by the looks of that it's saying the the mod_python.so is trying to
reference Python2.5 so hasn't built properly (i.e to ref python2.4)

**

So does anyone have any ideas as to why mod_python won't build to the
2.4 version installed via macports, despite me configuring it to use
that one.

Sorry if the post is a bit of a mess i'm not that great at all this
stuff. Any help would be greatly received,

Pete.

**
P.s Other information that might be usefull:

Python:
Pete:~ Pete$ which python
/opt/local/bin/python

Apache:
Pete:~ Pete$ which apachectl
/opt/local/apache2/bin/apachectl

mod_python:
/opt/local/lib/python2.4/site-packages/mod_python

Python path:
Python 2.4.6 (#1, Jan 13 2009, 18:18:46)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/
python24.zip',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/plat-darwin',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/plat-mac',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/plat-mac/lib-scriptpackages',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/lib-tk',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/lib-dynload',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages',
'/opt/local/lib/python2.4/site-packages']


.bash_profile:
export PATH="/opt/local/bin:/opt/local/apache2/bin:/opt/local/lib/
mysql5/bin:$PATH"
alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &'
alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
--~--~-~--~~~---~--~~

redirect to results

2009-01-14 Thread Vince

Hi everyone,

I am a bit confused about how to do what follows, I would appreciate
any help.

My django project is very simple I have a upload zip page, this page
processes a zip file and it is being decompressed and stored in a
folder for further purposes.
After I check and unzip the file I call the return_to_render

return render_to_response('upload_OK.html', {'nombre': filename,
'size': filesize, 'type': filetype, 'msg': msg, 'is_ok': isOk,
'zip_list': zf.namelist(), 'item': file_inzip})

I have a link in the upload_ok.html that is supossed to show the files
inside the zip file (see below)

[...]

   

Analyst DEMO server


Subiendo...
 
 
  {% if is_ok %}
 {{ msg }} 
 {{ size|filesizeformat }}
 Tipo de archivo: {{ type}}

http://aux/
unzip_results/">Visualizar ficheros descomprimidos
[...]

The problem is that i have already the template that shows the results
and it works if I change the return render_to_response line by another
call to a different template. as the variables that I need are all in
the same function (check, unzip and store in a folder).

If I change the return render_to_response line by:

return render_to_response('unzip_OK.html', {'nombre':
filename,'zip_list': zf.namelist(), 'item': file_inzip, 'iNum':
iCount})

it works as it shows the results. The thing is that I would like to
only show the results if the user wants to, once he sees that the zip
has been correctly processed (by clicking at the link)

How am I supossed to implement this, Can i pass parameters to another
function that calls the second return render_to_response ?

Thanks in advance

Vince



--~--~-~--~~~---~--~~
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: How to set the from a ModelChoiceField?

2009-01-14 Thread mb0...@googlemail.com

Thank you very much... it took me some time to figure it out.
But now it 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: I'm moving to Oxford

2009-01-14 Thread José Moreira

dont go, run from the white light!

2009/1/14 Juan Hernandez :
> yes, we are going to miss you very much ;)
>
> So long london!
>
> On Wed, Jan 14, 2009 at 10:10 AM, Marc Boivin  wrote:
>>
>> Glad you let the whole Django community know ;)
>>
>>
>> On 09-01-14, at 08:52, "Will McGugan"  wrote:
>>
>> Hi,
>>
>> I'm sending this out to everyone in my gmail contacts, because I'm lazy.
>> Apologies if you don't need to know this.
>>
>> I'm moving to Oxford tomorrow (Thursday 15th). Please get in touch if you
>> need my new address. My landline will change, but you can always get me on
>> my mobile.
>>
>> I wont have internet access at home from tomorrow, so apologies if emails
>> go unanswered till I get broadband again!
>>
>> So long, London!
>>
>> Will
>>
>> --
>> Will McGugan
>> http://www.willmcgugan.com
>>
>>
>>
>>
>
>
> >
>



-- 
José Moreira

--~--~-~--~~~---~--~~
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: Transactions not working

2009-01-14 Thread Thomas Guettler

You need to test if the data is already in the db first.
There is a handy method:

model_object, created = YourModel.objects.get_or_create(...)

If you still get this errors, you might want to check if
your sequence is in sync:

select max(id) from yourapp_yourmodel;

select * from yourapp_yourmodel_id_seq ;

  Thomas

thomasbecht...@googlemail.com schrieb:
> Hi all,
>
> Problem: I want to use Transaction to save data to a postgresql-db.
> Error: IntegrityError: doppelter Schlüsselwert (double keyvalue)
> verletzt (harm) Unique-Constraint
> ...



-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~-~--~~~---~--~~
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: Getting a 'too many values to unpack' error

2009-01-14 Thread Thomas Guettler

yourmodel.objects.filter(a) does not work since a seems to be a queryset.

You need to use .filter(attribute=value) or something like this.

BTW: Why do you do all the select_related() calls?

Michael schrieb:
> Hello,
> Here is my code:
>
> filter = {}
> if request.GET.get('color', '').isdigit():
> filter['color_cat'] = request.GET['color']
> if request.GET.get('origin', '').isdigit():
> filter['collection__origin'] = request.GET['origin']
> styles = Style.objects.select_related().filter(**filter).distinct()
> if request.GET.get('minprice', '').isdigit() :
> if request.GET.get('size', '').isdigit():
> a = Style.objects.filter(Q
> (sandp__size__size_cat=request.GET['size']) & Q
> (sandp__price__name__gte=request.GET['minprice']))
> styles = styles.select_related().filter(a) ### This is the
> line that is giving me the error!!
>
> Whenever I do a search where the user enters a minimum price and
> selects a sizeI get the error:
>
> 'ValueError at /search/ too many values to unpack'
>
> The error comes from the line 'styles = styles.select_related().filter
> (a)'
>   


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~-~--~~~---~--~~
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: I'm moving to Oxford

2009-01-14 Thread Juan Hernandez
yes, we are going to miss you very much ;)

So long london!

On Wed, Jan 14, 2009 at 10:10 AM, Marc Boivin  wrote:

> Glad you let the whole Django community know ;)
>
>
> On 09-01-14, at 08:52, "Will McGugan"  wrote:
>
> Hi,
>
> I'm sending this out to everyone in my gmail contacts, because I'm lazy.
> Apologies if you don't need to know this.
>
> I'm moving to Oxford tomorrow (Thursday 15th). Please get in touch if you
> need my new address. My landline will change, but you can always get me on
> my mobile.
>
> I wont have internet access at home from tomorrow, so apologies if emails
> go unanswered till I get broadband again!
>
> So long, London!
>
> Will
>
> --
> Will McGugan
> http://www.willmcgugan.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: I'm moving to Oxford

2009-01-14 Thread Marc Boivin
Glad you let the whole Django community know ;)


On 09-01-14, at 08:52, "Will McGugan"  wrote:

> Hi,
>
> I'm sending this out to everyone in my gmail contacts, because I'm  
> lazy. Apologies if you don't need to know this.
>
> I'm moving to Oxford tomorrow (Thursday 15th). Please get in touch  
> if you need my new address. My landline will change, but you can  
> always get me on my mobile.
>
> I wont have internet access at home from tomorrow, so apologies if  
> emails go unanswered till I get broadband again!
>
> So long, London!
>
> Will
>
> -- 
> Will McGugan
> http://www.willmcgugan.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ifequals Decimalfield comparison

2009-01-14 Thread Ardesco

So, I have a decimalfield that can be 3 different values. In my view,
I pass in a dictionary of values that contains the appropriate decimal
values as keys.

{% for item in booklist %}
{% for key, value in numvec.items %}
{{item.number}}
{% ifequals item.number value %}
{{value}}
{% endifequals %}
{% endfor %}

this is the dict I pass in as numvec:
numvec = {"TEST":Decimal("0.999"), "TEST2":Decimal("0.500"),
"TEST3":Decimal("0.255")}

the number field was defined as having these choices in my model:
BOOK_CHOICES = (
(Decimal("0.999"), 'TEST'),
(Decimal("0.500"), 'TEST2'),
(Decimal("0.255"), 'TEST3'),
)

The item number prints out just fine in the view if I compare the dict
with the attribute, but for some reason the ifequals cannot properly
compare two decimals together. Is this a bug, or am I doing something
wrong in my template with ifequals?
--~--~-~--~~~---~--~~
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: Overriding Model's save method: error propagation

2009-01-14 Thread Markus T.

if x > y:

should read

except:

of course...
--~--~-~--~~~---~--~~
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: Overriding Model's save method: error propagation

2009-01-14 Thread Markus T.

David,

for me, these two links did the trick:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin
http://docs.djangoproject.com/en/dev/ref/forms/validation/#ref-forms-validation

However, validation as described in the Django docs does not happen in
the model's save method; it happens in the admin form. Above links
explain how to tell the admin layer to use your form class which
provides its own validation method. So you could alter the second
database in the validation method and raise a ValidationError if it
fails.
For example:

models.py:
class MyModel(models.Model):
  [...]

class MyModelAdminForm(forms.ModelForm):
  class Meta:
model = MyModel

  def clean(self):
data = self.cleaned_data

try:
  # alter other DB here

if x > y:
  raise forms.ValidationError(_("X must not be greater than y!"))

return data

admin.py:
class MyModelAdmin(admin.ModelAdmin):
  form = MyModelAdminForm


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



Getting a 'too many values to unpack' error

2009-01-14 Thread Michael

Hello,
Here is my code:

filter = {}
if request.GET.get('color', '').isdigit():
filter['color_cat'] = request.GET['color']
if request.GET.get('origin', '').isdigit():
filter['collection__origin'] = request.GET['origin']
styles = Style.objects.select_related().filter(**filter).distinct()
if request.GET.get('minprice', '').isdigit() :
if request.GET.get('size', '').isdigit():
a = Style.objects.filter(Q
(sandp__size__size_cat=request.GET['size']) & Q
(sandp__price__name__gte=request.GET['minprice']))
styles = styles.select_related().filter(a) ### This is the
line that is giving me the error!!

Whenever I do a search where the user enters a minimum price and
selects a sizeI get the error:

'ValueError at /search/ too many values to unpack'

The error comes from the line 'styles = styles.select_related().filter
(a)'
--~--~-~--~~~---~--~~
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: Overriding Model's save method: error propagation

2009-01-14 Thread Markus

David,

I've been looking for a solution for this problem, too.
Maybe this helps - I'm yet to try this out:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin

Things seem to be underway though:
http://code.djangoproject.com/ticket/6845
http://wiki.github.com/HonzaKral/django/model-validation

Cheers
Markus
--~--~-~--~~~---~--~~
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: How to add tinyMCE to django 1.0.2 admin

2009-01-14 Thread Oleg Oltar
it, worked!
thanks everyone!

On Wed, Jan 14, 2009 at 3:40 PM, kamil  wrote:

>
> Hi Oleg
>
> You must create your admin config eg:
>
> class ArticleOptions(admin.ModelAdmin):
>
>class Media:
>js = ('/static_media/js/tiny_mce/tiny_mce.js', '/static_media/
> js/textareas.js')
>
>
> Please check if it correspond to your urs.
> good luck
> kamil
>
> On Jan 13, 9:43 pm, "Oleg Oltar"  wrote:
> > Hi!
> >
> > I want to add tinyMCE to my project's admin site. I downloaded the latest
> > version of the editor, added the js/tiny_mce to my media files
> >
> > Added following to my urls.py
> > from django.conf.urls.defaults import *
> >
> > # Uncomment the next two lines to enable the admin:
> > from django.contrib import admin
> > admin.autodiscover()
> >
> > urlpatterns = patterns('django.views.generic.simple',
> >(r'^contacts$',
> > 'direct_to_template',{'template':'visitcard/contacts.html'} ),
> >(r'^construction$',
> > 'direct_to_template',{'template':'visitcard/construction.html'}),
> >(r'^portfolio1$',
> > 'direct_to_template',{'template':'visitcard/portfolio.html'}),
> >(r'^partners$',
> > 'direct_to_template',{'template':'visitcard/partners.html'}),
> >(r'^articles$',
> > 'direct_to_template',{'template':'visitcard/artilcles.html'}),
> >(r'^portfolio$',
> > 'direct_to_template',{'template':'visitcard/portfolio1.html'}),
> >(r'^dom_karkasnij$', 'direct_to_template',
> > {'template':'visitcard/dom_karkas.html'}),
> >(r'^$',
> > 'direct_to_template',{'template':'visitcard/index.html'} ),
> >
> >)
> >
> > urlpatterns +=  patterns('',
> >
> > (r'^tiny_mce/(?P.*)$','django.views.static.serve',
> >   {'document_root':
> > '/Users/oleg/Desktop/TECHNOBUD/TEMPLATES/static_media/js/tiny_mce' }),
> >  (r'^admin/', include('cms.admin_urls')),
> >  (r'^admin/(.*)', admin.site.root),
> >  )
> >
> > Also created the config for tinyMCE: textareas.js
> > tinyMCE.init({
> > mode : "textareas",
> > theme : "advanced",
> > //content_css : "/appmedia/blog/style.css",
> > theme_advanced_toolbar_location : "top",
> > theme_advanced_toolbar_align : "left",
> > theme_advanced_buttons1 :
> >
> "fullscreen,separator,preview,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,separator,image,cleanup,help,separator,code",
> > theme_advanced_buttons2 : "",
> > theme_advanced_buttons3 : "",
> > auto_cleanup_word : true,
> > plugins :
> >
> "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,fullscreen",
> > plugin_insertdate_dateFormat : "%m/%d/%Y",
> > plugin_insertdate_timeFormat : "%H:%M:%S",
> > extended_valid_elements :
> >
> "a[name|href|target=_blank|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
> > fullscreen_settings : {
> > theme_advanced_path_location : "top",
> > theme_advanced_buttons1 :
> >
> "fullscreen,separator,preview,separator,cut,copy,paste,separator,undo,redo,separator,search,replace,separator,code,separator,cleanup,separator,bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,help",
> > theme_advanced_buttons2 :
> >
> "removeformat,styleselect,formatselect,fontselect,fontsizeselect,separator,bullist,numlist,outdent,indent,separator,link,unlink,anchor",
> > theme_advanced_buttons3 :
> >
> "sub,sup,separator,image,insertdate,inserttime,separator,tablecontrols,separator,hr,advhr,visualaid,separator,charmap,emotions,iespell,flash,separator,print"
> > }
> >
> > });
> >
> > My models file:
> > from django.db import models
> >
> > class Article(models.Model):
> > title = models.CharField(max_length=60)
> > body = models.TextField(max_length=3000)
> > slug = models.SlugField(unique=True)
> >
> > The editor is still not appearing on my admin interface, when I am trying
> to
> > add articles... Did I miss something? Please help me to understand the
> > problem
> >
> > Thanks,
> > Oleg
> >
>

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

admin model search

2009-01-14 Thread Bobby Roberts

hi all...

I have search fields setup in my admin model as such:


search_fields = ['name','postdate','testimony']


When i try to search , it just shows everything in the database.  Am I
missing something here?


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



I'm moving to Oxford

2009-01-14 Thread Will McGugan
Hi,

I'm sending this out to everyone in my gmail contacts, because I'm lazy.
Apologies if you don't need to know this.

I'm moving to Oxford tomorrow (Thursday 15th). Please get in touch if you
need my new address. My landline will change, but you can always get me on
my mobile.

I wont have internet access at home from tomorrow, so apologies if emails go
unanswered till I get broadband again!

So long, London!

Will

-- 
Will McGugan
http://www.willmcgugan.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to add tinyMCE to django 1.0.2 admin

2009-01-14 Thread kamil

Hi Oleg

You must create your admin config eg:

class ArticleOptions(admin.ModelAdmin):

class Media:
js = ('/static_media/js/tiny_mce/tiny_mce.js', '/static_media/
js/textareas.js')


Please check if it correspond to your urs.
good luck
kamil

On Jan 13, 9:43 pm, "Oleg Oltar"  wrote:
> Hi!
>
> I want to add tinyMCE to my project's admin site. I downloaded the latest
> version of the editor, added the js/tiny_mce to my media files
>
> Added following to my urls.py
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('django.views.generic.simple',
>                        (r'^contacts$',
> 'direct_to_template',{'template':'visitcard/contacts.html'} ),
>                        (r'^construction$',
> 'direct_to_template',{'template':'visitcard/construction.html'}),
>                        (r'^portfolio1$',
> 'direct_to_template',{'template':'visitcard/portfolio.html'}),
>                        (r'^partners$',
> 'direct_to_template',{'template':'visitcard/partners.html'}),
>                        (r'^articles$',
> 'direct_to_template',{'template':'visitcard/artilcles.html'}),
>                        (r'^portfolio$',
> 'direct_to_template',{'template':'visitcard/portfolio1.html'}),
>                        (r'^dom_karkasnij$', 'direct_to_template',
> {'template':'visitcard/dom_karkas.html'}),
>                        (r'^$',
> 'direct_to_template',{'template':'visitcard/index.html'} ),
>
>                        )
>
> urlpatterns +=  patterns('',
>
> (r'^tiny_mce/(?P.*)$','django.views.static.serve',
>                           {'document_root':
> '/Users/oleg/Desktop/TECHNOBUD/TEMPLATES/static_media/js/tiny_mce' }),
>                          (r'^admin/', include('cms.admin_urls')),
>                          (r'^admin/(.*)', admin.site.root),
>                          )
>
> Also created the config for tinyMCE: textareas.js
> tinyMCE.init({
>     mode : "textareas",
>     theme : "advanced",
>     //content_css : "/appmedia/blog/style.css",
>     theme_advanced_toolbar_location : "top",
>     theme_advanced_toolbar_align : "left",
>     theme_advanced_buttons1 :
> "fullscreen,separator,preview,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,separator,image,cleanup,help,separator,code",
>     theme_advanced_buttons2 : "",
>     theme_advanced_buttons3 : "",
>     auto_cleanup_word : true,
>     plugins :
> "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,fullscreen",
>     plugin_insertdate_dateFormat : "%m/%d/%Y",
>     plugin_insertdate_timeFormat : "%H:%M:%S",
>     extended_valid_elements :
> "a[name|href|target=_blank|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
>     fullscreen_settings : {
>         theme_advanced_path_location : "top",
>         theme_advanced_buttons1 :
> "fullscreen,separator,preview,separator,cut,copy,paste,separator,undo,redo,separator,search,replace,separator,code,separator,cleanup,separator,bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,help",
>         theme_advanced_buttons2 :
> "removeformat,styleselect,formatselect,fontselect,fontsizeselect,separator,bullist,numlist,outdent,indent,separator,link,unlink,anchor",
>         theme_advanced_buttons3 :
> "sub,sup,separator,image,insertdate,inserttime,separator,tablecontrols,separator,hr,advhr,visualaid,separator,charmap,emotions,iespell,flash,separator,print"
>     }
>
> });
>
> My models file:
> from django.db import models
>
> class Article(models.Model):
>     title = models.CharField(max_length=60)
>     body = models.TextField(max_length=3000)
>     slug = models.SlugField(unique=True)
>
> The editor is still not appearing on my admin interface, when I am trying to
> add articles... Did I miss something? Please help me to understand the
> problem
>
> Thanks,
> Oleg
--~--~-~--~~~---~--~~
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: Getting url/host/domain info in settings.py

2009-01-14 Thread Donn

Tom, thanks for your feedback.

I guess what I was asking was how to get the domain/subdomain info from places 
like models and settings -- i.e. places that have no connection to a request.

Still, I see a way through and will employ your suggestions.

\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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to add tinyMCE to django 1.0.2 admin

2009-01-14 Thread Oleg Oltar
yep, trying it
But still not sure how to add it to admin

On Wed, Jan 14, 2009 at 10:54 AM, izzy_dizzy  wrote:

>
> Try using django-tiny_mce
>
> Here's its documentation:
> http://django-tinymce.googlecode.com/svn/tags/release-1.2/docs/.build/html/index.html
>
>
>
> On Jan 14, 3:26 pm, "Oleg Oltar"  wrote:
> > Ok, I read the doc...But not sure if I done everything correctly, as the
> > tinyMCE is still not in my admin
> >
> > So what I've done:
> >
> > beryl:TECHNOBUD oleg$ cp
> >
> /Users/oleg/src/django1.0/django/contrib/admin/templates/admin/change_form.html
> > ./TEMPLATES/admin/
> >
> > Then I edited copied file and added:
> >
> > 
> > 
> > tinyMCE.init({
> > mode: "textareas",
> > theme:"simple"});
> >
> > 
> >
> > after the line:
> >
> > 
> >
> > (I read this solution in practical-django-projects book)
> >
> > That's all what I've done so far. But the editor still didn't appear
> >
> > Thanks,
> > Oleg
> >
> > On Wed, Jan 14, 2009 at 12:18 AM, Brian Neal  wrote:
> >
> > > On Jan 13, 3:43 pm, "Oleg Oltar"  wrote:
> > > > Hi!
> >
> > > > I want to add tinyMCE to my project's admin site.
> >
> > > You didn't list any admin.py code. Check out the docs on the admin
> > > interface:
> >
> > >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#module-django.
> ..
> >
> > > After you read through that, pay attention to the ModelAdmin media
> > > definitions:
> >
> > >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-me.
> ..
> >
> > > It is there you specify the tinymce javascript files. When the admin
> > > displays the form for your models it will generate the appropriate
> > > script tags to the javascript files.
> >
> > > Good luck!
> > > BN
>
> >
>

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



How to import Hotmail/Messenger contacts...

2009-01-14 Thread bcurtu

Is there any API like gdata or bbauth to authenticated against hotmail
servers to be able to read hotmail contacts?

thanx.
--~--~-~--~~~---~--~~
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: request.user objects in base.html

2009-01-14 Thread Alan
On your views.py, do something like:

@login_required

def readme(request):

return render_to_response('acpypi/readme.html', {'user': request.user})

I mean, your view has to pass the 'user' value to the template. I use this
very same scheme where all my pages extent base.html, so in my readme.html:


{% extends "base.html" %}
...

I hope it helps.

Cheers,
Alan

On Wed, Jan 14, 2009 at 07:15, izzy_dizzy  wrote:

>
> Hi all,
>
> I'm having a hard time on how to use request.user objects in
> base.html. I know that we can use requestcontext to be able to render
> request.user and its objects on a given template but I would like
> someone help me to be able to use it on base.html like:
>
> {% if user.is_authenticated%} You are currently logged in.{%endif%}
>
> I also tried to use custom template tags but I can't get it right. Can
> any one provide me a working custom template tag for this one?
>
> Thanks!!
>
> >
>


-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<

--~--~-~--~~~---~--~~
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: How to add tinyMCE to django 1.0.2 admin

2009-01-14 Thread izzy_dizzy

Try using django-tiny_mce

Here's its documentation: 
http://django-tinymce.googlecode.com/svn/tags/release-1.2/docs/.build/html/index.html



On Jan 14, 3:26 pm, "Oleg Oltar"  wrote:
> Ok, I read the doc...But not sure if I done everything correctly, as the
> tinyMCE is still not in my admin
>
> So what I've done:
>
> beryl:TECHNOBUD oleg$ cp
> /Users/oleg/src/django1.0/django/contrib/admin/templates/admin/change_form.html
> ./TEMPLATES/admin/
>
> Then I edited copied file and added:
>
> 
> 
> tinyMCE.init({
> mode: "textareas",
> theme:"simple"});
>
> 
>
> after the line:
>
> 
>
> (I read this solution in practical-django-projects book)
>
> That's all what I've done so far. But the editor still didn't appear
>
> Thanks,
> Oleg
>
> On Wed, Jan 14, 2009 at 12:18 AM, Brian Neal  wrote:
>
> > On Jan 13, 3:43 pm, "Oleg Oltar"  wrote:
> > > Hi!
>
> > > I want to add tinyMCE to my project's admin site.
>
> > You didn't list any admin.py code. Check out the docs on the admin
> > interface:
>
> >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#module-django...
>
> > After you read through that, pay attention to the ModelAdmin media
> > definitions:
>
> >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-me...
>
> > It is there you specify the tinymce javascript files. When the admin
> > displays the form for your models it will generate the appropriate
> > script tags to the javascript files.
>
> > Good luck!
> > BN

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



request.user objects in base.html

2009-01-14 Thread izzy_dizzy

Hi all,

I'm having a hard time on how to use request.user objects in
base.html. I know that we can use requestcontext to be able to render
request.user and its objects on a given template but I would like
someone help me to be able to use it on base.html like:

{% if user.is_authenticated%} You are currently logged in.{%endif%}

I also tried to use custom template tags but I can't get it right. Can
any one provide me a working custom template tag for this one?

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



a different kind of file path field

2009-01-14 Thread DrKayBee

Hi,
I'm creating a task journal using django for personal use.

I'm creating an application wherein I require a CharField to store a
file location on a local drive. This is different from the FileField,
since I do not want to 'upload' the file to any different location on
my local drive, just to record a file url. What field must I use for
this? The FilePathField doesn't work for me because I want the
absolute location of the file to be user selectable, not restricted to
a pre-determined location. Ideally I would like a file chooser
dialog.

Do I need to create my own field or is there something I'm missing?

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



Re: Getting url/host/domain info in settings.py

2009-01-14 Thread Tom Dyson

Settings can be altered at runtime - the middleware code I referenced
does this - but the Django docs warn against it:

http://docs.djangoproject.com/en/dev/topics/settings/#altering-settings-at-runtime

I'd recommend using middleware to set the subdomain in the request
scope, e.g.:

http://www.djangosnippets.org/snippets/1119/

Tom

On Jan 13, 5:53 pm, Donn  wrote:
> On Tuesday, 13 January 2009 19:28:01 Tom Dyson wrote:
>
> > We do something like this with middleware in theCarbonAccount[1]:
>
> I have not used middleware yet, so will look into it. I am not sure if it can
> supply request.META *within* settings.py though.
>
> I want to set certain variables depending on what visits the settings.py file
> in my project. For example:
> UPLOAD_DIR would be 'www' when the browser comes fromwww.mydomain.comand it
> would be 'comics' when from comics.mydomain.com
>
> Or am I getting this all muddled? I have the vaguest notion that settings.py
> and some other files are run once and kept in memory after that -- so perhaps
> my idea won't work anyway.
>
> \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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to add tinyMCE to django 1.0.2 admin

2009-01-14 Thread Oleg Oltar
Also my admin code is

from TECHNOBUD.visitcard.models import Article

from django.contrib import admin

admin.site.register(Article)


Need help :(


I tried to do everything from the beginning, so started a new project.
I added there django tiny_mce application.

I added these code to my settings file:

TINYMCE_JS_URL='http://127.0.0.1:8000/smedia/js/tiny_mce/tiny_mce_src.js'



TINYMCE_DEFAULT_CONFIG={
'theme': 'advanced',
'mode': 'textareas',
}



Also added a line to urls:
(r'^tinymce/', include('tinymce.urls')),

But still, not sure how to make my fields be represented by the mce

Please help!


On Wed, Jan 14, 2009 at 9:26 AM, Oleg Oltar  wrote:

> Ok, I read the doc...But not sure if I done everything correctly, as the
> tinyMCE is still not in my admin
>
> So what I've done:
>
> beryl:TECHNOBUD oleg$ cp
> /Users/oleg/src/django1.0/django/contrib/admin/templates/admin/change_form.html
> ./TEMPLATES/admin/
>
> Then I edited copied file and added:
>
> 
> 
> tinyMCE.init({
> mode: "textareas",
> theme:"simple"
> });
> 
>
> after the line:
>
> 
>
> (I read this solution in practical-django-projects book)
>
>
>
> That's all what I've done so far. But the editor still didn't appear
>
> Thanks,
> Oleg
>
> On Wed, Jan 14, 2009 at 12:18 AM, Brian Neal  wrote:
>
>>
>> On Jan 13, 3:43 pm, "Oleg Oltar"  wrote:
>> > Hi!
>> >
>> > I want to add tinyMCE to my project's admin site.
>>
>> You didn't list any admin.py code. Check out the docs on the admin
>> interface:
>>
>>
>> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#module-django.contrib.admin
>>
>> After you read through that, pay attention to the ModelAdmin media
>> definitions:
>>
>>
>> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-media-definitions
>>
>> It is there you specify the tinymce javascript files. When the admin
>> displays the form for your models it will generate the appropriate
>> script tags to the javascript files.
>>
>> Good luck!
>> BN
>> >>
>>
>

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



Transactions not working

2009-01-14 Thread thomasbecht...@googlemail.com

Hi all,

Problem: I want to use Transaction to save data to a postgresql-db.
Error: IntegrityError: doppelter Schlüsselwert (double keyvalue)
verletzt (harm) Unique-Constraint
»measurements_loggerdata_logger_id_key«

My Model looks like this:

class LoggerData(models.Model):
  logger = models.ForeignKey(Logger)
  datetime = models.DateTimeField(db_index=True)
  class Meta:
unique_together = [('logger', 'datetime')]

Now i read from a file measurement-data. It should be possible to read
the same file as often as i want, but maybe, there is some new data
append to the file. So the problem is, that inside of the file, there
is some old and some new data. The old data should not be written to
the DB, the new Data should be writte to the DB.

My Method to write the data to DB looks like:

from django.db import transaction
obj = LoggerData(**params)
self.saveLoggerDataToDatabase(obj)

def saveLoggerDataToDatabase(self, obj):
""" Save a LoggerData Object to the Database. Use a
Transaction for this."""
transaction.enter_transaction_management()
obj.save()
try:
transaction.commit()
except(psycopg2.IntegrityError, psycopg2.InternalError), e:
self.logger.error(str(e.message) + str(line[0]))
transaction.rollback()#
transaction.leave_transaction_management()

I also tried it without  transaction.enter_transaction_management()
and with a decorator (commit_manually() ). I tried with activated
Middleware and without. Nothing worked for me.

I also tried to coment out the commit() statement. The strange thing
was, that i got the same error. I thougt, without the commit()
statement, the DB would not get touched.

have you any suggestions?

Thanks,
Tom

--~--~-~--~~~---~--~~
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: How to find out more info about "Error: No module named ..."

2009-01-14 Thread Alan
Assuming you are in your project dir, I think it has to be:
python -v ./manage.py validate

Alan

On Wed, Jan 14, 2009 at 02:59, Karen Tracey  wrote:

> On Tue, Jan 13, 2009 at 1:21 PM, jhill10110  wrote:
>
>>
>> I am getting a module load error but I can't tell what is causing it.
>>
>> Running `./django-admin.py validate --verbosity 2` returns "Error: No
>> module named config".
>>
>> I have no idea what is trying to load this module and can't find any
>> reference to it after doing several greps. How can I find out more
>> information on what is actually looking for this config module?
>
>
> Try
>
> python -v  django-admin.py validate
>
> and you should be able to see (once you sift through all the output) what's
> trying to pull in this nonexistant config.
>
> Karen
>
> >
>


-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<

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



post_syncdb signal: Called several times

2009-01-14 Thread Thomas Guettler

Hi,

I read the docs for the sync_db signal:
   http://docs.djangoproject.com/en/dev/ref/signals/#post-syncdb

The signal gets fired several times. Since my app has several model classes.

But how can you know that the tabel for a particular model was just created?

Or do you need to write the callback method the way, that it can be called
several times (for example: check if change was already done before
changing something)

  Thomas


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~-~--~~~---~--~~
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: Dealing with 'date' ranges in template?

2009-01-14 Thread Daniel Roseman

On Jan 13, 9:40 pm, Manfred  wrote:
> Hello,
>
> I wrote a special kind of blog- or news application. One of the
> specialities of this application is, that authors are able to make
> entries visible/invisible by a date range or by a simple switch to
> hide the entry. This works well. But (the authors are not supposed to
> use the admin interface) authors need to be able to change the state
> of 'invisible' entries if they are in editing mode. Therefore, the
> view selects _all_ entries if one is logged in but only visible ones
> if one is not logged in.
>
> To support authors and show them if an entry is visible for the normal
> user or not, invisible entries have a different layout than visible
> ones. Using a booelan field 'entry.hide' in the template is easy by {%
> if entry.hide %}...
>
> But how can I deal with the date range? I have two fields: 'show_from'
> and 'show_until' to restrict the visible date range for each entry.
> The essence of what I need is something like this:
>
> IF entry.hide == True OR entry.show_from > date.today() OR
> entry.show_until < date.today() THEN ...
>
> In my template currently I use a statement like this: {% if entry.hide
> %} class="hidden"{% endif %} to change the section layout for
> invisible sections. But if the entry is "invisible" because of the
> date range, I had no success to mark the entry 'hidden' in the
> templete.
>
> Currently my application runs on Django 0.96, but I did not found any
> solution to this question even in Django 1.0
>
> Is there a solution?
>
> Many thanks in advance,
> Manfred.

I would put a method on your entry class, something like is_hidden,
which would do the calculation and return a boolean. Then your
template can just call {% if entry.is_hidden %} as necessary.
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---