Re: Static content protection

2009-08-05 Thread Ronghui Yu
My solution now is enclosing the file with a HttpResponse and then return.
It is a bit slow.I wonder if we can create a Apache module(or module for
other server) to authenticate access to specific file. I don't have
experience on this.

On Thu, Aug 6, 2009 at 11:59 AM, Dj Gilcrease  wrote:

>
> On Wed, Aug 5, 2009 at 7:28 PM, TheIvIaxx wrote:
> >
> > Hello, I have a question that probably spans a few different groups.
> > However I know this setup is familiar withing the django community.
> >
> > I have apache handling all django/python stuff and have lighttpd
> > handling the static content.  All is well,works fine and fast.  Auth
> > is my problem on the static stuff.
> >
> > With django i can control auth with the built in auth middleware,
> > however anyone can just type in a url to a static image and get it.
> > Other than using directory auth on lighty or apache, how would you
> > control access to the static content without having the user enter
> > user/pass info every time them went to the site?
>
>
> For protected static files I actually consider them non static and use
> a model with a FileField to keep track of them, then a view to output
> them that has the @login_required decorator.
>
> http://dpaste.com/75843/
>
> you can even go so far as to create a tag library for it so it can be
> used to display in files inline not just for download.
>
> This does make things a little slower then just having them served
> directly, but if your site is for internal company use only the
> slowdown will be non-significant in my experiance
>
> >
>


-- 
===
Regards
Ronghui Yu

--~--~-~--~~~---~--~~
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 queryset based on when data created

2009-08-05 Thread Joru

Everytime I edit some data, the data order in queryset changed into
the newest edited
Is it posible to get queryset that ordered based when the data created
without having to add creation date for sorting purpose
--~--~-~--~~~---~--~~
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: Admin site images not coming up in 1.1

2009-08-05 Thread Joshua Partogi
On Thu, Aug 6, 2009 at 2:34 PM, emily wong  wrote:

>
> Thanks Malcolm, I've figured it out. There were some changes to the
> admin's index.html page. I've updated to the 1.1 one.
> All the best,
> Emily
>

How did you fix it? Because I experience the same thing too.

Regards,

-- 
http://blog.scrum8.com
http://twitter.com/scrum8

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



Re: Admin site images not coming up in 1.1

2009-08-05 Thread emily wong

Thanks Malcolm, I've figured it out. There were some changes to the
admin's index.html page. I've updated to the 1.1 one.
All the best,
Emily
--~--~-~--~~~---~--~~
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: Admin site images not coming up in 1.1

2009-08-05 Thread Malcolm Tredinnick

On Wed, 2009-08-05 at 21:09 -0700, emy_66 wrote:
> Hi,
> 
> Just migrating my application to 1.1. Everything works fine except the
> images inside the admin site are not showing up. Any ideas why this
> may be? Everything worked with 1.0.1 and 1.0.2 I think.

Remember that the admin images and CSS files are static data, so you
will have some extra configuration in place to serve those files (what
and where will depend on your particular server choices). Have you
changed things to point to the Django 1.1 admin media files instead of
the 1.0 versions?

Not sure if that will fix your problem or not. I haven't had any
particular problems moving projects to the new code, so I haven't seen
what you are seeing.

Regards,
Malcolm



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



Re: Admin site images not coming up in 1.1

2009-08-05 Thread emily wong

Also it's just the first page of the admin after I log in that the
stylesheet is not coming up. Other admin pages are displaying
correctly. I have changed in url.py the admin line to '(r'^admin/',
include(admin.site.urls)),' as recommended for 1.1
Emily




On Aug 6, 2:09 pm, emy_66  wrote:
> Hi,
>
> Just migrating my application to 1.1. Everything works fine except the
> images inside the admin site are not showing up. Any ideas why this
> may be? Everything worked with 1.0.1 and 1.0.2 I think.
>
> Thanks,
> Emily
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Admin site images not coming up in 1.1

2009-08-05 Thread emy_66

Hi,

Just migrating my application to 1.1. Everything works fine except the
images inside the admin site are not showing up. Any ideas why this
may be? Everything worked with 1.0.1 and 1.0.2 I think.

Thanks,
Emily
--~--~-~--~~~---~--~~
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: Static content protection

2009-08-05 Thread Dj Gilcrease

On Wed, Aug 5, 2009 at 7:28 PM, TheIvIaxx wrote:
>
> Hello, I have a question that probably spans a few different groups.
> However I know this setup is familiar withing the django community.
>
> I have apache handling all django/python stuff and have lighttpd
> handling the static content.  All is well,works fine and fast.  Auth
> is my problem on the static stuff.
>
> With django i can control auth with the built in auth middleware,
> however anyone can just type in a url to a static image and get it.
> Other than using directory auth on lighty or apache, how would you
> control access to the static content without having the user enter
> user/pass info every time them went to the site?


For protected static files I actually consider them non static and use
a model with a FileField to keep track of them, then a view to output
them that has the @login_required decorator.

http://dpaste.com/75843/

you can even go so far as to create a tag library for it so it can be
used to display in files inline not just for download.

This does make things a little slower then just having them served
directly, but if your site is for internal company use only the
slowdown will be non-significant in my experiance

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

2009-08-05 Thread alexarsh

If you want to see your app from another computer in local network,
you can run:
python manage.py runserver 0.0.0.0:8000

Regards, Alex A.

On Aug 5, 11:13 am, Salvatore Leone 
wrote:
> Graham Dumpleton ha scritto:> You must recompile mod_python to use a 
> different Python version.
> > Changing the symlink like that will not make a difference and you
> > could break other stuff on your system which assumed default Python is
> > a specific version.
>
> I know, and I didn't do it(I'm on Ubuntu a most application are in
> python and they expect 2.6 which is installed by default)> You should also 
> not go blindly changing permissions to 777 as that
> > makes it world writable which is bad practice and disastrous on a
> > shared host as other users can then change stuff in your directories.
> > Please go read documentation on file permissions on UNIX systems.
>
> I know that too. But I just want something for others than me to see the
> site. The "manage.py  runserver" isn't visible by other pc than mine
> (http://myhost:8000doesn't work).
>
> If I could use that server would not need apache at all.
>
> -Salvatore
--~--~-~--~~~---~--~~
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: syncdb does not find app on the PYTHONPATH

2009-08-05 Thread Kenneth Gonsalves

On Thursday 06 Aug 2009 8:45:59 am Matthew wrote:
> Just did - I got the same message:
> >>> c = coltrane.category()
>
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'module' object has no attribute 'category'

please give your model and the whole traceback

-- 
regards
kg
http://lawgon.livejournal.com

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



Re: Static content protection

2009-08-05 Thread theiviaxx

The only thing i can find right now is to deny access based on the
remote ip.  Not the best solution, but for internal it may work.
Filter with a regex possibly.

On Aug 5, 7:32 pm, Ronghui Yu  wrote:
> I have the similar problem. Could not find a good way either.
>
>
>
>
>
> On Thu, Aug 6, 2009 at 9:28 AM, TheIvIaxx  wrote:
>
> > Hello, I have a question that probably spans a few different groups.
> > However I know this setup is familiar withing the django community.
>
> > I have apache handling all django/python stuff and have lighttpd
> > handling the static content.  All is well,works fine and fast.  Auth
> > is my problem on the static stuff.
>
> > With django i can control auth with the built in auth middleware,
> > however anyone can just type in a url to a static image and get it.
> > Other than using directory auth on lighty or apache, how would you
> > control access to the static content without having the user enter
> > user/pass info every time them went to the site?
>
> > Thanks
>
> --
> ===
> Regards
> Ronghui Yu
--~--~-~--~~~---~--~~
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: syncdb does not find app on the PYTHONPATH

2009-08-05 Thread Matthew

Just did - I got the same message:

>>> c = coltrane.category()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'category'

Thanks,
Matthew

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



Re: Static content protection

2009-08-05 Thread Ronghui Yu
I have the similar problem. Could not find a good way either.

On Thu, Aug 6, 2009 at 9:28 AM, TheIvIaxx  wrote:

>
> Hello, I have a question that probably spans a few different groups.
> However I know this setup is familiar withing the django community.
>
> I have apache handling all django/python stuff and have lighttpd
> handling the static content.  All is well,works fine and fast.  Auth
> is my problem on the static stuff.
>
> With django i can control auth with the built in auth middleware,
> however anyone can just type in a url to a static image and get it.
> Other than using directory auth on lighty or apache, how would you
> control access to the static content without having the user enter
> user/pass info every time them went to the site?
>
> Thanks
> >
>


-- 
===
Regards
Ronghui Yu

--~--~-~--~~~---~--~~
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: Select Table or Database based on User

2009-08-05 Thread Javier Guerra

Wojciech Gryc wrote:
> Filtering by user ID each time would
> be extremely wasteful, would it not?

not with the right indexes.

-- 
Javier

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



A form that doesn't render.

2009-08-05 Thread cornjuliox

I've got this form that won't display at all. The page renders
properly, right up to the submit button, but the form isn't there and
neither is the error message "No comments to display". I've looked
over the view and everything looks fine, but it just doesn't work.
Could someone take a look at it? How are you supposed to debug
something that doesn't give you any error messages?

# VIEW
def fetch_individual_entry(request, slug):
# I'm gonna shove the comment logic in here somewhere.
error = False
no_comment = False
if request.method == 'POST':
# This means that the user clicked the 'submit' button on the
only
# form on this page. The comment entry form.
# Tie the form to the request data.
comment_form = CommentEntryForm(request.POST)
data = comment_form.cleaned_data
# Check its validity.
if comment_form.is_valid():
# Construct a dictionary of values to pass
user_values = {"parent"   : data["parent_entry"],
   "author_name"  : data["name"],
   "author_email" : data["email"],
   "subject"  : data["subject"],
   "body" : data["comment"],
   "author_ip": data["ip_address"],}
# Use that dictionary to create a comment!
Comment(**user_values).save()
# Otherwise...
page = Entry.objects.get(slug__exact=slug)
if not page:
error = True
return render_to_response(
'entry_page.html', {
'error' : error,
'slug'  : slug,
})
initial_data = {'ip_address': request.META["REMOTE_ADDR"],
'parent_entry': page.id,}
comment_form = CommentEntryForm(initial=initial_data)

# Get the comments for the currently selected entry.
comment_list = Comment.objects.filter(parent=page.id)
if len(comment_list) == 0:
no_comment = True

return render_to_response(
'entry_page.html', {
'commentForm': comment_form,
'commentList': comment_list,
'noComments' : no_comment,
'x'  : page,
})


# TEMPLATE
{% extends "base.html" %}
{% block content %}


Title:
{{ x.title }}

Date: {{ x.dateTime|date }}
Time: {{ x.dateTime|time }}
Subject: {{ x.subject }}

{{ x.content|safe }}

{% for comment in commentList %}
{% if not comment %}
No comments to display
{% endif %}

Name: {{ comment.author_name }}
Subject: {{ comment.subject }}
Submitted on: {{ comment.submission_dateTime }}
Body: {{ comment.body }}

{% endfor %}


{{ commentForm.as_ul }}





{% endblock %}

# MODEL
class Comment(models.Model):
parent = models.ForeignKey(Entry)
author_name = models.CharField(max_length=100)
author_email = models.EmailField(max_length=100)
subject = models.CharField(max_length=120, blank=True)
body = models.TextField(max_length=3000)

author_ip = models.IPAddressField()
submission_dateTime = models.DateTimeField(auto_now=True)
is_public = models.BooleanField(default=False)
is_removed = models.BooleanField(default=False)

class Meta:
ordering = ['submission_dateTime']

def __unicode__(self):
return author_name + submission_dateTime

# FORM
class CommentEntryForm(forms.Form):
# Comment form won't render properly. Don't know why, yet.
parent_entry = forms.ModelChoiceField(Entry)
name = forms.CharField(label="Name:")
email = forms.EmailField(label="E-mail Address:")
subject = forms.CharField(label="Subject:", max_length=75)
comment = forms.CharField(label="Comment",widget=forms.Textarea,
  max_length=MAX_COMMENT_LENGTH)
honeypot = forms.CharField(required=False, label="This field is
not required.",
   widget=forms.HiddenInput)
ip_address = forms.IPAddressField(widget=forms.HiddenInput)

def clean_honeypot(self):
# The honeypot is supposed to be _empty_
value = self.cleaned_data['honeypot']
if value:
raise forms.ValidationError(self.fields['honeypot'].label)
return value

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" 

Static content protection

2009-08-05 Thread TheIvIaxx

Hello, I have a question that probably spans a few different groups.
However I know this setup is familiar withing the django community.

I have apache handling all django/python stuff and have lighttpd
handling the static content.  All is well,works fine and fast.  Auth
is my problem on the static stuff.

With django i can control auth with the built in auth middleware,
however anyone can just type in a url to a static image and get it.
Other than using directory auth on lighty or apache, how would you
control access to the static content without having the user enter
user/pass info every time them went to the site?

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



Get current user outside a view / without an request object

2009-08-05 Thread Julián C . Pérez

Hi everyone
I'm in trouble because of a form class
I have a form class with attributes defined, but with one thing:
One of the attributes requires the current user, or al least its
username

The form definition in as shown below:
---
class SendMessageForm(forms.Form):
recipientUser = ShowValidContactList(label=u'Send to')
messageSubject= forms.CharField(label=u'Subject')
messageContent = forms.CharField(label=u'Content',
widget=forms.Textarea())
---

As you can tell I'm trying to make a 'Send message' form to make
message sending available in my project... but the recipient user must
be in the contacts list of the current user...
The 'recipientUser' field is a ShowValidContactList
(forms.ModelChoiceField) instance... so it works with a fixed queryset
based on that user (the currently logged-in one)

My problem is that... how can I get the current user information
outside a view and without request objects??
Or... how can I make that form works with a different approach??


Any help would be appreciate!
--~--~-~--~~~---~--~~
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: building directory path with user table

2009-08-05 Thread neridaj

I've revised my code but files are still getting uploaded to the
'listings' directory.

class Listing(models.Model):
user = models.ForeignKey(User)
zipfile = models.FileField(upload_to='listings')
name = models.CharField(max_length=50)
order = models.ForeignKey('Order')

def overwrite_upload_to(self):
user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings',
self.user.username)
self.zipfile.url=user_dir_path

def save(self, force_insert=False, force_update=False):
Listing.overwrite_upload_to(self)
super(Listing, self).save(force_insert, force_update) # Call
the "real" save() method.

def __unicode__(self):
return self.name

On Jul 22, 10:59 pm, neridaj  wrote:
> I'm new to django and not sure how to do this, is this remotely close?
>
> class Listing(models.Model):
>     user = models.ForeignKey(User, unique=True)
>     zipfile = models.FileField(upload_to='listings')
>     name = models.CharField(max_length=50)
>     order = models.ForeignKey('Order')
>
>     def save(self, user=user):
>         user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings',
> user)
>         zipfile.upload_to=user_dir_path
>
>     def __unicode__(self):
>                 return self.name
>
> On Jul 18, 5:20 am, Eugene Mirotin  wrote:
>
> > What you have written (this join for user_dir_path) is evaluated only
> > once on model class creation, but what you need is evaluating it for
> > each specific object.
>
> > I recommend you overloading the model save method to alter the image
> > save path.
>
> > On Jul 17, 10:44 am, "neri...@gmail.com"  wrote:
>
> > > Hello,
>
> > > I'm trying to build a photo upload path which corresponds to the
> > > selected user i.e., when the user is selected from the drop down the
> > > username gets appended to the file upload path dynamically. If you
> > > have any ideas I would like to hear them:
>
> > > class Listing(models.Model):
> > >         user = models.ForeignKey(User, unique=True)
> > >         user_directory_path = os.path.join(settings.MEDIA_ROOT, 
> > > 'listings',
> > > user)
> > >         user_directory = models.FilePathField(path=user_directory_path,
> > > recursive=True)
> > >         photo = models.ImageField(upload_to=user_directory)
> > >         name = models.CharField(max_length=50)
> > >         order = models.ForeignKey('Order')
>
> > >         def __unicode__(self):
> > >                 return self.name
>
> > > I keep getting this error:
>
> > > AttributeError: 'ForeignKey' object has no attribute 'startswith'
--~--~-~--~~~---~--~~
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: syncdb does not find app on the PYTHONPATH

2009-08-05 Thread Kenneth Gonsalves

On Thursday 06 Aug 2009 4:08:03 am Matthew wrote:
> Thank you again for your help!

maybe it is 'category' with a small 'c'
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: checking if db schema and model match

2009-08-05 Thread kmike

That's a question about database migration. Django doesn't have built-
in solution for that.
Try using South (http://bitbucket.org/andrewgodwin/south/overview/),
it is a very good db migration app. I suggest using development
version because (based on my experience) it is more robust than last
official release (0.5).

On 5 авг, 18:28, Sam Lai  wrote:
> I hope this hasn't been asked before; had a quick look through the
> archives and docs but couldn't find anything.
>
> Is it possible to get django (e.g. via manage.py) to CHECK if the db
> schema and model match? I don't want it to change anything, just to
> tell me if there is a mismatch, and what that is.
>
> I thought syncdb did this, but it doesn't seem to. I think this would
> be quite useful to have, and could pre-empt errors later on when
> non-existent fields are used in views etc.
>
> Sam
--~--~-~--~~~---~--~~
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 Django user: best way to load/verify/update/create data from a csv file

2009-08-05 Thread Glaskows

Hi,

 I need to do the following thing:
- form where the user select a csv file (done)
- load a view where the file is loaded and parsed (done)

 (from now on I am having doubts of the proper solution)

- present to user a page where there are three list:
 1) data entries with errors (missing o incorrect values)
 2) data entries which exist in the DB, but with different values.
 3) data entries which doesn't exist in the DB.

 In the 2nd list there will be checkboxes for each entry, if this are
checked, then the entry is updated.
 In the 3rd list there'll be also checkboxes, but this time, checking
means create a new entry.

- after pressing the "accept" button (the user should be already tired
of pressing checkboxes) we present him a new "resume" page, where we
display two list (one with accepted operations and another with
canceled ones).

- after pressing the last "accept" we redirect the user to the initial
"load file" screen with a SUCCESS message.

One solution is generating the forms in one view's method, and in
other view a method for parsing the forms (looking for checked
checkboxes and alike). The 1,000,000 million question is how much of
this is already done in django API or if there is another approach,
like using some class of the Form family or some magic generic view.

Thanks for the help,
  I am really enjoying moving from Joomla.

 George Laskowsky Ziguilinsky

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



Announce: django-ldap-groups

2009-08-05 Thread Peter Herndon

I'm pleased to announce the release of django-ldap-groups.  Of special 
interest for building intranet sites, django-ldap-groups allows Django 
users to authenticate against LDAP, and allows site administrators to 
map LDAP organizational units (OUs) to Django groups.  This mapping 
allows LDAP-authenticated users to acquire site permissions based on 
their LDAP OU membership, automatically when they first log in to the 
Django site. The app is available at 
http://code.google.com/p/django-ldap-groups/, and is BSD licensed.

Currently the app has been tested and works against Microsoft Active 
Directory and Novell eDirectory.  Other LDAP servers will probably work 
using the eDirectory backend, but none have been tested at the time of 
writing.

Please let me know if you have any questions or comments.

Regards,

---Peter Herndon

--~--~-~--~~~---~--~~
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: multiple projects shared database

2009-08-05 Thread Malcolm Tredinnick

On Wed, 2009-08-05 at 17:59 +0100, Robin Becker wrote:
> My boss wants to have two different django controlled websites with a common 
> database. Is there a way to do this?
> 
> We are already running multiple websites into a single django project and 
> because they have a disambiguating term in the urls eg each url has 
> /lang/brand/path we can map the URLs pretty well.
> 
> With the multiple django projects & 1 database I am worried there are some 
> hidden problems waiting to come out and play.

The only potential problem is the content types. There are entries in
the content types table for each model and it needs to contain
information about all the models. So be careful when you're running
syncdb.

What you're trying to do here is not dissimilar to just using different
settings files for the same database, as in this tip:
http://www.pointy-stick.com/blog/2009/03/26/django-tip-controlling-admin-or-other-access/

On the other hand, if the two websites are entirely independent, putting
them into a single database is simply poor design. It's trivial to
create a separate database and why not use the tools that are available
instead of adding extra complexity?!

Regards,
Malcolm



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



Re: Practical Django Projects Chp. 3: TinyMCE won't appear in admin

2009-08-05 Thread Matthew

It looks like you have 2 slashes on the line for tiny_mce.js:



...should read:




Hopefully that's it.

I'm on Chapter 4 and stuck:
http://groups.google.com/group/django-users/browse_thread/thread/db2b3bd39a2525fc

Let me know if you have the same problem or can help out when you get
there  :-)

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



Re: Touch django.wsgi not reloading daemon

2009-08-05 Thread Graham Dumpleton



On Aug 6, 7:53 am, Sean Kemplay  wrote:
> You are correct - it actually didn't work - it just seemed to.
>
> The issue was resolved by installing the latest version of mod_wsgi
> from source - I am using ubuntu hardy server edition.
>
> I uninstalled, installed from source, enabled the module using the
> original ubuntu config files that were left behind by apt and all is
> now fine.  I did notice in my apache logs that mod_wsgi was compiled
> against python 2.5.1 and that python 2.5.2 was installed on my system
> - I am not sure if that contributed.

The version mismatch is only an issue if your Python installation
doesn't provide a usable shared library for Python in the correct
location that could be found. See:

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

Loading of mod_python in same Apache can also be a problem if
mod_python compiled against different version and mod_python linked
library statically but mod_wsgi was using shared library. Where static
versus shared is the issue, usually causes crashes rather than
unexpected behaviour.

Graham

> The config files needed no change.
>
> Thanks,
> Sean
>
> On Aug 5, 10:20 pm, Graham Dumpleton 
> wrote:
>
>
>
> > On Aug 5, 11:12 pm, Sean Kemplay  wrote:
>
> > > Hi all.
>
> > > I have resolved this by adding user=www-data group=www-data to the
> > > WSGIDaemonProcess:
>
> > > WSGIDaemonProcess sean75_ispy user=www-data group=www-data
>
> > That change shouldn't have made any difference as those are the
> > defaults for user/group anyway and so aren't required. You only need
> > to supply those options if you want to override what the Apache
> > defaults are.
>
> > Unfortunately a lot of blog posts show the use of those options with
> > same credentials as Apache. It is just a waste of time to do it.
>
> > Best to have just worked through:
>
> >  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
>
> > and double check that where you were placing your configuration was in
> > fact actually resulting in daemon mode being used, as touching the
> > WSGI script file only works for daemon mode.
>
> > Graham
>
> > > Regards,
> > > Sean
>
> > > On Aug 5, 1:46 pm, Sean Kemplay  wrote:
>
> > > > Hi All,
>
> > > > I have the following in my virtual host config:
>
> > > > WSGIDaemonProcess sean75_ispy
> > > > WSGIProcessGroup sean75_ispy
>
> > > > and the following in my django.wsgi:
>
> > > > import os, sys
> > > > sys.path.append('/srv/home/sean75/django/')
> > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'ispy.settings'
> > > > import django.core.handlers.wsgi
> > > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > > Everything is working as expected except reloading the daemon.
>
> > > > When I try touch /srv/home/sean75/django/ispy/apache/django.wsgi it
> > > > does not reload and any changes I have made d not show up.
>
> > > > When I run apache2ctl restart, the changes show up.
>
> > > > Has anyone else experienced this?
>
> > > > Regards,
> > > > Sean
--~--~-~--~~~---~--~~
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: Select Table or Database based on User

2009-08-05 Thread Maksymus007

On Thu, Aug 6, 2009 at 12:38 AM, Wojciech Gryc wrote:
>
> Thanks for your replies!
>
> The problem with storing the user ID for each table and then filtering
> by the ID is that once the data set grows very large, this will become
> extremely slow (as far as I understand).
>
> I expected to have about 2000 pieces of information per user, with
> several dozen users (at least). Filtering by user ID each time would
> be extremely wasteful, would it not?

I think it really depends on database - however such a simple
operation like filtering based on indexed field shouldn't take much
resources .
How about database views?
Several dozens of users means several dozens * number of content types tables...

--~--~-~--~~~---~--~~
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 specify site's domain dynamically in development environment

2009-08-05 Thread Margie

My app needs to create a public url for its objects in order to send
that out via email.  My code does this by prefixing site.domain to the
relative portion of the url.  When working in my development
environment (using runserver), the machine I am running the server on
frequently changes.   I was thinking of putting some code into
admin.py that figures out the ip address and the port on the fly and
creates a Site object from that.  I can get from ip address via
socket.gethostbyname(), but I'm not sure how to identify the port I am
running on.  Is there any way to get that information from the
development server?

Is there some typical way that folks handle this?

Margie

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



Re: syncdb does not find app on the PYTHONPATH

2009-08-05 Thread Matthew

I tried what you asked, and found no errors when importing, but errors
when I tried to use the imported class.  It seems as though it finds
'coltrane', but can't find the models in the app.  Here is the
result:

python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import coltrane
>>> from coltrane import *
>>> c = coltrane.Category()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'Category'
>>> c = Category()
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'Category' is not defined
>>>

Here is the class in my models.py file.  I should also note that this
code WORKED with syncdb at first, then starting failing later:

import datetime

from django.db import models
from django.contrib.auth import User

from markdown import markdown
from tagging.fields import TagField

class Category(models.Model):
title = models.CharField(max_length=250,
 help_text='Maximum 250 characters.')
slug = models.SlugField(unique=True,
help_text="Suggested automatically from
the title. Must be unique.")
description = models.TextField()

class Meta:
ordering = ['title']
verbose_name_plural = "Categories"

def __unicode__(self):
return self.title

def get_absolute_url(self):
return "/categories/%s" % self.slug


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



Re: Select Table or Database based on User

2009-08-05 Thread Wojciech Gryc

Thanks for your replies!

The problem with storing the user ID for each table and then filtering
by the ID is that once the data set grows very large, this will become
extremely slow (as far as I understand).

I expected to have about 2000 pieces of information per user, with
several dozen users (at least). Filtering by user ID each time would
be extremely wasteful, would it not?

Thanks,
Wojciech
--~--~-~--~~~---~--~~
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: adapt admin interface

2009-08-05 Thread Peter Herndon

On 08/05/2009 03:36 PM, sveri wrote:
> Hi,
>
> i wonder if it is possible to change the admin interface of an app
> like that:
>
Yes, it is very possible.

> Now i go to the admin interface of Entries and want to add a new
> Entry.
> Then i select a party for the new entry.
> After having that selected i want to reload the form ajax like
> and show only the politicians that belong to that specific selected
> party.
>
One way to do this would be to override the admin template for the 
change_form.html for your model, and add the necessary Javascript to it 
to do what you need.  You will likely need to create a view for your app 
that performs the querying for your Ajax request, but you'd write the 
view like you would any other, and you'd just override the admin 
template to include the Javascript that calls to your view and parses 
the response.

Overriding the admin templates documentation is here:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

Hope that helps,

---Peter

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



Re: cache and multple languages

2009-08-05 Thread kmike

Hi,
I've recently create an app for advanced view caching. It allow pages
to be cached based on anything in request, specific cookies for
example.
Please check http://bitbucket.org/kmike/django-view-cache-utils/wiki/Home

If you have any questions about it feel free to ask.

On 5 авг, 20:11, cwurld  wrote:
> Hi,
>
> I have been successfully running a multi-language site for a while
> now. The users language pref is stored (along with other data) in a
> cookie.
>
> Recently, I have been trying to cache some of the more common and
> processor intensive views. Since the language code is not in the url,
> I can't figure out how to cache pages based on language.
>
> I looked in to the vary_on_header decorator, but I do not see how to
> get that to work since the cookies vary on lots of stuff in addition
> to language and I doubt I can get my users to change the Accept-
> Language attribute in the request header.
>
> Any ideas?
>
> Thanks,
> Chuck

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



Practical Django Projects Chp. 3: TinyMCE won't appear in admin

2009-08-05 Thread Jeff

I have installed TinyMCE to my machine but I cant get it to appear in
my admin screen. I am working through "Practical Django Projects" by
James Bennett chapter 3. I am using windows not Linux so sometimes my
errors are simply forward vs. backwards slashes but it doesn't appear
to be the issue this time.


Here is my urls.py file

from django.conf.urls.defaults import *

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

urlpatterns = patterns('',
# Example:
# (r'^cms/', include('cms.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
(r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
  { 'document_root': 'C:/cms/tinymce/jscripts/
tiny_mce' },),
(r'', include('django.contrib.flatpages.urls'))
)

Here is my change_form.html

{% extends "admin/base_site.html" %}
{% load i18n admin_modify adminmedia %}

{% block extrahead %}{{ block.super }}

{{ media }}


tinyMCE.init({
  mode: "textareas",
  theme: "simple"
});

...

TinyMCE is here: C:\cms\tinymce\jscripts\tiny_mce\tiny_mce.js
Change_form is her: C:\cms\templates\admin\flatpages\flatpage
\change_form.html

--~--~-~--~~~---~--~~
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: Touch django.wsgi not reloading daemon

2009-08-05 Thread Sean Kemplay

You are correct - it actually didn't work - it just seemed to.

The issue was resolved by installing the latest version of mod_wsgi
from source - I am using ubuntu hardy server edition.

I uninstalled, installed from source, enabled the module using the
original ubuntu config files that were left behind by apt and all is
now fine.  I did notice in my apache logs that mod_wsgi was compiled
against python 2.5.1 and that python 2.5.2 was installed on my system
- I am not sure if that contributed.

The config files needed no change.

Thanks,
Sean

On Aug 5, 10:20 pm, Graham Dumpleton 
wrote:
> On Aug 5, 11:12 pm, Sean Kemplay  wrote:
>
> > Hi all.
>
> > I have resolved this by adding user=www-data group=www-data to the
> > WSGIDaemonProcess:
>
> > WSGIDaemonProcess sean75_ispy user=www-data group=www-data
>
> That change shouldn't have made any difference as those are the
> defaults for user/group anyway and so aren't required. You only need
> to supply those options if you want to override what the Apache
> defaults are.
>
> Unfortunately a lot of blog posts show the use of those options with
> same credentials as Apache. It is just a waste of time to do it.
>
> Best to have just worked through:
>
>  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
>
> and double check that where you were placing your configuration was in
> fact actually resulting in daemon mode being used, as touching the
> WSGI script file only works for daemon mode.
>
> Graham
>
> > Regards,
> > Sean
>
> > On Aug 5, 1:46 pm, Sean Kemplay  wrote:
>
> > > Hi All,
>
> > > I have the following in my virtual host config:
>
> > > WSGIDaemonProcess sean75_ispy
> > > WSGIProcessGroup sean75_ispy
>
> > > and the following in my django.wsgi:
>
> > > import os, sys
> > > sys.path.append('/srv/home/sean75/django/')
> > > os.environ['DJANGO_SETTINGS_MODULE'] = 'ispy.settings'
> > > import django.core.handlers.wsgi
> > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > Everything is working as expected except reloading the daemon.
>
> > > When I try touch /srv/home/sean75/django/ispy/apache/django.wsgi it
> > > does not reload and any changes I have made d not show up.
>
> > > When I run apache2ctl restart, the changes show up.
>
> > > Has anyone else experienced this?
>
> > > Regards,
> > > Sean
--~--~-~--~~~---~--~~
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: Simultaneous use of the admin interface

2009-08-05 Thread David

> 1) sign into admin as user A in one browser and begin to edit a record
> 2) sign into admin as user B in another browser and begin to edit the
> SAME record

To clarify, both users have their browsers pointing at the editing
form for the same instance of the same model, e.g.:
http://example.com/admin/myproject/mymodel/1

--~--~-~--~~~---~--~~
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: Simultaneous use of the admin interface

2009-08-05 Thread David



On Aug 5, 5:21 pm, Margie  wrote:
>   I think
> that when fields became editable in 1.1, this was not handled and
> needs to be adressed in order for multiple people to modify at once.
>

Thanks Margie. I wasn't referring to list_editable though, but perhaps
the problem is the same?

--~--~-~--~~~---~--~~
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: default blank choice on form.Form select widget

2009-08-05 Thread jheasly

Hey Paulo,

No I hadn't seen the ticket. Thanks for the heads up.

Hard to tell from Trac what is holding up 4092. I see 10969 is more
recent, but a different angle of attack on the issue.

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



Re: Select Table or Database based on User

2009-08-05 Thread Paulo Almeida
Yeah, the way I do that is have a foreign key with the user in the table
with private data and then filter by user when retrieving data in the view.

On Wed, Aug 5, 2009 at 10:11 PM, Maksymus007  wrote:

>
> >
> > Hi everyone,
> >
> > I'm sure this has come up in the past, but I sincerely can't find it
> > in any of the Django tutorials, documentation, or websites. I
> > apologize in advance if I missed something!
> >
> > I'm trying to develop a website where different users store their own
> > sets of contacts / articles / etc. If a user logs in, I only want them
> > to have access to their own articles or contacts. As such, I'm
> > thinking that storing each individual user's data in their own table
> > is the way to go.
> >
> > However, my question is: how do I actually have Django select the
> > proper table? The models and views stay the same, but I need to make
> > sure that, given a user name, Django selects the proper table(s).
> >
> > Is there a tutorial on this? A link? Any advice would be appreciated.
> >
> > Thanks,
> > Wojciech
>
> and why not to just store user_id column for each table?
> Tylko jak to django adminowi powiedzieć...
>
> >
>

--~--~-~--~~~---~--~~
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/ Python 3 - nervous about starting large project

2009-08-05 Thread Wayne Koorts

Hi Tony,

> However, I'm nervous about the Python 3 situation.  What if I start
> building a large project based on Django/Python 2.6, and then a year
> or two down the road the project starts limping because of all of the
> cool new Python 3 modules coming out?  And I've got a bunch of Django/
> Python 2.6 code that needs to be ported?

First of all, welcome to the Python world, we'll do our best to make
you feel comfortable here.

You'll find that the Python crowd is very good at supporting legacy
versions.  You'll see that you can even still download [1] Python
1.5.2 (April 1999!).  That's not to say that your favourite libraries
will be available for such old versions, but many libraries still make
releases for at least as far back as Python 2.3.  Also, I don't think
you'll find that Python 3.x will introduce anything so radically new
and innovative that it will severely limit what you can accomplish
with older releases.  I'm working on a team starting a new (large)
project now which we are basing around Python 2.5.

Remember that Python has been around for a long time, since 1991, and
releases like 2.5, 2.6 etc. are extremely mature and by now all of the
common programming problems have already been encountered, solved and
accomodated in the core and standard libraries.

If you do decide to port your application to 3.x (think very carefully
about it first - make sure that any of the associated libraries you
require have mature 3.x releases) there are tools available to make
the job a lot easier, like the 2to3 [2] script.

[1] http://www.python.org/download/
[2] http://www.python.org/doc/2.6/library/2to3.html

HTH,

Regards,
Wayne Koorts
http://www.wkoorts.com

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



Re: Simultaneous use of the admin interface

2009-08-05 Thread Margie

I posted this same issue to the issue tracker a couple months ago,
here is the report:

http://code.djangoproject.com/ticket/11313

I do believe this is a shortcoming of the admin interface.  I think
that when fields became editable in 1.1, this was not handled and
needs to be adressed in order for multiple people to modify at once.

Currently the changelist is imlemented such that the ids of the forms
in the changelist are just numerically ordered (first form is 1,
second is 2, etc).  Thus, if the database changes under you, when you
then save your data, the forms that are generated (which are the
result of a filter based on your current filter params) do not have
the same numbering as the forms you just posted.  This just doesn't
work.

I think that instead the implementation needs to be changed so that
when an edited changelist is posted, each form carries with it the id
of the object that it is for.  Then, instead of filtering when the
POST is received, the code needs to just extract the ids and use those
as the queryest.

This may be more detail than anyone wants - but I figured I'd post it
just in case.  In my own app, which has a lot of similarites to the
admin app, I have done what I described above, and for me it has
worked well.

Margie

On Aug 5, 12:06 pm, David  wrote:
> Using Django 1.1 if I do:
>
> 1) sign into admin as user A in one browser and begin to edit a record
> 2) sign into admin as user B in another browser and begin to edit the
> SAME record
> 3) make a change as user A and press Save
> 4) make a different change as user B and press Save
>
> The result is that A's change is silently overwritten with user B's
> change.
>
> How do I make it so that user B gets an error telling them the record
> has been changed by someone else since they started editing it? That's
> what I would have expected to be the default behaviour.
>
> I did some searching of the documentation but didn't find anything
> obviously related. I also looked here at past posts and saw some
> people asking similar questions but no obvious solutions. There was
> some talk of adding SELECT FOR UPDATE functionality to Django 1.1, but
> I don't know if that made it in, or how to use it if it did.
>
> Can I perhaps add hooks to save a copy of the model object at the HTTP
> GET time, and at HTTP POST pull another copy of the model back from
> the db (distinct from the copy that is about to be saved) and compare
> to the previous one from the HTTP GET then error if they're different?
--~--~-~--~~~---~--~~
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: Touch django.wsgi not reloading daemon

2009-08-05 Thread Graham Dumpleton



On Aug 5, 11:12 pm, Sean Kemplay  wrote:
> Hi all.
>
> I have resolved this by adding user=www-data group=www-data to the
> WSGIDaemonProcess:
>
> WSGIDaemonProcess sean75_ispy user=www-data group=www-data

That change shouldn't have made any difference as those are the
defaults for user/group anyway and so aren't required. You only need
to supply those options if you want to override what the Apache
defaults are.

Unfortunately a lot of blog posts show the use of those options with
same credentials as Apache. It is just a waste of time to do it.

Best to have just worked through:

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

and double check that where you were placing your configuration was in
fact actually resulting in daemon mode being used, as touching the
WSGI script file only works for daemon mode.

Graham

> Regards,
> Sean
>
> On Aug 5, 1:46 pm, Sean Kemplay  wrote:
>
>
>
> > Hi All,
>
> > I have the following in my virtual host config:
>
> > WSGIDaemonProcess sean75_ispy
> > WSGIProcessGroup sean75_ispy
>
> > and the following in my django.wsgi:
>
> > import os, sys
> > sys.path.append('/srv/home/sean75/django/')
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'ispy.settings'
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > Everything is working as expected except reloading the daemon.
>
> > When I try touch /srv/home/sean75/django/ispy/apache/django.wsgi it
> > does not reload and any changes I have made d not show up.
>
> > When I run apache2ctl restart, the changes show up.
>
> > Has anyone else experienced this?
>
> > Regards,
> > Sean
--~--~-~--~~~---~--~~
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: Memory error

2009-08-05 Thread Peter Herndon

On 08/05/2009 04:09 PM, drakkan wrote:
> The code is something like this
>
> obj=DBModels.objects.filter(somefilter)
> results=[]
> for o in obj:
>results.append({'field1':o.field1,'field2':o.field2})
>
> return JsonResponse(results)
>
> where JsonResponse is a class derived from HttpResponse that add a
> simplejson.dumps
>
> I have a really large database and in some edge case I need to return
> a large number of results (about 150.000 when I get the error). I make
> only one query with select_related and I tried also with DEBUG=False
> but nothing changed only the detailed stack trace isn't printed,
>
> thanks
> drakkan
>
Hi drakkan,

Your code:

results=[]
for o in obj:
   results.append({'field1':o.field1,'field2':o.field2})

is building a list in memory.  Chances are, with 150k+ objects, that's 
where you are running into the memory issue.  That's a big list!

A couple of possibilities come to mind.  First, have you looked into 
using a values query?  You may be able to avoid building the list 
entirely.  The relevant documentation is here:

http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields

and the syntax would be something like this:

results = DBModels.objects.filter(somefilter).values('field1', 'field2')

At which point, results is basically this:

[{'field1':o1.field1, 'field2':o1.field2}, {'field1':o2.field1, 
'field2':o2.field1}, ...]

but it's a lazy iterator rather than an in-memory list.

Another thing that comes to mind is using Django's built-in serializers, 
which will take your filtered QuerySet, a tuple of fields, and serialize 
to JSON for you.  Docs are here:
http://docs.djangoproject.com/en/dev/topics/serialization/#topics-serialization

Hope that helps,

---Peter

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



Re: Django/ Python 3 - nervous about starting large project

2009-08-05 Thread Berco Beute

No worries, Python 2.6 will be actively supported for many, many years
to come and the differences between 2.6 and 3 are not that huge. You
can program for 2.6 while keeping in mind the code will be ported to 3
one day. It'll make a shift a breeze.

2B

On Aug 5, 10:47 pm, snfctech  wrote:
> Hello.
>
> We are researching technologies to begin what may become a pretty
> large intranet Dashboard project.
>
> I'm a PHP developer, so the fact that Django uses Python doesn't give
> me a head-start - but I've been wanting to consider it, because I am
> interested in learning Python.
>
> However, I'm nervous about the Python 3 situation.  What if I start
> building a large project based on Django/Python 2.6, and then a year
> or two down the road the project starts limping because of all of the
> cool new Python 3 modules coming out?  And I've got a bunch of Django/
> Python 2.6 code that needs to be ported?
>
> Any tips would be greatly appreciated.  Thanks.
>
> Tony
--~--~-~--~~~---~--~~
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: Multiple instances of the same form on one page: how to get the right POST data?

2009-08-05 Thread Maksymus007

On Wed, Aug 5, 2009 at 11:16 PM, Berco Beute wrote:
>
>> You forgot to set the prefix here, so the form that the user is
>> submitting their data from doesn't have the fields named correctly. You
>> need to set it up exactly the same way at this point as you did in the
>> POST path, with the exception of not prepopulating with data.
>
> Thanks, the missing prefix was indeed one issue, although
> prepopulating with data is not a problem. It didn't solve the problem
> though. The problem arises from the fact that I'm rendering multiple
> forms, but the user is POSTing back only one form. Each form has it's
> own submit field. How do I know which form was submitted? I've tried
> stripping the prefix from the subitted form, but that felt kind of
> hacky (and didn't really work).
>

how about hidden input?

--~--~-~--~~~---~--~~
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: Multiple instances of the same form on one page: how to get the right POST data?

2009-08-05 Thread Berco Beute

> You forgot to set the prefix here, so the form that the user is
> submitting their data from doesn't have the fields named correctly. You
> need to set it up exactly the same way at this point as you did in the
> POST path, with the exception of not prepopulating with data.

Thanks, the missing prefix was indeed one issue, although
prepopulating with data is not a problem. It didn't solve the problem
though. The problem arises from the fact that I'm rendering multiple
forms, but the user is POSTing back only one form. Each form has it's
own submit field. How do I know which form was submitted? I've tried
stripping the prefix from the subitted form, but that felt kind of
hacky (and didn't really work).

> Also, you've almost certainly left off an "else" clause here. You only
> want to create new, empty forms if the method is not POST (you can fall
> through to this point with request.method == "POST" and one of the forms
> being invalid).

You are absolutely right, I added that. Thanks.

2B
--~--~-~--~~~---~--~~
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: Select Table or Database based on User

2009-08-05 Thread Maksymus007

>
> Hi everyone,
>
> I'm sure this has come up in the past, but I sincerely can't find it
> in any of the Django tutorials, documentation, or websites. I
> apologize in advance if I missed something!
>
> I'm trying to develop a website where different users store their own
> sets of contacts / articles / etc. If a user logs in, I only want them
> to have access to their own articles or contacts. As such, I'm
> thinking that storing each individual user's data in their own table
> is the way to go.
>
> However, my question is: how do I actually have Django select the
> proper table? The models and views stay the same, but I need to make
> sure that, given a user name, Django selects the proper table(s).
>
> Is there a tutorial on this? A link? Any advice would be appreciated.
>
> Thanks,
> Wojciech

and why not to just store user_id column for each table?
Tylko jak to django adminowi powiedzieć...

--~--~-~--~~~---~--~~
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/ Python 3 - nervous about starting large project

2009-08-05 Thread snfctech

Hello.

We are researching technologies to begin what may become a pretty
large intranet Dashboard project.

I'm a PHP developer, so the fact that Django uses Python doesn't give
me a head-start - but I've been wanting to consider it, because I am
interested in learning Python.

However, I'm nervous about the Python 3 situation.  What if I start
building a large project based on Django/Python 2.6, and then a year
or two down the road the project starts limping because of all of the
cool new Python 3 modules coming out?  And I've got a bunch of Django/
Python 2.6 code that needs to be ported?

Any tips would be greatly appreciated.  Thanks.

Tony

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



Select Table or Database based on User

2009-08-05 Thread Wojciech Gryc

Hi everyone,

I'm sure this has come up in the past, but I sincerely can't find it
in any of the Django tutorials, documentation, or websites. I
apologize in advance if I missed something!

I'm trying to develop a website where different users store their own
sets of contacts / articles / etc. If a user logs in, I only want them
to have access to their own articles or contacts. As such, I'm
thinking that storing each individual user's data in their own table
is the way to go.

However, my question is: how do I actually have Django select the
proper table? The models and views stay the same, but I need to make
sure that, given a user name, Django selects the proper table(s).

Is there a tutorial on this? A link? Any advice would be appreciated.

Thanks,
Wojciech

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



Simultaneous use of the admin interface

2009-08-05 Thread David

Using Django 1.1 if I do:

1) sign into admin as user A in one browser and begin to edit a record
2) sign into admin as user B in another browser and begin to edit the
SAME record
3) make a change as user A and press Save
4) make a different change as user B and press Save

The result is that A's change is silently overwritten with user B's
change.

How do I make it so that user B gets an error telling them the record
has been changed by someone else since they started editing it? That's
what I would have expected to be the default behaviour.

I did some searching of the documentation but didn't find anything
obviously related. I also looked here at past posts and saw some
people asking similar questions but no obvious solutions. There was
some talk of adding SELECT FOR UPDATE functionality to Django 1.1, but
I don't know if that made it in, or how to use it if it did.

Can I perhaps add hooks to save a copy of the model object at the HTTP
GET time, and at HTTP POST pull another copy of the model back from
the db (distinct from the copy that is about to be saved) and compare
to the previous one from the HTTP GET then error if they're different?

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



adapt admin interface

2009-08-05 Thread sveri

Hi,

i wonder if it is possible to change the admin interface of an app
like that:
Imagine i have a model:

class Entries(models.Model):
party = models.ForeignKey('party.Parties')
politician = models.ForeignKey('politician.Politicians')
name = ...

Now i go to the admin interface of Entries and want to add a new
Entry.
Then i select a party for the new entry.
After having that selected i want to reload the form ajax like
and show only the politicians that belong to that specific selected
party.

I hope i could express what i want good enough.

Thanks in Advance for any advices
Sven

--~--~-~--~~~---~--~~
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: Apache and mod_wsgi on Ubuntu

2009-08-05 Thread Steve1234

Thanks, I got it working. I searched this forum and I even read the
page referenced but still missed the answer. Thanks again this forum
is very helpful.
The fix was to add one line to the django.wsgi file to end up with
this:

import os
import sys
sys.path.append('/home/steve)
sys.path.append('/home/steve/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()



--~--~-~--~~~---~--~~
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: default blank choice on form.Form select widget

2009-08-05 Thread Paulo Almeida
Did you see this ticket?

http://code.djangoproject.com/ticket/4092

Maybe you can use the patch code to customize your field.

- Paulo

On Wed, Aug 5, 2009 at 8:01 PM, JHeasly  wrote:

>
> The doc page "Creating forms from models"
> (http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#topics-
> forms-modelforms
> )
> describes how
> "If the model field has choices set ... [snip] ... The choices will
> normally include the blank choice which is selected by default. ... "
>
> I have a form that's not associated with a database model (i.e.,
> form.Form) and I'm using the USStateSelect widget, but the blank
> choice isn't included in the STATE_CHOICE list. When the form loads,
> what I get is "Alabama" selected by default. I'd like to get the
> forms.ModelForm-style blank choice default selection behavior.
>
> I'm guessing some sort of super() def __init__ trickery is called for
> but am stumped so far ...
>
> Thanks,
> John
> >
>

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



Re: Memory error

2009-08-05 Thread drakkan

The code is something like this

obj=DBModels.objects.filter(somefilter)
results=[]
for o in obj:
  results.append({'field1':o.field1,'field2':o.field2})

return JsonResponse(results)

where JsonResponse is a class derived from HttpResponse that add a
simplejson.dumps

I have a really large database and in some edge case I need to return
a large number of results (about 150.000 when I get the error). I make
only one query with select_related and I tried also with DEBUG=False
but nothing changed only the detailed stack trace isn't printed,

thanks
drakkan



On 5 Ago, 21:02, Peter Herndon  wrote:
> On 08/05/2009 12:26 PM, drakkan wrote:> No I'm not serving static file I have 
> a very large json file
> > dinamycally generated (based on a db query)
>
> Please post the relevant view and model code, so we can see what's
> happening.  Also, if your db query is actually a really large number of
> db queries, and you are running in debug mode (DEBUG = True in
> settings), then Django caches all of your SQL queries to assist with
> debugging -- at the expense of memory and performance.
--~--~-~--~~~---~--~~
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: Memory error

2009-08-05 Thread Peter Herndon

On 08/05/2009 12:26 PM, drakkan wrote:
> No I'm not serving static file I have a very large json file
> dinamycally generated (based on a db query)
>
Please post the relevant view and model code, so we can see what's 
happening.  Also, if your db query is actually a really large number of 
db queries, and you are running in debug mode (DEBUG = True in 
settings), then Django caches all of your SQL queries to assist with 
debugging -- at the expense of memory and performance.

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



default blank choice on form.Form select widget

2009-08-05 Thread JHeasly

The doc page "Creating forms from models"
(http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#topics-
forms-modelforms)
describes how
"If the model field has choices set ... [snip] ... The choices will
normally include the blank choice which is selected by default. ... "

I have a form that's not associated with a database model (i.e.,
form.Form) and I'm using the USStateSelect widget, but the blank
choice isn't included in the STATE_CHOICE list. When the form loads,
what I get is "Alabama" selected by default. I'd like to get the
forms.ModelForm-style blank choice default selection behavior.

I'm guessing some sort of super() def __init__ trickery is called for
but am stumped so far ...

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



Re: Have I found a bug? Deletion and rolled back transactions

2009-08-05 Thread Peter Bengtsson

2009/8/5 Alex Gaynor :
>
> On Wed, Aug 5, 2009 at 11:31 AM, Peter Bengtsson wrote:
>>
>> I have found that when running this as a normal server, the rollback
>> DOES work. It's just in tests it doesn't work.
>>
>> On 5 Aug, 17:27, Peter Bengtsson  wrote:
>>> Here's the models:
>>>
>>> # models.py
>>> class Article(models.Model):
>>>     title = models.CharField(max_length=100)
>>>
>>> # urls.py
>>> urlpatterns = patterns('',
>>>     (r'^delete-rolledback/$', delete_rolledback),
>>> )
>>>
>>> # views.py
>>> def delete_rolledback(request):
>>>     transaction.enter_transaction_management()
>>>     transaction.managed(True)
>>>     qs = Article.objects.all()
>>>     for article in qs:
>>>         if article.title.lower().startswith(request.GET.get
>>> ('startswith')):
>>>             article.delete()
>>>             break
>>>     transaction.rollback()
>>>     return HttpResponse("Rolled back!")
>>>
>>> # tests.py
>>> from django.test import TestCase
>>>
>>> from news.models import Article
>>>
>>> class SimpleTest(TestCase):
>>>     def setUp(self):
>>>         Article.objects.create(title=u'Abraham')
>>>         Article.objects.create(title=u'Ben')
>>>         Article.objects.create(title=u'Ancor')
>>>         Article.objects.create(title=u'Wat')
>>>
>>>         super(SimpleTest, self).setUp()
>>>
>>>     def test_deletion(self):
>>>         count_before = Article.objects.count()
>>>         assert count_before == 4
>>>         r = self.client.get('/news/delete-rolledback/',
>>>                             dict(startswith='a'))
>>>         assert r.content.count("Rolled back")
>>>         count_after = Article.objects.count()
>>>         assert count_after == 4, count_after
>>>
>>> When I run these tests (with postgres or with sqlite) I get this
>>> assertion error:
>>>
>>> Traceback (most recent call last):
>>> ...
>>> AssertionError: 3
>>>
>>> If someone more clued up than me could take a look at this and confirm
>>> that it is a Django bug I can start looking into explaining what's
>>> wrong and possibilities of a patch.
>>> I've found this ticket (http://code.djangoproject.com/ticket/4758)
>>> where someone has experienced similar problems when using Oracle. But
>>> only for Oracle; he claims the same code *works* with Postgres.
>> >
>>
>
> Your tests test transaction behavior so you need to subclass
> TransactionTestCase instead of jsut TestCase.
>
I see. Thanks!

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



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org

--~--~-~--~~~---~--~~
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: multiple projects shared database

2009-08-05 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

There is no problem with that, as long as your code accounts for it.

Luke
luke.seelenbin...@gmail.com


Robin Becker wrote:
> My boss wants to have two different django controlled websites with a common 
> database. Is there a way to do this?
> 
> We are already running multiple websites into a single django project and 
> because they have a disambiguating term in the urls eg each url has 
> /lang/brand/path we can map the URLs pretty well.
> 
> With the multiple django projects & 1 database I am worried there are some 
> hidden problems waiting to come out and play.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkp5vgsACgkQXQrGVCncjPz1PACgnzUvWNdB7xcIf5K0nvKu3IHO
334AnRbzsb9ajiJSWAuHZNxkmRexGq84
=RJj/
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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: Have I found a bug? Deletion and rolled back transactions

2009-08-05 Thread Alex Gaynor

On Wed, Aug 5, 2009 at 11:31 AM, Peter Bengtsson wrote:
>
> I have found that when running this as a normal server, the rollback
> DOES work. It's just in tests it doesn't work.
>
> On 5 Aug, 17:27, Peter Bengtsson  wrote:
>> Here's the models:
>>
>> # models.py
>> class Article(models.Model):
>>     title = models.CharField(max_length=100)
>>
>> # urls.py
>> urlpatterns = patterns('',
>>     (r'^delete-rolledback/$', delete_rolledback),
>> )
>>
>> # views.py
>> def delete_rolledback(request):
>>     transaction.enter_transaction_management()
>>     transaction.managed(True)
>>     qs = Article.objects.all()
>>     for article in qs:
>>         if article.title.lower().startswith(request.GET.get
>> ('startswith')):
>>             article.delete()
>>             break
>>     transaction.rollback()
>>     return HttpResponse("Rolled back!")
>>
>> # tests.py
>> from django.test import TestCase
>>
>> from news.models import Article
>>
>> class SimpleTest(TestCase):
>>     def setUp(self):
>>         Article.objects.create(title=u'Abraham')
>>         Article.objects.create(title=u'Ben')
>>         Article.objects.create(title=u'Ancor')
>>         Article.objects.create(title=u'Wat')
>>
>>         super(SimpleTest, self).setUp()
>>
>>     def test_deletion(self):
>>         count_before = Article.objects.count()
>>         assert count_before == 4
>>         r = self.client.get('/news/delete-rolledback/',
>>                             dict(startswith='a'))
>>         assert r.content.count("Rolled back")
>>         count_after = Article.objects.count()
>>         assert count_after == 4, count_after
>>
>> When I run these tests (with postgres or with sqlite) I get this
>> assertion error:
>>
>> Traceback (most recent call last):
>> ...
>> AssertionError: 3
>>
>> If someone more clued up than me could take a look at this and confirm
>> that it is a Django bug I can start looking into explaining what's
>> wrong and possibilities of a patch.
>> I've found this ticket (http://code.djangoproject.com/ticket/4758)
>> where someone has experienced similar problems when using Oracle. But
>> only for Oracle; he claims the same code *works* with Postgres.
> >
>

Your tests test transaction behavior so you need to subclass
TransactionTestCase instead of jsut TestCase.

Alex

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

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



multiple projects shared database

2009-08-05 Thread Robin Becker

My boss wants to have two different django controlled websites with a common 
database. Is there a way to do this?

We are already running multiple websites into a single django project and 
because they have a disambiguating term in the urls eg each url has 
/lang/brand/path we can map the URLs pretty well.

With the multiple django projects & 1 database I am worried there are some 
hidden problems waiting to come out and play.
-- 
Robin Becker

--~--~-~--~~~---~--~~
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: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-05 Thread Paulo Almeida
Mystery solved.

The fixtures were not being imported after all. My list_experiments view
imports files from a certain folder, and that was the experiment data being
listed. Then the database was rolled back before the view_experiment test
started, and naturally the experiment with id 1 was not there anymore. I
suppose that rollback is the difference that made the test work with
unittest.

Thanks for all the help,
Paulo

On Wed, Aug 5, 2009 at 11:11 AM, Paulo Almeida
wrote:

> Hi,
>
> Thanks for the suggestion. I will do that now, but in the mean time I
> realized the 404 is probably happening because of the get_object_or_404 in
> the view, which means the experiment really isn't there, or at least not
> with id 1. I confirmed that by replacing get_object_or_404 with:
>
> exp = Experiment.objects.get(pk=experiment_id)
>
> which returns:
>
> DoesNotExist: Experiment matching query does not exist.
>
> That is weird, because the id in the href comes from experiment.id, and
> everything is working fine outside testing, but the response.context is also
> weird, so I'll do what you suggest to try and narrow down the problem.
>
> Thanks,
> Paulo
>
>
> On Wed, Aug 5, 2009 at 10:57 AM, Malcolm Tredinnick <
> malc...@pointy-stick.com> wrote:
>
>>
>> On Wed, 2009-08-05 at 10:45 +0100, Paulo Almeida wrote:
>> > Ok, so with APPEND_SLASH = False , I get a 404 (so no
>> > response['location']) , but the response.context still has all the
>> > variables like MEDIA_URL, LANGUAGES, LANGUAGE_BIDI, and not the ones
>> > it should have. It still has also:
>> >
>> > {'request_path': u'/myflow/experiment/1'}
>> >
>> > I also tested another view, with URL:
>> >
>> > response = self.client.get('/myflow/experiments')
>> >
>> > This one works, and it has a list of experiments which links to the
>> > view that isn't working. The link in response.content is:
>> >
>> > a href="/myflow/experiment/1"
>> >
>> > as it should be, and as it works outside tests. Also, from
>> > that /myflow/experiments response.content I can tell that the fixtures
>> > are being loaded, so it should not be a problem of experiment 1 not
>> > existing.
>> >
>> > If you can suggest anything else I may try, please do.
>>
>> It's time to use the scientific method. Make the smallest self-contained
>> example possible that exhibits the problem. A single test case in a file
>> that uses Django.TestCase. A single view that does nothing but returns a
>> constant string. A single URL pattern, etc. Remove everything that you
>> possibly can. If you find you cannot remove a particular chunk of
>> functionality (a URL pattern or a view or a template or whatever), then
>> you know where to look for the problem.
>>
>> You have a lot of things in flight here all at once. Throw as many
>> overboard as you and eliminate the moving parts. What's left is the
>> problem you're trying to solve.
>>
>> Regards,
>> Malcolm
>>
>>
>> >>
>>
>

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



Re: Sending File Upload Handler errors to the view

2009-08-05 Thread Kai

I've found a reason for why I couldn't get it working and a solution
as well.

It would appear that Django uses lazy evaluation for request.FILES to
determine when the upload handler is called. Therefore, the upload
handler is only evoked when and if you attempt to access
request.FILES. Additionally, the request object I am using
(WSGIRequest in my case) has made GET and POST immutable dictionaries,
so we can't pass information through there. However, META is still
available to add information to.

My combined solution has the line "request.FILES" in the view that
handles uploads, which forces the upload handler to begin. When the
error is captured in new_files, I set self.request.META['error'] to
the error message and raise StopUpload, which pushes us back into the
view without a file. Finally, I check for request.META['error'] in the
view and display that message when there is a problem.

I hope this helps!

~ Kai

On Aug 5, 8:44 am, Kai  wrote:
> Hi all,
>
> I want to stop any file uploads that don't end in my designated
> extension as soon as they're received. To do this, I define a custom
> Upload Handler and write new_file to look something like this:
>
> def new_file(self, field_name, file_name, content_type,
> content_length, charset=None):
>         basename, extension = os.path.splitext(file_name)
>         if extension != ".txt":
>                 raise StopUpload(True) # Error: Only .txt files are
> accepted
>
> This works fine for stopping the upload but it also clears
> request.FILES. Now, when my view receives the request, it has no way
> to telling whether the upload handler caused the file to be missing
> and I can't display a useful message to the user.
>
> Is there any way to send messages from the Upload Handler to the
> corresponding view, such that I can display the error to the user?
>
> Thanks!
> ~ Kai
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Have I found a bug? Deletion and rolled back transactions

2009-08-05 Thread Peter Bengtsson

I have found that when running this as a normal server, the rollback
DOES work. It's just in tests it doesn't work.

On 5 Aug, 17:27, Peter Bengtsson  wrote:
> Here's the models:
>
> # models.py
> class Article(models.Model):
>     title = models.CharField(max_length=100)
>
> # urls.py
> urlpatterns = patterns('',
>     (r'^delete-rolledback/$', delete_rolledback),
> )
>
> # views.py
> def delete_rolledback(request):
>     transaction.enter_transaction_management()
>     transaction.managed(True)
>     qs = Article.objects.all()
>     for article in qs:
>         if article.title.lower().startswith(request.GET.get
> ('startswith')):
>             article.delete()
>             break
>     transaction.rollback()
>     return HttpResponse("Rolled back!")
>
> # tests.py
> from django.test import TestCase
>
> from news.models import Article
>
> class SimpleTest(TestCase):
>     def setUp(self):
>         Article.objects.create(title=u'Abraham')
>         Article.objects.create(title=u'Ben')
>         Article.objects.create(title=u'Ancor')
>         Article.objects.create(title=u'Wat')
>
>         super(SimpleTest, self).setUp()
>
>     def test_deletion(self):
>         count_before = Article.objects.count()
>         assert count_before == 4
>         r = self.client.get('/news/delete-rolledback/',
>                             dict(startswith='a'))
>         assert r.content.count("Rolled back")
>         count_after = Article.objects.count()
>         assert count_after == 4, count_after
>
> When I run these tests (with postgres or with sqlite) I get this
> assertion error:
>
> Traceback (most recent call last):
> ...
> AssertionError: 3
>
> If someone more clued up than me could take a look at this and confirm
> that it is a Django bug I can start looking into explaining what's
> wrong and possibilities of a patch.
> I've found this ticket (http://code.djangoproject.com/ticket/4758)
> where someone has experienced similar problems when using Oracle. But
> only for Oracle; he claims the same code *works* with Postgres.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Have I found a bug? Deletion and rolled back transactions

2009-08-05 Thread Peter Bengtsson

Here's the models:

# models.py
class Article(models.Model):
title = models.CharField(max_length=100)

# urls.py
urlpatterns = patterns('',
(r'^delete-rolledback/$', delete_rolledback),
)

# views.py
def delete_rolledback(request):
transaction.enter_transaction_management()
transaction.managed(True)
qs = Article.objects.all()
for article in qs:
if article.title.lower().startswith(request.GET.get
('startswith')):
article.delete()
break
transaction.rollback()
return HttpResponse("Rolled back!")

# tests.py
from django.test import TestCase

from news.models import Article

class SimpleTest(TestCase):
def setUp(self):
Article.objects.create(title=u'Abraham')
Article.objects.create(title=u'Ben')
Article.objects.create(title=u'Ancor')
Article.objects.create(title=u'Wat')

super(SimpleTest, self).setUp()

def test_deletion(self):
count_before = Article.objects.count()
assert count_before == 4
r = self.client.get('/news/delete-rolledback/',
dict(startswith='a'))
assert r.content.count("Rolled back")
count_after = Article.objects.count()
assert count_after == 4, count_after


When I run these tests (with postgres or with sqlite) I get this
assertion error:

Traceback (most recent call last):
...
AssertionError: 3


If someone more clued up than me could take a look at this and confirm
that it is a Django bug I can start looking into explaining what's
wrong and possibilities of a patch.
I've found this ticket (http://code.djangoproject.com/ticket/4758)
where someone has experienced similar problems when using Oracle. But
only for Oracle; he claims the same code *works* with Postgres.
--~--~-~--~~~---~--~~
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: Memory error

2009-08-05 Thread drakkan

No I'm not serving static file I have a very large json file
dinamycally generated (based on a db query)

On 5 Ago, 15:28, Mike Ramirez  wrote:
> On Wednesday 05 August 2009 04:08:15 am drakkan wrote:
>
>
>
> > here is the excpetion returned while trying to serve a large file:
>
> > Traceback:
> > File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
> > in get_response
> >   92.                 response = callback(request, *callback_args,
> > **callback_kwargs)
> > File "/usr/lib/python2.4/site-packages/django/contrib/auth/
> > decorators.py" in __call__
> >   78.             return self.view_func(request, *args, **kwargs)
> > File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> > _result_iter
> >   106.                 self._fill_cache()
> > File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> > _fill_cache
> >   692.                     self._result_cache.append(self._iter.next
> > ())
> > File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> > iterator
> >   243.                             only_load=only_load)
> > File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> > get_cached_row
> >   987.             obj = klass(*fields)
> > File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in
> > __init__
> >   263.                 setattr(self, field.attname, val)
>
> > Exception Type: MemoryError at 
> > Exception Value:
>
> > any way to solve the issue?
>
> > thanks
> > drakkan
>
> I assume you're using django to serve static files, this method isn't
> recommended, it is inefficient [1].  You'll want to serve static files
> through another method, such as a nginx server or follow the mod_python
> instructions on serving static files [2]. Personally, I find it is just
> better, even in development to follow this 'rule of thumb' and setup a vhost
> for serving media/static files through apache, bypassing django.
>
> [1]http://docs.djangoproject.com/en/dev/howto/static-files/#the-big-fat-...
>
> [2]http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serv...
>
> Mike
>
> --
> Overdrawn?  But I still have checks left!
>
>  signature.asc
> < 1KVisualizzaScarica
--~--~-~--~~~---~--~~
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: field order:ModelForm

2009-08-05 Thread Emily Rodgers

2009/8/5 Ludwik  Trammer :
>
>> I tried adding a fields attribute to the Meta class (which I think is
>> what you would do in the dev version), but that didn't work.
>
> Django 1.1 stable is out and supports this feature, so if you can
> upgrade it will probably be the easiest solution.

OK I will try that - 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
-~--~~~~--~~--~--~---



DjangoCon '09 - DoubleTree Green Room Block

2009-08-05 Thread Robert Lofthouse

I would like to make everyone aware that the room block ends on
Monday, August 17th. You will still be able to register for the
conference up to the 4th September, but accommodation-wise you will
either have to register with the DoubleTree Green hotel at the regular
rate or try and find cheaper accommodation elsewhere.

I recommend registering for the conference as soon as possible so you
can take advantage of the DoubleTree conference rate ($99 per night) -
http://djangocon09.eventbrite.com. Speakers/Talks approved so far will
be on the website tonight and the schedule will be up on 8th August.

If you have already registered for the conference I will send around
another email with the link for the hotel booking page.

If you have any issues with registering due to paypal problems let me
know and I'll make Google checkout an option.

Regards

Robert Lofthouse
DjangoCon Chairman
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Sending File Upload Handler errors to the view

2009-08-05 Thread Kai

Hi all,

I want to stop any file uploads that don't end in my designated
extension as soon as they're received. To do this, I define a custom
Upload Handler and write new_file to look something like this:

def new_file(self, field_name, file_name, content_type,
content_length, charset=None):
basename, extension = os.path.splitext(file_name)
if extension != ".txt":
raise StopUpload(True) # Error: Only .txt files are
accepted

This works fine for stopping the upload but it also clears
request.FILES. Now, when my view receives the request, it has no way
to telling whether the upload handler caused the file to be missing
and I can't display a useful message to the user.

Is there any way to send messages from the Upload Handler to the
corresponding view, such that I can display the error to the user?

Thanks!
~ Kai

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



Re: Counting results

2009-08-05 Thread Randy Barlow

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

When ideas fail declared:
> Hi, I was wondering what is the simpliest way to count the number of
> objects returned in a QuerySet?
> 
> Basically i have a blog and i want to count the number of comment
> relating to each post and display it, the blog posts are shown on a
> seperate page to the comments but i guess you would still have to
> create the query set in the posts view so that you can count the
> results.

Try appending '.count()' to the end of your query!

http://docs.djangoproject.com/en/dev/ref/models/querysets/#count

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkp5opQACgkQw3vjPfF7QfWLIgCfXtC6uKghLldclw6euN5CeeEl
qB0AoIgMZ4b7CB5wX4hWGazTsx1jjUOT
=fo+f
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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: Counting results

2009-08-05 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I believe QuerySets have a .count() method.

Luke

luke.seelenbin...@gmail.com


When ideas fail wrote:
> Hi, I was wondering what is the simpliest way to count the number of
> objects returned in a QuerySet?
> 
> Basically i have a blog and i want to count the number of comment
> relating to each post and display it, the blog posts are shown on a
> seperate page to the comments but i guess you would still have to
> create the query set in the posts view so that you can count the
> results.
> 
> Thanks
> > 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkp5ojMACgkQXQrGVCncjPxzcACgpGprrgc/o00WHsJ3XdvZmeFD
wZwAnRczHExrEqTDHBNMvCu8BcES3jBI
=apvd
-END PGP SIGNATURE-

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



Counting results

2009-08-05 Thread When ideas fail

Hi, I was wondering what is the simpliest way to count the number of
objects returned in a QuerySet?

Basically i have a blog and i want to count the number of comment
relating to each post and display it, the blog posts are shown on a
seperate page to the comments but i guess you would still have to
create the query set in the posts view so that you can count the
results.

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: Searchform with pagination and GET parameters - easy solution needed

2009-08-05 Thread Alex Gaynor

On Wed, Aug 5, 2009 at 10:03 AM, tom wrote:
>
> Hi folks,
>
> i want to build a searchform (with GET parameters) and also want to
> use pagination. But i can't find an easy solution for this common
> case.
> My solution has a searchform, a view and a template. Can anybody tell
> me if this is a good solution? I'm not sure because i find it very
> complicated for such an common case. maybe there's a much faster
> (easier) way to handle this.
>
>
> forms.py
>
> class ProjectDataSearchForm(forms.Form):
>    """
>    A Search form for the Project Data
>    """
>    dtf = forms.DateTimeField(label='Datetime from', required=False)
>    dtt = forms.DateTimeField(label='Datetime to', required=False)
>    d_u = forms.BooleanField(label='Data with status unknown',
> required=False)
>    d_g = forms.BooleanField(label='Data with status good',
> required=False)
>    d_w = forms.BooleanField(label='Data with status warning',
> required=False)
>    d_e = forms.BooleanField(label='Data with status error',
> required=False)
>
> views.py
>
> def project_data_list(request, project_id):
>    """
>    Show a List with all Measurement Data from the Project
>    """
>    #Get Project. Needed by template
>    project = get_object_or_404(Project, pk=project_id,
> auth_group__in=request.user.groups.all())
>    #Use none-query
>    query = Measurand.objects.none()
>    newurl = ''
>    if len(request.GET) > 0:
>        form = ProjectDataSearchForm(data=request.GET)
>        if form.is_valid():
>            #Standard query
>            query = Measurand.objects.filter
> (entry__project=project_id,
> entry__project__auth_group__in=request.user.groups.all())
>            searchdict = form.cleaned_data
>            qdict = {
>                'dtf':'entry__datetime__gte',
>                'dtt':'entry__datetime__lte',
>            }
>            q_objs = [Q(**{qdict[k]: searchdict[k]}) for k in
> qdict.keys() if searchdict.get(k, None)]
>            query = query.filter(*q_objs)
>            #get data status
>            status = []
>            if searchdict['d_u']:
>                status.append('U')
>            if searchdict['d_g']:
>                status.append('G')
>            if searchdict['d_w']:
>                status.append('W')
>            if searchdict['d_e']:
>                status.append('E')
>            query = query.filter(status__in=status)
>
>            rawurl = urlencode(form.data)
>            if len(rawurl):
>                newurl = '&' + rawurl
>
>            query = query.order_by('-entry__datetime')
>
>    else:
>        form = ProjectDataSearchForm(initial={'d_u':True, 'd_g':True,
> 'd_w':True, 'd_e':True})
>
>    response =  list_detail.object_list(
>        request,
>        queryset = query,
>        template_name = 'project_data_list.html',
>        template_object_name = 'measurand',
>        paginate_by = 25,
>        page = int(request.GET.get('page', '1')),
>        extra_context = {'project':project, 'form':form,
> 'newurl':newurl}
>    )
>
>    return response
>
> template.html
>
>
> {% extends 'base.html' %}
> {% load i18n %}
>
> {% block content %}
>
> {% trans "Browse Measurands" %} ({% trans "Project:" %}
> {{project.name}})
> 
> 
>                
>                        {{ form.as_table }}
>                
>                
> 
> 
>
> {% if is_paginated %}
> 
>                
>                                Select page: {% for p in page_range %}  href=?page={{p}}
> {{newurl}}>{{p}} {% endfor %}
>                
> 
> {% endif %}
>
> here is more stuff to print the data 
>
> {% endblock content %}
>
>
>
>
>
>
>
>
> >
>

I'd like to reccomend you take a look at a reusable application I
wrote named Django filter:
http://github.com/alex/django-filter/tree/master .  It tries to
automate building these forms, and it's interface should make it easy
enough to paginate.

Alex

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

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



Searchform with pagination and GET parameters - easy solution needed

2009-08-05 Thread tom

Hi folks,

i want to build a searchform (with GET parameters) and also want to
use pagination. But i can't find an easy solution for this common
case.
My solution has a searchform, a view and a template. Can anybody tell
me if this is a good solution? I'm not sure because i find it very
complicated for such an common case. maybe there's a much faster
(easier) way to handle this.


forms.py

class ProjectDataSearchForm(forms.Form):
"""
A Search form for the Project Data
"""
dtf = forms.DateTimeField(label='Datetime from', required=False)
dtt = forms.DateTimeField(label='Datetime to', required=False)
d_u = forms.BooleanField(label='Data with status unknown',
required=False)
d_g = forms.BooleanField(label='Data with status good',
required=False)
d_w = forms.BooleanField(label='Data with status warning',
required=False)
d_e = forms.BooleanField(label='Data with status error',
required=False)

views.py

def project_data_list(request, project_id):
"""
Show a List with all Measurement Data from the Project
"""
#Get Project. Needed by template
project = get_object_or_404(Project, pk=project_id,
auth_group__in=request.user.groups.all())
#Use none-query
query = Measurand.objects.none()
newurl = ''
if len(request.GET) > 0:
form = ProjectDataSearchForm(data=request.GET)
if form.is_valid():
#Standard query
query = Measurand.objects.filter
(entry__project=project_id,
entry__project__auth_group__in=request.user.groups.all())
searchdict = form.cleaned_data
qdict = {
'dtf':'entry__datetime__gte',
'dtt':'entry__datetime__lte',
}
q_objs = [Q(**{qdict[k]: searchdict[k]}) for k in
qdict.keys() if searchdict.get(k, None)]
query = query.filter(*q_objs)
#get data status
status = []
if searchdict['d_u']:
status.append('U')
if searchdict['d_g']:
status.append('G')
if searchdict['d_w']:
status.append('W')
if searchdict['d_e']:
status.append('E')
query = query.filter(status__in=status)

rawurl = urlencode(form.data)
if len(rawurl):
newurl = '&' + rawurl

query = query.order_by('-entry__datetime')

else:
form = ProjectDataSearchForm(initial={'d_u':True, 'd_g':True,
'd_w':True, 'd_e':True})

response =  list_detail.object_list(
request,
queryset = query,
template_name = 'project_data_list.html',
template_object_name = 'measurand',
paginate_by = 25,
page = int(request.GET.get('page', '1')),
extra_context = {'project':project, 'form':form,
'newurl':newurl}
)

return response

template.html


{% extends 'base.html' %}
{% load i18n %}

{% block content %}

{% trans "Browse Measurands" %} ({% trans "Project:" %}
{{project.name}})



{{ form.as_table }}





{% if is_paginated %}


Select page: {% for p in page_range %} {{p}} {% endfor %}


{% endif %}

here is more stuff to print the data 

{% endblock content %}








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

2009-08-05 Thread Cristiano

Some guy made a pretty handy site/tool for Symfony developers:
http://symfony-check.org/

Basically it's a site that gives you a checklist of things you ought
to go through before deploying/putting live your site.

Anyone got a clue of something like this for Django, or iswilling to
work on building something similar?

--~--~-~--~~~---~--~~
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: field order:ModelForm

2009-08-05 Thread Ludwik Trammer

> I tried adding a fields attribute to the Meta class (which I think is
> what you would do in the dev version), but that didn't work.

Django 1.1 stable is out and supports this feature, so if you can
upgrade it will probably be the easiest solution.
--~--~-~--~~~---~--~~
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: Multiple data formats for one view

2009-08-05 Thread Ludwik Trammer

If you do this just for unintrusive AJAX functionality you can simply
use HttpRequest.is_ajax()
http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.is_ajax

if request.is_ajax():
 # return data serialized to JSON or XML
else:
 # render data in HTML template

Read documentation for information about compatibility with various
JavaScript libraries.

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



Use of the ORM in long running (non web) daemon

2009-08-05 Thread wam

I am using the Django ORM to build and manipulate models from outside
of a web context and within a long running daemonized application. I'm
using the django ORM talking to a postgresql db for this processing
since the results of this external processing are then used by a
Django based web reporting application and it was exceptionally
convenient to have a library that acted on these objects in a
consistent way regardless of whether it was called from the daemon vs
from a web request.

I've been seeing more and more database errors occurring within the
external processor. For example, I get a lot of these:
   InternalError: current transaction is aborted, commands ignored
until end of transaction block

I get a few of these:
  InternalError: SET TRANSACTION ISOLATION LEVEL must be called before
any query

The postgresql logs are not very descriptive as to what the root
problem is:
  2009-08-04 14:04:08 EDT STATEMENT:  BEGIN; SET TRANSACTION ISOLATION
LEVEL READ COMMITTED
  2009-08-04 14:04:14 EDT ERROR:  current transaction is aborted,
commands ignored until end of transaction block

The research I've seen so far leads me to think the problem is that
the ORM is building transactions that ordinarily would be closed at
the end of a view, but are being kept open in my case since I really
don't have a 'view' life-cycle. I've tried decorating my db-hitting
routines in the daemon code with django.db.transaction.commit_manually
along with appropriate calls to commit() and rollback() in case of
error, yet the problem persists. I've read the docs (and some of the
code) associated with transactions, yet the focus (naturally) is on
views and functions that have a typical request/response lifecycle.
I'm wondering what suggestions people would have for using the ORM in
a long running daemon (e.g. should I be closing the db connection
periodically? how would you suggest managing the transactions?).

The basic flow of my code is:
daemonize my process
while True:
listen for an external event (e.g. from the net)
process that event into model based objects
save the objects

Any help would be appreciated.

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



cache and multple languages

2009-08-05 Thread cwurld

Hi,

I have been successfully running a multi-language site for a while
now. The users language pref is stored (along with other data) in a
cookie.

Recently, I have been trying to cache some of the more common and
processor intensive views. Since the language code is not in the url,
I can't figure out how to cache pages based on language.

I looked in to the vary_on_header decorator, but I do not see how to
get that to work since the cookies vary on lots of stuff in addition
to language and I doubt I can get my users to change the Accept-
Language attribute in the request header.

Any ideas?

Thanks,
Chuck
--~--~-~--~~~---~--~~
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: apache ok (mod_wsgi) bue some issue with admin backend

2009-08-05 Thread Salvatore Leone

Graham Dumpleton ha scritto:
>
>
> The mod_python documentation is not really appropriate for explaining
> how static files are hosted when using mod_wsgi as mod_wsgi handles it
> differently. Instead see documentation on mod_wsgi site.
>
>   http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>   
> http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#Hosting_Of_Static_Files
>
> Graham
>
>   
I'll give a look, thanks.
>>>   
>> Sounds like your MEDIA_URL setting isn't correct, since that is what is
>> used to derive the initial portion of the hostname for media links,
>> unless you've done something really customised in your model's file
>> fields.
>> 
You're right. I forgotten about this... thanks again.


Regards,
Salvatore

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



Re: No data in template available

2009-08-05 Thread Frulli58

Now i understand and this way it makes sense.
Thank you very much
Uli

On 5 Aug., 15:54, Daniel Roseman  wrote:
> On Aug 5, 1:44 pm, Frulli58  wrote:
>
>
>
> > Hi together,
> > till now we worked with PHP. For a new database I desided to try
> > python and django.
> > I´m trying to find the right way and now I have a problem, that I can
> > ´t get data within a template.
> > My view:
> > from Django_Demo.news.models import D300, D200, D840
> > from django.http import HttpResponse
> > from django.template import Context, loader
>
> > def d300_anz(request):
> >     template = loader.get_template("news/d300.html")
> >     context = Context({"anzeige" : D300.objects.all()})
> >     return HttpResponse(template.render(context))
>
> > My template:
> > {% extends "news/basis.html" %}
>
> > {% block titel %}D300-bersicht{% endblock %}
>
> > {% block inhalt %}
> >     hier 1
> >     
> >     {% for n in D300.objects.all %}
> >          hier 2
> >          
> >          
> >          {{ n.titel|escape }}
> >          {{ n.zeitstempel }}
> >          
> >          
> >          
> >          {{ n.text|escape|linebreaksbr }}
> >          
> >          Details
> >          
> >          
> >         
> >     {% endfor %}
> >     hier 3
> > {% endblock %}
>
> > Wether witch of the for-loops I try, in browser, I only can see
> > D300-Übersicht
> > hier 1
> > hier 2
>
> > Wether in object_list nor in model D300.objects are data found.
>
> > If I make an output of D300 database in view without templates the
> > data are shown.
> > What is wrong with the template?
>
> > thanks for any help
> > Uli
>
> The template can only use the variables you actually pass into the
> view via the context. In the context, you've called the object list
> 'anzeige'. So that's the name you have to use in the template loop:
> {% for n in anzeige %}
> --
> 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: No data in template available

2009-08-05 Thread Daniel Roseman

On Aug 5, 1:44 pm, Frulli58  wrote:
> Hi together,
> till now we worked with PHP. For a new database I desided to try
> python and django.
> I´m trying to find the right way and now I have a problem, that I can
> ´t get data within a template.
> My view:
> from Django_Demo.news.models import D300, D200, D840
> from django.http import HttpResponse
> from django.template import Context, loader
>
> def d300_anz(request):
>     template = loader.get_template("news/d300.html")
>     context = Context({"anzeige" : D300.objects.all()})
>     return HttpResponse(template.render(context))
>
> My template:
> {% extends "news/basis.html" %}
>
> {% block titel %}D300-bersicht{% endblock %}
>
> {% block inhalt %}
>     hier 1
>     
>     {% for n in D300.objects.all %}
>          hier 2
>          
>          
>          {{ n.titel|escape }}
>          {{ n.zeitstempel }}
>          
>          
>          
>          {{ n.text|escape|linebreaksbr }}
>          
>          Details
>          
>          
>         
>     {% endfor %}
>     hier 3
> {% endblock %}
>
> Wether witch of the for-loops I try, in browser, I only can see
> D300-Übersicht
> hier 1
> hier 2
>
> Wether in object_list nor in model D300.objects are data found.
>
> If I make an output of D300 database in view without templates the
> data are shown.
> What is wrong with the template?
>
> thanks for any help
> Uli

The template can only use the variables you actually pass into the
view via the context. In the context, you've called the object list
'anzeige'. So that's the name you have to use in the template loop:
{% for n in anzeige %}
--
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: HttpResponseRedirect and encoding

2009-08-05 Thread alecs

Ticket #11638 ...
--~--~-~--~~~---~--~~
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: Memory error

2009-08-05 Thread Mike Ramirez
On Wednesday 05 August 2009 04:08:15 am drakkan wrote:
> here is the excpetion returned while trying to serve a large file:
>
> Traceback:
> File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
> in get_response
>   92. response = callback(request, *callback_args,
> **callback_kwargs)
> File "/usr/lib/python2.4/site-packages/django/contrib/auth/
> decorators.py" in __call__
>   78. return self.view_func(request, *args, **kwargs)
> File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> _result_iter
>   106. self._fill_cache()
> File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> _fill_cache
>   692. self._result_cache.append(self._iter.next
> ())
> File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> iterator
>   243. only_load=only_load)
> File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
> get_cached_row
>   987. obj = klass(*fields)
> File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in
> __init__
>   263. setattr(self, field.attname, val)
>
> Exception Type: MemoryError at 
> Exception Value:
>
> any way to solve the issue?
>
> thanks
> drakkan


I assume you're using django to serve static files, this method isn't 
recommended, it is inefficient [1].  You'll want to serve static files 
through another method, such as a nginx server or follow the mod_python 
instructions on serving static files [2]. Personally, I find it is just 
better, even in development to follow this 'rule of thumb' and setup a vhost 
for serving media/static files through apache, bypassing django.

[1] 
http://docs.djangoproject.com/en/dev/howto/static-files/#the-big-fat-disclaimer

[2] 
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-media-files

Mike

-- 
Overdrawn?  But I still have checks left!


signature.asc
Description: This is a digitally signed message part.


Re: Calculating a date

2009-08-05 Thread Mike Dewhirst

adelaide_mike wrote:
> This should really be a Python enquiry, but I am sure someone will
> know:
> 
> I need to calculate the date 12 weeks before today.  What is the best
> way?  TIA

This might give you a clue ...

from datetime import date

def anniversary_this_week(self, tday=date.today()):
 anniversary = self.birthdate.replace(year=tday.year)
 diff = anniversary.toordinal() - tday.toordinal()
 if diff < -358 or (diff >= 0 and diff <=7):
 return 'Yes'
 return 'No'

> 
> 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: Calculating a date

2009-08-05 Thread Spajderix

 From what i know, you can operate on datetime.datetime objects using 
datetime.timedelta, eg:

datetime.datetime.now() - datetime.timedelta(days=84)

will give you datetime.datetime object with date of today - 12 weeks

Link to manual: 
http://docs.python.org/library/datetime.html#datetime.timedelta

adelaide_mike pisze:
> This should really be a Python enquiry, but I am sure someone will
> know:
>
> I need to calculate the date 12 weeks before today.  What is the best
> 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: Calculating a date

2009-08-05 Thread krylatij

from datetime import date, timedelta
a = date.today() - timedelta(7 * 12)
print a
2009-05-13
--~--~-~--~~~---~--~~
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: Calculating a date

2009-08-05 Thread Mike Ramirez
On Wednesday 05 August 2009 06:01:11 am adelaide_mike wrote:
> This should really be a Python enquiry, but I am sure someone will
> know:
>
> I need to calculate the date 12 weeks before today.  What is the best
> 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
> -~--~~~~--~~--~--~---


The example should be pretty self explanatory and the docs will give you all 
the relative info.

You'll want to use datetime and datetime.timedelta

http://docs.python.org/library/datetime.html

and examples of using datetime and datetime.timedelta 

http://pleac.sourceforge.net/pleac_python/datesandtimes.html


Here's the example for figuring out 12 weeks in the past:

In [1]: import datetime

In [2]: now = datetime.datetime.now()

In [3]: diff = datetime.timedelta(weeks=12)

In [4]: past = now - diff

In [5]: past

Out[5]: datetime.datetime(2009, 5, 13, 6, 18, 12, 582151)


Mike

-- 
Any circuit design must contain at least one part which is obsolete, two parts
which are unobtainable, and three parts which are still under development.


signature.asc
Description: This is a digitally signed message part.


field order:ModelForm

2009-08-05 Thread Emily Rodgers

Hi,

I am using django 1.0.2, and I was wondering if it is possible to
change the order of the fields (it seems you can do this in the dev
version)?

I have added an extra field in my form (that doesn't actually
correspond with a field in the model). It is being listed after the
model fields, and I would like it to go before.

I tried adding a fields attribute to the Meta class (which I think is
what you would do in the dev version), but that didn't work.

Is the only way to do this to just create a normal form and do the
model instance interface manually? I am using an extJS frontend and
JSON to pass the values across (using the ExtJsonEncoder from django
snippets).

I think I am having a slow brain day so please excuse me if I am being
really dumb!

Em
--~--~-~--~~~---~--~~
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: Memory error

2009-08-05 Thread drakkan

No sorry isn't a file upload but is django to serve a large file

On 5 Ago, 13:47, krylatij  wrote:
> tryhttp://docs.djangoproject.com/en/dev/ref/settings/#file-upload-max-me...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Touch django.wsgi not reloading daemon

2009-08-05 Thread Sean Kemplay

Hi all.

I have resolved this by adding user=www-data group=www-data to the
WSGIDaemonProcess:

WSGIDaemonProcess sean75_ispy user=www-data group=www-data

Regards,
Sean

On Aug 5, 1:46 pm, Sean Kemplay  wrote:
> Hi All,
>
> I have the following in my virtual host config:
>
> WSGIDaemonProcess sean75_ispy
> WSGIProcessGroup sean75_ispy
>
> and the following in my django.wsgi:
>
> import os, sys
> sys.path.append('/srv/home/sean75/django/')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'ispy.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> Everything is working as expected except reloading the daemon.
>
> When I try touch /srv/home/sean75/django/ispy/apache/django.wsgi it
> does not reload and any changes I have made d not show up.
>
> When I run apache2ctl restart, the changes show up.
>
> Has anyone else experienced this?
>
> Regards,
> Sean
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Calculating a date

2009-08-05 Thread adelaide_mike

This should really be a Python enquiry, but I am sure someone will
know:

I need to calculate the date 12 weeks before today.  What is the best
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: Multiple data formats for one view

2009-08-05 Thread Sam Lai

I have a piece of middleware which assigns the right MIME type based
on URL extension, then I have templates for XML, JSON and HTML. My
view function simply gets the required context objects, then passes it
to the appropriate template.

This could probably be generified to make it more reusable.

I believe there's an XML and JSON serializer in-built too, so you can
easily write a generic view that simply uses those serializers; saves
you writing the templates for XML/JSON.

I'd be interested to know if there are better ways of doing this.

2009/8/5 krylatij :
>
> Why not?
> You can simply specify mimetype in HttpResponse object
> urls.py
> (r'^articles.xml/$', my_view_function, {'format': 'xml'}),
> (r'^articles.html/$', my_view_function, {'format': 'html'}),
>
> views.py
> def my_view_function(request, format='json'):
>  if format == 'xml':
>      mimetype = '.'
>      data = 
>  elif format == 'html':
>      
> return HttpResponse(content=data, mimetype=mimetype)
> >
>

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

2009-08-05 Thread StevenC

There seems to be nothing on the doccumentation.

On 5 Aug, 12:12, StevenC  wrote:
> NameError at /application/
> name 'input_formats' is not definedRequest Method: POST
> Request URL:http://webapps.stamford.ac.uk/application/
> Exception Type: NameError
> Exception Value: name 'input_formats' is not defined
>
> On 5 Aug, 12:05, StevenC  wrote:
>
>
>
> > How so i import input_format
>
> > On 5 Aug, 11:51, Daniel Roseman  wrote:
>
> > > On Aug 5, 11:03 am, StevenC  wrote:
>
> > > > Hey all!!
>
> > > > I have had some validation working but it seems to have stopped. I
> > > > want the date format on my form to validate as DD-MM- so i have
> > > > done the following within the view:
>
> > > > DOB = forms.DateField(('%d/%m/%Y',),'Date Of Birth',help_text="Please
> > > > use the following format: DD/MM/.")
>
> > > > So this used to work, like last week. Now when the form is submitted i
> > > > get the following error:
>
> > > > Enter a valid date in -MM-DD format.
>
> > > > Why?
>
> > > > Any ideas?
> > > > Cheers
>
> > > It's a bad idea to rely on positional arguments when they are
> > > documented as keyword args. Try:
>
> > > DOB = forms.DateField(input_formats=('%d/%m/%Y',), label='Date Of
> > > Birth',
> > >                                    help_text="Please use the following
> > > format: DD/MM/.")
>
> > > --
> > > DR.- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Touch django.wsgi not reloading daemon

2009-08-05 Thread Sean Kemplay

Hi All,

I have the following in my virtual host config:

WSGIDaemonProcess sean75_ispy
WSGIProcessGroup sean75_ispy

and the following in my django.wsgi:

import os, sys
sys.path.append('/srv/home/sean75/django/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'ispy.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Everything is working as expected except reloading the daemon.

When I try touch /srv/home/sean75/django/ispy/apache/django.wsgi it
does not reload and any changes I have made d not show up.

When I run apache2ctl restart, the changes show up.

Has anyone else experienced this?

Regards,
Sean

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



No data in template available

2009-08-05 Thread Frulli58

Hi together,
till now we worked with PHP. For a new database I desided to try
python and django.
I´m trying to find the right way and now I have a problem, that I can
´t get data within a template.
My view:
from Django_Demo.news.models import D300, D200, D840
from django.http import HttpResponse
from django.template import Context, loader

def d300_anz(request):
template = loader.get_template("news/d300.html")
context = Context({"anzeige" : D300.objects.all()})
return HttpResponse(template.render(context))


My template:
{% extends "news/basis.html" %}

{% block titel %}D300-bersicht{% endblock %}

{% block inhalt %}
hier 1

{% for n in D300.objects.all %}
 hier 2
 
 
 {{ n.titel|escape }}
 {{ n.zeitstempel }}
 
 
 
 {{ n.text|escape|linebreaksbr }}
 
 Details
 
 

{% endfor %}
hier 3
{% endblock %}

Wether witch of the for-loops I try, in browser, I only can see
D300-Übersicht
hier 1
hier 2

Wether in object_list nor in model D300.objects are data found.

If I make an output of D300 database in view without templates the
data are shown.
What is wrong with the template?

thanks for any help
Uli

--~--~-~--~~~---~--~~
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: HttpResponseRedirect and encoding

2009-08-05 Thread alecs

After jumping to sqlite Internal Server Error is not raised, just

Environment:

Request Method: GET
Request URL: 
http://172.16.23.33/file/2840e589359de657b7275adcb60d4fbea6472e2a7746b3c9d451cb4b
Django Version: 1.1
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'filez.filezupload',
 'debug_toolbar']
Installed Middleware:
('firepy.django.middleware.FirePHPMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
decorators.py" in __call__
  78. return self.view_func(request, *args, **kwargs)
File "/var/www/filez/filezupload/views.py" in send_file
  260. return HttpResponseRedirect(path)
File "/usr/local/lib/python2.6/dist-packages/django/http/__init__.py"
in __init__
  407. self['Location'] = redirect_to
File "/usr/local/lib/python2.6/dist-packages/django/http/__init__.py"
in __setitem__
  320. header, value = self._convert_to_ascii(header, value)
File "/usr/local/lib/python2.6/dist-packages/django/http/__init__.py"
in _convert_to_ascii
  309. value = value.encode('us-ascii')

Exception Type: UnicodeEncodeError at /file/
2840e589359de657b7275adcb60d4fbea6472e2a7746b3c9d451cb4b
Exception Value: ('ascii', u"/site_media/upload/alecs/
\u0413\u0438\u0444\u0442,\u0414\u0436\u043e\u043d\u0441 - Python
\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c
\u0430\u0434\u043c\u0438\u043d
\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d
\u0438\u0438.2009'.djvu", 25, 29, 'ordinal not in range(128)')


So I shall try to open a ticket ?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



checking if db schema and model match

2009-08-05 Thread Sam Lai

I hope this hasn't been asked before; had a quick look through the
archives and docs but couldn't find anything.

Is it possible to get django (e.g. via manage.py) to CHECK if the db
schema and model match? I don't want it to change anything, just to
tell me if there is a mismatch, and what that is.

I thought syncdb did this, but it doesn't seem to. I think this would
be quite useful to have, and could pre-empt errors later on when
non-existent fields are used in views etc.

Sam

--~--~-~--~~~---~--~~
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: HttpResponseRedirect and encoding

2009-08-05 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-08-05, o godz. 13:29, przez alecs:

> The problem happens when django is trying to path.encode('us-
> ascii') ...
> What can be the reason and how to prepare string to be successfully
> processed ?


If path is bytestring, calling .encode() will first try to decode it  
to unicode using default codec, which is ascii.

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


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



Intermediary model and filter_horizontal problem

2009-08-05 Thread Jean Stebens

Hi All,

My Problem: I'm adapting the generated models from inspectdb in order to 
use a legacy application with django. The application database schema 
has intermediary tables in it - I'd want to use the nice 
"filter_horizontal" instead of inlines. Inlines do work, so the 
intermediary table lookup works fine - but with filter_horizontal the 
admin panel just doesnt show up the relations - no warnings nor errors.

Thanks for having a look at it,
Greetings from Luxemburg,
Jean

#models.py

class Person(models.Model):
id = models.AutoField(primary_key=True, db_column='PersonId')
name = models.CharField(max_length=300, db_column='PersonName')
groups = models.ManyToManyField('Group', through='Membership')

class Group(models.Model):
id = models.AutoField(primary_key=True, db_column='GroupId')
name = models.CharField(max_length=300, db_column='GroupName')
members = models.ManyToManyField('Person', through='Membership')

class Membership(models.Model):
id = models.AutoField(primary_key=True, db_column='Id')
person = models.ForeignKey(Person, db_column='PersonId')
group = models.ForeignKey(Group, db_column='GroupId')

#admin.py

class Membership_inline(admin.TabularInline):
model = Membership
extra = 1

class PersonAdmin(admin.ModelAdmin):
search_fields = ['name']
#inlines = [ Membership_inline ]
filter_horizontal = ('groups',)

class GroupAdmin(admin.ModelAdmin):
search_fields = ['name']
#inlines = [ Membership_inline ]
filter_horizontal = ('persons',)

admin.site.register(Person, PersonAdmin)
admin.site.register(Group, GroupAdmin)



--~--~-~--~~~---~--~~
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: Memory error

2009-08-05 Thread krylatij

try 
http://docs.djangoproject.com/en/dev/ref/settings/#file-upload-max-memory-size

--~--~-~--~~~---~--~~
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: Multiple data formats for one view

2009-08-05 Thread krylatij

Why not?
You can simply specify mimetype in HttpResponse object
urls.py
(r'^articles.xml/$', my_view_function, {'format': 'xml'}),
(r'^articles.html/$', my_view_function, {'format': 'html'}),

views.py
def my_view_function(request, format='json'):
 if format == 'xml':
  mimetype = '.'
  data = 
 elif format == 'html':
  
return HttpResponse(content=data, mimetype=mimetype)
--~--~-~--~~~---~--~~
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: HttpResponseRedirect and encoding

2009-08-05 Thread alecs

The problem happens when django is trying to path.encode('us-
ascii') ...
What can be the reason and how to prepare string to be successfully
processed ?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >