Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves


On 29-Mar-08, at 11:43 AM, Kenneth Gonsalves wrote:

> {% for w in wc %}
w.title<-- forgot this
> 
> {% for sample in w.workcategory_set.all %}
> sample
> {% endfor %}
> 
> {% endfor %}

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves


On 29-Mar-08, at 11:17 AM, Brandon Taylor wrote:

> What I would like to accomplish is output that looks as such:
>
> Category name
> 
>   Sample Name
>   Sample Name
>   Sample Name
> 
>
> Category name
> 
>   Sample Name
>   Sample Name
>   Sample Name
> 
>
wc = WorkCategory.objects.all()
for w in wc:
for sample in wc.workcategory_set.all():
 print sample

or in html:

{% for w in wc %}

{% for sample in w.workcategory_set.all %}
sample
{% endfor %}

{% endfor %}
-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: many to many field problem

2008-03-28 Thread didia lim
thanks so much evert really appreciate it.. it works 
now  i do like this

ds = DigitalSignage.objects.get(pk=ds_id)#Digital Signage 
config & setting
setting = ds.setting
textslots = ds.textslot_set.all()
slots = ds.slot_set.all()
tableslots = tableSlot.objects.filter(DS_List=ds)
columnsetups = columnSetup.objects.filter(tableList=tableslots)
querysetups = querySetup.objects.filter(tableList=tableslots)

but bumps into another problems.. really headache when i call the columnsetups 
or querysetups it will gave me error 

{%for tableslots in tableslots_list%}
 {{tableslots.Transparency}} 
{%endfor%}
{%for querysetups in querysetups_list%}
{{querysetups.dbTemp}} 
{%endfor%}

Request Method:  GET  Request URL:  
http://localhost/reed/1/ds.xml  Exception Type:  InterfaceError 
 Exception Value:  Error binding parameter 0 - probably 
unsupported type.  Exception Location:  
C:\Python25\lib\site-packages\django\db\backends\sqlite3\base.py in execute, 
line 133  Python Executable:  C:\Program Files\Apache Software 
Foundation\Apache2.2\bin\httpd.exe  Python Version:  2.5.1

- Original Message 
From: Evert Rol <[EMAIL PROTECTED]>
To: django-users@googlegroups.com
Sent: Friday, March 28, 2008 8:47:17 AM
Subject: Re: many to many field problem


> thanks for reply, but i don't quite understand :( sorry i'm newbie  
> here
> First my models.py is like this
> class DigitalSignage(models.Model):
> DS_ID = integerField()
>
> class tableSlot(models.Model):
> ds_id =models.ManyToManyField(DigitalSignage)
>
> class columnSetup(models.Model):
> tableList  =models.ManyToManyField(tableSlot)
>
> so in my views.py like this:


>
> >ds = DigitalSignage.objects.get(pk=ds_id)

Here, you are retrieving a single object, namely a DigitalSignage (as  
defined in your model).
The _set identifier will work for objects, as below.


> >tableslots = ds.tableslot_set.all()

Here, you're retrieving all tableslots, which results in a QuerySet.  
It is a QuerySet of your tableSlot model, but it's not the model  
itself. A QuerySet allows filtering, but you cannot directly retrieve  
any of the relations defined in your models, since it's not the model  
itself.
Have another look at 
http://www.djangoproject.com/documentation/db-api/#many-to-many-relationships
You'll see that the _set is used for an object, not a  
QuerySet.


>
> >columnsetups = tableslots.columnsetup_set.all()
>
> so now if i change upwards... that's mean my models.py should be  
> like this:
> class DigitalSignage(models.Model):
> DS_ID = integerField()
>
> class columnSetup(models.Model):
> field1 = models.charField()
>
> class tableSlot(models.Model):
> ds_id =models.ManyToManyField(DigitalSignage)
> columnList  =models.ManyToManyField(columnSetup)

Changing your models has nothing to do with it.

Therefore, continuing with the model defintion you originally had (top  
of this mail), you should probably access things from the other side:
ds = DigitalSignage.objects.get(pk=ds_id)
tableslots = tableSlot.objects.filter(ds_id=ds)   # note: not using  
ds.id. See also note below

Also, have another good luck at 
http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships


Lastly, I can suggest some renaming, to stay with the usage in Python  
and Django. Has nothing to do with the problem, so consider it free  
(and possibly unwanted) advice:
- model names start with a Capital (TableSlot instead of tableSlot);  
as you do for DigitalSignage.
- m2m relations are often named as the plural of the relation they  
refer to. So ds_id should become something like digital_signages (or  
signages, if you consider that too long). In particular, the ds_id  
naming is rather badly chosen, since it should reflect an object, not  
the database id of that object (don't think database-level, think  
object-level). It is indeed an id (integer) in the database, but if  
you would retrieve if from your model (through a_table_slot.ds_id),  
it'll show up as a DigitalSignage object, not a number.

Good luck.









  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.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: Problem with nested loop

2008-03-28 Thread Brandon Taylor

I already have my site built in Rails, and this is just a re-code in
Django. I've had really good luck with it until now :) You can see the
desired output (although the markup is different) at
http://www.btaylordesign.com/portfolio

On Mar 29, 12:47 am, Brandon Taylor <[EMAIL PROTECTED]> wrote:
> What I would like to accomplish is output that looks as such:
>
> Category name
> 
>   Sample Name
>   Sample Name
>   Sample Name
> 
>
> Category name
> 
>   Sample Name
>   Sample Name
>   Sample Name
> 
>
> (repeat)
>
> So, it made sense to me to start with the categories and loop through
> the children for each category. Is my thinking way off for the way the
> template system is designed? Thanks for your help, I really appreciate
> your time.
>
> On Mar 29, 12:43 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
> > On 29-Mar-08, at 10:52 AM, Brandon Taylor wrote:
>
> > > So, to simplify my question, how can I access the child objects of a
> > > 'work_category' through the nested for loop, given my model structure?
>
> > each WorkSample will have one work_category which you can access like  
> > this:
>
> > worksamples = WorkSample.objects.all()
> > for sample in worksamples:
> >      show worksamples.work_category
>
> > if you want all the WorkSamples that reference a particular  
> > work_catgory then you do:
>
> > wc = WorkCategory.objects.get(pk=id)
> > samples = wc.work_category_set.all()
>
> > and you can loop through the samples. I hope this helps
>
> > --
>
> > regards
> > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with nested loop

2008-03-28 Thread Brandon Taylor

What I would like to accomplish is output that looks as such:

Category name

  Sample Name
  Sample Name
  Sample Name


Category name

  Sample Name
  Sample Name
  Sample Name


(repeat)

So, it made sense to me to start with the categories and loop through
the children for each category. Is my thinking way off for the way the
template system is designed? Thanks for your help, I really appreciate
your time.


On Mar 29, 12:43 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 29-Mar-08, at 10:52 AM, Brandon Taylor wrote:
>
> > So, to simplify my question, how can I access the child objects of a
> > 'work_category' through the nested for loop, given my model structure?
>
> each WorkSample will have one work_category which you can access like  
> this:
>
> worksamples = WorkSample.objects.all()
> for sample in worksamples:
>      show worksamples.work_category
>
> if you want all the WorkSamples that reference a particular  
> work_catgory then you do:
>
> wc = WorkCategory.objects.get(pk=id)
> samples = wc.work_category_set.all()
>
> and you can loop through the samples. I hope this helps
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves


On 29-Mar-08, at 10:52 AM, Brandon Taylor wrote:

> So, to simplify my question, how can I access the child objects of a
> 'work_category' through the nested for loop, given my model structure?

each WorkSample will have one work_category which you can access like  
this:

worksamples = WorkSample.objects.all()
for sample in worksamples:
 show worksamples.work_category

if you want all the WorkSamples that reference a particular  
work_catgory then you do:

wc = WorkCategory.objects.get(pk=id)
samples = wc.work_category_set.all()

and you can loop through the samples. I hope this helps

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: MySQL-python-1.2.2 errors

2008-03-28 Thread [EMAIL PROTECTED]

I tried commenting out those lines but still got:

/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/
pyconfig.h:807:1: warning: this is the location of the previous
definition
error: command 'gcc' failed with exit status 1

any other ideas other than uninstall and install 32-bit?

On Mar 25, 8:36 am, Mike H <[EMAIL PROTECTED]> wrote:
> I had the same problem just this morning.
>
> Commenting out
>
> #ifndef uint
> #define uint unsigned int
> #endif
>
> from _mysql.c fixed it for me, and all the django tests pass with a
> mysql backend afterwards, so I should be safe :)
>
> Cheers,
>
> Mike
>
> On 25 Mar 2008, at 15:04, Karen Tracey wrote:
>
> > On Tue, Mar 25, 2008 at 3:49 AM, [EMAIL PROTECTED]
> > <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I'm trying to build MySQL-python-1.2.2 and I don't understand how to
> > fix these errors:
>
> > running build
> > running build_py
> > copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.5/MySQLdb
> > running build_ext
> > building '_mysql' extension
> > gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -
> > Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -
> > DNDEBUG -g -O3 -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -
> > I/
> > usr/local/mysql-5.0.51a-osx10.4-powerpc-64bit/include -I/Library/
> > Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c
> > -o build/temp.macosx-10.3-fat-2.5/_mysql.o -Os -arch ppc64 -fno-common
> > In file included from /Library/Frameworks/Python.framework/Versions/
> > 2.5/include/python2.5/Python.h:57,
> > from pymemcompat.h:10,
> > from _mysql.c:29:
> > /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/
> > pyport.h:730:2: error: #error "LONG_BIT definition appears wrong for
> > platform (bad gcc/glibc config?)."
> > In file included from _mysql.c:35:
> > /usr/local/mysql-5.0.51a-osx10.4-powerpc-64bit/include/my_config.h:
> > 1032:1: warning: "SIZEOF_LONG" redefined
> > In file included from /Library/Frameworks/Python.framework/Versions/
> > 2.5/include/python2.5/Python.h:8,
> > from pymemcompat.h:10,
> > from _mysql.c:29:
> > /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/
> > pyconfig.h:807:1: warning: this is the location of the previous
> > definition
> > error: command 'gcc' failed with exit status 1
>
> > Thanks for any help,
>
> > This page:
>
> >http://antoniocangiano.com/2007/12/22/how-to-install-django-with-mysq...
>
> > reports the same "LONG_BIT definition appears wrong" error resulting
> > from the conflict of trying to build with 64-bit MySQL libraries and
> > 32-bit Python.
>
> >  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: Problem with nested loop

2008-03-28 Thread Brandon Taylor

Sorry, I should have just posted my code instead of trying to simplify
it for the post. My apologies.

Item = WorkSample


WorkSample has a foreign key for the WorkCategory: work_category =
models.ForeignKey(WorkCategory)

I *assumed* I would be able to access any child objects of a
'work_category' when iterating through the loop as
'work_category.work_samples'.

Example:
{% for work_category in work_categories %}
{% for work_sample in work_category.work_samples %}
{% endfor %}
{% endfor %}


So, to simplify my question, how can I access the child objects of a
'work_category' through the nested for loop, given my model structure?
On Mar 29, 12:18 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 29-Mar-08, at 10:30 AM, Brandon Taylor wrote:
>
>
>
> > Sure. This app is for my portfolio. Here's my models.py
>
> > class WorkCategory(models.Model):
> >    title = models.CharField(max_length = 30)
> >    position = models.PositiveSmallIntegerField()
>
> >    def __unicode__(self):
> >            return self.title
>
> >    class Admin:
> >            ordering = ('position',)
> >            search_fields = ('title', 'position')
>
> >    class Meta:
> >            verbose_name_plural = 'Work Categories'
>
> > class WorkType(models.Model):
> >    title = models.CharField(max_length = 40)
>
> >    def __unicode__(self):
> >            return self.title
>
> >    class Admin:
> >            pass
>
> >    class Meta:
> >            verbose_name_plural = 'Work Types'
>
> > class Client(models.Model):
> >    position = models.PositiveSmallIntegerField()
> >    name = models.CharField(max_length = 50)
> >    url = models.CharField(max_length = 50, blank = True)
> >    display = models.BooleanField()
>
> >    def __unicode__(self):
> >            return self.name
>
> >    class Admin:
> >            list_display = ('position','name','url','display')
> >            list_filter = ('display',)
> >            ordering = ('name',)
> >            search_fields = ('name', 'position')
>
> >    class Meta:
> >            ordering = ['name']
>
> > class WorkSample(models.Model):
> >    work_category = models.ForeignKey(WorkCategory)
> >    work_type = models.ForeignKey(WorkType)
> >    client = models.ForeignKey(Client)
> >    title = models.CharField(max_length = 75)
> >    desc = models.TextField()
> >    thumbnail = models.ImageField(upload_to = 'images')
> >    sample_image = models.ImageField(upload_to = 'images')
> >    sample_alt = models.CharField(max_length = 75)
> >    slug = models.SlugField()
>
> >    def __unicode__(self):
> >            return self.title
>
> >    def get_absolute_url(self):
> >            return u'/portfolio/view/%s' % self.slug
>
> >    class Admin:
> >            list_display = ('title','desc','sample_alt','slug')
> >            list_filter = ('work_category', 'work_type', 'client')
> >            search_fields = ('client', 'desc')
>
> >    class Meta:
> >            verbose_name_plural = 'Work Samples'
>
> > I thought I could probably loop through the work samples by saying:
>
> > {% for work_sample in work_category.work_samples %}{% endfor %}
>
> where are you getting 'work_samples' from? I do not see any  
> work_samples in the models. And what happened to the 'items' you had  
> mentioned in your original post?
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves


On 29-Mar-08, at 10:30 AM, Brandon Taylor wrote:

> Sure. This app is for my portfolio. Here's my models.py
>
> class WorkCategory(models.Model):
>   title = models.CharField(max_length = 30)
>   position = models.PositiveSmallIntegerField()
>
>   def __unicode__(self):
>   return self.title
>
>   class Admin:
>   ordering = ('position',)
>   search_fields = ('title', 'position')
>
>   class Meta:
>   verbose_name_plural = 'Work Categories'
>
>
> class WorkType(models.Model):
>   title = models.CharField(max_length = 40)
>
>   def __unicode__(self):
>   return self.title
>
>   class Admin:
>   pass
>
>   class Meta:
>   verbose_name_plural = 'Work Types'
>
>
> class Client(models.Model):
>   position = models.PositiveSmallIntegerField()
>   name = models.CharField(max_length = 50)
>   url = models.CharField(max_length = 50, blank = True)
>   display = models.BooleanField()
>
>   def __unicode__(self):
>   return self.name
>
>   class Admin:
>   list_display = ('position','name','url','display')
>   list_filter = ('display',)
>   ordering = ('name',)
>   search_fields = ('name', 'position')
>
>   class Meta:
>   ordering = ['name']
>
>
> class WorkSample(models.Model):
>   work_category = models.ForeignKey(WorkCategory)
>   work_type = models.ForeignKey(WorkType)
>   client = models.ForeignKey(Client)
>   title = models.CharField(max_length = 75)
>   desc = models.TextField()
>   thumbnail = models.ImageField(upload_to = 'images')
>   sample_image = models.ImageField(upload_to = 'images')
>   sample_alt = models.CharField(max_length = 75)
>   slug = models.SlugField()
>
>   def __unicode__(self):
>   return self.title
>
>   def get_absolute_url(self):
>   return u'/portfolio/view/%s' % self.slug
>
>   class Admin:
>   list_display = ('title','desc','sample_alt','slug')
>   list_filter = ('work_category', 'work_type', 'client')
>   search_fields = ('client', 'desc')
>
>   class Meta:
>   verbose_name_plural = 'Work Samples'
>
>
> I thought I could probably loop through the work samples by saying:
>
> {% for work_sample in work_category.work_samples %}{% endfor %}

where are you getting 'work_samples' from? I do not see any  
work_samples in the models. And what happened to the 'items' you had  
mentioned in your original post?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: Problem with nested loop

2008-03-28 Thread Brandon Taylor

Sure. This app is for my portfolio. Here's my models.py

class WorkCategory(models.Model):
title = models.CharField(max_length = 30)
position = models.PositiveSmallIntegerField()

def __unicode__(self):
return self.title

class Admin:
ordering = ('position',)
search_fields = ('title', 'position')

class Meta:
verbose_name_plural = 'Work Categories'


class WorkType(models.Model):
title = models.CharField(max_length = 40)

def __unicode__(self):
return self.title

class Admin:
pass

class Meta:
verbose_name_plural = 'Work Types'


class Client(models.Model):
position = models.PositiveSmallIntegerField()
name = models.CharField(max_length = 50)
url = models.CharField(max_length = 50, blank = True)
display = models.BooleanField()

def __unicode__(self):
return self.name

class Admin:
list_display = ('position','name','url','display')
list_filter = ('display',)
ordering = ('name',)
search_fields = ('name', 'position')

class Meta:
ordering = ['name']


class WorkSample(models.Model):
work_category = models.ForeignKey(WorkCategory)
work_type = models.ForeignKey(WorkType)
client = models.ForeignKey(Client)
title = models.CharField(max_length = 75)
desc = models.TextField()
thumbnail = models.ImageField(upload_to = 'images')
sample_image = models.ImageField(upload_to = 'images')
sample_alt = models.CharField(max_length = 75)
slug = models.SlugField()

def __unicode__(self):
return self.title

def get_absolute_url(self):
return u'/portfolio/view/%s' % self.slug

class Admin:
list_display = ('title','desc','sample_alt','slug')
list_filter = ('work_category', 'work_type', 'client')
search_fields = ('client', 'desc')

class Meta:
verbose_name_plural = 'Work Samples'


I thought I could probably loop through the work samples by saying:

{% for work_sample in work_category.work_samples %}{% endfor %}

But when I return the length of child records:
{{ work_category.work_samples|length }}
I get 0.

Thoughts?

On Mar 28, 11:55 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 29-Mar-08, at 10:13 AM, Brandon Taylor wrote:
>
> > Sorry, that's my fault. I was trying to simplify the naming a bit for
> > the post. 'work_category' should just be 'category'
>
> could you paste the relevant models also (preferably without  
> 'simplifying')
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: scraping PDF

2008-03-28 Thread James Bennett

On Fri, Mar 28, 2008 at 11:21 PM,  <[EMAIL PROTECTED]> wrote:
>  I'm trying to figure out the best way to link-up everything. Any
>  suggestions?

So, since I talked about it at PyCon, I'll take an example from this
project:

http://www2.ljworld.com/data/crime/ku/

And I'll walk through this in a bit more detail than I did in my PyCon
lightning talk, since I have more than five minutes to explain the
process; of course, each data set you'll encounter will require some
unique work to handle, but the general process is the same each time.

The data was originally tables embedded in Microsoft Word documents,
which were converted to HTML and then scraped with BeautifulSoup; the
raw data was in the form of rows which looked like this:

04/23/2007 U077034 21-3701 14-304 1318 LOUISIANA 103 B 13 4 Building -
Housing 88
11/26/2007 U0723675 21-3508a1 14-602 1323 OHIO   13 4 Building - Housing 88
08/14/2007 U0714884 21-3701a2 14-304 1515 ENGEL 307 O 12 4 Building - Housing 88

Some of this is irrelevant administrative stuff, so the bits I cared
about here were:

* The first field, which is the data of the crime report.

* The third and fourth fields, which have data on the relevant
  statute.

* The fifth and sixth fields, which are the street address for the
  report.

I'd set up several models, but the relevant ones here were named
``ResidenceHall``, ``Offense`` and ``Crime``, where ``Crime``
represents the actual report, and has foreign keys to ``Offense``
(representing the particular crime -- burglary, vandalism, etc.) and
to ``ResidenceHall``.

What I ended up dumping to CSV was a set of data which looked like
this:

2007-04-23,Theft,K.K. Amini Scholarship Hall
2007-11-26,Lewd and lascivious behavior,Dennis E. Rieger Scholarship Hall
2007-08-14,Theft,Templin Hall

The path from the raw data to this CSV was a process of normalization;
I chose to convert to a format of:

report date,offense,residence hall

Largely because of a couple of ambiguities in using other aspects of
the data:

* Though a statute number is unique within a specific legal code, we
  were dealing with two different codes: the state laws and the city
  ordinances. The name of the offense, however, was unique for both
  sets.

* Some residences are actually complexes of multiple buildings, or can
  be otherwise be referred to using multiple street addresses; the
  name of the residence is unique, though.

So I set up two dictionaries: one mapped statute numbers to names of
offenses, the other mapped street addresses to names of residence
halls. From there, it was easy to loop over the raw data, look up the
offense and the residence, and write out one row of normalized CSV for
each row of raw data.

This normalized CSV file was then used for a couple different
purposes, including some initial exploration of the data by pulling it
into a spreadsheet, and then the database import was handled by
a script which:

1. Read in a row of CSV.

2. Used ``strftime`` to get a ``date`` object from the report date.

3. Looked up the offense by name from the ``Offense`` model.

4. Looked up the residence hall by name from the ``ResidenceHall``
   model.

5. Instantiated and saved a ``Crime`` object from these three pieces
   of data (since they corresponded to the fields on that model).

And at that point I had nice, normalized, structured data and I could
start building out the views of it.


So the broad steps of the process are:

1. Find a way to get at the raw data so that it's easy to read from
   Python; in this case, that meant turning Word docs into HTML.

2. Figure out which parts of the data you care about, and build models
   to represent them in a structured way.

3. Read through the raw data and normalize it based on things you can
   guarantee will be unique to each type of record, and write this out
   to a standard format like CSV.

4. Run your database import from the normalized data; by this point
   it'll be in a format where you can simply look up relations on the
   fly and fill them in as you create new objects.

Once you get used to it, and get over the initial hurdle of figuring
out how to read the data from Python, this tends to go pretty quickly;
as I mentioned in my PyCon talk, this crime-report project had the
browseable database + views to drill down through the data within two
days.





-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves


On 29-Mar-08, at 10:13 AM, Brandon Taylor wrote:

> Sorry, that's my fault. I was trying to simplify the naming a bit for
> the post. 'work_category' should just be 'category'

could you paste the relevant models also (preferably without  
'simplifying')

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: Problem with nested loop

2008-03-28 Thread Brandon Taylor

Sorry, that's my fault. I was trying to simplify the naming a bit for
the post. 'work_category' should just be 'category'

On Mar 28, 11:44 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 29-Mar-08, at 9:43 AM, Brandon Taylor wrote:
>
>
>
> > def showCategories(request):
> >     categories = Category.objects.all().select_related()
> >     return render_to_response('showCategories.html',{'categories':
> > categories})
>
> > In my template, I have:
>
> > {% for category in categories %}
> >     {{ category.title }}
> >     
> >     {% for item in work_category.items %}
> >         {{ item.name }}
> >     {% endfor %}
> >     
> > {% endfor %}
>
> where does 'work_category' come from?
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves


On 29-Mar-08, at 9:43 AM, Brandon Taylor wrote:

> def showCategories(request):
> categories = Category.objects.all().select_related()
> return render_to_response('showCategories.html',{'categories':
> categories})
>
>
> In my template, I have:
>
> {% for category in categories %}
> {{ category.title }}
> 
> {% for item in work_category.items %}
> {{ item.name }}
> {% endfor %}
> 
> {% endfor %}

where does 'work_category' come from?
-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: scraping PDF

2008-03-28 Thread cmccomas80

just trying to think logic through here.

if i set the scrape up so the results are:

SB9, Anderson, 1
SB9, Andes, 1
SB9, Brown, 2

Where SB9 stands for Senate Bill 9, the middle field is the voting
last name (or last name + first initial if two people have the same
last name), and the last field is 1 for a yes, 2 for a no, and 3 for a
no vote.

Then assuming I setup the models like this (generic setup)

PERSON
first name
last name
party

BILL
title
description
full content

VOTES
person
bill
vote (vote_choices = yes, no, no-vote)

I'm trying to figure out the best way to link-up everything. Any
suggestions?

Chris

On Mar 28, 9:52 pm, [EMAIL PROTECTED] wrote:
> James,
>
> Thnx. I would prefer scraping it into a CSV as well. I had a scraper
> that got NCAA football scores from a site and output them in CSV to
> drop into a db, it was in PHP though and scraped .html files.
>
> Also, love your blog, a lot of great stuff there.
>
> Thnx again,
>
> C
>
> On Mar 28, 9:34 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> > On Fri, Mar 28, 2008 at 10:15 PM,  <[EMAIL PROTECTED]> wrote:
> > >  our state legislature has all their reports online in PDF format, i
> > >  was hoping to scrape 'em and get them and use them with django to
> > >  create something similar to what adrian did with the w-p and others
> > >  have done.
>
> > There are a couple freely-available libraries that can scrape PDF;
> > pyPdf [1], for example, is BSD licensed and seems to be actively
> > maintained, and can read the text out of a PDF for you. From there you
> > can pretty easily fiddle with the text; the Python Cookbook has a
> > recipe [2] for reading the text from a PDF programmatically, for
> > example.
>
> > For getting data from PDF into a database, I (personally) generally
> > convert to an intermediate format like CSV, which has the advantage of
> > also working in a lot of spreadsheet tools for people to browse while
> > you're getting the DB import going.
>
> > [1]http://pybrary.net/pyPdf/
> > [2]http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/511465
>
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with nested loop

2008-03-28 Thread Brandon Taylor

Hi everyone,

Still wet behind the ears with Django, so please bear with me...

In my model, I have categories and items. Each item belongs to a
category. When I run the admin app, I can see my categories, and I can
see my products. I have visually verified that each item has a foreign
key for the category id.

In my view, I am retrieving the categories as such:

def showCategories(request):
categories = Category.objects.all().select_related()
return render_to_response('showCategories.html',{'categories':
categories})


In my template, I have:

{% for category in categories %}
{{ category.title }}

{% for item in work_category.items %}
{{ item.name }}
{% endfor %}

{% endfor %}


I get categories, but no items. When I display a count of the items:

{{ category.items|length }}

I get 0. What am I doing wrong? Any help greatly appreciated!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Multiple django sites with common portal

2008-03-28 Thread Graham Dumpleton

On Mar 29, 8:43 am, hambaloney <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I'm hoping to get an idea on how to approach a system setup I've been
> thinking about.
>
> In this system:
>  - a group of users each has it's own Django site and database.  (e.g.
> Group A has access only to Site A, etc)
>  - each Django site shares common application code.
>  - all users log in via a common portal and are 'redirected' to their
> respective sites (I'm using contrib.admin in my example, so they're
> redirected to their admin)
>
> Ideally, this common portal would be seamless to the user. They log in
> and immediately see their admin.
>
> Couple of questions:
>
> 1. Is it possible to set up a portal in such away that the user login
> information can be then used to authenticate them against their site?
> I suspect I'd have to duplicate user entries, e.g. UserA would be in
> the portal db as well as SiteA db. Ideally I'd want one interface to
> manage all users, so redundant entries doesn't appeal.
>
> 2. Can I make this seamless? I would like users to use example.com,
> login, and then, with the same url, utilize their site. I'm currently
> using Apache+mod_python, but I have full access to a test server so
> anything is possible. I was looking through Apache modules and read
> through the proxying docs. Basically I can imagine hosting each Django
> instance separately, via Lighttpd or another Apache instance, and
> proxying, but the way I understand proxying, its a mapped address
> (e.g. /myuser -> 127.0.0.1:someport), but I'd rather not have the /
> myuser url.
>
> If any of this is unclear, let me know.

If I understand what you want to do, I somewhat doubt you could do
this with a single instance of Apache running mod_python, or would be
quite hard. This is because the only way to separate Django instances
in mod_python is by running them in distinct interpreters. Problem
there is that which URLs go to which interpreter instance with
mod_python is static and would be able to be dynamically changed based
on the identity of the user.

You may however be able to do this with mod_wsgi. I would not though
use separate interpreters for each Django instance however, but us
mod_wsgi daemon mode to run them all in a separate process. There are
then various means in mod_wsgi of dynamically delegating specific
requests to a particular process and the Django instance in that
process. This could be determined from a cookie or Basic auth
credentials.

Problem at that point though is how for a single top level URL for
application to have DJANGO_SETTINGS_MODULE be calculated differently.
The issue here is that Django uses an environment variable to set it
and thus to have that somehow dynamically set through the WSGI
application environment variables passed by mod_wsgi as directed by
Apache configuration files and some rewrite rules is a bit of a hack.
It isn't that it can't be done, as Django uses that sort of hack with
mod_python to allow it to be set in Apache configuration.

Thus, the separation bit is probably achievable with mod_wsgi as would
be the dynamic delegation. The bit I was unsure about was how you
wanted to work the front portal. I sort of know how that could be done
as well, and it would require the duplication of credentials as you
say, unless you use some sort of custom auth plugin for Django that
allow sharing of user database.

Anyway, I'd suggest you have a look at mod_wsgi and if you are happy
with running Django under mod_wsgi to begin with, then we can work out
how to do the rest. At that point, may make more sense to take the
discussion over to the mod_wsgi discussion group on Google groups.

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: scraping PDF

2008-03-28 Thread cmccomas80

James,

Thnx. I would prefer scraping it into a CSV as well. I had a scraper
that got NCAA football scores from a site and output them in CSV to
drop into a db, it was in PHP though and scraped .html files.

Also, love your blog, a lot of great stuff there.

Thnx again,

C

On Mar 28, 9:34 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 10:15 PM,  <[EMAIL PROTECTED]> wrote:
> >  our state legislature has all their reports online in PDF format, i
> >  was hoping to scrape 'em and get them and use them with django to
> >  create something similar to what adrian did with the w-p and others
> >  have done.
>
> There are a couple freely-available libraries that can scrape PDF;
> pyPdf [1], for example, is BSD licensed and seems to be actively
> maintained, and can read the text out of a PDF for you. From there you
> can pretty easily fiddle with the text; the Python Cookbook has a
> recipe [2] for reading the text from a PDF programmatically, for
> example.
>
> For getting data from PDF into a database, I (personally) generally
> convert to an intermediate format like CSV, which has the advantage of
> also working in a lot of spreadsheet tools for people to browse while
> you're getting the DB import going.
>
> [1]http://pybrary.net/pyPdf/
> [2]http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/511465
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: scraping PDF

2008-03-28 Thread James Bennett

On Fri, Mar 28, 2008 at 10:15 PM,  <[EMAIL PROTECTED]> wrote:
>  our state legislature has all their reports online in PDF format, i
>  was hoping to scrape 'em and get them and use them with django to
>  create something similar to what adrian did with the w-p and others
>  have done.

There are a couple freely-available libraries that can scrape PDF;
pyPdf [1], for example, is BSD licensed and seems to be actively
maintained, and can read the text out of a PDF for you. From there you
can pretty easily fiddle with the text; the Python Cookbook has a
recipe [2] for reading the text from a PDF programmatically, for
example.

For getting data from PDF into a database, I (personally) generally
convert to an intermediate format like CSV, which has the advantage of
also working in a lot of spreadsheet tools for people to browse while
you're getting the DB import going.


[1] http://pybrary.net/pyPdf/
[2] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/511465


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



scraping PDF

2008-03-28 Thread cmccomas80

has anyone done any PDF scraping?

our state legislature has all their reports online in PDF format, i
was hoping to scrape 'em and get them and use them with django to
create something similar to what adrian did with the w-p and others
have done.

here's an example of what i'd have to scrape...

http://www.legis.state.wv.us/Bulletin_Board/2008/RS/House/Votes/00411.pdf
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problems with Apache + mod_python [SOLVED]

2008-03-28 Thread Graham Dumpleton

On Mar 29, 5:04 am, Slayer_X <[EMAIL PROTECTED]> wrote:
> Problem solved!
>
> I deleted the symlinks, delete de django-trunk dir and make a fresh
> install directly in
>
> /usr/lib/python2.4/site-packages/django

What do you mean by 'make a fresh install directly in'? Do you mean
you copied it in by hand or did you use an appropriate setup.py file
script?

> In my Apache conf I use this path
>
> PythonPath "['/'] + sys.path"

Why are you adding '/' to the module search path. There shouldn't be
any need to add the root of the file system to it.

Graham

> And now Django is working :-D
>
> Thanks a lot for your help
>
> César
>
> PD: Sorry for my bad english
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Terminology doubt

2008-03-28 Thread Russell Keith-Magee

On Sat, Mar 29, 2008 at 9:30 AM, Haroldo Stenger
<[EMAIL PROTECTED]> wrote:
>  I have a terminology doubt:
>
> if my django project is called "p" and my django app within p is called "a",
>
> now in the context of django.contrib.admin.views,
> what do each of "app","model", and "id" stand for ? is "p" one of them ?

I'm unsure what you're confused about. The naming is consistent:

"app" is your application "a".
"model" is a model definition in the application "a".
"id" is the id number for a particular instance of "model"

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



'jellyroll' a django app

2008-03-28 Thread stranger

Hi all,

 I am using jellyroll application written by jacob kaplan moss.
http://code.google.com/p/jellyroll/

I want  to add geo-latitude and geo-longitude fields for flickr model.
Can anyone help me in syncing those 2 fields into my jellyroll app.
When displaying the photo I am want to mashup the photo's location
with a google map. 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Do I need two classes that are identical because I want to use two database tables?

2008-03-28 Thread andy baxter

Peter Rowell wrote:
>> So should I just create two classes that are identical but name one
>> CurrentElectionResults and the other PastElectionResults?
>> 
Can't you just have a single class 'ElectionResults' and add a field 
called 'current'?

I'm planning on doing something similar with my app.

andy.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 I need two classes that are identical because I want to use two database tables?

2008-03-28 Thread Peter Rowell

> So should I just create two classes that are identical but name one
> CurrentElectionResults and the other PastElectionResults?

That would be one way of doing it. There are promises of subclassable
(?) Models in the works, but it hasn't been released yet.

If there are a fair number of methods connected with the class, you
could avoid duplicating them by creating a third class and then using
multiple inheritance for the two models. A project I recently finished
had a dozen different types of content objects (articles, q&a, videos,
etc.), each with unique aspects to it, but all of which needed
functions for determining parent sections, building breadcrumbs, etc.
etc., and this technique handled it nicely.

E.g.

class ElectionResultMethods:
  """Common methods for the two ElectionResult classes""
  def foo(self):
  pass
  def bar(self):
  pass

class CurrentElectionResults(models.Model, ElectionResultsMethods):
   etc.

class PassElectionResults(models.Model, ElectionResultsMethods):
   etc.

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



Re: Tutorial: Admin Template Customization

2008-03-28 Thread Peter Rowell

On Mar 28, 2:48 pm, Evert Rol <[EMAIL PROTECTED]> wrote:
> locate uses a database which doesn't always get promptly updated.
> Waiting a few hours (or perhaps days) will show the correct
> base_site.html as well. So locate not finding this is not an issue here.

If you are root on the machine, you can force an update.
/usr/bin/updatedb will do the trick on most Linux boxen.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Terminology doubt

2008-03-28 Thread Haroldo Stenger
 I have a terminology doubt:

if my django project is called "p" and my django app within p is called "a",

now in the context of django.contrib.admin.views,
what do each of "app","model", and "id" stand for ? is "p" one of them ?

which part of the doc should I check ?

cheers

h

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Purpose of Complex Generic Views

2008-03-28 Thread bob

Thanks for pointing that out.  I just browsed to the object_list()
source, and it's nice to see a lot of the pagination stuffs abstracted
out, it indeed helped me to appreciate it more. :)

On Mar 28, 4:50 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 6:40 PM, bob <[EMAIL PROTECTED]> wrote:
> >  in some examples that require extra work, we have to define a wrapper
> >  function.  What's confusing me is how is this different from just
> >  defining regular views?  I can't quite notice much reduction in code,
> >  nor improvements in reusability.  Can anyone please help to point out
> >  what I'm missing?
>
> Typically, so long as the additional requirements are not terribly
> complex, it is a significant code saving; the 'object_list' generic
> view, for example, is just under 100 lines of code, while in many
> cases a wrapper function which uses it is only a half-dozen lines (if
> that). That's better than a 90% reduction in the amount of code you
> have to write yourself, so it's a useful pattern.
>
> Of course, if you need to add in more complex functionality, the
> saving naturally decreases to the point where using nothing but your
> own code makes sense.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Purpose of Complex Generic Views

2008-03-28 Thread James Bennett

On Fri, Mar 28, 2008 at 6:40 PM, bob <[EMAIL PROTECTED]> wrote:
>  in some examples that require extra work, we have to define a wrapper
>  function.  What's confusing me is how is this different from just
>  defining regular views?  I can't quite notice much reduction in code,
>  nor improvements in reusability.  Can anyone please help to point out
>  what I'm missing?

Typically, so long as the additional requirements are not terribly
complex, it is a significant code saving; the 'object_list' generic
view, for example, is just under 100 lines of code, while in many
cases a wrapper function which uses it is only a half-dozen lines (if
that). That's better than a 90% reduction in the amount of code you
have to write yourself, so it's a useful pattern.

Of course, if you need to add in more complex functionality, the
saving naturally decreases to the point where using nothing but your
own code makes sense.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Purpose of Complex Generic Views

2008-03-28 Thread bob

Hi,

I'm a newbie to Django.  I've just read the reference doc and Django
Book chapter on generic view, but I'm still a bit confused as to when
to justify the use of generic views.  This is just out of curiosity,
as I'm sure there are aspects I've overlooked.  My understanding is
that generic views save you the trouble of defining a regular view,
which it seems to work out quite nicely in many scenarios.  However,
in some examples that require extra work, we have to define a wrapper
function.  What's confusing me is how is this different from just
defining regular views?  I can't quite notice much reduction in code,
nor improvements in reusability.  Can anyone please help to point out
what I'm missing?

Thanks very much!

Bob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problems with generic.GenericForeignKey()

2008-03-28 Thread Daniel Roseman

On Mar 28, 9:16 pm, Josh <[EMAIL PROTECTED]> wrote:
> I've determined that the problem is with the get(). If I just create
> the objects without first checking to see if it already exists,
> there's no problem.
>
> So I guess my question is now this: what's the best way to avoid
> duplicates here?

You can't use the dynamically-generated content_object field as a
lookup. However, you can use content_type and object_id, since these
are explicitly declared in your model. So something like this will
work:

model = ContentType.objects.get_for_model(match)
obj = WordedItem.objects.get(content_type=model, object_id=match.id,
word=word)

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



Re: Tutorial: Admin Template Customization

2008-03-28 Thread Evert Rol

> directory. Also, when I run locate base_site.html from within the
> shell, it only returns the default base_site.html located in the
> django/contrib/admin/templates/admin/ directory. When I cd into

locate uses a database which doesn't always get promptly updated.  
Waiting a few hours (or perhaps days) will show the correct  
base_site.html as well. So locate not finding this is not an issue here.


> fastraxstudio/mytemplates/admin/, where my base_site.html file is and
> ls -l there it is, or for that matter when I view the directory from
> the finder, there it is.
>
> Here is the terminal output:
>
> fastrax-studios-power-mac-g4:~ fastraxstudio$ locate base_site.html
> /opt/local/lib/python2.5/site-packages/django/contrib/admin/templates/
> admin/base_site.html
> /opt/local/var/macports/software/py25-django-devel/0.96.1_1/opt/local/
> lib/python2.5/site-packages/django/contrib/admin/templates/admin/
> base_site.html
> fastrax-studios-power-mac-g4:~ fastraxstudio$ cd mytemplates
> fastrax-studios-power-mac-g4:~/mytemplates fastraxstudio$ cd admin
> fastrax-studios-power-mac-g4:~/mytemplates/admin fastraxstudio$ ls -l
> total 8
> -rw-r--r--   1 fastraxs  fastraxs  268 Mar 28 13:32 base_site.html
> fastrax-studios-power-mac-g4:~/mytemplates/admin fastraxstudio$
>
> Thanks for any help with this,
>
> Jason

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Multiple django sites with common portal

2008-03-28 Thread hambaloney

Hello!

I'm hoping to get an idea on how to approach a system setup I've been
thinking about.

In this system:
 - a group of users each has it's own Django site and database.  (e.g.
Group A has access only to Site A, etc)
 - each Django site shares common application code.
 - all users log in via a common portal and are 'redirected' to their
respective sites (I'm using contrib.admin in my example, so they're
redirected to their admin)

Ideally, this common portal would be seamless to the user. They log in
and immediately see their admin.

Couple of questions:

1. Is it possible to set up a portal in such away that the user login
information can be then used to authenticate them against their site?
I suspect I'd have to duplicate user entries, e.g. UserA would be in
the portal db as well as SiteA db. Ideally I'd want one interface to
manage all users, so redundant entries doesn't appeal.

2. Can I make this seamless? I would like users to use example.com,
login, and then, with the same url, utilize their site. I'm currently
using Apache+mod_python, but I have full access to a test server so
anything is possible. I was looking through Apache modules and read
through the proxying docs. Basically I can imagine hosting each Django
instance separately, via Lighttpd or another Apache instance, and
proxying, but the way I understand proxying, its a mapped address
(e.g. /myuser -> 127.0.0.1:someport), but I'd rather not have the /
myuser url.

If any of this is unclear, let me know.

Thanks,

Fred/hambaloney
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problems with generic.GenericForeignKey()

2008-03-28 Thread Josh

I've determined that the problem is with the get(). If I just create
the objects without first checking to see if it already exists,
there's no problem.

So I guess my question is now this: what's the best way to avoid
duplicates here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: using Django unit test framework with existing production db

2008-03-28 Thread Jeff Gentry

> Is there some graceful way to have the Django unit test framework
> access the "production database" for certain tests as opposed to
> creating a test db? The idea is to do a basic sanity check of the
> "production db" in case the schema has changed and the db needs to be
> rebuilt.

http://groups.google.com/group/django-users/browse_thread/thread/e323bd3a3d7bc5ef/83995eb20dba8c27?hl=en&lnk=st&q=django-users+jgentry#83995eb20dba8c27


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



using Django unit test framework with existing production db

2008-03-28 Thread Faheem Mitha


Hi,

Is there some graceful way to have the Django unit test framework access 
the "production database" for certain tests as opposed to creating a test 
db? The idea is to do a basic sanity check of the "production db" in case 
the schema has changed and the db needs to be rebuilt.

Please CC me on any reply.
  Thanks, Faheem.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Tutorial: Admin Template Customization

2008-03-28 Thread [EMAIL PROTECTED]

Hello,

I'm just going through the tutorial for the admin template
customization and for some reason django isn't picking up the
base_site.html file I copied into my /user/mytemplates/admin
directory. Also, when I run locate base_site.html from within the
shell, it only returns the default base_site.html located in the
django/contrib/admin/templates/admin/ directory. When I cd into
fastraxstudio/mytemplates/admin/, where my base_site.html file is and
ls -l there it is, or for that matter when I view the directory from
the finder, there it is.

Here is the terminal output:

fastrax-studios-power-mac-g4:~ fastraxstudio$ locate base_site.html
/opt/local/lib/python2.5/site-packages/django/contrib/admin/templates/
admin/base_site.html
/opt/local/var/macports/software/py25-django-devel/0.96.1_1/opt/local/
lib/python2.5/site-packages/django/contrib/admin/templates/admin/
base_site.html
fastrax-studios-power-mac-g4:~ fastraxstudio$ cd mytemplates
fastrax-studios-power-mac-g4:~/mytemplates fastraxstudio$ cd admin
fastrax-studios-power-mac-g4:~/mytemplates/admin fastraxstudio$ ls -l
total 8
-rw-r--r--   1 fastraxs  fastraxs  268 Mar 28 13:32 base_site.html
fastrax-studios-power-mac-g4:~/mytemplates/admin fastraxstudio$

Thanks for any help with this,

Jason
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi Karen,

You are correct, it should be:
AUTH_PROFILE_MODULE=userprofile.userprofile

I think the current documentation on this particular issue, needs to
be updated more properly, since the way it is currently written does
not agree with what you have showed me.

Thank you so much!

Rgs!/Fco

On Mar 28, 2:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 4:06 PM, Francisco Benavides <
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi Again,
>
> > I also get errors if I try to use the get_profile() funtion:
>
> > from django.contrib.auth.models import User
> >from txm.userprofile.models import UserProfile
> >user= User.objects.get(username__exact=username)
> >profile = user.get_profile()
>
> > Here is the traceback:
> >http://dpaste.com/41883/
>
> This one looks like your AUTH_PROFILE_MODULE hasn't be set properly in
> settings.py.  From your earlier note I see you have it as 'txm.userprofile'
> but you've got your models.py that defines the UserProfile model under
> userprofile, not txm, so I think perhaps AUTH_PROFILE_MODULE is supposed to
> be 'userprofile.userprofile' for the way you have things set up.
>
> 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
-~--~~~~--~~--~--~---



make money

2008-03-28 Thread ahbrikaa

make money online
http://www.idccard.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
-~--~~~~--~~--~--~---



make money

2008-03-28 Thread ahbrikaa

make money online
http://www.idccard.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: User profile metadata problem

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 4:06 PM, Francisco Benavides <
[EMAIL PROTECTED]> wrote:

>
> Hi Again,
>
> I also get errors if I try to use the get_profile() funtion:
>
> from django.contrib.auth.models import User
>from txm.userprofile.models import UserProfile
>user= User.objects.get(username__exact=username)
>profile = user.get_profile()
>
> Here is the traceback:
> http://dpaste.com/41883/
>

This one looks like your AUTH_PROFILE_MODULE hasn't be set properly in
settings.py.  From your earlier note I see you have it as 'txm.userprofile'
but you've got your models.py that defines the UserProfile model under
userprofile, not txm, so I think perhaps AUTH_PROFILE_MODULE is supposed to
be 'userprofile.userprofile' for the way you have things set up.

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



Django admin interface: problem with '../../../' in URLs and post_url.

2008-03-28 Thread Josh

I've made some changes to my admin interface to create a new set of
pages for editing some of my models. Instead of just /admin/app/model/
id, I now also have /admin/dashboard/id which shows summary of the
data for that object as well as giving some options for modifying some
of it's ForeignKey/ManyToMany relationship. In order to accommodate
this, I'm using post_url so that when you go to a change_form from the
dashboard page it returns you back to the dashboard when you're done.
To accomplish this I used the code found here:
http://groups.google.com/group/django-users/browse_thread/thread/75b6e51430adf84e/8eae175407f76393?lnk=st&q=post_url#8eae175407f76393

This is where the problem with the '../../../' URLs comes in. Since I
now have URLs along the lines of /admin/app/model/id1/admin/dashboard/
id2 which causes those URLs to evaluate to something like /admin/app/
model/id1/jsi18n.js. I was able to fix this for the history, the
breadcrumbs, and jsi18n by overriding the default admin template and
hardcoding those URLs in. Unfortunately I'm also using raw_id_admin
for a number of fields, and the showRelatedObjectLookupPopup link also
uses the '../../../' syntax. Since this isn't controlled directly in
the template I'm not able to override it there as I did with the
others.

Is there some simple way to fix those URLs? Or maybe a better way of
using post_url?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: User profile metadata problem

2008-03-28 Thread Francisco Benavides

HI Karen,

OK, I will leave Meta as "pass", which is sufficient, for now and I
thank you for your time and effort helping me.

I will wait on the get_profile() issue, I am using 0.97-pre.

Rgs!/Fco

On Mar 28, 2:14 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Mar 28, 1:57 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> >  ordering = ['auth_user.first_name','auth_user.last_name']
>
> Giving a model a default ordering based on a foreign key is not
> currently possible in either 0.96 or trunk.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IntegrityError: duplicate key violates unique constraint

2008-03-28 Thread Brian Armstrong

Also, if you have access to the old DB still, consider exporting the
entire thing out again.  Make sure that you include the structural
part as well as the data itself.  It should export it directly as a
series of SQL statements.  A complete dump will provide information
about the sequences.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: User profile metadata problem

2008-03-28 Thread James Bennett

On Mar 28, 1:57 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>  ordering = ['auth_user.first_name','auth_user.last_name']

Giving a model a default ordering based on a foreign key is not
currently possible in either 0.96 or trunk.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi Karen,

Nop, the suggestion does not work, look at the trace:

Traceback debug:
http://dpaste.com/41887/

Rgs!/Fco

On Mar 28, 1:57 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 3:46 PM, Francisco Benavides <
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi Karen,
>
> > Thanks for the pointer. I started looking as suggested, and found an
> > interesting link on the issue:
>
> >http://groups.google.com.mx/group/django-users/browse_thread/thread/b...
>
> > The above, makes me look into te details and understadn how vague my
> > question was. Still, I do not know how to do the following:
> > How can I configure my UserProfile metadata in order to order the data
> > in accordance to the User table fields (first_name, last_name), which
> > are pointed to by a ForeignKey in UserProfile (user).
>
> Does:
>
> ordering = ['auth_user.first_name','auth_user.last_name']
>
> not work?  auth_user is the table name for the User's table, I believe.
>
> Karen
>
>
>
> > Thank's/Fco
>
> > On Mar 28, 12:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
>
> > > [EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > I have created a User profile, pointing to the User table, as per the
> > > > documentation; how can I access the User fields from the UserProfile
> > > > so I can place that in the metadata class?
>
> > > > userprofile.models.py
> > > >http://dpaste.com/41831/
>
> > > Your question is vague, so I'm not sure what you are asking.  If you've
> > got
> > > something that isn't working it helps people to help you if you tell
> > them
> > > what the symptoms are of its not working.  In this case looking at your
> > > model I'm guessing the ordering you are trying to specify isn't ordering
> > the
> > > way you expect or is throwing an error.  Ordering by related fields is,
> > I
> > > believe, a bit fragile in trunk (to be improved when queryset-refactor
> > is
> > > merged), but it might work for a simple relation.  I think it involves
> > > specifying the table name for the related field, but I don't recall the
> > > details.  You might try searching on "ForeignKey" and "ordering" on this
> > > list and you should find some pointers for how to do it.  If your
> > problem
> > > relates to something else please provide more details.
>
> > > 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: User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi Again,

I also get errors if I try to use the get_profile() funtion:

from django.contrib.auth.models import User
from txm.userprofile.models import UserProfile
user= User.objects.get(username__exact=username)
profile = user.get_profile()

Here is the traceback:
http://dpaste.com/41883/

Rgs!/Fco

On Mar 28, 1:46 pm, Francisco Benavides
<[EMAIL PROTECTED]> wrote:
> Hi Karen,
>
> Thanks for the pointer. I started looking as suggested, and found an
> interesting link on the 
> issue:http://groups.google.com.mx/group/django-users/browse_thread/thread/b...
>
> The above, makes me look into te details and understadn how vague my
> question was. Still, I do not know how to do the following:
> How can I configure my UserProfile metadata in order to order the data
> in accordance to the User table fields (first_name, last_name), which
> are pointed to by a ForeignKey in UserProfile (user).
>
> Thank's/Fco
>
> On Mar 28, 12:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
>
> > [EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I have created a User profile, pointing to the User table, as per the
> > > documentation; how can I access the User fields from the UserProfile
> > > so I can place that in the metadata class?
>
> > > userprofile.models.py
> > >http://dpaste.com/41831/
>
> > Your question is vague, so I'm not sure what you are asking.  If you've got
> > something that isn't working it helps people to help you if you tell them
> > what the symptoms are of its not working.  In this case looking at your
> > model I'm guessing the ordering you are trying to specify isn't ordering the
> > way you expect or is throwing an error.  Ordering by related fields is, I
> > believe, a bit fragile in trunk (to be improved when queryset-refactor is
> > merged), but it might work for a simple relation.  I think it involves
> > specifying the table name for the related field, but I don't recall the
> > details.  You might try searching on "ForeignKey" and "ordering" on this
> > list and you should find some pointers for how to do it.  If your problem
> > relates to something else please provide more details.
>
> > 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: IntegrityError: duplicate key violates unique constraint

2008-03-28 Thread Marty Alchin

Given that you say you're working with PG Navicat, I assume you're
using Postgresql as your database. Postgresql has a concept of
sequences, which it uses to generate IDs for auto-generated fields
like Django's AutoField.

I think what you've done, by copying data in directly, is created
records with the specific IDs that existed in your existing data.
Since Postgresql didn't have to generate these IDs, it probably never
incremented its sequence. So when you add new records, Django doesn't
provide an ID, so Postgresql gets a new one from its sequence, then
bombs out because that new ID already exists.

Check out the Postgresql docs for ALTER SEQUENCE[1], which you can use
to reset the value to something like the highest ID in your data set
(or the highest plus one, I'm not sure). This way, when a new object
is created, the generated ID won't already be in use. Keep in mind
that you'll have to do this for every sequence that your database uses
to generate IDs, and each one will need to be set to a different
value, depending on what IDs are in the related table.

Hope that helps.

-Gul

[1] http://www.postgresql.org/docs/current/interactive/sql-altersequence.html

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



Re: User profile metadata problem

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 3:46 PM, Francisco Benavides <
[EMAIL PROTECTED]> wrote:

>
> Hi Karen,
>
> Thanks for the pointer. I started looking as suggested, and found an
> interesting link on the issue:
>
> http://groups.google.com.mx/group/django-users/browse_thread/thread/bddbc4c71e8298ef/3d367268d297e89c?lnk=gst&q=%22ForeignKey%22+and+%22ordering%22#3d367268d297e89c
>
> The above, makes me look into te details and understadn how vague my
> question was. Still, I do not know how to do the following:
> How can I configure my UserProfile metadata in order to order the data
> in accordance to the User table fields (first_name, last_name), which
> are pointed to by a ForeignKey in UserProfile (user).
>

Does:

ordering = ['auth_user.first_name','auth_user.last_name']

not work?  auth_user is the table name for the User's table, I believe.

Karen


>
> Thank's/Fco
>
> On Mar 28, 12:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
> >
> > [EMAIL PROTECTED]> wrote:
> >
> > > Hi,
> >
> > > I have created a User profile, pointing to the User table, as per the
> > > documentation; how can I access the User fields from the UserProfile
> > > so I can place that in the metadata class?
> >
> > > userprofile.models.py
> > >http://dpaste.com/41831/
> >
> > Your question is vague, so I'm not sure what you are asking.  If you've
> got
> > something that isn't working it helps people to help you if you tell
> them
> > what the symptoms are of its not working.  In this case looking at your
> > model I'm guessing the ordering you are trying to specify isn't ordering
> the
> > way you expect or is throwing an error.  Ordering by related fields is,
> I
> > believe, a bit fragile in trunk (to be improved when queryset-refactor
> is
> > merged), but it might work for a simple relation.  I think it involves
> > specifying the table name for the related field, but I don't recall the
> > details.  You might try searching on "ForeignKey" and "ordering" on this
> > list and you should find some pointers for how to do it.  If your
> problem
> > relates to something else please provide more details.
> >
> > 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: IntegrityError: duplicate key violates unique constraint

2008-03-28 Thread James Bennett

On Fri, Mar 28, 2008 at 2:35 PM, makebelieve <[EMAIL PROTECTED]> wrote:
>  I haven't added any unique contraints.  It really seems as though
>  django doesn't know
>  about my existing data.  If I obliterate the old data everything works
>  fine, but
>  that's not a possibility.

At the database level there is some sort of constraint requiring
uniqueness; otherwise your DB would not be raising the error it's
raising.

But you apparently have not made Django aware of this constraint, so
Django tries to insert duplicate data and you get an error.

The solution is to make Django aware of the constraint.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: usernames and case sensitivity

2008-03-28 Thread Jonathan Lukens


> (Now that I think of it, I'm somewhat surprised that Django's
> contrib.auth allows mixed case usernames. Quickly scanning through it,
> all examples seem to use all lower-case anyway.)

Surprised me too, but I'm not a real web developer (I pay the bills by
translating technical literature) so I thought there was maybe a best
practice I was unaware of.  If other people are caught off guard by
it, maybe a ticket should be opened...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: CacheMiddleware issue

2008-03-28 Thread bfrederi

It absolutely does work, I just didn't know what I was doing:
return HttpResponse(response_file.read(), mimetype=response_mimetype)

Thanks :)

On Mar 28, 1:00 pm, Mike Axiak <[EMAIL PROTECTED]> wrote:
> Does the following code change not work?
>http://dpaste.com/41855/
>
> Cheers,
> Mike
>
> On Mar 28, 1:16 pm, bfrederi <[EMAIL PROTECTED]> wrote:
>
> > Mike,
>
> > I'm not exactly sure how to do a read and get the file to be cached in
> > memory with the middleware. If you look at the links I posted to my
> > code, how would I cache the file within that view I posted? The
> > decorator you specified worked perfectly fine for disabling the cache
> > middleware for that view, but I actually want the file to be placed in
> > cache, and so far I haven't been able to get it to work.
>
> > Thanks, Brandon
>
> > On Mar 27, 5:45 pm, Mike Axiak <[EMAIL PROTECTED]> wrote:
>
> > > Brandon,
>
> > > It appears that the Cache Middleware does not read the content from
> > > the file before caching the response [1]. I'm not sure if this is a
> > > bug or not...though I'd probably lean towards it being a bug. (Do we
> > > not cache middleware to *always* evaluate a file object before caching
> > > the response?)
> > > Anyway, until that behavior gets changed, there's no reason you can't
> > > read (via .read()) your files to just send your content.
>
> > > If you expect Django to cache all your data, then you have to read the
> > > entire file into memory at *some* point. So I see two options:
> > >1. Read all the file contents into memory by calling
> > > file_object.read() before putting it into the HttpResponse object.
> > >2. Disabling cache middleware for that view. To do this, you can
> > > use the cache_control decorator [2]. E.g.:
> > >   @cache_control(max_age=0)
> > >   dev view(request): ...
>
> > > As it is your kind of giving Django conflicting requests since you're
> > > saying "Don't load the file into memory, load it lazily" while also
> > > saying "load the entire response into the cache".
>
> > > Regards,
> > > Mike
>
> > > 1:http://code.djangoproject.com/browser/django/trunk/django/middleware/...
> > > 2:http://www.djangoproject.com/documentation/cache/#controlling-cache-u...
>
> > > On Mar 27, 6:13 pm, bfrederi <[EMAIL PROTECTED]> wrote:
>
> > > > I appreciate the help Rajesh,
>
> > > > I haven't added any special settings for the cachemiddleware, I just
> > > > placed 'django.middleware.cache.CacheMiddleware' in my middleware
> > > > classes and that's it. As far as the low-level caching that I have
> > > > written into my code using the "from django.core.cache import cache",
> > > > all of that is working fine. It's just the middleware that is the
> > > > issue. As soon as I set the cache middleware in my middleware classes
> > > > setting, that's when I start having problems.
>
> > > > Here is an example view, where I try to open a file and it gives me a
> > > > "ValueError: I/O operation on closed file":
> > > > view (the line it actually executes is line 24):http://dpaste.com/41671/
> > > > function it calls (open_system_file):http://dpaste.com/41672/
>
> > > > Every part of that view works fine except for when I go to open that
> > > > file on line 24. And it works fine in my tests.py, I get the exact
> > > > data that I am supposed to from the file (the specific test is on line
> > > > 22):http://dpaste.com/41678/(open_system_fileonline23 is defined
> > > > in system_methods on line 3)
>
> > > > And as far as stack traces go, I have my mod python error I just gave
> > > > you. Here is the apache2 error log (I blocked out my ip out of
> > > > paranoia):http://dpaste.com/41682/Idon'tknowwhat else to give you
> > > > that would help as far as problems within the stack. I'm not doing
> > > > anything db related, so if there is something else you need me to
> > > > post, please mention it by name specifically, in case there is
> > > > something I'm not thinking of.
>
> > > > Thanks for the help,
> > > > Brandon
>
> > > > On Mar 27, 4:01 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi Brandon,
>
> > > > > > I would paste in some code examples, but this project is several
> > > > > > hundred lines long, and there are several incidences where I open
> > > > > > files that is conflicting with the cache middleware.
>
> > > > > Not knowing how you have your cache setup (anonymous, all views, low-
> > > > > level), it's hard to tell what's causing this problem. You haven't
> > > > > included full stack traces either. So, I would suggest including at
> > > > > least this:
>
> > > > > - A snippet of a view that fails...include at least one file opening
> > > > > command.
> > > > > - Full stacktraces of the two errors you mentioned along with the
> > > > > snippets of your application code that the stack traces point to.
>
> > > > > -Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django u

Re: admin filter field

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 1:40 PM, ameriblog <[EMAIL PROTECTED]> wrote:

>
> i have the following classes:
>
> NEWS
> headline
> story
> main-image (fk)
> story-image (fk)
>
> IMAGE
> image
> title
> description
> type
>
> What I'd like to do is in the admin, when I go to add a news item that
> in the main-image field it only gets entries from IMAGE where type =
> 1, and story-image where type = 2
>
> Can I do this?
>

Sounds like you want limit_choices_to, described here (under the description
of extra arguments):

http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships

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: usernames and case sensitivity

2008-03-28 Thread Jonathan Lukens


> Using the "iexact" option would fix this case.  Take a look 
> at:http://www.djangobook.com/en/1.0/appendixC/
> towards the bottom, in the Field Lookups section.

Yes, this is what I meant by "filter with case-insensitive queries
whenever the username is URL param" -- I just couldn't remember the
syntax :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi Karen,

Thanks for the pointer. I started looking as suggested, and found an
interesting link on the issue:
http://groups.google.com.mx/group/django-users/browse_thread/thread/bddbc4c71e8298ef/3d367268d297e89c?lnk=gst&q=%22ForeignKey%22+and+%22ordering%22#3d367268d297e89c

The above, makes me look into te details and understadn how vague my
question was. Still, I do not know how to do the following:
How can I configure my UserProfile metadata in order to order the data
in accordance to the User table fields (first_name, last_name), which
are pointed to by a ForeignKey in UserProfile (user).

Thank's/Fco

On Mar 28, 12:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I have created a User profile, pointing to the User table, as per the
> > documentation; how can I access the User fields from the UserProfile
> > so I can place that in the metadata class?
>
> > userprofile.models.py
> >http://dpaste.com/41831/
>
> Your question is vague, so I'm not sure what you are asking.  If you've got
> something that isn't working it helps people to help you if you tell them
> what the symptoms are of its not working.  In this case looking at your
> model I'm guessing the ordering you are trying to specify isn't ordering the
> way you expect or is throwing an error.  Ordering by related fields is, I
> believe, a bit fragile in trunk (to be improved when queryset-refactor is
> merged), but it might work for a simple relation.  I think it involves
> specifying the table name for the related field, but I don't recall the
> details.  You might try searching on "ForeignKey" and "ordering" on this
> list and you should find some pointers for how to do it.  If your problem
> relates to something else please provide more details.
>
> 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
-~--~~~~--~~--~--~---



Is Django thread safe?

2008-03-28 Thread Peter Rowell

Graham --

Thanks very much for your replies.

My concerns were from having two authorities saying different things
-- it makes the unwashed masses nervous. :-)

Of course, *now* I need to do a code review, since I hadn't been
thinking "thread safe" when I wrote it.

Is anyone (Django core developers?) reading this who can verify that
Django is, in fact, thread safe and plays well under worker MPM?

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



Re: What is an UploadedFile?

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 2:10 PM, Eric VW <[EMAIL PROTECTED]> wrote:

>
> I have tried searching around in the newforms FileField documentation
> and have no idea what I is the UploadedFile object is when you
> cleaned_data?  Does anyone else know?
>
> Thanks!
>

When documentation is lacking, there's always the source to look at:

http://code.djangoproject.com/browser/django/trunk/django/newforms/fields.py#L417

It's just a wrapper to hold the filename, content pair.

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: IntegrityError: duplicate key violates unique constraint

2008-03-28 Thread makebelieve

I haven't added any unique contraints.  It really seems as though
django doesn't know
about my existing data.  If I obliterate the old data everything works
fine, but
that's not a possibility.

On Mar 28, 12:13 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 2:10 PM, makebelieve <[EMAIL PROTECTED]> wrote:
> >  Saving some of my objects work, but only because early IDs have been
> >  removed
> >  so it isn't trying to insert an object with an existing ID.
>
> It sounds like you have a unique constraint in the DB that you haven't
> told Django about.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: blog displays raw html [SOLVED]

2008-03-28 Thread Floyd Arguello

That was it exactly - thank you very much!

Floyd


Justin Lilly wrote:
> You're being affected by a relatively new feature: Autoescaping HTML. 
>  You can find more information at this link:
> 
> http://www.djangoproject.com/documentation/templates/#automatic-html-escaping
> 
> -justin
> 
> On Thu, Mar 27, 2008 at 7:32 PM, Floyd Arguello <[EMAIL PROTECTED] 
> > wrote:
> 
> 
> Hi djangoers,
> 
> I'm learning Django by setting up a blog per instructions here (combined
> with code from djangoproject.com  svn):
> http://www.rossp.org/blog/2006/jun/08/django-blog-redux/
> 
> Most things work, except I enter raw html when posting the blog through
> the admin interface, and the raw html is displayed on the page.
> 
> I enter raw html when editing flatpages, and that renders properly in my
> browser.
> 
> Also, I use the slug as part of my post urls; but they only work when I
> use text... I would also like to use hyphens.
> 
> I'm using latest django svn, python 2.4.3, RHEL5, Apache2.2 w/
> mod_python.
> 
> models.py:
> import datetime
> from django.db import models
> 
> class Post(models.Model):
> pub_date = models.DateTimeField()
> slug = models.SlugField(unique_for_date='pub_date')
> headline = models.CharField(max_length=200)
> summary = models.TextField(help_text="post summary - use html")
> body = models.TextField(help_text="Body Text - can use html")
> author = models.CharField(max_length=100)
> 
> 
> Thanks,
> Floyd
> 
> 
> 
> 
> 
> -- 
> Justin Lilly
> Web Developer/Designer
> http://justinlilly.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: IntegrityError: duplicate key violates unique constraint

2008-03-28 Thread James Bennett

On Fri, Mar 28, 2008 at 2:10 PM, makebelieve <[EMAIL PROTECTED]> wrote:
>  Saving some of my objects work, but only because early IDs have been
>  removed
>  so it isn't trying to insert an object with an existing ID.

It sounds like you have a unique constraint in the DB that you haven't
told Django about.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: IntegrityError: duplicate key violates unique constraint

2008-03-28 Thread makebelieve

I'm really in a bind here and need to get my site back up.
Any help at all will be greatly appreciated.

Saving some of my objects work, but only because early IDs have been
removed
so it isn't trying to insert an object with an existing ID.

Is there anyway to make django 'know' about the existing data?

Thanks you.

On Mar 27, 7:28 pm, makebelieve <[EMAIL PROTECTED]> wrote:
> I recently made a new production database for a site using the
> following methods:
>
> 1.  Ran syncdb to create all tables needed for the project
> 2.  Used data transfer in PG Navicat to bring in old data I need
>
> Now when I try to create a new object in the admin interface I keep
> getting:
>
> IntegrityError: duplicate key violates unique constraint
> "app_table_pkey"
>
> It's like it doesn't know all those records are there and is trying to
> save over them.
>
> Can someone please tell me how to fix this?
>
> Thank you.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: assertRaises() in django unittest framework doesn't catch exceptions

2008-03-28 Thread Marty Alchin

On Thu, Mar 27, 2008 at 10:49 AM, Karantir <[EMAIL PROTECTED]> wrote:
>
>  And here is a bit of my testcase
>  [code]
>
> self.assertRaises(RevisionNotStarted,
>  self.documents[0].fix_revision())
>  [/code]

Try removing the extra parentheses from your test case. assertRaises
expects to get a callable, which it can call within its own try/catch
block. You're instead calling the fix_revision() method before
assertRaises even has a chance to see the function. There's no way it
could catch the error in this case, so the error you reported is
natural.

[code]
self.assertRaises(RevisionNotStarted,
self.documents[0].fix_revision)
[/code]

-Gul

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: User profile metadata problem

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I have created a User profile, pointing to the User table, as per the
> documentation; how can I access the User fields from the UserProfile
> so I can place that in the metadata class?
>
> userprofile.models.py
> http://dpaste.com/41831/
>
>
Your question is vague, so I'm not sure what you are asking.  If you've got
something that isn't working it helps people to help you if you tell them
what the symptoms are of its not working.  In this case looking at your
model I'm guessing the ordering you are trying to specify isn't ordering the
way you expect or is throwing an error.  Ordering by related fields is, I
believe, a bit fragile in trunk (to be improved when queryset-refactor is
merged), but it might work for a simple relation.  I think it involves
specifying the table name for the related field, but I don't recall the
details.  You might try searching on "ForeignKey" and "ordering" on this
list and you should find some pointers for how to do it.  If your problem
relates to something else please provide more details.

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: usernames and case sensitivity

2008-03-28 Thread Evert Rol

> You've understood me perfectly.  I was just being picky.  I would
> *like* to preserve the option of cased usernames, but if wikimedia
> doesn't fuss with it, why should I?  I'll just add a clean_username
> method to the registration form that .lower() 's the name entered as
> suggested.
> Thank you for your input.

Well, wikimedia isn't the official oracle, but it works fine as a good  
example. (As another example, trying logging in to your gmail account  
using some odd variation of lower and upper case letter; google/gmail  
doesn't care: it's all lower case behind the scenes.)
And I'm just used to all lower-case usernames anyway, although that  
originates probably from the fact that I'm just used to working with  
computer systems that have their origins in the 70's, where everything  
was case insensitive anyway. Though I'm not sure if *nix simply  
doesn't allow upper case in account names, or that's more a standard  
rule.

(Now that I think of it, I'm somewhat surprised that Django's  
contrib.auth allows mixed case usernames. Quickly scanning through it,  
all examples seem to use all lower-case anyway.)



> 2) Validate new usernames for case-insensitive uniqueness and  
> filter
> with case-insensitive queries whenever the username is URL param.
>>
 def view(request, username, child=None, ...):
  username = username.lower()
>>
>>> The problem here is that that even if 'Charlie' and 'charlie' cannot
>>> exist as usernames concurrently, 'Charlie' still can if he gets  
>>> there
>>> first.  So if that were the case and I had '/Charlie/' and passed
>>> username.lower() to `widgets =
>>> Widget.objects.get(owner__username=username), it is going to look  
>>> for
>>> charlie and won't find it.  At least I am pretty sure that  
>>> happened to
>>> me last evening when I was trying this, though it was pretty late...
>>
>> Ok, but cannot you store owner.username in lowercase from the start?
>> At some point, Charlie wants to create an account (or however you've
>> set it up), and while you have a proper name (Charlie Someone), the
>> username is (invisibly) charlie. If you put in a line on the sign up
>> form or similar stating that the username will be lower case, that
>> shouldn't be confusing.  (Eg, wikimedia doesn't bother with case for
>> user accounts on sign up and afterwards. In fact, it always
>> capitalizes the first letter, even if the account would 'root', which
>> is typically an all lower-case account.)
>> For user friendliness, the username should be invisible to the user.
>> The fact that you allow it in the URL is ok, but should otherwise
>> still be invisible (You could even choose to redirect to an all  
>> lower-
>> case URL).
>> Though I fear I'm simply misunderstanding your problem (or missing
>> some unknowns), so all my suggestions may be of not much use anyway!
>>
>>   Evert
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



What is an UploadedFile?

2008-03-28 Thread Eric VW

I have tried searching around in the newforms FileField documentation
and have no idea what I is the UploadedFile object is when you
cleaned_data?  Does anyone else know?

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: Weird POST data issues

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 12:10 PM, homebrew79 <[EMAIL PROTECTED]> wrote:

> A friend of mine that has been helping me look at this just showed me
> ticket 6256: http://code.djangoproject.com/ticket/6256.  So I guess no
> need to reply.  Thanks!
>

You're the second person to re-discover this bug in the last week.   It's
extremely hard to diagnose (or even search for in the tracker, since you
almost have to figure out what is going on to discover some likely keywords
to search on), so if any of the core devs have some time (yeah, I know) it'd
be really nice to get a fix for this into Django.

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



not receiving email from the list

2008-03-28 Thread andy baxter

hello,

I have subscribed successfully to the group, and can read it online,
but I'm not receiving emails sent from the group, even though I have
asked to when subscribing. Is this a known issue? Can any of you do
anything about it or should I contact google?

thanks,

andy baxter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problems with Apache + mod_python [SOLVED]

2008-03-28 Thread Slayer_X

Problem solved!

I deleted the symlinks, delete de django-trunk dir and make a fresh
install directly in

/usr/lib/python2.4/site-packages/django

In my Apache conf I use this path

PythonPath "['/'] + sys.path"

And now Django is working :-D

Thanks a lot for your help

César

PD: Sorry for my bad english

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: CacheMiddleware issue

2008-03-28 Thread Mike Axiak

Does the following code change not work?
   http://dpaste.com/41855/

Cheers,
Mike

On Mar 28, 1:16 pm, bfrederi <[EMAIL PROTECTED]> wrote:
> Mike,
>
> I'm not exactly sure how to do a read and get the file to be cached in
> memory with the middleware. If you look at the links I posted to my
> code, how would I cache the file within that view I posted? The
> decorator you specified worked perfectly fine for disabling the cache
> middleware for that view, but I actually want the file to be placed in
> cache, and so far I haven't been able to get it to work.
>
> Thanks, Brandon
>
> On Mar 27, 5:45 pm, Mike Axiak <[EMAIL PROTECTED]> wrote:
>
> > Brandon,
>
> > It appears that the Cache Middleware does not read the content from
> > the file before caching the response [1]. I'm not sure if this is a
> > bug or not...though I'd probably lean towards it being a bug. (Do we
> > not cache middleware to *always* evaluate a file object before caching
> > the response?)
> > Anyway, until that behavior gets changed, there's no reason you can't
> > read (via .read()) your files to just send your content.
>
> > If you expect Django to cache all your data, then you have to read the
> > entire file into memory at *some* point. So I see two options:
> >    1. Read all the file contents into memory by calling
> > file_object.read() before putting it into the HttpResponse object.
> >    2. Disabling cache middleware for that view. To do this, you can
> > use the cache_control decorator [2]. E.g.:
> >       @cache_control(max_age=0)
> >       dev view(request): ...
>
> > As it is your kind of giving Django conflicting requests since you're
> > saying "Don't load the file into memory, load it lazily" while also
> > saying "load the entire response into the cache".
>
> > Regards,
> > Mike
>
> > 1:http://code.djangoproject.com/browser/django/trunk/django/middleware/...
> > 2:http://www.djangoproject.com/documentation/cache/#controlling-cache-u...
>
> > On Mar 27, 6:13 pm, bfrederi <[EMAIL PROTECTED]> wrote:
>
> > > I appreciate the help Rajesh,
>
> > > I haven't added any special settings for the cachemiddleware, I just
> > > placed 'django.middleware.cache.CacheMiddleware' in my middleware
> > > classes and that's it. As far as the low-level caching that I have
> > > written into my code using the "from django.core.cache import cache",
> > > all of that is working fine. It's just the middleware that is the
> > > issue. As soon as I set the cache middleware in my middleware classes
> > > setting, that's when I start having problems.
>
> > > Here is an example view, where I try to open a file and it gives me a
> > > "ValueError: I/O operation on closed file":
> > > view (the line it actually executes is line 24):http://dpaste.com/41671/
> > > function it calls (open_system_file):http://dpaste.com/41672/
>
> > > Every part of that view works fine except for when I go to open that
> > > file on line 24. And it works fine in my tests.py, I get the exact
> > > data that I am supposed to from the file (the specific test is on line
> > > 22):http://dpaste.com/41678/(open_system_fileonline 23 is defined
> > > in system_methods on line 3)
>
> > > And as far as stack traces go, I have my mod python error I just gave
> > > you. Here is the apache2 error log (I blocked out my ip out of
> > > paranoia):http://dpaste.com/41682/Idon'tknow what else to give you
> > > that would help as far as problems within the stack. I'm not doing
> > > anything db related, so if there is something else you need me to
> > > post, please mention it by name specifically, in case there is
> > > something I'm not thinking of.
>
> > > Thanks for the help,
> > > Brandon
>
> > > On Mar 27, 4:01 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Brandon,
>
> > > > > I would paste in some code examples, but this project is several
> > > > > hundred lines long, and there are several incidences where I open
> > > > > files that is conflicting with the cache middleware.
>
> > > > Not knowing how you have your cache setup (anonymous, all views, low-
> > > > level), it's hard to tell what's causing this problem. You haven't
> > > > included full stack traces either. So, I would suggest including at
> > > > least this:
>
> > > > - A snippet of a view that fails...include at least one file opening
> > > > command.
> > > > - Full stacktraces of the two errors you mentioned along with the
> > > > snippets of your application code that the stack traces point to.
>
> > > > -Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: usernames and case sensitivity

2008-03-28 Thread Colin Bean

On Fri, Mar 28, 2008 at 10:02 AM, Jonathan Lukens
<[EMAIL PROTECTED]> wrote:
>
>  Hi Evert,
>
>
>  > > 2) Validate new usernames for case-insensitive uniqueness and filter
>  > > with case-insensitive queries whenever the username is URL param.
>
>
> > def view(request, username, child=None, ...):
>  >username = username.lower()
>
>  The problem here is that that even if 'Charlie' and 'charlie' cannot
>  exist as usernames concurrently, 'Charlie' still can if he gets there
>  first.  So if that were the case and I had '/Charlie/' and passed
>  username.lower() to `widgets =
>  Widget.objects.get(owner__username=username), it is going to look for
>  charlie and won't find it.  At least I am pretty sure that happened to
>  me last evening when I was trying this, though it was pretty late...

Hey Jonathan,

Using the "iexact" option would fix this case.  Take a look at:
http://www.djangobook.com/en/1.0/appendixC/
towards the bottom, in the Field Lookups section.

I *think* that:
 Widget.objects.get(owner__username__iexact='charlie') would get
Charlie, charlie, or any other case variation...  That way you could
also the original username value in the template, complete with
capitalization.

Colin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: sorl-thumbnail: Permission Denied

2008-03-28 Thread Josh

I figured it out. The problem was that I was using get_image_url
instead of just image, so it was attempting to write to media_root/
media_root/path/to/image instead of media_root/path/to/image.

On Mar 19, 1:04 pm, Josh Ourisman <[EMAIL PROTECTED]> wrote:
> I'm trying to set up sorl-thumbnail in my project, but it's giving me
> permission denied errors when it attempts to write the thumbnail to my
> media_root. I'm able to upload images through the Django admin
> interface, so I'm not sure why sorl wouldn't also have access to the
> directory. Is there some setting that needs to be changed to give it
> access?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: usernames and case sensitivity

2008-03-28 Thread Jonathan Lukens

You've understood me perfectly.  I was just being picky.  I would
*like* to preserve the option of cased usernames, but if wikimedia
doesn't fuss with it, why should I?  I'll just add a clean_username
method to the registration form that .lower() 's the name entered as
suggested.
Thank you for your input.

On Mar 28, 1:22 pm, Evert Rol <[EMAIL PROTECTED]> wrote:
> >>> 2) Validate new usernames for case-insensitive uniqueness and filter
> >>> with case-insensitive queries whenever the username is URL param.
>
> >> def view(request, username, child=None, ...):
> >>   username = username.lower()
>
> > The problem here is that that even if 'Charlie' and 'charlie' cannot
> > exist as usernames concurrently, 'Charlie' still can if he gets there
> > first.  So if that were the case and I had '/Charlie/' and passed
> > username.lower() to `widgets =
> > Widget.objects.get(owner__username=username), it is going to look for
> > charlie and won't find it.  At least I am pretty sure that happened to
> > me last evening when I was trying this, though it was pretty late...
>
> Ok, but cannot you store owner.username in lowercase from the start?
> At some point, Charlie wants to create an account (or however you've
> set it up), and while you have a proper name (Charlie Someone), the
> username is (invisibly) charlie. If you put in a line on the sign up
> form or similar stating that the username will be lower case, that
> shouldn't be confusing.  (Eg, wikimedia doesn't bother with case for
> user accounts on sign up and afterwards. In fact, it always
> capitalizes the first letter, even if the account would 'root', which
> is typically an all lower-case account.)
> For user friendliness, the username should be invisible to the user.
> The fact that you allow it in the URL is ok, but should otherwise
> still be invisible (You could even choose to redirect to an all lower-
> case URL).
> Though I fear I'm simply misunderstanding your problem (or missing
> some unknowns), so all my suggestions may be of not much use anyway!
>
>Evert
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 filter field

2008-03-28 Thread ameriblog

i have the following classes:

NEWS
headline
story
main-image (fk)
story-image (fk)

IMAGE
image
title
description
type

What I'd like to do is in the admin, when I go to add a news item that
in the main-image field it only gets entries from IMAGE where type =
1, and story-image where type = 2

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



Problems with generic.GenericForeignKey()

2008-03-28 Thread Josh

I've defined a model using a generic foreign key which is basically
exactly like the tagging example provided in the Django docs:

from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

class WordedItem(models.Model):
word = models.ForeignKey(FoodWord)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type',
'object_id')

def __unicode__(self):
return self.word

However, when I try to create a WordedItem object using the syntax
that I literally copied and pasted from the documentation it fails,
telling me that 'content_object' is not a field. Initially I tried
using get_or_create() which failed in the same way, but that appears
to be a known bug (#6805).

I've tried doing both this:

obj, created = WordedItem.objects.get_or_create(content_object=match,
word=word)

and this:
try:
obj = WordedItem.objects.get(content_object=match, word=word)
except WordedItem.DoesNotExist:
obj = WordedItem(content_object=match, word=word)
obj.save()
num_created += 1

Regardless, I end up with this:
TypeError: Cannot resolve keyword 'content_object' into field. Choices
are: id, word, content_type, object_id
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: usernames and case sensitivity

2008-03-28 Thread Evert Rol

>>> 2) Validate new usernames for case-insensitive uniqueness and filter
>>> with case-insensitive queries whenever the username is URL param.
>
>> def view(request, username, child=None, ...):
>>   username = username.lower()
>
> The problem here is that that even if 'Charlie' and 'charlie' cannot
> exist as usernames concurrently, 'Charlie' still can if he gets there
> first.  So if that were the case and I had '/Charlie/' and passed
> username.lower() to `widgets =
> Widget.objects.get(owner__username=username), it is going to look for
> charlie and won't find it.  At least I am pretty sure that happened to
> me last evening when I was trying this, though it was pretty late...

Ok, but cannot you store owner.username in lowercase from the start?  
At some point, Charlie wants to create an account (or however you've  
set it up), and while you have a proper name (Charlie Someone), the  
username is (invisibly) charlie. If you put in a line on the sign up  
form or similar stating that the username will be lower case, that  
shouldn't be confusing.  (Eg, wikimedia doesn't bother with case for  
user accounts on sign up and afterwards. In fact, it always  
capitalizes the first letter, even if the account would 'root', which  
is typically an all lower-case account.)
For user friendliness, the username should be invisible to the user.  
The fact that you allow it in the URL is ok, but should otherwise  
still be invisible (You could even choose to redirect to an all lower- 
case URL).
Though I fear I'm simply misunderstanding your problem (or missing  
some unknowns), so all my suggestions may be of not much use anyway!

   Evert


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



GeoDjango Lookup Woes

2008-03-28 Thread Hank Sims
 Hello:

 I'm trying to get up on GeoDjango, but I can't get lookups to work at
all. All geographic operations via the GeoManager -- filter, exclude, get --
fail with the same error: "Operations on two geometries with different
SRIDs."
 Strangely, though, I'm perfectly able to perform geometric operations
like "intersects," "touches," "contains," etc., outside the GeoManager. And
I'm pretty sure that the geometries in question don't have different SRIDs
because they come from the same model.
 Here's a typical shell session. The first error listed is an IPython
error -- I don't think that's it, because it fails the same way in the plain
Python shell, but I'll leave it here in case I'm missing something.
 Probably I'm doing something extremely boneheaded.  Any ideas?

 Thanks in advance,

 Hank Sims


In [1]: from gistest.watershed.models import River

In [2]: river0=River.objects.all()[0]

In [3]: river1=River.objects.all()[1]

In [4]: river0.line.touches(river1.line)
Out[4]: True

In [5]: river0.line.srid
Out[5]: 4326

In [6]: River.objects.filter(line__touches=river0.line)
Out[6]:
---
   Traceback (most recent call last)

/home/hanksims/gis_projects/gistest/ in ()

/var/lib/python-support/python2.5/IPython/Prompts.py in __call__(self, arg)
521
522 # and now call a possibly user-defined print mechanism
--> 523 manipulated_val = self.display(arg)
524
525 # user display hooks can change the variable to be
stored in

/var/lib/python-support/python2.5/IPython/Prompts.py in _display(self, arg)
545 """
546
--> 547 return self.shell.hooks.result_display(arg)
548
549 # Assign the default display method:

/var/lib/python-support/python2.5/IPython/hooks.py in __call__(self, *args,
**kw)
132 #print "prio",prio,"cmd",cmd #dbg
133 try:
--> 134 ret = cmd(*args, **kw)
135 return ret
136 except ipapi.TryNext, exc:

/var/lib/python-support/python2.5/IPython/hooks.py in result_display(self,
arg)
160
161 if self.rc.pprint:
--> 162 out = pformat(arg)
163 if '\n' in out:
164 # So that multi-line strings line up with the left
column of

/home/hanksims/gis_projects/gistest/pprint.py in pformat(self, object)
109 def pformat(self, object):
110 sio = _StringIO()
--> 111 self._format(object, sio, 0, 0, {}, 0)
112 return sio.getvalue()
113

/home/hanksims/gis_projects/gistest/pprint.py in _format(self, object,
stream, indent, allowance, context, level)
127 self._readable = False
128 return
--> 129 rep = self._repr(object, context, level - 1)
130 typ = _type(object)
131 sepLines = _len(rep) > (self._width - 1 - indent -
allowance)

/home/hanksims/gis_projects/gistest/pprint.py in _repr(self, object,
context, level)
193 def _repr(self, object, context, level):
194 repr, readable, recursive = self.format(object, context.copy
(),
--> 195 self._depth, level)
196 if not readable:
197 self._readable = False

/home/hanksims/gis_projects/gistest/pprint.py in format(self, object,
context, maxlevels, level)
205 and whether the object represents a recursive construct.
206 """
--> 207 return _safe_repr(object, context, maxlevels, level)
208
209

/home/hanksims/gis_projects/gistest/pprint.py in _safe_repr(object, context,
maxlevels, level)
290 return format % _commajoin(components), readable, recursive
291
--> 292 rep = repr(object)
293 return rep, (rep and not rep.startswith('<')), False
294

/usr/lib/python2.5/site-packages/django/db/models/query.py in __repr__(self)
106
107 def __repr__(self):
--> 108 return repr(self._get_data())
109
110 def __len__(self):

/usr/lib/python2.5/site-packages/django/db/models/query.py in
_get_data(self)
484 def _get_data(self):
485 if self._result_cache is None:
--> 486 self._result_cache = list(self.iterator())
487 return self._result_cache
488

/usr/lib/python2.5/site-packages/django/db/models/query.py in iterator(self)
187
188 cursor = connection.cursor()
--> 189 cursor.execute("SELECT " + (self._distinct and "DISTINCT "
or "") + ",".join(select) + sql, params)
190
191 fill_cache = self._select_related

/usr/lib/python2.5/site-packages/django/db/backends/util.py in execute(self,
sql, params)
 16 start = time()
 17 try:
---> 18 return self.cursor.execute(sql, params)
 19 finally:
 20 stop = time()

: Operation on two geometries with
different

Language code as part of URL

2008-03-28 Thread akaihola

I have a website with the following i18n requirements:

  Part of the site is monolingual with conventional URLs (e.g. /first/
example/).

  Another part of the site is multi-lingual content from the database
(flatpages-like). The language code should be accepted as a prefix in
the URL (e.g. /fi/second/example/).

  Links generated with {% url %} and reverse() should retain the
language prefix.

  Multi-lingual content is editable by authorized users.

  If a URL for a multi-lingual page is requested but the language code
is missing, a redirect is done according to the visitor's active
language (e.g. /second/example/ -> /fi/second/example/).

  When editing multi-lingual pages in any language, the editing user
interface stays always in one language chosen by the user (e.g. UI in
German when editing content in German, Swedish or English).

  If the requested multi-lingual page hasn't been translated to the
visitor's current language, a redirect is done to an existing
translation (according to browser preferences or site's default
language). But navigation and other links to other pages should point
back to URLs with the originally requested language.

  In the links for viewing pages in another language, the language
names should be in the language itself (see 
http://code.djangoproject.com/ticket/4030).


We have most of this functionality implemented and working, but the
code is rather involved. I'd like to create clean, re-usable modules
instead.

I'm currently out of ideas for how to design the language code URL
prefix handling as a drop-in module for use with any views which
utilize Django's standard i18n infrastructure. The troublesome point
is how to keep the language code prefix when using {% url %} /
reverse() without having to modify the views.

It's simple to use either middleware or a decorator to catch the
language code prefix, activate the correct language and strip the
language variable from being passed on to the view. I'm leaning on the
decorator side since part of the site doesn't use the prefix.

Currently I have a customized url() function for creating language-
prefixed urlpattern rules. It returns a subclassed RegexURLPattern or
RegexURLResolver which modifies the regex to catch the language
prefix. Views are wrapped in a decorator which consumes the prefix and
activates the correct language.

The problem is that since the language prefix catcher is now part of
the regex, I can't use  reverse() in the view or {% url %} in the
template without modifying views/templates to pass the current
language explicitly as a kwarg. That's goodbye to drop-in style re-
usability.

The way reverse() is implemented makes it difficult to inject the
value of get_language() back into the URL. I doubt that the required
changes will be accepted in Django.


Maybe there's an easy solution I just can't see now. Also, if anyone
has similar requirements as described above, it would be fruitful to
share thoughts and code. If we manage to create re-usable components
with no pre-existing counterparts, we'll of course publish and
maintain them.


I've collected some relevant links here: 
http://www.diigo.com/user/akaihola/django+language-in-url


-Antti
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: CacheMiddleware issue

2008-03-28 Thread bfrederi

Mike,

I'm not exactly sure how to do a read and get the file to be cached in
memory with the middleware. If you look at the links I posted to my
code, how would I cache the file within that view I posted? The
decorator you specified worked perfectly fine for disabling the cache
middleware for that view, but I actually want the file to be placed in
cache, and so far I haven't been able to get it to work.

Thanks, Brandon

On Mar 27, 5:45 pm, Mike Axiak <[EMAIL PROTECTED]> wrote:
> Brandon,
>
> It appears that the Cache Middleware does not read the content from
> the file before caching the response [1]. I'm not sure if this is a
> bug or not...though I'd probably lean towards it being a bug. (Do we
> not cache middleware to *always* evaluate a file object before caching
> the response?)
> Anyway, until that behavior gets changed, there's no reason you can't
> read (via .read()) your files to just send your content.
>
> If you expect Django to cache all your data, then you have to read the
> entire file into memory at *some* point. So I see two options:
>1. Read all the file contents into memory by calling
> file_object.read() before putting it into the HttpResponse object.
>2. Disabling cache middleware for that view. To do this, you can
> use the cache_control decorator [2]. E.g.:
>   @cache_control(max_age=0)
>   dev view(request): ...
>
> As it is your kind of giving Django conflicting requests since you're
> saying "Don't load the file into memory, load it lazily" while also
> saying "load the entire response into the cache".
>
> Regards,
> Mike
>
> 1:http://code.djangoproject.com/browser/django/trunk/django/middleware/...
> 2:http://www.djangoproject.com/documentation/cache/#controlling-cache-u...
>
> On Mar 27, 6:13 pm, bfrederi <[EMAIL PROTECTED]> wrote:
>
> > I appreciate the help Rajesh,
>
> > I haven't added any special settings for the cachemiddleware, I just
> > placed 'django.middleware.cache.CacheMiddleware' in my middleware
> > classes and that's it. As far as the low-level caching that I have
> > written into my code using the "from django.core.cache import cache",
> > all of that is working fine. It's just the middleware that is the
> > issue. As soon as I set the cache middleware in my middleware classes
> > setting, that's when I start having problems.
>
> > Here is an example view, where I try to open a file and it gives me a
> > "ValueError: I/O operation on closed file":
> > view (the line it actually executes is line 24):http://dpaste.com/41671/
> > function it calls (open_system_file):http://dpaste.com/41672/
>
> > Every part of that view works fine except for when I go to open that
> > file on line 24. And it works fine in my tests.py, I get the exact
> > data that I am supposed to from the file (the specific test is on line
> > 22):http://dpaste.com/41678/(open_system_fileon line 23 is defined
> > in system_methods on line 3)
>
> > And as far as stack traces go, I have my mod python error I just gave
> > you. Here is the apache2 error log (I blocked out my ip out of
> > paranoia):http://dpaste.com/41682/Idon't know what else to give you
> > that would help as far as problems within the stack. I'm not doing
> > anything db related, so if there is something else you need me to
> > post, please mention it by name specifically, in case there is
> > something I'm not thinking of.
>
> > Thanks for the help,
> > Brandon
>
> > On Mar 27, 4:01 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > > Hi Brandon,
>
> > > > I would paste in some code examples, but this project is several
> > > > hundred lines long, and there are several incidences where I open
> > > > files that is conflicting with the cache middleware.
>
> > > Not knowing how you have your cache setup (anonymous, all views, low-
> > > level), it's hard to tell what's causing this problem. You haven't
> > > included full stack traces either. So, I would suggest including at
> > > least this:
>
> > > - A snippet of a view that fails...include at least one file opening
> > > command.
> > > - Full stacktraces of the two errors you mentioned along with the
> > > snippets of your application code that the stack traces point to.
>
> > > -Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: usernames and case sensitivity

2008-03-28 Thread Jonathan Lukens

Hi Evert,

> > 2) Validate new usernames for case-insensitive uniqueness and filter
> > with case-insensitive queries whenever the username is URL param.

> def view(request, username, child=None, ...):
>username = username.lower()

The problem here is that that even if 'Charlie' and 'charlie' cannot
exist as usernames concurrently, 'Charlie' still can if he gets there
first.  So if that were the case and I had '/Charlie/' and passed
username.lower() to `widgets =
Widget.objects.get(owner__username=username), it is going to look for
charlie and won't find it.  At least I am pretty sure that happened to
me last evening when I was trying this, though it was pretty late...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



selenium versus django app

2008-03-28 Thread Robin Becker

I have a bunch of really weird errors coming from selenium built with the IDE 
when running in proper selenium. The page in question is an admin form coming 
from the python django framework


>  info: Executing: |type | ctyhocn | gathi |
>  debug: Command found, going to execute type
>  error: Unexpected Exception: A script from "http://127.0.0.1:8000"; was 
> denied UniversalFileRead privileges.

The field in question appears to be completely unexceptional; it's just an 
input 
text box

> 

following this message there appears to be a large amount of debug info related 
to some kind of string functions eg camelize, gsub etc etc.

Can anybody tell me what's going on?
-- 
Robin Becker

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



User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi,

I have created a User profile, pointing to the User table, as per the
documentation; how can I access the User fields from the UserProfile
so I can place that in the metadata class?

userprofile.models.py
http://dpaste.com/41831/

Thx!/Fco
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Cannot run Django on my local machine

2008-03-28 Thread martyn

OK, I've set Debug to FALSE, so I set it False and it's OK

let's have fun ! Django rocks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: User profile problem

2008-03-28 Thread Francisco Benavides

Hi Karen,

Thanks!

On Mar 27, 6:12 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Mar 27, 2008 at 6:45 PM, Francisco Benavides <
>
>
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I am in the process of adding more information to the user, managed
> > via django.contrib.auth.  I am getting an error in the admin
> > interface, when trying to add a profile to a given user. First time
> > the interface crashes, but the profile gets added, so the next time I
> > try to add the same profile, it naturally complains that it already
> > exists.
>
> > I have setup the AUTH_PROFILE_MODULE = 'txm.userprofile'
> > settings.py
> >http://dpaste.com/41684/
>
> > The profile is using user = models.ForeignKey(User, unique=True,
> > related_name='profile')
> > userprofile.model.py
> >http://dpaste.com/41685/
>
> > url.py
> >http://dpaste.com/41686/
>
> > The DEBUG data is in:
> >http://dpaste.com/41688/
>
> > Thx!/Fco
>
> Traceback shows the admin code is trying to log information about the new
> object created.  Ultimate error is in force_unicode and from the line above
> you can see force_unicode is being called on 'new_object', so that's
> probably an instance of your UserProfile model.  Checking its __unicode__
> method shows the problem:
>
> return '%i %s %s %s' % (self.user.first_name, self.user.last_name, self.
> materno, self.user.username)
>
> It's trying to format self.user.first_name (a string, I'd guess) as a %i
> (integer).  I think that %i should be %s.
>
> 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: Cannot run Django on my local machine

2008-03-28 Thread martyn

Are you looking over my shoulders ? :)
Yes I've set up a wiki this 1 hour ago.
I cleaned my cookies and now he wants a 404.html template

I've never seen this before
I'll try to specify my template dir
---
Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 272, in run
self.result = application(self.environ, self.start_response)

  File "/usr/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 614, in __call__
return self.application(environ, start_response)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 189, in __call__
response = self.get_response(request)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 103, in get_response
return callback(request, **param_dict)

  File "/usr/lib/python2.5/site-packages/django/views/defaults.py",
line 78, in page_not_found
t = loader.get_template(template_name) # You need to create a
404.html template.

  File "/usr/lib/python2.5/site-packages/django/template/loader.py",
line 79, in get_template
source, origin = find_template_source(template_name)

  File "/usr/lib/python2.5/site-packages/django/template/loader.py",
line 72, in find_template_source
raise TemplateDoesNotExist, name

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



Re: Cannot run Django on my local machine

2008-03-28 Thread Evert Rol

Looks like you have a cookie in the webbrowser on your desktop, for  
the localhost domain (have you been trying to run a wiki-page there?).  
Try clearing that cookie, then reload/restart the dev-server.


> I've already run Django on my Laptop (OpenSuse 10.3)  and it was so
> easy thanks to it's own dev server.
> On my desktop, I tried to run Djangon (openSuse 10.3 too).
> Django Install : OK
> import django : OK
> Startproject : OK
> runserver : OK
>
> When I open my favorite browser, the only thing I can see since 1 or 2
> hours is that :
>
> 
> Traceback (most recent call last):
>
>  File "/usr/lib/python2.5/site-packages/django/core/servers/
> basehttp.py", line 272, in run
>self.result = application(self.environ, self.start_response)
>
>  File "/usr/lib/python2.5/site-packages/django/core/servers/
> basehttp.py", line 614, in __call__
>return self.application(environ, start_response)
>
>  File "/usr/lib/python2.5/site-packages/django/core/handlers/
> wsgi.py", line 189, in __call__
>response = self.get_response(request)
>
>  File "/usr/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 59, in get_response
>response = middleware_method(request)
>
>  File "/usr/lib/python2.5/site-packages/django/contrib/sessions/
> middleware.py", line 72, in process_request
>request.session =
> SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME,
> None))
>
>  File "/usr/lib/python2.5/site-packages/django/core/handlers/
> wsgi.py", line 144, in _get_cookies
>self._cookies = http.parse_cookie(self.environ.get('HTTP_COOKIE',
> ''))
>
>  File "/usr/lib/python2.5/site-packages/django/http/__init__.py",
> line 150, in parse_cookie
>c.load(cookie)
>
>  File "/usr/lib/python2.5/Cookie.py", line 619, in load
>self.__ParseString(rawdata)
>
>  File "/usr/lib/python2.5/Cookie.py", line 650, in __ParseString
>self.__set(K, rval, cval)
>
>  File "/usr/lib/python2.5/Cookie.py", line 572, in __set
>M.set(key, real_value, coded_value)
>
>  File "/usr/lib/python2.5/Cookie.py", line 451, in set
>raise CookieError("Illegal key value: %s" % key)
>
> CookieError: Illegal key value: [EMAIL PROTECTED]
> ---
>
>
> Where the official doc tells me I have to see a pretty Welcome to
> Django in pleasant light blue.
> What's the matter ?
>
> Thanks a lot for you help, Django rocks !
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Cannot run Django on my local machine

2008-03-28 Thread martyn

Hi,

I've already run Django on my Laptop (OpenSuse 10.3)  and it was so
easy thanks to it's own dev server.
On my desktop, I tried to run Djangon (openSuse 10.3 too).
Django Install : OK
import django : OK
Startproject : OK
runserver : OK

When I open my favorite browser, the only thing I can see since 1 or 2
hours is that :


Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 272, in run
self.result = application(self.environ, self.start_response)

  File "/usr/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 614, in __call__
return self.application(environ, start_response)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 189, in __call__
response = self.get_response(request)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 59, in get_response
response = middleware_method(request)

  File "/usr/lib/python2.5/site-packages/django/contrib/sessions/
middleware.py", line 72, in process_request
request.session =
SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME,
None))

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 144, in _get_cookies
self._cookies = http.parse_cookie(self.environ.get('HTTP_COOKIE',
''))

  File "/usr/lib/python2.5/site-packages/django/http/__init__.py",
line 150, in parse_cookie
c.load(cookie)

  File "/usr/lib/python2.5/Cookie.py", line 619, in load
self.__ParseString(rawdata)

  File "/usr/lib/python2.5/Cookie.py", line 650, in __ParseString
self.__set(K, rval, cval)

  File "/usr/lib/python2.5/Cookie.py", line 572, in __set
M.set(key, real_value, coded_value)

  File "/usr/lib/python2.5/Cookie.py", line 451, in set
raise CookieError("Illegal key value: %s" % key)

CookieError: Illegal key value: [EMAIL PROTECTED]
---


Where the official doc tells me I have to see a pretty Welcome to
Django in pleasant light blue.
What's the matter ?

Thanks a lot for you help, Django rocks !
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: usernames and case sensitivity

2008-03-28 Thread Evert Rol

> I am writing an application that involves a number of nested parent-
> child relationships, where users create objects that each in turn have
> sub-objects.  So far the URL structure looks like this:
>
> example.com/username/
> example.com/username/child1/, example.com/username/child2/
> example.com/username/child2/grandchild1,  example.com/username/child2/
> grandchild2
>
> As you could guess, keyworded URL parameters are used to filter
> through each level of this structure.  Usernames in Django are case-
> sensitive; I think it could be a real problem to have case sensitive
> urls, something like example.com/Bob/widget1 and example.com/bob/
> widget1, leading to user confusion.  I can think of two ways to
> circumvent this:
> 1) Have an uneditable SlugField in a UserProfile that is saved when
> the account is created that would save the username as
> username.lower();
> 2) Validate new usernames for case-insensitive uniqueness and filter
> with case-insensitive queries whenever the username is URL param.
>
> My hope is that there is a magically third option (I wouldn't consider
> a patch very magical), but if not, which of these options is better?
> My guess is the first.

I'd opt for the second; there won't be no need for an extra field in  
eg the admin view (potentially confusing other admins).
Besides, unless I understand your problem incorrectly, it would be  
easy to transform the username to lower case and use that throughout  
your view (and models). You catch it once in your args/kwargs in the  
first line (definition) of your view, than transform it:
def view(request, username, child=None, ...):
   username = username.lower()
   

Perhaps there is a way to even do this at the URL level (in the  
regex?), but I wouldn't know.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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.newforms and AJAX

2008-03-28 Thread Ariel Mauricio Nunez Gomez
David,

Good luck on what you are trying to achieve.

Jump in, I think your list is just enough for a proof of concept.

We are waiting eagerly to try what you come up with.

Dive in.

Regards,
Ariel

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Weird POST data issues

2008-03-28 Thread homebrew79

A friend of mine that has been helping me look at this just showed me
ticket 6256: http://code.djangoproject.com/ticket/6256.  So I guess no
need to reply.  Thanks!

On Mar 28, 11:02 am, homebrew79 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm having a really strange problem with the django admin, and POST
> data.
> This is with trunk.  On rev 7364.  But this has been happening for a
> long time on older builds.
>
> There is an edit_inline that has several hundred associated records.
>
> When saving, it frequently fails validation an gives the "Please
> correct the error below" message.
> I'll use firebug to search on the term "error" and it will show me the
> field that caused the error.
> Typically the field is filled out as should be, or in the case of a
> select option, it will be the '', no selection.
> What's really crazy is that this happens if you just load the page and
> save without making any changes.
> It doesn't happen every time, and the field that it errs on is totally
> random.
>
> I finally got so frustrated that I put some logging in the
> change_stage view of the admin to write the post data out to a file.
> What I found is that the fields that it is erring on are getting a '\r
> \n' prepended to the data.
>
> So for example the request.POST data that is coming into the view has
> a value that looks like this:
> u'style.41.color_cat': [u'\r\n11']
>
> But the request.raw_post_data from the same place looks like this:
> Content-Disposition: form-data; name="style.41.color_cat"^M
> ^M
> 11^M
>
> So it looks to me like django is inserting the \r\n somewhere between
> when the POST data leaves the browser and when it gets to the view as
> request.POST.
>
> I have disabled all middleware but
> 'django.contrib.sessions.middleware.SessionMiddleware' and
> 'django.contrib.auth.middleware.AuthenticationMiddleware' because I
> belive those are needed to use the admin.
>
> The context processers in use are just the default context processors.
>
> This is happening with mod_python and the django development server.
> This is happening with Firefox 2 and 3b4.  Also happening with IE 7.
>
> Any ideas or advice on how to debug this would be really appreciated.
> It is driving me nuts and I am at the point of obsession.
>
> Many Thanks!
>
> -Brian Morgan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Weird POST data issues

2008-03-28 Thread homebrew79

Hi,

I'm having a really strange problem with the django admin, and POST
data.
This is with trunk.  On rev 7364.  But this has been happening for a
long time on older builds.

There is an edit_inline that has several hundred associated records.

When saving, it frequently fails validation an gives the "Please
correct the error below" message.
I'll use firebug to search on the term "error" and it will show me the
field that caused the error.
Typically the field is filled out as should be, or in the case of a
select option, it will be the '', no selection.
What's really crazy is that this happens if you just load the page and
save without making any changes.
It doesn't happen every time, and the field that it errs on is totally
random.

I finally got so frustrated that I put some logging in the
change_stage view of the admin to write the post data out to a file.
What I found is that the fields that it is erring on are getting a '\r
\n' prepended to the data.

So for example the request.POST data that is coming into the view has
a value that looks like this:
u'style.41.color_cat': [u'\r\n11']

But the request.raw_post_data from the same place looks like this:
Content-Disposition: form-data; name="style.41.color_cat"^M
^M
11^M

So it looks to me like django is inserting the \r\n somewhere between
when the POST data leaves the browser and when it gets to the view as
request.POST.

I have disabled all middleware but
'django.contrib.sessions.middleware.SessionMiddleware' and
'django.contrib.auth.middleware.AuthenticationMiddleware' because I
belive those are needed to use the admin.

The context processers in use are just the default context processors.

This is happening with mod_python and the django development server.
This is happening with Firefox 2 and 3b4.  Also happening with IE 7.

Any ideas or advice on how to debug this would be really appreciated.
It is driving me nuts and I am at the point of obsession.

Many Thanks!

-Brian Morgan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



usernames and case sensitivity

2008-03-28 Thread Jonathan Lukens

I am writing an application that involves a number of nested parent-
child relationships, where users create objects that each in turn have
sub-objects.  So far the URL structure looks like this:

example.com/username/
example.com/username/child1/, example.com/username/child2/
example.com/username/child2/grandchild1,  example.com/username/child2/
grandchild2

As you could guess, keyworded URL parameters are used to filter
through each level of this structure.  Usernames in Django are case-
sensitive; I think it could be a real problem to have case sensitive
urls, something like example.com/Bob/widget1 and example.com/bob/
widget1, leading to user confusion.  I can think of two ways to
circumvent this:
1) Have an uneditable SlugField in a UserProfile that is saved when
the account is created that would save the username as
username.lower();
2) Validate new usernames for case-insensitive uniqueness and filter
with case-insensitive queries whenever the username is URL param.

My hope is that there is a magically third option (I wouldn't consider
a patch very magical), but if not, which of these options is better?
My guess is the first.

Thanks,
Jonathan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: javascript in django

2008-03-28 Thread [EMAIL PROTECTED]

What David said. In jquery it would be $("#field_id"). That's not a
django thing at all.
You can always view source to see what the field id is, but by default
django appends id_ to the field name in the model. So if it was called
"color" in your model, the field name would be "id_foo"
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Anybody using UUID fields yet?

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 11:54 AM, jeffself <[EMAIL PROTECTED]> wrote:

>
> I'm starting to see a lot of benefit in using UUID as a primary key
> rather than autogenerated id numbers.  Since Django doesn't natively
> support the field, I guess you would have to use a CharField with a
> max_length of 32.  Unfortunately, this wouldn't produce a native UUID
> datatype which Oracle and PostgreSQL 8.3 support.
>
> In addition, you would have to write some python code to generate the
> UUID value that would get placed in this field.
>
> In order to get a datatype created for Django, I believe it would
> first have to be supported in the database engine that's being used,
> correct?  So I would need to make sure psycopg2 supported it before I
> could try and implement it in Django.  Is this correct?
>

You might want to check out: http://code.djangoproject.com/ticket/4682

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: newforms-admin: raw_id_fields works for admin area but not my site

2008-03-28 Thread hotani

Thanks Karen. Looks like that is my problem: using generic views with
newforms-admin. I'll need to either hand-roll those problematic forms
or wait for the newforms-generic to become available. I'll have to do
*something* - one of the foreign keys references a table with 1M rows!
That's one helluva drop-down.

On Mar 21, 8:29 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Mar 20, 2008 at 12:12 PM, hotani <[EMAIL PROTECTED]> wrote:
>
> > My issue is similar to this one from October:
>
> >http://groups.google.com/group/django-users/browse_thread/thread/a0a0...
> > But from what I can tell, those fixes have been applied. I just
> > downloaded the newforms-admin branch yesterday.
>
> Yes, those fixes are in.  I initially reported that problem, the fixes were
> made very quickly, and I've been running with newforms-admin pretty much by
> default since then.
>
>
>
> > I have a form with an fk table including thousands of records which
> > takes a long time to load as a drop-down. Pre-newforms-admin, I put
> > "raw_id_admin=True" in the model definition and it would display a
> > text field in both places. Now it only seems to work on the admin
> > side.
>
> > here's a chopped version of the model definition:
> > ---
> > class Issue(models.Model):
> >    
> >    hardware_item      = models.ForeignKey(Hardware, blank=True,
> > null=True)
>
> > class IssueAdmin(admin.ModelAdmin):
> >    raw_id_fields = ('hardware_item', 'submitted_by', 'assigned_to')
>
> > admin.site.register(Issue, IssueAdmin)
> > ---
>
> > Note that this is a generic 'update_object' view.
>
> Generic views haven't been migrated to newforms yet 
> (seehttp://code.djangoproject.com/ticket/3639).  When that happens I think
> you'll be able to get the 'raw id' functionality by properly specifying the
> field/widget for the ModelForm to be used for the view.  I don't know if
> you'll be able to re-use the admin's special widget for ForeignKeys listed
> in raw_id_fields or not.  I don't use generic views myself so I'm guessing
> based on a cursory look at the docs -- I think there is still some work to
> be done here to allow people relying on 'raw id' behavior outside of admin
> to migrate, at a minimum some doc.
>
> > Also, sometimes I need 'raw_id_fields' for models I do not want to see
> > in the admin area. With this decoupled from the models definition will
> > that still be possible?
>
> I don't believe it will be as automatic as it was in the old system, but I
> believe it is possible via the right choice of field/widgets for the fields
> you want to treat as 'raw'.  The new system actually gives you more
> flexibility than the old, where you were locked into having to specify the
> pk value for your raw ForeignKey.  With newforms and ModelForm you have a
> lot more flexibility with how things are handled.  I think you could write a
> custom form field that, for example, used a textual representation instead
> of pk value to look up your target ForeignKey object.  I know I'm
> hand-waving a bit here since I haven't had a need to do this myself, but my
> impression is it's pretty easily doable and could be used to make your
> necessarily 'raw' fields much more user-friendly than they were before
> newforms.
>
> 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
-~--~~~~--~~--~--~---



Anybody using UUID fields yet?

2008-03-28 Thread jeffself

I'm starting to see a lot of benefit in using UUID as a primary key
rather than autogenerated id numbers.  Since Django doesn't natively
support the field, I guess you would have to use a CharField with a
max_length of 32.  Unfortunately, this wouldn't produce a native UUID
datatype which Oracle and PostgreSQL 8.3 support.

In addition, you would have to write some python code to generate the
UUID value that would get placed in this field.

In order to get a datatype created for Django, I believe it would
first have to be supported in the database engine that's being used,
correct?  So I would need to make sure psycopg2 supported it before I
could try and implement it in Django.  Is this correct?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with Apache + mod_python

2008-03-28 Thread Slayer_X

Hi everyone!

> Michael Wieher wrote:
> Get rid of your installation of django and re-install it.
---
done

>To test it, go to any unrelated location in your file-system  (ie: cd /usr
>or cd /var or something, start up python and import django.)
---
I can import django without errors

>Also, be sure you don't have duplicate copies of python 2.4 installed on
>your system.
---
Just 1 copy of python (python-2.4.3-19.el5)

>Evert Rol wrote:
>You shouldn't need to add '/usr/lib/python2.4/site-packages/' to
>PythonPath: django is already in site-packages, and python (assuming
>that's python2.4 in /usr/bin) will automatically search there.
>You should, however, add the path to the 'ripsol' project there (or
>actually the path just above that); otherwise Python cannot pick up
>the ripsol.settings file (or any of your python files within ripsol).
>And I guess it should find something to test your setup when accessing
>the URL.
---
Done! and the python binary is in the correct location

>Karen Tracey:
>I know nothing of CentOS but from googling a bit it sounds like it
>is a distrib possibly based off of SELinux (security-enhanced).  Is django
>actually installed under site-packages or is it just linked there?  If it's
>only linked, and the link is to some user-owned space, then probably the
>issue is that apache doesn't have the access rights to read that space.
--
U can disable SElinux using system-config-security or modifying the /
etc/sysconfig/selinux file directly, after this u need to reboot :)

If u want to be sure about SElinux status run:
/usr/bin/sestatus -v

Obviusly I disabled SELinux on my system

> Graham Dumpleton wrote:
>Since mod_wsgi shares many of the same issues as mod_python, you may
>want to also read the issues documents for mod_wsgi:

>  http://code.google.com/p/modwsgi/wiki/ApplicationIssues
--
Thanks for the link, Im reading and watching probably issues, news
coming soon ;)

On Mar 27, 6:19 pm, Floyd Arguello <[EMAIL PROTECTED]> wrote:
> Try this:
> PythonPath "['/var/www/html/ripsol'] + sys.path"
---
Tried but the same problem persist

I keep trying, no surrender! thanks to all your responses

César
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 field problem

2008-03-28 Thread Evert Rol

> thanks for reply, but i don't quite understand :( sorry i'm newbie  
> here
> First my models.py is like this
> class DigitalSignage(models.Model):
> DS_ID = integerField()
>
> class tableSlot(models.Model):
> ds_id =models.ManyToManyField(DigitalSignage)
>
> class columnSetup(models.Model):
> tableList  =models.ManyToManyField(tableSlot)
>
> so in my views.py like this:


>
> >ds = DigitalSignage.objects.get(pk=ds_id)

Here, you are retrieving a single object, namely a DigitalSignage (as  
defined in your model).
The _set identifier will work for objects, as below.


> >tableslots = ds.tableslot_set.all()

Here, you're retrieving all tableslots, which results in a QuerySet.  
It is a QuerySet of your tableSlot model, but it's not the model  
itself. A QuerySet allows filtering, but you cannot directly retrieve  
any of the relations defined in your models, since it's not the model  
itself.
Have another look at 
http://www.djangoproject.com/documentation/db-api/#many-to-many-relationships
You'll see that the _set is used for an object, not a  
QuerySet.


>
> >columnsetups = tableslots.columnsetup_set.all()
>
> so now if i change upwards... that's mean my models.py should be  
> like this:
> class DigitalSignage(models.Model):
> DS_ID = integerField()
>
> class columnSetup(models.Model):
> field1 = models.charField()
>
> class tableSlot(models.Model):
> ds_id =models.ManyToManyField(DigitalSignage)
> columnList  =models.ManyToManyField(columnSetup)

Changing your models has nothing to do with it.

Therefore, continuing with the model defintion you originally had (top  
of this mail), you should probably access things from the other side:
ds = DigitalSignage.objects.get(pk=ds_id)
tableslots = tableSlot.objects.filter(ds_id=ds)   # note: not using  
ds.id. See also note below

Also, have another good luck at 
http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships


Lastly, I can suggest some renaming, to stay with the usage in Python  
and Django. Has nothing to do with the problem, so consider it free  
(and possibly unwanted) advice:
- model names start with a Capital (TableSlot instead of tableSlot);  
as you do for DigitalSignage.
- m2m relations are often named as the plural of the relation they  
refer to. So ds_id should become something like digital_signages (or  
signages, if you consider that too long). In particular, the ds_id  
naming is rather badly chosen, since it should reflect an object, not  
the database id of that object (don't think database-level, think  
object-level). It is indeed an id (integer) in the database, but if  
you would retrieve if from your model (through a_table_slot.ds_id),  
it'll show up as a DigitalSignage object, not a number.

Good luck.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problems with Apache + mod_python

2008-03-28 Thread Slayer_X

Hi everyone!

> Michael Wieher wrote:
> Get rid of your installation of django and re-install it.
---
done

>To test it, go to any unrelated location in your file-system  (ie: cd /usr
>or cd /var or something, start up python and import django.)
---
I can import django without errors

>Also, be sure you don't have duplicate copies of python 2.4 installed on
>your system.
---
Just 1 copy of python (python-2.4.3-19.el5)

>Evert Rol wrote:
>You shouldn't need to add '/usr/lib/python2.4/site-packages/' to
>PythonPath: django is already in site-packages, and python (assuming
>that's python2.4 in /usr/bin) will automatically search there.
>You should, however, add the path to the 'ripsol' project there (or
>actually the path just above that); otherwise Python cannot pick up
>the ripsol.settings file (or any of your python files within ripsol).
>And I guess it should find something to test your setup when accessing
>the URL.
---
Done! and the python binary is in the correct location

>Karen Tracey:
>I know nothing of CentOS but from googling a bit it sounds like it
>is a distrib possibly based off of SELinux (security-enhanced).  Is django
>actually installed under site-packages or is it just linked there?  If it's
>only linked, and the link is to some user-owned space, then probably the
>issue is that apache doesn't have the access rights to read that space.
--
U can disable SElinux using system-config-security or modifying the /
etc/sysconfig/selinux file directly, after this u need to reboot :)

If u want to be sure about SElinux status run:
/usr/bin/sestatus -v

Obviusly I disabled SELinux on my system

> Graham Dumpleton wrote:
>Since mod_wsgi shares many of the same issues as mod_python, you may
>want to also read the issues documents for mod_wsgi:

>  http://code.google.com/p/modwsgi/wiki/ApplicationIssues
--
Thanks for the link, Im reading and watching probably issues, news
coming soon ;)

On Mar 27, 6:19 pm, Floyd Arguello <[EMAIL PROTECTED]> wrote:
> Try this:
> PythonPath "['/var/www/html/ripsol'] + sys.path"
---
Tried but the same problem persist

I keep trying, no surrender! thanks to all your responses

César
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: javascript in django

2008-03-28 Thread David Marquis
document.getElementById("field_id")
OR
if you use Prototype library : $("field_id")

--
David

On 28-Mar-08, at 10:49 AM, didia lim wrote:

> hi baxter, how can JS get the texfield by ID.. is there any  
> documentation or example? sorry i'm still new in django
>
> - Original Message 
> From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> To: Django users 
> Sent: Friday, March 28, 2008 7:45:57 AM
> Subject: Re: javascript in django
>
>
> A custom widget would work, but you don't need to do that. Just have
> your JS get the textfield by ID. Done.
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  
> Try it now.
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Do I need two classes that are identical because I want to use two database tables?

2008-03-28 Thread jeffself

I've created a class called ElectionResults that contains the
following fields:

election = models.ForeignKey(Election)
precinct = models.ForeignKey(Precinct)
office = models.ForeignKey(Office)
candidate = models.ForeignKey(Candidate)
total_votes = models.PositiveIntegerField(default=0)

Here's the problem.  I will need to have a current Results table
generated for several reasons. One is performance.  Keeping Current
Election Results in their own table away from past election results
will result in quicker lookups.  The other reason is that the current
election results table will need to be dropped and recreated on a
timely basis.  The reason is the data will be imported from a CSV file
that gets updated frequently.

So should I just create two classes that are identical but name one
CurrentElectionResults and the other PastElectionResults?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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   >