Dynamically add a line to an inlineformset

2009-08-19 Thread Andew Gee

Does anyone know how to add a new line to anlineformset dynamically? I
have a page that contains an inlineformset and I need to be able to
click a button and add a new line which will then be saved when the
form is submitted, is that possible?

Thanks
Andrew
--~--~-~--~~~---~--~~
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: Displaying username on every page

2009-08-19 Thread John Barham

On Aug 19, 9:27 pm, Kenneth Gonsalves wrote:

> > Yes, I'd read about RequestContext but from what I understand you have
> > to pass it explicitly to render_to_response().  Is that the case?
>
> yes

Thanks for the confirmation.  In that case I'll have to write my own
render_to_response() wrapper.

  John
--~--~-~--~~~---~--~~
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: Displaying username on every page

2009-08-19 Thread Kenneth Gonsalves

On Thursday 20 Aug 2009 9:52:37 am John Barham wrote:
> > If you use RequestContext(), you automatically get visibility to the
> > current user and their permissions
>
> (Sorry, I meant to say RequestContext instead of RequestInstance.)
>
> Yes, I'd read about RequestContext but from what I understand you have
> to pass it explicitly to render_to_response().  Is that the case?

yes
-- 
regards
kg
http://lawgon.livejournal.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: django-tinymce not appearing in admin

2009-08-19 Thread Kenneth Gonsalves

On Thursday 20 Aug 2009 9:42:33 am zignorp wrote:
> Can you post the example of Setting the Media nested class with the
> TinyMCE media?
> I'm in exactly the same place,

class ReportAdmin(admin.ModelAdmin):
list_display  = ['title','approved']
class Media:
js = ('/sitemedia/js/tiny_mce/jscripts/tiny_mce/tiny_mce.js',
  '/sitemedia/js/tiny_mce/jscripts/tiny_mce/textareas.js',)
-- 
regards
kg
http://lawgon.livejournal.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: Displaying username on every page

2009-08-19 Thread John Barham

On Aug 19, 5:06 pm, grahamu  wrote:

> If you use RequestContext(), you automatically get visibility to the
> current user and their permissions

(Sorry, I meant to say RequestContext instead of RequestInstance.)

Yes, I'd read about RequestContext but from what I understand you have
to pass it explicitly to render_to_response().  Is that the case?

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



Models.py and overriding the get_or_create class method. Help please with obj = self.model(**params)

2009-08-19 Thread rh0dium

Hi all,

I have a class in which I want to override the get_or_create method.
Basically if my class doesn't store the answer I want it do some
process to get the answer and it's not provided. The method is really
a get_or_retrieve method.  I have heavily borrowed this from db/models/
query.py and I can't figure out the line "obj = self.model(**params)".
I don't understand what the attr model needs to be and it's not
intuitively obvious what this should be. Even looking back at the
query.py I can't figure this out. Can someone explain this to me? I
would really like to understand it and fix my code.

So here's the class:

class P4User(models.Model):
  user  = models.CharField(max_length=100, primary_key=True)
  fullname  = models.CharField(max_length=256)
  email = models.EmailField()
  access= models.DateField(auto_now_add=True)
  update= models.DateField(auto_now_add=True)

  @classmethod
  def get_or_retrieve(self, username, auto_now_add=False):
try:
return self.get(user=username), False
except self.model.DoesNotExist:
import P4
import datetime
from django.db import connection, transaction, IntegrityError
p4 = P4.P4().connect()
kwargs = p4.run(("user", "-o", username))[0]
p4.disconnect()
params = dict( [(k.lower(),v) for k, v in kwargs.items
()])
obj = self.model(**params)
sid = transaction.savepoint()
obj.save(force_insert=True)
transaction.savepoint_commit(sid)
return obj, True
except IntegrityError, e:
transaction.savepoint_rollback(sid)
try:
return self.get(**kwargs), False
except self.model.DoesNotExist:
raise e

  def __unicode__(self):
return str(self.user)

I am able to get the params but I haven't defined self.model. I don't
understand what that needs to be and it's not intuitively obvious what
value that should be. Even looking back at the query.py I can't figure
this out. Can someone explain this to me? I would really like to
understand it and fix my code.

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: django-tinymce not appearing in admin

2009-08-19 Thread zignorp

Hello,
Can you post the example of Setting the Media nested class with the
TinyMCE media?
I'm in exactly the same place,
Thanks,
Wendy

On Aug 14, 3:15 pm, diogobaeder  wrote:
> Kenneth,
>
> Setting the Media nested class with the TinyMCE media worked! :-)
>
> Thanks for the help, and sorry for the delay to answer your last post.
>
> Diogo
>
> On Aug 13, 5:28 am, diogobaeder  wrote:
>
> > Hehehehe... indeed, it's a curious problem...
>
> > Well, I'll try to stick to your posting suggestions, then. About the
> > TinyMCE, I'm getting some errors, but it must be some typo
> > somewhere... I'll post the results here when I make the changes.
>
> > Thanks!
>
> > Diogo
>
> > On Aug 12, 9:27 pm, Kenneth Gonsalves  wrote:
>
> > > On Wednesday 12 Aug 2009 9:35:30 pm diogobaeder wrote:
>
> > > > Oops, sorry... it's version 1.1 final.
>
> > > > I'll try to create the Media subclass with the media, then, although
> > > > it's not specified in the django-tinymce use documentation.
>
> > > > About dpaste, I'm confused, because in another post I pasted exception
> > > > content and someone advised me to use dpaste to make the thread more
> > > > readable. Are you really sure this is a recommendation for this list?
>
> > > it is not a recommendation - it is my personal opinion. I have been 
> > > flamed in
> > > the past for both not posting enough of the error traceback and also for
> > > posting too much of the error traceback. I have also been bitten in the
> > > archives where the dpaste has expired. I suppose the best way would be to
> > > paste the relevant lines of the traceback inline and the full traceback
> > > somewhere else. But then one has to know which lines are relevant - and 
> > > if one
> > > does know that, usually one can solve the problem himself.
> > > --
> > > regards
> > > kghttp://lawgon.livejournal.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: invitation mechanism implementation, ideas needed

2009-08-19 Thread Kenneth Gonsalves

On Thursday 20 Aug 2009 7:14:40 am Nicolas Aggelidis wrote:
> once again i need your help. I want to implement a simple friendship
> invitation/rejection mechanism. In more words, a user sends an
> invitation to another user, the latter has the option to accept it ,
> or reject it...
>
>
> What parts of django should i look into? (i am new to django!) .

try signals - user fills in invitation and presses submit, it is saved and a 
signal is used to send mail/url to the receiver ...
-- 
regards
kg
http://lawgon.livejournal.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
-~--~~~~--~~--~--~---



invitation mechanism implementation, ideas needed

2009-08-19 Thread Nicolas Aggelidis

hi friends,

once again i need your help. I want to implement a simple friendship
invitation/rejection mechanism. In more words, a user sends an
invitation to another user, the latter has the option to accept it ,
or reject it...


What parts of django should i look into? (i am new to django!) .

In the morning i will look into
http://code.google.com/p/django-friends/ source code. any other
sources i should look?

ideas or anything is welcome!

-nicolas

--~--~-~--~~~---~--~~
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: Problem installing Django 1.1 on XP

2009-08-19 Thread Karen Tracey
2009/8/19 Nikola Smiljanić 

>
> Django-1.1.tar.gz
> MD5: b2d75b4457a39c405fa2b36bf826bf6b
>
> Same thing. File __init__ in django/utils starts exactly like
> traceback says:
>
> Django-1.1/Django was originally created in late 2003 at World Online,
> the Web division
> of the Lawrence Journal-World newspaper in Lawrence, Kansas.
>

If your copy of django/utils/__init__.py contains that text than whatever
tool you are using to unpack the tar.gz file is broken.  There have been
reports of this before and as I recall the problem was the tool (I don't
recall what it was) could not handle unzipping 0-byte files.  Try using a
different uncompress/unzip tool.

Karen

--~--~-~--~~~---~--~~
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 "freezing" after a few minutes?

2009-08-19 Thread Graham Dumpleton



On Aug 20, 1:01 am, erikcw  wrote:
> Hi,
>
> I'm running Django through mod_wsgi and Apache (2.2.8) on Ubuntu 8.04.
>
> I've been running Django on this setup for about 6 months without any
> problems. Yesterday, I moved my database (postgres 8.3) to its own
> server, and my Django site started refusing to load (the browser
> spinner would just keep spinning).
>
> Pages will load when I first start apache, but after about 10 mintues,
> it just stops. Apache is still able to serve static files. Just
> nothing through Django.
>
> I've checked the apache error logs, and I don't see any entries that
> could be related. I'm not sure if this is aWSGI, Django, Apache, or
> Postgres issue?
>
> Any ideas?

Post your Apache configuration snippet for how you have set up
mod_wsgi. Sounds like you are using mod_wsgi daemon mode, but
confirmation would be nice, along with the options you are using for
WSGIDaemonProcess. Also indicate whether your Apache is running PHP
using mod_php and what MPM Apache is built for, prefork or worker.

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



Template Filters

2009-08-19 Thread WilsonOfCanada

Hellos,

I was wondering if there is a filter that can remove these '\' that
python added when strings are appended to a list or dictionary.  I
cannot use cut because I still need one of the '\'

ex.  C:\\moo

Code:

arrPlaces = []
intPoint =0

while (len(testline)):
testline = fileName.readline()
print testline
arrPlaces[intPoint].append(testline)
intPoint += 1

d["places"] = arrPlaces
return render_to_response('rentSearch.html', d)

> C:\moo
> C:\supermoo

the HTML using Django has:

{{ places|safe }} but returns ['C:\\moo', 'C:\\supermoo'].  I was
wondering of there is a filter for the template that would return ['C:
\moo', 'C:\supermoo'] instead.

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: Form upload passed to ftp method

2009-08-19 Thread Karen Tracey
On Wed, Aug 19, 2009 at 1:06 AM, Jonathan  wrote:

>
> I am trying to write a view that will take a file uploaded via form,
> pass it to an ftp method and save it on an ftp server.  However I am
> running into problems when with the file object that gets passed to
> the ftp method.
>
> This is my view:
>
> [snip]
> So when I run this, I get:
>
> Exception Value: coercing to Unicode: need string or buffer,
> InMemoryUploadedFile found
>
> Which leads me to believe that I need to modify the file object before
> I pass it to the ftp method.  Unfortunately, I am stuck.  Any pointers?


Post the full traceback, not just the error message, so that people who
might be able to help have a place to start looking for where the problem
lies.

Karen

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



ANN: Django 0.96.5 released

2009-08-19 Thread James Bennett

Due to an issue with a misapplied patch in the recent Django 0.96.4
security release, tonight the Django project has issued Django 0.96.5.

Full information is available here:

http://www.djangoproject.com/weblog/2009/aug/19/bugfix/

Please note that this will be the *final* release in the Django 0.96 series.


-- 
"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: Displaying username on every page

2009-08-19 Thread grahamu

If you use RequestContext(), you automatically get visibility to the
current user and their permissions. See
http://docs.djangoproject.com/en/dev/topics/auth/#authentication-data-in-templates.
My base templates use a block like this:

{% block user %}
{% if user.is_authenticated %}
User: {{ user.get_full_name }}{% if user.is_staff %}
[staff]{% endif %}
Log out
{% else %}
Log in or Sign up
{% endif %}
{% endblock user %}

Graham

On Aug 19, 4:27 pm, John Barham  wrote:
> Apologies in advance if this is a FAQ but I've searched the list and
> can't find a precise answer.
>
> I want to display the login status of the user at the top of every
> page.  If they were logged in, it should say something like "Logged is
> as  (Log Out)" and if they're not logged in it should show a
> link to the login page.
>
> I could of course pass in the username as a dictionary value for each
> page, but this quickly becomes tedious.  I also use render_to_response
> a lot and if I understand correctly it doesn't pass through the user
> info automatically, but will if you set the context_instance parameter
> to a RequestInstance.  Is there a way I can access the user info from
> any page without having to do the above?
>
>   John
--~--~-~--~~~---~--~~
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: Accent-insensitive queryset filter

2009-08-19 Thread Karen Tracey
On Wed, Aug 19, 2009 at 6:47 PM, A Melé  wrote:

>
> Is there any way to perform an accent insensitive match when you are
> filtering a queryset? I'm looking for something like iexact (http://
> docs.djangoproject.com/en/dev/ref/models/querysets/#iexact) but accent-
> insensitive. Is there any simple way to do it?
>

What database? MySQL's default collation does this, offhand I don't know how
others behave.

Karen

--~--~-~--~~~---~--~~
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: Displaying username on every page

2009-08-19 Thread Kenneth Gonsalves

On Thursday 20 Aug 2009 3:57:13 am John Barham wrote:
> I could of course pass in the username as a dictionary value for each
> page, but this quickly becomes tedious.  I also use render_to_response
> a lot and if I understand correctly it doesn't pass through the user
> info automatically, but will if you set the context_instance parameter
> to a RequestInstance.  Is there a way I can access the user info from
> any page without having to do the above?

use RequestContext - do not forget to add this in settings.py:

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',

You can then get the user as request.user in the template
-- 
regards
kg
http://lawgon.livejournal.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
-~--~~~~--~~--~--~---



Displaying username on every page

2009-08-19 Thread John Barham

Apologies in advance if this is a FAQ but I've searched the list and
can't find a precise answer.

I want to display the login status of the user at the top of every
page.  If they were logged in, it should say something like "Logged is
as  (Log Out)" and if they're not logged in it should show a
link to the login page.

I could of course pass in the username as a dictionary value for each
page, but this quickly becomes tedious.  I also use render_to_response
a lot and if I understand correctly it doesn't pass through the user
info automatically, but will if you set the context_instance parameter
to a RequestInstance.  Is there a way I can access the user info from
any page without having to do the above?

  John

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



Accent-insensitive queryset filter

2009-08-19 Thread A Melé

Is there any way to perform an accent insensitive match when you are
filtering a queryset? I'm looking for something like iexact (http://
docs.djangoproject.com/en/dev/ref/models/querysets/#iexact) but accent-
insensitive. Is there any simple way to do it?

Thank you!
--~--~-~--~~~---~--~~
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: Problem with Django/Jython and Postgres backend

2009-08-19 Thread fwierzbicki



On Aug 18, 10:54 am, Brandon Taylor  wrote:
> Hi everyone,
>
> I'm getting this exception with the latest Django-Jython and
> Jython2.5:
What version of Django are you using?  What where you doing at the
time that you get this error?

-Frank
--~--~-~--~~~---~--~~
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 ManyToMany field to django comments

2009-08-19 Thread grahamu

In general, I'm wondering how to retrieve a Queryset provided to a
Form (choices for a ManyToMany field) from within a view that only
accepts POST data from that form. This isn't really a question about
extending django.contrib.comments, but that framework provides a good
point of reference for the issue.

For example, suppose I wanted to add: "reviewers = models.ManyToMany
(User)" to the django.contrib.comment Comment model. This would be a
list of Users who are allowed to review the comment, specified by the
comment creator.

In order for this to work we need to provide a Queryset of Users when
creating the form. This can be accomplished with a template tag of the
form "{% get_comment_form for [object] with [reviewers] as [varname]
%}", where 'reviewers' is a Queryset passed in the template context.
This works fine.

However, when the form is posted, we don't have visibility (in the
post view) to the Queryset of possible reviewers. The post view, after
checking the validity of several other pieces of data, creates a new
comment form to check the validity of the received data. Of course the
form must have a Queryset for the 'reviewers' field, and this isn't
part of the request POST data.

Any ideas how one might either pass the queryset data to the view in
the form, or some other way to manage the form validation in this
situation?

Graham
--~--~-~--~~~---~--~~
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 do you remove a manytomany relationship in django?

2009-08-19 Thread Ray

Hi,
thanks for the fast response! I'm trying to use the remove function
right now just like this sample code:

# And from the other end
>>> p2.article_set.remove(a5)
>>> p2.article_set.all()
[]
>>> a5.publications.all()
[]

from http://www.djangoproject.com/documentation/models/many_to_many/

I'm doing "Group.objects.get(id=3).members.remove(member1)"

and getting this error: 'ManyRelatedManager' object has no attribute
'remove'

I also did help to find out what methods ManyRelatedManager had, and
indeed it didn't have a 'remove' method, only: clear, create,
get_or_create, and get_query_set

AND THEN,

I tried the remove function with the queryset object,
"Group.objects.get(id=3).members.all().remove(member1)"

and I got this error: 'QuerySet' object has no attribute 'remove'

I'm at a loss as to how I'm supposed to update these relationships

Ray

On Aug 18, 7:03 pm, Daniel Roseman  wrote:
> On Aug 18, 9:49 pm, Ray  wrote:
>
> > I know in the backend, a manytomany relationship is essentially a join
> > table, but there seems to be no easy way to delete relationships from
> > it. The only remove option is made only for ForeignKey relationships.
> > Is there a workaround? Why would django design a relationship that you
> > can only add but not delete?
>
> The wording in the documentation 
> here:http://docs.djangoproject.com/en/dev/ref/models/relations/
> is potentially confusing. The top of the page clearly states that the
> methods are available both for foreignkeys and many-to-many
> relationships. However, remove() and clear() state that they are "only
> available on ForeignKeys where null=True". I believe this should just
> read "for FKs, these methods are only available where null=True" - in
> other words, they are available as you would expect for ManyToMany.
> --
> 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
-~--~~~~--~~--~--~---



Re: How do you remove a manytomany relationship in django?

2009-08-19 Thread Daniel Roseman

On Aug 19, 10:09 pm, Ray  wrote:
> Hi,
> thanks for the fast response! I'm trying to use the remove function
> right now just like this sample code:
>
> # And from the other end>>> p2.article_set.remove(a5)
> >>> p2.article_set.all()
> []
> >>> a5.publications.all()
>
> []
>
> fromhttp://www.djangoproject.com/documentation/models/many_to_many/
>
> I'm doing "Group.objects.get(id=3).members.remove(member1)"
>
> and getting this error: 'ManyRelatedManager' object has no attribute
> 'remove'
>
> I also did help to find out what methods ManyRelatedManager had, and
> indeed it didn't have a 'remove' method, only: clear, create,
> get_or_create, and get_query_set
>
> AND THEN,
>
> I tried the remove function with the queryset object,
> "Group.objects.get(id=3).members.all().remove(member1)"
>
> and I got this error: 'QuerySet' object has no attribute 'remove'
>
> I'm at a loss as to how I'm supposed to update these relationships
>
> Ray

Well, that is weird. MayRelatedManager definitely *does* have an
attribute 'remove'. With these basic models:

class Category(models.Model):
title = models.CharField(_('title'), max_length=100)

class Post(models.Model):
title = models.CharField(_('title'), max_length=200)
categories = models.ManyToManyField(Category)


the following works fine:
>>> from blog.models import Post, Category
>>> p=Post.objects.create(title='dan')
>>> c=Category.objects.create(title='category')
>>> p.categories.all()
[]
>>> p.categories.add(c)
>>> p.categories.all()
[]
>>> p.categories.remove(c)
>>> p.categories.all()
[]

So it works for me, I can't imagine what is happening with your setup.
What version of Django are you using?
--
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
-~--~~~~--~~--~--~---



Re: PIL & imagefield validation

2009-08-19 Thread zayatzz

OK. Apparently this is not PIL problem.

I replaced validation errormessage with custom messages for debugging
and i found out that imagefield validation fails here :

try:
# load() is the only method that can spot a truncated
JPEG,
#  but it cannot be called sanely after verify()
trial_image = Image.open(file)
-->   trial_image.load()

If i comment that .load() line out i got IOerror:
IOError at /profile/edit/

decoder jpeg not available

So apparently, even though i reinstalled jpeg before installing PIL,
there is something wrong with jpeg module pathing and i have to remove
and reinstall that too.

Alan.

On Aug 19, 10:09 pm, zayatzz  wrote:
> I followed the instructions on that website.
>
> I used kfind to find all files/folders containing PIL. I removed
> PIL.pth files and PIL folders from several places. Then i tried
> importing PIL in python prompt and got the error. - no pil in the
> system.
>
> Then i reinstalled PIL. tested it and got the validation error message
> again. Then i deleted django, i deleted it under python2.6 site-
> packages, and dist packages, i deleted the unpacked folder also.
> decompressed the tar file, built and reinstalled it again. Still no
> changes.  So i  guess only thing to try is either troubleshoot the
> fields.py and find out why it gives the error and if it can or cannot
> import the pil, or reinstall ubuntu and start from clean system.
>
> Or do you have any other ideas?
>
> Alan.
>
> On Aug 19, 5:41 am, Malcolm MacKinnon  wrote:
>
> > For what it's worth, here's what helped me about a month ago. The PIL
> > installation process is a mess, and I had to follow these instructions, step
> > by step.
> > I think I've fixed the problem. It had to so with  PIL not being installed
> > correctly. Check out this 
> > link:http://www.answermysearches.com/fixing-pil-ioerror-decoder-jpeg-not-a...
> > for
> > a possible solution. Now, jpeg images are uploaded and saved.
>
> > On Mon, Aug 17, 2009 at 11:24 AM, zayatzz  wrote:
>
> > > Hello
>
> > > On sunday i had problems with python when i installed stackless
> > > python. Now i have compiled and installed :
> > > setuptools & python-mysqldb and i got my django project up and running
> > > again. (i also reinstalled django-1.1),
> > > Then i compiled and installed, jpeg, freetyp2 and PIL. I also started
> > > using mod_wsgi instead of mod_python.
>
> > > But when uploading imagefield in form i  get validationerror:
> > > Upload a valid image. The file you uploaded was either not an image or
> > > a corrupted image.
>
> > > Searchmonkey shows that it comes from field.py imagefield validation.
> > > before raising this error it imports Image from PIL, opens file and
> > > verfies it. I tried importing PIL from python prompt manually - it
> > > worked just fine. Same with Image.open and Image.verify.
>
> > > So what could by causing this problem?
>
> > > Alan
>
>
--~--~-~--~~~---~--~~
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: PIL & imagefield validation

2009-08-19 Thread zayatzz

I followed the instructions on that website.

I used kfind to find all files/folders containing PIL. I removed
PIL.pth files and PIL folders from several places. Then i tried
importing PIL in python prompt and got the error. - no pil in the
system.

Then i reinstalled PIL. tested it and got the validation error message
again. Then i deleted django, i deleted it under python2.6 site-
packages, and dist packages, i deleted the unpacked folder also.
decompressed the tar file, built and reinstalled it again. Still no
changes.  So i  guess only thing to try is either troubleshoot the
fields.py and find out why it gives the error and if it can or cannot
import the pil, or reinstall ubuntu and start from clean system.

Or do you have any other ideas?

Alan.

On Aug 19, 5:41 am, Malcolm MacKinnon  wrote:
> For what it's worth, here's what helped me about a month ago. The PIL
> installation process is a mess, and I had to follow these instructions, step
> by step.
> I think I've fixed the problem. It had to so with  PIL not being installed
> correctly. Check out this 
> link:http://www.answermysearches.com/fixing-pil-ioerror-decoder-jpeg-not-a...
> for
> a possible solution. Now, jpeg images are uploaded and saved.
>
> On Mon, Aug 17, 2009 at 11:24 AM, zayatzz  wrote:
>
> > Hello
>
> > On sunday i had problems with python when i installed stackless
> > python. Now i have compiled and installed :
> > setuptools & python-mysqldb and i got my django project up and running
> > again. (i also reinstalled django-1.1),
> > Then i compiled and installed, jpeg, freetyp2 and PIL. I also started
> > using mod_wsgi instead of mod_python.
>
> > But when uploading imagefield in form i  get validationerror:
> > Upload a valid image. The file you uploaded was either not an image or
> > a corrupted image.
>
> > Searchmonkey shows that it comes from field.py imagefield validation.
> > before raising this error it imports Image from PIL, opens file and
> > verfies it. I tried importing PIL from python prompt manually - it
> > worked just fine. Same with Image.open and Image.verify.
>
> > So what could by causing this problem?
>
> > Alan
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Function fields in admin change view?

2009-08-19 Thread deadguy

Hello,

Can you add fields whose values are generated by functions to the
admin change view like you can to the list view?  They would have to
be read only, of course, since there's no db column for them.  I'd
like them to be presented in the fieldset along with everything else.

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: custom authentication backend not being used...

2009-08-19 Thread Peter Herndon

On 08/19/2009 02:04 PM, Jay wrote:
> Sorry, nevermind.  I finally figured this out right after I posted
> this.
>
>
What was the solution?  Both for posterity, and because I'm personally 
curious.

Thanks,

---Peter

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



Google app engine patch translation : model_set.all doesnt work

2009-08-19 Thread justin jools

It seems google app engine patch doesnt support _set.all.  I have
tried my original django only version and it works but with google app
engine patch does not.

my template code:

 {% for model in object.product_model_set.all %}
{{ model.full_title }}
 {% endfor %}

I dont how / what to replace _set.all with, if I set it to model.all
it still does nothing.
Thanks...

here is my model:


class Product_Model(db.Model):
"""  Model Details """
type  = db.ReferenceProperty(Product_Make, required=True,
collection_name='make_set')
title = db.StringProperty(required=True)
slug  = db.StringProperty(required=True)
derivative= db.StringProperty(required=True)
released  = db.DateProperty(auto_now_add = 1)
picture   = db.BlobProperty(default=None)
review= db.TextProperty(required=True)
genre  = db.ReferenceProperty(Product_Type, required=True,
collection_name='genre_set')

def __unicode__(self):
return '%s' % (self.title)

class Meta:
ordering = ('title',)

@property
def full_title(self):
return '%s %s' % (self.title, self.type)


@permalink
def get_absolute_url(self):
return ('model_detail_url', None, { 'slug': self.slug })
--~--~-~--~~~---~--~~
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: custom authentication backend not being used...

2009-08-19 Thread Jay

Sorry, nevermind.  I finally figured this out right after I posted
this.

On Aug 19, 12:48 pm, Jay  wrote:
> First off, I'm using Django 1.1.
>
> I've been having problems getting my custom authentication backend to
> work, specifically in the "admin" site.
>
> I've been using this page as guide to put together an auth backend
> that uses my subclass of the User model to authenticate.
>
> http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-mod...
>
> I will post all code below, but for the moment here is the problem.
> I'm trying to log into the django admin site and I'm getting an
> exception on "check_password()" that shows me that the admin login
> system is using the User.check_password() rather than my subclass'
> check_password(). I'm working with an existing database here and I
> don't want to change my password hashing scheme if I don't have to.
> The thing that's driving me crazy is that the admin site doesn't seem
> to be using my User subclass.
>
> Is there something I'm forgetting/missing here?
>
> Thanks for any help anyone has to offer.
>
> Here is all relevant code (if there is something I'm forgetting, do
> let me know):
>
> settings.py
> --
>
> ...
> ...
> AUTHENTICATION_BACKENDS = (
>     'mf_pyweb.auth_backends.EmUserModelBackend' ,
> )
> CUSTOM_USER_MODEL = 'mfmain.EmUser'
>
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'django.contrib.admin',
>     'mf_pyweb.mfmain',
>     'mf_pyweb.mfadmin',
> )
>
> --
>
> auth_backends.py
> --
>
> from django.conf import settings
> from django.contrib.auth.backends import ModelBackend
> from django.core.exceptions import ImproperlyConfigured
> from django.db.models import get_model
>
> class EmUserModelBackend(ModelBackend):
>     def authenticate(self , username=None , password=None ,
> email=None):
>         try:
>             user = None
>             if email or '@' in username:
>                 user = self.user_class.objects.get(email=email)
>             elif username:
>                 user = self.user_class.objects.get(username=username)
>             else:
>                 return None
>             if user.check_password(password):
>                 return user
>         except:
>             return None
>
>     def get_user(self , user_id):
>         try:
>             return self.user_class.objects.get(pk=user_id)
>         except:
>             return None
>
>     def get_user(self , user_id):
>         try:
>             return self.user_class.objects.get(pk=user_id)
>         except:
>             return None
>
>     @property
>     def user_class(self):
>         if not hasattr(self , '_user_class'):
>             self._user_class = get_model(
>                     *settings.CUSTOM_USER_MODEL.split('.' , 2))
>             if not self._user_class:
>                 raise ImproperlyConfigured('Could not get custom user
> model')
>         return self._user_class
>
> --
>
> mfmain/models.py:
> --
>
> ...
> ...
> class EmUser(User):
>     domain = models.ForeignKey(Domain , db_index=True ,
> db_column='dom_id')
>     report_freq = models.PositiveIntegerField()
>     report_time = models.DateTimeField()
>     userdir = models.CharField(max_length=1024)
>
>     objects = UserManager()
>
>     def set_password(self , raw_pass):
>         self.password = getPHash(raw_pass)
>
>     def check_password(self , raw_pass):
>         salt , hash = self.password.split('$')
>         return (getPHash(raw_pass , salt , False) == hash)
>
>     def __str__(self):
>         return self.email
>
>     class Meta:
>         db_table = 'users'
>         ordering = ['email' , 'username' , 'date_joined']
>         verbose_name_plural = 'users'
> ...
> ...
> --
>
> --
> Jay Deiman
>
> \033:wq!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



custom authentication backend not being used...

2009-08-19 Thread Jay

First off, I'm using Django 1.1.

I've been having problems getting my custom authentication backend to
work, specifically in the "admin" site.

I've been using this page as guide to put together an auth backend
that uses my subclass of the User model to authenticate.

http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/

I will post all code below, but for the moment here is the problem.
I'm trying to log into the django admin site and I'm getting an
exception on "check_password()" that shows me that the admin login
system is using the User.check_password() rather than my subclass'
check_password(). I'm working with an existing database here and I
don't want to change my password hashing scheme if I don't have to.
The thing that's driving me crazy is that the admin site doesn't seem
to be using my User subclass.

Is there something I'm forgetting/missing here?

Thanks for any help anyone has to offer.

Here is all relevant code (if there is something I'm forgetting, do
let me know):

settings.py
--

...
...
AUTHENTICATION_BACKENDS = (
'mf_pyweb.auth_backends.EmUserModelBackend' ,
)
CUSTOM_USER_MODEL = 'mfmain.EmUser'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'mf_pyweb.mfmain',
'mf_pyweb.mfadmin',
)


--

auth_backends.py
--

from django.conf import settings
from django.contrib.auth.backends import ModelBackend
from django.core.exceptions import ImproperlyConfigured
from django.db.models import get_model

class EmUserModelBackend(ModelBackend):
def authenticate(self , username=None , password=None ,
email=None):
try:
user = None
if email or '@' in username:
user = self.user_class.objects.get(email=email)
elif username:
user = self.user_class.objects.get(username=username)
else:
return None
if user.check_password(password):
return user
except:
return None

def get_user(self , user_id):
try:
return self.user_class.objects.get(pk=user_id)
except:
return None

def get_user(self , user_id):
try:
return self.user_class.objects.get(pk=user_id)
except:
return None

@property
def user_class(self):
if not hasattr(self , '_user_class'):
self._user_class = get_model(
*settings.CUSTOM_USER_MODEL.split('.' , 2))
if not self._user_class:
raise ImproperlyConfigured('Could not get custom user
model')
return self._user_class


--

mfmain/models.py:
--

...
...
class EmUser(User):
domain = models.ForeignKey(Domain , db_index=True ,
db_column='dom_id')
report_freq = models.PositiveIntegerField()
report_time = models.DateTimeField()
userdir = models.CharField(max_length=1024)

objects = UserManager()

def set_password(self , raw_pass):
self.password = getPHash(raw_pass)

def check_password(self , raw_pass):
salt , hash = self.password.split('$')
return (getPHash(raw_pass , salt , False) == hash)

def __str__(self):
return self.email

class Meta:
db_table = 'users'
ordering = ['email' , 'username' , 'date_joined']
verbose_name_plural = 'users'
...
...
--


--
Jay Deiman

\033:wq!

--~--~-~--~~~---~--~~
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: save a form

2009-08-19 Thread Alex Gaynor

On Wed, Aug 19, 2009 at 11:22 AM, luca72 wrote:
>
> how i can get the value of the fields?
>
> On 19 Ago, 17:45, Daniel Roseman  wrote:
>> On Aug 19, 3:40 pm, luca72  wrote:
>>
>> > Iis but form.save don't work
>>
>> That's true.
>> --
>> DR.
> >
>

On a validated form the values will be in the dictionary form.cleaned_data

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Re: explanation of: {{ action.action_time|date:_("DATETIME_FORMAT") }}

2009-08-19 Thread Margie

Ah, thank you very much!  That makes more sense now.

Margie

On Aug 18, 4:30 pm, Ramiro Morales  wrote:
> On Tue, Aug 18, 2009 at 7:08 PM, Margie
>
> Roginski wrote:
>
> > I was trying to figure out how to run the date filter, using
> > SETTINGS.DATETIME_FORMAT as an argument.
>
> > When I grepped in the admin app I found this in object_history.html:
>
> > {{ action.action_time|date:_("DATETIME_FORMAT") }}
>
> > Can anyone give me a pointer as to how this works?  What is '_' in
> > this case, and where is it defined?  I see {% load il8n %}, but it is
> > very hard to grep for '_', can seem to see where it is being defined
> > there.
>
> Sure, the "DATETIME_FORMAT" literal is what we call a technical
> message: A clever idea to give translators a way to determine
> a few local-dependant info bits (usually date/time output formatting)
> using the same infrastructure and tools used for translations
> (hence the _()):
>
> http://docs.djangoproject.com/en/dev/topics/i18n/#id2
>
> (last item in the list).
>
> If I understand things correctly, if/when Marc's GSoC work on this
> front gets merged, in 1.2 this will be replaced by similar but
> more explicit ways to specify the same info.
>
> HTH
>
> --
> Ramiro Moraleshttp://rmorales.net
>
> PyCon 2009 Argentina - Vie 4 y Sab 5 Setiembre
> Buenos Aires, Argentinahttp://ar.pycon.org/2009/about/
--~--~-~--~~~---~--~~
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 "freezing" after a few minutes?

2009-08-19 Thread erikcw

Hi Thomas,

Thanks for the reply.

I have postgres max_connections=100, but when I run "select count(*)
from pg_stat_activity;" I only get 2.  So I would think that I'm not
maxing out the connections. (is that right -- I'm fairly new to
Postgres)

Here are the results from an strace:

# pgrep apache2
32555
32557
32561
32564
32565
32566
32568
32570
32600
32601
32630
32632
32633
r...@domu-12-31-39-03-3e-22:~# strace -p 32555
Process 32555 attached - interrupt to quit
select(0, NULL, NULL, NULL, {0, 48}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
waitpid(-1, 0xbf879bd8, WNOHANG|WSTOPPED) = 0
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)

Does any of this help?

Erik

On Aug 19, 8:09 am, Thomas Guettler  wrote:
> Just a first guess:
>
> How many wsgi-clients access the db server at the same time?
> Maybe the db does accept only N, while apache/wsgi tries it
> with N+1. Then the connection could hang.
>
> What do the wsgi processes do? You can use "strace -p WSGI-PID" to find
> this out.
>
> You can sent SIGINT (like ctrl-c) the the PID. In the stacktrace
> you can see where the python code was hanging (should be in apache
> error log).
>
>  HTH,
>    Thomas
>
> erikcw schrieb:
>
>
>
> > Hi,
>
> > I'm running Django through mod_wsgi and Apache (2.2.8) on Ubuntu 8.04.
>
> > I've been running Django on this setup for about 6 months without any
> > problems. Yesterday, I moved my database (postgres 8.3) to its own
> > server, and my Django site started refusing to load (the browser
> > spinner would just keep spinning).
>
> > Pages will load when I first start apache, but after about 10 mintues,
> > it just stops. Apache is still able to serve static files. Just
> > nothing through Django.
>
> > I've checked the apache error logs, and I don't see any entries that
> > could be related. I'm not sure if this is a WSGI, Django, Apache, or
> > Postgres issue?
>
> --
> 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: save a form

2009-08-19 Thread luca72

how i can get the value of the fields?

On 19 Ago, 17:45, Daniel Roseman  wrote:
> On Aug 19, 3:40 pm, luca72  wrote:
>
> > Iis but form.save don't work
>
> That's true.
> --
> 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
-~--~~~~--~~--~--~---



Re: Error in setting up psycopg2

2009-08-19 Thread Simon Lee

Hi Thomas,

Tried your method and modified /mysite3/apache/myapp.wsgi as followed:

import os, sys
sys.path.append('/Users/myname')
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django')
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/psycopg2')

try:
import psycopg2 as Database
except ImportError, exc:
import sys
raise ImportError('%s %s' % (exc, sys.path))

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite3.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()



Now the error log is as followed:

[Wed Aug 19 23:58:54 2009] [info] [client 127.0.0.1] mod_wsgi
(pid=135, process='', application='www.test-mysite.com|'): Reloading
WSGI script '/Users/myname/mysite3/apache/myapp.wsgi'.
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=135): Target WSGI script '/Users/myname/mysite3/apache/
myapp.wsgi' cannot be loaded as Python module.
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=135): Exception occurred processing WSGI script '/Users/myname/
mysite3/apache/myapp.wsgi'.
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1]   File "/Users/
myname/mysite3/apache/myapp.wsgi", line 10, in 
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] raise
ImportError('%s %s' % (exc, sys.path))
[Wed Aug 19 23:58:54 2009] [error] [client 127.0.0.1] ImportError:
cannot import name tz ['/Library/Frameworks/Python.framework/Versions/
2.6/lib/python26.zip', '/Library/Frameworks/Python.framework/Versions/
2.6/lib/python2.6', '/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/plat-darwin', '/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/plat-mac', '/Library/Frameworks/
Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-
scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/lib-tk', '/Library/Frameworks/Python.framework/Versions/
2.6/lib/python2.6/lib-old', '/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/lib-dynload', '/Library/Frameworks/
Python.framework/Versions/2.6/lib/python2.6/site-packages', '/Users/
myname', '/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django', '/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/site-packages/psycopg2']



Any idea? Please advise. Thanks.

Simon

On Aug 19, 10:44 pm, Thomas Guettler  wrote:
> Hi,
>
> you need to know what sys.path looks like. This is a list of
> searched directories.
>
> try:
>     import  # Import lines that failes
> except ImportError, exc:
>     import sys
>     raise ImportError('%s %s' % (exc, sys.path))
>
> Then check if the stuff you want to import is on sys.path.
>
> Simon Lee schrieb:
>
>
>
>
>
> > I am trying to set up a simple test website in the Apache Server that
> > comes with OSX 10.5.8 and continuously ran into errors that
> > complainted about not able to import something in pscycopg2. The site
> > works if I ran with the django development server. When I port to
> > Apache, it did not work. Can someone tell me what I am missing?
> > ...
> ...
> > The following error was logged in my error log file:
>
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] mod_wsgi
> > (pid=120): Exception occurred processing WSGI script '/Users/myname/
> > mysite3/apache/myapp.wsgi'.
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] Traceback (most
> > recent call last):
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> > myname/mysite3/django/core/handlers/wsgi.py", line 239, in __call__
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> > myname/mysite3/django/core/handlers/base.py", line 67, in get_response
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> > myname/mysite3/django/contrib/sessions/middleware.py", line 9, in
> > process_request
> > [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] ImportError: No
> > module named db
>
> Here you will find your ImportError and sys.path.
>
> --
> 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: Database design question

2009-08-19 Thread ringemup


Validation turns out to be well-nigh impossible using parent / child
aliases, but pretty easy with parent / child accounts.  Here's what
I've ended up with:

class Account(models.Model):
user = models.ForeignKey(User, unique=True, null=True, blank=True)
alias = models.CharField(max_length=32, unique=True)
parent_account = models.ForeignKey('self', related_name='children',
null=True, blank=True)

def __unicode__(self):
return '%s owned by %s' % (self.alias, self.get_owner())

def save(self, force_insert=False, force_update=False):
if not Account.is_valid_parent_or_child(self.user,
self.parent_account):
raise AccountInheritanceError
super(Account, self).save(force_insert, force_update)

def get_canonical_alias(self):
if self.is_child():
return self.parent_account.get_canonical_alias()
return self.alias

def get_owner(self):
if self.is_child():
return self.parent_account.get_owner()
return self.user

@staticmethod
def is_valid_parent_or_child(user, parent_account):
# We need either a user (meaning this is a primary account)
# or a parent (meaning this is a child account), but not both
if bool(user) == bool(parent_account):
return False
if parent_account.is_child():
return False
return True

def is_parent(self):
return bool(self.user)

def is_child(self):
return bool(self.parent_account)

I'll probably end up shunting any required account fields into a
Profile model and either a)attaching that to Account with a nullable
one-to-one relationship, and making that required for parent accounts;
or b) making the Profile model the AUTH_PROFILE_MODULE rather than
Account (which is currently).
--~--~-~--~~~---~--~~
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: Problem with "Cancel" button

2009-08-19 Thread David

Thanks Thomas for your reply. I just tested it with Firefox. "Cancel"
button works perfect.
With IE "Cancel" button has such a problem.

Let me do more test and see.


On Aug 19, 7:50 am, Thomas Guettler  wrote:
> Hi David,
>
> David schrieb:
>
> > Hello,
>
> > I have a "Cancel" button on one of my Webpages. The button sometimes
> > works as expected, sometimes it does not. After the button has been
> > clicked, it is supposed that the webpage is re-directed to another
> > page. However, this re-direction seems not work all the time.
> > Following is my script.
>
> When does it work and when not? Does it work in one browser always, and
> in a different browser never? Django does not do any random stuff.
> What happens if the redirect does not work?
>
>
>
> > In my urls.py:
>
> > 
> >  (r'^cancel/$', cancel),
> > .
>
> > In my view.py:
>
> > def save_view(request):
>
> >     if request.POST:
> >         action = request.POST['action']
>
> I stopped getting any values from request.POST or request.GET. I use
> the form library.
>
> >         if action == 'Cancel':
> >             url = '/cancel/'
> > #            this_url = reverse('cancel')
> > #            return HttpResponseRedirect(this_url)
> >             return HttpResponseRedirect(url)
>
> > And my "cancel" view is really simple. It is
>
> > def cancel(request):
> >         return render_to_response('cancel.html')
>
> I guess the error is in cancel.html. You need to post it here.
>
> HTH,
>   Thomas Güttler
>
> --
> 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: save a form

2009-08-19 Thread Daniel Roseman

On Aug 19, 3:40 pm, luca72  wrote:
> Iis but form.save don't work
>

That's true.
--
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
-~--~~~~--~~--~--~---



Re: That model works on doctests but...

2009-08-19 Thread Daniel Roseman

On Aug 19, 4:14 pm, Mirat Bayrak  wrote:
> http://dpaste.com/82737/< here is models.py , as you see i wrote
> doctests for every model and they are working well. But when i try to
> create GeneralProperties or AccomodationProperties from admin page,
> when i press save button it gives that error :http://dpaste.com/82736/
>
> Do you see what i am missing? Thank you a lot.

This has nothing to do with doctests. The __unicode__ function for
your GeneralProperties model is:

def __unicode__(self):
return "General Properties of", self.boat

As the error says, this is returning a tuple, not a unicode string.
You need to format this as you have done with all the other models.

By the way, none of your unicode methods are actually returning
unicode values, they are returning bytestrings. This *will* cause
failure as soon as you have a name that isn't ASCII - eg an accent.
You need to make sure that any literal string is prefixed by u to make
it work:
return u"General Properties of %s" % self.boat
--
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
-~--~~~~--~~--~--~---



Re: is Django a good choice for a LAN app?

2009-08-19 Thread snfctech

UPDATE

Looks like the Django multi-DB support didn't quite make it in yet:

http://groups.google.com/group/django-developers/browse_thread/thread/267a2fd7104f0209?hl=en

On another note, I came across the web2py project, which has multi-db
support built in - "table attributes are attributes of a database
connection."  That's what I'm talkin about!

I think the answer to this thread may be:

"Yes, Django is a good choice for a LAN app, but depending on your
specific needs (e.g. multi-db support), another framework may be
better."

I also found out that Django + Elixir may be an option for multi-db
support, so I may evaluate this as well if web2py falls short.

On Aug 13, 3:45 pm, snfctech  wrote:
> @Torsten: Grüß Gott!  Agreed, I'm sold that the web client/server
> model is the way to go for my project.
>
> @Jonas: Thanks for the tip!  I found the multi-db thread.  Looks like
> multi-db support is just around the corner, and I probably wont need
> it for a few months, so I think I'm going to give Django a go!
>
> Btw, I researched the Rails camp on this topic, and found multi-db
> support there to be equally lacking.  A couple folks said they came up
> with solutions (rails gems): connection_ninja and
> magic_multi_connections.  But these seemed like beta, individual, side-
> projects (not to mention that the Google group associated with the
> second project was infested with spam).
>
> Hopefully the multi-db support they are talking about in django-
> developers will be a more integral part of the Django core.
>
> On Aug 13, 5:57 am, Jonas Obrist  wrote:
>
> >  From what I read on django-developers, multi-db support is being
> > actively worked on.
>
> > roberto wrote:
> > > snfctech,
> > > As far as I know, Django doesn't have an option to set more than one
> > > database. If I am mistaken, please, let me know.
> > > I am not sure if there is any project to add this capability in the
> > > future tough.
> > > Maybe you should investigate a bit more in the site
> > > (djangoproject.com).
> > > Regards.
>
> > > On Aug 12, 4:31 pm, snfctech  wrote:
>
> > >> Thanks, Jonas.
>
> > >> And do you think Django's ORM will be able to handle my multiple DB
> > >> connections, with read/write fields from different DB producs/ servers
> > >> on the same view (most of which will hopefully be ODBC compliant, but
> > >> some might not)?
>
> > >> On Aug 12, 11:32 am, Jonas Obrist  wrote:
>
> > >>> In my opinion writing it in django/html/... is a lot easier and faster
> > >>> than doing it in a real python GUI tool. Also you have the networking in
> > >>> your LAN taken care of by the browser.
>
> > >>> snfctech wrote:
>
> >  One more question:  Any advantage to just using a Python GUI toolkit
> >  instead?
>
> >  On Aug 12, 9:18 am, snfctech  wrote:
>
> > > Thanks for all of the good feedback!
>
> > > At the very least I am enthusiastic about the health of this list! ;-)
>
> > > @Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
> > > sales/week).
>
> > > Sounds like the community feels Django is a good choice for my type of
> > > project.
>
> > > Thanks!
>
> > > On Aug 12, 5:18 am, Philippe Raoult  wrote:
>
> > >> I don't know what you mean by mid-sized but I deployed exactly what
> > >> you're describing in a 45-strong company. We have occasional browser
> > >> incompatibilities with ajax but overall django was very much the 
> > >> right
> > >> tool for the job. As a bonus the company's clients can now access a
> > >> restricted part of the application to monitor their files and 
> > >> dealings
> > >> over https. Employees can also log in from home over https without 
> > >> any
> > >> software/hardware prerequisite. We're also planning on adding some
> > >> smartphone friendly pages for specific tasks (billing when employees
> > >> are working offsite).
>
> > >> My app is around 25k lines of python+templates
>
> > >> Hope this helps you make your mind.
>
> > >> On Aug 11, 9:06 pm, snfctech  wrote:
>
> > >>> I'm about to start a fairly large project for a mid-sized business
> > >>> with a lot of integration with other systems (POS, accounting,
> > >>> website, inventory, purchasing, etc.) The purpose of the system is 
> > >>> to
> > >>> try to reduce current data siloing and give employees role-based
> > >>> access to the specific data entry and reports they need, as well as 
> > >>> to
> > >>> replace some manual and redundant business processes. The system 
> > >>> needs
> > >>> to be cross-platform (Windows/Linux), open source and is primarily 
> > >>> for
> > >>> LAN use.
>
> > >>> My experience is mostly PHP/web/app development, but I have 
> > >>> developed
> > 

Re: Database design question

2009-08-19 Thread ringemup


I'm not asking as a Django / foreign key thing.  I'm having a lot of
trouble referencing each model from the other's save method for
validation purposes, because there's always going to be one that's
declared after the other.


On Aug 19, 10:35 am, Joshua Russo  wrote:
> You can, it just creates headaches. At least one of the ForeignKeys needs to
> not be required (I believe that's the default anyway).
>
> On Wed, Aug 19, 2009 at 1:27 PM, ringemup  wrote:
>
> > Is having two classes that reference one another just simply something
> > that can't be done in Python?
>
> > On Aug 19, 4:36 am, Joshua Russo  wrote:
> > > On Tue, Aug 18, 2009 at 11:04 PM, ringemup  wrote:
>
> > > > Well, I'm trying to implement parent / child aliases, but I'm running
> > > > into problems with class declaration order because I need to reference
> > > > the Alias class from within the Account class as well as referencing
> > > > Account from Alias for validation purposes -- and not just in
> > > > ForeignKey declarations and such.
>
> > > > Since one will always have to be declared before the other, is there
> > > > any way to do this?
>
> > > What I would recommend is to drop the ForeignKey in the Account table.
> > You
> > > can always retrieve the set of Aliases for an Account based on the
> > > ForeignKey from Alias to Account. I believe that you will even be able to
> > > access Account.alias_set in your code, though if not you can always get
> > > Alias.objects.filter(Account_id=xx) and for the primary you will be able
> > to
> > > say either Account.alias_set.filter(parent__isnull=True)or
> > > Alias.objects.filter(Account_id=xx).filter(parent__isnull=True)
--~--~-~--~~~---~--~~
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: user profile problems

2009-08-19 Thread Justin

Figured it out.  Apparently when I did my intial test I did not have a
profile create for the user which was causing a different error.

the correct string was 'engine.UserProfile'

Justin

On Aug 19, 10:11 am, Justin  wrote:
> I am sure this is a newbie mistake but I can't seem to find exactly
> the right setting.  I have create a user profile class.  I am trying
> to attach into my django project via the AUTH_PROFILE_MODULE setting
> in the settings.py file.
>
> The error I get is as follows when I try to retrieve the profile>>> from 
> django.contrib.auth.models import User
> >>> from engine.models import *
> >>> user = User.objects.get(pk=1)
> >>> prof = user.get_profile()
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> models.py", line 285, in get_profile
>     self._profile_cache = model._default_manager.get
> (user__id__exact=self.id)
> AttributeError: 'NoneType' object has no attribute '_default_manager'
>
> My AUTH_PROFILE_MODULE = 'engine.UserProfile'
>
> Rough project layout
>
> /logi - site folder
> /logi/engine/models model folder
> /logi/engine/views views folder
>
> The userprofile exists within the /logi/engine/models folder in a file
> call models_file.py.  so the full path to my user profile class is /
> logi/engine/models/models_file.py
>
> I have tried several variations of the AUTH_PROFILE_MODULE string but
> none seems to work.
>  engine.UserProfile
>  models.UserProfile
>  logi.UserProfile
>
> User Class as defined
> class UserProfile(models.Model):
>
>         panel_id = models.IntegerField()
>         email = models.EmailField()
>         status = models.CharField(max_length=1)
>         user = models.ForeignKey(User, unique=True)
>
>         def __unicode__(self):
>                 return "%s - %s" % (self.panel_id, self.email)
>
>         class Meta:
>                 app_label = 'engine'
>
> Any help would be appreciated,
>   I am sure this is something simple.
>
> Thanks,
>   Justin
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



That model works on doctests but...

2009-08-19 Thread Mirat Bayrak

http://dpaste.com/82737/ < here is models.py , as you see i wrote
doctests for every model and they are working well. But when i try to
create GeneralProperties or AccomodationProperties from admin page,
when i press save button it gives that error :
http://dpaste.com/82736/

Do you see what i am missing? Thank you a lot.

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

2009-08-19 Thread Justin

I am sure this is a newbie mistake but I can't seem to find exactly
the right setting.  I have create a user profile class.  I am trying
to attach into my django project via the AUTH_PROFILE_MODULE setting
in the settings.py file.

The error I get is as follows when I try to retrieve the profile
>>> from django.contrib.auth.models import User
>>> from engine.models import *
>>> user = User.objects.get(pk=1)
>>> prof = user.get_profile()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
models.py", line 285, in get_profile
self._profile_cache = model._default_manager.get
(user__id__exact=self.id)
AttributeError: 'NoneType' object has no attribute '_default_manager'

My AUTH_PROFILE_MODULE = 'engine.UserProfile'

Rough project layout

/logi - site folder
/logi/engine/models model folder
/logi/engine/views views folder

The userprofile exists within the /logi/engine/models folder in a file
call models_file.py.  so the full path to my user profile class is /
logi/engine/models/models_file.py

I have tried several variations of the AUTH_PROFILE_MODULE string but
none seems to work.
 engine.UserProfile
 models.UserProfile
 logi.UserProfile

User Class as defined
class UserProfile(models.Model):

panel_id = models.IntegerField()
email = models.EmailField()
status = models.CharField(max_length=1)
user = models.ForeignKey(User, unique=True)

def __unicode__(self):
return "%s - %s" % (self.panel_id, self.email)

class Meta:
app_label = 'engine'

Any help would be appreciated,
  I am sure this is something simple.

Thanks,
  Justin

--~--~-~--~~~---~--~~
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 "freezing" after a few minutes?

2009-08-19 Thread Thomas Guettler

Just a first guess:

How many wsgi-clients access the db server at the same time?
Maybe the db does accept only N, while apache/wsgi tries it
with N+1. Then the connection could hang.

What do the wsgi processes do? You can use "strace -p WSGI-PID" to find
this out.

You can sent SIGINT (like ctrl-c) the the PID. In the stacktrace
you can see where the python code was hanging (should be in apache
error log).

 HTH,
   Thomas

erikcw schrieb:
> Hi,
> 
> I'm running Django through mod_wsgi and Apache (2.2.8) on Ubuntu 8.04.
> 
> I've been running Django on this setup for about 6 months without any
> problems. Yesterday, I moved my database (postgres 8.3) to its own
> server, and my Django site started refusing to load (the browser
> spinner would just keep spinning).
> 
> Pages will load when I first start apache, but after about 10 mintues,
> it just stops. Apache is still able to serve static files. Just
> nothing through Django.
> 
> I've checked the apache error logs, and I don't see any entries that
> could be related. I'm not sure if this is a WSGI, Django, Apache, or
> Postgres issue?

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



Django "freezing" after a few minutes?

2009-08-19 Thread erikcw

Hi,

I'm running Django through mod_wsgi and Apache (2.2.8) on Ubuntu 8.04.

I've been running Django on this setup for about 6 months without any
problems. Yesterday, I moved my database (postgres 8.3) to its own
server, and my Django site started refusing to load (the browser
spinner would just keep spinning).

Pages will load when I first start apache, but after about 10 mintues,
it just stops. Apache is still able to serve static files. Just
nothing through Django.

I've checked the apache error logs, and I don't see any entries that
could be related. I'm not sure if this is a WSGI, Django, Apache, or
Postgres issue?

Any ideas?

Thanks for your help!
Erik
--~--~-~--~~~---~--~~
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: Problem with Django/Jython and Postgres backend

2009-08-19 Thread Thomas Guettler

Hi Brandon,

I don't use Jython and not OSX, but if you look at the stacktrace
and at the source, you should see the error.


Brandon Taylor schrieb:
>   File "/Users/btaylor/jython2.5.0/Lib/site-packages/doj/backends/
> zxjdbc/postgresql/base.py", line 54, in __init__
> self.client = DatabaseClient()
> TypeError: __init__() takes exactly 2 arguments (1 given)

"1 given" is the implicit "self". This means your DatabaseClient wants
one argument, but in base.py none is given. Try to find the souce
of DatabaseClient.__init__(self, ...)

u...@host> find django/ -name '*.py'|xargs grep 'class DatabaseClient'
django/db/backends/postgresql/client.py:class 
DatabaseClient(BaseDatabaseClient):
... Mine just inherits from BaseDatabaseClient.



-- 
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: Check server type at runtime?

2009-08-19 Thread Thomas Guettler

Hi,

AFAIK there is no such variable in settings.py. It would be nice to have it.
In your company we use the variable STAGE.

ringemup schrieb:
> Is there any way to check at runtime whether Django is running on the
> development server?
> 
> Thanks!


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



Running test suite without CREATE permission.

2009-08-19 Thread J. Cliff Dyer

When running a test suite, django starts by creating a test database.  I
am trying to run it on a webfaction account, and I can create an extra
database through the site's control panel, but I can't give django
permission to create one.  Is there a way to get django to use a
pre-existing database for unittests?

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: Problem with "Cancel" button

2009-08-19 Thread Thomas Guettler

Hi David,

David schrieb:
> Hello,
> 
> I have a "Cancel" button on one of my Webpages. The button sometimes
> works as expected, sometimes it does not. After the button has been
> clicked, it is supposed that the webpage is re-directed to another
> page. However, this re-direction seems not work all the time.
> Following is my script.

When does it work and when not? Does it work in one browser always, and
in a different browser never? Django does not do any random stuff.
What happens if the redirect does not work?

> 
> In my urls.py:
> 
> 
>  (r'^cancel/$', cancel),
> .
> 
> In my view.py:
> 
> def save_view(request):
> 
> if request.POST:
> action = request.POST['action']

I stopped getting any values from request.POST or request.GET. I use
the form library.

> if action == 'Cancel':
> url = '/cancel/'
> #this_url = reverse('cancel')
> #return HttpResponseRedirect(this_url)
> return HttpResponseRedirect(url)
> 
> And my "cancel" view is really simple. It is
> 
> def cancel(request):
> return render_to_response('cancel.html')

I guess the error is in cancel.html. You need to post it here.

HTH,
  Thomas Güttler

-- 
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: Error in setting up psycopg2

2009-08-19 Thread Thomas Guettler

Hi,

you need to know what sys.path looks like. This is a list of
searched directories.

try:
import  # Import lines that failes
except ImportError, exc:
import sys
raise ImportError('%s %s' % (exc, sys.path))

Then check if the stuff you want to import is on sys.path.

Simon Lee schrieb:
> I am trying to set up a simple test website in the Apache Server that
> comes with OSX 10.5.8 and continuously ran into errors that
> complainted about not able to import something in pscycopg2. The site
> works if I ran with the django development server. When I port to
> Apache, it did not work. Can someone tell me what I am missing?
> ...
...
> The following error was logged in my error log file:
> 
> [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] mod_wsgi
> (pid=120): Exception occurred processing WSGI script '/Users/myname/
> mysite3/apache/myapp.wsgi'.
> [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] Traceback (most
> recent call last):
> [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> myname/mysite3/django/core/handlers/wsgi.py", line 239, in __call__
> [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> myname/mysite3/django/core/handlers/base.py", line 67, in get_response
> [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1]   File "/Users/
> myname/mysite3/django/contrib/sessions/middleware.py", line 9, in
> process_request
> [Wed Aug 19 11:00:26 2009] [error] [client 127.0.0.1] ImportError: No
> module named db

Here you will find your ImportError and sys.path.


-- 
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: save a form

2009-08-19 Thread luca72

Iis but form.save don't work

On 19 Ago, 16:23, Daniel Roseman  wrote:
> On Aug 19, 3:21 pm, luca72  wrote:
>
> > Hello i have a POST form (not modelform) how i can save the data in
> > the db, and if i need to change the data before the save how i can do?
>
> > Thanks
>
> If it's not a modelform, what does it mean to save it in the database?
> It's not associated with any model, by definition.
> --
> 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
-~--~~~~--~~--~--~---



Re: Database design question

2009-08-19 Thread Joshua Russo
You can, it just creates headaches. At least one of the ForeignKeys needs to
not be required (I believe that's the default anyway).

On Wed, Aug 19, 2009 at 1:27 PM, ringemup  wrote:

>
>
> Is having two classes that reference one another just simply something
> that can't be done in Python?
>
>
> On Aug 19, 4:36 am, Joshua Russo  wrote:
> > On Tue, Aug 18, 2009 at 11:04 PM, ringemup  wrote:
> >
> > > Well, I'm trying to implement parent / child aliases, but I'm running
> > > into problems with class declaration order because I need to reference
> > > the Alias class from within the Account class as well as referencing
> > > Account from Alias for validation purposes -- and not just in
> > > ForeignKey declarations and such.
> >
> > > Since one will always have to be declared before the other, is there
> > > any way to do this?
> >
> > What I would recommend is to drop the ForeignKey in the Account table.
> You
> > can always retrieve the set of Aliases for an Account based on the
> > ForeignKey from Alias to Account. I believe that you will even be able to
> > access Account.alias_set in your code, though if not you can always get
> > Alias.objects.filter(Account_id=xx) and for the primary you will be able
> to
> > say either Account.alias_set.filter(parent__isnull=True)or
> > Alias.objects.filter(Account_id=xx).filter(parent__isnull=True)
> >
>

--~--~-~--~~~---~--~~
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 model-specific exceptions like DoesNotExist?

2009-08-19 Thread Joshua Russo
In that case you can create an abstract model class and use that instead of
models.Model:
class MyModel(models.Model):
class Meta:
abstract = True

class DoesNotExist(Exception):
pass


On Wed, Aug 19, 2009 at 1:22 PM, Idan Gazit  wrote:

>
> Yes, and then I also need to import that class into every place that I
> want to use it, no?
>
> The benefit of making it part of the model is that any place I'm using
> it, I already have the exception handy:
>
> try:
># ... do some things
>m = MyModel(foo=bar, baz=bling)
>m.save()
> except MyModel.FrobNotAllowed:
># handle the exception...
>
> It's not a big deal but I figured that emulating the framework isn't a
> bad idea.
>
> On Aug 19, 5:03 pm, Joshua Russo  wrote:
> > All you really need is:
> >
> > class DoesNotExist(Exception):
> > pass
>
> >
>

--~--~-~--~~~---~--~~
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: Database design question

2009-08-19 Thread ringemup


Is having two classes that reference one another just simply something
that can't be done in Python? 


On Aug 19, 4:36 am, Joshua Russo  wrote:
> On Tue, Aug 18, 2009 at 11:04 PM, ringemup  wrote:
>
> > Well, I'm trying to implement parent / child aliases, but I'm running
> > into problems with class declaration order because I need to reference
> > the Alias class from within the Account class as well as referencing
> > Account from Alias for validation purposes -- and not just in
> > ForeignKey declarations and such.
>
> > Since one will always have to be declared before the other, is there
> > any way to do this?
>
> What I would recommend is to drop the ForeignKey in the Account table. You
> can always retrieve the set of Aliases for an Account based on the
> ForeignKey from Alias to Account. I believe that you will even be able to
> access Account.alias_set in your code, though if not you can always get
> Alias.objects.filter(Account_id=xx) and for the primary you will be able to
> say either Account.alias_set.filter(parent__isnull=True)or
> Alias.objects.filter(Account_id=xx).filter(parent__isnull=True)
--~--~-~--~~~---~--~~
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: save a form

2009-08-19 Thread Daniel Roseman

On Aug 19, 3:21 pm, luca72  wrote:
> Hello i have a POST form (not modelform) how i can save the data in
> the db, and if i need to change the data before the save how i can do?
>
> Thanks

If it's not a modelform, what does it mean to save it in the database?
It's not associated with any model, by definition.
--
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
-~--~~~~--~~--~--~---



Re: Adding model-specific exceptions like DoesNotExist?

2009-08-19 Thread Idan Gazit

Yes, and then I also need to import that class into every place that I
want to use it, no?

The benefit of making it part of the model is that any place I'm using
it, I already have the exception handy:

try:
# ... do some things
m = MyModel(foo=bar, baz=bling)
m.save()
except MyModel.FrobNotAllowed:
# handle the exception...

It's not a big deal but I figured that emulating the framework isn't a
bad idea.

On Aug 19, 5:03 pm, Joshua Russo  wrote:
> All you really need is:
>
> class DoesNotExist(Exception):
>     pass

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



save a form

2009-08-19 Thread luca72

Hello i have a POST form (not modelform) how i can save the data in
the db, and if i need to change the data before the save how i can do?

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



Subselect in query set .extra(tables=...)

2009-08-19 Thread Matt Hoskins

A couple of times I've wanted to be able to pass in a sub query as a
table in query_set.extra to be able join in some extra information but
have been thwarted as the query code always insists on quoting what
you pass in as tables to .extra (i.e. it assumes it's always table
names).

Back in 2005 with issue #967 someone put in some code to allow this,
but as part of qs-rf this was dropped (although the way it was decided
whether to quote something back then looks a bit clunky).

With postgres at least, if you pass in a subselect to the FROM it has
to have an alias, so if the tables argument to extra were to support
subselects it would need to allow something like "(SELECT foo FROM
blah) AS alias_of_subsel" being passed in.

I can't see how to pass in a subselect via .extra with Django 1.1 - if
anyone knows how to that would be useful. It seems unnecessarily
limiting for .extra not to allow subselects to be passed in where the
database engine supports it. A simple fix (although I don't know if it
has any bad consequences I can't think of) at least for postgres would
be if the backend's quote_name function didn't quote what's passed in
if it begins with "(" as subselects in the from in postgres always
have to be in parenthesis. I'm going to monkey patch
connection.opts.quote_name in my code for now to behave that 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
-~--~~~~--~~--~--~---



Re: Adding model-specific exceptions like DoesNotExist?

2009-08-19 Thread Joshua Russo
On Wed, Aug 19, 2009 at 12:56 PM, Idan Gazit  wrote:

>
> Hey all,
>
> I'd like to add some custom exception to a model of mine,
> Foo.FrobNotAllowed, along the lines of ModelName.DoesNotExist.
>
> From looking at models/base.py, it looks like the pattern is to
> override __new__() and use add_to_class. Something like:
>
> def __new__(cls, name, bases, attrs):
>new_class = super(MyModel, cls).__new__(cls, name, bases, attrs)
>abstract = getattr(attr_meta, 'abstract', False)
>if not abstract:
>new_class.add_to_class('FrobNotAllowed', MyExceptionClass)
>return new_class
>
> Is this the pattern I should be emulating for the kind of thing I'm
> seeking?


All you really need is:

class DoesNotExist(Exception):
pass

I generally create a Utils app in my project with a modelUtils.py where I
put things like that. Then you can just import the exception and use it in
any of your models.py files.

--~--~-~--~~~---~--~~
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 model-specific exceptions like DoesNotExist?

2009-08-19 Thread Idan Gazit

Hey all,

I'd like to add some custom exception to a model of mine,
Foo.FrobNotAllowed, along the lines of ModelName.DoesNotExist.

>From looking at models/base.py, it looks like the pattern is to
override __new__() and use add_to_class. Something like:

def __new__(cls, name, bases, attrs):
new_class = super(MyModel, cls).__new__(cls, name, bases, attrs)
abstract = getattr(attr_meta, 'abstract', False)
if not abstract:
new_class.add_to_class('FrobNotAllowed', MyExceptionClass)
return new_class

Is this the pattern I should be emulating for the kind of thing I'm
seeking?

-Idan
--~--~-~--~~~---~--~~
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: new session ID is created for every request from IE 7

2009-08-19 Thread Kelvan

Setting SESSION_ENGINE to 'django.contrib.sessions.backends.cached_db'
in Django 1.1 solved my problem.
Sorry for my "spam".

On Aug 19, 2:03 pm, Kelvan  wrote:
> Tested without apache on the server, seems to work.
> I think my problem has another reason.
>
> On Aug 19, 1:05 pm, Kelvan  wrote:
>
> > I have a similar problem with FF and Etch (with Django 1.0 and 1.1
> > tested).
> > Works when running on my notebook (Ubuntu 9.10a4 with Django 1.1).
> > I'm using Apache/mod_python.
>
> > On 13 Aug., 23:07, humble  wrote:
>
> > > Hi Malcolm
>
> > > Thanks for your suggestion. I did to try using a FQDN to configure IE
> > > for cookies. I am still seeing requests coming in from IE do not carry
> > > a cookie..
>
> > > What am I doing wrong?
>
> > > On Aug 12, 9:48 pm, Malcolm Tredinnick 
> > > wrote:
>
> > > > On Wed, 2009-08-12 at 19:21 -0700, humble wrote:
> > > > > Hi,
>
> > > > > I am writing a web application that involves session management with
> > > > > the corporate backend module. I wrote my own authentication backend
> > > > > plugin to satisfy the corporate requirement, not the default
> > > > > authentication backend. I use file based session engine to avoid
> > > > > sqlite crap. Everything works fine in firefox and chrome. But it seems
> > > > > to be a problem with IE: response includes a new session ID (actually
> > > > > a test cookie) for each request from IE. It seems IE never sends back
> > > > > the previous cookie given by the server in subsequent request. Check
> > > > > in /tmp/ (where I store all session files), I see the previous session
> > > > > file is replaced with a new empty session file.
>
> > > > > Looking in to contrib.session.middleware.py confirms
> > > > > "request.session.session_key" is different for each request. However,
> > > > > this only happens when I use IE.  I configured IE 7 to allow cookies,
> > > > > so it does not reject cookies from django. What might be the problem?
> > > > > Has any one seen this issue before?
>
> > > > I've seen it before when the domain being used for the cookie wasn't a
> > > > valid domain name. Browsers have blacklists of sets of domains that they
> > > > won't accept/send cookies for and they typically won't allow you to set
> > > > a cookie for .com, say.
>
> > > > That might be the problem in this case.
>
> > > > 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: new session ID is created for every request from IE 7

2009-08-19 Thread Maksymus007

On Thu, Aug 13, 2009 at 4:21 AM, humble wrote:
>
> Hi,
>
> I am writing a web application that involves session management with
> the corporate backend module. I wrote my own authentication backend
> plugin to satisfy the corporate requirement, not the default
> authentication backend. I use file based session engine to avoid
> sqlite crap. Everything works fine in firefox and chrome. But it seems
> to be a problem with IE: response includes a new session ID (actually
> a test cookie) for each request from IE. It seems IE never sends back
> the previous cookie given by the server in subsequent request. Check
> in /tmp/ (where I store all session files), I see the previous session
> file is replaced with a new empty session file.
>
> Looking in to contrib.session.middleware.py confirms
> "request.session.session_key" is different for each request. However,
> this only happens when I use IE.  I configured IE 7 to allow cookies,
> so it does not reject cookies from django. What might be the problem?
> Has any one seen this issue before?

IE requires your domain to have at least 2 parts - so you cannot set,
for example, cookie.domain like .application even such a domain is
valid in your network.

--~--~-~--~~~---~--~~
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: new session ID is created for every request from IE 7

2009-08-19 Thread Kelvan

Tested without apache on the server, seems to work.
I think my problem has another reason.

On Aug 19, 1:05 pm, Kelvan  wrote:
> I have a similar problem with FF and Etch (with Django 1.0 and 1.1
> tested).
> Works when running on my notebook (Ubuntu 9.10a4 with Django 1.1).
> I'm using Apache/mod_python.
>
> On 13 Aug., 23:07, humble  wrote:
>
> > Hi Malcolm
>
> > Thanks for your suggestion. I did to try using a FQDN to configure IE
> > for cookies. I am still seeing requests coming in from IE do not carry
> > a cookie..
>
> > What am I doing wrong?
>
> > On Aug 12, 9:48 pm, Malcolm Tredinnick 
> > wrote:
>
> > > On Wed, 2009-08-12 at 19:21 -0700, humble wrote:
> > > > Hi,
>
> > > > I am writing a web application that involves session management with
> > > > the corporate backend module. I wrote my own authentication backend
> > > > plugin to satisfy the corporate requirement, not the default
> > > > authentication backend. I use file based session engine to avoid
> > > > sqlite crap. Everything works fine in firefox and chrome. But it seems
> > > > to be a problem with IE: response includes a new session ID (actually
> > > > a test cookie) for each request from IE. It seems IE never sends back
> > > > the previous cookie given by the server in subsequent request. Check
> > > > in /tmp/ (where I store all session files), I see the previous session
> > > > file is replaced with a new empty session file.
>
> > > > Looking in to contrib.session.middleware.py confirms
> > > > "request.session.session_key" is different for each request. However,
> > > > this only happens when I use IE.  I configured IE 7 to allow cookies,
> > > > so it does not reject cookies from django. What might be the problem?
> > > > Has any one seen this issue before?
>
> > > I've seen it before when the domain being used for the cookie wasn't a
> > > valid domain name. Browsers have blacklists of sets of domains that they
> > > won't accept/send cookies for and they typically won't allow you to set
> > > a cookie for .com, say.
>
> > > That might be the problem in this case.
>
> > > 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: new session ID is created for every request from IE 7

2009-08-19 Thread Kelvan

I have a similar problem with FF and Etch (with Django 1.0 and 1.1
tested).
Works when running on my notebook (Ubuntu 9.10a4 with Django 1.1).
I'm using Apache/mod_python.

On 13 Aug., 23:07, humble  wrote:
> Hi Malcolm
>
> Thanks for your suggestion. I did to try using a FQDN to configure IE
> for cookies. I am still seeing requests coming in from IE do not carry
> a cookie..
>
> What am I doing wrong?
>
> On Aug 12, 9:48 pm, Malcolm Tredinnick 
> wrote:
>
> > On Wed, 2009-08-12 at 19:21 -0700, humble wrote:
> > > Hi,
>
> > > I am writing a web application that involves session management with
> > > the corporate backend module. I wrote my own authentication backend
> > > plugin to satisfy the corporate requirement, not the default
> > > authentication backend. I use file based session engine to avoid
> > > sqlite crap. Everything works fine in firefox and chrome. But it seems
> > > to be a problem with IE: response includes a new session ID (actually
> > > a test cookie) for each request from IE. It seems IE never sends back
> > > the previous cookie given by the server in subsequent request. Check
> > > in /tmp/ (where I store all session files), I see the previous session
> > > file is replaced with a new empty session file.
>
> > > Looking in to contrib.session.middleware.py confirms
> > > "request.session.session_key" is different for each request. However,
> > > this only happens when I use IE.  I configured IE 7 to allow cookies,
> > > so it does not reject cookies from django. What might be the problem?
> > > Has any one seen this issue before?
>
> > I've seen it before when the domain being used for the cookie wasn't a
> > valid domain name. Browsers have blacklists of sets of domains that they
> > won't accept/send cookies for and they typically won't allow you to set
> > a cookie for .com, say.
>
> > That might be the problem in this case.
>
> > 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: OT: Drawing lines in the browser

2009-08-19 Thread Thomas Guettler



Chris McCormick schrieb:
> On Tue, Aug 18, 2009 at 07:40:00AM -0700, Ian McDowall wrote:
>> On Aug 18, 8:53 am, Thomas Guettler  wrote:
>>> Hi,
>>>
>>> this is offtopic: How can you draw lines in a (django) web application?
>>>
>>> I think you need to use flash or java to do it. I googled for it, but found 
>>> only beta
>>> quality projects.
>>>
>>> Has anyone experience with this?
>> Depends on what type of line.  It is technically possible to use SVG.
>> You can embed an SVG image in HTML and then draw lines (or circles
>> etc.) in it. The SVG is just XMl and Django's templating works fine
>> for that.  There are some technical catches about the type of the
>> document and namespaces but I can provide a worked example. The
>> drawback is that not all browsers support SVG well. This appears to
>> work well in recent versions of Firefox but not well in IE.
> 
> Even better is the  element and it has good coverage on recent 
> browsers
> with the help of explorercanvas  for
> Internet Explorer, although the drawing must be done dynamically with
> javascript.   is an example of a library which
> uses the  element to draw graphs.

Thank you very much. I thought you can't do it with JS. I will try this.

  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: Database design question

2009-08-19 Thread Joshua Russo
On Tue, Aug 18, 2009 at 11:04 PM, ringemup  wrote:
>
> Well, I'm trying to implement parent / child aliases, but I'm running
> into problems with class declaration order because I need to reference
> the Alias class from within the Account class as well as referencing
> Account from Alias for validation purposes -- and not just in
> ForeignKey declarations and such.
>
> Since one will always have to be declared before the other, is there
> any way to do this?


What I would recommend is to drop the ForeignKey in the Account table. You
can always retrieve the set of Aliases for an Account based on the
ForeignKey from Alias to Account. I believe that you will even be able to
access Account.alias_set in your code, though if not you can always get
Alias.objects.filter(Account_id=xx) and for the primary you will be able to
say either Account.alias_set.filter(parent__isnull=True)or
Alias.objects.filter(Account_id=xx).filter(parent__isnull=True)

--~--~-~--~~~---~--~~
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 access ForeignKey models properties?

2009-08-19 Thread Marek Palatinus

On Wed, Aug 19, 2009 at 10:04 AM, Daniel Roseman wrote:
> photo_set = models.ForeignKey(PhotoSet, blank=True, null=True)

Are you sure you have set up data in database correctly? Your model
allow null value in photo_set, so maybe everything is working well and
you forgot to fill database... ;)

Marek

--~--~-~--~~~---~--~~
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 access ForeignKey models properties?

2009-08-19 Thread Daniel Roseman

On Aug 18, 10:48 pm, onoxo  wrote:
> this is my model.py:
>
> class Event(models.Model):
>     title = models.CharField('Event Name', max_length=300)
>     photo_set = models.ForeignKey(PhotoSet, blank=True, null=True)
>
> class PhotoSet(models.Model):
>     title = models.CharField(max_length=300)
>     slug = models.CharField(max_length=300)
>
> and this is my views.py
>
> def getProgrammAsXML(request):
>     entries = Event.objects.filter(start_time__year=2009)
>     for item in entries:
>         print item.title
>         print item.photo_set
>         # this one gets the error:
>         print item.photo_set.title
>
> i'm getting this error when i try to access item.photo_set.title.
> 'NoneType' object has no attribute 'title'
>
> when i try item.photo_set, then i get the name of that object so i
> think that reference to object is ok...
> what am i doing wrong here? or do i have to do that some other way?
>
> tnx,
> vedran

You will need to provide more information, such as the actual
traceback. I don't believe that the 'print item.photo_set' line can be
working if in the very next line you're getting an error which in
effect says that item.photo_set is None.

As an aside, I must say that you are very likely to get extremely
confused with your models and fields named the way they are. 'xxx_set'
is usually used in Django for the automatically-created reverse
relation on ForeignKeys - so in this case, the reverse relation from
PhotoSet to Event would be called event_set - and this is always a
queryset. Calling your actual FK 'photo_set' is bound to lead to
confusion.
--
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
-~--~~~~--~~--~--~---



Re: template syntax

2009-08-19 Thread Daniel Roseman

On Aug 19, 8:55 am, elminio  wrote:
> You don't understand me.
> WQhat I want to achieve is to use student.id as a key in dictionary
> (Im talking abous template)
> If I use:
>
> {% for student in students %}
>
> ... do sth ...
>
>  {{dictionary.student.id }} 
>
> {% endfor %}
>
> using dictionary.1 works using dictionary.student.id doesnt work
> because there is no such key like student in dictionary. What can I do
> to convert student.id to value and pass it like for example dictionary.
> (student.id)
>
> if in this iteration student.id = 5 then i want to have {{ dictionary.
> 5 }}
>
> thats all

As has been explained, you can't do this straight out of the box.
However it is trivially easy to write a custom template filter that
will do it.

@register.filter
def get(dictionary, key):
return dictionary.get(key)

Now you can do {{ dictionary.get:5 }}

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



Re: template syntax

2009-08-19 Thread elminio

You don't understand me.
WQhat I want to achieve is to use student.id as a key in dictionary
(Im talking abous template)
If I use:

{% for student in students %}

... do sth ...

 {{dictionary.student.id }} 

{% endfor %}

using dictionary.1 works using dictionary.student.id doesnt work
because there is no such key like student in dictionary. What can I do
to convert student.id to value and pass it like for example dictionary.
(student.id)

if in this iteration student.id = 5 then i want to have {{ dictionary.
5 }}

thats all



On Aug 18, 6:15 pm, mettwoch  wrote:
> See this:
>
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
>
> There's an example of iterating over key, value pairs
>
> Marc
>
> On Aug 18, 5:48 pm, elminio  wrote:
>
> > I iterate through all students and have distionary containing students
> > ids as key and for example grade as a value. I pass this dictionary to
> > the view and then while iterating through all students I though that
> > it would be simple to get appropriate value for current student. I
> > dont know how I could make it simplier in template :/ If You think so
> > maybe any ideas? but please with sample code
>
>
--~--~-~--~~~---~--~~
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: OK to put app_directories before filesystem template loader?

2009-08-19 Thread David Christiansen

Well, it doesn't seem to make much sense to me.  I use the default
order so that I can place files in a site-level templates directory in
order to override the default templates in the app directory without
having to directly open it up and modify its template files.

-David Christiansen

On Aug 18, 5:43 pm, ke1g  wrote:
> I find myself wanting to place the app_directories template loader
> before the filesystem template loader in
> settings.TEMPLATE_LOADERS, so that when I clone an app to, among other
> things, modifiy its templates, I get mine instead of the default.
>
> I'm wondering if anyone knows of reasons not to change the order?
>
> [I'm actually using pinax, but this seems like a general Django
> question.]
>
> Bill
--~--~-~--~~~---~--~~
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: Flatpages - what am I missing to make these work (advice, please)?

2009-08-19 Thread gegard

Thank you! That has resolved my problem.

The admin shell does not show the site id number by default, so I
supposed that removing the default 'example.com' and adding 'mysite'
would enable Django to reuse id 1. I should have assumed otherwise -
the new site was id == 2, of course. I should have edited
'example.com' rather than removing it.

Geoff

> ... my site.id was not 1 but 2 as I
> discovered with
> the shell...

--~--~-~--~~~---~--~~
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 access ForeignKey models properties?

2009-08-19 Thread onoxo

someone?
i need this today...
tnx!

On Aug 18, 11:48 pm, onoxo  wrote:
> this is my model.py:
>
> class Event(models.Model):
>     title = models.CharField('Event Name', max_length=300)
>     photo_set = models.ForeignKey(PhotoSet, blank=True, null=True)
>
> class PhotoSet(models.Model):
>     title = models.CharField(max_length=300)
>     slug = models.CharField(max_length=300)
>
> and this is my views.py
>
> def getProgrammAsXML(request):
>     entries = Event.objects.filter(start_time__year=2009)
>     for item in entries:
>         print item.title
>         print item.photo_set
>         # this one gets the error:
>         print item.photo_set.title
>
> i'm getting this error when i try to access item.photo_set.title.
> 'NoneType' object has no attribute 'title'
>
> when i try item.photo_set, then i get the name of that object so i
> think that reference to object is ok...
> what am i doing wrong here? or do i have to do that some other way?
>
> tnx,
> vedran
--~--~-~--~~~---~--~~
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: Using custom table instead of "user" in django

2009-08-19 Thread Marek Wawrzyczek

How about writting adapter to the django user class? It can have
descriptor for login (getting login would return users email). While
creating such user login would be set (only once, during creation) for
example the following value: user id converted to string preceded by
one character. For other custom fields there can be also descriptors,
but they would reffer to yours customer model (for example adapters
field homepage which would be descriptor would reffer to
customer.homepage).

Regards,
Marek

On 17 Sie, 19:05, Joshua Partogi  wrote:
> On Mon, Aug 17, 2009 at 10:40 PM, Jonas Obrist  wrote:
>
> > Here's what I did:
>
> > I took the built in auth system and changed it a bit, or to be more
> > precise I changed all imports within auth (because I moved it within the
> > pythonpath) and edited models.py:
>
> >http://dpaste.com/81651/
>
> > Whole code:
>
> >http://www.ojii.ch/auth.tar.gz
>
> > If you wanna use it:
>
> > Add the folder in the archive to your pythonpath.
>
> > Add 'auth' to your installed applications
>
> > Set 'USER_MODEL' in your settings file to the model you use (string).
>
> Is it better to re-write the user model or to extend it? Any insights?
>
> Thanks in advance
>
> --http://blog.scrum8.comhttp://twitter.com/scrum8
--~--~-~--~~~---~--~~
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: Using custom table instead of "user" in django

2009-08-19 Thread marekw2143

How about writting adapter to the django user class? It can have
descriptor for login (getting login would return users email). While
creating such user login would be set (only once, during creation) for
example the following value: user id converted to string preceded by
one character. For other custom fields there can be also descriptors,
but they would reffer to yours customer model (for example adapters
field homepage which would be descriptor would reffer to
customer.homepage).

Regards,
Marek

On 17 Sie, 19:05, Joshua Partogi  wrote:
> On Mon, Aug 17, 2009 at 10:40 PM, Jonas Obrist  wrote:
>
> > Here's what I did:
>
> > I took the built in auth system and changed it a bit, or to be more
> > precise I changed all imports within auth (because I moved it within the
> > pythonpath) and edited models.py:
>
> >http://dpaste.com/81651/
>
> > Whole code:
>
> >http://www.ojii.ch/auth.tar.gz
>
> > If you wanna use it:
>
> > Add the folder in the archive to your pythonpath.
>
> > Add 'auth' to your installed applications
>
> > Set 'USER_MODEL' in your settings file to the model you use (string).
>
> Is it better to re-write the user model or to extend it? Any insights?
>
> Thanks in advance
>
> --http://blog.scrum8.comhttp://twitter.com/scrum8
--~--~-~--~~~---~--~~
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: Using custom table instead of "user" in django

2009-08-19 Thread marekw2143

How about writting adapter to the django user class? It can have
descriptor for login (getting login would return users email). While
creating such user login would be set (only once, during creation) for
example the following value: user id converted to string preceded by
one character. For other custom fields there can be also descriptors,
but they would reffer to yours customer model (for example adapters
field homepage which would be descriptor would reffer to
customer.homepage).

Regards,
Marek

On 17 Sie, 19:05, Joshua Partogi  wrote:
> On Mon, Aug 17, 2009 at 10:40 PM, Jonas Obrist  wrote:
>
> > Here's what I did:
>
> > I took the built in auth system and changed it a bit, or to be more
> > precise I changed all imports within auth (because I moved it within the
> > pythonpath) and edited models.py:
>
> >http://dpaste.com/81651/
>
> > Whole code:
>
> >http://www.ojii.ch/auth.tar.gz
>
> > If you wanna use it:
>
> > Add the folder in the archive to your pythonpath.
>
> > Add 'auth' to your installed applications
>
> > Set 'USER_MODEL' in your settings file to the model you use (string).
>
> Is it better to re-write the user model or to extend it? Any insights?
>
> Thanks in advance
>
> --http://blog.scrum8.comhttp://twitter.com/scrum8
--~--~-~--~~~---~--~~
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 model attribs and property()

2009-08-19 Thread Tracy Reed
I have been looking into Django since February and not done much with
it in recent months. But the past few days for some reason everything
just clicked and I have cranked out a ton of cool functionality rather
painlessly. I'm loving Django so far! I have just completed my first
real world django project. Thanks Django team!

My project has room for improvement: I just have realized that one of
the attributes on one of my models depends on other outside factors
for its value such that it becomes outdated after being set. I have
very nearly a million instances of this object in the database. So I
can't just update all million of them when something changes.

It should be possible to somehow wrap accesses to this attribute,
recalculate, and return the correct updated value. But I understand
that property() won't work with model attributes and even if they did
I would have to rename the attribute in the model which would not make
the ORM happy.

Also, I notice that the only place I really access this attribute is:

queryset.filter(Status='Good', received__range=(hourago, now)).order_by('Score')

Plus, I'm not sure how the ORM and Python count this as an access to
"Score" (the value I want to recalc/update on the fly) due to the way
it is apparently passed to the ORM as a string.

Suggestions? Thanks!

-- 
Tracy Reed
http://tracyreed.org


pgp8BYTf6ogbc.pgp
Description: PGP signature


Re: Raw Strings with Variables

2009-08-19 Thread Matthias Kestenholz

On Wed, Aug 19, 2009 at 2:51 AM, WilsonOfCanada wrote:
>
> However, when I send the list over as a dictionary for HTML:
>
> d["places"] = arrPlaces
>
> return render_to_response('rentSearch.html', d)
>
> the HTML using Django has:
>
> {{ places }} but returns ['C:\\moo', 'C:\\supermoo']
>

And what's unexpected about that exactly?

--~--~-~--~~~---~--~~
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: Problem installing Django 1.1 on XP

2009-08-19 Thread Nikola Smiljanić

Django-1.1.tar.gz
MD5: b2d75b4457a39c405fa2b36bf826bf6b

Same thing. File __init__ in django/utils starts exactly like
traceback says:

Django-1.1/Django was originally created in late 2003 at World Online,
the Web division
of the Lawrence Journal-World newspaper in Lawrence, Kansas.
--~--~-~--~~~---~--~~
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: Using custom table instead of "user" in django

2009-08-19 Thread marekw2143

How about writting adapter to the django user class? It can have
descriptor for login (getting login would return users email). While
creating such user login would be set (only once, during creation) for
example the following value: user id converted to string preceded by
one character. For other custom fields there can be also descriptors,
but they would reffer to yours customer model (for example adapters
field homepage which would be descriptor would reffer to
customer.homepage).

Regards,
Marek



On 17 Sie, 19:05, Joshua Partogi  wrote:
> On Mon, Aug 17, 2009 at 10:40 PM, Jonas Obrist  wrote:
>
> > Here's what I did:
>
> > I took the built in auth system and changed it a bit, or to be more
> > precise I changed all imports within auth (because I moved it within the
> > pythonpath) and edited models.py:
>
> >http://dpaste.com/81651/
>
> > Whole code:
>
> >http://www.ojii.ch/auth.tar.gz
>
> > If you wanna use it:
>
> > Add the folder in the archive to your pythonpath.
>
> > Add 'auth' to your installed applications
>
> > Set 'USER_MODEL' in your settings file to the model you use (string).
>
> Is it better to re-write the user model or to extend it? Any insights?
>
> Thanks in advance
>
> --http://blog.scrum8.comhttp://twitter.com/scrum8
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---