Re: form instance to update an object

2009-06-15 Thread Daniel Roseman

On Jun 15, 4:23 pm, Genis Pujol Hamelink 
wrote:
> yes, but what if it's a new object and not an existing one? How do I test
> this? The request method will be POST, so form will be form =
> MyForm(request.POST)... so if form.pk exists in the db how do I tell it's
> editing an existing object?
>
> if request.method == 'POST':
>      form = myform(request.POST)
>      try:
>        instance = myobj.objects.get(id=form.id)
>        form = myform(request.POST, instance=instance)
>        if form.is_valid():
>          form.save()
>        else:
>           whatever goes here
>      except:
>        form = myform(request.POST)
>         if form.is_valid():
>          form.save()
>        else:
>           whatever goes here
>
> Something like this or do u know a better way?
>

I don't really understand how a newly-entered item can exist in the
database already. At the very least, saving the new item would give it
a new PK, so it wouldn't be a duplicate, surely.
--
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: ModelForm, foreignkey, and hidden fields is null

2009-06-15 Thread Daniel Roseman

On Jun 16, 1:12 am, k-dj  wrote:
> I'm just starting to use django and have run into a problem I have not
> been able to solve.
>
> I have a model Item which stores, among other things, user_id.
> Then I have a ModelForm. I want user_id to be a hidden field. After
> searching around the web, I found out how to create a hidden field.
> The template is rendered as I like it.
> user_id is a hidden field with a value of 1. The problem is when I
> submit the form, I get IntegrityError. "Column 'user_id' cannot be
> null".
>
> but from the debug message I get back I can see that POST has all 3
> things I need. So maybe when a new form is created there is problem.
>
> views.py
> @login_required
> def newItem(request):
>         if not request.POST:
>                 form = ItemForm()
>                 return 
> render_to_response('manager/newItem.html',{'form':form})
>         newForm = ItemForm(request.POST)
>         if newForm.is_valid():
>                 newForm.save() #problem here?
>                 return HttpResponsePermanentRedirect('.')
>
> models.py
> class Item(models.Model):
>         user = models.ForeignKey(User)
>         name = models.CharField(max_length=32)
>         description = models.CharField(max_length=128)
>         creation_date = models.DateField(auto_now=True)
>
> forms.py
> class ItemForm(ModelForm):
>     user_id_wid = forms.HiddenInput(attrs={'value': 1})
>     user_id = forms.IntegerField(widget=user_id_wid,required=False)
>     class Meta:
>         model = Item
>         fields = ['name', 'description']


You can't set 'value' as an argument to attrs.

If you want to preset the value of a field, pass in an 'initial'
dictionary on form instatiation:
form = MyForm(initial={'user_id':1})

However a much better way is not to have the user_id field in the form
at all, and set the correct value on the object on save.

class itemForm(ModelForm):

class Meta:
 model = Item
 exclude = ('user',)

and in the view:
if newForm.is_valid():
item = newForm.save(commit=False)
item.user_id = 1
item.save()

--
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: Sometimes datetime sometimes date?

2009-06-15 Thread Daniel Roseman

On Jun 16, 3:34 am, Streamweaver  wrote:
> sqlite3
>
> I changed the method and it seems to be working now.
>
> The code I'm using is:
>
> def all_last_updated(self):
>         d = [self.last_updated, self.activity_set.latest
> ().last_updated]
>         d.sort()
>         d.reverse()
>         return d[0]
>
> There seemed to be some problem when chaining sort().reverse() before.
>
> Not sure I understand it still and attributing it to me missing
> something in general but it's working now.

The problem is that sort() doesn't return anything, it sorts in-place.
So you can't chain it, as reverse() acts on the return value of the
previous function, which is None.

Although I can't understand why you got the error you did, I would
expect the error 'NoneType' object has no attribute 'reverse'.
--
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
-~--~~~~--~~--~--~---



Django gives little information about custom raised exceptions

2009-06-15 Thread Nick Fishman
Hey everyone,

I'm writing a project that does some communication with proprietary devices
on a non-standard protocol, so I've written a custom exception class that
extends Exception and has some additional useful parameters. However, when I
raise an exception instantiated from my class, the pretty Django error page
doesn't report any of the parameters. It's probably a stupid mistake I've
made, but I can't figure it out.

Here's a snippet of my custom exception class (with additional, similar code
removed for the sake of clarity):

class ConnectionError(Exception):
CONNECTION_REFUSED = 1
INVALID_DATA = 2

def __init__(self, type, buffer_name, *args, **kwargs):
self.type = type
self.buffer_name = buffer_name
self.args = args

def __str__(self):
if self.type == ConnectionError.CONNECTION_REFUSED:
return 'Connection refused for %s' % self.buffer_name
elif self.type == ConnectionError.INVALID_DATA:
# The first arg in self.args is the string we got back from the
device
return 'Invalid data received for %s: "%s"' % (self.buffer_name,
self.args[0])
else:
return "Unknown connection error"

In a view, if I try
raise ConnectionError(ConnectionError.CONNECTION_REFUSED, "mainbuf")
then the pretty Django error page just says
ConnectionError at /page/
Request Method: GET
without any specifics. Ideally, I'd like to see the custom "Connection
refused for %s" string that I wrote.

At the same time, if I try
raise ConnectionError(ConnectionError.INVALID_DATA, "mainbuf",
"BADDATA")
then the Django error page says
ConnectionError at /page/
BADDATA
Request Method: GET

In the second case, Django catches the last argument, but not the first. But
in both cases, it doesn't read my custom string message.

Is there any way to display custom error strings, or am I doing something
completely wrong?

Thanks a ton!

Nick

--~--~-~--~~~---~--~~
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: querystring redirect

2009-06-15 Thread Rama Vadakattu

This can be done with javascript as follows  :

1) View/middleware (depends on your needs)  detects the  redirection
url
2) put down the redirection url in the context and redirect to
template say abc.html
3) in abc.html
 a) put the message "your are leaving our site"
 b) write javascript which just triggers the redirect after some
particular amount of time (like say 10sec,20 sec depending on your
needs) using "setTimeOut
method"

i don't know whether we can able to achieve this using only django.


On Jun 16, 1:56 am, Bobby Roberts  wrote:
> hi all... is it possible to do the following?
>
> let's say the user types in the following url into their browser:
>
> mysite.com/redirect/?http://www.newsiteout.com/whatever.asp
>
> Is it possible to snag the redirect url after the ? in the url and
> then use it to do a redirect?  I've run into a situation where a
> client has a need for an interim ("you're leaving our site") type page
> before doing a redirect.  I'm trying to make this as easy as possible
> for the client.
>
> is this possible?  I'm reading the response docs but i'm not really
> finding a good example.
--~--~-~--~~~---~--~~
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 preset a value to a field on a ModelForm

2009-06-15 Thread Rama Vadakattu

else:
form = FooForm()
foo.date = request.session['date']# we
know request.session  ['date'] has a value
form = FooForm(instance=foo)
...

You don't need this line==> foo=form.save(commit=False)


On Jun 16, 3:46 am, adelaide_mike  wrote:
> Hi
> Newbie trying to preset a field on a form where the object is to be
> inserted.  The snippet below does not do it.
>
> class FooForm(ModelForm):
>     class Meta:
>         model = Foo
>
> 
>     if request.method == 'GET':
>                 if foo_id > '0':
>                         foo=Foo.objects.get(pk=foo_id)
>                         form = FooForm(instance=foo)            # this part 
> works OK
>                 else:
>                         form = FooForm()
>                         foo=form.save(commit=False)
>                         foo.date = request.session['date']        # we know 
> request.session
> ['date'] has a value
>                         form = FooForm(instance=foo)
>
> What is a better way?  TIA
>
> Mike
--~--~-~--~~~---~--~~
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: Sometimes datetime sometimes date?

2009-06-15 Thread Streamweaver

sqlite3

I changed the method and it seems to be working now.

The code I'm using is:

def all_last_updated(self):
d = [self.last_updated, self.activity_set.latest
().last_updated]
d.sort()
d.reverse()
return d[0]

There seemed to be some problem when chaining sort().reverse() before.

Not sure I understand it still and attributing it to me missing
something in general but it's working now.

On Jun 15, 10:08 pm, Ramiro Morales  wrote:
> On Mon, Jun 15, 2009 at 10:34 PM, Streamweaver wrote:
>
> > I ran into what I think might be a bug and wanted to check here before
> > possibly posting it.
>
> > Essentially what seems to be happening is that Django seems to return
> > datetime.datetime or datetime.date from DateFields in models and I
> > can't figure out why it returns one type at one time and another type
> > at another.
>
> What database are you using?
>
> --
> Ramiro Moraleshttp://rmorales.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: AttributeError when implementing Django Tutorial

2009-06-15 Thread Alex Gaynor
On Mon, Jun 15, 2009 at 8:34 PM, ebbnormal  wrote:

>
> Hello,
>
> I have been following along the Django tutorial, and as I was editing
> the urlpatterns in my urls module, i got the following error
> when I tried to run the mysite server:
>
>AttributeError at /
>'AdminSite' object has no attribute 'urls'
>Request Method: GET
>Request URL:http://127.0.0.1:8000/
>Exception Type: AttributeError
>
>
> the line that error references is in my urls.py file, line 13:
>
> >>>from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>   # (r'^mysite/', include('mysite.foo.urls')),
>  (r'^polls/$', 'mysite.polls.views.index'),
>  (r'^polls/(?P\d+)/$',
> 'mysite.polls.views.detail'),
>  (r'^polls/(?P\d+)/results/$',
> 'mysite.polls.views.results'),
>  (r'^polls/(?P\d+)/vote/$',
> 'mysite.polls.views.vote'),
>  (r'^admin/', include(admin.site.urls)),   #FIXME: this
> is the error.
> )
>
>
> however, line13 is exactly as written in part 3 of the official Django
> tutorial.
>
> Any suggestions?
>
> Thanks
>
> Ryan.
>
> >
>
The problem is you are folloiwng the tutorial for the latest development
version of Django, but you are using Django 1.0.  Follow the tutorial here:
http://docs.djangoproject.com/en/1.0/ instead.

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

--~--~-~--~~~---~--~~
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: Sometimes datetime sometimes date?

2009-06-15 Thread Ramiro Morales

On Mon, Jun 15, 2009 at 10:34 PM, Streamweaver wrote:
>
> I ran into what I think might be a bug and wanted to check here before
> possibly posting it.
>
> Essentially what seems to be happening is that Django seems to return
> datetime.datetime or datetime.date from DateFields in models and I
> can't figure out why it returns one type at one time and another type
> at another.

What database are you using?

-- 
Ramiro Morales
http://rmorales.net

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



AttributeError when implementing Django Tutorial

2009-06-15 Thread ebbnormal

Hello,

I have been following along the Django tutorial, and as I was editing
the urlpatterns in my urls module, i got the following error
when I tried to run the mysite server:

AttributeError at /
'AdminSite' object has no attribute 'urls'
Request Method: GET
Request URL:http://127.0.0.1:8000/
Exception Type: AttributeError


the line that error references is in my urls.py file, line 13:

>>>from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
  # (r'^mysite/', include('mysite.foo.urls')),
  (r'^polls/$', 'mysite.polls.views.index'),
  (r'^polls/(?P\d+)/$',
'mysite.polls.views.detail'),
  (r'^polls/(?P\d+)/results/$',
'mysite.polls.views.results'),
  (r'^polls/(?P\d+)/vote/$',
'mysite.polls.views.vote'),
  (r'^admin/', include(admin.site.urls)),   #FIXME: this
is the error.
)


however, line13 is exactly as written in part 3 of the official Django
tutorial.

Any suggestions?

Thanks

Ryan.

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



Sometimes datetime sometimes date?

2009-06-15 Thread Streamweaver

I ran into what I think might be a bug and wanted to check here before
possibly posting it.

Essentially what seems to be happening is that Django seems to return
datetime.datetime or datetime.date from DateFields in models and I
can't figure out why it returns one type at one time and another type
at another.

I have two models and the parent has a method that is suppose to
compare it's latest update date and the date of the latest child
update and return whichever date is more rescent.  However when I try
to unit test the Release.all_last_update method I get the following
error:

"TypeError: can't compare datetime.datetime to datetime.date"

But all values are being pulled from a DateField.  Is Django casting
it incorrectly or am I missing something somewhere?

Models are below.

class Release(models.Model):
created_on = models.DateField(auto_now=False, auto_now_add=True)
last_updated = models.DateField(auto_now=True, auto_now_add=True)

def all_last_updated(self):
d = []
d.append(self.last_updated)
d.append(Activity.objects.filter(release_fk=self).latest
().last_updated)
d.sort().reverse()
return d[0]

class Meta:
get_latest_by = 'last_updated'
ordering = ["project_fk", "internal_priority"]

class Activity(models.Model):
created_on = models.DateField(auto_now=False, auto_now_add=True)
last_updated = models.DateField(auto_now=True, auto_now_add=True)

def all_last_updated(self):
  return self.last_updated

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



ModelForm, foreignkey, and hidden fields is null

2009-06-15 Thread k-dj

I'm just starting to use django and have run into a problem I have not
been able to solve.

I have a model Item which stores, among other things, user_id.
Then I have a ModelForm. I want user_id to be a hidden field. After
searching around the web, I found out how to create a hidden field.
The template is rendered as I like it.
user_id is a hidden field with a value of 1. The problem is when I
submit the form, I get IntegrityError. "Column 'user_id' cannot be
null".

but from the debug message I get back I can see that POST has all 3
things I need. So maybe when a new form is created there is problem.

views.py
@login_required
def newItem(request):
if not request.POST:
form = ItemForm()
return render_to_response('manager/newItem.html',{'form':form})
newForm = ItemForm(request.POST)
if newForm.is_valid():
newForm.save() #problem here?
return HttpResponsePermanentRedirect('.')

models.py
class Item(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=32)
description = models.CharField(max_length=128)
creation_date = models.DateField(auto_now=True)

forms.py
class ItemForm(ModelForm):
user_id_wid = forms.HiddenInput(attrs={'value': 1})
user_id = forms.IntegerField(widget=user_id_wid,required=False)
class Meta:
model = Item
fields = ['name', 'description']

and my template has:


Create Item
{% for field in form %}
{% if field.is_hidden %}
{{field}}
{% else %}

{{ field.errors }}
{{ field.label_tag }}: {{ field }}

{% endif %}
{% endfor %}




The hidden field is not being bound to the form? is that it? If so how
can I go about it?

NOTE: I can insert a new object if i manually create a form myself,
and just get the values from request.POST and do Item.objects.create()
with the POST values I get. I am just learning so I want to make sure
how to do this with ModelForms. That way i won't have to write as many
forms html either.

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



Memcached, out of sockets

2009-06-15 Thread Miles

I've been running the python memcached connector for a while, without
much trouble. But just today during a stress test of one of the feeds
(read: many many requests expected), I've ran into an out of sockets
situation.

After every single request, the cache backend forces a disconnect from
all memcached servers. That's no problem if you don't get too many
hits, but after about ~5k requests in a minute, python just fails to
connect to memcached and falls back to database access.


Cause:

Fixed #5133 -- Explicitly close memcached connections after each
request
(similar to database connection management). We can't effectively
manage the
lifecycle by pooling connections and recent versions of python-
memcache can
lead to connection exhaustion in some quite reasonable setups.


Memcached is designed to help web apps hit insane throughput, not kill
the whole server by exhausting all available sockets by forcing them
all in TIME_WAIT... Without a decent amount of traffic, people
wouldn't even bother to run memcached.

Oh well, I'll be nooping the fix locally. That it added another 30%
throughput on windows is just a bonus. If you plan to disable close
with something like
django.core.cache.backends.memcached.CacheClass.close = lambda x:
None, make sure you also set memcache._Host._DEAD_RETRY = 5. Otherwise
a broken socket can cause 30s of no cache on a thread, or worse, 30s
of no cache at all when you restart memcached, instead of reconnecting
on the next request. I thought I hit a bug the first I saw it happen.


With a mod_wsgi deamon mode setup, max-requests=500, I'm not scared of
leaking some sockets which gets freed after a few minutes at most.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to preset a value to a field on a ModelForm

2009-06-15 Thread adelaide_mike

Hi
Newbie trying to preset a field on a form where the object is to be
inserted.  The snippet below does not do it.

class FooForm(ModelForm):
class Meta:
model = Foo


if request.method == 'GET':
if foo_id > '0':
foo=Foo.objects.get(pk=foo_id)
form = FooForm(instance=foo)# this part 
works OK
else:
form = FooForm()
foo=form.save(commit=False)
foo.date = request.session['date']# we know 
request.session
['date'] has a value
form = FooForm(instance=foo)

What is a better way?  TIA

Mike
--~--~-~--~~~---~--~~
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: Relative imports in custom template tag collections seem to look in the wrong place.

2009-06-15 Thread greatlemer

On Jun 15, 10:47 pm, Alex Gaynor  wrote:
> On Mon, Jun 15, 2009 at 4:39 PM, greatlemer wrote:
>
>
>
>
>
> > Hi everyone,
>
> > I was creating some custom template tags and attempted to import my
> > models through the following import at the top of the file:
>
> > from ..models import *
>
> > Unfortunately this seems to be attempting to import from django.models
> > (which doesn't exist) rather than myapp.models and therefore throws up
> > an error when I try to use it.  Is there any possible way that I will
> > be able to perform this import without specifying the app name (as I
> > was trying to keep things as generic as possible) or am I just going
> > to have to bite the bullet and hard-code the app name in there?
>
> > Cheers,
>
> > G
>
> Unfortunately for the time being you're going to need to bite the bullet.
> Django does some *very* nasty things when loading templatetags that are
> almost certainly the source of your problem.  This is considered a bug,
> however it won't get fixed until the 1.2 release cycle in all likelyhood
> (only bugs that break things very badly are being considered for 1.1 at this
> point).
>
> 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

Ah well, I feared that may be the case, fortunately it's not a
showstopper, just an annoying niggle.  I'll keep an eye on things to
see if it does get picked up for 1.2 though.

Thanks for the quick response.

G
--~--~-~--~~~---~--~~
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: Relative imports in custom template tag collections seem to look in the wrong place.

2009-06-15 Thread Alex Gaynor
On Mon, Jun 15, 2009 at 4:39 PM, greatlemer wrote:

>
> Hi everyone,
>
> I was creating some custom template tags and attempted to import my
> models through the following import at the top of the file:
>
> from ..models import *
>
> Unfortunately this seems to be attempting to import from django.models
> (which doesn't exist) rather than myapp.models and therefore throws up
> an error when I try to use it.  Is there any possible way that I will
> be able to perform this import without specifying the app name (as I
> was trying to keep things as generic as possible) or am I just going
> to have to bite the bullet and hard-code the app name in there?
>
> Cheers,
>
> G
> >
>
Unfortunately for the time being you're going to need to bite the bullet.
Django does some *very* nasty things when loading templatetags that are
almost certainly the source of your problem.  This is considered a bug,
however it won't get fixed until the 1.2 release cycle in all likelyhood
(only bugs that break things very badly are being considered for 1.1 at this
point).

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

--~--~-~--~~~---~--~~
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 logged in by default??

2009-06-15 Thread Joakim Hove

Hello,

thank you for answering.

> Did you log yourself in in the admin without thinking about it?  That's
> usually how I end up logged in without realizing it.

I had thought of that - and did a fresh start of the browser without
any success. But, prompted by your suggestion I continued to remove
all cookies, and then it worked (i..e I was presented with the login
view I expected).

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



Relative imports in custom template tag collections seem to look in the wrong place.

2009-06-15 Thread greatlemer

Hi everyone,

I was creating some custom template tags and attempted to import my
models through the following import at the top of the file:

from ..models import *

Unfortunately this seems to be attempting to import from django.models
(which doesn't exist) rather than myapp.models and therefore throws up
an error when I try to use it.  Is there any possible way that I will
be able to perform this import without specifying the app name (as I
was trying to keep things as generic as possible) or am I just going
to have to bite the bullet and hard-code the app name in there?

Cheers,

G
--~--~-~--~~~---~--~~
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 logged in by default??

2009-06-15 Thread Alex Gaynor
On Mon, Jun 15, 2009 at 4:35 PM, Joakim Hove  wrote:

>
> Hello,
>
> I have just started experimenting with the Django user authentication
> system, I am currently only running with the Python testserver (if
> that matters). In my url.py file I have the following view mapping:
>
> ...
> (r'^agent/$'  ,   'Sleipner.model.views.agent'),
> .
>
> This view looks like this:
>
>
> def agent(request):
> if not request.user.is_authenticated():
> return HttpResponseRedirect('/Sleipner/login/?next=%s' %
> request.path)
> else:
> return render_to_response("model/agent.html" , {"username" :
> request.user.username})
>
>
> I.e. if the current request does not come from a authenticated user
> the view should redirect to a page querying for login info, otherwise
> it should render a simple page which displays the username of the
> currently logged in (authenticated) user. Now, what I do not
> understand is that the agent() function above always seems to execute
> the second code branch, i.e. it renders a welcome message to the
> agent, with a valid username, without me ever logging in? It ssems a
> user is automatically logged in - without any effort on my behalf.
>
> The logout() function also fails with "maximum recursion depth
> exceeded" - which might indicate some auto-login behaviour?
>
> Any tips greatly appreciated!
>
> Joakim
>
> >
>
Did you log yourself in in the admin without thinking about it?  That's
usually how I end up logged in without realizing it.

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

--~--~-~--~~~---~--~~
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 logged in by default??

2009-06-15 Thread Joakim Hove

Hello,

I have just started experimenting with the Django user authentication
system, I am currently only running with the Python testserver (if
that matters). In my url.py file I have the following view mapping:

...
(r'^agent/$'  ,   'Sleipner.model.views.agent'),
.

This view looks like this:


def agent(request):
 if not request.user.is_authenticated():
 return HttpResponseRedirect('/Sleipner/login/?next=%s' %
request.path)
 else:
 return render_to_response("model/agent.html" , {"username" :
request.user.username})


I.e. if the current request does not come from a authenticated user
the view should redirect to a page querying for login info, otherwise
it should render a simple page which displays the username of the
currently logged in (authenticated) user. Now, what I do not
understand is that the agent() function above always seems to execute
the second code branch, i.e. it renders a welcome message to the
agent, with a valid username, without me ever logging in? It ssems a
user is automatically logged in - without any effort on my behalf.

The logout() function also fails with "maximum recursion depth
exceeded" - which might indicate some auto-login behaviour?

Any tips greatly appreciated!

Joakim

--~--~-~--~~~---~--~~
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: Change AuthenticationForm error message

2009-06-15 Thread Vitaly Babiy
Yeah I think that is what I am going to do.

Thanks
Vitaly Babiy


On Mon, Jun 15, 2009 at 4:58 PM, TiNo  wrote:

> On Sun, Jun 14, 2009 at 14:45, Vitaly Babiy  wrote:
>
>> Hey Everyone,
>> I need to change the inactive account error message on the
>> AuthenticationForm, one thing I have is to replace the clean method on the
>> form with my own custom clean method the problem with this is django test
>> fail when I do this. I was wondering was is the best practice when it comes
>> to this.
>>
>
> You could subclass AuthenticationForm, override the clean method, and use
> it in your own custom login view. That is probably the easiest.
>
> TiNo
>
> >
>

--~--~-~--~~~---~--~~
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: Change AuthenticationForm error message

2009-06-15 Thread TiNo
On Sun, Jun 14, 2009 at 14:45, Vitaly Babiy  wrote:

> Hey Everyone,
> I need to change the inactive account error message on the
> AuthenticationForm, one thing I have is to replace the clean method on the
> form with my own custom clean method the problem with this is django test
> fail when I do this. I was wondering was is the best practice when it comes
> to this.
>

You could subclass AuthenticationForm, override the clean method, and use it
in your own custom login view. That is probably the easiest.

TiNo

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



querystring redirect

2009-06-15 Thread Bobby Roberts

hi all... is it possible to do the following?

let's say the user types in the following url into their browser:

mysite.com/redirect/?http://www.newsiteout.com/whatever.asp

Is it possible to snag the redirect url after the ? in the url and
then use it to do a redirect?  I've run into a situation where a
client has a need for an interim ("you're leaving our site") type page
before doing a redirect.  I'm trying to make this as easy as possible
for the client.

is this possible?  I'm reading the response docs but i'm not really
finding a good example.
--~--~-~--~~~---~--~~
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: Query Help: "Get Blogs where last Entry.title='foo'"

2009-06-15 Thread Streamweaver

A custom method in the model could work fine.

If you set a 'get_latest_by' in the Entry Model ->
http://www.djangoproject.com/documentation/models/get_latest/

Then in the Blog Model define something like:

def last_is_foo(self):
if Entry.objects.latest().title == 'foo'
return True
return False

Adding a CustomManager to that would easily give you back sets.

Getting closer?

On Jun 15, 4:11 pm, Jason  wrote:
> Close.  That returns all entrys that have title foo.  I need all blogs
> *where the last entry* has title foo.  I think I need to
> leverage .extra(where=something) but not having much luck.
>
> On Jun 15, 2:36 pm, Streamweaver  wrote:
>
> > If I understand your question right there is an example that covers
> > this exact situation that may help at
>
> >http://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-...
>
> > I believe it could come out to something like this:
>
> > e = Entry.objects.filter(title__exact='foo')
>
> > blog = e.blog
>
> > On Jun 15, 2:41 pm, Jason  wrote:
>
> > > I'm new to django and attempting to leverage the query functionality.
> > > I'm not sure if what I'm attempting requires custom sql or if I"m just
> > > missing something.  I'm spending alot of time with the docs but
> > > haven't found guidance for this issue.
>
> > > Just using blogs as an easy example, assume the models below...
>
> > > class Blog(models.Model):
> > >     name = models.CharField(max_length=100, unique=True)
>
> > > class Entry(models.Model):
> > >     blog = models.ForeignKey(Blog)
> > >     title = models.CharField(max_length=100)
>
> > > How can I construct a query that returns all blogs where the last
> > > entry has a title of 'foo'?
>
> > > Note:  Using Django 1.1 beta, and thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Query Help: "Get Blogs where last Entry.title='foo'"

2009-06-15 Thread Jason

Close.  That returns all entrys that have title foo.  I need all blogs
*where the last entry* has title foo.  I think I need to
leverage .extra(where=something) but not having much luck.


On Jun 15, 2:36 pm, Streamweaver  wrote:
> If I understand your question right there is an example that covers
> this exact situation that may help at
>
> http://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-...
>
> I believe it could come out to something like this:
>
> e = Entry.objects.filter(title__exact='foo')
>
> blog = e.blog
>
> On Jun 15, 2:41 pm, Jason  wrote:
>
> > I'm new to django and attempting to leverage the query functionality.
> > I'm not sure if what I'm attempting requires custom sql or if I"m just
> > missing something.  I'm spending alot of time with the docs but
> > haven't found guidance for this issue.
>
> > Just using blogs as an easy example, assume the models below...
>
> > class Blog(models.Model):
> >     name = models.CharField(max_length=100, unique=True)
>
> > class Entry(models.Model):
> >     blog = models.ForeignKey(Blog)
> >     title = models.CharField(max_length=100)
>
> > How can I construct a query that returns all blogs where the last
> > entry has a title of 'foo'?
>
> > Note:  Using Django 1.1 beta, and thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting a distinct list of Users from two related Models

2009-06-15 Thread Streamweaver

awesome.  Thanks for that.

I put that in the comments in my code so if I ever get back to it
after an update I can streamline it a bit.

Thanks again.

On Jun 11, 10:44 am, Karen Tracey  wrote:
> On Wed, Jun 10, 2009 at 3:24 PM, Streamweaver wrote:
>
>
>
>
>
> > Thanks so much for the reply.
>
> > Oddly the method you suggests throws an error but I'm not sure why.
>
> > The solution I came up with is as follows:
>
> > User.objects.order_by('username').filter
> > (project__owner__isnull=False).distinct() | User.objects.filter
> > (release__owner__isnull=False).distinct()
>
> > I would expect the line you wrote to give the same results but when I
> > try it I get an Template Error of "Caught an exception while
> > rendering: no such column: U1.owner_id"  I have no idea why.
>
> > It's working for me so I don't have a problem now but I'm definitly
> > missing something about why I'm getting this error at all.
>
> An error like that -- where the ORM generates SQL that is incorrect -- is
> generally a bug in Django.  In this case I can recreate it with the 1.0.2
> release, but not with current trunk or 1.0.X branch code, so it is
> apparently a bug that has been found and fixed since 1.0.2.
>
> 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: Modifying Django's User Model

2009-06-15 Thread LeeRisq

Thanks for the info. I'll check it out.

On Jun 12, 11:06 am, Rajesh D  wrote:
> On Jun 12, 9:29 am, LeeRisq  wrote:
>
> > I am interested in changing the primary key of the User model to email
> > and also use that as the username.
>
> > I would like to maintain the admin interface as well.
>
> > I am uncertain about the ramifications of doing this. I understand
> > this change will need to be reflected in other models and some views,
> > but does anyone know just how deep this change would need to go?
>
> If you're mainly interested in making the email field unique (rather
> than a PK), you could use a custom user-creation form of your own. In
> your form, ensure that the clean_email method rejects duplicate
> emails. If you create users through admin, unregister the built-in
> UserAdmin class and reregister your own UserAdmin class that uses your
> custom user-creation form.
>
> If you want to allow login by email instead of by username, here's a
> starting point:
>
> http://www.djangosnippets.org/snippets/74/
>
> -Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Query Help: "Get Blogs where last Entry.title='foo'"

2009-06-15 Thread Streamweaver

If I understand your question right there is an example that covers
this exact situation that may help at

http://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationships

I believe it could come out to something like this:

e = Entry.objects.filter(title__exact='foo')

blog = e.blog

On Jun 15, 2:41 pm, Jason  wrote:
> I'm new to django and attempting to leverage the query functionality.
> I'm not sure if what I'm attempting requires custom sql or if I"m just
> missing something.  I'm spending alot of time with the docs but
> haven't found guidance for this issue.
>
> Just using blogs as an easy example, assume the models below...
>
> class Blog(models.Model):
>     name = models.CharField(max_length=100, unique=True)
>
> class Entry(models.Model):
>     blog = models.ForeignKey(Blog)
>     title = models.CharField(max_length=100)
>
> How can I construct a query that returns all blogs where the last
> entry has a title of 'foo'?
>
> Note:  Using Django 1.1 beta, and thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Query Help: "Get Blogs where last Entry.title='foo'"

2009-06-15 Thread Jason

I'm new to django and attempting to leverage the query functionality.
I'm not sure if what I'm attempting requires custom sql or if I"m just
missing something.  I'm spending alot of time with the docs but
haven't found guidance for this issue.

Just using blogs as an easy example, assume the models below...

class Blog(models.Model):
name = models.CharField(max_length=100, unique=True)

class Entry(models.Model):
blog = models.ForeignKey(Blog)
title = models.CharField(max_length=100)


How can I construct a query that returns all blogs where the last
entry has a title of 'foo'?

Note:  Using Django 1.1 beta, and thanks in advance.

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



Date of last update across Relationships

2009-06-15 Thread Streamweaver

What I want to do is get the date of the last update across
relationships to figure out when the last update in an entire series
of related objects happened.

I'm pasting the relevant code of my models below but for example, I
want to be able to call a series_updated method on project that
returns the most recent date of a last_updated value from the project
or any of the related Releases or Activities.

I'm having trouble wrapping my head around this and would appreciate
any insight.


class Project(models.Model):
last_updated = models.DateField(auto_now=True, auto_now_add=True)

class Meta:
get_latest_by = 'last_updated'
ordering = ['last_updated']

class Release(models.Model):
project_fk = models.ForeignKey(Project)
last_updated = models.DateField(auto_now=True, auto_now_add=True)

class Meta:
get_latest_by = 'last_updated'
ordering = ["project_fk", "internal_priority"]

class Activity(models.Model):
release_fk = models.ForeignKey(Release)
last_updated = models.DateField(auto_now=True, auto_now_add=True)

class Meta:
get_latest_by = 'last_updated'
ordering = ['last_updated']

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



subdomain vs. prefix

2009-06-15 Thread eric.frederich

Hello,

I have been running a django site on apache using the following
alias...

WSGIScriptAlias /apps /path/to/django_application/apache/django.wsgi

In doing this I was pleasantly surprised to see that most of the URLs
worked fine.  The only thing I needed to change was LOGIN_URL='/apps/
login' in settings.py.  Nowhere else in my code is /apps mentioned
because apache sets some script prefix variable that wsgi tells django
about and all is well.

Now I am running into a problem with my cron jobs that run outside the
context of apache and my URLs generated with "http://%s%s/"; %
(Site.objects.get_current().domain, reverse(*args, **kwargs)) are
missing the /apps part.

I was okay with having one thing my code having /apps hard coded but
now I'm looking at having to see what context I'm running in (apache
vs. cron) and selectively adding this prefix.  This would introduce
another place where I'd need /apps hard coded which I don't like.  I
wasn't really happy with having to do it the one time.

Questions:

Would running in a subdomain solve all my problems?  For example using
apps.example.com rather than example.com/apps/.

Are there other parts of django that I have not run into yet that
expect django to be ran at the root?

If I can't get IT to give me a subdomain, what is the best way to
detect whether the code is running inside Apache or outside so that I
can slap /apps into my URLs?

Thanks in advance,
~Eric

--~--~-~--~~~---~--~~
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 + Apache + mod_wsgi + Oracle -> threading problems?

2009-06-15 Thread Ian Kelly

On Jun 15, 11:11 am, Miles  wrote:
> Connections aren't thread safe - you have to ensure every thread gets
> its own connection. You can create a new connection every request or
> use a thread-local to cache connections.

The latter is what Django does, although it's very easy to miss when
perusing the source code.  The backend DatabaseWrapper class (where
the connection is stored) inherits from BaseDatabaseWrapper, which
inherits from threading.local.

Ian
--~--~-~--~~~---~--~~
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 to deploy on production server

2009-06-15 Thread Francis

Also, if I set the SITE_ID to be equal in both config, When I save a
model entry, I got an error from django:
ERROR:  canceling statement due to statement timeout

Francis

On Jun 15, 10:40 am, Thomas Guettler  wrote:
> Hi,
>
> do you use the cache module? Be sure, that both projects use
> different ones.
>
> Maybe you need to set SESSION_COOKIE_NAME if the domain name is the
> same.
>
> Do you use one database or two? (Is settings.DATABASE_NAME the same?)
>
>   Thomas
>
> Francis schrieb:
>
>
>
>
>
> > Hi,
>
> > I have completed one web site and I am now ready to deploy it in
> > production, but I have serious issues where I can't find any
> > information/clue on the django web site, in the book or on IRC. I have
> > no idea how I can solve my problem
>
> > What I want to achieve is the following:
> > 1 site under http without admin acces
> > 1 site under https + admin acces
>
> > My config
> > python 2.5
> > django 1.0.2
> > postgresql
> > mod_wsgi (i'm using it because djapian doesn't work with mod_python)
>
> > So what I did was to create two mod_wsgi on two project repositories.
> > One configured with the admin apps installed (https) an one without
> > (http).
> > Results:
> > When I save an entry to a model, it saves it and redirects to the non
> > secure http service instead of the secure one, throwing a 404.
>
> > So I tried to enable the admin apps on both services.
> > Results:
> > Now I get a proxy error on the https service and a timeout on the http
> > service.
> > Some tables show no result on the http service but show them all on
> > the other one.
>
> > If I shut down the https service, some entries can be saved and others
> > don't.
> > The same tables that wrongly display nothing are still empty.
>
> > I tried to give each site a different site_id, but it doesn't help.
>
> > Help would be very much appreciated,
>
> > Thank you
>
> > Francis
>
> --
> 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: Problem to deploy on production server

2009-06-15 Thread Francis

Cache is planned for the non secure site, but not configured at this
point.

SESSION_COOKIE_NAME makes no diffrence.
When I log to https://mysite.com/myadmin
it redirect to http after succesful login, I need to manually enter
https.

Saving an entry generate a 502 BAD GATEWAY - The proxy server received
an invalid response from an upstream server.

I have only one database. DATABASE_NAME is the same.

Francis


On Jun 15, 10:40 am, Thomas Guettler  wrote:
> Hi,
>
> do you use the cache module? Be sure, that both projects use
> different ones.
>
> Maybe you need to set SESSION_COOKIE_NAME if the domain name is the
> same.
>
> Do you use one database or two? (Is settings.DATABASE_NAME the same?)
>
>   Thomas
>
> Francis schrieb:
>
>
>
>
>
> > Hi,
>
> > I have completed one web site and I am now ready to deploy it in
> > production, but I have serious issues where I can't find any
> > information/clue on the django web site, in the book or on IRC. I have
> > no idea how I can solve my problem
>
> > What I want to achieve is the following:
> > 1 site under http without admin acces
> > 1 site under https + admin acces
>
> > My config
> > python 2.5
> > django 1.0.2
> > postgresql
> > mod_wsgi (i'm using it because djapian doesn't work with mod_python)
>
> > So what I did was to create two mod_wsgi on two project repositories.
> > One configured with the admin apps installed (https) an one without
> > (http).
> > Results:
> > When I save an entry to a model, it saves it and redirects to the non
> > secure http service instead of the secure one, throwing a 404.
>
> > So I tried to enable the admin apps on both services.
> > Results:
> > Now I get a proxy error on the https service and a timeout on the http
> > service.
> > Some tables show no result on the http service but show them all on
> > the other one.
>
> > If I shut down the https service, some entries can be saved and others
> > don't.
> > The same tables that wrongly display nothing are still empty.
>
> > I tried to give each site a different site_id, but it doesn't help.
>
> > Help would be very much appreciated,
>
> > Thank you
>
> > Francis
>
> --
> 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: can you have a flatpage with url of "/" when Debug=True?

2009-06-15 Thread Michael
On Mon, Jun 15, 2009 at 2:00 PM, Joseph Brown  wrote:

> Well I'm flummoxed.  After reading your post I retested on my dev site, and
> the problem has vanished.  Then I tried on production and same thing, it's
> gone!
>
> I do have custom 404 and 500 templates. All I can figure that might have
> changed is the file ownership - I'm using subversion and might have copied
> the files from the repository incorrectly, I don't know, but that's all I
> can think of that might have changed.
>
> The server is Apache2.2, urls.py has no handler for Flatpages, I just use
> the fallback default in settings.py.
>
> Sorry if this is stupid, but since I'm rendering my 500 page for this
> error, what's the best way to capture the traceback, if it happens again?
>
> Thanks for the help!
>

Short of placing logging around your system, Django has the ability to send
e-mails with errors that include the traceback.  Here is the documents
regarding that:
http://docs.djangoproject.com/en/dev/howto/error-reporting/#howto-error-reporting

Hope that helps,

Michael

--~--~-~--~~~---~--~~
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: can you have a flatpage with url of "/" when Debug=True?

2009-06-15 Thread Joseph Brown
Well I'm flummoxed.  After reading your post I retested on my dev site, and
the problem has vanished.  Then I tried on production and same thing, it's
gone!

I do have custom 404 and 500 templates. All I can figure that might have
changed is the file ownership - I'm using subversion and might have copied
the files from the repository incorrectly, I don't know, but that's all I
can think of that might have changed.

The server is Apache2.2, urls.py has no handler for Flatpages, I just use
the fallback default in settings.py.

Sorry if this is stupid, but since I'm rendering my 500 page for this error,
what's the best way to capture the traceback, if it happens again?

Thanks for the help!

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



Re: Developing on Apache w/ mod_python

2009-06-15 Thread Gabriel .

Hi,

This a test conf with mod_python:


ServerName py.banshee.lnx
DocumentRoot "/home/www/python"
ErrorLog /var/log/apache2/cash-error_log
CustomLog /var/log/apache2/cash-out_log combined


 SetHandler mod_python
 PythonHandler django.core.handlers.modpython
 SetEnv DJANGO_SETTINGS_MODULE pyCash.settings
 PythonOption django.root /pyCash
 PythonDebug Off
 PythonPath "['/home/www/python','/home/www/python/pyCash'] + sys.path"
 PythonInterpreter pyCash


Alias /media "/home/www/python/pyCash/pages/media"
Alias /admin_media "/home/www/python/pyCash/admin_media"


SetHandler None



SetHandler None



SetHandler None



Options None
AllowOverride FileInfo
Order allow,deny
Allow from all




The project is pyCash an is located at /home/www/python

In my case, I have a symlink call admin_media in my application path
pointing to the correct crontib path.

Modify it to serve your needs.

-- 
Kind Regards

--~--~-~--~~~---~--~~
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 + Apache + mod_wsgi + Oracle -> threading problems?

2009-06-15 Thread James Gregory


> Connections aren't thread safe - you have to ensure every thread gets
> its own connection. You can create a new connection every request or
> use a thread-local to cache connections.
>

Ok, thanks for the explanation/confirmation

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



Developing on Apache w/ mod_python

2009-06-15 Thread gte351s

Hello,

I'm very new to Django and trying to configure apache to work
with the tutorial application. I installed mod_python and
configured httpd.conf to look like this:

# mod python
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
NameVirtualHost *:80

ServerName django.test
DocumentRoot "/home/gte351s/dev/django/mysite"
PythonPath "['/home/gte351s/dev/django/mysite',
   '/usr/local/lib/python2.6/dist-packages/django'] +
sys.path"
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On



I have nothing else in that file.

When I point the browser to  http://localhost/time/
I get a mod_python error:
==Hello,

I'm very new to Django and trying to configure apache to work
with the tutorial application. I installed mod_python and
configured httpd.conf to look like this:

# mod python
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
NameVirtualHost *:80

ServerName django.test
DocumentRoot "/home/gte351s/dev/django/mysite"
PythonPath "['/home/gte351s/dev/django/mysite',
   '/usr/local/lib/python2.6/dist-packages/django'] +
sys.path"
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On



I have nothing else in that file.

When I point the browser to  http://localhost/time/
I get a mod_python error:
==
ImportError: Could not import settings 'mysite.settings'
(Is it on sys.path? Does it have syntax errors?): No module
named mysite.settings
==
This is obviously a configuration error, but I'm not sure how to
set up apache to properly find the django app. I'd appreciate any
help on this - 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 + Apache + mod_wsgi + Oracle -> threading problems?

2009-06-15 Thread Miles

On Jun 15, 6:18 pm, James Gregory  wrote:
> I am creating a web app with Django. I use a local MySQL database to
> store users etc, but also connect to a remote Oracle database to pull
> in some information to display.
>
> Due to Django's lack of multiple database support I have written my
> own very smalI Oracle wrapper, using cx_Oracle. In an effort to be
> more efficient, I create a new Oracle connection when my oracle python
> code is first included, and then only reconnect if the connection is
> closed. I note that Django's own database wrapper code does the same
> thing.
>
> This works fine when running with Django's development server, but if
> I:
> 1. Run my application via Apache and mod_wsgi
> 2. Then hit the server with two requests in rapid succession
>
> The second request displays a database error of "ORA-24909: call in
> progress. Current operation cancelled". It seems this is caused by
> attempting to use a database connection/cursor before the last query
> has finished - i.e. the Oracle client library doesn't like multiple
> threads attempting to use the same cursor simultanously.
>
> Questions:
> 1. Is this a bug in Oracle? I see some one web reference implying that
> this is a bug in Oracle version 10.2.0.1, and that is indeed the
> version I am using. However, I only get the error when multiple
> threads are attempting to use the same connection at the same time, so
> it might well be a valid error message regardless of version.
>
> 2. If it is not a bug in Oracle, then how does Django's own Oracle
> wrapper avoid this problem? I was reading through the source but can't
> see anything obvious.
>
> 3. If it is not a bug but Django's own wrapper doesn't deal with this
> problem, how do I deal with it? Should I simply create a new database
> connection for every single web request?
>
> James

Connections aren't thread safe - you have to ensure every thread gets
its own connection. You can create a new connection every request or
use a thread-local to cache connections.

Miles
--~--~-~--~~~---~--~~
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 + Apache + mod_wsgi + Oracle -> threading problems?

2009-06-15 Thread James Gregory

I am creating a web app with Django. I use a local MySQL database to
store users etc, but also connect to a remote Oracle database to pull
in some information to display.

Due to Django's lack of multiple database support I have written my
own very smalI Oracle wrapper, using cx_Oracle. In an effort to be
more efficient, I create a new Oracle connection when my oracle python
code is first included, and then only reconnect if the connection is
closed. I note that Django's own database wrapper code does the same
thing.

This works fine when running with Django's development server, but if
I:
1. Run my application via Apache and mod_wsgi
2. Then hit the server with two requests in rapid succession

The second request displays a database error of "ORA-24909: call in
progress. Current operation cancelled". It seems this is caused by
attempting to use a database connection/cursor before the last query
has finished - i.e. the Oracle client library doesn't like multiple
threads attempting to use the same cursor simultanously.

Questions:
1. Is this a bug in Oracle? I see some one web reference implying that
this is a bug in Oracle version 10.2.0.1, and that is indeed the
version I am using. However, I only get the error when multiple
threads are attempting to use the same connection at the same time, so
it might well be a valid error message regardless of version.

2. If it is not a bug in Oracle, then how does Django's own Oracle
wrapper avoid this problem? I was reading through the source but can't
see anything obvious.

3. If it is not a bug but Django's own wrapper doesn't deal with this
problem, how do I deal with it? Should I simply create a new database
connection for every single web request?

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



Re: is there a form building pluggable?

2009-06-15 Thread Alex Gaynor
On Mon, Jun 15, 2009 at 10:51 AM, Viktor  wrote:

>
> Hi,
>
> do you know about an existing application that would allow someone to
> add (more-or-less) arbitrary forms to an object?
>
> basically, I'm creating a conference management application, and when
> you register for a conference different questions might be asked which
> might not even be known today (e.g. long conferences might offer
> accomodation, while short ones don't, and you can decide whether you
> need it or not). Thus I would like to add arbitraty questions to my
> conference model instances such that the form for the question is
> generated on the fly including some basic validation rules (that are
> likely to be preprogrammed for every available field type)
>
> do you know of such an existing project?
>
> thanks, Viktor
> >
>
I don't know of an existing project that does this, however I covered
something similar in a talk I gave, you can see the slides here:
http://www.slideshare.net/kingkilr/forms-getting-your-moneys-worth

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

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



is there a form building pluggable?

2009-06-15 Thread Viktor

Hi,

do you know about an existing application that would allow someone to
add (more-or-less) arbitrary forms to an object?

basically, I'm creating a conference management application, and when
you register for a conference different questions might be asked which
might not even be known today (e.g. long conferences might offer
accomodation, while short ones don't, and you can decide whether you
need it or not). Thus I would like to add arbitraty questions to my
conference model instances such that the form for the question is
generated on the fly including some basic validation rules (that are
likely to be preprogrammed for every available field type)

do you know of such an existing project?

thanks, Viktor
--~--~-~--~~~---~--~~
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 instance to update an object

2009-06-15 Thread Genis Pujol Hamelink
yes, but what if it's a new object and not an existing one? How do I test
this? The request method will be POST, so form will be form =
MyForm(request.POST)... so if form.pk exists in the db how do I tell it's
editing an existing object?

if request.method == 'POST':
 form = myform(request.POST)
 try:
   instance = myobj.objects.get(id=form.id)
   form = myform(request.POST, instance=instance)
   if form.is_valid():
 form.save()
   else:
  whatever goes here
 except:
   form = myform(request.POST)
if form.is_valid():
 form.save()
   else:
  whatever goes here

Something like this or do u know a better way?





2009/6/15 Daniel Roseman 

>
> On Jun 15, 3:20 pm, Genis Pujol Hamelink 
> wrote:
> > Hi list,
> >
> > I am trying to create a view to update objects in the db:
> >
> > http://dpaste.com/55546/
> >
> > but when posting the data, form.is_valid() fails because the object
> already
> > exists in the db. Is there a way to validate a form using an existing
> object
> > and then save it?
> >
> > regards,
> >
> > --
> > Genís
>
> Yes, pass the instance as a parameter to the form instantiation.
> form = MyForm(instance=instance)
> --
> DR.
> >
>


-- 
Genís

--~--~-~--~~~---~--~~
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: Deploy with mod_python on Apache2 server

2009-06-15 Thread Karen Tracey
On Mon, Jun 15, 2009 at 11:01 AM, kiwi  wrote:

>
> Hi,
>
> I try to deploy my web application written with django on Apache2 with
> mod_python, but when I try to load my homepage using apache at
> http://localhost/myproject/  my template does not load although the
> TEMPLATE_DIR in django settings is correct, why?
>
> My Apache2 http.conf file is correct because I've try to deploy a
> simple web application and it's works, I think that the problem is the
> path of templates, in fact I've created a directory in the root (/) of
> my file system and I put templates in there,  and the template has
> been loaded correctly.
>
> Django error is:
>
> emplateDoesNotExist at /sds/
>
> index.html
>
> Request Method: GET
> Request URL:http://localhost/sds/
> Exception Type: TemplateDoesNotExist
> Exception Value:
>
> index.html
>
> Exception Location: /usr/local/lib/python2.6/dist-packages/django/
> template/loader.py in find_template_source, line 73
> Python Executable:  /usr/bin/python
> Python Version: 2.6.2
> Python Path:['/home/utente/Scrivania/', '/home/utente/Scrivania/
> web_App', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/
> usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/
> python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/
> python2.6/dist-packages/Numeric', '/usr/lib/python2.6/dist-packages/
> PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/lib/python-
> support/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/var/
> lib/python-support/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-
> packages']
> Server time:Mon, 15 Jun 2009 08:59:57 -0500
> Template-loader postmortem
>
> Django tried loading these templates, in this order:
>
>* Using loader
> django.template.loaders.filesystem.load_template_source:
>  o /home/utente/Scrivania/web_App/sds/templates/index.html
> (File exists)
>
>   ---> The file exists but It does not loaded. Why?
>
>
That generally means that the Apache process does not have permission to
read the file.

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



Deploy with mod_python on Apache2 server

2009-06-15 Thread kiwi

Hi,

I try to deploy my web application written with django on Apache2 with
mod_python, but when I try to load my homepage using apache at
http://localhost/myproject/  my template does not load although the
TEMPLATE_DIR in django settings is correct, why?

My Apache2 http.conf file is correct because I've try to deploy a
simple web application and it's works, I think that the problem is the
path of templates, in fact I've created a directory in the root (/) of
my file system and I put templates in there,  and the template has
been loaded correctly.

Django error is:

emplateDoesNotExist at /sds/

index.html

Request Method: GET
Request URL:http://localhost/sds/
Exception Type: TemplateDoesNotExist
Exception Value:

index.html

Exception Location: /usr/local/lib/python2.6/dist-packages/django/
template/loader.py in find_template_source, line 73
Python Executable:  /usr/bin/python
Python Version: 2.6.2
Python Path:['/home/utente/Scrivania/', '/home/utente/Scrivania/
web_App', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/
usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/
python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/
python2.6/dist-packages/Numeric', '/usr/lib/python2.6/dist-packages/
PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/lib/python-
support/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/var/
lib/python-support/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-
packages']
Server time:Mon, 15 Jun 2009 08:59:57 -0500
Template-loader postmortem

Django tried loading these templates, in this order:

* Using loader
django.template.loaders.filesystem.load_template_source:
  o /home/utente/Scrivania/web_App/sds/templates/index.html
(File exists)

   ---> The file exists but It does not loaded. Why?


  o /templates/index.html (File does not exist)
* Using loader
django.template.loaders.app_directories.load_template_source:
  o /usr/local/lib/python2.6/dist-packages/django/contrib/
admin/templates/index.html (File does not exist)
  o /usr/local/lib/python2.6/dist-packages/django/contrib/
admindocs/templates/index.html (File does not exist)

thanks, Nicola.


--~--~-~--~~~---~--~~
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: Change AuthenticationForm error message

2009-06-15 Thread Vitaly Babiy
That seem likes to much overhead to make every request to go through.

Vitaly Babiy


On Mon, Jun 15, 2009 at 1:31 AM, Rama Vadakattu wrote:

>
> one simple idea ( it may or may not be feasible ) that you can use is
> 1) write down a middleware
> 2) examine the context which has a form and with the above error
> message
>and replace it with your new error message
>
>
>
> On Jun 14, 5:45 pm, Vitaly Babiy  wrote:
> > Hey Everyone,
> > I need to change the inactive account error message on the
> > AuthenticationForm, one thing I have is to replace the clean method on
> the
> > form with my own custom clean method the problem with this is django test
> > fail when I do this. I was wondering was is the best practice when it
> comes
> > to this.
> >
> > Thanks,
> > Vitaly Babiy
> >
>

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



New with Python and Django

2009-06-15 Thread Asinox

Hi guy's, im new with Python and Django, well im learning Python using
Django... im php user and CodeIgniter Framework, so i want to know
something about admin generator...

What i need to make a User Panel (user will write article, upload
pictures, etc) ? or the samen Admin Generator will help me?


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

2009-06-15 Thread Daniel Roseman

On Jun 15, 3:20 pm, Genis Pujol Hamelink 
wrote:
> Hi list,
>
> I am trying to create a view to update objects in the db:
>
> http://dpaste.com/55546/
>
> but when posting the data, form.is_valid() fails because the object already
> exists in the db. Is there a way to validate a form using an existing object
> and then save it?
>
> regards,
>
> --
> Genís

Yes, pass the instance as a parameter to the form instantiation.
form = MyForm(instance=instance)
--
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: Problem to deploy on production server

2009-06-15 Thread Thomas Guettler

Hi,

do you use the cache module? Be sure, that both projects use
different ones.

Maybe you need to set SESSION_COOKIE_NAME if the domain name is the
same.

Do you use one database or two? (Is settings.DATABASE_NAME the same?)

  Thomas

Francis schrieb:
> Hi,
> 
> I have completed one web site and I am now ready to deploy it in
> production, but I have serious issues where I can't find any
> information/clue on the django web site, in the book or on IRC. I have
> no idea how I can solve my problem
> 
> What I want to achieve is the following:
> 1 site under http without admin acces
> 1 site under https + admin acces
> 
> My config
> python 2.5
> django 1.0.2
> postgresql
> mod_wsgi (i'm using it because djapian doesn't work with mod_python)
> 
> So what I did was to create two mod_wsgi on two project repositories.
> One configured with the admin apps installed (https) an one without
> (http).
> Results:
> When I save an entry to a model, it saves it and redirects to the non
> secure http service instead of the secure one, throwing a 404.
> 
> So I tried to enable the admin apps on both services.
> Results:
> Now I get a proxy error on the https service and a timeout on the http
> service.
> Some tables show no result on the http service but show them all on
> the other one.
> 
> If I shut down the https service, some entries can be saved and others
> don't.
> The same tables that wrongly display nothing are still empty.
> 
> I tried to give each site a different site_id, but it doesn't help.
> 
> Help would be very much appreciated,
> 
> Thank you
> 
> Francis


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



How to make the authorized cross-domain AJAX-requests with Django as AJAX-server backend?

2009-06-15 Thread Valery

Hi all,

the question is in subject. Details:

I have a server running my Django project. I'd like to add support for
authorized AJAX-queries to my site. That is, user opens a page on the
http://some-3rd-party-site.tld If HTML of the page will contain a
published by me JavaScript AJAX-snippet then my Django-site could be
requested for JSON. However, I'd like to reply to the authorized
surfers only. Say, for the first time the user is visiting
http://some-3rd-party-site.tld, here comes a pop-up and the users gets
authenticated by my Django server. The user continues to surf on
http://some-3rd-party-site.tld powered by AJAX-data from my Django
server.

Of course, I'd like very much to be kind to the user and let him/her
to do the queries from http://ANOTHER-3rd-party-site.tld and do it
*without* repeating the authentication against my Django-server.

The out-of-the-box authentication could hardly be used because the
pages from http://*-3rd-party-site.tld have their domains other than
my Django-site, so I should forget about cookies.

So, how to get through?

regards
Valery

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



form instance to update an object

2009-06-15 Thread Genis Pujol Hamelink
Hi list,

I am trying to create a view to update objects in the db:

http://dpaste.com/55546/

but when posting the data, form.is_valid() fails because the object already
exists in the db. Is there a way to validate a form using an existing object
and then save it?

regards,

-- 
Genís

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



Problem to deploy on production server

2009-06-15 Thread Francis

Hi,

I have completed one web site and I am now ready to deploy it in
production, but I have serious issues where I can't find any
information/clue on the django web site, in the book or on IRC. I have
no idea how I can solve my problem

What I want to achieve is the following:
1 site under http without admin acces
1 site under https + admin acces

My config
python 2.5
django 1.0.2
postgresql
mod_wsgi (i'm using it because djapian doesn't work with mod_python)

So what I did was to create two mod_wsgi on two project repositories.
One configured with the admin apps installed (https) an one without
(http).
Results:
When I save an entry to a model, it saves it and redirects to the non
secure http service instead of the secure one, throwing a 404.

So I tried to enable the admin apps on both services.
Results:
Now I get a proxy error on the https service and a timeout on the http
service.
Some tables show no result on the http service but show them all on
the other one.

If I shut down the https service, some entries can be saved and others
don't.
The same tables that wrongly display nothing are still empty.

I tried to give each site a different site_id, but it doesn't help.

Help would be very much appreciated,

Thank you

Francis

--~--~-~--~~~---~--~~
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: get all the comments from a user

2009-06-15 Thread Bastien

I was searching in the included template tags but obviously doing a
database search works very well:

Comment.objects.filter(user_name='myname')

thanks,
Bastien

On Jun 15, 3:09 pm, Bastien  wrote:
> Hi,
>
> with the django comments app how can I get all the comments form a
> given user?
>
> thanks,
> Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



get all the comments from a user

2009-06-15 Thread Bastien

Hi,

with the django comments app how can I get all the comments form a
given user?

thanks,
Bastien
--~--~-~--~~~---~--~~
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 loading MySQLdb module: libmysqlclient_r.so.16 - Help please

2009-06-15 Thread Adam Stein

LD_LIBRARY_PATH variable is the correct one to use when running from
your account (not to go into the discussion as to why some people think
LD_LIBRARY_PATH is evil), as evidenced when you run python on the
command line.

In the case of Django running through a web server, the web server is
not picking up the LD_LIBRARY_PATH setting you are using in your own
personal account.

The reason editing ld.so.conf works, is because you are globally setting
the library path to search.  Since ld.so.conf is a 'global' setting,
your Django application (python) picks it up from the system and finds
the library.

Another way (what I do) is to compile Python with the MySQL lib
directory (--with-libs configuration argument) so that Python can find
the library whenever it runs (no matter who's running it, me -- or the
web server).

On Sat, 2009-06-13 at 10:18 -0700, NoCleverName wrote:
> 
> This is the author again.  Of course, 10 minutes after I post a question, I
> find the solution.  (After hours of searching beforehand)
> 
> If anyone else has this problem, the solution for me was:
> 
> edit /etc/ld.so.conf
> add the line: /usr/local/mysql/lib
> 
> then run /etc/ldconfig
> 
> Fixed the problem right up.  No idea why or how this worked, but everything
> is working now.
> 
> 
> 
> NoCleverName wrote:
> > 
> > So I'm having an issue getting Django to work with MySQL.  After I log
> > into my Django site, I get the following error:
> > 
> > ImproperlyConfigured: Error loading MySQLdb module:
> > libmysqlclient_r.so.16: cannot open shared object file: No such file or
> > directory
> > 
> > The error is being thrown from
> > site-packages/django/db/backends/mysql/base.py line 13.
> > 
> > Unlike a lot of similar posts on the message board (I have searched), I
> > have MySQLdb installed.  The lines in question are just 'import MySQLdb as
> > Database' and the associated try/catch throwing the error.  When I run
> > python from a command line and type 'import MySQLdb' it imports just fine. 
> > I added to to the root's .bash_profile and the .bashrc of the 'mysql'
> > user.  The file definitely exists (in /usr/local/mysql/lib)
> > 
> > I used the variable LD_LIBRARY_PATH in the two profiles to make the
> > 'import MySQLdb' statement work, is that the correct environment variable?
> > 
> > As a note, I installed mysql from the .tar.gz files and MySQLpython from
> > the .tar.gz files as well.  I can't use any sort of package manager to
> > install this stuff.
> > 
> 
-- 
Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]


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



Unable to perform Search operation with the combination of two fields

2009-06-15 Thread diti

Hi,

I am Creating an application called 'Defect Tracking System'. My
models.py contain the three fields  namely- Defect ID, Defect Status
and Defect Reported By.
I have to perform search operation based on these three fields.
ie if I specify the Defect ID it should give me the details of that
particular defect ID. If I give Defect ID and Status then it should
give me the details of that particular defect.(ie the reported by
field).

I have to perform search operation with the combination of all these 3
fields.

I could perform search operation based on the 3 fields individually
but not with the combination of any two.

My views.py is as follows. this performs search operation based on the
Defect ID.

Please suggest how to perform search operation with the combination of
defect ID and Status field.

from django.http import HttpResponse
from django.shortcuts import render_to_response
from searchscreen.search.models import SearchScreen

def first_screen(request):
return render_to_response('first_screen.html')

def search_form(request):
return render_to_response('search_form.html')

def search(request):
errors = []
if 'q' in request.GET:
q = request.GET['q']
if not q:
errors.append('Enter a search term.')
elif len(q) > 20:
errors.append('Please enter at most 20 characters.')
else:
defectids = SearchScreen.objects.filter
(defect_id__icontains=q)
return render_to_response('search_results.html',
{'defectids': defectids, 'query': q})
return render_to_response('search_form.html',
{'errors': errors})
def search1(request):
return render_to_response('link.html')



Please reply as soon as possible.


Thanks & Regards
Diti Mansata

--~--~-~--~~~---~--~~
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: Possible memory leak moving to Django 1.1 from 1.0.2 in mixed use test.

2009-06-15 Thread proteusguy

After working through this I feel I need to follow through and
clarify what actually happened. As you say, Russ, there does not seem
to be any memory leak. However it is a lot fatter in it's memory
usage. I'm guessing this is due primarily to database caching. We will
be doing some capacity measurements to determine just what the
capacity impact is as we do have to reduce the number of simultaneous
processes we can launch to handle requests but, hopefully, the
increased memory usage comes with increased performance so less time
per request hopefully offsets and even improves our overall capacity.

This led me to believe that perhaps our postgres db library had an
issue but couldn't find anything pointing that direction and nothing
had changed in that regard. Finally, we discovered that the version of
mod_wsgi we were using had a known issue (
http://code.google.com/p/modwsgi/issues/detail?id=99&can=1&q=leak )
where it did not recover all its memory when apache was restarted. We
had actually eliminated immortal apache processes and had it
restarting quite often to offset the perceived memory leak - resulting
in actually introducing a memory leak on top of our increased memory
usage from Django 1.1. :-( Re-introducing immortal processes (albeit
fewer of them), got rid of the memory leak from restarts and then we
subsequently upgraded to the latest mod_wsgi (2.5) and the leak seems
to have disappeared.

Conclusion - so far no leaks known in Django 1.1 and it's working
fine in production now. It does use significantly more memory.

  thanx,

-- Ben


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



Looking for Django/Pinax developers to help finish project

2009-06-15 Thread Ole

Hi

We are a small open source company situated in Copenhagen, Denmark. We
are working on a web portal for an organisation for volunteers working
with young people with problems related to loneliness etc.

The portal is based on Pinax, Django and MySQL.

We have established the portal on this test site: 
http://web03.magenta-aps.dk:8001/

We still have some tasks and challenges and we would like some help to
solve these issues.

All tasks is described in details in this document:
http://magenta-aps.dk/misc/ventil_tasks_external.pdf

We can not pay a lot of cash for your assistance but we have some
small amounts at our disposal. The tasks are listed below.

If you want to help, please respond to us telling which task(s) you
want to work on and please also tell us what you want to charge (if
anything) and when you can complete the task. If you charge, we will
not be able to pay in advance - all payment is on delivery.

Do not hesitate to contact us if you have questions or want additional
information.

Kind regards,

Ole Hejlskov

--~--~-~--~~~---~--~~
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: What is available IN Django compared to other frameworks?

2009-06-15 Thread Olav

On Jun 14, 11:43 pm, Olav  wrote:
> On Jun 8, 5:37 pm, Necmettin Begiter 
> wrote:> On Mon, Jun 8, 2009 at 16:39, Olav wrote:
> I also objects objects like articles, comments, posts are Django
shoud be: I also THINK
Anyway, what I mean is that if users, articles, blog comments etc are
not "known" at a Django-level, you can't write plugables/modules to
handle them.
--~--~-~--~~~---~--~~
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: GHRML Documentation

2009-06-15 Thread gte351s

> It's a generic templating language, it's not particularly geared toward HTML.
> It's no HAML (you'll still get to write all the HTML yourself), but writing
> custom tags is much easier than with Django. Also, it compiles templates to
> Python code, which makes it reaaally fast.

fast is always good.

> The issue is that views of third-party apps will use Django's stock
> render_to_response, which will use Django's standard templating system,
> which will mean you'll get to maintain templates in two different templating
> languages.
>
> If you don't need third-party apps, this is not a problem (though it removes a
> lot of Django's appeal in my opinion).

Not sure yet, I'm just playing with it - but it's probably safe to
assume
I will someday in the future. Plus the GHRML page wasn't updated in
about 13
months... So it's probably dead.

Thanks,
Shilo.

--~--~-~--~~~---~--~~
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: can django add custom permission without module association?

2009-06-15 Thread andybak

I spotted this the other day: http://www.djangosnippets.org/snippets/334/

On Jun 15, 5:42 am, victor  wrote:
> can django add custom permission without module association?
> if can,how to?
> thx 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
-~--~~~~--~~--~--~---



How to access a form subfield? form design?

2009-06-15 Thread Bastien

Hi,

I have a multi choice field to choose 1 or many months in checkboxes:

in forms.py:
months_open = forms.MultipleChoiceField(choices = MONTH_LIST,
widget=forms.CheckboxSelectMultiple)

then in my template I use {{ form.months_open }} to make the list
appear. Now that works but the list appears as a raw list without
style so I would like to change the order of the months but don't know
how to access them. I tried things like {{ form.months_open.1 }} or
{{ form.months_open[0] }} , I tried a for loop to get what's inside
but there's nothing I can do.

Anybody can tell me how this works?
Thanks.
Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---