Can't access the development server

2008-11-17 Thread Ben

Hi,

I'm completely new to python and Django, although fairly familiar with
programming and web servers in general.

I'm struggling to get Django up and running, at the moment, and I'd be
really grateful if someone could help.

I'm following this tutorial, after having successfully installed
Django:

http://docs.djangoproject.com/en/dev/intro/tutorial01

I start the development server using:

python manage.py runserver

which seems to work ok:

Validating models...
0 errors found

Django version 1.1 pre-alpha SVN-9479, using settings
'prototype.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

In fact, on that server, I can telnet to the development server fine.
However, if I try to access it in my browser, nothing happens. The
access doesn't show up on the server output and the browser fails to
connect at all. I've tried starting it on different ports, with no
success. I am able to access the thing on port 3000, although at the
moment I'm not quite sure what this is... As far as I know there are
no firewalls between me and the server (it's a shared hosting server
with Site5).

I'm assuming that when I try to connect to port 8000 this will go
directly to the development server and apache settings etc should be
irrelevant? How about python settings? Is it possible that I've got
something misconfigured that would cause this behaviour?

Any more information I can provide?

Thanks in advance!

Ben


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



Re: Can't access the development server

2008-11-18 Thread Ben

Thanks -- that solved it!

Ben

On 17 Nov, 21:16, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Nov 17, 2008 at 8:14 AM, Ben <[EMAIL PROTECTED]> wrote:
>
> > [snip]
>
> > I start the development server using:
>
> > python manage.py runserver
>
> > which seems to work ok:
>
> > Validating models...
> > 0 errors found
>
> > Django version 1.1 pre-alpha SVN-9479, using settings
> > 'prototype.settings'
> > Development server is running athttp://127.0.0.1:8000/
> > Quit the server with CONTROL-C.
>
> > [snip
> >  As far as I know there are
> > no firewalls between me and the server (it's a shared hosting server
> > with Site5).
> > [snip]
>
> If you're trying to connect to the server from a machine other than the one
> you are running it on, you need to tell it to listen on all the machine's
> addresses, not just local-loopback (127.0.0.1), which is the default.  Try:
>
> python manage.py runserver 0.0.0.0:8000
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Do you recommend "Practical Django Projects"?

2009-01-05 Thread Ben

I recently read both and went thru all the examples in Pracitical
Django Projects.  It was a bit tough at first because some of it is a
little dated, but actually figuring out how to adapt it to 1.0 is
actually a good exercise in itself (learning how to debug and actually
understanding how things work).  I found learned a lot more this way
than if everything went smoothly by coping the examples.

There is also a doc that specifically points out what are backwards
incompatible changes 
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges

-Ben



On Jan 5, 5:16 pm, "David Zhou"  wrote:
> On Mon, Jan 5, 2009 at 3:57 AM, Kenneth Gonsalves
>
>  wrote:
>
> > On Monday 05 Jan 2009 2:10:34 pm David Zhou wrote:
> >> >> and covers a lot of materials.
> >> >> What do you think?
>
> >> > As the author, I recommend waiting a couple months.
>
> >> Are you planning to update Practical Django Projects to 1.0?
>
> > isnt that obvious from the answer?
>
> Your perpetual grouchiness aside, not in any substantial way.
>
> Will the update be new online errata? Or a brand new printed version?
> Or perhaps a brand new volume?  A vague "wait a couple months" doesn't
> impart any real detail -- hence the further prompting.
>
> Perhaps there is no more detail to give at this stage.
>
> But then, that's not really for you to decide, is it?
>
> ---
> David Zhou
> da...@nodnod.net

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



Inline with Grouper

2009-06-30 Thread Ben
ubmit_row %}

{% if add %}
document.getElementById
("{{ adminform.first_field.auto_id }}").focus();
{% endif %}

{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}






{% endblock %}

#TemplateSyntaxError is "'int' object not iterable" at the
"inline_admin_form" line, and my best guess is that I haven't been
able to declare the formset and hook it to the model correctly


Thanks very much in advance for any ideas or suggestions -
Ben

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



Re: Tutorial 2 - Template Dirs

2009-06-30 Thread Ben

Hey this might be a question I can answer - I'm a NKOTB too.

The easiest way is to modify the "title" and "branding" blocks in the
base_site.html file.  This would change the name for the admin across
the site, as far as I know.  It should live in (in your case) /home/
divesh/projects/myproject/templates/admin/base_site.html - looks like
you've already copied that file from the django site-packages
directory.

--

{% extends "admin/base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {% trans 'Django site admin' %}{%
endblock %}

{% block branding %}
{% trans 'Django administration' %}
{% endblock %}

{% block nav-global %}{% endblock %}



On Jun 30, 1:06 pm, Divesh Gidwani  wrote:
> Okay, I have experimented with this for sometime, but for some reason
> the site is still showing 'Django Administration' on top. I open it
> with Text/Edit and changed the name. What exact files from the Django
> directory should i copy to my project one.
>
> Thanks
>
> On Jun 30, 1:12 pm, Divesh Gidwani  wrote:
>
>
>
> > Now that I created the templates folder, should I take the base.html
> > and index.html files and paste them in this folder?
>
> > That being done, how can I edit these files? Is there a particular
> > program to use?
>
> > On Jun 30, 12:56 pm, Ahmet Emre Aladağ  wrote:
>
> > > On Tue, Jun 30, 2009 at 7:36 PM, Divesh Gidwani  
> > > wrote:
>
> > > > So I have had a pretty smooth transition so far, but am now stuck when
> > > > at the end of tutorial 2, it asks to specify my directory of tempaltes
> > > > in the settings.py file under the template_dirs tuple.
>
> > > > Where are the templates i created stored?
>
> > > You can create a directory called templates inside your project [not app]
> > > folder and give its fullpath such as:
> > > /home/divesh/projects/myproject/templates
>
> > > An example structure:
> > > -myproject
> > > --myapp
> > > views.py
> > > models.py
> > > urls.py
> > > --templates
> > > index.html
> > > base.html
> > > myapp
> > > --results.html
> > > --output.html
> > > --urls.py
> > > --settings.py
> > > --manage.py
> > > --__init__.py- 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
-~--~~~~--~~--~--~---



syncdb doesn't updated database after adding null=True to an IntegerField

2009-07-15 Thread Ben

I'm using the admin site. I noticed that I couldn't leave an
IntegerField empty even when I had "year = models.IntegerField
(blank=True)". I googled and found out I should set null=True as well.
I did this, ran syncdb, and it didn't fix the issue.

I am using sqlite3 with a temporary database. I restarted my machine,
so that the database was deleted, ran syncdb, and the issue was fixed.
I tested again and it looks like once the database and tables are
created, adding null=True to an IntegerField and running syncdb won't
actually update the database.

Is syncdb supposed to fully sync the database to the model
definitions? If so I would call this a bug.

Comments?

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



Quick Newbie Question - reverse ManyToMany in admin site

2009-08-12 Thread ben

Hi all,
I've got a model with a plain many-to-many relationship (no
intermediate model) and want to edit the relationships in the admin
site. By default the multiple select box only appears on the admin
page for the model that defined it, however I'd like to be able to
modify the relationships the other way around too.

e.g. for items in groups, I'd like to have
item admin page allowing a multi-select on the groups related to it
group admin page allowing a multi-select of items within the group

The admin docs describe the problem but only show the solution for the
more complicated (intermediary model) case:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-many-to-many-intermediary-models

Is there an easy way to do what I want? The solutions I've found have
all been for some complicated syncdb and model definition solutions
that seem a bit overkill for just showing the relationship in the
admin site.

Cheers
Ben

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



default settings for applications

2009-06-05 Thread ben

I'm wondering if a convention exists for dealing with applications
settings.  I'm thinking of having the default  settings to be
specified in my application in a default_settings.py file but be
overridden by any values in DJANGO_SETTINGS_MODULE.  I can do this
easily enough, but it feels like something that might be already
standardised.  Does a convention exist, and if so what is it?

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



Re: default settings for applications

2009-06-06 Thread ben

Thanks for the answer.
In particular I'm wondering about apps that will be shared by several
projects.  The
default_settings.py would then be the values of the settings if the
projects don't
override these settings in their DJANGO_SETTINGS_MODULEs.  Effectively
I'm planning
on using something like django.conf.settings but where the defaults
are in the application
itself rather than in django.conf.global_settings.  It sounds like
there's no convention
for something like this.

On Jun 5, 10:46 pm, Ben Davis  wrote:
> I'm not sure that there's a real "standard" for it,  but that's more or less
> what I've done for my projects,  except my multi-environment setup looks
> like this:
>
> settings/
>     __init__.py
>     defaults.py
>     development.py
>     staging.py
>     production.py
>
> all my default/common settings go in defaults.py,  and for each environment
> (development, staging, production) I have  "from defaults import *" at the
> top.   I then set DJANGO_SETTINGS_MODULE to one of the appropriate modules,
> eg: "settings.development".   I'm not sure how standard that is, but it
> works well for me.
>
> On Fri, Jun 5, 2009 at 11:39 PM, ben  wrote:
>
> > I'm wondering if a convention exists for dealing with applications
> > settings.  I'm thinking of having the default  settings to be
> > specified in my application in a default_settings.py file but be
> > overridden by any values in DJANGO_SETTINGS_MODULE.  I can do this
> > easily enough, but it feels like something that might be already
> > standardised.  Does a convention exist, and if so what is it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Deleting objects in Admin - Circular References

2009-06-10 Thread ben

If I have two models that contain foreign keys to each other, e.g.

class Quiz(models.Model):
current_question = models.ForeignKey('Question')

class Question(models.Model):
quiz = models.ForeignKey('Quiz')

, where there are multiple questions in each quiz, but only one is
current.

When I then delete a quiz object in the admin interface the
confirmation page show a long list of dependent objects of the form:
- Quiz
- Question
- Question
- Question
- Quiz
-Question
-Question
-Question
, and so on.

The delete works fine, I just find the confirmation page aesthetically
unpleasing.  Is there a way to exclude circular references from the
displayed list of dependent objects?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Puzzling filter/annotation of queryset based on count

2009-11-10 Thread ben

Hi all, have been having trouble with figuring out how to construct
more complicated filters on query sets, especially when mixing them
with annotations.

Specifically, I have:

An Item, which has one of many ItemTypes
A Collection, which contains many Items.

What I want to construct is a queryset containing a set of
Collections, with a field (annotation) with the Count of items
belonging to that collection with a specific ItemType

So something along the lines of Collection.objects.annotate
(item_count=Count('item')).filter(item__itemtype=1).filter
(item_count__gt=0).all()

however I can't figure out the correct configuration of annotations
and filters to get back what I want! I'm sure this will take a
seasoned djangonaut a few seconds to figure out so any help is
appreciated!
Cheers
Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Generic Many-To-Many without GenericRelations

2010-02-11 Thread ben
Generic Many-To-Many Relationships

I have a collection class which contains arbitrary objects using a
Generic Many-To-Many relationship.


class Collection(models.Model):
name = models.CharField(max_length=VERBOSE_NAME_MAX_LENGTH)

def member_objects(self, klass):
"""Returns a QuerySet of all objects in the collection of the
given class."""
# Should be stuff here.
pass


class ObjectInCollection(models.Model):
collection = models.ForeignKey(Collection)
content_type = models.ForeignKey(ContentType)
object_id =models.PositiveIntegerField()
object = generic.GenericForeignKey()


class ExampleObject(models.Model):
# Stuff here
# I don't want to rely on the following generic relation.
oics = generic.GenericRelation(ObjectInCollection,
   related_name='example_object')


My problem is the member_objects method.  If I give all the object
classes that might be included in the collection a GenericRelation (as
in ExampleObject) then I can use:

   def member_objects(self, klass)
   return klass.objects.filter(oics__collection__id=self.id)

But I don't want to rely on having this in all the classes (because
the classes might be in other applications or there might be multiple
collection classes).

I could use a klass.objects.raw custom SQL method but that wouldn't
return a QuerySet which I would prefer.

Is there a way to do this that:
  1) does not require a GenericRelation in all classes and
  2) returns a QuerySet?

Cheers.

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



dynamic inlines (svn #12297) and older template logic breaking down

2010-03-04 Thread ben
I was updating to the latest SVN and encountered some odd behavior
with a custom gallery image admin inline template. I've narrowed it
down to some dynamic inlines development released in 12297. The
problem is that I don't really know if it merits a feature request or
if I'm missing something.

The issue boils down to the "add new" loop with "extra" set to 1 (only
one image can be added per save), specifically the use of the
"original" property in differentiating between existing and new
gallery images. The goal is to be able to determine which are bound to
the database from those that are adds.

{% for inline_admin_form in inline_admin_formset %}
{% if inline_admin_form.original %}
{% else %}
{% include "admin/edit_inline/gallery_image.html" %}
{% endif %}
{% endfor %}

The above template admittedly has the problem where the underlying
django can not create other formsets which are not "original" without
it breaking, and this is indeed what seems to be happening.

In a fresh gallery admin with no images saved --
#12296
1 gallery image add option - galleryimages-0-image only
#12297
2 gallery image add options - galleryimages-0-image and galleryimages-
__prefix__-image

Under current SVN is there a way to excude the __prefix__ instance
within the template? If not, would it be worth submitting a feature
request to enable the ability to discern between the two kinds of non-
original inlines?

Thanks!
Ben

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: dynamic inlines (svn #12297) and older template logic breaking down

2010-03-04 Thread ben
Update - it seems that excluding the prefix elements can be done by
excluding forloop.last in addition to formsets that are data bound.
the stacked.html template in contrib mirrors this. While it doesn't
seem to be the futureproof solution I'd hoped for, it does work.
Perhaps the best move would be to allow the 1.2 release to settle out
and revisit the logic later.

workaround:

{% for inline_admin_form in inline_admin_formset %}
{% if inline_admin_form.original or forloop.last %}
{% else %}
{% include "admin/edit_inline/gallery_image.html" %}
{% endif %}
{% endfor %}

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



run single regression test from test suite

2010-03-14 Thread ben
I haven't been able to work out how to run a single regression test
from the test suite.

I would have thought that

./runtests.py --settings=test_sqlite
regressiontests.generic_relations_regress.tests.GenericRelationTests

might work.  But it expects tests of the form app.TestCase.  Since
these tests aren't in an app I'm not sure how to run them
individually.

Cheers,
Ben

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 use CommaSeperatedIntegerList with CheckboxSelectMultiple

2010-04-02 Thread ben
Hi, I am new to Django. I am currently using the latest Django 1.2
from trunk. I am trying to store a list of values in a
CommaSeperatedIntegerList. I would like to use a
CheckboxSelectMultiple widget to render and select the values in the
list. I have setup my code like so.

SOME_CHOICES =  (('1', 'ch1'),('2', 'ch2'), ('3', 'ch3'),('4',"ch4"),
('5',"ch5"),)

class QandA(models.Model):
q1 = models.CommaSeparatedIntegerField(choices=SOME_CHOICES,
max_length=100, null=True,blank=True)


class QandAForm(ModelForm):
  class Meta:
  model=QandA
  fields=['q1']
  widgets={'q1':forms.CheckboxSelectMultiple,}

The form renders properly but I get the following validation error
after posting.

"Select a valid choice. [u'1'] is not one of the available choices."

The same thing happens when I attempt to use SelectMultiple as the
widget. Can anyone tell me what I am doing wrong? I have googled about
but have not been able to find anything describing how to handle this.

Thanks, Ben

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



Re: How to use CommaSeperatedIntegerList with CheckboxSelectMultiple

2010-04-02 Thread ben
So what your saying is that I'm not using CommaSeperatedIntegerField
for its intended purpose? I should think about writing a set of custom
fields? I just assumed support for this type of thing was built in. I
will keep hunting.

On Apr 2, 1:50 pm, Bill Freeman  wrote:
> I once saw something for this on djangosnippets.  Search hard.
>
>
>
> On Fri, Apr 2, 2010 at 1:09 PM, ben  wrote:
> > Hi, I am new to Django. I am currently using the latest Django 1.2
> > from trunk. I am trying to store a list of values in a
> > CommaSeperatedIntegerList. I would like to use a
> > CheckboxSelectMultiple widget to render and select the values in the
> > list. I have setup my code like so.
>
> > SOME_CHOICES =  (('1', 'ch1'),('2', 'ch2'), ('3', 'ch3'),('4',"ch4"),
> > ('5',"ch5"),)
>
> > class QandA(models.Model):
> >    q1 = models.CommaSeparatedIntegerField(choices=SOME_CHOICES,
> > max_length=100, null=True,blank=True)
>
> > class QandAForm(ModelForm):
> >      class Meta:
> >          model=QandA
> >          fields=['q1']
> >          widgets={'q1':forms.CheckboxSelectMultiple,}
>
> > The form renders properly but I get the following validation error
> > after posting.
>
> > "Select a valid choice. [u'1'] is not one of the available choices."
>
> > The same thing happens when I attempt to use SelectMultiple as the
> > widget. Can anyone tell me what I am doing wrong? I have googled about
> > but have not been able to find anything describing how to handle this.
>
> > Thanks, Ben
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



Re: How to use CommaSeperatedIntegerList with CheckboxSelectMultiple

2010-04-02 Thread ben
Sorry. I pasted code that I was experimenting with. I thought maybe
the validation code was looking for strings because that is what the
error code said it was looking for. Before that I had been using
integers and that doesn't seem to work either. I am wondering if this
is a bug in Django 1.2. I hunted around on Django snippets as Bill
Freeman suggested and found the following code 
http://www.djangosnippets.org/snippets/1200/
for a custom multiple selection field.

I inserted it into my app and it doesn't want to validate the
selection either. In fact it returns a validation error message
similar to what I received from CommaSeperatedIntegerField and
CheckboxSelectMultiple. "Value [u'1'] is not a valid choice."

Not sure what is going on. Any insights would be appreciated.

On Apr 2, 3:06 pm, orokusaki  wrote:
> The problem is that you're using '1' instead of 1. The comma
> separated integer list is expecting integers not strings. The reason
> you're seeing u'1' is because it's being turned from a string to a
> unicode object.
>
> Try this instead:
>
> SOME_CHOICES =  ((1, 'ch1'),(2, 'ch2'), (3, 'ch3'),(4, 'ch4'))

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



Re: How to use CommaSeperatedIntegerList with CheckboxSelectMultiple

2010-04-03 Thread ben
Either I don't understand how CheckboxSelectMultiple works or there is
a bug in Django 1.2. I have tried the following custom multi select
fields I have found around the web.

http://www.djangosnippets.org/snippets/1200/
http://www.davidcramer.net/code/181/custom-fields-in-django.html

Out of desperation I tried using a ManyToMany field and all produce
the same validation error when used with either CheckboxSelectMultiple
or SelectMultiple.

'Select a valid choice. [u'1', u'2', u'3', u'4'] is not one of the
available choices.'

This happens regardless of the number of choices, types of the choices
tuple values, or the model field type.

Can anyone point me to an example that demonstrates how to properly
use these fields.

Thanks,
Ben


On Apr 2, 5:19 pm, Bill Freeman  wrote:
> I know that I used (some revision of) that snippet a while back.
>
> Realize that what it stores is a string, containing digits and commas.
>
> The to_python and get_db_prep_value methods are responsible for
> converting between that database single string and a list of strings,
> not integers.  You can use any string (that doesn't contain comma) to
> represent a choice (db value).  I had two character ID flags (easier to
> read in pgadmin).  It did work, but I forget the details (I eventually went
> to multi to multi and the one end of many to one relationships).  So I
> expect that the DB side of your choice tuples must be strings.
>
> Bill
>
>
>
> On Fri, Apr 2, 2010 at 3:37 PM, ben  wrote:
> > Sorry. I pasted code that I was experimenting with. I thought maybe
> > the validation code was looking for strings because that is what the
> > error code said it was looking for. Before that I had been using
> > integers and that doesn't seem to work either. I am wondering if this
> > is a bug in Django 1.2. I hunted around on Django snippets as Bill
> > Freeman suggested and found the following 
> > codehttp://www.djangosnippets.org/snippets/1200/
> > for a custom multiple selection field.
>
> > I inserted it into my app and it doesn't want to validate the
> > selection either. In fact it returns a validation error message
> > similar to what I received from CommaSeperatedIntegerField and
> > CheckboxSelectMultiple. "Value [u'1'] is not a valid choice."
>
> > Not sure what is going on. Any insights would be appreciated.
>
> > On Apr 2, 3:06 pm, orokusaki  wrote:
> >> The problem is that you're using '1' instead of 1. The comma
> >> separated integer list is expecting integers not strings. The reason
> >> you're seeing u'1' is because it's being turned from a string to a
> >> unicode object.
>
> >> Try this instead:
>
> >> SOME_CHOICES =  ((1, 'ch1'),(2, 'ch2'), (3, 'ch3'),(4, 'ch4'))
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



Module loading error in django trunk.

2010-05-18 Thread ben
Hi All,

After a recent svn update to my copy of Django/trunk I’ve been getting
a persistent error relating to module loading (see below). I am able
to create the same error from many but not all views/requests.

Interesting, when I run my code against a slightly older version of
Django trunk (at Rev. 13079) I don’t get these errors.

Is this a bug, or have I missed some backwards incompatible change?
I’ve searched around and came up with nothing? Any insights or
suggestions much appreciated.

kindly,
Ben.


Example Error:

TypeError at /admin/auth/user/1787/

find_module() takes exactly 3 arguments (2 given)

Request Method: GET
Request URL:http://0.0.0.0/admin/auth/user/1787/
Django Version: 1.2.1 pre-alpha SVN-13291
Exception Type: TypeError
Exception Value:

find_module() takes exactly 3 arguments (2 given)

Exception Location: / django/utils/module_loading.py in
module_has_submodule, line 12

Python Executable: /

Python Version: 2.6.4

Python Path:['/new-mos', '/new-mos/django', '/new-mos/contrib', '/
usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg', '/
usr/local/lib/python2.6/site-packages/Genshi-0.5.1-py2.6-freebsd-6.3-
RELEASE-p1-i386.egg', '/usr/local/lib/python2.6/site-packages/
pytz-2009l-py2.6.egg', '/usr/local/lib/python2.6/site-packages/
Jinja2-2.1.1-py2.6-freebsd-6.3-RELEASE-p1-i386.egg', '/usr/local/lib/
python2.6/site-packages/Pygments-1.0-py2.6.egg', '/usr/local/lib/
python2.6/site-packages/flup-1.0.2-py2.6.egg', '/usr/local/lib/
python2.6/site-packages/Sphinx-0.6.3-py2.6.egg', '/usr/local/lib/
python2.6/site-packages/PyAMF-0.5-py2.6-freebsd-6.3-RELEASE-p1-
i386.egg', '/usr/local/lib/python2.6/site-packages/Markdown-2.0.1-
py2.6.egg', '/usr/local/lib/python2.6/site-packages/
python_memcached-1.44-py2.6.egg', '/usr/local/lib/python2.6/site-
packages/Trac-0.11.5-py2.6.egg', '/usr/local/lib/python2.6/site-
packages/paramiko-1.7.6-py2.6.egg', '/usr/local/lib/python2.6/site-
packages/pycrypto-2.0.1-py2.6-freebsd-6.3-RELEASE-p1-i386.egg', '/usr/
local/lib/python26.zip', '/usr/local/lib/python2.6', '/usr/local/lib/
python2.6/plat-freebsd6', '/usr/local/lib/python2.6/lib-tk', '/usr/
local/lib/python2.6/lib-old', '/usr/local/lib/python2.6/lib-dynload',
'/usr/local/lib/python2.6/site-packages', '/usr/local/lib/python2.6/
site-packages/PIL', '/usr/local/lib/python2.6/site-packages/
pythonutils', '/new-mos/contrib/satchmo/apps']


An Example Traceback:

Traceback (most recent call last):

  File "/django/core/handlers/base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/new_mos/views.py", line 24, in index
return render_to_response('index.html',
context_instance=Context(request, data))

  File "/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs),
**httpresponse_kwargs)

  File "/django/template/loader.py", line 181, in render_to_string
t = get_template(template_name)

  File "/django/template/loader.py", line 160, in get_template
template = get_template_from_string(template, origin,
template_name)

  File "/django/template/loader.py", line 168, in
get_template_from_string
return Template(source, origin, name)

  File "/django/template/__init__.py", line 158, in __init__
self.nodelist = compile_string(template_string, origin)

  File "/django/template/__init__.py", line 186, in compile_string
return parser.parse()

  File "/django/template/__init__.py", line 282, in parse
compiled_result = compile_func(self, token)

  File "/django/template/loader_tags.py", line 197, in do_extends
nodelist = parser.parse()

  File "/django/template/__init__.py", line 282, in parse
compiled_result = compile_func(self, token)

  File "/django/template/defaulttags.py", line 917, in load
try:

  File "/django/template/__init__.py", line 1040, in get_library
lib = import_library(taglib_module)

  File "/django/template/__init__.py", line 992, in import_library
if not module_has_submodule(app_module, taglib):

  File "/django/utils/module_loading.py", line 12, in
module_has_submodule
# zipimport.zipimporter.find_module is documented to take

TypeError: find_module() takes exactly 3 arguments (2 given)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Module loading error in django trunk.

2010-05-20 Thread ben


On May 18, 9:35 pm, Russell Keith-Magee 
wrote:
> On Tue, May 18, 2010 at 6:12 PM, ben  wrote:
> > Hi All,
>
> > After a recent svn update to my copy of Django/trunk I’ve been getting
> > a persistent error relating to module loading (see below). I am able
> > to create the same error from many but not all views/requests.
>
> > Interesting, when I run my code against a slightly older version of
> > Django trunk (at Rev. 13079) I don’t get these errors.
> > Is this a bug, or have I missed some backwards incompatible change?
>
> It's certainly possible you've found a bug. The module that is raising
> errors was subject to a number of changes in the last days of 1.2
> preparation, and while we've added lots of tests to make sure module
> loading works as expected, it's possible we've missed some edge cases.
>
> There is one thing that is a little suspicious. Your stack track
> contains the following at the end:
>
> File "/django/utils/module_loading.py", line 12, in
> module_has_submodule
>    # zipimport.zipimporter.find_moduleis documented to take
>
> This indicates that there is some confusion over exactly what code is
> running. Line 12 of module_loading.py in 1.2-final is a call tofind_module, 
> not a comment about zipimport. The first step in
> debugging this will be to purge all your .pyc files in case some
> timestamp problems are causing some stale code to execute.
>
> If you still see the problem, the next thing we need to know is
> exactly what is being imported, from where -- and most importantly --
> by what. Assuming the line numbers in the stack trace are correct, the
> block of code that you are tripping over is a walk through
> sys.meta_path, which suggests that you are using a custom module
> loader of some kind. We're going to need lots of details on exactly
> what your stack is doing - how you are storing modules, how they are
> being loaded, any special cases you may have, etc.
>
> The stack trace you've given us looks like it's been cut from a
> standard Django 500 page; if this is the case, it would be helpful to
> have all the local stack information from the last stack frame -- all
> the local variables, as well as anything you can furnish about
> sys.path and sys.meta_path. Ideally, this will lead to a simple test
> case where you can give us the exact conditions under which the
> problem arises.
>
> Yours,
> Russ Magee %-)
>

I have performed a system wide root level expunge of all .pyc's
and a svn up to 1.2.1 pre-alpha SVN-13294, but this sporadic error
still persists.

The same view will not always trigger the error, sometimes the view
function will run successfully, others not.

If i walk though the procedure with pdb (and if i understand what it
is telling me) it seems to indicate an issue with loading taglib and
perhaps one of my apps called 'featured'. but why would this app now
fail to be loaded properly, when previous to django Rev13079 it loaded
fine?

Below is a more full (read lengthy) stack trace. and some pdb output.

If there is more information that i can provide to assist please let
me know, and how to gather it.

Thanks in advance,
Ben


-
Example 500 tracback & request info 

TypeError at /radio/

find_module() takes exactly 3 arguments (2 given)

Request Method: GET
Request URL:http://0.0.0.0:8000/radio/
Django Version: 1.2.1 pre-alpha SVN-13294
Exception Type: TypeError
Exception Value:

find_module() takes exactly 3 arguments (2 given)

Exception Location: /workspace/mos-trunk-pre/django/utils/
module_loading.py in module_has_submodule, line 12
Python Executable:  /sw/bin/python2.6
Python Version: 2.6.4
Python Path:['/workspace/mos-trunk-pre', '/workspace/mos-trunk-pre/
contrib', '/workspace/mos-trunk-pre/new_mos', '/sw/lib/python2.6/site-
packages/pip-0.6-py2.6.egg', '/sw/lib/python2.6/site-packages/
Sphinx-0.6.3-py2.6.egg', '/sw/lib/python2.6/site-packages/docutils-0.6-
py2.6.egg', '/sw/lib/python2.6/site-packages/Jinja2-2.2.1-py2.6.egg',
'/sw/lib/python2.6/site-packages/Pygments-1.1.1-py2.6.egg', '/sw/lib/
python2.6/site-packages/Satchmo-1.0_pre-py2.6.egg', '/sw/lib/python2.6/
site-packages/paramiko-1.7.6-py2.6.egg', '/Users/ben/src/pyamf', '/sw/
lib/python26.zip', '/sw/lib/python2.6', '/sw/lib/python2.6/plat-
darwin', '/sw/lib/python2.6/plat-mac', '/sw/lib/python2.6/plat-mac/lib-
scriptpackages', '/sw/lib/python2.6/lib-tk', '/sw/lib/python2.6/lib-
old', '/sw/lib/python2.6

hyperlinks within admin interface

2010-05-21 Thread Ben
Is it possible to mess with the __unicode__ method of a model to
enable a model instance to return a link to itself when viewed within
the admin interface? What I want is for there to be a link on an item
in an inline which takes the user to it's own edit page.

For example, I have a Survey system where we have questionnaires with
pages and questions. I use a questions_in_page model to store extra
attributes for the many_to_many, and this is what appears as an inline
in the Page admin view (i.e. you can't edit the question itself from
the Page admin view, only the object in the link table). I'd like to
be able to create links directly to the questions...

Any suggestions much appreciated.

Ben

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



Deploying Django on a server with mod_userdir

2010-05-21 Thread Ben
Hi everyone, I'm just starting out with Django and really enjoying it.
For a project I am trying to install it on an Apache server at school
with multiple users. The userdir module is enabled such that users can
create their own websites. I'd like to allow some of these users to
tinker with Django.

I have administrator access but need to make it easy for regular users
to deploy their own Django websites if they are so inclined. I have
installed mod_wsgi and mod_userdir, and configured everything as such:

/home/username/django/  is where their Django 
application lives
/home/username/django/apache/   contains the WSGI interface file
/home/username/www/ is their website directory
/home/username/www/media/   is where their Django media 
files live

example.com/~username/  is their static website
example.com/~username/django/   WSGI mounts the Django application at /
~username/django/

The problem I am having is actually accessing my test Django website.
When I attempt to access example.com/~username/django/admin/, I get
the Django 404 debug message. So, I know it's at least running
correctly. I've uncommented the three lines from urls.py to enable
admin access and added the django.contrib.admin package to
INSTALLED_APPS in settings.py. I ran syncdb.

I've tried configuring urls.py to map the admin to ~username/django/
admin and django/admin as well, with no luck. If anyone could help me
out I'd really appreciate it!

Thanks,

Benjamin Webber

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



NullBooleanField default to unknown

2012-03-16 Thread Ben
I have a NullBooleanField that I would like to show up in my admin
interface as radio buttons with unknown selected by default.

# I have the following simplified files

## models.py ##
class Value(models.Model):
presence = models.NullBooleanField(default=False)

## admin.py ##
PRESENCE_CHOICES = ((True, 'True'), (False, 'False'), (None, 'None') )
class ValueAdmin(admin.ModelAdmin):
formfield_overrides = {
models.NullBooleanField: {'widget':
RadioSelect(choices=PRESENCE_CHOICES)}
}
admin.site.register(Value, ValueAdmin)

This behaves very closely to what I desire, but I don't know what I
could replace the False with in:
presence = models.NullBooleanField(default=False)
in order to make it behave as I would like.

Thanks so much for your time,
Ben R.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 testing

2013-07-08 Thread ben


On Monday, July 8, 2013 7:49:53 AM UTC-4, larry@gmail.com wrote:
>
>
>
> Ah, I missed that in the docs. Thanks. When I renamed it to tests.py 
> it got picked up. 
>
> But in the django/contrib dirs (e.g. django/contrib/auth) the tests 
> are in a tests sub dir and are not called tests.py and they seem to 
> get run. 
>

Django will run all tests imported from the tests module. Check out the 
__init__.py in django/contrib/auth/tests and you'll see it imports all of 
the tests from the other files in the test dir.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: unit testing

2013-07-09 Thread ben
Also note that Django 1.6 will bring a better test discovery mechanism. See 
the full details at 
https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module

Django 1.6 ships with a new test runner that allows more flexibility in the 
> location of tests. The previous runner (
> django.test.simple.DjangoTestSuiteRunner) found tests only in the 
> models.py and tests.py modules of a Python package 
> inINSTALLED_APPS
> .
> The new runner (django.test.runner.DiscoverRunner) uses the test 
> discovery features built into unittest2 (the version of unittestin the 
> Python 2.7+ standard library, and bundled with Django). With test 
> discovery, tests can be located in any module whose name matches the 
> pattern test*.py.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Django Success Story

2008-02-12 Thread Ben

If you'd like to read about the recent success of a summer project
involving Django, read on.

I've been playing with django in my spare time for a couple years.
I've written a simple blog app, and have half-finished a few sizeable
apps, one of which will be put on a vps by the end of the semester.

This past summer, my fiance worked in an REU to develop an online
learning module for a graduate course. I promised to help her a bit
with the details if she chose to use Django. By the end of the 8 week
summer project, all the code and templates had been written,
documented, tested, and debugged, and most of the content was in
place. The first 2-3 weeks were spent learning the content of the
course, and the last week was spent installing everything on her
supervisor's machine and teaching her how to create the rest of the
content. (MySQL on windows can be annoying.) So, about 20 hours per
week times about 4 weeks produces a debugged cross-platform webapp.

Anyway, my fiance just got an email from the supervisor to say that
the learning module was recently used in the course, and just about
everybody loved it. There were no technical difficulties, the
professor was impressed, and the TA said it would be a good tool
throughout the class.

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



404 on admin media files and mod_python

2008-04-25 Thread Ben

Hello

The issue of how to serve the admin media files using mod_python has been dealt 
with several times before, and AFAICS I've followed the advice given (and the 
documentation), but I still get a 404 on the admin media files.   I've already 
removed "Apache expert" from my CV.
Any suggestion appreciated.   

#settings.py:
ADMIN_MEDIA_PREFIX =  '/admin_media/'

#urls.py:
urlpatterns = patterns('',
 (r'^requests/', include('mysite.requests')),
 (r'^admin/', include('django.contrib.admin.urls')),
 (r'^admin_media/', include('django.contrib.admin.urls')),
)


Apache config:
Alias /admin_media/ /var/www/mysite/admin_media

   SetHandler None


#Apache log file (Result of above config)
GET /admin_media/css/dashboard.css HTTP/1.1" 404 3571 "http://mysite.com/admin/";


Receive Notifications of Incoming Messages
Easily monitor multiple email accounts & access them with a click.
Visit http://www.inbox.com/notifier and check it out!

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



Re: 404 on admin media files and mod_python

2008-04-25 Thread Ben

> Darryl wrote:
> You don't need admin_media in the urls.py file as it shouldn't make it
> as far as Django.

Thanks for your reply. I agree, but desperation made me doubt what I knew

 
> Unless you've copied the media files from the Django source into your
> web root, it needs to point at the admin media directory in your django
> source. 

I did indeed copy the media files to the web root.  However, aliasing them to 
the django source makes no diffference:
Alias /admin_media/ /usr/lib/python2.4/site-packages/django/contrib/admin/media/

It still gives me a 404


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

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



Re: 404 on admin media files and mod_python

2008-04-25 Thread Ben

Karen wrote:
> If you include the trailing slash on the first part (url-path), then you
> need to include it also on the second part.

Thanks for your reply.  I now have the trailing slash in both places, but still 
a 404

>> 
> 
> Check the error log as well, this will print out the actual file name
> apache
> is trying to read.  For the config you have posted, I expect you will see
> there is a slash missing between 'admin_media' and 'css'.

There is nothing of interest in the error log.  The slashes and everything else 
look OK in the access log:
GET /admin_media/css/dashboard.css HTTP/1.1" 404 2054

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



Re: 404 on admin media files and mod_python

2008-04-25 Thread Ben

Karen wrote:
> You did restart apache after making the change?
Yes 


> the error log that will show the cause of the 404 (assuming the url is
> being
> handled by apache itself), since it is where you will see the actual file
> name apache is trying to access.  If you see nothing about the admin
> media
> file in the error log, that would seem to imply your SetHandler None for
> the
> admin media urls isn't taking effect.

Yes, this seems to be the problem, because if I visit 
http://mysite.com/admin_media/css/dashboard.css I get a Django 404 page - not 
an Apache 404


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



Re: 404 on admin media files and mod_python

2008-04-25 Thread Ben

Karen wrote:
> Where in your apache config is the  relative to your 
> Django  block?  It sounds like you need to reverse 
> the order, so that the admin_media location over-rides the Django one, not 
> vice-versa.

Thats it!  Your'e a star!
I've put the admin_media stuff below the Django  block and it now 
works fine
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



website template compatible with django

2007-08-01 Thread Ben

Hi all,
I am a total Django newbie.  Hence the probably silly questions:
There are professional-looking website templates for sale in several
places (templatemonster, etc).
Can those be used easily with Django ?
Do they need to be designed specifically for Django ?  Do you know of
any vendor that does it ?
If not, what to look for in a template order to make sure it will be
relatively easy to use with Django ?
Thanks a lot!


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



Detecting changed fields when saving an object

2007-10-30 Thread Ben

I'm trying to create an audit trail for a particular model, capturing
all changes made on the objects.

My immediate idea was to subclass the save() method on the model and
compare the values both before and after calling the parent save
method. This would work, but it would mean I would have to update this
whenever a new field was added to the model which is both non-DRY and
rather tedious.

Is there any django way of doing this? Something like:

def save():
  for all fields in this object:
if field is now different:
  do audit here
  super(blah, self).save()

Cheers,
Ben.


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



Re: Detecting changed fields when saving an object

2007-10-30 Thread Ben

On Oct 30, 7:31 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 10/30/07, Ben <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to create an audit trail for a particular model, capturing
> > all changes made on the objects.
>
> You might want to read this:
>
> http://code.djangoproject.com/wiki/AuditTrail

If I could have described the type of answer I wanted, it would have
been exactly that :)

Thanks,
Ben.


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



Re: Detecting changed fields when saving an object

2007-10-30 Thread Ben

On Oct 30, 7:31 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 10/30/07, Ben <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to create an audit trail for a particular model, capturing
> > all changes made on the objects.
>
> You might want to read this:
>
> http://code.djangoproject.com/wiki/AuditTrail

Actually, that's given me ideas but I can't seem to work out how to do
what I want. That works by simply storing the values after the change
each time the model is updated. However, I don't seem to have both the
before and after values in a single method, they are the same before
and after the parent save() call.

Using signals seems to have this problem as well, I can't compare the
before and after values at any one time.


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



Re: Detecting changed fields when saving an object

2007-10-30 Thread Ben

On Oct 30, 10:07 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:

> Is there a particular reason you need the before and after, instead of
> just the after? Getting the before values would either require an
> additional query during your save, or you'd have to overload the
> __init__ method to store the original values somewhere.

I don't specifically need the before value, I need to know which of
the fields have changed.


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



Re: Detecting changed fields when saving an object

2007-10-30 Thread Ben

On Oct 30, 10:33 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:

> That's the basic idea, anyway. Hope this helps.

Spot on, it was overriding __init__() that does it :)

Many thanks,
Ben.


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



Re: geodjango apache vs lighttpd

2008-09-23 Thread Ben Eliott

Yup as you say, it was apache + mod_python switched to lighttpd +  
fastcgi. Sounds like it could well be mod_python / Apache issue at the  
root of it.



On 23 Sep 2008, at 21:47, Jashugan wrote:

>
> Did you switched from Apache + mod_python to Lighttpd + FCGI? If so,
> are you sure it wasn't a problem with mod_python versus Apache in
> general? I'm having some issues with mod_python unrelated to
> geodjango. It seems there are certain modules that work in the python
> interpreter that will cause Apache+mod_python to stall.
> >


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



Re: save existing jpg to model

2008-10-17 Thread Ben Eliott

Hi Steve,
Nope, Linux machine...
???

On 17 Oct 2008, at 01:30, Steve Holden wrote:

>
> [EMAIL PROTECTED] wrote:
>> I have users dumping jpgs into a folder within the media root, the
>> idea is to monitor this folder and programmatically add the jpgs to
>> certain model instances based on a naming convention. It all works
>> fine... except... every time i put a jpg in File object and save to a
>> model the  jpg gets corrupted.
>>
>> I've tried with both regular File() object and default_storage.
>>
>> f = open('%s' % infile, 'w')
>> file = File(f)
>> #file = default_storage.open(infile, 'wb')
>> ProductImage.objects.create(product=product,sort=sort,picture=file)
>>
>> what am i missing here - should i be using PIL in some way?
>>
> Are you perchance running on Windows? If so you must write the files  
> in
> binary mode to avoid the content being mangled ("\n" will be  
> replaced by
> "\r\n" wherever it occurs).
>
> regards
> Steve
>
>
> >


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



Admin interface crashes when adding a new item with a ForeignKey

2008-11-10 Thread Ben Gerdemann

Good morning all,

This problem sure seems like a bug, but it's such a common operation
that I must be doing something wrong. I am using the admin interface
to add a new student to my database. At the same time I also want to
add the parents of the student, so I click on the "+" icon on the
student page to add the data for the parents. The data for the parents
saves fine, but when I click to save the student I always get an error
(copied below). If I do the operation in two steps, adding the parent
first then going to the student page and adding the student linked to
the parents, everything works fine. In fact, if I simply click back
from the error page to the student page I submitted from, click reload
so the parent now appears in the select box, select the parent and
then click save everything works too.

Looking at the traceback, it appears the value of the field for the
ForeignKey in the student that points to the parent has a value of
u"None" when I suppose that it should have an integer value that
points the parent primary key. Anyway, I'm not expert here, but I hope
that someone can help out. This operation seems so common that I must
be doing something wrong.

Cheers,
Ben

Environment:

Request Method: POST
Request URL: http://www.moviemago.com/admin/students/aluno/add/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.4.3
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'ETF.students',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/sites.py"
in root
  158. return self.model_page(request, *url.split('/',
2))
File "/usr/lib/python2.4/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/sites.py"
in model_page
  177. return admin_obj(request, rest_of_url)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/
options.py" in __call__
  191. return self.add_view(request)
File "/usr/lib/python2.4/site-packages/django/db/transaction.py" in
_commit_on_success
  238. res = func(*args, **kw)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/
options.py" in add_view
  490. if form.is_valid():
File "/usr/lib/python2.4/site-packages/django/forms/forms.py" in
is_valid
  120. return self.is_bound and not bool(self.errors)
File "/usr/lib/python2.4/site-packages/django/forms/forms.py" in
_get_errors
  111. self.full_clean()
File "/usr/lib/python2.4/site-packages/django/forms/forms.py" in
full_clean
  224. value = field.clean(value)
File "/usr/lib/python2.4/site-packages/django/forms/models.py" in
clean
  650. value = self.queryset.get(**{key: value})
File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
get
  297. clone = self.filter(*args, **kwargs)
File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
filter
  483. return self._filter_or_exclude(False, *args, **kwargs)
File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in
_filter_or_exclude
  501. clone.query.add_q(Q(*args, **kwargs))
File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py"
in add_q
  1224. can_reuse=used_aliases)
File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py"
in add_filter
  1167. self.where.add((alias, col, field, lookup_type,
value), connector)
File "/usr/lib/python2.4/site-packages/django/db/models/sql/where.py"
in add
  48. params = field.get_db_prep_lookup(lookup_type,
value)
File "/usr/lib/python2.4/site-packages/django/db/models/fields/
__init__.py" in get_db_prep_lookup
  202. return [self.get_db_prep_value(value)]
File "/usr/lib/python2.4/site-packages/django/db/models/fields/
__init__.py" in get_db_prep_value
  671. return int(value)

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



Re: Admin interface crashes when adding a new item with a ForeignKey

2008-11-10 Thread Ben Gerdemann

I figured out the problem. I used inspectdb to import my models from
an existing database. I then marked the primary_key fields with
primary_key=True, but I didn't should have also converted them from
IntegerField to AutoField. Once I did that everything worked fine. I
hope this message saves someone else from debugging in the future. For
future reference the assertion was: "invalid literal for int(): None"

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



Intercepting return from new ForeignKey popups? (RelatedObjectLookups.js)

2008-11-16 Thread Ben Gerdemann

I've been experimenting with an autocomplete widget for ForeignKey
model fields following the very useful advice from Jannis here:
http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/
The basic idea is to create a widget with a hidden text field that
contains the ForeignKey ID that is updated by the results of the
autocomplete field.

I've got everything working correctly except for one problem. When
adding a new foreign key by clicking on the "+" the hidden field is
correctly updated with the primary key of the new object, but the
autocomplete field still shows the previous text which is confusing to
the user. The insertion still works correctly of course as it's the
hidden field that is actually used. Any ideas on how to correct this?
It seems the JavaScript code RelatedObjectLookups.js controls this
behavior, but I can't quite get my head around what to do. I need
someway to intercept the return from the Popup to update fields on my
form.

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



Frustration with custom Inline forms

2008-11-17 Thread Ben Gerdemann

I'm trying to customize the inline forms of a model that are displayed
when I'm editing it's parent, but I can't get anything to work! Can
someone help? First, here are my models:

class T22Pais(models.Model):
a22_id = models.AutoField(primary_key=True)
a22_nome_1 = models.CharField("Nome Responsavel
#1",max_length=255)

class T55Visitas(models.Model):
a55_id = models.IntegerField(primary_key=True)
a55_visita_agendada = models.DateTimeField(null=True, blank=True)
a22 = models.ForeignKey(T22Pais,verbose_name="Pais")

The documentation says "The InlineModelAdmin class is a subclass of
ModelAdmin so it inherits all the same functionality as well as some
of its own," so first I tried this:

class T22PaisAdmin(admin.ModelAdmin):
inlines = [T55VisitasInline]

class T55VisitasInline(admin.StackedInline):
exclude = ('a55_id')
model = T55Visitas

but nothing changes. I tried a couple variations of the name without
and without quotes and adding the model hierarchy exclude=
('T55Visitas.a55_id') but nothing worked.

Then I noticed that the documentation refers to form and formset
fields in InlineModelAdmin. The documentation isn't very clear how to
use these, but I tried the following things and nothing had any
effect: the inline form was always rendered with all of its fields:

class T55VisitasInlineForm(forms.ModelForm):
class Meta:
model = T55Visitas
exclude = ('a55_id')

class T55VisitasInline(admin.StackedInline):
model = T55Visitas
form = T55VisitasInlineForm

tried adding a formset:

class T55VisitasInline(admin.StackedInline):
model = T55Visitas
form = T55VisitasInlineForm
formset = inlineformset_factory(
T22Pais,
T55Visitas,
exclude = ('a55_id')
)

adding the same form back into the formset even though I'm already
setting T55VisitasInline.form, but no dice. :(

class T55VisitasInline(admin.StackedInline):
model = T55Visitas
form = T55VisitasInlineForm
formset = inlineformset_factory(
T22Pais,
T55Visitas,
form = T55VisitasInlineForm,
exclude = ('a55_id')
)

How can I get this to work??? Grrr... Ideally, I'd like to have a
fully custom inline form using "fieldsets," but for now I'll settle
for just hiding fields.

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



Re: Frustration with custom Inline forms

2008-11-17 Thread Ben Gerdemann

Ok, so I just noticed that the a55_id field which is the primary key,
was declared as an IntegerField instead of an AutoField which is why
it was showing up on the inline form, but I still can't get any of the
other fields excluded from the inline form so the problem is still
there.

Also, if it helps for understanding Pais = Parents and Visitas =
Visits in Portuguese.

Thanks again for any and all help.

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



Re: Custom Inline Forms with InlineFormsets

2008-11-17 Thread Ben Gerdemann

I'm having a similar problem that I posted about here:

http://groups.google.com/group/django-users/browse_thread/thread/bb4c792f13b2eceb#

Did you find a solution that works for you? Sorry, I couldn't figure
out from your post exactly what you did. I tried using
inlineformset_factory() like you described, but I couldn't get it to
work. Are you working inside the admin interface? Perhaps that is my
problem....

Cheers,
Ben

On Nov 10, 6:49 pm, John Boxall <[EMAIL PROTECTED]> wrote:
> I take it back.
>
> I over thought it -
>
> Instead of using a custominlineform model just pass the parameters
> directly to inlineformset_factory as per it's spec:
> def inlineformset_factory(parent_model, model, form=ModelForm,
>   formset=BaseInlineFormSet, fk_name=None,
>   fields=None, exclude=None,
>   extra=3, can_order=False, can_delete=True,
> max_num=0,
>   formfield_callback=lambda f:
> f.formfield()):
>
> On Nov 10, 12:47 pm, John Boxall <[EMAIL PROTECTED]> wrote:
>
> > Heyo Django Users,
>
> > I'm in a bit of a pickle with InlineFormsets -
>
> > I'm following the example at the Django 
> > Docs:http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-i...
>
> > I've got two models:
> > 
> > class Author(models.Model):
> > name = models.CharField(max_length=100)
>
> > class Book(models.Model):
> > author = models.ForeignKey(Author)
> > title = models.CharField(max_length=100)
> > description = models.CharField(max_length=255)
> > 
>
> > And I want to have aninlineformsets to edit authors & booksinline.
>
> > What I want to do is just show the title field of the Book so  I have
> > a custom ModelForm for that:
>
> > 
> > class BookModelForm(forms.ModelForm):
> > class Meta:
> > model = Book
> > fields = ('title',)
> > 
>
> > Everything looks good, I'm all ready to construct my
> > inlinemodelformset using inlineformset_factory...
> > 
> > from django.forms.models import inlineformset_factory
> > # ???
> > BookFormSet = inlineformset_factory(Author, Book)
> > 
>
> > And doh! inlineformset_factory doesn't seem to want to let me set the
> > form for 
> > theinlinemodel.http://code.djangoproject.com/browser/django/trunk/django/forms/model...
>
> > Anyone have any luck with this?
>
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom form/formset for edit inline

2008-11-17 Thread Ben Gerdemann

I'm having exactly the same problem which I posted about here
http://groups.google.com/group/django-users/browse_thread/thread/bb4c792f13b2eceb#
Have you figured out how to do this? Yours is the third message I've
read by someone trying to customize an inline form without any
solution. I'm beginning to think this probably isn't possible in the
admin interface... :(


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



Re: Frustration with custom Inline forms

2008-11-17 Thread Ben Gerdemann

Thank you thank you thank you! I knew I was doing something simple
wrong. :)

I've been enjoying my experience using Django so far, but one thing I
have noticed is that the error messages (or in this case lack of error
messages) can be frustrating. It sometimes takes me quite a while to
figure out what caused an exception especially if there are no line
numbers of my own code. In this case, it's actually the Python syntax
and I'm not sure what Django could do if your syntax is wrong, but I
sure spent a while tracking this down....

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



Re: problem enabling the admin interface

2008-11-19 Thread Ben Eliott

installed apps needs 'django.contrib.sessions',

http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-http-sessions

On 19 Nov 2008, at 19:42, Bryan Oakley wrote:

>
> I inherited a django app and I'm trying to enable the admin interface
> without much luck. When I try to access the admin interface I see this
> at the end of the error log:
>
> OperationalError: no such table: django_session
>
> Sure enough, it's not in my (sqlite) database. If I create a new
> database from scratch that table is not being created:
>
> $ python manage.py syncdb
> Creating table tests_testinfo
> Creating table dashboard_testresult
> Creating table django_admin_log
> Creating table django_content_type
> Installing index for tests.TestInfo model
> Installing index for dashboard.TestResult model
> Installing index for admin.LogEntry model
> $
>
> My settings.py includes this:
>
> MIDDLEWARE_CLASSES = (
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.gzip.GZipMiddleware',
>'django.contrib.sessions.middleware.SessionMiddleware',
>'django.contrib.auth.middleware.AuthenticationMiddleware',
> #'django.middleware.doc.XViewMiddleware',
> )
>
> INSTALLED_APPS = (
>  'web.tests',
>  'web.dashboard',
>  'django.contrib.admin',
>  'django.contrib.contenttypes',
> )
>
> Anyone have advice for what I might be doing wrong?
>
>
> >


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



Re: Django template tag question

2008-11-19 Thread Ben Eliott

what happens when you go into the python interpreter and write
import basic

On 19 Nov 2008, at 16:58, goblue0311 wrote:

>
> I'm implementing the popular basic.blog application, which requires
> the inclusion of the basic.inlines project. However, I cannot seem to
> get my application to locate the basic.inlines project. I have asked
> this question in the basic.apps group, but I think it's generic enough
> to be posted here as well.
>
> I have installed the module in my site-packages directory, which is on
> my PYTHONPATH. The basic.inlines module is located in a folder called
> 'basic' as per the installation instructions, and basic.inlines is
> included in INSTALLED_APPS.
>
> However, while trying to run syncdb, I get an error stating "no module
> named basic". The question is, how is Django trying to locate this
> package? I was assuming it used PYTHONPATH in conjunction with some
> generic paths, but perhaps I'm missing a step here. Any hints or
> suggestions on how to resolve this?
>
> Thanks!
>
> >


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



Re: problem enabling the admin interface

2008-11-19 Thread Ben Eliott

Sounds like it could be easier to learn by building piecemeal from the  
ground up than working through a dodgy set up.
Keep going to break through the initial stages of getting to grips  
with Django, it'll reward you in the end.

On 19 Nov 2008, at 21:53, Bryan Oakley wrote:

>
> Thank you. That was certainly part of the problem. I also discovered I
> needed to add django.contrib.auth. And oddly, a problem where I had an
> admindocs (plural) directory but the admin site was looking for
> admindoc (singular).
>
> Eventually, with your help and some educated guesses I'm finally up
> and running. It's been surprisingly difficult, but I'm not tuned in to
> the django world so maybe these are all known issues.
>
> Thanks again!
>
> On Nov 19, 2:49 pm, Ben Eliott <[EMAIL PROTECTED]> wrote:
>> installed apps needs 'django.contrib.sessions',
>>
>> http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics- 
>> htt...
>>
>> On 19 Nov 2008, at 19:42, Bryan Oakley wrote:
>>
>>
>>
>>> I inherited a django app and I'm trying to enable the admin  
>>> interface
>>> without much luck. When I try to access the admin interface I see  
>>> this
>>> at the end of the error log:
>>
>>> OperationalError: no such table: django_session
>>
>>> Sure enough, it's not in my (sqlite) database. If I create a new
>>> database from scratch that table is not being created:
>>
>>> $ python manage.py syncdb
>>> Creating table tests_testinfo
>>> Creating table dashboard_testresult
>>> Creating table django_admin_log
>>> Creating table django_content_type
>>> Installing index for tests.TestInfo model
>>> Installing index for dashboard.TestResult model
>>> Installing index for admin.LogEntry model
>>> $
>>
>>> My settings.py includes this:
>>
>>> MIDDLEWARE_CLASSES = (
>>>'django.middleware.common.CommonMiddleware',
>>>'django.middleware.gzip.GZipMiddleware',
>>>   'django.contrib.sessions.middleware.SessionMiddleware',
>>>   'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> #'django.middleware.doc.XViewMiddleware',
>>> )
>>
>>> INSTALLED_APPS = (
>>> 'web.tests',
>>> 'web.dashboard',
>>> 'django.contrib.admin',
>>> 'django.contrib.contenttypes',
>>> )
>>
>>> Anyone have advice for what I might be doing wrong?
> >


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



Re: Customising slugify filter

2008-11-19 Thread Ben Eliott

Um, what about a regular python function which replaces '/' with '-'  
then calls slugify

On 19 Nov 2008, at 20:44, Nick wrote:

>
> Hi,
>
> I have the following strings which is run through the slugify filter
> on my site:
>
> "Business/Executives"
>
> and it becomes "businessexecutives".  I'd like this to instead become
> "business-executives" (as they are actually two seperate words).
>
> I've tracked down the slugify filter to django/template/
> defaultfilters.py, but can't get my head round the regular expressions
> required to replace "/" with "-".
>
> Alternatively, instead of changing the core Django install, can I
> "extend" slugify in my own app to have this behaviour?
>
> Any help very much appreciated!
>
> Thanks,
> Nick
> >


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



Re: Help for crontab

2008-11-20 Thread Ben Eliott

recommend you check out django-extensions jobs.
http://code.google.com/p/django-command-extensions/


On 20 Nov 2008, at 12:53, laspal wrote:

>
> hi,
> I am writing cron job for my application but run into problem
>
> from django.core.management import setup_environ
> import settings
> setup_environ(settings)
>
> from test.crm.models import CronEmail
>
> Basically the problem is I am not able to import any model.
>
> I tried this too:
> pathname = os.path.dirname(sys.argv[0])
> sys.path.append(os.path.abspath(pathname))
> sys.path.append(os.path.normpath(os.path.join(os.path.abspath
> (pathname), '../')))
> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> but still can import any model.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Implement file upload in admin interface

2008-11-27 Thread Ben Lau

Hi all,

  I would like to implement a data upload feature in admin interface
for my application. A form with file upload field will be show for a
data model.
The file should be a XML file which is generated by another program
and contain more than one record of data.

  Anybody implemented similar thing before ? Seem that I could
implement it by override ModelAdmin, but it need to modify a lot of
thing.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Implement file upload in admin interface

2008-11-28 Thread Ben Lau

Hi redbaron,

My approach is to subclass ModelAdmin to implement a import command .
It should need to override the __call__() and create a import_view()
function to handle the import form. Example:

class XXXAdmin(admin.ModelAdmin):



def __call__(self, request, url):

if url == "import":

return self.import_view(request)

else:

return admin.ModelAdmin.__call__(self,request,url)


However, I am still studying how to make the import_view function by
reading the source of ModelAdmin.add_view(). It use quite a lot of
undocumented functions..

On Fri, Nov 28, 2008 at 6:08 PM, redbaron <[EMAIL PROTECTED]> wrote:
>
> I try to implement same thing.I need some place where I could upload
> file, django should parse it and populate database with new data. To
> make it more ease I defined new model BatchUpload with only one field
> batch. Now I need to customize upload handler method in admin site.
> Could anyone give advice how to do it best way?
>
> >
>

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



Re: Implement file upload in admin interface

2008-11-30 Thread Ben Lau

hi,

It is mush easier then my approach. Thanks a lot!

On Fri, Nov 28, 2008 at 9:28 PM, redbaron <[EMAIL PROTECTED]> wrote:
>
>
> My current solution is.
>
> 1. Define new model Batches:
>
> class Batches(models.Model):
>  batchfile = model.FileField(upload_to="noop")
>
> 2. In admin.py define new form with custom validators:
>
> class BatchUploadForm(forms.ModelFormi):
>class Meta:
>model = Batches
>
>def clean_batchfile(self):
>data = self.cleaned_data['batchfile'].read() #here we've got
> uploaded file content
>ret = your_processing_routine(data) #if file is wrong
> processing returns error message
>if ret:
>raise forms.ValidationError(ret)
>
>
> 3. Register customized ModelAdmin for Batches:
>
> class BatchesAdmin(admin.ModelAdmin):
>form = BatchUploadForm #here we've replaced default form to our
> one
>
>def save_model(self, request, obj, form, change):
>pass #nothing save to base actually
>
> >
>

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



Re: dynamic mod wsgi

2008-12-09 Thread Ben Eliott

Graham,
Thank you for coming back personally to such a lowly wsgi question!  I  
started reading your email and thinking the answer was 'no', then  
ended up thinking 'definitely maybe'. I'll keep an eye out in case you  
post more, otherwise i'll follow those links and your directions and  
hope to report back with some progress.
Thanks and Regards,
Ben


On 9 Dec 2008, at 08:23, Graham Dumpleton wrote:

>
>
>
> On Dec 9, 6:53 pm, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>> Hi, I'm converting to the excellent mod_wsgi and wondering if it's
>> possible to make a single httpd virtual host/wsgi file to manage
>> wildcard subdomains.
>>
>> Basically I have an app where i'm creating a new instance for each
>> client and using subdomains. So client1.example.com and
>> client2.example.com both point to the same app, but their own
>> settings.py/django instance.
>>
>> So far so fine.  I've been happily converting to mod_wsgi daemons,
>> creating virtual hosts and independent .wsgi files for each one. But
>> now just wondering whether there is some way i can make this process
>> dynamic so one virtual host/.wsgi file will take care of all these
>> subdomains.
>>
>> I see the advice on the wsgi wiki to push domain sub-directories to
>> different django instances, but i'd rather keep using the subdomains
>> if possible.
>>
>> It looks possible to be able to parse information about the incoming
>> request in the wsgi file and push it to different settings. But i'm
>> not sure what this will do in terms of spawning processes etc, it
>> looks a little dangerous, or maybe this will work. Any advice
>> appreciated thanks!
>
> Start by reading recent discussion:
>
>  
> http://groups.google.com/group/django-users/browse_frm/thread/dfd352162db59ed7
>
> I'll post more tomorrow if have time, have to do some things tonight
> and then out most of the day tomorrow.
>
> In short though, no support for dynamic transient daemon processes
> yet, ie.,:
>
>  http://code.google.com/p/modwsgi/issues/detail?id=22
>
> so, can't get away from using WSGIDaemonProcess for each instance at
> the moment.
>
> One can use dynamic setting of WSGIApplicationGroup via a variable set
> by mod_rewrite to select daemon process as well as set some name
> relevant to settings file. WSGI application wrapper can then be used
> to override DJANGO_SETTINGS_MODULE.
>
> So, information is in that post, you just need to adapt it to your
> situation. That is, use SERVER_NAME rather than REMOTE_USER from
> authentication as basis of selecting daemon process group. You could
> though skip the rewrite maps that allowed multiple levels of
> indirection and made it further dynamic in nature.
>
> Graham
> >


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



Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Ben Eliott

Do you want something like this?
friends_new = models.ManyToManyField("self",symmetrical=False)

On 9 Dec 2008, at 09:06, Darthmahon wrote:

>
> Hi Guys,
>
> Just bumping this up as I still can't figure out why this is
> happening :/
>
> On Dec 8, 9:27 pm, Darthmahon <[EMAIL PROTECTED]> wrote:
>> Hi Guys,
>>
>> I've got a model that has a Many to Many relationship on one of the
>> fields. This relationship is basically on itself though like this:
>>
>> #
>>
>> class UserProfile(models.Model):
>>
>> user= models.ForeignKey(User,  
>> unique=True)
>> friends_new = models.ManyToManyField('UserProfile',  
>> blank=True,
>> related_name='friend_set_new')
>>
>> #
>>
>> I'm trying to "add" to the friends_new field using this code:
>>
>> #
>>
>> # get users
>> initiator_profile = UserProfile.objects.get(user=request.user.id)
>> recipient_profile = UserProfile.objects.get(user=username)
>>
>> # now add them as a friend
>> initiator_profile.friends_new.add(recipient_profile)
>>
>> #
>>
>> Now the problem I'm having is that it is adding the friendship to  
>> BOTH
>> userprofiles, initiator and recipient. And when I try to remove the
>> relationship, again it removes BOTH. So in the database it has two
>> entries when I only expect there to be one.
>>
>> Hope I've made that clear enough, any ideas how to get around this?
>>
>> Cheers,
>> Chris
> >


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



Re: request parsing

2008-12-09 Thread Ben Eliott

request.FILES
If this is what you mean, I think this is kind of django 101, i'd  
recommend having a solid read through the docs which cover all these  
kind of bases really well.


On 9 Dec 2008, at 09:30, Vicky wrote:

>
> If we send a file by post method to a django function how can we
> separate the file from the request?
> >


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



Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Ben Eliott

hmm, don't know. that's the documented approach. you might want to  
investigate intermediary tables/models etc.


On 9 Dec 2008, at 09:24, Darthmahon wrote:

>
> Ahh yes possibly. Any downsides to using this?
>
> On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote:
>> Do you want something like this?
>> friends_new = models.ManyToManyField("self",symmetrical=False)
>>
>> On 9 Dec 2008, at 09:06, Darthmahon wrote:
>>
>>
>>
>>> Hi Guys,
>>
>>> Just bumping this up as I still can't figure out why this is
>>> happening :/
>>
>>> On Dec 8, 9:27 pm, Darthmahon <[EMAIL PROTECTED]> wrote:
>>>> Hi Guys,
>>
>>>> I've got a model that has a Many to Many relationship on one of the
>>>> fields. This relationship is basically on itself though like this:
>>
>>>> #
>>
>>>> class UserProfile(models.Model):
>>
>>>> user= models.ForeignKey(User,
>>>> unique=True)
>>>> friends_new = models.ManyToManyField('UserProfile',
>>>> blank=True,
>>>> related_name='friend_set_new')
>>
>>>> #
>>
>>>> I'm trying to "add" to the friends_new field using this code:
>>
>>>> #
>>
>>>> # get users
>>>> initiator_profile = UserProfile.objects.get(user=request.user.id)
>>>> recipient_profile = UserProfile.objects.get(user=username)
>>
>>>> # now add them as a friend
>>>> initiator_profile.friends_new.add(recipient_profile)
>>
>>>> #
>>
>>>> Now the problem I'm having is that it is adding the friendship to
>>>> BOTH
>>>> userprofiles, initiator and recipient. And when I try to remove the
>>>> relationship, again it removes BOTH. So in the database it has two
>>>> entries when I only expect there to be one.
>>
>>>> Hope I've made that clear enough, any ideas how to get around this?
>>
>>>> Cheers,
>>>> Chris
> >


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



Re: dynamic mod wsgi

2008-12-09 Thread Ben Eliott

Understood. Thanks.

On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:

>
>
>
> On Dec 9, 8:05 pm, Ben Eliott <[EMAIL PROTECTED]> wrote:
>> Graham,
>> Thank you for coming back personally to such a lowly wsgi question! I
>> started reading your email and thinking the answer was 'no', then
>> ended up thinking 'definitely maybe'. I'll keep an eye out in case  
>> you
>> post more, otherwise i'll follow those links and your directions and
>> hope to report back with some progress.
>
> I'll definitely try and say more later when get a chance.
>
> Just do be aware of one thing. By using a single WSGI script file for
> multiple sites, you loose the ability with mod_wsgi daemon mode to
> touch the WSGI script file and cause a single site to be reloaded. One
> would normally use this as a way of reloading a single site without
> the need to restart the whole of Apache. When sharing the single WSGI
> script file across sites, touching the WSGI script file will restart
> all sites using that WSGI script file. If they share the code this may
> actually be want you want, so not a problem, but worth mentioning.
>
> In this arrangement, if you did want to reload one site, for example
> because you change its settings file, you would need to use 'ps' to
> identify process(es) in that daemon process group, based on what
> display-name option was set to, and send all those processes in that
> daemon process group a SIGINT using the 'kill' command. Alternatively,
> you would need to setup a background thread which monitored something
> like the distinct settings file for each site and have the process
> itself send a SIGINT to itself. This would be a variation on
> background reloader described in:
>
>  
> http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_Daemon_Processes
>
> More later.
>
> Graham
>
>> Thanks and Regards,
>> Ben
>>
>> On 9 Dec 2008, at 08:23, Graham Dumpleton wrote:
>>
>>
>>
>>> On Dec 9, 6:53 pm, "[EMAIL PROTECTED]"
>>> <[EMAIL PROTECTED]> wrote:
>>>> Hi, I'm converting to the excellent mod_wsgi and wondering if it's
>>>> possible to make a single httpd virtual host/wsgi file to manage
>>>> wildcard subdomains.
>>
>>>> Basically I have an app where i'm creating a new instance for each
>>>> client and using subdomains. So client1.example.com and
>>>> client2.example.com both point to the same app, but their own
>>>> settings.py/django instance.
>>
>>>> So far so fine.  I've been happily converting to mod_wsgi daemons,
>>>> creating virtual hosts and independent .wsgi files for each one.  
>>>> But
>>>> now just wondering whether there is some way i can make this  
>>>> process
>>>> dynamic so one virtual host/.wsgi file will take care of all these
>>>> subdomains.
>>
>>>> I see the advice on the wsgi wiki to push domain sub-directories to
>>>> different django instances, but i'd rather keep using the  
>>>> subdomains
>>>> if possible.
>>
>>>> It looks possible to be able to parse information about the  
>>>> incoming
>>>> request in the wsgi file and push it to different settings. But i'm
>>>> not sure what this will do in terms of spawning processes etc, it
>>>> looks a little dangerous, or maybe this will work. Any advice
>>>> appreciated thanks!
>>
>>> Start by reading recent discussion:
>>
>>>  http://groups.google.com/group/django-users/browse_frm/thread/dfd3521 
>>> ...
>>
>>> I'll post more tomorrow if have time, have to do some things tonight
>>> and then out most of the day tomorrow.
>>
>>> In short though, no support for dynamic transient daemon processes
>>> yet, ie.,:
>>
>>>  http://code.google.com/p/modwsgi/issues/detail?id=22
>>
>>> so, can't get away from using WSGIDaemonProcess for each instance at
>>> the moment.
>>
>>> One can use dynamic setting of WSGIApplicationGroup via a variable  
>>> set
>>> by mod_rewrite to select daemon process as well as set some name
>>> relevant to settings file. WSGI application wrapper can then be used
>>> to override DJANGO_SETTINGS_MODULE.
>>
>>> So, information is in that post, you just need to adapt it to your
>>> situation. That is, use SERVER_NAME rather than REMOTE_USER from
>>> authentication as basis of selecting daemon process group. You could
>>> though skip the rewrite maps that allowed multiple levels of
>>> indirection and made it further dynamic in nature.
>>
>>> Graham
> >


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



A Top-Level Django Index for the root URL

2008-12-21 Thread Ben Pritchard





Hello everyone,

First, a warning: I'm a total noob but I have really enjoyed working
through the tutorial.

The first post-tutorial thing I've done is construct a top-level page
that gets rendered using:

urlpatterns = patterns('',
    (r'^$', 'mysite.views.index'),    

This was necessary because since I've added (r'^polls/',
include('mysite.polls.urls')), the link http://localhost:8000/
failed to render a response (which is understandable).


The intention is that this page will list all my of sandbox projects. 
So at the moment it just links to http://localhost:8000/polls but (a)
coding the link seems like a HTML solution rather than a Django
solution and (b) it will be tedious to update this html template file
each time I add a new subsection to my site.

So, is there a Django solution that can list the available mini-sites
that are available?

I look forward to any help that someone can offer me.

Thanks,
Ben


p.s.: I've searched the mailing list archives but (not surprisingly)
hits for "top-level" "site" "index" "projects" and "list" are producing
rather a lot of hits!!  One candidate I've found is the sites
framework?  Is the answer hidden in there somewhere?

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





Re: dynamic mod wsgi

2008-12-22 Thread Ben Eliott

Hi Graham,
I've finally managed to get back to the wildcard subdomains & mod_wsgi  
today. Unfortunately the discussion thread you mentioned has  
disappeared and after a few hours i still seem to be doing a good job  
of getting nowhere.

Although you mentioned using mod_rewrite to get hold of the url  
variable, it looks like the %{SERVER} variable in mod_wsgi might take  
care of this already?

My main issue seems to be to accessing the %{SERVER} (or relevant  
mod_rewrite) variable in the .wsgi script, to specify a particular  
settings file.

Within a VirtualHost i have:
WSGIApplicationGroup %{SERVER}
WSGIDaemonProcess %{SERVER} ...threads etc
WSGIProcessGroup %{SERVER}

So this is probably hoplessly wrong also, but if you can give some  
further pointers that would be most kind.
Thanks and Regards,
Ben




On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:

>
>
>
> On Dec 9, 8:05 pm, Ben Eliott  wrote:
>> Graham,
>> Thank you for coming back personally to such a lowly wsgi question! I
>> started reading your email and thinking the answer was 'no', then
>> ended up thinking 'definitely maybe'. I'll keep an eye out in case  
>> you
>> post more, otherwise i'll follow those links and your directions and
>> hope to report back with some progress.
>
> I'll definitely try and say more later when get a chance.
>
> Just do be aware of one thing. By using a single WSGI script file for
> multiple sites, you loose the ability with mod_wsgi daemon mode to
> touch the WSGI script file and cause a single site to be reloaded. One
> would normally use this as a way of reloading a single site without
> the need to restart the whole of Apache. When sharing the single WSGI
> script file across sites, touching the WSGI script file will restart
> all sites using that WSGI script file. If they share the code this may
> actually be want you want, so not a problem, but worth mentioning.
>
> In this arrangement, if you did want to reload one site, for example
> because you change its settings file, you would need to use 'ps' to
> identify process(es) in that daemon process group, based on what
> display-name option was set to, and send all those processes in that
> daemon process group a SIGINT using the 'kill' command. Alternatively,
> you would need to setup a background thread which monitored something
> like the distinct settings file for each site and have the process
> itself send a SIGINT to itself. This would be a variation on
> background reloader described in:
>
>  
> http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_Daemon_Processes
>
> More later.
>
> Graham
>
>> Thanks and Regards,
>> Ben
>>
>> On 9 Dec 2008, at 08:23, Graham Dumpleton wrote:
>>
>>
>>
>>> On Dec 9, 6:53 pm, "ben.dja...@googlemail.com"
>>>  wrote:
>>>> Hi, I'm converting to the excellent mod_wsgi and wondering if it's
>>>> possible to make a single httpd virtual host/wsgi file to manage
>>>> wildcard subdomains.
>>
>>>> Basically I have an app where i'm creating a new instance for each
>>>> client and using subdomains. So client1.example.com and
>>>> client2.example.com both point to the same app, but their own
>>>> settings.py/django instance.
>>
>>>> So far so fine.  I've been happily converting to mod_wsgi daemons,
>>>> creating virtual hosts and independent .wsgi files for each one.  
>>>> But
>>>> now just wondering whether there is some way i can make this  
>>>> process
>>>> dynamic so one virtual host/.wsgi file will take care of all these
>>>> subdomains.
>>
>>>> I see the advice on the wsgi wiki to push domain sub-directories to
>>>> different django instances, but i'd rather keep using the  
>>>> subdomains
>>>> if possible.
>>
>>>> It looks possible to be able to parse information about the  
>>>> incoming
>>>> request in the wsgi file and push it to different settings. But i'm
>>>> not sure what this will do in terms of spawning processes etc, it
>>>> looks a little dangerous, or maybe this will work. Any advice
>>>> appreciated thanks!
>>
>>> Start by reading recent discussion:
>>
>>>  http://groups.google.com/group/django-users/browse_frm/thread/dfd3521 
>>> ...
>>
>>> I'll post more tomorrow if have time, have to do some things tonight
>>> and then out most of the day tomorrow.
>>
>>> In short though, no support for dyna

Re: How to set the from a ModelChoiceField?

2008-12-22 Thread Ben Eliott

I suspect that bots aren't going to follow form submits like this so  
it doesn't matter.
But if you have these GET queries coded into any html  elements,  
thereby becoming part of the sitemap, then it probably will matter.

This is a bit of a common sense punt, i'm not an SEO expert, so  
standing-by to be corrected!



On 22 Dec 2008, at 13:06, mb0...@googlemail.com wrote:

>
> Hello,
>
> I have a ModelChoiceField getting filled up by a database queryset.
> Works fine this far.
> In my template the entries of the select-field look all like this:
> Afghanistan
>
> I know that that the value between the two option tags (Afghanistan)
> can be set by changing the model's __str()__-method. But is there also
> a way to change the way the value-attribut (3) is set? By now it is
> the unique id-field from the database, I guess.
> I would like to change it, to get more SE-friendly urls (when
> submitting the form with GET). Or am I wrong about this?
>
>
> Kind regards,
> Martin
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: dynamic mod wsgi

2008-12-23 Thread Ben Eliott

Strange, that thread is down for me. Maybe it has something to do with  
cacheing in a different locale...

Anyhow, the idea is to create a new django instance and point to  
different settings.py files  for different wildcard subdomains.  here  
is current Vhost:


ServerAlias *.stayunstuck.co.uk
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.stayunstuck\.co\.uk$ [NC]
RewriteRule . - [E=subdomain:%1]

WSGIDaemonProcess test  user=ben group=ben threads=10 processes=1
WSGIProcessGroup %{ENV:subdomain}
WSGIScriptAlias / /home/ben/mod_wsgi/django.wsgi


WSGIApplicationGroup %{ENV:subdomain}
Order deny,allow
Allow from all



The rewrite is assigning the ENV value correctly but  the  
WSGIDaemonProcess has a fixed name. So it  works for a subdomain  
'test', but then fails for anything else.
I'm also not getting how to access the ENV value in the wsgi script to  
specify a different settings file.




On 22 Dec 2008, at 22:00, Graham Dumpleton wrote:

>
>
>
> On Dec 22, 9:44 pm, Ben Eliott  wrote:
>> Hi Graham,
>> I've finally managed to get back to the wildcard subdomains &  
>> mod_wsgi
>> today. Unfortunately the discussion thread you mentioned has
>> disappeared and after a few hours i still seem to be doing a good job
>> of getting nowhere.
>
> I can still access thread with no problems.
>
>> Although you mentioned using mod_rewrite to get hold of the url
>> variable, it looks like the %{SERVER} variable in mod_wsgi might take
>> care of this already?
>>
>> My main issue seems to be to accessing the %{SERVER} (or relevant
>> mod_rewrite) variable in the .wsgi script, to specify a particular
>> settings file.
>>
>> Within a VirtualHost i have:
>> WSGIApplicationGroup %{SERVER}
>> WSGIDaemonProcess %{SERVER} ...threads etc
>> WSGIProcessGroup %{SERVER}
>
> The %{SERVER} value is only magic when used with WSGIApplicationGroup
> directive.
>
>> So this is probably hoplessly wrong also, but if you can give some
>> further pointers that would be most kind.
>
> Can you post a more complete example of your Apache configuration
> showing what you are trying to achieve.
>
> Sorry I didn't get back to you last time, it was a hectic few weeks.
> Things have settled down somewhat now, so I'll go back over your
> original post and work out again what it is you were trying to do.
>
> Graham
>
>> Thanks and Regards,
>> Ben
>>
>> On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:
>>
>>
>>
>>> On Dec 9, 8:05 pm, Ben Eliott  wrote:
>>>> Graham,
>>>> Thank you for coming back personally to such a lowly wsgi  
>>>> question! I
>>>> started reading your email and thinking the answer was 'no', then
>>>> ended up thinking 'definitely maybe'. I'll keep an eye out in case
>>>> you
>>>> post more, otherwise i'll follow those links and your directions  
>>>> and
>>>> hope to report back with some progress.
>>
>>> I'll definitely try and say more later when get a chance.
>>
>>> Just do be aware of one thing. By using a single WSGI script file  
>>> for
>>> multiple sites, you loose the ability with mod_wsgi daemon mode to
>>> touch the WSGI script file and cause a single site to be reloaded.  
>>> One
>>> would normally use this as a way of reloading a single site without
>>> the need to restart the whole of Apache. When sharing the single  
>>> WSGI
>>> script file across sites, touching the WSGI script file will restart
>>> all sites using that WSGI script file. If they share the code this  
>>> may
>>> actually be want you want, so not a problem, but worth mentioning.
>>
>>> In this arrangement, if you did want to reload one site, for example
>>> because you change its settings file, you would need to use 'ps' to
>>> identify process(es) in that daemon process group, based on what
>>> display-name option was set to, and send all those processes in that
>>> daemon process group a SIGINT using the 'kill' command.  
>>> Alternatively,
>>> you would need to setup a background thread which monitored  
>>> something
>>> like the distinct settings file for each site and have the process
>>> itself send a SIGINT to itself. This would be a variation on
>>> background reloader described in:
>>
>>>  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_ 
>>> ...
>>
>>> More later.
>>
>>> Graham
>>
>>&g

Re: dynamic mod wsgi

2008-12-23 Thread Ben Eliott

I just saw your message below after sending the vhost.

I don't think i'd mind whether it's separate processes or one really  
fat one. I think perhaps separate processes with a quite a short  
inactivity timeout might work quite well? I'd rather keep the overall  
footprint as  small as feasible, especially since i'm only using a  
memory starved VPS for the time being. But this is for alpha-testing  
purposes really so not crucial concern.

I don't know the answer really to your questions, but perhaps if i can  
give you some background:  I'm looking to set up/demonstrate a django  
app for users according to a set of specific settings they choose.  
Subdomains are to identify the client accounts where they can see  
their django app . The subdomain would be temporary for demonstration/ 
set-up purposes and a client account  would get moved across to a  
dedicated domain name in due course.

Based on users entry in a form i can write/re-write python settings,  
and mod_wsgi allows me to programmatically restart a site - this is  
what led me to think it might be possible. The crunch is obviously  
that i want it to create these instances on the fly, so that the user  
completes the form and *bam* their subdomain is there complete with  
their customized django app.









On 23 Dec 2008, at 01:13, Graham Dumpleton wrote:

>
> Have some further questions about what you want to do.
>
> Do you want a separate daemon process for each distinct Django site,
> or are you happy with one really fat process which contains each
> Django site in a separate sub interpreter of that process?
>
> How much memory does each Django site instance take up?
>
> How many different site instances would you have?
>
> Are all the site instances distinguishable by server name alone?
>
> Graham
>
> On Dec 23, 9:00 am, Graham Dumpleton 
> wrote:
>> On Dec 22, 9:44 pm, Ben Eliott  wrote:
>>
>>> Hi Graham,
>>> I've finally managed to get back to the wildcard subdomains &  
>>> mod_wsgi
>>> today. Unfortunately the discussion thread you mentioned has
>>> disappeared and after a few hours i still seem to be doing a good  
>>> job
>>> of getting nowhere.
>>
>> I can still access thread with no problems.
>>
>>> Although you mentioned using mod_rewrite to get hold of the url
>>> variable, it looks like the %{SERVER} variable in mod_wsgi might  
>>> take
>>> care of this already?
>>
>>> My main issue seems to be to accessing the %{SERVER} (or relevant
>>> mod_rewrite) variable in the .wsgi script, to specify a particular
>>> settings file.
>>
>>> Within a VirtualHost i have:
>>> WSGIApplicationGroup %{SERVER}
>>> WSGIDaemonProcess %{SERVER} ...threads etc
>>> WSGIProcessGroup %{SERVER}
>>
>> The %{SERVER} value is only magic when used with WSGIApplicationGroup
>> directive.
>>
>>> So this is probably hoplessly wrong also, but if you can give some
>>> further pointers that would be most kind.
>>
>> Can you post a more complete example of your Apache configuration
>> showing what you are trying to achieve.
>>
>> Sorry I didn't get back to you last time, it was a hectic few weeks.
>> Things have settled down somewhat now, so I'll go back over your
>> original post and work out again what it is you were trying to do.
>>
>> Graham
>>
>>> Thanks and Regards,
>>> Ben
>>
>>> On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:
>>
>>>> On Dec 9, 8:05 pm, Ben Eliott  wrote:
>>>>> Graham,
>>>>> Thank you for coming back personally to such a lowly wsgi  
>>>>> question! I
>>>>> started reading your email and thinking the answer was 'no', then
>>>>> ended up thinking 'definitely maybe'. I'll keep an eye out in case
>>>>> you
>>>>> post more, otherwise i'll follow those links and your directions  
>>>>> and
>>>>> hope to report back with some progress.
>>
>>>> I'll definitely try and say more later when get a chance.
>>
>>>> Just do be aware of one thing. By using a single WSGI script file  
>>>> for
>>>> multiple sites, you loose the ability with mod_wsgi daemon mode to
>>>> touch the WSGI script file and cause a single site to be  
>>>> reloaded. One
>>>> would normally use this as a way of reloading a single site without
>>>> the need to restart the whole of Apache. When sharing the single  
>>>> WSGI
>>>

Re: Do sth on time ?

2009-01-04 Thread Ben Eliott

Maybe look at it from the point of view of whether you need these  
items to actually expire on time, or whether you need them to have  
expired when they're actually accessed from the database.
If the latter you could use a method in your model, + a manager  
function perhaps, to flick the 'expired' switch.
You've probably discounted this already, but it's easy to get stuck in  
a mindset.



On 4 Jan 2009, at 10:50, makka...@gmail.com wrote:

>
> Hi list,
>
> I have a web app which is a kind of arbitration application. Users  
> bid on some
> products or projects and the one who gives the biggest price gets the
> project. Every project has some bidding expiration time. What i need  
> is how
> can i handle the situation to change the status of the project on a  
> specific
> time? For example , i submit a project and it should expire after 2  
> hours.
>
> Some solutions i can think are :
>   - Cronjobs , which checks the db every minute , but that will be very
> expensive i think
>   - Twisted , but if server gets restarted i may loose the track of the
> deferreds
>
> Does anyone solved a problem like that before ? Any suggestions ...
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Recipe 534109: XML to Python data structure

2009-01-06 Thread Ben Eliott

Perhaps try:
http://www.crummy.com/software/BeautifulSoup/
is awesome and has good documentation

On 6 Jan 2009, at 15:27, shi shaozhong wrote:

>
> I am reading in a xml from a web service.  I wish to find a Python
> script to turn the xml into a Python data array for further
> manipulation and to be saved in a .dbf file.
>
> Has anyone tried the following script?
> http://code.activestate.com/recipes/534109/
>
> How do I use it?
>
> Regards.
>
> David
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Circular imports between managers and models

2009-01-06 Thread Ben Eliott

Not that pretty/efficient but you could use contenttype contrib  
temporarily.
IF ClassB has a ForeignKey to Class A could you extract the Class A  
model from  a foreign key via Class B's  .meta?
Or the Class B could have a callable method which returned the  
instance of the model you want...
Not sure whether/how these will work but just throwing out some ideas.



On 6 Jan 2009, at 16:08, bruno desthuilliers wrote:

>
> on 6 jan, 14:54, Polat Tuzla  wrote:
> (snip)
>> The reason why I need to separate models and managers into different
>> files is that they have simply grown to thousands of lines.
>>
> It's indeed a very compelling reason !-)
>
> But (simple suggestion - I know nothing about your project...) don't
> you see it as a sign your app (django meaning) is getting a bit to
> big ? Perhaps refactoring it into a couple or more small apps would be
> a better move ? (once again, just my 2 cents...)
>
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: dynamic mod wsgi

2009-01-11 Thread Ben Eliott

Hi Graham,
Just following up on this thread. I replied with some details, but  
maybe you missed those, or maybe i missed your reply. Or maybe this  
isn't worth it and i should stop being lazy and just write out the  
VirtualHost files :)
Ben

On 23 Dec 2008, at 01:13, Graham Dumpleton wrote:

>
> Have some further questions about what you want to do.
>
> Do you want a separate daemon process for each distinct Django site,
> or are you happy with one really fat process which contains each
> Django site in a separate sub interpreter of that process?
>
> How much memory does each Django site instance take up?
>
> How many different site instances would you have?
>
> Are all the site instances distinguishable by server name alone?
>
> Graham
>
> On Dec 23, 9:00 am, Graham Dumpleton 
> wrote:
>> On Dec 22, 9:44 pm, Ben Eliott  wrote:
>>
>>> Hi Graham,
>>> I've finally managed to get back to the wildcard subdomains &  
>>> mod_wsgi
>>> today. Unfortunately the discussion thread you mentioned has
>>> disappeared and after a few hours i still seem to be doing a good  
>>> job
>>> of getting nowhere.
>>
>> I can still access thread with no problems.
>>
>>> Although you mentioned using mod_rewrite to get hold of the url
>>> variable, it looks like the %{SERVER} variable in mod_wsgi might  
>>> take
>>> care of this already?
>>
>>> My main issue seems to be to accessing the %{SERVER} (or relevant
>>> mod_rewrite) variable in the .wsgi script, to specify a particular
>>> settings file.
>>
>>> Within a VirtualHost i have:
>>> WSGIApplicationGroup %{SERVER}
>>> WSGIDaemonProcess %{SERVER} ...threads etc
>>> WSGIProcessGroup %{SERVER}
>>
>> The %{SERVER} value is only magic when used with WSGIApplicationGroup
>> directive.
>>
>>> So this is probably hoplessly wrong also, but if you can give some
>>> further pointers that would be most kind.
>>
>> Can you post a more complete example of your Apache configuration
>> showing what you are trying to achieve.
>>
>> Sorry I didn't get back to you last time, it was a hectic few weeks.
>> Things have settled down somewhat now, so I'll go back over your
>> original post and work out again what it is you were trying to do.
>>
>> Graham
>>
>>> Thanks and Regards,
>>> Ben
>>
>>> On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:
>>
>>>> On Dec 9, 8:05 pm, Ben Eliott  wrote:
>>>>> Graham,
>>>>> Thank you for coming back personally to such a lowly wsgi  
>>>>> question! I
>>>>> started reading your email and thinking the answer was 'no', then
>>>>> ended up thinking 'definitely maybe'. I'll keep an eye out in case
>>>>> you
>>>>> post more, otherwise i'll follow those links and your directions  
>>>>> and
>>>>> hope to report back with some progress.
>>
>>>> I'll definitely try and say more later when get a chance.
>>
>>>> Just do be aware of one thing. By using a single WSGI script file  
>>>> for
>>>> multiple sites, you loose the ability with mod_wsgi daemon mode to
>>>> touch the WSGI script file and cause a single site to be  
>>>> reloaded. One
>>>> would normally use this as a way of reloading a single site without
>>>> the need to restart the whole of Apache. When sharing the single  
>>>> WSGI
>>>> script file across sites, touching the WSGI script file will  
>>>> restart
>>>> all sites using that WSGI script file. If they share the code  
>>>> this may
>>>> actually be want you want, so not a problem, but worth mentioning.
>>
>>>> In this arrangement, if you did want to reload one site, for  
>>>> example
>>>> because you change its settings file, you would need to use 'ps' to
>>>> identify process(es) in that daemon process group, based on what
>>>> display-name option was set to, and send all those processes in  
>>>> that
>>>> daemon process group a SIGINT using the 'kill' command.  
>>>> Alternatively,
>>>> you would need to setup a background thread which monitored  
>>>> something
>>>> like the distinct settings file for each site and have the process
>>>> itself send a SIGINT to itself. This would be a variation on
>>>>

Re: dynamic mod wsgi

2009-01-12 Thread Ben Eliott

Ok, thanks Graham, will do.

On 11 Jan 2009, at 10:45, Graham Dumpleton wrote:

>
>
>
> On Jan 11, 7:59 pm, Ben Eliott  wrote:
>> Hi Graham,
>> Just following up on this thread. I replied with some details, but
>> maybe you missed those, or maybe i missed your reply. Or maybe this
>> isn't worth it and i should stop being lazy and just write out the
>> VirtualHost files :)
>
> I missed the posts. It was a festive time of year, plus have been
> exceedingly busy.
>
> If the only thing this web server is going to host is the Django
> instances, you are possibly better of not using VirtualHost at all,
> but use mod_rewrite to implement virtual hosts. See:
>
>  http://groups.google.com/group/modwsgi/browse_frm/thread/c29dde8fbef68e0b#
>
> They never came back with final configuration which incorporated
> static media hosting distinct for each site, but not too much work.
> Perhaps post a followup to that thread if you want to work through
> static media aliases that are needed so each instance can have its own
> separate media files.
>
> Also perhaps use that thread if you want to discuss how to extend that
> scheme such that a pool of daemon processes is available and so you
> can have dynamic assignment to one of the daemon process groups from
> the pool.
>
> Discussion on the mod_wsgi list where that thread is in general better
> for me as it then comes in my mail box and don't miss it, where as
> just browse here occasionally so don't always pick up posts.
>
> Graham
>
>> On 23 Dec 2008, at 01:13, Graham Dumpleton wrote:
>>
>>
>>
>>> Have some further questions about what you want to do.
>>
>>> Do you want a separate daemon process for each distinct Django site,
>>> or are you happy with one really fat process which contains each
>>> Django site in a separate sub interpreter of that process?
>>
>>> How much memory does each Django site instance take up?
>>
>>> How many different site instances would you have?
>>
>>> Are all the site instances distinguishable by server name alone?
>>
>>> Graham
>>
>>> On Dec 23, 9:00 am, Graham Dumpleton 
>>> wrote:
>>>> On Dec 22, 9:44 pm, Ben Eliott  wrote:
>>
>>>>> Hi Graham,
>>>>> I've finally managed to get back to the wildcard subdomains &
>>>>> mod_wsgi
>>>>> today. Unfortunately the discussion thread you mentioned has
>>>>> disappeared and after a few hours i still seem to be doing a good
>>>>> job
>>>>> of getting nowhere.
>>
>>>> I can still access thread with no problems.
>>
>>>>> Although you mentioned using mod_rewrite to get hold of the url
>>>>> variable, it looks like the %{SERVER} variable in mod_wsgi might
>>>>> take
>>>>> care of this already?
>>
>>>>> My main issue seems to be to accessing the %{SERVER} (or relevant
>>>>> mod_rewrite) variable in the .wsgi script, to specify a particular
>>>>> settings file.
>>
>>>>> Within a VirtualHost i have:
>>>>> WSGIApplicationGroup %{SERVER}
>>>>> WSGIDaemonProcess %{SERVER} ...threads etc
>>>>> WSGIProcessGroup %{SERVER}
>>
>>>> The %{SERVER} value is only magic when used with  
>>>> WSGIApplicationGroup
>>>> directive.
>>
>>>>> So this is probably hoplessly wrong also, but if you can give some
>>>>> further pointers that would be most kind.
>>
>>>> Can you post a more complete example of your Apache configuration
>>>> showing what you are trying to achieve.
>>
>>>> Sorry I didn't get back to you last time, it was a hectic few  
>>>> weeks.
>>>> Things have settled down somewhat now, so I'll go back over your
>>>> original post and work out again what it is you were trying to do.
>>
>>>> Graham
>>
>>>>> Thanks and Regards,
>>>>> Ben
>>
>>>>> On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:
>>
>>>>>> On Dec 9, 8:05 pm, Ben Eliott  wrote:
>>>>>>> Graham,
>>>>>>> Thank you for coming back personally to such a lowly wsgi
>>>>>>> question! I
>>>>>>> started reading your email and thinking the answer was 'no',  
>>>>>>> then
>>>>>>> ended up thinking 'definitely maybe'. I'll keep an eye out in

Problem with encoding and using ifequal in Django templates

2009-01-27 Thread Ben Gerdemann

Hello,

I'm having problems using {% ifequal s1 "some text" %} to compare
strings with extended characters in Django templates. When string s1
contains ascii characters >127, I get exceptions in the template
rendering. What am I doing wrong? I'm using UTF-8 coding throughout
the rest of application in both the data, templates and Python code
without any problems. Any ideas?

Cheers,
Ben

views.py

def test(request):
return render_to_response("test.html", {
"s1": "dados",
"s2": "aprovação",
}
  )

test.html

s1={{s1}}
s2={{s2}}

{% ifequal s1 "dados" %}
  s1="dados" is true
{% endifequal %}

{% ifequal s1 "aprovação" %}
  s1="aprovação" is true
{% endifequal %}

{% comment %}
The following two comparions cause the following exception:
Caught an exception while rendering: 'ascii' codec can't decode byte
0xc3 in position 6: ordinal not in range(128)

{% ifequal s2 "dados" %}
  s2="dados" is true
{% endifequal %}

{% ifequal s2 "aprovação" %}
  s2="aprovação" is true
{% endifequal %}
{% endcomment %}

{% ifequal s2 u"dados" %}
  s2="dados" is true
{% endifequal %}

{% comment %}
The following comparison causes the following exception:
Caught an exception while rendering: 'ascii' codec can't encode
characters in position 8-9: ordinal not in range(128)
{% ifequal s2 u"aprovação" %}
  s2="aprovação" is true
{% endifequal %}
{% endcomment %}

Output

s1=dados
s2=aprovação
s1="dados" is true


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



Re: Problem with encoding and using ifequal in Django templates

2009-01-27 Thread Ben Gerdemann

Sometimes there's nothing like describing a problem to someone else to
help you solve it. :) I should have marked the Python strings as
Unicode like this and everything works now:

def test(request):
return render_to_response("test.html", {
"s1": u"dados",
"s2": u"aprovação",
}
  )


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



Converting queryset filter() strings to their fields?

2009-02-06 Thread Ben Gerdemann

Hello,

I think the best why to explain my question is with an example. I have
a model T60CursoAdmin and a query string "a21__a21_ano" that I can use
to search with like this:

T60CursoAdmin.objects.filter(a21__a21_ano=2008)

The models look like this:

class T60Curso(models.Model):
a21 = models.ForeignKey(T21Turma,verbose_name="Turma")
ex = models.CharField()

class T21Turma(models.Model):
a21_ano = models.IntegerField("Ano")

My question is how, can I can get a reference to the 'a21_ano' field
that this filter is referencing? If the filter didn't span through the
foreign key, I could just do:

T60Curso._meta.get_field("ex")

but this doesn't work:

T60Curso._meta.get_field("a21__a21_ano")

Thanks for any and all help.

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



signal connection

2009-02-10 Thread Ben Eliott

Can anyone please suggest why a signal might be failing to connect.  
I'm using 1.0.2 on apache + mod_wsgi. The signal gets picked up fine  
using the localserver, but fails on the server proper.

When i go into the shell and get the signal object and check  
'receivers' i can see the listener registered. But it just doesn't  
seem to want to fire when the event occurs.

The signal is in one app's models.py, when i put a listener in that  
same file it picks it up fine. When i move the listener to a different  
app's models.py this is when it fails.
Something to do with an import conflict? The second app's models.py  
file already imports a class from the signal's models.py file.  Any  
suggestions very welcome, thanks!

Ben




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



Custom template tags in admin with hacking to source?

2009-02-16 Thread Ben Gerdemann

Is it possible to add a custom template tag to the admin without
modifying the Django source? I'd like to add a tag to display a
different submit_line, but the only way I can figure out how to do
this is by either adding one of the existing template tags in django/
contrib/admin/templatetags or adding a new file in the directory. I
tried adding a templatetags directory to my app, but it doesn't work
because Django only searches for template tags in the templatetag
directory of the active app. Any ideas about how to do this without
hacking the source?

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



Re: get_absolute_url() and related models

2009-02-24 Thread Ben Davis
Thank you so much!  It's funny because I had originally tried
category__slug,  not sure why it didn't occur to me to use
self.category.slug !  Also,  I'm glad to have learned about
select_related()   --  that's exactly what I was looking for!

On Mon, Feb 23, 2009 at 6:36 PM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Tue, 2009-02-24 at 11:33 +1100, Malcolm Tredinnick wrote:
> [...]
> > You can certainly simplify get_absolute_url() a bit:
> >
> > def get_absolute_url(self):
> >category_slug = self.category__slug
>
> Sorry, this is a typo. Should be self.category.slug -- normal attribute
> reference stuff.
>
> 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
-~--~~~~--~~--~--~---



Compressed fixtures?

2009-03-06 Thread Ben Davis
http://docs.djangoproject.com/en/dev/ref/django-admin/#compressed-fixtures

The docs say that you can use compressed fixtures, but I haven't gotten this
to work.  For example, I have myapp/fixtures/myfixture.yaml.gz,  but when I
run ./django-admin.py loaddata myapp/fixtures/myfixture.yaml,  it just exits
with no output, status of 0.

What am I doing wrong?

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



Re: Compressed fixtures?

2009-03-07 Thread Ben Davis
Ahh. Searching for "compressed fixtures" on djangoproject.com under the
"1.0" documentation option  reveals the following page:
http://docs.djangoproject.com/en/dev/ref/django-admin/?from=olddocs

That page has the "1.0 Docs" label,  so I'm guessing this is an error in the
documentation?  Is there a place to submit documentation bugs?


On Fri, Mar 6, 2009 at 8:43 PM, Alex Gaynor  wrote:

>
> This only works on the latest development version of Django, not 1.0.
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>

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



I can't decide on a migration framework

2009-03-07 Thread Ben Davis
I've been looking into both the "South" and "django-evolution" migration
frameworks.   There are things I like about both of them, although I'm
leaning towards django-evolution.

The thing I like about django-evolution is that migrations are described in
the same "language" as your model,  that is,  instead of adding/removing
tables & columns,  we're adding/removing models and fields,  which is (I
believe) the way it should be.  I don't feel like "create_table()" is any
different from SQL's  "CREATE TABLE".

However,  the author of South
claimsto have started the
project out of frustrations with django-evolution.  I've
read those points, and having a really difficult time understanding what
they really mean.  What do they mean by migartions not being "fixed in the
codebase",  and "fixed migrations are all run when an app is first
installed" ?   What exactly are "fixed migrations" anyways?   I'd love to
understand these points as I don't want to regret choosing django-evolution.

I haven't looked into dmigrations that much, but if anyone has any input on
that I'm all ears.

 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: I can't decide on a migration framework

2009-03-09 Thread Ben Davis
are you saying that django-evolution does not support migrating between
"versions"  (ie up and down)?

I'm mostly trying to get an idea of what migration frameworks django
devopers use, and why they prefer it.

On Mar 7, 2009 5:31 PM, "Briel"  wrote:


A fixed migration is the code run to get from one step to another.
Migrations uses the, maybe at some point you needed to add an extra
table to the db. Then you could write a migration that would add the
table if you wanted to progress or delete the table if you wanted to
get back. You would have that list with app and when you install the
app elsewhere you could choose at which point in the migration history
you wanted your database in. Maybe for some testing you needed the
database like it was at some point. Evolution works differently, it
looks at the db and compares it to the models and the try to make the
changes needed when you run syncdb. So in order to controll evolutions
you would need to change to model fields.

On 7 Mar., 23:59, Ben Davis  wrote: > I've been
looking into both the "South"...
> claims<http://south.aeracode.org/wiki/Alternatives>to have started the

> project out of frustrations with django-evolution.  I've > read those
points, and having a really ...

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



Re: I can't decide on a migration framework

2009-03-09 Thread Ben Davis
Thanks Russ! Your insight is greatly appreciated.

On Mon, Mar 9, 2009 at 8:58 PM, Russell Keith-Magee
wrote:

>
> On Tue, Mar 10, 2009 at 8:23 AM, Ben Davis  wrote:
> > are you saying that django-evolution does not support migrating between
> > "versions"  (ie up and down)?
>
> Django Evolution doesn't currently support down-migrations. This isn't
> due to any particular technical limitation - it just hasn't been
> implemented.
>
> > I'm mostly trying to get an idea of what migration frameworks django
> > devopers use, and why they prefer it.
>
> At the moment, this is still an emerging field. All of the leading
> candidates are works-in-progress, so there isn't any single framework
> you can point at and conclusively say "use this one". For what it's
> worth, a recent survey on the This Week in Django [1] gave Django
> Evolution a slight edge over South in the popularity stakes, but both
> frameworks came second to "Raw sql".
>
> [1] http://thisweekindjango.com/twid/episode/47/this-week-in-django-47/
>
> I'm biased, since I'm the developer of Django Evolution. Obviously, I
> think Evolution is pretty good :-) However, my Django and other life
> commitments mean I haven't been able to give it the attention it has
> needed lately. There are a couple of outstanding bugs, and plenty of
> features I would like to add.
>
> Historically, Django Evolution has had more "smarts" - the evolution
> hinting process is more advanced under Evolution than it is under
> South. However, there are some edge cases where this hinting process
> goes wrong, and it can be difficult to recover from these situations.
> There is also a known gap in the support for MySQL, due to some of the
> eccentricities of MySQL schema modification syntax.
>
> South is another strong candidate. Andrew is a smart guy, and he's
> been making some great advances in South over the last few months.
> Reading between the lines, I believe that Evolution-like hinting
> features are on his to-do list in the near future. I haven't used
> South in anger myself, but I know plenty of people that do - I doubt
> you would be disappointed if you chose to use it.
>
> dbmigrations is a pretty good 'bare bones' framework - it manages your
> SQL migrations, but not much else. However, if that is all you need,
> it may be a good choice.
>
> This isn't a complete list, either. Migration frameworks keep popping
> up all the time. The only really helpful advice I can give is to try a
> few, and see what suits your needs.
>
> Yours,
> Russ Magee %-)
>
> >
>

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



Reading data from database tied to another Django project?

2009-07-10 Thread Ben Kreeger

Here's the situation: I've got two projects, both Django. One is a
simple, public-facing website that renders a library of
reStructuredText files, as well as a couple of simple forms using the
Forms API. The other is a back-end that requires a login from a member
of our staff, and contains database tables, forms, the whole bit; it's
practical purpose is for tracking equipment in buildings across a
college campus.

In this second Django project, let's call it P2, I've got a database
table of all the buildings on our campus, as well as a database table
of all of our equipment, and most pieces of equipment has a barcode
number associated with it.

In the first Django project, let's call it P1, I've got a form where a
patron will fill out information about who they are, what department,
they're with, etc., but I need them to choose a specific building, and
if available, specify the barcode number of the troublesome equipment.
I want to have a dropdown list of all the buildings show up in the
form, but all the data is associated with another project; otherwise,
I'd just do a forms.ModelChoiceForm.

How do I go about accessing that data from P2's database? Do I need to
create a model in P1 and bind it to a certain table in P2's database?
If that's the case, how do I specify access credentials for that
database? Is that in settings.py?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Finding a Django expert to review my code

2009-07-30 Thread Ben Atkin
I'd probably try emailing some of the top Django developers. This seems like
it would be a buyer's market, due to the job being short and fun for a
dedicated Django dev. Don't hire a noob like me. ;)

http://code.djangoproject.com/wiki/DevelopersForHire

Ben

On Thu, Jul 30, 2009 at 11:21 PM, Rex  wrote:

>
> I just created my first Django site (as an academic research project).
> Now that it is done, I would like to get feedback on my code from a
> Django expert so that I can learn where I can improve as a Django dev.
> How can I find someone to spend 1 or 2 hours reviewing my code with
> me? I found a few employment posting websites, but they seemed more
> geared toward posting jobs or large freelance projects, not something
> small like this.
>
> Thanks,
>
> Rex
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Concurrent Web Access and Edits

2009-08-12 Thread Ben Moran

On Tue, Aug 11, 2009 at 10:14 PM, Doug Blank wrote:

> New Django user here with a question about the client side: Is there
> built-in support for dealing with concurrent edits? ...
>   

Maybe you want the Django condition decorator, which lets you use HTTP 
headers to send an ETag or Modified date and reject the updates if 
they're not correct?

http://docs.djangoproject.com/en/dev/topics/conditional-view-processing/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Return FK model

2009-09-03 Thread Ben Davis
It looks you're setting a many-to-many reflexive (circular) relationship
between users.   It seems it would be better to add a ManyToManyField on the
User model, eg:

class User(models.Model):
...
friends = ManyToManyField(User)


Then you could just use "user.friends"



On Thu, Sep 3, 2009 at 9:50 AM, Yanik  wrote:

>
> Let's say I have a model "Friends" that looks something like:
>
> class Friend(models.Model):
>user = models.ForeignKey(User)
>friend = models.ForeignKey(User, related_name="friend")
>
> I want a list of "User" instances of a user's friends. Is my only
> option to:
>
> 1) Get list of "Friends"
> 2) Then get list of "Users" where id in friends.value_llist('id')
>
> Or is there a way to do a query on the "Friend" model and as to return
> "User" instances of friends?
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Return FK model

2009-09-03 Thread Ben Davis
True, you wouldn't be able to modify the auth.User model.   Though you're
wrong about what would happen if you were able to.  What I'm saying is with
a ManyToMany field,  the relationship is with itself (User),  so it would
return User objects.

The django docs suggest using a UserProfile model when you need to add more
information about a user:
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

What you could do is this.  Create a UserProfile model with the friends
reflexive relationship:

  class UserProfile(models.Model):
  user = ForeignKey(User)
  friends = ManyToManyField(UserProfile)


then you could do:

  some_user = UserProfile.objects.get(user=X)
  his_friends = some_user.friends

This would return UserProfile objects, though.  So if you wanted User
objects, you could do

  his_friends = some_user.friends.select_related('user')

This would pull all this user's friends,  plus their information from the
auth_user table in one query,  so while looping through their friends, you
access their user information like so:

   for friend in his_friends:
   this_friends_user_acct = friend.user



Make sense?

On Thu, Sep 3, 2009 at 10:17 AM, Yanik  wrote:

>
> Well, I can't add very well add fields to the Auth.User. But even if I
> could, user.friends would get me instances of "Friend" model, not
> "User" model.
>
> On Sep 3, 11:13 am, Ben Davis  wrote:
> > It looks you're setting a many-to-many reflexive (circular) relationship
> > between users.   It seems it would be better to add a ManyToManyField on
> the
> > User model, eg:
> >
> > class User(models.Model):
> > ...
> > friends = ManyToManyField(User)
> >
> > Then you could just use "user.friends"
> >
> > On Thu, Sep 3, 2009 at 9:50 AM, Yanik  wrote:
> >
> > > Let's say I have a model "Friends" that looks something like:
> >
> > > class Friend(models.Model):
> > >user = models.ForeignKey(User)
> > >friend = models.ForeignKey(User, related_name="friend")
> >
> > > I want a list of "User" instances of a user's friends. Is my only
> > > option to:
> >
> > > 1) Get list of "Friends"
> > > 2) Then get list of "Users" where id in friends.value_llist('id')
> >
> > > Or is there a way to do a query on the "Friend" model and as to return
> > > "User" instances of friends?
> >
> >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Return FK model

2009-09-03 Thread Ben Davis
@Javier,  not sure.. I've used user profiles on my past sites because that's
what I was told to do a while ago,   if inheritance works with
authentication and the admin,  I would definitely go that route.

Also, @Yanik,  I realized my UserProfile model example above was wrong,
the  user relation should be OneToOneField,   not ForeignKey.



On Thu, Sep 3, 2009 at 10:49 AM, Javier Guerra  wrote:

>
> On Thu, Sep 3, 2009 at 10:41 AM, Ben Davis wrote:
> > The django docs suggest using a UserProfile model when you need to add
> more
> > information about a user:
> >
> http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
>
> slightly OT: is there any advantage to use profiles instead of table
> inheritance?
>
> I know the userprofiles were the only choice before there was table
> inheritance; but is it still the best way?
>
> --
> 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
-~--~~~~--~~--~--~---



Re: are you using mptt, treebeard or something else?

2009-09-03 Thread Ben Davis
>From what I understand,  Treebeard has better performance,  but mptt has (I
think) been around longer.   I've messed around w/ mptt,  but looking
through treebeards benchmarks,  it looks like treebeard might be more well
thought out.   As far as admin support goes,  I don't think either has
"official" admin support,  but both seem to have patches from other users
that attempt to implement it.



On Thu, Sep 3, 2009 at 10:51 AM, Sandra Django wrote:

> Hi Aljosa Mohorovic, I need work with django-mptt or django-treebeard, but
> neither I'm sure. I think that django-mptt is better, this says all (
> http://magicrebirth.wordpress.com/2009/08/06/representing-hierarchical-data-with-django-and-mptt/
> )
> Sorry, a cuestion because I don't understand. mptt requires v1.1, but not
> SVN version?
>
>
>
> On Thu, Sep 3, 2009 at 11:11 AM, Aljosa Mohorovic <
> aljosa.mohoro...@gmail.com> wrote:
>
>>
>> i'm looking at django-mptt and django-treebeard but i'm not sure which
>> one to use although both will solve my problem.
>> currently i'm thinking to use treebeard because mptt requires me to
>> use trunk for django v1.1.
>> any comments/tips/recommendations are appreciated.
>>
>> Aljosa Mohorovic
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: create non-form widgets like a ajax driven table

2009-09-07 Thread Ben Davis
In django terms,  a table is not a widget.  Widgets are basically different
input methods for form fields.   Django's admin app has a built-in list view
(I think it's called changelist) which you can customize or override.  It
basically just takes some effort to dig into the admin contrib app to see
how it's done.  There may or may not be options on the ModelAdmin that say
whether or not its editable,  but check the docs to be sure.

On Mon, Sep 7, 2009 at 11:29 AM, hinnack wrote:

>
> Hi,
>
> is there a standard way, how to create non form widgets - e.g. a table
> - just showing
> data, no edit possible - therefore no form?
> I know I can create an object, put in a method toHTML or render that
> returns the
> safe HTML/JS code...
>
> But how should it be done?
>
> -- Hinanck
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 & mod_wsgi, multipart/form-data forms, and hell

2009-09-10 Thread Ben Kreeger

I've got a model that has an ImageField, and a ModelForm that uses
this model. I've got my template set up using the form fields, and my
form tag is set up with enctype="multipart/form-data" so the picture
upload works.

When I use the included Django development server (runserver command),
I can use this form all day, it uploads photos, all is right with the
world.

When I use my setup with mod_wsgi and Apache2, and I hit submit on
this form while attaching a photo, it just hangs. I've checked my code
(using assert False just to raise an AssertionError) and it doesn't
even make it into my "if request.method == "POST":" statement. It just
sits there. If I don't submit a photo with the form, it's fine.

Before I added the enctype attribute to my form tags, the form would
submit, but if you attached a photo, it wouldn't save.

Anybody seeing this?

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



Authentication for static files

2009-09-26 Thread Ben Davis
I would like to be able to serve files that were uploaded via the admin
site;  for example, when someone clicks on the "Currently:" file link in the
changeform.  However, I also have the following requirements:

   1. The file should only be accessible when authenticated via django's
   auth system
   2. Clicking the file link should not present an already authenticated
   user with another authentication challenge

I'm currently using a custom FileSystemStorage location and base_url for
files that should be only accessible via the admin.

I've seen this documentation:
http://docs.djangoproject.com/en/dev/howto/apache-auth/,   but it deals with
mod_python,   and I'm using mod_wsgi,  so I'm not sure if that will work.
Also,  I'm not sure if that solution meets requirement #2.

Any ideas?

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



Re: Authentication for static files

2009-09-27 Thread Ben Davis
Actually, I just found out about the X-Sendfile header which I think might
solve this problem.  It basically allows you to set the HttpResponse content
to an empty string,  but the X-Sendfile header tells apache to send a file
from the filesystem,  so apache handles the actual serving of the file, but
it still allows you to do preprocessing beforehand.   I'll probably just
override django.views.static.serve to support this, and use the X-Sendfile
header when in production mode.

On Sat, Sep 26, 2009 at 11:16 PM, Graham Dumpleton <
graham.dumple...@gmail.com> wrote:

>
>
>
> On Sep 27, 3:08 am, Ben Davis  wrote:
> > I would like to be able to serve files that were uploaded via the admin
> > site;  for example, when someone clicks on the "Currently:" file link in
> the
> > changeform.  However, I also have the following requirements:
> >
> >1. The file should only be accessible when authenticated via django's
> >auth system
> >2. Clicking the file link should not present an already authenticated
> >user with another authentication challenge
> >
> > I'm currently using a custom FileSystemStorage location and base_url for
> > files that should be only accessible via the admin.
> >
> > I've seen this documentation:
> http://docs.djangoproject.com/en/dev/howto/apache-auth/,   but it deals
> with
> > mod_python,   and I'm using mod_wsgi,  so I'm not sure if that will work.
> > Also,  I'm not sure if that solution meets requirement #2.
> >
> > Any ideas?
>
> The mod_wsgi equivalent of that page is at:
>
>  http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms
>
> Neither will help you though as they implement Basic/Digest
> authentication which is distinct from Django form/session based
> authentication and would as a result prompt for credentials again.
>
> Graham
> >
>

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



Re: can't compare datetime.datetime to datetime.date

2008-05-20 Thread Ben Firshman

The date() method of the datetime object is what you probably want.  
See the documentation:

http://docs.python.org/lib/datetime-datetime.html

Ben

On 20 May 2008, at 09:56, vance ma wrote:

> In django ;How to compare datetime.datetime and datetime.date
> >


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



Re: Django in a HA cluster web services application with some near real time elements

2008-05-21 Thread Ben Ford
Hi there,

I'm probably not qualified to comment on the deeper technical issues
mentioned here. However that said I've just taken over quite a large
codebase that does some of this stuff, and it can be quite painful! I'd
suggest keeping your django code as simple as possible, i.e. just to process
the request and return the results. There are a few instances where we've
called out to other web services in a view and it's gone ok... but there are
a couple where it's bitten us HARD! (SOAP over https using the ZSI library).

If you're thinking of a cron job, then I would say a good match would be a
custom management command, this is the approach we now take as much as
possible and it works well for us.

> It seems likely that parts of our application will want to be
> threaded.  What, if any, issues are there with threading within Django/
> Apache?

I'd second Graham's sentiments here... we're trying to move from fastcgi and
a number of nasty hacks put in place by the previous people to a more normal
setup as per community recommendations for running django at the moment it
isn't easy, we have a lot of bugs surfacing  and a lot of trouble finding
where the originate! Our code uses threadlocal in some places - I'm not sure
how similar threadlocal is to 'threading' (if anyone can enlighten me I'd
appreciate it!), but I think it might be causing a few of our problems.

Cheers,
Ben



-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+447792598685

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



Re: Sydney - Django Contracts - Mobile/Web Dev

2008-05-29 Thread Ben Ford
Hi Glen,

Have you tried posting this on djangogigs.com..? You might get a wider
readership there :-)

Ben

2008/5/29 Wunderkind <[EMAIL PROTECTED]>:

>
> Hi,
>
> A client of mine located in North Sydney is looking for a couple of
> contractors who have experience developing in Django and who will be
> available over the next month.
>
> They develop big branded websites and quite a bit of work in the
> mobile space.
>
> If you have relevant open source experience and can be available in a
> week or two - please contact me at [EMAIL PROTECTED]
> or give me a call on +61 400 639008.
>
> Thanks very much - if you aren't from Australia - sorry for clogging
> up your email with another job!  I'm sure you must get sick of it :)
>
> Glen McGrath.
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+447792598685

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



Re: Tests in files other than tests.py and models.py

2008-06-25 Thread Ben Ford
The testrunner is probably the way to go!

I do this:
# somemod.test.py
from somemod import testing as reg # testing is a package with various
modules inside

__test__ = {
'create_tracker': reg.process.create_tracker,
'create_new_user': reg.process.create_new_user,
'default_promo': reg.process.default_promo,
'session_keys': reg.trackers.sess_keys,
}

The modules look like this:

_imports = _pre_setup + r"""
Import what we need
>>> from django.http import HttpRequest
>>> #Other imports here
"""

_pre_setup is a doctest that mimicks the pre_setup method on a django
TestCase and allows me to specify:

_pre_setup = r"""
>>> from django.core.management import call_command
>>> def _pre_setup(*fixtures):
... "see django.test.testcases.TextCase._pre_setup"
... call_command('flush', verbosity=0, interactive=False)
... if fixtures:
... call_command('loaddata', *fixtures, **{'verbosity': 0})
... mail.outbox = []
"""

This way I can mix and match doctests from lots of different places, and I
can use fixtures in my doctests. I find it pretty flexible, but I'm not
really 100% convinced it's the best way to go about this, so I'd be
interested in hearing from others.

Cheers,
Ben


2008/6/25 Andrew Fong <[EMAIL PROTECTED]>:

>
> A quick browse of a few other posts on the list tell me this question
> has been asked before but the previous answers didn't exactly work for
> me. I created my own solution, but given that I'm very much a Django
> (and Python) newbie, if there are any glaring errors in my approach,
> please point them out.
>
> Anyhow, we want the Django test runner to run tests from modules other
> than tests and models. The documentation says to use tests.py as a
> hook to other tests, but it's not very explicit in how to do so. From
> previous posts, we know that to "hook" unit tests, we just have to
> import the testcase like so:
>
> from project.app.some_module import testcase
>
> ... where testcase is an instance of unittest.TestCase. This seems to
> work swell.
>
> For doctests, the simplest solution seems to be creating a dictionary
> called __test__ that points to the functions and classes whose
> docstrings you want to test. For me at least however, this didn't work
> well. Doctest does not recurse on the items in __test__, meaning if
> you have something in __test__ pointing to a class, it won't read the
> docstrings for each class method, only the class's docstring. This
> meant you had to manually enter in something for each class method, a
> huge pain.
>
> After that, I just put in a custom test suite in my tests.py file. It
> seems to work fine, at least in the development version of Django. If
> anyone sees any glaring mistakes, please point them out. Otherwise,
> this might help someone else down the road:
>
> # Start tests.py
> # Place all your tests in separate modules and hook them by
> # importing them and adding them to TEST_MODULE_LIST
>
> import unittest
> from django.test import _doctest as doctest
> from django.test.testcases import OutputChecker, DocTestRunner
> doctestOutputChecker = OutputChecker()
>
> import project.app.views as views
> import project.app.helpers as helpers
>
> TEST_MODULE_LIST = [views, helpers]
>
> def suite():
>  s = unittest.TestSuite()
>  for m in TEST_MODULE_LIST:
>s.addTest(unittest.defaultTestLoader.loadTestsFromModule(m))
>try:
>  s.addTest(doctest.DocTestSuite(m,
>checker=doctestOutputChecker,
>runner=DocTestRunner))
>except ValueError:
>  # No doc tests in tests.py
>  pass
>  return s
>
> # End tests.py
>
> -- Andrew
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+447792598685

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



Re: Do you code django with Komodo?

2008-06-25 Thread Ben Ford
> BTW: would anybody be interested in contributing to a Komodo-Django
> extension with shortcuts to manage.py etc., modeling wizards and so on?


Hell yeah, is it relatively straightforward or very involved? I know python
pretty well, but firefox/komodo extensions are a bit of a black art!

Ben

-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+447792598685

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



"Eval" in templates?

2008-07-04 Thread Ben Kovitz

Is there an easy way in Django to do the following?

In blah.html:

   {{ buttonDecidedAtRunTime }} blah blah blah

In the Context passed to blah.html at run-time:

   buttonDecidedAtRunTime: '{% include "button4.html %}'
   thisPage: "/some/path"

   Naturally, the included template might be button1.html,
button2.html, etc., depending on run-time decisions.

In button4.html:

   html  for button #4


The kicker is the {{ thisPage }} inside button4.html.  I'm hoping to
pass thisPage in the context sent to blah.html.  This would make the
code really simple.  Of course, the code you see above will just show
the string literal '{% include "button4.html %}' right in your
browser.

What's needed is something like eval for template tags.  I could
imagine:

   {% eval %}{% buttonDecidedAtRunTime %}{% endeval %}

or maybe even better would be:

   {% eval buttonDecidedAtRunTime %}

Is there a way to do this?  If it's not already in Django, does it
look easy to implement?  I haven't yet implemented a custom tag, but I
read the chapter in the book, and it doesn't look too hard.  On the
other hand, I don't want to spend days mired in it if it's hard.

Or, is there a better way to do what I'm trying to do?  Right now, I
see two other options:  render button4.html and pass the result as the
value of buttonDecidedAtRunTime (this complicates the Python code a
bit, since thisPage must be passed to the subroutine that decides
which button to render); or use {% if %} tags in blah.html (kind of
ugly, involves difficulties with parameter-passing, and we need to do
this all over the place, though we could stuff the {% if %} logic into
an included template).


Ben Kovitz
http://decisionero.com


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



Re: "Eval" in templates?

2008-07-05 Thread Ben Kovitz

Thanks for the encouragement, Alex.  This was so easy, it should be a
first lesson in how to write a custom tag.  It took about 15 minutes
and worked the first time!


from django import template

register = template.Library()

@register.tag(name="eval")
def do_eval(parser, token):
   try:
  tagName, variableName = token.split_contents()
   except ValueError:
  raise template.TemplateSyntaxError("%r requires a single
argument: the name of the variable to evaluate as the body of a
template" % tagName)

   return EvalNode(variableName)


class EvalNode(template.Node):

   def __init__(self, variableName):
  self.variableName = variableName


   def render(self, context):
  t = template.Template(context[self.variableName])
  return t.render(context)




On Jul 4, 5:51 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I don't think it would be difficult to implement, either as a block
> tag, or as a regular tag with context.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   3   4   >