Django editor for Debian

2009-12-15 Thread NMarcu
Hello all,

   Can you tell me a good Django editor for Debian? Something more
pretty then default text editor. Something to can edit templates also.
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: FK to an Abstract class? Alternative?

2009-12-15 Thread Maksymus007
On Wed, Dec 16, 2009 at 6:21 AM, Victor Hooi  wrote:
> heya,
>
> We have a small project where we need to store a series of exam
> results for students.
>
> Some exams receive a grade out of 100, others are simply a pass/fail,
> while others are given a one-word grade (e.g. pass, fail, credit,
> distinction).
>
> In a sense, they all do map to a 0 to 100 scale (e.g. for the pass/
> fail, you can make it 0 and 100, while the pass/fail/credit/
> distinction can be mapped to other numbers. However apparently the
> users don't want to store it that way, and want them each
> differentiated. Also, I suppose you'd need to store somehow which type
> of mark it was anyway, for when you need to represent it to the user.
>
> I was thinking of setting up abstract models to handle this, something
> like:
>
>    class AssessmentTask(models.Model):
>        name = models.CharField(max_length=20)
>        paper = models.FileField(upload_to='forms/examination')
>        date = models.DateField()
>
>        class Meta:
>            abstract = True
>
>    class GradedAssessmentTask(AssessmentTask):
>        mark = models.CharField(max_length=1,
> choices=ASSESSMENT_GRADE_CHOICES)
>
>    class PassFailAssessmentTask(AssessmentTask):
>        mark = models.BooleanField()
>
>    class NumericalMarkAssessmentTask(AssessmentTask):
>        mark = models.PositiveIntegerField()
>
>    class ExaminationRecord(models.Model):
>        assessment = models.OneToOneField(AssessmentTask)
>
> You could then create overridden methods to handle pass/fail checking
> for each of those. The ExaminationRecord object contains a list of
> assessments, each of which is of type AssessmentTask.
>
> However, Django complains with:
>
>    AssertionError: OneToOneField cannot define a relation with
> abstract class AssessmentTask
>
> So obviously that's not the right way to handle this. What is the
> right way within Django to handle something like this?
>
> Cheers,
> Victor
>

store results as 0-100 integer and use second integer field to
indicate what type of mark it is - then simply convert it - you can
use method of your model

--

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




Re: Can a django form render a javascript (interactive) calendar?

2009-12-15 Thread Kenneth Gonsalves
On Wednesday 16 Dec 2009 12:32:21 pm Kenneth Gonsalves wrote:
> On Wednesday 16 Dec 2009 12:23:48 pm codingJoe wrote:
> > Is it possible for django to render a javascript calendar?  How so?
> > If this is possible, a code snippet would be very helpful.
> > 
> 
> same as in normal html - you will have to manually render the form and
>  attach  the javascript calendar with the correct id. Here is a sample:
> 
> http://bitbucket.org/lawgon/ilugc/src/tip/templates/web/addevent.html
> 

caution - I know nothing of javascript - but it works for me.
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

--

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




Re: Can a django form render a javascript (interactive) calendar?

2009-12-15 Thread Kenneth Gonsalves
On Wednesday 16 Dec 2009 12:23:48 pm codingJoe wrote:
> Is it possible for django to render a javascript calendar?  How so?
> If this is possible, a code snippet would be very helpful.
> 

same as in normal html - you will have to manually render the form and attach 
the javascript calendar with the correct id. Here is a sample:

http://bitbucket.org/lawgon/ilugc/src/tip/templates/web/addevent.html
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

--

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




Can a django form render a javascript (interactive) calendar?

2009-12-15 Thread codingJoe
I'm specifically using Google AppEngine, but this seems like this is
more a django question.

I need an my template to render an interactive Table that someone can
click a date, or "Today".  The typical javascript calendar will do.  I
can do this without django, but I would like my form to automatically
render this.  Below is the current code I am using.

When the template is rendered a simple textbox is provided, with no
formatting guidance.  I would like the javascript calendar to assist
in picking the date and formatting the field.

Is it possible for django to render a javascript calendar?  How so?
If this is possible, a code snippet would be very helpful.

Note:  The only relevant documentation I can find is here:
http://docs.djangoproject.com/en/dev/ref/models/fields/#datefield
Which states:  The admin represents this as an 
with a JavaScript calendar, and a shortcut for "Today". The JavaScript
calendar will always start the week on a Sunday.

But, I don't see any javascript calendar, nor do I know how to
integrate one.

Thanks for any assistance or advice!

Joe


<-begin code>

# for illustrative purposes
class Registration(db.Model):
  courseName = db.StringProperty(required=True)
  startDate = db.DateProperty(required=True)


class RegistrationForm(djangoforms.ModelForm):
  class Meta:
model = Registration

... Template...

 
  {{ RegistrationForm }} 
 
  

< end 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: can any on help me how to create a sample model project.

2009-12-15 Thread chiranjeevi muttoju
hi as i said that i had installed the mysql in other machine. when i
installing the python-mysql connector using the command
python setup.py build

it giving the fallowing error:
[r...@scci01 MySQL-python-1.2.3c1]# python setup.py build
sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in 
metadata, options = get_config()
  File "/root/chiru/MySQL-python-1.2.3c1/setup_posix.py", line 43, in
get_config
libs = mysql_config("libs_r")
  File "/root/chiru/MySQL-python-1.2.3c1/setup_posix.py", line 24, in
mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found


what is the modifications to setup_posix.py file, plz help me..
thanku.

On Tue, Dec 15, 2009 at 8:31 PM, Simon Brunning wrote:

> 2009/12/15 chiranjeevi muttoju :
> > ImportError: No module named setuptools
>
> Seems pretty self-evident to me. Try installing setuptools first.
>
> --
> Cheers,
> Simon B.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>


-- 
▒▒�...@g@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




FK to an Abstract class? Alternative?

2009-12-15 Thread Victor Hooi
heya,

We have a small project where we need to store a series of exam
results for students.

Some exams receive a grade out of 100, others are simply a pass/fail,
while others are given a one-word grade (e.g. pass, fail, credit,
distinction).

In a sense, they all do map to a 0 to 100 scale (e.g. for the pass/
fail, you can make it 0 and 100, while the pass/fail/credit/
distinction can be mapped to other numbers. However apparently the
users don't want to store it that way, and want them each
differentiated. Also, I suppose you'd need to store somehow which type
of mark it was anyway, for when you need to represent it to the user.

I was thinking of setting up abstract models to handle this, something
like:

class AssessmentTask(models.Model):
name = models.CharField(max_length=20)
paper = models.FileField(upload_to='forms/examination')
date = models.DateField()

class Meta:
abstract = True

class GradedAssessmentTask(AssessmentTask):
mark = models.CharField(max_length=1,
choices=ASSESSMENT_GRADE_CHOICES)

class PassFailAssessmentTask(AssessmentTask):
mark = models.BooleanField()

class NumericalMarkAssessmentTask(AssessmentTask):
mark = models.PositiveIntegerField()

class ExaminationRecord(models.Model):
assessment = models.OneToOneField(AssessmentTask)

You could then create overridden methods to handle pass/fail checking
for each of those. The ExaminationRecord object contains a list of
assessments, each of which is of type AssessmentTask.

However, Django complains with:

AssertionError: OneToOneField cannot define a relation with
abstract class AssessmentTask

So obviously that's not the right way to handle this. What is the
right way within Django to handle something like this?

Cheers,
Victor

--

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




Re: Filter (AND excluding empty values)

2009-12-15 Thread creecode
Hello Osiaq,

On Dec 15, 8:40 pm, Osiaq  wrote:

> Is there anyway to force filter to exclude null values from the
> statement?
> Logic: "if 'city' is null(or 0), exclude it from search term" ?

Did you try the exclude method < 
http://docs.djangoproject.com/en/dev/ref/models/querysets/#exclude-kwargs
>?  I haven't been following this closely, just throwing it out there.

Toodle-loo
creecode

--

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




Re: Filter (AND excluding empty values)

2009-12-15 Thread Phui Hock
I see. I think this is probably you are looking for:

params = ['city', 'category', 'status']
kwargs = dict([(p, request.GET.get(p)) for p in params if
request.GET.get(p)]) # use just the request params whose value is not
empty string
Property.objects.filter(**kwargs)

On Dec 16, 12:40 pm, Osiaq  wrote:
> Well, still the same:
>
> VIEW:
>
> def search(request):
>                 t=request.GET['city']
>                 c=request.GET['category']
>                 s=request.GET['status']
>                 properties 
> =Property.objects.filter(Q(city__isnull=True)|Q(city=t),
> Q(category__isnull=True) | Q(category=c), Q(status__isnull=True) | Q
> (status=s))
>                 return render_to_response ('website/search_results.html',
> {'property': properties, 'city': t})
>
> RESULTS:
> Returning url:http://127.0.0.1:8000/search/?city=1=1=1
> works perfect
> Returning url:http://127.0.0.1:8000/search/?city==1=
> doesnt't work at all (removed 1 from city and status)
>
> Is there anyway to force filter to exclude null values from the
> statement?
> Logic: "if 'city' is null(or 0), exclude it from search term" ?

--

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




Re: csrf error on login and admin

2009-12-15 Thread Paddy Joy
Try 'django.middleware.csrf.CsrfMiddleware' instead of
'django.contrib.csrf.middleware.CsrfMiddleware'

Paddy

On Dec 15, 4:28 pm, Kenneth Gonsalves  wrote:
> On Tuesday 15 Dec 2009 9:07:38 am Kenneth Gonsalves wrote:
>
> > > I tried another browser - same problem of erratic behaviour, at times
> > >  login  works, at other times it does not - forms on site work, but forms
> > >  in admin do not work. Then I thought maybe my webserver was giving the
> > >  problem - so I used the developement server. Login at admin does not
> > > work. 'Cookie not set'. Login to the site works, and then I can bypass
> > > the admin login screen - but forms in admin again give 'CSRF token
> > > missing or incorrect'.
>
> > problem solved - one of the other contributors to the project had
> >  overridden a  whole lot of admin templates which were causing the
> >  confusion.
>
> back to the drawing board! Still not working properly. I tried with konqueror.
> It worked for one site. The moment I went to another site, the csrf problem
> started. With firefox it works at times and doesnt at other times. This is the
> situation with all the developers in the lab - and they have a variety of
> distros, browsers and platforms. We have decided to revert to a pre csrf
> version until we can spare the time to sort things out.
> --
> regards
> Kenneth Gonsalves
> Senior Project Officer
> NRC-FOSShttp://nrcfosshelpline.in/web/

--

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




Re: Filter (AND excluding empty values)

2009-12-15 Thread Osiaq
Well, still the same:

VIEW:

def search(request):
t=request.GET['city']
c=request.GET['category']
s=request.GET['status']
properties 
=Property.objects.filter(Q(city__isnull=True)|Q(city=t),
Q(category__isnull=True) | Q(category=c), Q(status__isnull=True) | Q
(status=s))
return render_to_response ('website/search_results.html',
{'property': properties, 'city': t})

RESULTS:
Returning url: http://127.0.0.1:8000/search/?city=1=1=1
works perfect
Returning url: http://127.0.0.1:8000/search/?city==1=
doesnt't work at all (removed 1 from city and status)

Is there anyway to force filter to exclude null values from the
statement?
Logic: "if 'city' is null(or 0), exclude it from search term" ?

--

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




Re: Multiple icontains using OR - Is it possible?

2009-12-15 Thread HARRY POTTRER
you're going to need the Q object, it seems.

from django.db.models import Q
MyModel.objects.filter(Q(summary__icontains=q) | Q
(title__icontains=q))

On Dec 15, 10:32 pm, tm  wrote:
> Hello Django Users,
>
> I'm trying to use icontains to check 2 fields in the same table for a
> keyword entered into a search.
>
> ex I've tried:
>
> queryset = MyModel.objects.filter(summary__icontains=q).filter
> (title__icontains=q)
>
> and
>
> queryset = MyModel.objects.filter(summary__icontains=q,
> title__icontains=q)
>
> Neither work, although judging by the docs the second one shouldn't in
> this case.  Has anyone successfully searched a MySQL DB using
> icontains on 2 filelds in the same model?  Any help greatly
> appreciated :)
>
> T

--

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




Trying to limit a ForeignKey in the admin site, but formfield_for_foreignkey isn't working

2009-12-15 Thread Eric Chamberlain

How do I get the default_provider field to only list providers that belong to 
this Partner?


class Partner(Model):
id = UUIDField(primary_key=True)
...
default_provider = ForeignKey('Provider', null=True, blank=True)
providers = ManyToManyField('Provider', related_name='provider_partners', 
blank=True, null=True)


class PartnerAdmin(ModelAdmin):
list_display = ('name', 'type', 'url')
list_filter = ('type',)
exclude = ['calls','providers' ]
raw_id_fields = ('admins',)

inlines = [ PartnerRegistrationInline, ]

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "default_provider":
kwargs["queryset"] = self.model.providers.all()
return db_field.formfield(**kwargs)
return super(PartnerAdmin, self).formfield_for_foreignkey(db_field, 
request, **kwargs)



The code above generates an AttributeError:

'ReverseManyRelatedObjectsDescriptor' object has no attribute 'all'

--
Eric Chamberlain






--

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




Re: Pydev + Django + Ubuntu 9.10

2009-12-15 Thread paul.dorman
I can confirm that removing the Python interpreter and re-adding
solved this issue for me. I'm using Karmic packages for Eclipse and
for Django.

On Dec 8, 8:32 am, Brian McKeever  wrote:
> I'm using django from the repositories.
> Installed this 
> way:http://docs.djangoproject.com/en/dev/topics/install/#installing-devel...
>
> I configured my interpretor in eclipse by doing this:
> "Now, on to re-configure the pydev interpreter to add those new
> paths... I'm kind of lazy, so, usually I just remove the interpreter
> and add it again, instead of figuring out just the new paths (I also
> thinks it's safer, as it gets all the folders it finds in the
> pythonpath automatically). "
>
> From:http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-djan...
>
> On Dec 7, 8:17 am, turkan  wrote:
>
>
>
> > Hello Brian.
>
> > Strange, I am also using Eclipse downloaded from eclipse.org. Did you
> > add any special folders to the PYTHONPATH? Are you using django from
> > the Ubuntu repositories?
>
> > On Dec 7, 6:06 am, Brian McKeever  wrote:
>
> > > I was having the same trouble you are when I installed eclipse from
> > > the repository.
> > > I fixed it by downloading it again from the 
> > > websitehttp://www.eclipse.org/downloads/
> > > (Eclipse IDE for C/C++ Developers (79 MB) is the one I picked
> > > specifically).

--

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




Multiple icontains using OR - Is it possible?

2009-12-15 Thread tm
Hello Django Users,

I'm trying to use icontains to check 2 fields in the same table for a
keyword entered into a search.

ex I've tried:

queryset = MyModel.objects.filter(summary__icontains=q).filter
(title__icontains=q)

and

queryset = MyModel.objects.filter(summary__icontains=q,
title__icontains=q)

Neither work, although judging by the docs the second one shouldn't in
this case.  Has anyone successfully searched a MySQL DB using
icontains on 2 filelds in the same model?  Any help greatly
appreciated :)

T

--

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




Re: Help me to fix problem related to migration from one server to another

2009-12-15 Thread Karen Tracey
On Tue, Dec 15, 2009 at 4:09 PM, Oleg Oltar  wrote:

> Hi,
>
> I've moved my django application from one server to another, and spotted
> strange bug with media after it:
>
> Traceback (most recent call last):
>
>  File "/usr/lib/python2.5/site-
> packages/Django-1.1.1-py2.5.egg/django/core/handlers/base.py", line 92, in
> get_response
>response = callback(request, *callback_args, **callback_kwargs)
>
>  File
> "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/views/static.py",
> line 51, in serve
>if os.path.isdir(fullpath):
>
>  File "/usr/lib/python2.5/posixpath.py", line 195, in isdir
>st = os.stat(path)
>
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 44-46: ordinal not in range(128)
>
>
> The image I am trying to access actually have Cyrillic symbols in the name,
> but it didn't made a problem on previous environment
>
>
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror

(Note the problem isn't limited to mod_python, despite that being where the
note is in the doc.  In whatever environment your new server is running,
LANG is apparently not set properly.)

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Admin UnicodeEncodeError

2009-12-15 Thread Karen Tracey
On Tue, Dec 15, 2009 at 2:42 PM, goome  wrote:

> Hello
> i have a model with a CharField field.
> When in the admin panel i try to insert a new record for the model
> with a text containing "é" for the field, i got
> """UnicodeEncodeError at /admin/abruzzodavedere/servizio/4/
>
> 'ascii' codec can't encode character u'\xe8' in position 14: ordinal
> not in range(128)
>
> Request Method: POST
> Request URL:http://127.0.0.1:8000/admin/abruzzodavedere/servizio/4/
> Exception Type: UnicodeEncodeError
> Exception Value:
>
> 'ascii' codec can't encode character u'\xe8' in position 14: ordinal
> not in range(128)
> """
> i didn't make any change in the Admin, i mean i simply register the
> model. Now just switched to django1.1
> This error did not appear with django096.
> i did NOT do a new installation of the directory after upgrading
> django,  i just corrrectet max[_]length and created the admin.py
> Can be that the problem?
> Thank you
>
>
Did you convert your old __str__ method to __unicode__?

Without the full traceback and some more specifics of your model it's hard
to guess what's wrong.  I can say in general the admin certainly supports
saving and displaying non-ASCII character data without throwing encoding
errors. There is something specific to your model that is causing this.

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Filter (AND excluding empty values)

2009-12-15 Thread Phui Hock
I suppose you can do something like:
Property.objects.filter(
  city=t, Q(category__isnull=True) | Q(category=c), Q
(status__isnull=True) | Q(status=s)
)

On Dec 16, 9:17 am, Osiaq  wrote:
> Yes, this one is working properly.
> Actually I can use i.e
>
> properties = Property.objects.filter( Q(city=t) & Q(category=c ) & Q
> (status=s) )
>
> These parameters are working perfect for:
> city='Tokio', category='House', status='For Rent'
>
> But fails for:
> city='Tokio', category null, status null
>
> Similar filters are working on every single property developer
> website, so it must be possible, but how to do it?

--

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




Re: How to implement GROUP BY in Django object models?

2009-12-15 Thread thai.pham
Hello Daniel,

Because I'm new to Django. I don't know how to apply the examples in
that document to my case. Would you mind telling me what I should do
with the above SQL query?

Thai.

On Dec 15, 2:47 pm, Daniel Roseman  wrote:
>
> http://docs.djangoproject.com/en/dev/topics/db/aggregation/
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: How to use debugger from doctest

2009-12-15 Thread Phui Hock
Thanks for the replies.

The problem I described earlier exhibits only in Django doctest. If
you write a doctest and run with plain python interpreter, such as
this:
test.py
def print_i(i):
"""
>>> i = 1 + 1
>>> i
2
>>> import pdb; pdb.set_trace()
"""
print i

$ python -m doctest test.py
you will get the interactive debugger to do "p i", "w", "locals()"
etc. So, I don't think it is a problem in pdb, or doctest in that
matter.

Unless I am missing the obvious, I believe Django replaces the stdout
with it's own version of output (django/test/_doctest.py,1152) that
simply won't print in debug mode. Having said that, is it not possible
to activate debugger in Django doctest?


On Dec 16, 8:08 am, Bill Freeman  wrote:
> Or maybe:
>
>   import pdb, sys; pdb.Pdb(stdin=sys.__stdin__,
> stdout=sys.__stdout__).set_trace(sys._getframe().f_back)
>
> On Tue, Dec 15, 2009 at 5:32 PM, Bill Freeman  wrote:
> > Untested, but it looks like you can do:
>
> >   import pdb, sys; pdb.Pdb(stdin=sys.__stdin__,
> > stdout=sys.__stdout__).set_trace()
>
> > On Tue, Dec 15, 2009 at 11:07 AM, Bill Freeman  wrote:
> >> IIUC, the test jig redirects stdin and stdout so that it can drive
> >> interpreter input from
> >> the corresponding substrings of the doc test strings, and capture the 
> >> output to
> >> compare it to the corresponding substrings of the doc test strings.  So 
> >> pdb is
> >> waiting for input from the doctest string and it's output is captured
> >> by the test
> >> framework instead of printed.
>
> >> One approach would be to, rather than simply calling set_trace(),
> >> create a function
> >> of your own to call instead, which rebinds stdin and stdout (and maybe
> >> stderr) to
> >> the terminal, and then calls set_trace() itself.
>
> >> There are two variants on this approach:
>
> >>  If you restore the test framework versions of I/O after set_trace(),
> >> then you can
> >>  print stuff, but single stepping and setting breakpoints is not
> >> going to work.  You
> >>  can, however, use the continue command to run further in the test.
>
> >>  If you don't restore the test framework I/O, then pdb will work,
> >> including breakpoints
> >>  and single step, but all bets are off if you step or run to the
> >> point that you have
> >>  returned to the test framework.
>
> >> Another approach is to hack pdb so that every time that it is entered
> >> it saves the
> >> existing I/O and sets things to the terming, and every time it
> >> transfers back to the
> >> program (s, n, r, c) it restores the I/O.  You can even step into the
> >> test framework
> >> with something like this.  A possible confusion could occur with
> >> non-complete line
> >> I/O, but maybe not.  (I wouldn't be surprised if there weren't
> >> something like this
> >> already in pdb, but to complex to mention in the simple user
> >> documentation.  Or not.
>
> >> A third possibility is a hacked pdb that can be told to interact over
> >> a tcp socket, or,
> >> on *nix, a pseudo tty.  Then you wire up telnet or an xterm, and drive
> >> pdb from there,
> >> without fiddling with stdin, stdout, and stderr at all.  (This would
> >> definitely be a cool
> >> addition to pdb, if it's not already there.)
>
> >> And, of course, you can always sprinkle in code to append
> >> informational lines to a file.
> >> This is the equivalent of the print statement approach, except that
> >> you must open a
> >> file for append and print (or write) to that, and close it.  You might
> >> also manage this
> >> with the logging facility.
>
> >> Bill
>
> >> On Mon, Dec 14, 2009 at 5:21 AM, Phui Hock  wrote:
> >>> Suppose I have the following in app 'app'.
> >>> from django.db import models
> >>> class Test(models.Model):
> >>>    """
> >>>    >>> v = "Hello, world!"
> >>>    >>> import pdb; pdb.set_trace()
> >>>    """
>
> >>> Running manage.py test app will drop me to an interactive debugger
> >>> mode but no output. How to execute the usual p, j, s etc?
>
> >>> --
>
> >>> You received this message because you are subscribed to the Google Groups 
> >>> "Django users" group.
> >>> To post to this group, send email to django-us...@googlegroups.com.
> >>> To unsubscribe from this group, send email to 
> >>> django-users+unsubscr...@googlegroups.com.
> >>> For more options, visit this group 
> >>> athttp://groups.google.com/group/django-users?hl=en.

--

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




Re: Legacy Postgres Database and Sequencers

2009-12-15 Thread Shawn Milochik
If it's a legacy database, but the tables actually have a field named 'id' 
(which is Django's default primary key), maybe the Django ORM is assuming that 
that's the primary key.

Does a field in your model have primary_key = True set?

http://docs.djangoproject.com/en/dev/topics/db/models/#automatic-primary-key-fields

Perhaps doing that will make it leave your 'id' alone. If this doesn't help, 
please post the model.

Shawn


--

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




Re: Filter (AND excluding empty values)

2009-12-15 Thread Osiaq
Yes, this one is working properly.
Actually I can use i.e

properties = Property.objects.filter( Q(city=t) & Q(category=c ) & Q
(status=s) )

These parameters are working perfect for:
city='Tokio', category='House', status='For Rent'

But fails for:
city='Tokio', category null, status null

Similar filters are working on every single property developer
website, so it must be possible, but how to do it?


--

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




Re: Using Forms to display and edit?

2009-12-15 Thread Doug Blank
On Tue, Dec 15, 2009 at 5:45 PM, Margie Roginski
 wrote:
> When I want to just display data in a form (as opposed to letting user
> edit it), I create a specialized widget.  For example, I have a model
> that has multiple datetime fields, and I don't want the user to be
> able to edit them, but I do want to display their values.  Here's a
> widget I use where you pass it some when you intiailize it (the task
> it's operating on and the field name to display).  Its render() method
> just renders the specified field:
>
> class TaskForm_DisplayDateTimeWidget(widgets.Widget):
>
>    def __init__(self, task=None, fieldNameToDisplay=None, attrs =
> {}):
>        self.task = task
>        self.fieldNameToDisplay=fieldNameToDisplay
>        super(TaskForm_DisplayDateTimeWidget, self).__init__(attrs)
>
>    def render(self, name, value, attrs=None):
>        rendered = ""
>        if self.task and self.fieldNameToDisplay:
>            dateVal = getattr(self.task, self.fieldNameToDisplay)
>            if dateVal:
>                rendered = mark_safe("%s" % date(dateVal, "%s %s" %
> (settings.DATE_FORMAT, settings.TIME_FORMAT)))
>
>        return rendered
>
> In my form, which is a model form, I declare the field like this in
> "class global" area (l the area that is in the class but not in any
> method:
>
>    displayModified = DisplayField(label="modified", widget =
> DisplayDateTimeWidget, required=False)
>
> Then in __init__() I do this:
>
>    instance = kwargs.get("instance")
>    if instance:
>            self.fields["displayModified"].widget =
> DisplayDateTimeWidget(task=instance, fieldName="displayModified")
>
> My form is a modelForm, so I do not put this field in Meta.fields, as
> that would cause django to do some extra stuff like atempt to clean
> the field, which doesn't make any sense since there is no input.  So
> basically I'm using all the form and widget infrastructure that django
> supplies, but I'm just not sending any inputs associated with these
> fields. I've seen a lot of people complain about django's lack of
> "read only" fields, but it seems to me that being able to write your
> own widgets and fields gives you total flexibility and that there's no
> need for an actual "read only" field.  My experience is that as soon
> as I got past the basics in my project and wanted to do more complex
> html/css, I never wanted to use the default rendering for any kind of
> field, and read only fields are just one case of this.
>
> In your case you say you sometimes want to create the fields as
> editable and soemtimes not.  In your form you could look at a GET
> variable that identifies whether you want fields to be editable or not
> and then either create your field with a different widget based on
> that GET variable, or even modify what your widget does based on that
> GET variable (ie, pass the value of the GET variable in as a parameter
> to the widgets __init__() method so it can do different stuff based on
> it at render time.
>
> Anyway, hope this helps and am curious if others use this same
> mechanism or if there is some alternate preferred approach.
>
> Margie

Thanks Margie for this example. I may come to something similar to
this, but for the time being I think I'll just put a filter in the
template. That way, I'll have all of the elements there (errors,
display information) for all of the modes (display, edit, and add).
I'll see how far I can go with this method before having to resort to
a more substantial widget-swap.

It does seem that this is an area of Django that could use some thinking...

-Doug

>
>
> On Dec 15, 4:01 am, Doug Blank  wrote:
>> Django users,
>>
>> I'm wrestling with how to best create HTML pages that can either be
>> used for displaying or editing data. That is, I'd like the field's
>> values to appear as text in display mode, but in their widgets when in
>> edit/add mode. It appears that Django wasn't designed to do this: the
>> fields always appear in their widgets (eg, text input, text area,
>> etc).
>>
>> Is there a common technique for handling this, short of using forms
>> for one, and not the other?
>>
>> I was thinking of a custom templatetag filter that could be used for
>> every form field, like:
>>
>> {{ form.field_name|render_field:mode }}
>>
>> where render_field would either return the field's HTML widget, or
>> just the value as text, based on the mode.
>>
>> Have I missed something, or is this a viable solution?
>>
>> -Doug
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post 

Legacy Postgres Database and Sequencers

2009-12-15 Thread D. Rick Anderson
Hi all! I'm new to Django (been a Zope developer for years), and I'm
working on an app to front-end a legacy postgres database, and running
into a few snags.

The database uses sequences for all of the PKs, and when I attempt to
insert a new record:

i = Person(name="Rick", facility_id=123)
i.save()

I get back:

IntegrityError: ERROR:  null value in column "id" violates not-null
constraint

It seems the ORM is automatically inserting 'null' in the id column on
insert, rather than not referencing it at all, and I can't figure out
how to stop that behavior. I'm sure this is a common problem, but I
can't find any answers via search.

TIA

Rick

--

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




Re: How to use debugger from doctest

2009-12-15 Thread Bill Freeman
Or maybe:

  import pdb, sys; pdb.Pdb(stdin=sys.__stdin__,
stdout=sys.__stdout__).set_trace(sys._getframe().f_back)

On Tue, Dec 15, 2009 at 5:32 PM, Bill Freeman  wrote:
> Untested, but it looks like you can do:
>
>   import pdb, sys; pdb.Pdb(stdin=sys.__stdin__,
> stdout=sys.__stdout__).set_trace()
>
> On Tue, Dec 15, 2009 at 11:07 AM, Bill Freeman  wrote:
>> IIUC, the test jig redirects stdin and stdout so that it can drive
>> interpreter input from
>> the corresponding substrings of the doc test strings, and capture the output 
>> to
>> compare it to the corresponding substrings of the doc test strings.  So pdb 
>> is
>> waiting for input from the doctest string and it's output is captured
>> by the test
>> framework instead of printed.
>>
>> One approach would be to, rather than simply calling set_trace(),
>> create a function
>> of your own to call instead, which rebinds stdin and stdout (and maybe
>> stderr) to
>> the terminal, and then calls set_trace() itself.
>>
>> There are two variants on this approach:
>>
>>  If you restore the test framework versions of I/O after set_trace(),
>> then you can
>>  print stuff, but single stepping and setting breakpoints is not
>> going to work.  You
>>  can, however, use the continue command to run further in the test.
>>
>>  If you don't restore the test framework I/O, then pdb will work,
>> including breakpoints
>>  and single step, but all bets are off if you step or run to the
>> point that you have
>>  returned to the test framework.
>>
>> Another approach is to hack pdb so that every time that it is entered
>> it saves the
>> existing I/O and sets things to the terming, and every time it
>> transfers back to the
>> program (s, n, r, c) it restores the I/O.  You can even step into the
>> test framework
>> with something like this.  A possible confusion could occur with
>> non-complete line
>> I/O, but maybe not.  (I wouldn't be surprised if there weren't
>> something like this
>> already in pdb, but to complex to mention in the simple user
>> documentation.  Or not.
>>
>> A third possibility is a hacked pdb that can be told to interact over
>> a tcp socket, or,
>> on *nix, a pseudo tty.  Then you wire up telnet or an xterm, and drive
>> pdb from there,
>> without fiddling with stdin, stdout, and stderr at all.  (This would
>> definitely be a cool
>> addition to pdb, if it's not already there.)
>>
>> And, of course, you can always sprinkle in code to append
>> informational lines to a file.
>> This is the equivalent of the print statement approach, except that
>> you must open a
>> file for append and print (or write) to that, and close it.  You might
>> also manage this
>> with the logging facility.
>>
>> Bill
>>
>> On Mon, Dec 14, 2009 at 5:21 AM, Phui Hock  wrote:
>>> Suppose I have the following in app 'app'.
>>> from django.db import models
>>> class Test(models.Model):
>>>    """
>>>    >>> v = "Hello, world!"
>>>    >>> import pdb; pdb.set_trace()
>>>    """
>>>
>>> Running manage.py test app will drop me to an interactive debugger
>>> mode but no output. How to execute the usual p, j, s etc?
>>>
>>> --
>>>
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>>
>>
>

--

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




How to use an alternative template system (trunk version)?

2009-12-15 Thread Measurement and statistics
According to the latest document:
http://docs.djangoproject.com/en/dev/ref/templates/api/#using-an-alternative-template-language,
it will be much easier to replace the django template system than
before. Has anyone tried the new approach? I tried, but I couldn't
make it work.

--

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




Re: Using Forms to display and edit?

2009-12-15 Thread Margie Roginski
When I want to just display data in a form (as opposed to letting user
edit it), I create a specialized widget.  For example, I have a model
that has multiple datetime fields, and I don't want the user to be
able to edit them, but I do want to display their values.  Here's a
widget I use where you pass it some when you intiailize it (the task
it's operating on and the field name to display).  Its render() method
just renders the specified field:

class TaskForm_DisplayDateTimeWidget(widgets.Widget):

def __init__(self, task=None, fieldNameToDisplay=None, attrs =
{}):
self.task = task
self.fieldNameToDisplay=fieldNameToDisplay
super(TaskForm_DisplayDateTimeWidget, self).__init__(attrs)

def render(self, name, value, attrs=None):
rendered = ""
if self.task and self.fieldNameToDisplay:
dateVal = getattr(self.task, self.fieldNameToDisplay)
if dateVal:
rendered = mark_safe("%s" % date(dateVal, "%s %s" %
(settings.DATE_FORMAT, settings.TIME_FORMAT)))

return rendered

In my form, which is a model form, I declare the field like this in
"class global" area (l the area that is in the class but not in any
method:

displayModified = DisplayField(label="modified", widget =
DisplayDateTimeWidget, required=False)

Then in __init__() I do this:

instance = kwargs.get("instance")
if instance:
self.fields["displayModified"].widget =
DisplayDateTimeWidget(task=instance, fieldName="displayModified")

My form is a modelForm, so I do not put this field in Meta.fields, as
that would cause django to do some extra stuff like atempt to clean
the field, which doesn't make any sense since there is no input.  So
basically I'm using all the form and widget infrastructure that django
supplies, but I'm just not sending any inputs associated with these
fields. I've seen a lot of people complain about django's lack of
"read only" fields, but it seems to me that being able to write your
own widgets and fields gives you total flexibility and that there's no
need for an actual "read only" field.  My experience is that as soon
as I got past the basics in my project and wanted to do more complex
html/css, I never wanted to use the default rendering for any kind of
field, and read only fields are just one case of this.

In your case you say you sometimes want to create the fields as
editable and soemtimes not.  In your form you could look at a GET
variable that identifies whether you want fields to be editable or not
and then either create your field with a different widget based on
that GET variable, or even modify what your widget does based on that
GET variable (ie, pass the value of the GET variable in as a parameter
to the widgets __init__() method so it can do different stuff based on
it at render time.

Anyway, hope this helps and am curious if others use this same
mechanism or if there is some alternate preferred approach.

Margie



On Dec 15, 4:01 am, Doug Blank  wrote:
> Django users,
>
> I'm wrestling with how to best create HTML pages that can either be
> used for displaying or editing data. That is, I'd like the field's
> values to appear as text in display mode, but in their widgets when in
> edit/add mode. It appears that Django wasn't designed to do this: the
> fields always appear in their widgets (eg, text input, text area,
> etc).
>
> Is there a common technique for handling this, short of using forms
> for one, and not the other?
>
> I was thinking of a custom templatetag filter that could be used for
> every form field, like:
>
> {{ form.field_name|render_field:mode }}
>
> where render_field would either return the field's HTML widget, or
> just the value as text, based on the mode.
>
> Have I missed something, or is this a viable solution?
>
> -Doug

--

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




Re: How to use debugger from doctest

2009-12-15 Thread Bill Freeman
Untested, but it looks like you can do:

   import pdb, sys; pdb.Pdb(stdin=sys.__stdin__,
stdout=sys.__stdout__).set_trace()

On Tue, Dec 15, 2009 at 11:07 AM, Bill Freeman  wrote:
> IIUC, the test jig redirects stdin and stdout so that it can drive
> interpreter input from
> the corresponding substrings of the doc test strings, and capture the output 
> to
> compare it to the corresponding substrings of the doc test strings.  So pdb is
> waiting for input from the doctest string and it's output is captured
> by the test
> framework instead of printed.
>
> One approach would be to, rather than simply calling set_trace(),
> create a function
> of your own to call instead, which rebinds stdin and stdout (and maybe
> stderr) to
> the terminal, and then calls set_trace() itself.
>
> There are two variants on this approach:
>
>  If you restore the test framework versions of I/O after set_trace(),
> then you can
>  print stuff, but single stepping and setting breakpoints is not
> going to work.  You
>  can, however, use the continue command to run further in the test.
>
>  If you don't restore the test framework I/O, then pdb will work,
> including breakpoints
>  and single step, but all bets are off if you step or run to the
> point that you have
>  returned to the test framework.
>
> Another approach is to hack pdb so that every time that it is entered
> it saves the
> existing I/O and sets things to the terming, and every time it
> transfers back to the
> program (s, n, r, c) it restores the I/O.  You can even step into the
> test framework
> with something like this.  A possible confusion could occur with
> non-complete line
> I/O, but maybe not.  (I wouldn't be surprised if there weren't
> something like this
> already in pdb, but to complex to mention in the simple user
> documentation.  Or not.
>
> A third possibility is a hacked pdb that can be told to interact over
> a tcp socket, or,
> on *nix, a pseudo tty.  Then you wire up telnet or an xterm, and drive
> pdb from there,
> without fiddling with stdin, stdout, and stderr at all.  (This would
> definitely be a cool
> addition to pdb, if it's not already there.)
>
> And, of course, you can always sprinkle in code to append
> informational lines to a file.
> This is the equivalent of the print statement approach, except that
> you must open a
> file for append and print (or write) to that, and close it.  You might
> also manage this
> with the logging facility.
>
> Bill
>
> On Mon, Dec 14, 2009 at 5:21 AM, Phui Hock  wrote:
>> Suppose I have the following in app 'app'.
>> from django.db import models
>> class Test(models.Model):
>>    """
>>    >>> v = "Hello, world!"
>>    >>> import pdb; pdb.set_trace()
>>    """
>>
>> Running manage.py test app will drop me to an interactive debugger
>> mode but no output. How to execute the usual p, j, s etc?
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>>
>

--

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




Re: stringformat in {% url %}

2009-12-15 Thread neridaj
nevermind, I'm doing this a different way.

On Dec 15, 1:46 pm, neridaj  wrote:
> Hello,
>
> I'm trying to format a variable inside a {% url %} tag with
> stringformat but I can't get it right. All I want to do is concatenate
> a pound sign (#) to an id i.e., "#123456789", here is what I have:
>
> 
>
> Thanks for any help,
>
> J

--

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




Re: How to customize form styled by django-uni-form?

2009-12-15 Thread Preston Holmes


On Dec 15, 12:02 pm, Continuation  wrote:
> This is a question about django-uni-form. But I figure many people
> here may have experienced with django-uni-form so I'd try asking here.
>
> I'm using django-uni-form to style my form using the filter my_form|
> as_uni_form:
>
> 
>       
>            {{ my_form|as_uni_form }}
>            
>                 
>            
>        
> 
>
> It looks really good. But I need to customize it.
>
> For example, one of the field "percentage" of the form is of the type
> IntegerField. It is being rendered as an .
>
> The problem is that the text box is really wide, I'd like to make it
> only 2 character wide.
>
> Also I want to add a percentage sign "%" right after the text box so
> that users know they if they put in the number "10" in the text box,
> it means 10%.
>
> Is there anyway to do that with django-uni-form?

These aren't related to the use of uni-form

This is just a matter of using the right widget with attributes, and
labels and help text in your models/forms:

http://docs.djangoproject.com/en/1.1/ref/forms/widgets/

-Preston

>
> Thanks for your help.

--

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




stringformat in {% url %}

2009-12-15 Thread neridaj
Hello,

I'm trying to format a variable inside a {% url %} tag with
stringformat but I can't get it right. All I want to do is concatenate
a pound sign (#) to an id i.e., "#123456789", here is what I have:



Thanks for any help,

J

--

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




Re: South data migration problem.

2009-12-15 Thread Shawn Milochik
Okay, okay. So I'm still replying to my own post. On the bright side, I figured 
it out.

First point of interest: 

If I stop referrering to my model with orm.Message, and just use Message 
(as imported from my app at the top), everything works fine.

Second point of interest (discovered AFTER "fixing" it as mentioned just above):

If I grab studies with orm['otherappname.Study'].objects.all() instead of 
Study.objects.all() (as imported at the top), everything works fine. Note that 
when doing this, I'm also correctly referring to the Message model with 
orm.Message, instead of the way I mentioned above.

So, evidently a Study is not the same class type as orm.Study, and when using 
an orm.Message, it expects its studies to be of type orm.Study, not Study.

In conclusion, the problem was because I was doing it wrong. South prefers that 
you use its "fake" ORM because it allows you to write data migrations to the 
models as they were at the time the migration was created, not whatever state 
the actual models are in months later.

For reference:
http://south.aeracode.org/wiki/Tutorial3

South and I are buddies again.

Shawn




--

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




Help me to fix problem related to migration from one server to another

2009-12-15 Thread Oleg Oltar
Hi,

I've moved my django application from one server to another, and spotted
strange bug with media after it:

Traceback (most recent call last):

 File "/usr/lib/python2.5/site-
packages/Django-1.1.1-py2.5.egg/django/core/handlers/base.py", line 92, in
get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File
"/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/views/static.py",
line 51, in serve
   if os.path.isdir(fullpath):

 File "/usr/lib/python2.5/posixpath.py", line 195, in isdir
   st = os.stat(path)

UnicodeEncodeError: 'ascii' codec can't encode characters in position 44-46:
ordinal not in range(128)


The image I am trying to access actually have Cyrillic symbols in the name,
but it didn't made a problem on previous environment

Thanks,
Oleg

--

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




Re: South data migration problem.

2009-12-15 Thread Shawn Milochik
Sorry to reply to my own post --  I just realized I left out a useful detail:

I added a foreign key to the Study model to several tables, and a ManyToMany to 
Study to two tables.

The data migration works flawlessly for the tables where I'm setting the 
foreign key to the Study instance -- it only fails for the ManyToMany.

Example (this works):

for x in orm.Messages.objects.all():
x.study = temp_study
x.save()

So, just to clarify. Sorry I forgot to mention that in the original post.

Shawn


--

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




South data migration problem.

2009-12-15 Thread Shawn Milochik
I added a new ManyToMany field to one of my models. The foreign key is to a 
model in a different Django application in our project.

The migration to add the foreign key works perfectly. I did remember to add the 
--freeze otherappname.modelname to the command line. I also added the --freeze 
otherappname.modelname to my startmigration for the data migration file.

However, the data migration is failing when I try to add a value to the 
ManyToMany, saying that it must be an instance of 'study' (my model). 

However, it most certainly is an instance of that model, which I've proven by 
printing its info to the screen, including type().

I'm wondering if it has something to do with the fact that I'm unable to refer 
to the study using orm.Study, because South complains (correctly) that 
appname.Study doesn't exist. It's otherappname.Study. So I'm directly importing 
Study at the top of the file, and just grabbing an instance of the Study model. 
Although I've 'frozen' otherappname.study into South's models{} dictionary, it 
doesn't seem that I can refer to it using South's orm.

Here's the actual error, with the line that causes it:

x.studies.add(temp_study)
TypeError: 'study' instance expected


Here's a line I inserted just above the line causing the error, and its output:


print "\n\n\nStudy: '%s'. Type: %s\n\n\n" % (temp_study, type(temp_study))


Study: 'Example Study Name'. Type: 


It's entirely possible I'm doing something wrong, but I kind of thought South 
and I had finally made peace. :o(
Any ideas?

Thanks,
Shawn

--

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




Re: ORM using tons of memory and CPU

2009-12-15 Thread Jirka Vejrazka
Well, I was bound to get something wrong :)

> to_be_purged = 
> archivedEmail.objects.filter(received__lte=newest_to_delete).values('cacheID',
>  flat=True)

the end of the line should be  .values_list('cacheID', flat=True)   #
not .values(

  Cheers

Jirka

--

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




Re: No module named urls (again)

2009-12-15 Thread Michael K


On Dec 15, 3:18 pm, Pablo Solera  wrote:
> When I try to run the same server from eclipse, it seems that
> something is not correct.
> I got the error: ImportError at / "No module named urls"
> I do have the urls.py on my application, and averything works fine out
> of eclipse.
>
> Could it be a PATH problem? How could I debug it?

Did you add your project path to the PYTHONPATH environment variable
in your Run profile?  That's what the problem sounds like - Eclipse's
environment doesn't know to tell Python that your Django project needs
to be in the PYTHONPATH.

--
Michael

--

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




No module named urls (again)

2009-12-15 Thread Pablo Solera
Hi everyone,

This is my first post ans as usual it deals with a problem.
I hope it isn´t answered yet. I´ve searched across the group and didn
´t find the solution (A similar problem didn´t detail the solution -
no renaming here)
Ok lets describe it:

I´m trying to start developing with eclipse + pydev + django.
I´ve followed the superb instructions here:
http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-django.html

When I run my server from command line (windows) It works!
E:\dev\nav\pr1>manage.py runserver

When I try to run the same server from eclipse, it seems that
something is not correct.
I got the error: ImportError at / "No module named urls"
I do have the urls.py on my application, and averything works fine out
of eclipse.

Could it be a PATH problem? How could I debug it?

--

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




Re: ORM using tons of memory and CPU

2009-12-15 Thread Jirka Vejrazka
Hi,

 correct me if I got it wrong, but you essentially need these 4 things:
 1) obtain the date for the the newest messages to delete
 2) get cacheID of all objects to be deleted
 3) delete the files
 4) delete these objects from the database

So, you could use something like this:

# get the date
newest_to_delete = datetime.today() - timedelta(days=settings.DAYSTOKEEP)
# get cacheID's of emails to be deleted, requires Django 1.0+
to_be_purged = 
archivedEmail.objects.filter(received__lte=newest_to_delete).values('cacheID',
flat=True)
# to_be_purged is now a Python list of cacheID's
for item in to_be_purged:
delete_file(item)  # do the os.unlink() operations
# now delete the entries from the database
archivedEmail.objects.filter(received__lte=newest_to_delete).delete()

Since you keep all files in flat directories, I'm assuming that you
are not deleting millions of emails per day (otherwise the file lookup
operations would really be the bottleneck). Hence, this "list of
cacheID's" approach might be the fastest way. The iterator idea
suggested before is good too, you'd have to compare them yourself on
your data set to figure out what works better.

  Hope this helps

Jirka

--

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




How to customize form styled by django-uni-form?

2009-12-15 Thread Continuation
This is a question about django-uni-form. But I figure many people
here may have experienced with django-uni-form so I'd try asking here.

I'm using django-uni-form to style my form using the filter my_form|
as_uni_form:


  
   {{ my_form|as_uni_form }}
   

   
   


It looks really good. But I need to customize it.

For example, one of the field "percentage" of the form is of the type
IntegerField. It is being rendered as an .

The problem is that the text box is really wide, I'd like to make it
only 2 character wide.

Also I want to add a percentage sign "%" right after the text box so
that users know they if they put in the number "10" in the text box,
it means 10%.

Is there anyway to do that with django-uni-form?

Thanks for your help.

--

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




Admin UnicodeEncodeError

2009-12-15 Thread goome
Hello
i have a model with a CharField field.
When in the admin panel i try to insert a new record for the model
with a text containing "é" for the field, i got
"""UnicodeEncodeError at /admin/abruzzodavedere/servizio/4/

'ascii' codec can't encode character u'\xe8' in position 14: ordinal
not in range(128)

Request Method: POST
Request URL:http://127.0.0.1:8000/admin/abruzzodavedere/servizio/4/
Exception Type: UnicodeEncodeError
Exception Value:

'ascii' codec can't encode character u'\xe8' in position 14: ordinal
not in range(128)
"""
i didn't make any change in the Admin, i mean i simply register the
model. Now just switched to django1.1
This error did not appear with django096.
i did NOT do a new installation of the directory after upgrading
django,  i just corrrectet max[_]length and created the admin.py
Can be that the problem?
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: variable {% url %} parameter

2009-12-15 Thread Baurzhan Ismagulov
On Tue, Dec 15, 2009 at 08:00:54AM -0800, Daniel Roseman wrote:
> Should be {% url app-edit object_id=object.pk %} - ie drop the quotes
> around app-edit.

Yes, this worked. Thanks, Daniel and Bruno!

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: problems downloading django

2009-12-15 Thread Michael K
On Dec 15, 12:30 pm, Michael K  wrote:
> I tried to download the TAR file(s) for releases, but I get a ~5Mb
> corrupted tar.gz from the website.   With this in mind, I tried the
> SVN, and here's what that resulted in:
>
> svn: PROPFIND request failed on '/svn/django/trunk'
> svn: PROPFIND of '/svn/django/trunk': Could not resolve hostname
> `code.djangoproject.com': The requested name is valid and was found in
> the database, but it does not have the correct associated data being
> resolved for.   (http://code.djangoproject.com)
>
> Here's the thing - I can browse it, so I think the "resolve hostname"
> may be a misnomer.  It says it can find it, but something's "missing".

Discovered the SVN problem is proxy-server related (they don't allow
the commands necessary for it to work).

However, that still leaves me unable to download the release packages.

Does anyone know of a mirror site that might let me download the
packages?

--
Michael

--

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




Re: What exactly does order_with_respect_to do?

2009-12-15 Thread Hanne Moa
2009/12/15 smcoll :
> i'd be curious to know if anyone has seen an admin implementation for
> reordering with this field.  i'd also heard some chatter a while back
> that this might be removed in future releases of Django, because it
> leans toward the "magic" end of things

I always end up making an explicit field "pos" for this anyway. Fewer surprises.


HM

--

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




Re: ORM using tons of memory and CPU

2009-12-15 Thread Tracy Reed
On Tue, Dec 15, 2009 at 03:35:29AM -0800, bruno desthuilliers spake thusly:
> looks like settings.DEBUG=True to me.

Nope. settings.py has DEBUG = False

> wrt/ the other mentioned problem - building whole model instances for
> each row - you can obviously save a lot of work here by using a
> value_list queryset - tuples are very cheap.

I don't understand which other problem you are referring to here... If
I mentioned something about building whole model instances for each
row I didn't realize it.

> Now for something different - here are a couple other python
> optimisation tricks:

Thanks!

> Oh and yes, one last point : how do you run this script exactly ?

I set the PYTHONPATH and DJANGO_SETTINGS_MODULE env vars and then do 
./purgemail.py

-- 
Tracy Reed
http://tracyreed.org


pgpSPr64Iuvkk.pgp
Description: PGP signature


Re: Photo Gallery Suggestions

2009-12-15 Thread patrickk
what we usually do with the filebrowser is this:
we create a custom gallery (gallery-model with gallery-images as
tabularinlines) with a filebrowsefield for a folder - when you add a
gallery you just select a folder on your filesystem. we overwrite the
save-method (of the gallery) in order to find all images within that
folder and assign the images to the gallery (via gallery-images).
the thumbnails and image-versions are generated on the fly.

an example can be found here:
http://www.skip.at/film/9580/bildgalerie/814/

btw: we´re working a a project coupled to the filebrowser - called
"medman". using the filebrowsers signals, we store image-information
(exif date) within models. medman will work with images and videos
(with exif.py and ffmpeg).

of couse, you can use the filebrowser signals to roll your own gallery
as well ...

regards,
patrick


On 15 Dez., 19:01, Kevin Monceaux  wrote:
> Oops, I knew I'd leave out at least one.
>
> On Tue, Dec 15, 2009 at 10:42:10AM -0600, Kevin Monceaux wrote:
> > Some of the items on my wish list include:
>
>     Customizable upload/save path, preferably including a directory named
>     after the photo's ID, to avoid filename collisions.
>
> --
>
> Kevinhttp://www.RawFedDogs.nethttp://www.WacoAgilityGroup.org
> Bruceville, TX
>
> Si hoc legere scis nimium eruditionis habes.
> Longum iter est per praecepta, breve et efficax per exempla!!!

--

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




Re: ORM using tons of memory and CPU

2009-12-15 Thread Tracy Reed
On Tue, Dec 15, 2009 at 09:43:02AM +0200, Jani Tiainen spake thusly:
> If you have DEBUG=True setting Django also records _every_ SQL query
> made to database and depending on a case, it might use quite lot of
> memory.

My settings.py contains:

DEBUG = False

-- 
Tracy Reed
http://tracyreed.org


pgp8LdeChJimo.pgp
Description: PGP signature


Re: Photo Gallery Suggestions

2009-12-15 Thread Kevin Monceaux

Oops, I knew I'd leave out at least one.

On Tue, Dec 15, 2009 at 10:42:10AM -0600, Kevin Monceaux wrote:

> Some of the items on my wish list include:

Customizable upload/save path, preferably including a directory named
after the photo's ID, to avoid filename collisions.

-- 

Kevin
http://www.RawFedDogs.net
http://www.WacoAgilityGroup.org
Bruceville, TX

Si hoc legere scis nimium eruditionis habes.
Longum iter est per praecepta, breve et efficax per exempla!!!

--

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




problems downloading django

2009-12-15 Thread Michael K
I don't know when this started, as I've not needed to download django
in a while, but I've come across a strange issue.  Pardon if this is
going to the wrong place.

I tried to download the TAR file(s) for releases, but I get a ~5Mb
corrupted tar.gz from the website.   With this in mind, I tried the
SVN, and here's what that resulted in:

svn: PROPFIND request failed on '/svn/django/trunk'
svn: PROPFIND of '/svn/django/trunk': Could not resolve hostname
`code.djangoproject.com': The requested name is valid and was found in
the database, but it does not have the correct associated data being
resolved for.   (http://code.djangoproject.com)

Here's the thing - I can browse it, so I think the "resolve hostname"
may be a misnomer.  It says it can find it, but something's "missing".

Help?

--
Michael

--

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




Re: What exactly does order_with_respect_to do?

2009-12-15 Thread smcoll
This is probably a dead thread, but...  i think the answer given is
incorrect.

'order_with_respect_to' adds an '_order' integer field to the model.
Each set of instances that share a parent object of the relation
specified by 'order_with_respect_to' get ordered as a set.  So in the
example, three Answer instances with fk's to one Question instance
will have '_order' values of 0, 1, and 2, which represent their
(specified) ordering "with respect to" that Question instance.

i'd be curious to know if anyone has seen an admin implementation for
reordering with this field.  i'd also heard some chatter a while back
that this might be removed in future releases of Django, because it
leans toward the "magic" end of things.

shannon

On Nov 30, 3:20 pm, Preston Holmes  wrote:
> On Nov 29, 4:50 pm, Continuation  wrote:
>
> > In the doc (http://docs.djangoproject.com/en/dev/ref/models/options/
> > #order-with-respect-to) it is mentioned that  order_with_respect_to
> > marks an object as "orderable" with respect to a given field.
>
> > What exactly does that mean? Can someone give me an example of how
> > this could  be used?
>
> > The doc's example is:
> >  order_with_respect_to = 'question'
>
> > How is that different from
> > ordering = ['question']
>
> order_with_respect_to uses the Question classes' ordering, where just
> ordering would use the string representation of that question.
>
> So using the example of questions and answers from the docs
>
> if Question had a 'sequence' field, and Question meta.ordering was set
> to use sequence, the answers would use that sequence.  If using
> ordering instead of order_with_respect_to, then the questions would be
> in alphabetical question order.
>
> At least thats how I understand it.
>
> -Preston

--

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




Re: How to use debugger from doctest

2009-12-15 Thread Bill Freeman
IIUC, the test jig redirects stdin and stdout so that it can drive
interpreter input from
the corresponding substrings of the doc test strings, and capture the output to
compare it to the corresponding substrings of the doc test strings.  So pdb is
waiting for input from the doctest string and it's output is captured
by the test
framework instead of printed.

One approach would be to, rather than simply calling set_trace(),
create a function
of your own to call instead, which rebinds stdin and stdout (and maybe
stderr) to
the terminal, and then calls set_trace() itself.

There are two variants on this approach:

  If you restore the test framework versions of I/O after set_trace(),
then you can
  print stuff, but single stepping and setting breakpoints is not
going to work.  You
  can, however, use the continue command to run further in the test.

  If you don't restore the test framework I/O, then pdb will work,
including breakpoints
  and single step, but all bets are off if you step or run to the
point that you have
  returned to the test framework.

Another approach is to hack pdb so that every time that it is entered
it saves the
existing I/O and sets things to the terming, and every time it
transfers back to the
program (s, n, r, c) it restores the I/O.  You can even step into the
test framework
with something like this.  A possible confusion could occur with
non-complete line
I/O, but maybe not.  (I wouldn't be surprised if there weren't
something like this
already in pdb, but to complex to mention in the simple user
documentation.  Or not.

A third possibility is a hacked pdb that can be told to interact over
a tcp socket, or,
on *nix, a pseudo tty.  Then you wire up telnet or an xterm, and drive
pdb from there,
without fiddling with stdin, stdout, and stderr at all.  (This would
definitely be a cool
addition to pdb, if it's not already there.)

And, of course, you can always sprinkle in code to append
informational lines to a file.
This is the equivalent of the print statement approach, except that
you must open a
file for append and print (or write) to that, and close it.  You might
also manage this
with the logging facility.

Bill

On Mon, Dec 14, 2009 at 5:21 AM, Phui Hock  wrote:
> Suppose I have the following in app 'app'.
> from django.db import models
> class Test(models.Model):
>    """
>    >>> v = "Hello, world!"
>    >>> import pdb; pdb.set_trace()
>    """
>
> Running manage.py test app will drop me to an interactive debugger
> mode but no output. How to execute the usual p, j, s etc?
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--

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




Re: variable {% url %} parameter

2009-12-15 Thread Daniel Roseman
On Dec 15, 3:36 pm, Baurzhan Ismagulov  wrote:
> On Mon, Dec 14, 2009 at 02:12:00AM -0800, bruno desthuilliers wrote:
> > > (r'^app/(?P\d+)/$', create_update.update_object,
> > > {'model': App}, 'app-edit'),
>
> > > Now, using {% url 'app-edit' object.pk %} in a form throws
> > > TemplateSyntaxError, mentioning "NoReverseMatch: Reverse for
> > > 'rc.'app-edit'' with arguments '(1,)' and keyword arguments '{}' not
> > > found."
>
> > The above url works with a named (aka 'keyword') param 'object_id', so
> > you do have to use the same scheme withing the url tag, ie:
>
> > {% url 'app-edit' object_id=object.pk %}
>
> Thanks for the tip. This results in TemplateSyntaxError with
> "NoReverseMatch: Reverse for 'rc.'app-edit'' with arguments '()' and
> keyword arguments '{'object_id': 1}' not found.". What am I doing
> wrongly?
>
> With kind regards,
> --
> Baurzhan Ismagulovhttp://www.kz-easy.com/

Should be {% url app-edit object_id=object.pk %} - ie drop the quotes
around app-edit.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: how to get the list_display properly?

2009-12-15 Thread Daniel Roseman
On Dec 15, 12:48 pm, Viktor  wrote:
> hi,
>
> I've just noticed that even the contrib apps' admin interface is bogus
> in django 1.1
>
> namely, the first column name should be the "check all" checkbox,
> instead that column receives a the first header of list_display, and
> finally the last column does not have a header.
>
> is this really a bug?
>
> thanks for your help,
> Viktor

No, it works fine. There must be something wrong with your
installation. Do you have any personalised admin templates in your
project?
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Django authentication, not permit 2 users with the same name to login in same time

2009-12-15 Thread Nicu Marcu
Need to be other solution, like using sessions?

2009/12/15 rebus_ 

> 2009/12/14 NMarcu :
> > Hi all,
> >
> >   How can I do, to not let the same user to be logged from 2
> > different location, in the same time. I want, when a user admin is
> > login, and another user try to login with the same user admin, to have
> > a message, you are already login. How can I do something like this?
> >
> > All the best,
> > Nicu Marcu
> >
> > --
> >
>
> You extend auth login view so it checks if the user that wants to
> login already has active session and if he does tell him he can't
> login.
>
> But if he forgets to logout on remote location how will he be able to
> login again?
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>


-- 
All the best,

Nicolae MARCU

--

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




Re: variable {% url %} parameter

2009-12-15 Thread Baurzhan Ismagulov
On Mon, Dec 14, 2009 at 02:12:00AM -0800, bruno desthuilliers wrote:
> >     (r'^app/(?P\d+)/$', create_update.update_object,
> >      {'model': App}, 'app-edit'),
> >
> > Now, using {% url 'app-edit' object.pk %} in a form throws
> > TemplateSyntaxError, mentioning "NoReverseMatch: Reverse for
> > 'rc.'app-edit'' with arguments '(1,)' and keyword arguments '{}' not
> > found."
> 
> The above url works with a named (aka 'keyword') param 'object_id', so
> you do have to use the same scheme withing the url tag, ie:
> 
> {% url 'app-edit' object_id=object.pk %}

Thanks for the tip. This results in TemplateSyntaxError with
"NoReverseMatch: Reverse for 'rc.'app-edit'' with arguments '()' and
keyword arguments '{'object_id': 1}' not found.". What am I doing
wrongly?

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: can any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 chiranjeevi muttoju :
> ImportError: No module named setuptools

Seems pretty self-evident to me. Try installing setuptools first.

-- 
Cheers,
Simon B.

--

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




Re: MySQLdb module for Python 2.5 on Windows XP

2009-12-15 Thread OkaMthembo
I followed Simon Brunning's advice on a similar post and ended up getting
the correct module from Sourceforge. Thank you.

Regards,
Lloyd

On Tue, Dec 15, 2009 at 4:36 PM, OkaMthembo  wrote:

> Pardon me, the settings module edited is the Django application one and not
> that of MySQL.
>
>
> On Tue, Dec 15, 2009 at 4:33 PM, OkaMthembo  wrote:
>
>> Hi guys,
>>
>> I'm a Django noob and am having a few hair-raising experiences (maybe it's
>> because i'm on Windows?). I successfully installed Django and fired up the
>> dev server. Now, i got to the part in the walkthrough where i must edit the
>> MySQL settings module and specify a user and password. I can log into MySQL
>> via the command line and run whatever SQL i need to - however, once i edited
>> the settings file and reloaded the Django welcome page, i'm getting an
>> error: "*Error loading MySQLdb module: no module named MySQLdb*"
>>
>> I then Googled about and found the modules at Sourceforge. There does not
>> seem to be a 32bit one for Python 2.5 - please advise? I am also wondering
>> whether the module should be unzipped into the MySQL bin folder (tried that
>> with the 64 bit one and aded the bin folder to the PATH variable. No
>> success).
>>
>> --
>> Regards,
>> Sithembewena Lloyd Dube
>> http://www.lloyddube.com
>>
>
>
>
> --
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.com
>



-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: can any on help me how to create a sample model project.

2009-12-15 Thread chiranjeevi muttoju
the content of that file is..
[options]
# embedded: link against the embedded server library
# threadsafe: use the threadsafe client
# static: link against a static library (probably required for embedded)

embedded = False
threadsafe = True
static = False

# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
#mysql_config = /usr/local/bin/mysql_config

# The Windows registry key for MySQL.
# This has to be set for Windows builds to work.
# Only change this if you have a different version.
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0


plz help me..

On Tue, Dec 15, 2009 at 8:08 PM, chiranjeevi muttoju
wrote:

>   $ tar xfz MySQL-python-1.2.1.tar.gz
>   $ cd MySQL-python-1.2.1
>   $ # edit site.cfg if necessary
>   $ python setup.py build
>   $ sudo python setup.py install # or su first
>
> this is the installation process specified.. I think the 3rd step is for
> mysql settings.. i instaled the my sql in other mechine of ip x.x.x.x. then
> how can i change that file..
>
> if i run 4th command directly its not working it gives the error..
>
>
> Traceback (most recent call last):
>   File "setup.py", line 5, in 
> from setuptools import setup, Extension
> ImportError: No module named setuptools
>
>
>
> On Tue, Dec 15, 2009 at 8:00 PM, Simon Brunning 
> wrote:
>
>> 2009/12/15 chiranjeevi muttoju :
>> > hey i installed django on one machine, and sql in another machine.. in
>> which
>> > mechine i need to install the sql connector.
>>
>> The Django machine.
>>
>> --
>> Cheers,
>> Simon B.
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>>
>
>
> --
> ▒▒�...@g@d...@◄▒▒
>



-- 
▒▒�...@g@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Filter (AND excluding empty values)

2009-12-15 Thread Alex Robbins
Does it work for one case at a time? Have you tried

q = request.GET.get('city')
properties = Property.objects.filter(city=q)

I would make sure it is working for each variable before combining
them together. (Maybe you already have, I don't know.)

Alex

On Dec 14, 5:32 pm, Osiaq  wrote:
> Andy, I couldn't manage it. Could you (please) give me some example?
> It looks like this case is NOT simple at all, googling through
> multiple websites didn't bring anything even close to  required
> solution.
>
> MODEL:
> class Property(models.Model):
>         name = models.CharField(max_length=200)
>         category =models.ForeignKey(PropertyCategory)
>         city =models.ForeignKey(City)
>         status=models.ForeignKey(PropertyStatus)
>         def __unicode__(self):
>                 return self.name
>
> VIEW:
> def search(request):
> q=request.GET['city']
> c=request.GET['category']
> s=request.GET['status']
> properties = Property.objects.filter( HERE_COMES_WHAT_IM_LOOKING_FOR)
>
> HTML:
> 
>         
>         ALL
>         Tokyo
>         Nashville
>         
>
>         
>         ALL
>         House
>         Apartment
>         
>
>         
>         ALL
>         For Sale
>         For Rent
>         
>
>         
> 
>
> ...and now I want to display i.e.
> all from Tokyo or
> all Houses or
> all For Sale in Tokyo
> etc...

--

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




Re: can any on help me how to create a sample model project.

2009-12-15 Thread chiranjeevi muttoju
  $ tar xfz MySQL-python-1.2.1.tar.gz
  $ cd MySQL-python-1.2.1
  $ # edit site.cfg if necessary
  $ python setup.py build
  $ sudo python setup.py install # or su first

this is the installation process specified.. I think the 3rd step is for
mysql settings.. i instaled the my sql in other mechine of ip x.x.x.x. then
how can i change that file..

if i run 4th command directly its not working it gives the error..

Traceback (most recent call last):
  File "setup.py", line 5, in 
from setuptools import setup, Extension
ImportError: No module named setuptools


On Tue, Dec 15, 2009 at 8:00 PM, Simon Brunning wrote:

> 2009/12/15 chiranjeevi muttoju :
> > hey i installed django on one machine, and sql in another machine.. in
> which
> > mechine i need to install the sql connector.
>
> The Django machine.
>
> --
> Cheers,
> Simon B.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>


-- 
▒▒�...@g@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: MySQLdb module for Python 2.5 on Windows XP

2009-12-15 Thread OkaMthembo
Pardon me, the settings module edited is the Django application one and not
that of MySQL.

On Tue, Dec 15, 2009 at 4:33 PM, OkaMthembo  wrote:

> Hi guys,
>
> I'm a Django noob and am having a few hair-raising experiences (maybe it's
> because i'm on Windows?). I successfully installed Django and fired up the
> dev server. Now, i got to the part in the walkthrough where i must edit the
> MySQL settings module and specify a user and password. I can log into MySQL
> via the command line and run whatever SQL i need to - however, once i edited
> the settings file and reloaded the Django welcome page, i'm getting an
> error: "*Error loading MySQLdb module: no module named MySQLdb*"
>
> I then Googled about and found the modules at Sourceforge. There does not
> seem to be a 32bit one for Python 2.5 - please advise? I am also wondering
> whether the module should be unzipped into the MySQL bin folder (tried that
> with the 64 bit one and aded the bin folder to the PATH variable. No
> success).
>
> --
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.com
>



-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




MySQLdb module for Python 2.5 on Windows XP

2009-12-15 Thread OkaMthembo
Hi guys,

I'm a Django noob and am having a few hair-raising experiences (maybe it's
because i'm on Windows?). I successfully installed Django and fired up the
dev server. Now, i got to the part in the walkthrough where i must edit the
MySQL settings module and specify a user and password. I can log into MySQL
via the command line and run whatever SQL i need to - however, once i edited
the settings file and reloaded the Django welcome page, i'm getting an
error: "*Error loading MySQLdb module: no module named MySQLdb*"

I then Googled about and found the modules at Sourceforge. There does not
seem to be a 32bit one for Python 2.5 - please advise? I am also wondering
whether the module should be unzipped into the MySQL bin folder (tried that
with the 64 bit one and aded the bin folder to the PATH variable. No
success).

-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: can any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 chiranjeevi muttoju :
> hey i installed django on one machine, and sql in another machine.. in which
> mechine i need to install the sql connector.

The Django machine.

-- 
Cheers,
Simon B.

--

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




Re: can any on help me how to create a sample model project.

2009-12-15 Thread chiranjeevi muttoju
hey i installed django on one machine, and sql in another machine.. in which
mechine i need to install the sql connector.

On Tue, Dec 15, 2009 at 7:51 PM, Simon Brunning wrote:

> 2009/12/15 chiranjeevi muttoju :
> > i've downloaded the mysql connector "MySQL-python-1.2.3c1.tar.gz'
> > could u please tellme how to instal that in linux..
>
> If you untar it, you should find installation instructions in the README.
>
> --
> Cheers,
> Simon B.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>


-- 
▒▒�...@g@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: can any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 chiranjeevi muttoju :
> i've downloaded the mysql connector "MySQL-python-1.2.3c1.tar.gz'
> could u please tellme how to instal that in linux..

If you untar it, you should find installation instructions in the README.

-- 
Cheers,
Simon B.

--

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




Re: can any on help me how to create a sample model project.

2009-12-15 Thread chiranjeevi muttoju
i've downloaded the mysql connector "MySQL-python-1.2.3c1.tar.gz'
could u please tellme how to instal that in linux..

On Tue, Dec 15, 2009 at 7:36 PM, Simon Brunning wrote:

> 2009/12/15 chiranjeevi muttoju :
> > i cont able to understand how to modify the settings for mysql..
> > when i run the cammand 'python manage.py shell'
> > it gives the error no modulr fing for No module named MySQLdb
>
> You've not installed the database module that Python needs to talk to
> MySql - see .
>
> --
> Cheers,
> Simon B.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>


-- 
▒▒�...@g@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Complicated Form "Workflow" - Need ideas/direction

2009-12-15 Thread DrBloodmoney
When I run into similar situations with regards to flow,  interface, I try
to approach from a different angle.

In this case, where you have different checks (before they can create an
Event, the venue must exist, etc.) I line those up first.
- Create event view, select Venue.
- If venue does not exist, take to Add Venue view. Once completed, redirect
to Create Event View, etc.

On Dec 15, 2009 8:51 AM, "Baurzhan Ismagulov"  wrote:

On Tue, Dec 15, 2009 at 05:18:56AM -0800, derek wrote: > If you are serious
about doing this, you ma...
Thanks for the info, an interesting concept.

I personally have no problems with representing a web app as a state
machine, so continuations are for me too far an abstraction.

With kind regards, -- Baurzhan Ismagulov

http://www.kz-easy.com/ -- You received this message because you are
subscribed to the Google Grou...

--

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




Re: can any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 chiranjeevi muttoju :
> i cont able to understand how to modify the settings for mysql..
> when i run the cammand 'python manage.py shell'
> it gives the error no modulr fing for No module named MySQLdb

You've not installed the database module that Python needs to talk to
MySql - see .

-- 
Cheers,
Simon B.

--

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




Re: can any on help me how to create a sample model project.

2009-12-15 Thread chiranjeevi muttoju
i cont able to understand how to modify the settings for mysql..
when i run the cammand 'python manage.py shell'
it gives the error no modulr fing for No module named MySQLdb

the actual error is::
---
[r...@scci01 book]# python manage.py shell
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File
"/usr/local/lib/python2.6/site-packages/django/core/management/__init__.py",
line 362, in execute_manager
utility.execute()
  File
"/usr/local/lib/python2.6/site-packages/django/core/management/__init__.py",
line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/usr/local/lib/python2.6/site-packages/django/core/management/base.py",
line 195, in run_from_argv
self.execute(*args, **options.__dict__)
  File
"/usr/local/lib/python2.6/site-packages/django/core/management/base.py",
line 222, in execute
output = self.handle(*args, **options)
  File
"/usr/local/lib/python2.6/site-packages/django/core/management/base.py",
line 351, in handle
return self.handle_noargs(**options)
  File
"/usr/local/lib/python2.6/site-packages/django/core/management/commands/shell.py",
line 17, in handle_noargs
from django.db.models.loading import get_models
  File "/usr/local/lib/python2.6/site-packages/django/db/__init__.py", line
41, in 
backend = load_backend(settings.DATABASE_ENGINE)
  File "/usr/local/lib/python2.6/site-packages/django/db/__init__.py", line
17, in load_backend
return import_module('.base', 'django.db.backends.%s' % backend_name)
  File "/usr/local/lib/python2.6/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
  File
"/usr/local/lib/python2.6/site-packages/django/db/backends/mysql/base.py",
line 13, in 
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module:
No module named MySQLdb


---

On Tue, Dec 15, 2009 at 7:19 PM, Simon Brunning wrote:

> 2009/12/15 'chiru'tha :
> > hey i've seen dat.. bt i cont able to create a new one.. i'm doing
> > some mistake while setting settings. If u createed a project.. plz
> > tell me the process in detail.. plz.
> > thanku..
>
> Sorry, but that *is* the process.
>
> Why don't you tell us what went wrong? Perhaps we can help.
>
> --
> Cheers,
> Simon B.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>


-- 
▒▒�...@g@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Inventory model design

2009-12-15 Thread yummy_droid
Hi,

I wanted to design a system that would keep inventory data for items.
The items themselves are different enough, that they don't conform to
a simple model.

E.g., the products are for a bakery company. The company keeps
inventory of solid items, liquid items, and items that are used in
partial quantities. Each has its own properties, some have volume,
some have wieght, some have length, etc.

So, should I try to create a base "Item" model, which common
attributes like name and vendor_id, and then have a one-to-many
relationship to a table which you can add custom fields/value pairs.
(i would like to be able to choose a "category" when creating a new
item, and have the form automatically show the fields for that item).

Or, should I go about creating a base "Item" class, and then subclass
it for each category of item?

My main concern is that the system is built in such a way that we can
easily create future reports across all the inventory database (e.g.
what is the time any item has been in the store room, price of
inventory of same type for all items, etc.), without having to worry
about the way we implemented the models.\

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Complicated Form "Workflow" - Need ideas/direction

2009-12-15 Thread Baurzhan Ismagulov
On Tue, Dec 15, 2009 at 05:18:56AM -0800, derek wrote:
> If you are serious about doing this, you may want to look at what has
> been "invented" elsewhere.  The one example I know of (and have used)
> is Apache Cocoon's flow model:
> http://cocoon.apache.org/2.1/userdocs/flow/continuations.html
> 
> Worth reading around ideas/concepts.

Thanks for the info, an interesting concept.

I personally have no problems with representing a web app as a state
machine, so continuations are for me too far an abstraction.

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




django and MSSQL

2009-12-15 Thread miocn
Help: django + mssql

the old system to add some content, the database is MSSQL 7.0, I
intend to use django 1.1, feasible? Django 1.1 and MSSQL How do I
connect??

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: can any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 'chiru'tha :
> hey i've seen dat.. bt i cont able to create a new one.. i'm doing
> some mistake while setting settings. If u createed a project.. plz
> tell me the process in detail.. plz.
> thanku..

Sorry, but that *is* the process.

Why don't you tell us what went wrong? Perhaps we can help.

-- 
Cheers,
Simon B.

--

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




Re: can any on help me how to create a sample model project.

2009-12-15 Thread 'chiru'tha
hey i've seen dat.. bt i cont able to create a new one.. i'm doing
some mistake while setting settings. If u createed a project.. plz
tell me the process in detail.. plz.
thanku..

On Dec 15, 6:25 pm, Simon Brunning  wrote:
> 2009/12/15 'chiru'tha :
>
> > hi..
> > I'm new to Django, i need it in my project applications, can any one
> > guide me to create a new model project(using MySql database). plz give
> > the process in detail..
>
> http://lmgtfy.com/?q=django+tutorial
>
> --
> Cheers,
> Simon B.

--

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




Re: can any on help me how to create a sample model project.

2009-12-15 Thread Simon Brunning
2009/12/15 'chiru'tha :
> hi..
> I'm new to Django, i need it in my project applications, can any one
> guide me to create a new model project(using MySql database). plz give
> the process in detail..

http://lmgtfy.com/?q=django+tutorial

-- 
Cheers,
Simon B.

--

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




Re: Complicated Form "Workflow" - Need ideas/direction

2009-12-15 Thread derek
Baurzhan

If you are serious about doing this, you may want to look at what has
been "invented" elsewhere.  The one example I know of (and have used)
is Apache Cocoon's flow model:
http://cocoon.apache.org/2.1/userdocs/flow/continuations.html

Worth reading around ideas/concepts.

Derek

On Dec 14, 11:04 pm, Baurzhan Ismagulov  wrote:
> On Mon, Dec 14, 2009 at 12:17:31PM -0800, Almost George wrote:
> > An Attendee, being added to an Event, must already exist in the
> > system. If the given Attendee doesn't exist, the user should be
> > prompted to create it/them (validly) before continuing further.
>
> > Likewise when selecting the Event Venue - if it doesn't exist, it must
> > be created.
>
> > Of particular note, Venues have some required meta-information that
> > must be filled out before it can be considered valid.
>
> > That's quite a bit of "add and/or create+validate", and I'm not sure
> > how to implement that. I'm assuming I'll be using the Form Wizards,
> > but at this point I'm just not sure where to start.
>
> This is implemented in admin using popups, your easiest way would be to
> copy / reuse that.
>
> I'll have to work on a solution without popups in order to have:
>
> 1. A single browser window, to avoid user confusion if you have nested
>    ForeignKeys (admin opens a popup for each).
>
> 2. Pagination / filtering, since admin's  controls don't scale
>    if you have anything more than a dozen of Attendees.
>
> I've looked into form wizards for that, but I don't think they are
> flexible enough. First, if you already have an Attendee, I couldn't find
> a way to skip that form. Second, the state is held in the POST requests.
> The advantage is that a user may open several browser windows and use
> different forms with complex workflows. The disadvantage is POST -- if
> you want POST-redirect-GET to avoid some of the issues with back /
> refresh (I'm using 1.0; you might want to look 
> athttp://code.djangoproject.com/ticket/9200).
>
> So, ATM I think we need a "workflow engine", which would display forms
> with PRG and hold intermediate data and "return stack" in sessions. I've
> scribbled together a couple of lines (not general, and nothing working
> yet); the problem with my design is, it will always have its
> limitations. For instance, if the user opens two browser windows and
> would add two new Events, continuing in another window at an
> "unfavorable" moment may result in a mess, although one may always
> customize that for one's needs. Another hurdle was pickling the form
> data into the session; I've skimmed through #9200 for that, but couldn't
> find how it does that yet.
>
> If anyone has code or ideas, I'd like to hear about that, too.
>
> With kind regards,
> --
> Baurzhan Ismagulovhttp://www.kz-easy.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




can any on help me how to create a sample model project.

2009-12-15 Thread 'chiru'tha
hi..
I'm new to Django, i need it in my project applications, can any one
guide me to create a new model project(using MySql database). plz give
the process in detail..

OS-- read hat
DB:mysql5
python2.6
Django-1.1.1


thanku..

--

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




Caching pages that take a long time to generate

2009-12-15 Thread Tom Evans
Hi all

(This is all running django 1.1.1)

On our site, we have a lot of pages that take a long time to generate,
mainly because they make a lot of expensive SOAP-like calls to other
servers. Some of the pages take exceptionally long periods of time (>
30 seconds) to generate a full web page. In order to output these
responses reliably, we use iterator objects to output the content of
the page bit by bit, eg:

def iterator_resp(request):
  def worker():
yield "Hello"
yield " "
yield "world"
  return HttpResponse(worker())

Since these pages take such a long time to generate, ideally we would
like to cache the generated content for the next time it is requested,
however it seems that any attempt to cache that view with the
@cache_page decorator is doomed to fail.

The first problem occurs when the UpdateCacheMiddleware runs it's
process_response() phase, it calls
django.utils.cache.patch_response_headers(), which consumes the
generator function trying to calculate an MD5 sum of the contents for
an ETag. This leads to the generator being exhausted when we come to
output the response, and we get an empty response.

This can be avoided by setting a manual ETag on the response, but in
this case python refuses to pickle the response object, since
generator objects are not picklable.

I figure that this sort of caching should definitely be possible, so I
wrote a small patch to UpdateCacheMiddleware to notice when we are
supplying an iterable response, and then create a duplicate
HttpResponse, with a proxy generator that reads from the original
response, writing each chunk to a buffer and yield'ing it also to the
response. Once the original response is drained, I create another
response with the buffered content, and this response can be put into
the cache.

Obviously, there are trade-offs here - if you want to cache a 50MB
page, you've got to be prepared to buffer 50MB - but is this the right
sort of approach to take? Is there a better way of achieving similar
results? I feel quite uncomfortable poking at the inside of
HttpResponse - looking at HttpResponse::_is_string in particular!

Cheers

Tom

--

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


Index: cache.py
===
--- cache.py(revision 147298)
+++ cache.py(working copy)
@@ -91,7 +91,21 @@
 patch_response_headers(response, timeout)
 if timeout:
 cache_key = learn_cache_key(request, response, timeout, 
self.key_prefix)
-cache.set(cache_key, response, timeout)
+if response._is_string:
+  cache.set(cache_key, response, timeout)
+else:
+  from django.http import HttpResponse
+  def worker(rsp):
+from cStringIO import StringIO
+buf = StringIO()
+for chunk in rsp:
+  buf.write(chunk)
+  yield chunk
+buffered_response = HttpResponse(buf.getvalue())
+buf.close()
+rsp.close()
+cache.set(cache_key, buffered_response, timeout)
+  return HttpResponse(worker(response))
 return response
 
 class FetchFromCacheMiddleware(object):


how to get the list_display properly?

2009-12-15 Thread Viktor
hi,

I've just noticed that even the contrib apps' admin interface is bogus
in django 1.1

namely, the first column name should be the "check all" checkbox,
instead that column receives a the first header of list_display, and
finally the last column does not have a header.

is this really a bug?

thanks for your help,
Viktor

--

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




Re: Testing Django applications

2009-12-15 Thread Jonas Obrist
HB wrote:
> Hey,
> Grails framework offers a huge set of tools to facilitate testing
> (unit and integration)
> I heard the same thing is true for Rails
> Does Django offers the same thing?
> Thanks.
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>   
Python comes with several ways of doing unit testing, read the django 
docs on this topic: 
http://docs.djangoproject.com/en/1.1/topics/testing/#topics-testing

Also the development server in Django is a brilliant way to test your 
app without having to set up a full blown apache.

--

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




Testing Django applications

2009-12-15 Thread HB
Hey,
Grails framework offers a huge set of tools to facilitate testing
(unit and integration)
I heard the same thing is true for Rails
Does Django offers the same thing?
Thanks.

--

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




Re: Understanding of File Upload in Django

2009-12-15 Thread David De La Harpe Golden
sjtirtha wrote:

> But what I understand from the documentation is uploading and saving are two
> different processes. How can I trigger the saving then?
> 


First, certainly, when a file is uploaded from a client, django puts it
somewhere *temporary* initially. You may have conceptualised that as
"saving", but remember it's only an initial temporary location - either
in a pseudofile in RAM or on disk (settings.FILE_UPLOAD_TEMP_DIR), with
a size based cutoff (settings.FILE_UPLOAD_MAX_MEMORY_SIZE, 2.5MByte by
default) to decide which.  Either way, this temporary UploadedFile
"looks like" a file to python code, and you can see it in request.FILES
in the view and treat it like a (temporary!) file.

If you just used a plain Form with a forms.FileField, you're pretty much
on your own now.  Do what you want with the UploadedFile, very probably
save it off somewhere more permanent of your choosing.
That's what the page you were looking at covers.

/However/ there's _extra_ support for "files as model fields" in
django's ORM layer (models) - for models.FileField, when you save a
model instance, a filename reference is stored in the DB while the file
is stored on the filesystem in a more permanent predefined location
(under MEDIA_ROOT to facilitate serving the file back out statically).

So if you've used a models.FileField on a _model_ and a ModelForm
generated from it, you can use .save()  .  That will save the
UploadedFile to your defined permanent location for model files.
http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to





--

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




Using Forms to display and edit?

2009-12-15 Thread Doug Blank
Django users,

I'm wrestling with how to best create HTML pages that can either be
used for displaying or editing data. That is, I'd like the field's
values to appear as text in display mode, but in their widgets when in
edit/add mode. It appears that Django wasn't designed to do this: the
fields always appear in their widgets (eg, text input, text area,
etc).

Is there a common technique for handling this, short of using forms
for one, and not the other?

I was thinking of a custom templatetag filter that could be used for
every form field, like:

{{ form.field_name|render_field:mode }}

where render_field would either return the field's HTML widget, or
just the value as text, based on the mode.

Have I missed something, or is this a viable solution?

-Doug

--

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




Re: Cron vs event triggered action

2009-12-15 Thread David De La Harpe Golden
Tim Daniel wrote:

> So how can I implement solution B? Is there a posibility to create a
> cron on a user action that executes only one time?
> 
> NOTE: I don't want to rely on a thread that should stay alive for two
> hours ore more inside the server memory.


Well, celery uses a "celeryd" daemon process and a message queue, so
that is a thread staying alive om the server, but it's a completely
separate and manageable process from your web server:

http://ask.github.com/celery/introduction.html

It may look a little complex, but it really makes all sorts of long
running and scheduled tasks easy and well-integrated with django.

FWIW, doing something two hours after some event is basically a one-liner:
http://ask.github.com/celery/userguide/executing.html#eta-and-countdown


--

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




Re: ORM using tons of memory and CPU

2009-12-15 Thread bruno desthuilliers
On 15 déc, 02:44, Tracy Reed  wrote:
> I have code which looks basically like this:
>
> now        = datetime.today()
> beginning  = datetime.fromtimestamp(0)
> end        = now - timedelta(days=settings.DAYSTOKEEP)
>
> def purgedb():
>     """Delete archivedEmail objects from the beginning of time until
>     daystokeep days in the past."""
>     queryset   = archivedEmail.objects.all()
>     purgeset   = queryset.filter(received__range=(beginning, end))
>     for email in purgeset:
>         print email
>         try:
>             os.unlink(settings.REAVER_CACHE+"texts/%s"     % email.cacheID)
>             os.unlink(settings.REAVER_CACHE+"prob_good/%s" % email.cacheID)
>             os.unlink(settings.REAVER_CACHE+"prob_spam/%s" % email.cacheID)
>         except OSError:
>             pass
>     purgeset.delete()
>
> if __name__ == '__main__':
>     purgedb()
>
(snip)

> But when purgedb runs it deletes emails 100 at a time (which takes
> forever) and after running for a couple of hours uses a gig and a half
> of RAM. If I let it continue after a number of hours it runs the
> machine out of RAM/swap.

looks like settings.DEBUG=True to me.

> Am I doing something which is not idiomatic or misusing the ORM
> somehow? My understanding is that it should be lazy so using
> objects.all() on queryset and then narrowing it down with a
> queryset.filter() to make a purgeset should be ok, right?

No problem here as long as you don't do anything that forces
evaluation of the queryset. But this is still redundant - you can as
well build the appropriate queryset immediatly.

> What can I
> do to make this run in reasonable time/memory?

Others already commented on checking whether you have settings.DEBUG
set to True - the usual suspects when it comes to RAM issues with
django's ORM.

wrt/ the other mentioned problem - building whole model instances for
each row - you can obviously save a lot of work here by using a
value_list queryset - tuples are very cheap.

Oh, and yes: I/O and filesystem operations are not free neither. This
doesn't solve your pb with the script eating all the RAM, but surely
impacts the overall performances.


Now for something different - here are a couple other python
optimisation tricks:

> for email in purgeset:
> print email

Remove this. I/O are not for free. Really.

> try:
> os.unlink(settings.REAVER_CACHE+"texts/%s" % email.cacheID)
> os.unlink(settings.REAVER_CACHE+"prob_good/%s" % email.cacheID)
> os.unlink(settings.REAVER_CACHE+"prob_spam/%s" % email.cacheID)
> except OSError:
> pass

Move all redundant attribute lookup (os.unlink and
settings.REAVER_CACHE) and string concatenations out of this loop.


def purgedb():
  """Delete archivedEmail objects from the beginning of time until
daystokeep days in the past.
  """
  text_cache = settings.REAVER_CACHE + "texts/%s"
  prob_good_cache = settings.REAVER_CACHE+"prob_good/%s"
  prob_spam_cache = settings.REAVER_CACHE+"prob_spam/%s"
  unlink = os.unlink

  # no reason to put this outside the function.
  now = datetime.today()
  beginning = datetime.fromtimestamp(0)
  end = now - timedelta(days=settings.DAYSTOKEEP)
  qs = archivedEmail.objects.filter(received__range=(beginning, end))

  for row in qs.value_list(cacheID):
cacheID = row[0]
try:
  unlink(text_cache % cacheID)
  unlink(prob_good_cache % cacheID)
  unlink(prob_spam_cache % cacheID)
except OSError:
  pass

  qs.delete()

Oh and yes, one last point : how do you run this script exactly ?

HTH

--

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




Re: Cron vs event triggered action

2009-12-15 Thread john2095
Just to throw it out there... forget about trying to make something
happen every ten minutes; or whatever your margin for error is.
Instead focus on just testing to see whether two hours have passed
when you come to use it. Either lazy (C), or diligent (D)...

Solution C:
Do nothing at all until someone comes asking for it: Have two hours
passed since the create_time? Yes. Trash. Sorry, you were too slow.

Solution D:
Every time someone comes asking for that object: Wait, let me just
trash everything i have which is over two hours old... ok. Now may I
help you? Oh, I'm sorry I don't have that anymore, maybe it expired.

(C) could lead to lots of dead stuff lying around whereas (D) could
lead to a lot of unnecessary overhead.
But for lightly loaded apps they'll do the job without the hassle.

Just for fun.

On Dec 13, 9:58 am, Tim Daniel  wrote:
> Just want to figure out if there is a smarter solution for handling
> the following problem:
>
> 1. An action is performed by a user (Normal django behaviour handling
> a request and giving a response).
> 2. Two hours later I want an automatic action to be done.
>
> Solution A: Have a datetime field with an expiry date and say every 10
> minutes a cron job checks the DB table for expired entries and
> performs the programed action.
>
> Solution B: Have an event triggered cronjob that only executes once
> and is created from Django(Python), after the 2 hours passed it
> performs the programmed action only on the required entry.
>
> So how can I implement solution B? Is there a posibility to create a
> cron on a user action that executes only one time?
>
> NOTE: I don't want to rely on a thread that should stay alive for two
> hours ore more inside the server memory.

--

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




Re: How to set attribute to the items in a QuerySet.

2009-12-15 Thread Daniel Roseman
On Dec 15, 7:02 am, Xuqing Kuang  wrote:
> Hi, all.
>
> Are there any way could keep a attribute new set to a item in QuerySet
> object ?
>
> For example:
>
> >>> tcs = TestCase.objects.filter(case_id__in = [1123, 1124, 1125])
> >>> tcs
>
> [, ,  MigrateOneWayDisk>]>>> tc = tcs[1]
> >>> setattr(tc, 'selected_param', [])
> >>> tc.selected_param
> []
> >>> tcs[1].selected_param
>
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'TestCase' object has no attribute 'selected_param'
>
> I wish to keep the a attribute to process the request data from web
> browser in the QuerySet data structure.
>
> Are there any solution ?
>
> Thanks.
>
> Xuqing

Evaluate the queryset first by calling list() on it:
tcs = list(TestCase.objects.filter(case_id__in = [1123, 1124, 1125]))

And you don't need to use setattr if you already have the name you
need to set, you can just set it directly:
tc.selected_param = []
setattr is mostly useful if the name of the attribute you want to set
is itself in a variable.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Understanding of File Upload in Django

2009-12-15 Thread john2095
I'm confident people will correct my mistakes...

A file is transferred from a web browser to a web server by breaking
it up into packets at the network layer. Each packet is part of the
file and you need the complete set of packets to recreate the whole
request, and thus the whole file.  Assuming you're using the default
backend, as each packet arrives it is placed into memory whilst we
wait for the rest of the packets to arrive.  This the uploading
process.

When all the packets of the HttpRequest have arrived and are in
memory. Then your code is executed and you can elect to do whatever
you like with the data sitting in memory, like write it to disk. That
would be the saving part.

But that was the default behaviour.  If you want something different
to happen, you can use a different backend, or even build your own
backend.  For example you won't have to look too far before finding a
backend which writes the "chunks" of the data directly to disk as they
arrive, rather than waiting for them to be marshalled in memory.

Whether you get preferred results by writing to memory or to disk is
entirely subjective upon your application and hardware.  If you expect
a lot of people to be uploading a lot of very large files
simultaneously, and your server has very little memory, then you might
find writing directly to disk is preferable; but the default is the
default because that works best for most subjects.


On Dec 14, 5:55 am, sjtirtha  wrote:
> Hi,
>
> can somebody explain me how file upload works in Django?
> I read this 
> documentation:http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
>
> And there is this part:
> ###
> Where uploaded data is
> stored¶
>
> Before you save uploaded files, the data needs to be stored somewhere.
>
> By default, if an uploaded file is smaller than 2.5 megabytes, Django will
> hold the entire contents of the upload in memory. This means that saving the
> file involves only a read from memory and a write to disk and thus is very
> fast.
>
> ###
>
> What does it mean by "saving the file involves only read from memory and a
> write to disk..."?
> I though uploading and saving a file are one process. When I upload a file
> by submiting my form it means it will also save the file somewhere.
>
> But what I understand from the documentation is uploading and saving are two
> different processes. How can I trigger the saving then?
>
> Regards,
>
> Steve

--

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




Re: Should empty formsets call their own clean method?

2009-12-15 Thread Tom Evans
On Fri, Dec 11, 2009 at 10:55 PM, Preston Holmes  wrote:
> Well something wonky is going on.
>
> From my readthrough of the code, it *should* get called on empty
> formsets:
>
> is_valid calls total_form_count to get a loop count
> total_form_count should be positive even if forms are blank
>
> is_valid then accesses form.errors inside that loop
> (django.forms.formsets.py 1.1.1 #237 if bool(self.errors[i]))
>
> accessing form.errors should run _get_errors()
> which calls full_clean()
> which calls clean()
>
> What about if you do
>
> formset3.is_valid()
>
> then
>
> formset3._errors
>
> this will access the current errors without triggering the full_clean
>
> If it is None - than validation is not triggering an access to the
> property function as it should
>
> -Preston
>

I don't see why total_form_count should be positive. The edge case is
for a formset with zero forms, not a formset with 'more than zero'
empty forms.
In this case, total_form_count will always be zero, the loop is never
entered, and the contract to validate/clean the formset when
Formset::is_valid() is called is ignored.

Cheers

Tom

--

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




Re: How to choose one row of data

2009-12-15 Thread Tom Evans
On Fri, Dec 11, 2009 at 6:25 PM, Andy  wrote:
> Tom - DR's method is simple and effective, but I'm guessing you say
> it's the worst way because it creates an unnecessary database
> request.  Is this a correct assumption?  If not, please explain.
>
>

There are at least 2 things wrong with it IMO:

1) Not using django's URL conf to generate the redirect URL. This
means that URL is hardcoded and duplicated.
2) Storing state unnecessarily in the session, ie, storing the current
order in the session. Once the order is created, we have a single
unambiguous URL to the order, that will not change. If you store it in
the session, you can only refer to that order by having the 'right
session'.

Cheers

Tom

--

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




Re: ORM using tons of memory and CPU

2009-12-15 Thread rebus_
2009/12/15 Tracy Reed :
>
> I have code which looks basically like this:
>
> now        = datetime.today()
> beginning  = datetime.fromtimestamp(0)
> end        = now - timedelta(days=settings.DAYSTOKEEP)
>
> def purgedb():
>    """Delete archivedEmail objects from the beginning of time until
>    daystokeep days in the past."""
>    queryset   = archivedEmail.objects.all()
>    purgeset   = queryset.filter(received__range=(beginning, end))

You don't need both queries (altghou they are lazy). You could just say:

purgeset = archivedEmail.filter(received__range=(beginning, end))


>    for email in purgeset:
>        print email
>        try:
>            os.unlink(settings.REAVER_CACHE+"texts/%s"     % email.cacheID)
>            os.unlink(settings.REAVER_CACHE+"prob_good/%s" % email.cacheID)
>            os.unlink(settings.REAVER_CACHE+"prob_spam/%s" % email.cacheID)
>        except OSError:
>            pass
>    purgeset.delete()
>
> if __name__ == '__main__':
>    purgedb()
>
> The idea is that we are stuffing a bunch of emails in a database for
> customer service purposes. I want to clear out anything older than
> DAYSTOKEEP. The model looks like this:
>
> class archivedEmail(models.Model):
>    subject     = models.CharField(blank=True, max_length=512, null=True)
>    toAddress   = models.CharField(blank=True, max_length=128, db_index=True)
>    fromAddress = models.CharField(blank=True, max_length=128, db_index=True)
>    date        = models.DateTimeField()
>    received    = models.DateTimeField(db_index=True)
>    crmScore    = models.FloatField()
>    spamStatus  = models.CharField(max_length=6, choices=spamStatusChoices, 
> db_index=True)
>    cacheHost   = models.CharField(max_length=24)
>    cacheID     = models.CharField(max_length=31, primary_key=True)
>
>    class Meta:
>        ordering = ('-received',)
>
> But when purgedb runs it deletes emails 100 at a time (which takes
> forever) and after running for a couple of hours uses a gig and a half
> of RAM. If I let it continue after a number of hours it runs the
> machine out of RAM/swap.
>
> Am I doing something which is not idiomatic or misusing the ORM
> somehow? My understanding is that it should be lazy so using
> objects.all() on queryset and then narrowing it down with a
> queryset.filter() to make a purgeset should be ok, right? What can I
> do to make this run in reasonable time/memory?
>
> PS: I used to have ordering set to -date in the class Meta but that
> caused the db to always put an ORDER BY date on the select query which
> was unnecessary in this case causing it to take ages sorting a couple
> million rows since there is no index on date (nor did there need to
> be, so I thought, since we never select on it). Changing it to
> received makes no difference to my app but avoids creating another
> index. Django's is the first ORM I have ever used and these sneaky
> performance issues are making me wonder...
>
> --
> Tracy Reed
> http://tracyreed.org
>


When you execute a query set that operates on millions of rows you
should remember that ORM will create a python object for each row.
This could take a while. Though i am not sure how it handles memory
issues.

You could issue plain SQL query which returns result as tuple (only
returning cache ID for example) and might be faster if you don't
really need ORM, then loop through the tuple and delete files on disk.
I think this should use less memory and processing time.

Also, I am not SQL guru but i guess BETWEEN should work on most DB
servers so you should not have portability issues (but i cant
guarantee this).

Don't use try ... except for checking if the file exists. Rather use
"if" statement with os.path.exists or os.path.isfile and if it does
exist delete the file. Exceptions are expensive in CPython.

Read this topic about deleting objects in bulk (though i think you
already have it never hurts to refresh your memory).

http://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects

Just my 2 cents

Davor

--

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




I have updated the django and firebird install guide on ubuntu

2009-12-15 Thread mariuz
I’m impressed about the new django-firebird driver from svn.No more
patching needed for the first 5 chapters in the django book.
So i have updated django+firebird howto and examples from the book are
tested with django 1.1.1 and firebird-django latest
http://www.firebirdnews.org/?p=3891

--

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




Re: Hey can any one help me.

2009-12-15 Thread Javier Guerra
'chiru'tha wrote:
> Hey i created a django project on linux read hat, and started the
> server.. now i want to access the server from the windows browser. bt
> it displays the diagnostic error, cont be able to connect to the
> server. can any one help me what the actual problem is..
>  thank u.

by default the development server listens only on 127.0.0.1, that's the 
local-only interface.

use "manage.py 0.0.0.0 80" to make it listen on all interfaces

-- 
Javier

--

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