Re: SystemError from django.conf.settings

2011-05-30 Thread Ian Clelland
On Sat, May 28, 2011 at 10:50 PM, Cameron wrote:

> So I have this stack trace on my production server. I can't reproduce
> it locally and it doesn't occur with an older version of the same site
> deployed on the same server.
>
> Traceback (most recent call last):
>  File "./dependencies/django/core/handlers/wsgi.py", line 222, in
> __call__
>from django.conf import settings
> SystemError: ../Objects/tupleobject.c:118: bad argument to internal
> function
>


> 1. Anyone seen this before? The only other reference that I can find
> to that line of python is here (http://bugs.debian.org/cgi-bin/
> bugreport.cgi?bug=581626)
>

I've never seen this before. Looking at the Python source (you mentioned
that you're running 2.5.2 from Debian lenny,) this looks to me like it has
to be an error in a C module somewhere -- probably a third-party module, but
it's possible it's in the Python core somewhere.

The line itself is a sanity check in PyTuple_SetItem, which shouldn't even
be available to Python code (tuples are supposed to be immutable, right?) It
would only get triggered if it got called somehow with an argument that
wasn't actually a tuple, or with a tuple for which another reference existed
somewhere (besides in the initializing code).


>
> 2. Any tips on how I can find out what has changed to cause it? Aside
> from rolling back through weeks of revisions to find what triggered
> it.
>

If it's happening on settings import, then try importing settings manually
from a python shell. You may see more of a stacktrace that way. If you still
get the error, but can't pinpoint the failing line, then try running it
through the debugger, and step from line to line until you see it. If you're
lucky, there will be call to a function in an external module that triggers
it, and you'll be able to narrow the possibilities down to that one module.

Failing that, a binary search through weeks or even months of revisions
should only take O(lg n) time -- a small consolation, but searching weeks of
development is only a couple of iterations more than searching a few days.


> 3. I am about to try upgrading python to a newer version, is that
> likely to make any difference? I have already tried 2 different
> versions of uwsgi (0.9.6.8 and 0.9.7.2), but I don't want to mess
> around with the production environment too much, or risk breaking the
> live sites.
>

If the error is in one of the python core modules, then it may have been
fixed recently; but I haven't seen any reports of failures in tupleobject.c
other than the Trac bug that you turned up. See if there are any other
compiled modules in the system that you can update first.


-- 
Regards,
Ian Clelland


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



SEND_BROKEN_LINK_EMAILS = True not sending email

2011-05-30 Thread Addy Yeow
Is SEND_BROKEN_LINK_EMAILS = True working for you guys?

I am using Django 1.2.5. I have view function that raise Http404 when object
is not found but I am not receiving the email
despite SEND_BROKEN_LINK_EMAILS = True in my settings.py. I do receive email
for HTTP500 though.

-- 
http://www.dazzlepod.com . http://twitter.com/dazzlepod
We write elegant and minimal apps that works. We develop web apps with
Django framework.

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



Can I perform an "alter table" to remove a "not null" constraint?

2011-05-30 Thread Gchorn
It seems as though the default in Django when creating tables is to
place a constraint that doesn't allow null values (contrary to what
I've learned is the default for SQL in general).  I have a model which
has a date attribute, and which I now want to be able to hold null
values, but when I tried doing this by adding 'null = True' and 'blank
= True' to the model's field options, Django generates a

model.date may not be NULL

error when I try to leave the field blank in the Django admin
interface.  This suggests I need to change something about the
database, rather than the model, correct?  If so, what is the SQL
syntax for doing this?  My research online has only turned up how to
apply a "not-null" constraint on a database table when creating the
table, not how to remove a "not-null" constraint on a table after it's
been created.  Thanks in advance for any help on this!

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



Re: admin site search field

2011-05-30 Thread Anoop Thomas Mathew
Hi,
Did you notice you are missing closing quote ' in the search fields???

Regards,
Anoop
On 31 May 2011 04:54, "podio"  wrote:
> Hi, I'm new and I'm trying to make an app that have a field, pointing
> to a record of the same object class. How can a make django has a
> search form and show the record of the class on a popup window like
> http://demoweb.cibernatural.com/admin/gestion/presupuesto/add/ (user
> and password demo:demo) but pointing to the same class
>
>
> class afiliado(models.Model):
> def __unicode__(self):
> return self.nombre
> nombre = models.CharField("Nombre",max_length=200)
> fecha_nac = models.DateField("Fecha Nacimiento")
> doc = models.CharField("Documento",max_length=20,blank =True)
> obra_social = models.ForeignKey(obra_sociale)
> caracter = models.ForeignKey(caractere)
> tipo = models.ForeignKey(tipo)
> titular = models.CharField(max_length=200) > this
> field
>
>
> class AfiliadoAdmin(admin.ModelAdmin):
> fieldsets = [
> (None ,{'fields':
> ['nombre','fecha_nac','DOCN','Nacionalidad']}),
> ('Datos Generales' ,{'fields':
> ['obra_social','caracter','tipo',"titular",'Matricula','fecha_ing']}),
> ('Datos de contacto',{'fields':
> ['Direccion',"CP","Ciudad","Provincia","Tel1","Tel2","Email"]}),
> ]
> list_display = ('nombre',"tipo")
> list_filter = ['Ciudad']
> search_fields = ['nombre','doc]
>
>
> Thansk!
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: No style sheets with DEBUG = False?

2011-05-30 Thread Karen Tracey
On Mon, May 30, 2011 at 9:56 PM, Roy Smith  wrote:

>
> Any clue what might be causing the style sheets not to load with DEBUG
> = False?
>
>
https://docs.djangoproject.com/en/1.3/ref/contrib/staticfiles/#static-file-development-view

Karen
-- 
http://tracey.org/kmt/

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



No style sheets with DEBUG = False?

2011-05-30 Thread Roy Smith
If I set:

DEBUG = False

in my settings.py file, my site runs and produces the correct HTML,
but there's no style sheets loaded.  Even stranger, if I save the HTML
generated each way into files and compare them, they're identical!

Any clue what might be causing the style sheets not to load with DEBUG
= False?

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



how to implement a data grid? (or populate inlineformset with initial data)

2011-05-30 Thread snfctech
I want to display a list of records that have some editable fields and
some readonly fields, as well as asynchronously add new records to the
list.  I thought the way to start would be with an InlineFormSet - but
I can't figure out how to populate my formset with initial data.  E.g.
MyInlineFormset(queryset=myquery.all()) or
MyInlineFormset(data=myquery.vales()) doesn't do the trick.

Can someone steer me in the right direction?

Thanks.

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



Re: Is there an HTML editor that's Django-aware

2011-05-30 Thread Mike Dewhirst

On 30/05/2011 11:41pm, Jacob Kaplan-Moss wrote:

On Monday, May 30, 2011, BobX  wrote:

If anyone from the Django Project itself is listening then can I (very
humbly) suggest that some editor recommendations would make a real
fine addition to the info on the site (useful to n00b's like me
anyway).

That's a good idea - thanks!

Where do you think such information should live?


Are you thinking that learning a new editor at the same time as learning 
django might be a burden?


Perhaps listing available django add-ons to all the popular existing 
editors would be worthwhile.  Then people could stay with the tool their 
fingers are comfortable with.


In fact the discussions here about editors every few weeks indicates 
there might be plenty of energy to sustain a django tools website! 
Evangelists could post their own add-ons.


Mike


That is, at what
point in your process of learning Django would information about
editors have been helpful? Somewhere in the tutorial, or after?
Before?

Thanks,

Jacob



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



admin site search field

2011-05-30 Thread podio
Hi, I'm new and I'm trying to make an app that have a field, pointing
to a record of the same object class. How can a make django has a
search form and show the record of the class on a popup window like
http://demoweb.cibernatural.com/admin/gestion/presupuesto/add/ (user
and password demo:demo) but pointing to the same class


class afiliado(models.Model):
def __unicode__(self):
return self.nombre
nombre = models.CharField("Nombre",max_length=200)
fecha_nac  = models.DateField("Fecha Nacimiento")
doc = models.CharField("Documento",max_length=20,blank =True)
obra_social = models.ForeignKey(obra_sociale)
caracter = models.ForeignKey(caractere)
tipo = models.ForeignKey(tipo)
titular = models.CharField(max_length=200) > this
field


class AfiliadoAdmin(admin.ModelAdmin):
fieldsets = [
(None   ,{'fields':
['nombre','fecha_nac','DOCN','Nacionalidad']}),
('Datos Generales'  ,{'fields':
['obra_social','caracter','tipo',"titular",'Matricula','fecha_ing']}),
('Datos de contacto',{'fields':
['Direccion',"CP","Ciudad","Provincia","Tel1","Tel2","Email"]}),
]
list_display = ('nombre',"tipo")
list_filter = ['Ciudad']
search_fields = ['nombre','doc]


Thansk!

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



Re: Is there an HTML editor that's Django-aware

2011-05-30 Thread AJ
If I can give my $0.02, the content can live anywhere, but how about at
least a link to the content within the initial "setting up django
environment' section?

This way those who are just beginning programming and Django can know what
do they need to do and what are the pros and cons of an editor/ide upfront.


On Mon, May 30, 2011 at 9:41 AM, Jacob Kaplan-Moss wrote:

> On Monday, May 30, 2011, BobX  wrote:
> > If anyone from the Django Project itself is listening then can I (very
> > humbly) suggest that some editor recommendations would make a real
> > fine addition to the info on the site (useful to n00b's like me
> > anyway).
>
> That's a good idea - thanks!
>
> Where do you think such information should live? That is, at what
> point in your process of learning Django would information about
> editors have been helpful? Somewhere in the tutorial, or after?
> Before?
>
> Thanks,
>
> Jacob
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
AJ

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



Re: Learning Django: Approach / Advice / Resources

2011-05-30 Thread Mike Dewhirst

Robin

Don't worry - your mother is probably right.

Here are my "rules" ...

1. Dive into Python 3 rocks

2. Read "Practical Django Projects"(*) or if you decide against that get 
yourself a small-ish concrete target and avoid extraneous functionality 
like the plague. Then when it is working look for other people's open 
source django apps to plug in and widen the scope with more functionality.


This is the core of my suggestion. If you keep your own portion of your 
next website really tiny and as simple as necessary it will be much 
easier to refactor for more elegance and better performance in future. 
Adopting this approach forces you to learn how everyone else does it.


I think your problem is that you want to achieve too much at once. The 
more experience you get the narrower the focus your apps have. The less 
each does the better. That takes courage and practice and makes unit 
testing much easier.


I also believe the django core team are arguing a false benefit for 
django - flexibility. Sure you can do it any way you like but that is no 
help for beginners. It only scores points off rails people and they 
aren't coming to django in numbers which could ever match beginners 
choosing between rails and django.


Flexibility is a later benefit absolutely essential when you run into a 
brick wall and is one of the main reasons experienced developers choose 
django.


The real genius of django is a system which lets heaps of applications 
collaborate in a single website.


* James Bennett - but don't even think of downloading his example code. 
Write your own as you read along.


My 2 cents

Mike

On 31/05/2011 5:30am, Robin wrote:

A little while ago, I was approached about building a basic web site
for a small store.  The requirements were pretty typical and read like
a menu of web development tutorials.  This was to be a data driven
site that any decent web developer could build.  I, however, am not a
web developer, decent or otherwise.  So, I turned the assignment down
and decided it's time I looked into learning something about web
development.

I looked at everything from ASP to Java to PHP and even the likes of
Drupal and Joomla.  I liked the ideas and patterns behind Django as a
framework ( MVC = :) ) and Python as a language.  The combination
seemed like perfect middle ground to me.  Things were going well as I
worked through the tutorial and explored the documentation to dig
deeper into core Django topics.  Where am I today?

I'm struggling a bit with Django, to be honest.  Or maybe I'm
struggling with Python, I'm not completely certain which.  Maybe it's
because I'm trying to learn web development and Python at the same
time.  I'm certainly no genius, but I'm not a bonehead either...at
least my mother doesn't think so. ;)

The individual technical ideas are presented well and I can always
find enough information to learn more.  But Django as a whole feels
less cohesive.  Or maybe it's that Django sometimes feels...TOO
flexible?  There are certainly a lot of choices in terms of how much
Django to use and how much to roll yourself.  Guidance seems to be
offered on a per-module basis.  Maybe that's just how it is and I'm
looking for structure where there is none available.

I'm not sure what to override...when to call the super classes
corresponding method.  Do I have to concern myself with the test
cookie idea?  Should I name my URLs?  Is mixing positional and keyword
arguments OK?  Are generic views the best way, or just the quickest
way?

I guess it boils down to a concern over making poor choices and
learning bad habits.  If I'm going to spend any amount of time with
this web development hing, I want to do it right.  I'm also fighting
my urge to build everything myself.  Sure it would be plenty flexible,
but it would also take longer and wouldn't leverage the great work
done by all of Django's contributors.

So, what am I rattling on about then?

Judging by some of the posts I've read since joining the group, I'm
sure there are a bunch of folks who would appreciate some guidance
and / or best practices from the more experienced Django developers.
I understand everyone learns and progresses differently, but I would
really appreciate your take on things.

How much do you use built in Django functionality?  Are there
components you tend to avoid?  Do you use Django only for certain
types of projects?  Do you struggle with Python or Django?  Is the
source code a good place to spend some time?  Is your authentication
system home-grown?  Have you been bitten in the behind by using too
much Django?  Not enough?

I realize this is a lot to ask, but I think it's a good thing that we
help newer developers do things the right way.  I certainyl want to
become a contributing member of this group, but not until I won't give
bad advice and flat out wrong answers. ;)

I've gone through a good chunk of the Django Book online.  Is this a
good resource or do you have other recommendations?  There 

Learning Django: Approach / Advice / Resources

2011-05-30 Thread Robin
A little while ago, I was approached about building a basic web site
for a small store.  The requirements were pretty typical and read like
a menu of web development tutorials.  This was to be a data driven
site that any decent web developer could build.  I, however, am not a
web developer, decent or otherwise.  So, I turned the assignment down
and decided it's time I looked into learning something about web
development.

I looked at everything from ASP to Java to PHP and even the likes of
Drupal and Joomla.  I liked the ideas and patterns behind Django as a
framework ( MVC = :) ) and Python as a language.  The combination
seemed like perfect middle ground to me.  Things were going well as I
worked through the tutorial and explored the documentation to dig
deeper into core Django topics.  Where am I today?

I'm struggling a bit with Django, to be honest.  Or maybe I'm
struggling with Python, I'm not completely certain which.  Maybe it's
because I'm trying to learn web development and Python at the same
time.  I'm certainly no genius, but I'm not a bonehead either...at
least my mother doesn't think so. ;)

The individual technical ideas are presented well and I can always
find enough information to learn more.  But Django as a whole feels
less cohesive.  Or maybe it's that Django sometimes feels...TOO
flexible?  There are certainly a lot of choices in terms of how much
Django to use and how much to roll yourself.  Guidance seems to be
offered on a per-module basis.  Maybe that's just how it is and I'm
looking for structure where there is none available.

I'm not sure what to override...when to call the super classes
corresponding method.  Do I have to concern myself with the test
cookie idea?  Should I name my URLs?  Is mixing positional and keyword
arguments OK?  Are generic views the best way, or just the quickest
way?

I guess it boils down to a concern over making poor choices and
learning bad habits.  If I'm going to spend any amount of time with
this web development hing, I want to do it right.  I'm also fighting
my urge to build everything myself.  Sure it would be plenty flexible,
but it would also take longer and wouldn't leverage the great work
done by all of Django's contributors.

So, what am I rattling on about then?

Judging by some of the posts I've read since joining the group, I'm
sure there are a bunch of folks who would appreciate some guidance
and / or best practices from the more experienced Django developers.
I understand everyone learns and progresses differently, but I would
really appreciate your take on things.

How much do you use built in Django functionality?  Are there
components you tend to avoid?  Do you use Django only for certain
types of projects?  Do you struggle with Python or Django?  Is the
source code a good place to spend some time?  Is your authentication
system home-grown?  Have you been bitten in the behind by using too
much Django?  Not enough?

I realize this is a lot to ask, but I think it's a good thing that we
help newer developers do things the right way.  I certainyl want to
become a contributing member of this group, but not until I won't give
bad advice and flat out wrong answers. ;)

I've gone through a good chunk of the Django Book online.  Is this a
good resource or do you have other recommendations?  There aren't all
that many books on Django, but there are a few.  Do any do a better
job than the others of guiding you to the best way to build web
sites / apps?  I sure wish there was a book that kept pace with the
changes and the miost recent version.  Is the fact that there isn't
much available a bad sign?

Just jump in and adjust as I learn my lessons?

Regards,

Robin

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



View with form?

2011-05-30 Thread mmm
Hi,
   I'm a DJango newb and need to make sure I approach initial issues
correctly:

I have a couple of models: Items, and subItems which have a ForeignKey
to Items.

I have a detail page for Items that displays all its subItems.

I want to add a form to allow addition of up to 3 extra subItems on
the Item detail page.

What's the best approach here?

I've found the UpdateView which looks like it might meet this, but
with the idea of putting the call to the View directly in urls.py I'm
unsure where any extra code in the view would need to live? Is it
worth moving away from calls to views in urls.py quickly, to allow for
putting custom code in views.py?

Thanks!

mmm

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



python threads and django views

2011-05-30 Thread rahul jain
All,

I would like to know how to do this?

For example, in my views I have to visit 10,000 websites (make url
connection).   Each of those connections are independent connections.
I would like to hit them as quickly as possible. Then return an
http-response with some results.

I have few questions now

Obviously, I cannot hit these sites sequentially, that will take forever.
Also, I believe its not possible, Django, put response time-out for each of
those view responses!

Creating 10,000 threads also is not a good idea.Therefore, I created queue
based threads.
I created 100 working threads and infinite size queue (i am not sure if this
is a good idea)
But receiving max URL connection error!

How to fix this "max URL connection error" ? In addition, any tips for
correctly implementing threads in django will be very helpful.
Also, how to set the max timeout for http-responses  (django views) ?

Thanks.

Rahul

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



Re: How to get user object from RequestContext?

2011-05-30 Thread Daniel Roseman


On Monday, 30 May 2011 18:07:16 UTC+1, MrMuffin wrote:
>
> How do I get the user related to the current request in templatetag?
> Using RequestContext?
>
> @register.tag(name='sometag')
> def sometag(parser, token):
> try:
> tagname, model_inst = token.split_contents()
> except ValueError:
> raise template.TemplateSyntaxError, "%r tag requires exactly
> one argument" % tagname
>
> return FormatNode(model_inst)
>
>
> class FormatNode(template.Node):
>
> def __init__(self, model_inst):
> self.model_inst = template.Variable(model_inst)
>
> def render(self, context):
> try:
> p = self.model_inst.resolve(context)
> # Here I'd like to get hold of the user object, but how??
> except Exception, e:
> return ''
>
> Thanks in advance,
> Thomas
>

Assuming the template was rendered with RequestContext as you imply, you can 
do `context['user']`.
--
DR.

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



Re: Disable debug logging for django.db.backends?

2011-05-30 Thread Nathan Duthoit
It's more of a hack than a clean solution but it works. Add the
following to your settings file:

import logging
logging.getLogger('django.db.backends').setLevel(logging.ERROR)

On May 24, 12:32 am, diafygi  wrote:
> Howdy all,
>
> I have DEBUG=True in my settings.py, and I have several logging
> entries in my project (Django 1.3)
>
> However, when I am testing, there are tons of django.db.backends debug
> entries that appear, and my logs gets lost in the shuffle.
>
> Is there a way to disable django.db.backends in my settings.py? What
> is an example?
>
> Thanks,
> Daniel

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



How to get user object from RequestContext?

2011-05-30 Thread Thomas Weholt
How do I get the user related to the current request in templatetag?
Using RequestContext?

@register.tag(name='sometag')
def sometag(parser, token):
try:
tagname, model_inst = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, "%r tag requires exactly
one argument" % tagname

return FormatNode(model_inst)


class FormatNode(template.Node):

def __init__(self, model_inst):
self.model_inst = template.Variable(model_inst)

def render(self, context):
try:
p = self.model_inst.resolve(context)
# Here I'd like to get hold of the user object, but how??
except Exception, e:
return ''

Thanks in advance,
Thomas

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



Odp: Re: Synchronize method or model field access

2011-05-30 Thread Etam
Is there a way to run Django (mod_wsgi) in threaded mode?

> I would push the atomic updates to the database or use a queue with a 
> single worker.  Thread level locking doesn't scale across processes or 
> servers.
>
>

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



Re: Odp: Re: signals pre_save vs model's save()

2011-05-30 Thread Alexander Schepanovski
> Because I am writing CRM, and my end users are non-technical ladies :}
> And each one of them inputs data in different format (id numbers, phone
> numbers, dates, names [upper cased, capitalized, lower cased])
> Therefore I have to normalize an input to store, and then print contract
> agreements in normalized way.

Input normalization should be done in form clean() or views.
If it is impossible or inconvenient then Model.save() is ok, but
signals should not handle this.
After all it's your model logic it should be in model, it will be far
more confusing moving it from there.

You can also take a look at Model.clean().

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



Re: Specifying a database for a specific app

2011-05-30 Thread Jacob Kaplan-Moss
On Mon, May 30, 2011 at 10:00 AM, Philip Zeyliger  wrote:
> I have several installed applications within my Hue environment.  I'd like
> to use the multiple database support to route all database requests
> associated with apptwo.models into a database called "apptwo", while keeping
> everything else in the default database.  Is this possible?  It seems like
> I'd have to do quite a bit of work to write a custom router, whereas this
> seems like a pretty common case.

The database router is the right tool for this job (the only one, actually).

It might seem like "quite a bit of work," but it's actually very
simple. There's even an example in the docs
(https://docs.djangoproject.com/en/dev/topics/db/multi-db/#an-example)
that does almost exactly what you want. In a nutshell, something like
the following should do the trick::


def app_label(model):
"""Shortcut for getting a model's app_label"""
return model._meta.app_label

class AppTwoRouter(object):

def db_for_read(self, model, **hints):
if app_label(model) == 'apptwo':
return 'apptwo'
return None

db_for_write = db_for_read

def allow_relation(self, obj1, obj2, **hints):
if app_label(obj1) == app_label(obj2) == 'apptwo':
return True
return None

def allow_syncdb(self, db, model):
if db == 'apptwo':
return app_label(model) == 'apptwo'
elif app_label(model) == 'apptwo':
return False
return None

Jacob

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



Re: setlang using AJAX

2011-05-30 Thread Kirill Spitsin
On Mon, May 30, 2011 at 08:03:46AM -0700, Luca Casagrande wrote:
> Thank you very much, for your help and your code.
> The problem is that the POST request is missing the csrf_token and so
> I have got a 403 Error.

https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#ajax

-- 
Kirill Spitsin

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



Specifying a database for a specific app

2011-05-30 Thread Philip Zeyliger
Hi there,

I have several installed applications within my Hue environment.  I'd like
to use the multiple database support to route all database requests
associated with apptwo.models into a database called "apptwo", while keeping
everything else in the default database.  Is this possible?  It seems like
I'd have to do quite a bit of work to write a custom router, whereas this
seems like a pretty common case.

Thanks!

-- Philip

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



Re: setlang using AJAX

2011-05-30 Thread Luca Casagrande
Hi Radovan,
this code should go on a web page before the real application.
Basically I'd like to have the user click on a flag representing the
language and load the real site with the appropriate language.

Thanks
L.

On 30 Mag, 15:30, urukay  wrote:
> hi,
>
> but you have to reload the whole page anyway or you want only part of
> the page to be translated?
> There's a way to change language without form.
>
> R.
>
> On 30. Máj, 13:07 h., Luca Casagrande 
> wrote:
>
>
>
>
>
>
>
> > Hello everybody,
> > I'd like to use an AJAX request without any form to change the
> > language of my site.
> > My problem is that I haven't found a way to avoid the csrf_token
> > error..
> > How can I generate the token without any form?
>
> > The other way it to use setlang with a GET request but, according to
> > docs, this seems no more possible.
>
> > Thanks for your support.
> > Luca

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



python code works in command line but not in django

2011-05-30 Thread Kann
Dear all,

I tried using python to execute some external java program in my code.
My problem is the os.system(cmd) was not working properly when the
code was included into some view in views.py. However, executing the
code from terminal worked just fine. I am not sure what is wrong here.

 this is from my medusa package

 1 import os
 2
 3 def create_image():
 4 path = os.path.abspath('tmp/medusa')
 5 medusa = os.path.abspath('mirnaworkbench/Medusa/Medusa.jar')
 6 cmd = str('java -cp ' + medusa + '
medusa.batchoperations.BatchOperations ' + path)
 7 os.system(cmd)

 this is from one of my views

MedusaConnector.create_image()


>
calling MedusaConnector.create_image() from python shell worked just
fine.

Thanks,

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



Re: Is there an HTML editor that's Django-aware

2011-05-30 Thread Jacob Kaplan-Moss
On Monday, May 30, 2011, BobX  wrote:
> If anyone from the Django Project itself is listening then can I (very
> humbly) suggest that some editor recommendations would make a real
> fine addition to the info on the site (useful to n00b's like me
> anyway).

That's a good idea - thanks!

Where do you think such information should live? That is, at what
point in your process of learning Django would information about
editors have been helpful? Somewhere in the tutorial, or after?
Before?

Thanks,

Jacob

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



Re: setlang using AJAX

2011-05-30 Thread urukay
hi,

but you have to reload the whole page anyway or you want only part of
the page to be translated?
There's a way to change language without form.

R.

On 30. Máj, 13:07 h., Luca Casagrande 
wrote:
> Hello everybody,
> I'd like to use an AJAX request without any form to change the
> language of my site.
> My problem is that I haven't found a way to avoid the csrf_token
> error..
> How can I generate the token without any form?
>
> The other way it to use setlang with a GET request but, according to
> docs, this seems no more possible.
>
> Thanks for your support.
> Luca

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



Re: Is there an HTML editor that's Django-aware

2011-05-30 Thread BobX
Again, thanks to everyone who took the time out of their schedules to
jot down a quick reply to my question. I'll go away and try some of
the apps suggested. :D

If anyone from the Django Project itself is listening then can I (very
humbly) suggest that some editor recommendations would make a real
fine addition to the info on the site (useful to n00b's like me
anyway).

On May 20, 10:54 am, BobX  wrote:
> Pretty obvious question, but is there any recommended HTML editor that
> won't munch the Django template codes? I was using Amaya to form my
> pages, but after a couple of what-the-heck moments, I discovered that
> it sporadically "eats" the template codes - ones in table definitions
> being particularly vulnerable.
>
> Notepad2 is very usable - but unfortunately that's just syntax
> highlighting the raw HTML codes. So at the moment I'm generating the
> templates with Amaya and then switching to Notepad2 once the template
> codes are added.

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



Re: Django model manager "live" object issues

2011-05-30 Thread James Hargreaves
Indeed, I have just updated this to use class-based generic-views and
it appears to be working as designed:

from django.conf.urls.defaults import *

from django.views.generic import ListView, RedirectView

from application.news.models import Article, Category

urlpatterns = patterns('',
(r'^$', RedirectView.as_view(url="all")),

url(r'^all/$', ListView.as_view(
model=Article,
), name="news_all"),
)

So here the queryset is not cached and using the model=Article
specification means that the default query is run, in my case the
"live" query.

Cheers
Jay

On May 30, 1:57 pm, James Hargreaves 
wrote:
> Hi Kirill,
>
> Thanks for your response and sorry for my tardiness in replying!
>
> I think you are right - my queryset is cached in the view, as my
> urls.py looks like this:
>
> from django.conf.urls.defaults import *
> from django.views.generic.simple import redirect_to
> from django.views.generic.list_detail import object_list,
> object_detail
>
> from application.news.models import Article, Category
> from application.news.views import news_article_detail
>
> urlpatterns = patterns('',
>     (r'^$',
>         redirect_to, { 'url' : 'all' }),
>
>     (r'^all/$',
>         object_list, {
>             'queryset' : Article.live.all(),
>         }, 'news_all'),
>
>     (r'^(?P[-\w]+)/$',
>         object_detail, {
>             'queryset' : Category.objects.all(),
>         }, 'news_category'),
>
>     # the article should appear under the category menu item
>     (r'^(?P[-\w]+)/(?P[-\w]+)/$',
>         news_article_detail, {
>             'queryset' : Article.live.all(),
>         }, 'news_article'),
> )
>
> Note - I realise this is using function-based generic-views and I am
> going to change this to class-based shortly, in the hope that this
> will fix the issue.
>
> Anyway, so the call to Article.live.all() will create a QuerySet and
> this is stored in the queryset attribute for the "news_all" and
> "news_article" views. I don't know how to create my view so that the
> filter is done at runtime instead of compile time. I could of course
> do the check in my view code, but that's not great programming
> practice and also bad from a performance perspective.
>
> Any thoughts???
>
> Thanks
> Jay
>
> On May 19, 10:36 pm, Kirill Spitsin  wrote:
>
>
>
>
>
>
>
> > On Wed, May 18, 2011 at 11:45:46PM -0700,JamesHargreaveswrote:
>
> > ...
>
> > > Firstly, when I query for LIVE objects in my view via
> > > Article.live.all() if I refresh the page repeatedly I can see (in
> > > MYSQL logs) the same database query being made with exactly the same
> > > date in the where clause - ie - the datetime.datetime.now() is being
> > > evaluated at compile time rather than runtime. I need the date to be
> > > evaluated at runtime.
>
> > I can't reproduce such behavior.  `.get_query_set()` is evaluted when
> > queryset is returned from manager, so, maybe, you cache queryset
> > somewhere in your view?
>
> > > Secondly, when I use the articles_set method on the Category object
> > > this appears to work correctly - the datetime used in the query
> > > changes each time the query is run - again I can see this in the logs.
> > > However, I am not quite sure why this works, since I don't have
> > > anything in my code to say that the articles_set query should return
> > > LIVE entries only!?
>
> > The first manager defined on model is interepted as "default manager".
> > You probably want to put line with `live` manager after `objects`
> > manager in `Article` declaration.
>
> > > Finally, why is none of this being cached?
>
> > Not quite so, QuerySet has a cache [1].
>
> > .. 
> > [1]http://docs.djangoproject.com/en/1.3/topics/db/queries/#caching-and-q...
>
> > --
> > Kirill Spitsin

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



Re: Django model manager "live" object issues

2011-05-30 Thread James Hargreaves
Hi Kirill,

Thanks for your response and sorry for my tardiness in replying!

I think you are right - my queryset is cached in the view, as my
urls.py looks like this:

from django.conf.urls.defaults import *
from django.views.generic.simple import redirect_to
from django.views.generic.list_detail import object_list,
object_detail

from application.news.models import Article, Category
from application.news.views import news_article_detail

urlpatterns = patterns('',
(r'^$',
redirect_to, { 'url' : 'all' }),

(r'^all/$',
object_list, {
'queryset' : Article.live.all(),
}, 'news_all'),

(r'^(?P[-\w]+)/$',
object_detail, {
'queryset' : Category.objects.all(),
}, 'news_category'),

# the article should appear under the category menu item
(r'^(?P[-\w]+)/(?P[-\w]+)/$',
news_article_detail, {
'queryset' : Article.live.all(),
}, 'news_article'),
)

Note - I realise this is using function-based generic-views and I am
going to change this to class-based shortly, in the hope that this
will fix the issue.

Anyway, so the call to Article.live.all() will create a QuerySet and
this is stored in the queryset attribute for the "news_all" and
"news_article" views. I don't know how to create my view so that the
filter is done at runtime instead of compile time. I could of course
do the check in my view code, but that's not great programming
practice and also bad from a performance perspective.

Any thoughts???

Thanks
Jay

On May 19, 10:36 pm, Kirill Spitsin  wrote:
> On Wed, May 18, 2011 at 11:45:46PM -0700,JamesHargreaveswrote:
>
> ...
>
> > Firstly, when I query for LIVE objects in my view via
> > Article.live.all() if I refresh the page repeatedly I can see (in
> > MYSQL logs) the same database query being made with exactly the same
> > date in the where clause - ie - the datetime.datetime.now() is being
> > evaluated at compile time rather than runtime. I need the date to be
> > evaluated at runtime.
>
> I can't reproduce such behavior.  `.get_query_set()` is evaluted when
> queryset is returned from manager, so, maybe, you cache queryset
> somewhere in your view?
>
> > Secondly, when I use the articles_set method on the Category object
> > this appears to work correctly - the datetime used in the query
> > changes each time the query is run - again I can see this in the logs.
> > However, I am not quite sure why this works, since I don't have
> > anything in my code to say that the articles_set query should return
> > LIVE entries only!?
>
> The first manager defined on model is interepted as "default manager".
> You probably want to put line with `live` manager after `objects`
> manager in `Article` declaration.
>
> > Finally, why is none of this being cached?
>
> Not quite so, QuerySet has a cache [1].
>
> .. [1]http://docs.djangoproject.com/en/1.3/topics/db/queries/#caching-and-q...
>
> --
> Kirill Spitsin

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



setlang using AJAX

2011-05-30 Thread Luca Casagrande
Hello everybody,
I'd like to use an AJAX request without any form to change the
language of my site.
My problem is that I haven't found a way to avoid the csrf_token
error..
How can I generate the token without any form?

The other way it to use setlang with a GET request but, according to
docs, this seems no more possible.

Thanks for your support.
Luca

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



Re: Serving static file on Windows

2011-05-30 Thread Alagu Madhu
urls.py

from django.conf.urls.defaults import patterns, include, url


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






On May 30, 12:28 pm, Praveen Krishna R 
wrote:
> *could you dump your urls.py ?
> *
>
>
>
>
>
>
>
>
>
> On Mon, May 30, 2011 at 12:19 PM, Alagu Madhu  wrote:
> > Hi,
>
> > sample/
> >                     static/
> >                    js/jquery.1.6.1.min.js
> >                 css/
>
> > settings.py
>
> > APP_DIR = os.path.abspath(os.path.dirname(__file__))
> > STATIC_ROOT = os.path.join(APP_DIR, 'static/')
> > STATIC_URL = '/static/'
> > INSTALLED_APPS = (
> >    'django.contrib.auth',
> >    'django.contrib.contenttypes',
> >    'django.contrib.sessions',
> >    'django.contrib.sites',
> >    'django.contrib.messages',
> >    'django.contrib.staticfiles',
> > )
>
> > urls.py
>
> > urlpatterns = patterns('',
> >    (r'^$', 'hydra.views.index'),
> > )
>
> >http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
>
> > Page not found (404)
> > 'js\jquery.1.6.1.min.js' could not be found
>
> > Thanks
>
> > Madhu
>
> > On May 24, 9:44 pm, shofty  wrote:
> > > ignore that last comment, im clearly behind a version!
>
> > > not sure why you're needing to static.serve the static files, if
> > > you're on django 1.3 it does that bit for you.
>
> > > On May 24, 9:22 am, AlaguMadhu wrote:
>
> > > > Hi,
>
> > > > sample/
> > > >           media/
> > > >                     js/jquery.1.6.1.min.js
> > > >                  css/
> > > >            static/
> > > >                     js/jquery.1.6.1.min.js
> > > >                  css/
>
> > > > settings.py
>
> > > > import os
> > > > PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
> > > > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
> > > > MEDIA_URL = '/media/'
> > > > STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
> > > > STATIC_URL = '/static/'
>
> > > > urls.py
>
> > > > urlpatterns = patterns('',
> > > >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > > > {'document_root': settings.MEDIA_ROOT}),
> > > >     (r'^static/(?P.*)$', 'django.views.static.serve',
> > > > {'document_root': settings.STATIC_ROOT}),
>
> > > >http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
>
> > > > Page not found (404)
> > > > 'js\jquery.1.6.1.min.js' could not be found
>
> > > > Thanks
>
> > > >Madhu
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Thanks and Regards,
> *Praveen Krishna R*

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



Odp: Re: Synchronize method or model field access

2011-05-30 Thread Etam
Thanks!

Celery provides a queue you could use:
>
> http://ask.github.com/celery/getting-started/introduction.html
>

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



Re: Serving static file on Windows

2011-05-30 Thread Praveen Krishna R
*could you dump your urls.py ?
*
On Mon, May 30, 2011 at 12:19 PM, Alagu Madhu  wrote:

> Hi,
>
> sample/
> static/
>js/jquery.1.6.1.min.js
> css/
>
> settings.py
>
> APP_DIR = os.path.abspath(os.path.dirname(__file__))
> STATIC_ROOT = os.path.join(APP_DIR, 'static/')
> STATIC_URL = '/static/'
> INSTALLED_APPS = (
>'django.contrib.auth',
>'django.contrib.contenttypes',
>'django.contrib.sessions',
>'django.contrib.sites',
>'django.contrib.messages',
>'django.contrib.staticfiles',
> )
>
> urls.py
>
> urlpatterns = patterns('',
>(r'^$', 'hydra.views.index'),
> )
>
> http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
>
> Page not found (404)
> 'js\jquery.1.6.1.min.js' could not be found
>
>
> Thanks
>
> Madhu
>
>
>
>
> On May 24, 9:44 pm, shofty  wrote:
> > ignore that last comment, im clearly behind a version!
> >
> > not sure why you're needing to static.serve the static files, if
> > you're on django 1.3 it does that bit for you.
> >
> > On May 24, 9:22 am, AlaguMadhu wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi,
> >
> > > sample/
> > >   media/
> > > js/jquery.1.6.1.min.js
> > >  css/
> > >static/
> > > js/jquery.1.6.1.min.js
> > >  css/
> >
> > > settings.py
> >
> > > import os
> > > PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
> > > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
> > > MEDIA_URL = '/media/'
> > > STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
> > > STATIC_URL = '/static/'
> >
> > > urls.py
> >
> > > urlpatterns = patterns('',
> > > (r'^media/(?P.*)$', 'django.views.static.serve',
> > > {'document_root': settings.MEDIA_ROOT}),
> > > (r'^static/(?P.*)$', 'django.views.static.serve',
> > > {'document_root': settings.STATIC_ROOT}),
> >
> > >http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
> >
> > > Page not found (404)
> > > 'js\jquery.1.6.1.min.js' could not be found
> >
> > > Thanks
> >
> > >Madhu
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Thanks and Regards,
*Praveen Krishna R*

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



Re: Serving static file on Windows

2011-05-30 Thread Alagu Madhu
Hi,

sample/
static/
js/jquery.1.6.1.min.js
 css/

settings.py

APP_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(APP_DIR, 'static/')
STATIC_URL = '/static/'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
)

urls.py

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

http://192.168.1.141:44/static/js/jquery.1.6.1.min.js

Page not found (404)
'js\jquery.1.6.1.min.js' could not be found


Thanks

Madhu




On May 24, 9:44 pm, shofty  wrote:
> ignore that last comment, im clearly behind a version!
>
> not sure why you're needing to static.serve the static files, if
> you're on django 1.3 it does that bit for you.
>
> On May 24, 9:22 am, AlaguMadhu wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > sample/
> >           media/
> >                     js/jquery.1.6.1.min.js
> >                  css/
> >            static/
> >                     js/jquery.1.6.1.min.js
> >                  css/
>
> > settings.py
>
> > import os
> > PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
> > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
> > MEDIA_URL = '/media/'
> > STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
> > STATIC_URL = '/static/'
>
> > urls.py
>
> > urlpatterns = patterns('',
> >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > {'document_root': settings.MEDIA_ROOT}),
> >     (r'^static/(?P.*)$', 'django.views.static.serve',
> > {'document_root': settings.STATIC_ROOT}),
>
> >http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
>
> > Page not found (404)
> > 'js\jquery.1.6.1.min.js' could not be found
>
> > Thanks
>
> >Madhu

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



Re: SystemError from django.conf.settings

2011-05-30 Thread Cameron
Yeah no worries, I will gather as much evidence as I can and post the
details tonight. FYI I am running python 2.5.2 which comes with debian
lenny, I did not compile it myself.

And yes you are right that the wsgi server plays such a small part in
the processing of a django page. The majority of my CPU time is spent
with the database and rendering views.

Which makes gunicorn an interesting option being pure python, but
overall not that important in terms of performance. I had just setup
the uwsgi Emperor mode which was very convenient so I will miss that.
My hacked together init.d script equivalent for gunicorn is not as
clean.

-
Cameron

On May 30, 2:15 pm, "Roberto De Ioris"  wrote:
> > As suggested on #django yesterday I swapped the site over to manage.py
> > runserver and also tried gunicorn and they are both stable so it looks
> > like a problem with uwsgi.
>
> As already suggested it looks like a Python c api problem, do you mind to
> fill a bug report in the uWSGI wiki with all the relevant information ?
> (mainly how python is compiled, as most of the time this kind of errors
> are related to python excessive optimizations)
>
>
>
> > Gunicorn is also surprisingly fast, beating uwsgi on a httperf test to
> > one of the heavier pages on the site.
>
> oh yes, and you will see tons of comparison reporting the opposite, others
> showing mod_wsgi is better and so on... Please try to understand that WSGI
> bridges/gateways/servers are pratically irrelevant in your app
> performance.
>
> Gunicorn works for you ? Perfect ! you have found your WSGI server ;)
>
> --
> Roberto De Iorishttp://unbit.it

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



Re: Regarding Django Applicaiton

2011-05-30 Thread Derek
On May 28, 12:42 pm, Amit Pal  wrote:
> Hello,
>
> I am Amit Pal , a undergrduate studentI need your help . I am new
> at Django and just run the first application on my workstation.
>
> I have to make a django applicaiton i.e.
>
> TO build a website which shows the IP location (geoip) on Google
> map I need your help very urgently ..
>
> Waiting for your all response :)
Amit

For the Django side, have a look at this tutorial:
http://invisibleroads.com/tutorials/geodjango-googlemaps-build.html
For the GeoLocation of IP addresses, it seems there are commercial
options out there, but you may be able to access a demo database that
will be usable by you as a student - for example,  have a look at:
http://www.iplocation.net/#geolocation

HTH
Derek

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



Re: choice_set.all()

2011-05-30 Thread bh.hoseini
i found out that i clicked on "space" before the function, so i faced
error,
tnx for your attention

On May 29, 9:26 am, Malcolm Box  wrote:
> On 29 May 2011 06:20, bahare hoseini  wrote:
>
> > hi there,
> > i followed the structure in
> >https://docs.djangoproject.com/en/dev/intro/tutorial01/ ,every thing was
> > allright till i wrote the code: >>> "p.choice_set.all()" , then i got
> > "AttributeError: 'function' object has no attribute choice_set" . :(
> > can somone help?!
>
> Psychic debugging: you previously typed:
>
> p = Poll.objects.get
> rather than
> p = Poll.objects.get(pk=1)
>
> If you did type the former, then p is a method reference and thus you would
> get the error above.
>
> Malcolm
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Malcolm Box
> malcolm@gmail.com

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



Re: SystemError from django.conf.settings

2011-05-30 Thread Roberto De Ioris

> As suggested on #django yesterday I swapped the site over to manage.py
> runserver and also tried gunicorn and they are both stable so it looks
> like a problem with uwsgi.


As already suggested it looks like a Python c api problem, do you mind to
fill a bug report in the uWSGI wiki with all the relevant information ?
(mainly how python is compiled, as most of the time this kind of errors
are related to python excessive optimizations)

>
> Gunicorn is also surprisingly fast, beating uwsgi on a httperf test to
> one of the heavier pages on the site.


oh yes, and you will see tons of comparison reporting the opposite, others
showing mod_wsgi is better and so on... Please try to understand that WSGI
bridges/gateways/servers are pratically irrelevant in your app
performance.

Gunicorn works for you ? Perfect ! you have found your WSGI server ;)

-- 
Roberto De Ioris
http://unbit.it

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