Re: Django 1.2.3, Oracle with Character Set WE8MSWIN1252 - 'utf8' codec can't decode bytes

2010-12-01 Thread Ian Kelly
On Wed, Dec 1, 2010 at 7:58 PM, Anurag Chourasia
 wrote:

> This is using cx_Oracle and it works fine
> ===
 cx_Oracle.version
> '5.0.3'
 cursor.execute("select to_term from terminology_map where id=316")
 cursor.fetchone()[0]
> 'Registro guardado con \xe9xito'

It's not clear to me which setting you used here.  Was this using the
.UTF8 NLS_LANG as I requested?  If so, then in fact this is also
coming back incorrectly, because that is not UTF-8.  If not, then
we're comparing apples to oranges, since Django uses the .UTF8
setting.

Thanks,
Ian

-- 
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: get_object_or_404 on composite key and Value Error:Invalid Literal for int with base 10

2010-12-01 Thread Pranav


On Dec 2, 12:10 am, bruno desthuilliers
 wrote:
> On 1 déc, 19:20, Pranav  wrote:
>
> > Hi all,
>
> > I'm new to django and python and i'm working on a project that works
> > with a legacy database.
> > I've a particular problem with a "composite key" and "get" or
> > "get_object_or_404".
>
> > i generated the below model form the legacy database using inspectdb
>
> > model:
> > --
> > class Member:
>
> This should inherit from models.Model
>
> >            member_id = field.CharField(max_length=20)
> >            organization_id = field.Foreignkey(Organization)
> >            member_type = field.CharField(max_length=10)
> >            class Meta:
> >                     db_table = u'member'
> >                     unique_together =
> > (('member_id','organization_id'),)
> > # unique_together is a constraint i added in order to form the
> > composite primary key
>
> It's a composite key, but it's not a primary key - or at least it's
> not recognized as such by Django (hint: Django doesn't handle
> composite primary keys so far)
>
> > class Organization:
>
> idem
>
>
>
> > I have a function in my view which receives a "MemOrgId" which is
> > nothing but the composite key of both member_id and organization_id.
> > for example the value i get is MemOrgId='AA1001', now the problem is
> > when i try to use get or a get_object_or_404 i get a Value
> > Error:Invalid Literal for int with base 10.
>
> > obj = get_object_or_404(Member,pk = MemOrgId)
>
> Since you didn't explicitly declared a primary key for your Member
> model, Django automagically adds one, named "id" and defined as an
> autoincrement integer, so the 'pk' shortcut resolves to this int
> field.
>
> > According to my understanding of the trace back its not able to
> > convert the key "CP1001" to int coz it contains char data along with
> > int. I cannot modify the database
>
> Should not be a major problem.
>
> > and i cannot change the way MemOrgId
> > comes to the view function.
>
> Why ?
>
> > Is there a way around this problem
>
> Yes: split the compound key and do an explicit lookup:
>
> def yourview(request, MemOrgId):
>     oid, mid = MemOrgId[0:2], MemOrgId[2:]
>     obj = get_object_or_404(
>        organization_id=oid,
>        member_id=mid
>        )
>
> IRL you probably want a bit more validation on what the MemOrgId arg
> looks like - but this can be done with the correct regexp in your
> urls.py

Thanks your solution worked, but now i have a bigger problem i cant
seem to save my form.
Django adds a automatic "id" to the table which i don't have in my
database so my database is throwing an error. Also none of the fields
in my table are unique so cannot set manual primary_key=True, I cannot
change the database as I said earlier. Is there a way to ignore this
auto generated id or a way to use the create a table without any
primary keys.

-- 
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 + Russian Charaters

2010-12-01 Thread pROCKrammer
Hi, I am getting such error while adding text with russian charaters
from the admin panel, Please help me

The Model is

class JobTitle (models.Model):
# Char Fields
title = models.CharField(max_length = 250)

def __unicode__(self):
return u'%s' % (self.title) # Tried return self.title before, 
also
Tried force_unicode


Warning at /admin/hrm/jobtitle/add/
Incorrect string value: '\xD1\x84\xD1\x8B\xD0\xB2...' for column
'object_repr' at row 1Request Method:   POST
Request URL:http://localhost:8000/admin/hrm/jobtitle/add/
Django Version: 1.2.3
Exception Type: Warning
Exception Value:Incorrect string value: '\xD1\x84\xD1\x8B
\xD0\xB2...'
for column 'object_repr' at row 1
Exception Location: /usr/lib/pymodules/python2.6/MySQLdb/
cursors.py in
_warning_check, line 82
Python Executable:  /usr/bin/python
Python Version: 2.6.6

-- 
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 define choices option per model's instance

2010-12-01 Thread Alex Boyko
Hi!

I got such kind of problem.
I'd like to define the tuple(list) of choices option at the moment of
instance created on the fly
In the future these choices will not change.
Hence I've found just one way to do it - override __init__() of my model
and
pass there the particular predefined list of choices that depends on current
model's instance (in code - 'range_list')
But this approach seems doesn't work properly.
Would You be so kind to help with advice  - how I can solve my task with
dynamical choices per model's instance.

---
RANGE_CHOICES = ()

class Something(models.Model):
def __init__(self, *args, **kwargs):
range = kwargs.pop('range_list', None)
super(Covenant, self).__init__(*args, **kwargs)
self._meta.get_field_by_name('range_marks')[0]._choices = range

range_marks = models.IntegerField(choices = RANGE_CHOICES, verbose_name
= 'Marks of Something')
-


Thanks in Advance!
Best Regards!
Alex

-- 
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: Python (2.6) threading module or multiprocessing module?

2010-12-01 Thread Cal Leeming [Simplicity Media Ltd]
Hmm, all depends what you're trying to achieve. I personally avoid 
conventional threading in Python from the outset, and use Stackless 
instead.


Have you possibly considered using Twisted (see 
http://twistedmatrix.com/trac/ and 
http://twistedmatrix.com/documents/current/core/examples/)


On 01/12/2010 19:07, ydjango wrote:

http://www.python.org/dev/peps/pep-0371/

I am aware this is a Django forum not python. But many python experts
are on this forum, so I though I would ask.

When would you use Python (2.6) threading module or multiprocessing
module?

It seems in general python multiprocessing module should be preferred
over threading because of GIL unless threads need to share data.

Though both API being similar the switch  from coding perspective is
trivial.

( it is kind of opposite in Java.)



--
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 in production on Windows

2010-12-01 Thread Cal Leeming [Simplicity Media Ltd]
It's a shame you are not using a *nix os, because you could have then 
used uWSGI (http://projects.unbit.it/uwsgi/).


Feature list:


   Current core features are

   * written totally in C
   * very fast (and simple) communication protocol for webservers
 integration (apache2
 ,nginx
 ,cherokee
 andlighttpd
 modules available)
   * low memory footprint (thanks to the evil premature optimizations)
   * support for multiple application in the same process/domain
   * a master process manager that will allows you to automatically
 respawn processes and monitor the stack status
   * preforking mode to improve concurrency
   * address space and rss usage reports
   * advanced logging (even networked, seeUdpLogging
 )
   * static file serving via sendfile() (where available)
   * portability (tested on Linux 2.6, Solaris/OpenSolaris, OpenBSD,
 NetBSD, DragonflyBSD, FreeBSD, MacOSX and Haiku)
   * support for funny architectures like SPARC64 or ARM
   * support for threads (configurable, available from 0.9.7-dev)
   * cgi mode for lazy users or ugly webservers (example cgi
 includedhere
 andhere
 )
   * harakiri mode for self-healing
   * vector based I/O to minimize syscall usage
   * hot-add of applications. SeeDynamicApps
 
   * on the-fly configuration parameters. SeeManagementFlag
 
   * big (professional) user-base (hundreds of production ready wsgi
 apps) thanks to its main development managed by the Italian ISP Unbit
   * commercial support available (contact Unbit for informations)
   * all code is under GPL2 (but you can buy a commercial license if
 you want to modify it without releasing source code)
   * configurable buffer size for low-memory system or to manage big
 requests
   * customizable builds (you can remove unneeded functionality)
   * intelligent worker respawner wih no-fork-bombing policy
   * limit requests per worker
   * process reaper for external process managers (as daemontools).
 Avoids zombie workers.
   * Per-request modifier for advanced users (SeeRunOnNginx
 for an example
 usage, anduwsgiProtocol
 for the
 modifiers list)
   * UNIX and TCP socket support
   * Graceful restart of worker processes and hot-plug
 substitution/upgrade of theuWSGIserver usingSignals
 . SeeuWSGIReload
 
   * A shared memory area to share data between workers/processes.
 SeeSharedArea 
   * An integratedSpooler
 for managing long
 running task.
   * Message exchanging (viauwsgiprotocol) for easy-implementation of
 distributed applications (look atClusteredExamples
 )
   * Get statistics of all the workers using theEmbeddedModule
 
   * Integrated Async/EventedProxy
 for load-balancing and
 healtchecking of big clusters (from version 0.9.5)
   * Address space usage limiting (from version 0.9.5)
   * integrated SNMP agent and nagios-friendly output (from version
 0.9.5) SeeUseSnmp 
   * VirtualHosting
 mode (from
 version 0.9.6)
   * Embedded threadedHTTP server
 for easy
 development and testing (from version 0.9.6)


   TODO/Working on

   * integrated support for wsgi middleware (is it really useful ?)
   * put some more code comments to gather external developers ;)
   * better anti-fork bombing policy (lesser dumb)
   * advanced conditional logging (already available in 0.9.6.5, more
 to come in 0.9.7)
   * Linux cgroups integration (work already started in 0.9.7-dev)
 seeUseCgroups 
   * SSL support (with certificate client authentication) to allow
 remote management of theuWSGIstack
   * support for multiple listening sockets (already available in
 mercurial repository, simply add more --socket options)
   * Web3 (PEP-444) (already available in mercurial repository)
   * IPv6 support (targeted at 0.9.7 release)
   * SCTP support 

Re: signal locations

2010-12-01 Thread Cal Leeming [Simplicity Media Ltd]

Place your signals into webapp/app/signals.py

Then, inside the signals, do "from webapp.app import models"

Then attach the signals in a fashion which you are accustom to (see 
http://docs.djangoproject.com/en/dev/topics/signals/).


Then, inside the __init__.py OR the models.py, do "import 
webapp.app.signals"


I do not know if Django checks if a signal has already been attached, so 
you might want to unit test this first.


On 01/12/2010 21:32, garagefan wrote:

That wouldn't resolve the problem any more than having everything in
the models.py.

i wish to externalize this signal from the gallery application so that
it is up to the website project whether or not a signal is being used.
i suppose i could add a toggle variable in the gallery settings file
so the project settings file can decide whether or not to utilize the
work being done within the method via a local variable...

seems kind of a messy way to do things... it'd be great to have a
single file for the website's signals... sort of like setting up
templatetags at the project level


On Dec 1, 3:28 pm, Daniel Roseman  wrote:

On Dec 1, 5:29 pm, garagefan  wrote:










Now, i've read the thread in regards to putting the import in the
__init__.py
here is my structure
website_project
->  signals
- ->  signals.py (and an __init__.py)
->  shared_apps (link to numerous apps shared amongst other projects)
- ->  gallery application
my signals.py looks like this
from django.db.models.signals import post_save
from django.core.mail import send_mail
from gallery.models import Gallery
def send_creation(sender, instance, *args, **kwargs):
 if 'created' in kwargs:
 if kwargs['created'] and instance.published:
 send_mail('Subject here',[sender, instance.published,
args, kwargs,], 'f...@example.com', ['@example.com'],
fail_silently=False)
post_save.connect(send_creation,sender=Gallery)
this works when in the gallery application, however... this is just a
test case, eventually i am going to be hitting up the fb graph api and
posting the website's facebook profile, and i'd prefer to keep the
gallery application useful for both facebook and non-facebook
integrated websites.
I've attempted import signals and import signals.signals in the
website_project __init__.py. the former resulting in nothing and the
latter resulting in a "internal server failure" upon restart.

You should do this the other way round. Keep the signal definition -
the `send_creation` function itself - in signals.py, but don't import
Gallery there. Instead, in gallery/models.py, import the *signal*:
from signals.signals import send_creation - and then do the
registering at the bottom of that file.
--
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 1.2.3, Oracle with Character Set WE8MSWIN1252 - 'utf8' codec can't decode bytes

2010-12-01 Thread Anurag Chourasia
Hi Ian,

Thanks for the response.

With cx_Oracle(version 5.0.3), the retrieval of that field value works fine
as in my original email.

It's only when i directly use the Django models way of accessing that it
fails.

Below two examples will make it more clear.

This is using Django models and it fails
==
>>> TerminologyMap.objects.filter(id=316)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line
68, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line
83, in __len__
self._result_cache.extend(list(self._iter))
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line
269, in iterator
for row in compiler.results_iter():
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/compiler.py",
line 672, in results_iter
for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/compiler.py",
line 741, in 
result = iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),
  File "/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py",
line 552, in fetchmany
for r in self.cursor.fetchmany(size)])
  File "/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py",
line 625, in _rowfactory
value = to_unicode(value)
  File "/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py",
line 636, in to_unicode
return force_unicode(s)
  File "/usr/lib/python2.5/site-packages/django/utils/encoding.py", line 88,
in force_unicode
raise DjangoUnicodeDecodeError(s, *e.args)
django.utils.encoding.DjangoUnicodeDecodeError: 'utf8' codec can't decode
bytes in position 22-24: invalid
 data. You passed in 'Registro guardado con \xe9xito' ()

This is using cx_Oracle and it works fine
===
>>> cx_Oracle.version
'5.0.3'
>>> cursor.execute("select to_term from terminology_map where id=316")
>>> cursor.fetchone()[0]
'Registro guardado con \xe9xito'

Regards,
Anurag

On Wed, Dec 1, 2010 at 10:51 PM, Ian  wrote:

> On Nov 30, 8:31 pm, Anurag Chourasia 
> wrote:
> > On Oracle 10.2 with Character-Set set to WE8MSWIN1252,
> >
> > When using Django, I try to select a Oracle row which contains a field
> with
> > value as 'Páginas', i encounter the following error "'utf8' codec can't
> > decode bytes "
>
> The NLS_LANG setting used by Django should guarantee that the data
> comes back as UTF-8 regardless of the database character set.
>
> What version of cx_Oracle are you using?
> Is the column type VARCHAR2 or NVARCHAR2?
> What do you get if you try the following, substituting the appropriate
> values?
>
> $ export NLS_LANG=.UTF8
> $ python
> >>> import cx_Oracle
> >>> conn = cx_Oracle.connect('username/passw...@dsn')
> >>> cursor = conn.cursor()
> >>> cursor.execute("SELECT PROBLEM_COLUMN FROM TERMINOLOGY_MAP WHERE ID =
> 206")
> >>> print repr(cursor.fetchone()[0])
>
> Thanks,
> Ian
>
> --
> 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: Unresolved import in Eclipse

2010-12-01 Thread cocolombo
Thank you all.

Project > Properties > PyDev - PYTHONPATH was the problem I had.

I will try using Aptana Studio.

Thanks again.

On Dec 1, 8:22 pm, Javier Guerra Giraldez  wrote:
> On Wed, Dec 1, 2010 at 6:54 PM, Andre Terra  wrote:
> > I've never used it as a plugin, just the standalone version.
>
> the standalone is just an Eclipse installer with the plugin already
> configured (and a few relevant others)
>
> --
> 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.



Re: Unresolved import in Eclipse

2010-12-01 Thread Javier Guerra Giraldez
On Wed, Dec 1, 2010 at 6:54 PM, Andre Terra  wrote:
> I've never used it as a plugin, just the standalone version.

the standalone is just an Eclipse installer with the plugin already
configured (and a few relevant others)

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



Re: Unresolved import in Eclipse

2010-12-01 Thread Andre Terra
You could also try using Aptana Studio, which is imho better than Eclipse
for django development. They're very similar, but it's more refined.

http://www.aptana.com/products/studio3

Mind you, I've never used it as a
plugin, just the standalone version.


Sincerely,

Andre Terra



On Wed, Dec 1, 2010 at 21:51, cootetom  wrote:

> I take it you're using PyDev with eclipse? My experience is that
> eclipse often says that it can't resolve an import but is wrong. Just
> remember an import will work if it is on your python path. When you
> run the django project from eclipse it will use the python path as
> well as the project directory to resolve imports. You can tell PyDev
> about paths that you're importing from so that it knows where to
> check. You do this for a project by clicking Project > Properties >
> PyDev - PYTHONPATH. You can then add paths to the list of source
> folders. I generally don't bother and tend to ignore eclipse's warning
> about unresolved imports. If the import is wrong then you'll know
> about it as soon as you try and run the website as it'll complain
> loudly!
>
>
>
>
> On Dec 1, 5:47 pm, cocolombo  wrote:
> > Hi everyone.
> >
> > I am using Eclipe 3.6.1 with Python 2.7 on Windows XP and my problem
> > is the following:
> >
> > 1) I have installed a module named : django-urlauth-0.1.1
> >
> > 2) In Eclipse, at the left of the line:
> >
> > from urlauth.util import wrap_url
> >
> > Eclipse qive a big red dot with the message : Unresolved import
> > wrap_url
> >
> > 3) But strangely If I open a shell window (django environnemnt window)
> > in Eclipse and type:
> >
> > >> from urlauth.util import wrap_url
> >
> > everything is fine and I can access the wrap_url function from the
> > shell window.
> >
> > Any Idea what is wrong. I am new to django and Eclipse so maybe this
> > is trivial stuff, sorry if this is the case.
> >
> > cclmb
>
> --
> 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: Unresolved import in Eclipse

2010-12-01 Thread cootetom
I take it you're using PyDev with eclipse? My experience is that
eclipse often says that it can't resolve an import but is wrong. Just
remember an import will work if it is on your python path. When you
run the django project from eclipse it will use the python path as
well as the project directory to resolve imports. You can tell PyDev
about paths that you're importing from so that it knows where to
check. You do this for a project by clicking Project > Properties >
PyDev - PYTHONPATH. You can then add paths to the list of source
folders. I generally don't bother and tend to ignore eclipse's warning
about unresolved imports. If the import is wrong then you'll know
about it as soon as you try and run the website as it'll complain
loudly!




On Dec 1, 5:47 pm, cocolombo  wrote:
> Hi everyone.
>
> I am using Eclipe 3.6.1 with Python 2.7 on Windows XP and my problem
> is the following:
>
> 1) I have installed a module named : django-urlauth-0.1.1
>
> 2) In Eclipse, at the left of the line:
>
> from urlauth.util import wrap_url
>
> Eclipse qive a big red dot with the message : Unresolved import
> wrap_url
>
> 3) But strangely If I open a shell window (django environnemnt window)
> in Eclipse and type:
>
> >> from urlauth.util import wrap_url
>
> everything is fine and I can access the wrap_url function from the
> shell window.
>
> Any Idea what is wrong. I am new to django and Eclipse so maybe this
> is trivial stuff, sorry if this is the case.
>
> cclmb

-- 
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: Loading CSS

2010-12-01 Thread Mike Dewhirst

On 2/12/2010 1:48am, octopusgrabbus wrote:

Thank you. I've done made changes according to your suggestions, but
the css appears not to load. I am using apache, not the built-in web
server.


Here is my working vhost.conf for my Apache. See the aliases below which 
cause Apache to find the css file and make it available to your Django 
pages.


The AliasMatch entries which are commented out should have worked but I 
didn't have the patience so I used Alias entries instead.


Good luck

Mike




 ServerName http://xxx.xxx:80
 DocumentRoot /srv/www/xxx/htdocs/

 HostnameLookups Off
 UseCanonicalName Off

 ErrorLog /var/log/apache2/xxx_error_log
 CustomLog /var/log/apache2/xxx_access_log combined

 Alias /robots.txt /srv/www/xxx/htdocs/static/robots/robots.txt
 Alias /favicon.ico /srv/www/xxx/htdocs/static/img/favicon.ico

#AliasMatch /([^/]*\.css) /srv/xxx/ccm/htdocs/static/css/$1
#AliasMatch /([^/]*\.js) /srv/xxx/ccm/htdocs/static/js/$1
#AliasMatch (^/.+\.js) /srv/xxx/ccm/htdocs/static/js/$1

 Alias /media/ /srv/www/xxx/htdocs/static/
 Alias /static/ /srv/www/xxx/htdocs/static/
 Alias /tiny_mce/ /srv/www/xxx/htdocs/static/js/tiny_mce/
 Alias /jquery/ /srv/www/xxx/htdocs/static/js/jquery/

# now let the public access anything here
 
  AllowOverride None
  Order allow,deny
  Allow from all
 

 WSGIScriptAlias / /srv/www/xxx/climate/wsgi-bin/xxx.wsgi
 
  Order allow,deny
  Allow from all
 








--
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 1.3 alpha static settings consistency

2010-12-01 Thread Russell Keith-Magee
On Thu, Dec 2, 2010 at 4:43 AM, fahhem  wrote:
> According to some pages in the dev documentation, the settings are
> STATIC_ROOT and STATIC_URL:
>
> http://docs.djangoproject.com/en/dev/ref/settings/
> http://docs.djangoproject.com/en/dev/howto/static-files/
>
> But according to this page and to the actual code, the settings are
> actually STATICFILES_ROOT and STATICFILE_URL:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/
> And code files:
> django/conf/global_settings.py
> django/conf/project_template/settings.py
> django/contrib/staticfiles/*.py
> django/contrib/staticfiles/management/commands/collectstatic.py
> django/contrib/staticfiles/templatetags/staticfiles.py
>
> Is the inconsistency due to switching from one to the other and could
> someone enlighten us as to the setting that will be used in the future
> so that Django users can use that (run a regex replace all until the
> fixes get committed/released)?

>From my inspection, the code locations you reference all say
STATIC_FILES and STATIC_ROOT now. This was a relatively recent change;
if you have an older source code checkout, it may not reflect these
changes.

Yours,
Russ Magee %-)

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



Wiki Plugin

2010-12-01 Thread Sam Pottinger
Hello,

I am writing a django-based website to hold documentation and a blog
for a university research project. We are looking to add a "wiki-like"
documentation section that implements history tracking and has decent
markdown support or a WYSIWYG editor, preferably with a way to handle
file attachments to articles.  However, due to some specific
requirements with a Git repository, this needs to act as a plugin that
can integrate with the rest of the website. While Django CMS and
FeinCMS are both very well polished solutions, we are hoping for
something a little less controlling. I have also looked into django-
wikiapp and, while their software looks very well done, it does not
seem to have support for the file uploads and, while not entirely
restrictive, does not support a WYSIWYG editor. I am more than happy
to implement this sort of lightweight plugin with tinymce but, in
order to avoid redundancy and to save time, I want to make sure that
there are no any obvious solutions I have not looked at yet.

Thanks,
Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: signal locations

2010-12-01 Thread garagefan
That wouldn't resolve the problem any more than having everything in
the models.py.

i wish to externalize this signal from the gallery application so that
it is up to the website project whether or not a signal is being used.
i suppose i could add a toggle variable in the gallery settings file
so the project settings file can decide whether or not to utilize the
work being done within the method via a local variable...

seems kind of a messy way to do things... it'd be great to have a
single file for the website's signals... sort of like setting up
templatetags at the project level


On Dec 1, 3:28 pm, Daniel Roseman  wrote:
> On Dec 1, 5:29 pm, garagefan  wrote:
>
>
>
>
>
>
>
>
>
> > Now, i've read the thread in regards to putting the import in the
> > __init__.py
>
> > here is my structure
>
> > website_project
> > - > signals
> > - - > signals.py (and an __init__.py)
> > - > shared_apps (link to numerous apps shared amongst other projects)
> > - - > gallery application
>
> > my signals.py looks like this
>
> > from django.db.models.signals import post_save
> > from django.core.mail import send_mail
> > from gallery.models import Gallery
>
> > def send_creation(sender, instance, *args, **kwargs):
> >     if 'created' in kwargs:
> >         if kwargs['created'] and instance.published:
> >             send_mail('Subject here',[sender, instance.published,
> > args, kwargs,], 'f...@example.com', ['@example.com'],
> > fail_silently=False)
>
> > post_save.connect(send_creation,sender=Gallery)
>
> > this works when in the gallery application, however... this is just a
> > test case, eventually i am going to be hitting up the fb graph api and
> > posting the website's facebook profile, and i'd prefer to keep the
> > gallery application useful for both facebook and non-facebook
> > integrated websites.
>
> > I've attempted import signals and import signals.signals in the
> > website_project __init__.py. the former resulting in nothing and the
> > latter resulting in a "internal server failure" upon restart.
>
> You should do this the other way round. Keep the signal definition -
> the `send_creation` function itself - in signals.py, but don't import
> Gallery there. Instead, in gallery/models.py, import the *signal*:
> from signals.signals import send_creation - and then do the
> registering at the bottom of that file.
> --
> 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: Loading CSS

2010-12-01 Thread octopusgrabbus
Many thanks to the replies and everyone's patience. I can't see the
9th response to this thread because Google Groups appears to be off
line, but here's what I've done to get amr.css to load:

1) Here is the base template portion that loads the css file:




{% block title %}Town of Arlington Water Department AMR
System{% endblock %} 
http://localhost:
8003/css/amr.css" />
   

2) Here is the apache config file. This is choice appears to be in
line with the Django documentation, because Django recommends not
serving static content from the same document root.

Listen 8003

DocumentRoot "/var/www/amr/media"

Options +Includes


Basically media is a symlink
 media -> /home/amr/django/amr/media

I get a 200 from loading the css file

body{ background-color: blue;}
p { color: blue; }
h3{ color: white; }

I picked blue just so I'd see a drastic change. It's not my final
choice.

My question is why don't I see a change?

Thanks.
cmn


On Dec 1, 10:12 am, Tom Evans  wrote:
> On Wed, Dec 1, 2010 at 3:02 PM, Tom Evans  wrote:
> > Are you expecting django to serve the file through apache or apache to
> > directly serve the file?
>
> > How have you configured apache?
>
> > What is output in apache's access log when you try to access the file?
>
> > You really need to provide more information. "It doesn't work" doesn't
> > really help debug.
>
> > Cheers
>
> > Tom
>
> I don't mean to repeat myself, but you still haven't given any of this
> information, so there are diminishing returns to helping you further.
> How you have configured apache to serve django affects this issue, and
> without the information, I'm just speculating.
>
> 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.



Django 1.3 alpha static settings consistency

2010-12-01 Thread fahhem
According to some pages in the dev documentation, the settings are
STATIC_ROOT and STATIC_URL:

http://docs.djangoproject.com/en/dev/ref/settings/
http://docs.djangoproject.com/en/dev/howto/static-files/

But according to this page and to the actual code, the settings are
actually STATICFILES_ROOT and STATICFILE_URL:

http://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/
And code files:
django/conf/global_settings.py
django/conf/project_template/settings.py
django/contrib/staticfiles/*.py
django/contrib/staticfiles/management/commands/collectstatic.py
django/contrib/staticfiles/templatetags/staticfiles.py

Is the inconsistency due to switching from one to the other and could
someone enlighten us as to the setting that will be used in the future
so that Django users can use that (run a regex replace all until the
fixes get committed/released)?

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: signal locations

2010-12-01 Thread Daniel Roseman
On Dec 1, 5:29 pm, garagefan  wrote:
> Now, i've read the thread in regards to putting the import in the
> __init__.py
>
> here is my structure
>
> website_project
> - > signals
> - - > signals.py (and an __init__.py)
> - > shared_apps (link to numerous apps shared amongst other projects)
> - - > gallery application
>
> my signals.py looks like this
>
> from django.db.models.signals import post_save
> from django.core.mail import send_mail
> from gallery.models import Gallery
>
> def send_creation(sender, instance, *args, **kwargs):
>     if 'created' in kwargs:
>         if kwargs['created'] and instance.published:
>             send_mail('Subject here',[sender, instance.published,
> args, kwargs,], 'f...@example.com', ['@example.com'],
> fail_silently=False)
>
> post_save.connect(send_creation,sender=Gallery)
>
> this works when in the gallery application, however... this is just a
> test case, eventually i am going to be hitting up the fb graph api and
> posting the website's facebook profile, and i'd prefer to keep the
> gallery application useful for both facebook and non-facebook
> integrated websites.
>
> I've attempted import signals and import signals.signals in the
> website_project __init__.py. the former resulting in nothing and the
> latter resulting in a "internal server failure" upon restart.

You should do this the other way round. Keep the signal definition -
the `send_creation` function itself - in signals.py, but don't import
Gallery there. Instead, in gallery/models.py, import the *signal*:
from signals.signals import send_creation - and then do the
registering at the bottom of that file.
--
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.



Creating Custom User Row In Custom Table with Django.auth.register

2010-12-01 Thread Corey
I am using Django registration platform and was trying to figure out
how to create a row in my CustomUser table for my custom user when a
user registers using the django registration platform. I derived a
CustomUser class from the django.contrib.auth.User class and added
many fields I wanted to get when calling the get_user method. I have
everything set up, but I cant figure out how to add a row to my custom
user table on the fly when people would register. I want to
automatically add a row in my custom user table when it creates a row
in he auth_user table as well. I am also using PostgreSql 8.4 if that
needs to be indicated. Thanks a lot for any 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.



Testing an app: adding an optional test model

2010-12-01 Thread Torsten Bronger
Hallöchen!

In order to test my app, I need to add a model class just for
testing.  While it doesn't do much harm if it's always there because
its DB table would remain empty, I'd like to add it only for the
test runner.  (Background: My app is extended by other apps.  But
for testing, I must simulate this extending.)

However, using a custom test runner didn't work, probably because
Django has detected all models already at that point.  Similarly, I
can't inject the model class into models.py from the test module.

Thus, I must place the model class in models.py.  Can I do this
conditionally?  For example:

if settings.TESTING:
class TestModel(models.Model):
...

would be great.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.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: get_object_or_404 on composite key and Value Error:Invalid Literal for int with base 10

2010-12-01 Thread bruno desthuilliers


On 1 déc, 19:20, Pranav  wrote:
> Hi all,
>
> I'm new to django and python and i'm working on a project that works
> with a legacy database.
> I've a particular problem with a "composite key" and "get" or
> "get_object_or_404".
>
> i generated the below model form the legacy database using inspectdb
>
> model:
> --
> class Member:

This should inherit from models.Model

>            member_id = field.CharField(max_length=20)
>            organization_id = field.Foreignkey(Organization)
>            member_type = field.CharField(max_length=10)
>            class Meta:
>                     db_table = u'member'
>                     unique_together =
> (('member_id','organization_id'),)
> # unique_together is a constraint i added in order to form the
> composite primary key

It's a composite key, but it's not a primary key - or at least it's
not recognized as such by Django (hint: Django doesn't handle
composite primary keys so far)

> class Organization:

idem

>
> I have a function in my view which receives a "MemOrgId" which is
> nothing but the composite key of both member_id and organization_id.
> for example the value i get is MemOrgId='AA1001', now the problem is
> when i try to use get or a get_object_or_404 i get a Value
> Error:Invalid Literal for int with base 10.
>
> obj = get_object_or_404(Member,pk = MemOrgId)


Since you didn't explicitly declared a primary key for your Member
model, Django automagically adds one, named "id" and defined as an
autoincrement integer, so the 'pk' shortcut resolves to this int
field.

> According to my understanding of the trace back its not able to
> convert the key "CP1001" to int coz it contains char data along with
> int. I cannot modify the database

Should not be a major problem.

> and i cannot change the way MemOrgId
> comes to the view function.

Why ?

> Is there a way around this problem

Yes: split the compound key and do an explicit lookup:


def yourview(request, MemOrgId):
oid, mid = MemOrgId[0:2], MemOrgId[2:]
obj = get_object_or_404(
   organization_id=oid,
   member_id=mid
   )


IRL you probably want a bit more validation on what the MemOrgId arg
looks like - but this can be done with the correct regexp in your
urls.py

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 (2.6) threading module or multiprocessing module?

2010-12-01 Thread ydjango
http://www.python.org/dev/peps/pep-0371/

I am aware this is a Django forum not python. But many python experts
are on this forum, so I though I would ask.

When would you use Python (2.6) threading module or multiprocessing
module?

It seems in general python multiprocessing module should be preferred
over threading because of GIL unless threads need to share data.

Though both API being similar the switch  from coding perspective is
trivial.

( it is kind of opposite in Java.)

-- 
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: get_object_or_404 on composite key and Value Error:Invalid Literal for int with base 10

2010-12-01 Thread Daniel Roseman
On Dec 1, 6:20 pm, Pranav  wrote:
> Hi all,
>
> I'm new to django and python and i'm working on a project that works
> with a legacy database.
> I've a particular problem with a "composite key" and "get" or
> "get_object_or_404".
>
> i generated the below model form the legacy database using inspectdb
>
> model:
> --
> class Member:
>            member_id = field.CharField(max_length=20)
>            organization_id = field.Foreignkey(Organization)
>            member_type = field.CharField(max_length=10)
>            class Meta:
>                     db_table = u'member'
>                     unique_together =
> (('member_id','organization_id'),)
> # unique_together is a constraint i added in order to form the
> composite primary key
>
> class Organization:
>            organization_id = field.CharField(max_length=2)
>            organization_name = field.CharField(max_length=20)
>            class Meta:
>                     db_table = u'organization'
>
> I have a function in my view which receives a "MemOrgId" which is
> nothing but the composite key of both member_id and organization_id.
> for example the value i get is MemOrgId='AA1001', now the problem is
> when i try to use get or a get_object_or_404 i get a Value
> Error:Invalid Literal for int with base 10.
>
> obj = get_object_or_404(Member,pk = MemOrgId)
>
> i assign the object instance to my form and save the form if the form
> is valid.
>
> The Trace Back starts with my view and ends at "fields.__init__."
> which retuns int(value).
>
> According to my understanding of the trace back its not able to
> convert the key "CP1001" to int coz it contains char data along with
> int. I cannot modify the database and i cannot change the way MemOrgId
> comes to the view function. Is there a way around this problem
>
> Thanks for your help.
>
> Regards,
> Pranav Hegde.

You have misunderstood what `unique_together` does. It simply adds a
unique constraint to the table: it does not create a composite primary
key. The actual field referred to by `pk` is still simply `id`. Django
does not support composite primary keys.
--
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.



get_object_or_404 on composite key and Value Error:Invalid Literal for int with base 10

2010-12-01 Thread Pranav
Hi all,

I'm new to django and python and i'm working on a project that works
with a legacy database.
I've a particular problem with a "composite key" and "get" or
"get_object_or_404".

i generated the below model form the legacy database using inspectdb

model:
--
class Member:
   member_id = field.CharField(max_length=20)
   organization_id = field.Foreignkey(Organization)
   member_type = field.CharField(max_length=10)
   class Meta:
db_table = u'member'
unique_together =
(('member_id','organization_id'),)
# unique_together is a constraint i added in order to form the
composite primary key

class Organization:
   organization_id = field.CharField(max_length=2)
   organization_name = field.CharField(max_length=20)
   class Meta:
db_table = u'organization'

I have a function in my view which receives a "MemOrgId" which is
nothing but the composite key of both member_id and organization_id.
for example the value i get is MemOrgId='AA1001', now the problem is
when i try to use get or a get_object_or_404 i get a Value
Error:Invalid Literal for int with base 10.

obj = get_object_or_404(Member,pk = MemOrgId)

i assign the object instance to my form and save the form if the form
is valid.

The Trace Back starts with my view and ends at "fields.__init__."
which retuns int(value).

According to my understanding of the trace back its not able to
convert the key "CP1001" to int coz it contains char data along with
int. I cannot modify the database and i cannot change the way MemOrgId
comes to the view function. Is there a way around this problem

Thanks for your help.

Regards,
Pranav Hegde.




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



Unresolved import in Eclipse

2010-12-01 Thread cocolombo
Hi everyone.

I am using Eclipe 3.6.1 with Python 2.7 on Windows XP and my problem
is the following:

1) I have installed a module named : django-urlauth-0.1.1

2) In Eclipse, at the left of the line:

from urlauth.util import wrap_url

Eclipse qive a big red dot with the message : Unresolved import
wrap_url

3) But strangely If I open a shell window (django environnemnt window)
in Eclipse and type:

>> from urlauth.util import wrap_url

everything is fine and I can access the wrap_url function from the
shell window.

Any Idea what is wrong. I am new to django and Eclipse so maybe this
is trivial stuff, sorry if this is the case.

cclmb





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



signal locations

2010-12-01 Thread garagefan
Now, i've read the thread in regards to putting the import in the
__init__.py

here is my structure

website_project
- > signals
- - > signals.py (and an __init__.py)
- > shared_apps (link to numerous apps shared amongst other projects)
- - > gallery application

my signals.py looks like this

from django.db.models.signals import post_save
from django.core.mail import send_mail
from gallery.models import Gallery

def send_creation(sender, instance, *args, **kwargs):
if 'created' in kwargs:
if kwargs['created'] and instance.published:
send_mail('Subject here',[sender, instance.published,
args, kwargs,], 'f...@example.com', ['t...@example.com'],
fail_silently=False)

post_save.connect(send_creation,sender=Gallery)

this works when in the gallery application, however... this is just a
test case, eventually i am going to be hitting up the fb graph api and
posting the website's facebook profile, and i'd prefer to keep the
gallery application useful for both facebook and non-facebook
integrated websites.

I've attempted import signals and import signals.signals in the
website_project __init__.py. the former resulting in nothing and the
latter resulting in a "internal server failure" upon restart.

-- 
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 1.2.3, Oracle with Character Set WE8MSWIN1252 - 'utf8' codec can't decode bytes

2010-12-01 Thread Ian
On Nov 30, 8:31 pm, Anurag Chourasia 
wrote:
> On Oracle 10.2 with Character-Set set to WE8MSWIN1252,
>
> When using Django, I try to select a Oracle row which contains a field with
> value as 'Páginas', i encounter the following error "'utf8' codec can't
> decode bytes "

The NLS_LANG setting used by Django should guarantee that the data
comes back as UTF-8 regardless of the database character set.

What version of cx_Oracle are you using?
Is the column type VARCHAR2 or NVARCHAR2?
What do you get if you try the following, substituting the appropriate
values?

$ export NLS_LANG=.UTF8
$ python
>>> import cx_Oracle
>>> conn = cx_Oracle.connect('username/passw...@dsn')
>>> cursor = conn.cursor()
>>> cursor.execute("SELECT PROBLEM_COLUMN FROM TERMINOLOGY_MAP WHERE ID = 206")
>>> print repr(cursor.fetchone()[0])

Thanks,
Ian

-- 
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 in production on Windows

2010-12-01 Thread ashdesigner
Javier,

Thanks for your reply. We will try to explore (to some extent)
solutions you propose, hopefully it will help.

Anthony

On Dec 1, 6:26 pm, Javier Guerra Giraldez  wrote:
> On Wed, Dec 1, 2010 at 6:43 AM, ashdesigner  wrote:
> > The only undiscovered issue to us is whether we can launch a heavy
> > loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> > any comment please.
>
> a WSGI plugin for IIS would be the best answer; but there's nothing
> wrong with FastCGI.  properly managed can sustain as high load as
> anybody else.
>
> unfortunately, the most common FastCGI->WSGI adapter (flup) is quite
> good and performant; but limited in terms of dynamic process/thread
> lifetime managing.  a more 'modern' approach could be gunicorn or
> Tornado.  since both of them handle HTTP->WSGI, your IIS frontend
> would have to proxy those requests, but i guess that's a standard
> feature of any webserver
>
> --
> 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.



Re: Problem with ForeignKey to an abstract class

2010-12-01 Thread Marc Aymerich
On Wed, Dec 1, 2010 at 12:48 PM, Ferran  wrote:

>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Hello everyone,
>
> I want to have foreign keys to parent model on a manytomany
> intermediate table (through) to have unique entries for that domain.
>
> The problem is i want this parent model class to be an abstract one,
> because i don't ever want to instantiate it, using DomainOwned or
> DomainPending instead.
>
> The error i'm getting is this:
>
>  File "/home/ferran/0_ubilibet/intranet/domains/models.py", line 48,
> in ContactType
>domain = models.ForeignKey(DomainUbi)
>  File
> "/usr/lib/python2.7/site-packages/django/db/models/fields/related.py",
> line 808, in __init__
>assert not to._meta.abstract, "%s cannot define a relation with
> abstract class %s" % (self.__class__.__name__, to._meta.object_name)
> AssertionError: ForeignKey cannot define a relation with abstract
> class DomainUbi
>
> On both the foreignkeys to DomainUbi on models ContactType and
> AssociatedNameServer.
>
> I've thought maybe i can implement contacts and ns fields in both
> DomainOwned and DomainPending, using generic relationships, but it
> does not seems right to me.
>
> Can anyone help me on this, please?
>
> - ---
>
> class DomainMinimal(models.Model):
>sld = models.CharField(
>max_length=63
>)
>tld = models.ForeignKey(common.Tld)
>name = property('_domain_name')
>
>def _domain_name(self):
>return u'%s.%s' % (self.sld, self.tld)
>
>def __unicode__(self):
>return self.name
>
>class Meta:
>abstract = True
>
>
> class DomainUbi(DomainMinimal):
>owner = models.ForeignKey(contacts.Contact, related_name='Owner')
>contacts = models.ManyToManyField(contacts.Contact,
> through='ContactType')
>ns = models.ManyToManyField('NameServer',
> through='AssociatedNameServer')
>period = models.IntegerField(validators=[MaxValueValidator(10)])
>
>class Meta:
>abstract = True
>
> class DomainOwned(DomainUbi):
>crdate = models.DateField()
>exdate = models.DateField()
>
> class DomainPending(DomainUbi):
>status = None # just an example, now
>
>
> class ContactType(models.Model):
>contact = models.ForeignKey(contacts.Contact)
>domain = models.ForeignKey(DomainUbi)
>role = models.CharField(
>max_length=10,
>choices = (
>('admin', 'Administratiu'),
>('billing', 'Facturacio'),
>('tech', 'Tecnic'),
>)
>)
>class Meta:
>unique_together = ('contact', 'domain', 'role')
>
> class AssociatedNameServer(models.Model):
>ns = models.ForeignKey('NameServer')
>domain = models.ForeignKey(DomainUbi)
>priority = models.IntegerField(
>validators=[MaxValueValidator(4)]
>)
>def __unicode__(self):
>return "%s (%s)" % (self.ns.host, self.ns.ip)
>
>class Meta:
>unique_together = ('ns', 'domain', 'priority')
>


Sorry, but I don't understand at all what you're trying to do. Can you
elaborate a little more? And why you're doing a FK to an abstract class
like
domain = models.ForeignKey(DomainUbi) ?

-- 
Marc

-- 
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: Problem with ForeignKey to an abstract class

2010-12-01 Thread Ferran
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 01/12/10 12:48, Ferran wrote:
> I've thought maybe i can implement contacts and ns fields in both
> DomainOwned and DomainPending, using generic relationships, but it
> does not seems right to me.

Shame on me.

This is the right way to do it, the only way, in fact.

I really want django to solve it with his own magic, but... no.

My solution:


# class DomainUbi

change:

contacts = models.ManyToManyField(
contacts.Contact,
through='ContactType'
)

to:

contacts = GenericRelation('ContactType')

# class ContactType

change:
domain = models.ForeignKey(DomainUbi)
to:
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey()


change:
unique_together = ('contact', 'domain', 'role')
to:
unique_together = ('contact', 'role', 'content_type', 'object_id')

Thank you!
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJM9ncHAAoJEAWOKfEESaOwVYQP/1V6w8UZn1NkLWS3YC49QDkC
QRlLpzUNH13pkYOXYF+2kEL6x1ZGCyL2G33R86485Ea/KP8kLo0TJT+nEn2sjFaW
0adG13w6yoXsE0Khot9vqDwKzqBKhpt2SMXxs4nCGjE66D1bUjRutq/xMgIY8EM+
6DJr1B7u1/n5jH/TKOOmfn3xcpo16Fe3rYc5udVoxa6tWdbMHIakozI2pkec+AMU
kDOlQg3OROCSSzurcjCybN4YNRW6bEM+9auh/jPaRXTry9vfy7wZyCn0Oije9knL
8l0v2JUZbmZTlZpFTX+oM/sziKN8s6EhgDWBH3Ii3WwapMFcEMa9vo8Ejb7SQUPL
HlfCxjjkeOHP07Eb/OkpWO7uACA2SF2Z4XLLG3+kxT9fP6trwRa2N0/8pZ+JFDh2
/ujTtGCGQIfG5dbjXB3sZfmT6h191MKMhKSpxmGfpH1JqFVQ6NIc7Kd3OwnKYi99
bYlFb3O1j2MwslTxrMxhhMOizdo0QEIbUYIdHCYXyes4ibecD7ZufT2tF6D/Y4P+
BLzj5ASqyRrnfWHNq1NRjLHm0CT27iXhMjn4AQjXae9vp1gUNMwA6d5h0LQmahTG
2bQ8VOxWvHwbjbJpTjHIcGt4396hkTa/Zcca4JuD5MwdHGvc8tqgpM4JYv9vw4m4
JM8ncLHB8bem+UoiquGk
=BCc+
-END PGP SIGNATURE-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Loading CSS

2010-12-01 Thread octopusgrabbus
My question is what do I need to do to straighten out the media path,
so I can load amr.css.

When trying to load amr.css, my application gets a 404.
10.100.0.88 - - [01/Dec/2010:10:03:06 -0500] "GET /css/amr.css HTTP/
1.1" 404 228
6 "http://amrserver:8002/; "Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:
1.9.2.12)
 Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.6.12"

Here's where amr.css is loaded in base.html




{% block title %}Town of Arlington Water Department AMR
System{% endblock %} 

   

Here are the paths in settings.py

MEDIA_ROOT = '/home/amr/django/amr/'
MEDIA_URL = 'media/'
ADMIN_MEDIA_PREFIX = '/media/'

The path to amr.css is /home/amr/django/amr/media/css

and here is the configuration from apache

Listen 8002

Alias /media /home/amr/django/amr/media

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
SetEnv PYTHON_EGG_CACHE /tmp/.python_eggs
PythonOption django.root /home/amr/django/amr
PythonPath "['/home/amr/django/amr/bin', '/home/amr/django', '/
home/amr/djan
go/amr', '/home/amr/django/amr/media', '/home/django/amr/media/css'] +
sys.path"
PythonDebug On

Any thoughts or pointers would be appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Unique querysets

2010-12-01 Thread cootetom
Excellent, thank you. That does the trick!




On Dec 1, 3:15 pm, Tom Evans  wrote:
> On Wed, Dec 1, 2010 at 3:07 PM, cootetom  wrote:
> > Hi, I have a question about the ORM.
>
> > If I have model class's:
>
> > class Event(models.Model):
> >    
>
> > class Ticket(models.Model):
> >    user = models.ForeignKey(User)
> >    event = models.ForeignKey(Event)
> >    .
>
> > Then I have a user who has 2 tickets for the same event. If I have the
> > event object and want to see who has tickets I could do this:
>
> > an_event.ticket_set.all()
>
> > However that will result in a list of tickets which isn't necessarily
> > a unique list of people who have tickets to the event. In my example
> > the user has 2 tickets for one event so I would get two ticket objects
> > back in my query set. How do I limit the query set results to say
> > don't give me more than one ticket for the event per user.
>
> > Hope that makes sense?
>
> User.objects.filter(ticket__event=ev).distinct() ?
>
> HTH
>
> 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: MySQL error

2010-12-01 Thread Tom Evans
On Wed, Dec 1, 2010 at 3:24 PM,   wrote:
> Thanks Tom, which one should I download for my django project?
> There are about 9 files.
>
> Kindly revert.
>
> Regards.
> Sent from my BlackBerry wireless device from MTN
>

I don't know; haven't used windows for ~10 years.

Google for 'python mysql windows howto' returns this top link..

http://stackoverflow.com/questions/645943/mysql-for-python-in-windows

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: Django in production on Windows

2010-12-01 Thread Javier Guerra Giraldez
On Wed, Dec 1, 2010 at 6:43 AM, ashdesigner  wrote:
> The only undiscovered issue to us is whether we can launch a heavy
> loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> any comment please.

a WSGI plugin for IIS would be the best answer; but there's nothing
wrong with FastCGI.  properly managed can sustain as high load as
anybody else.

unfortunately, the most common FastCGI->WSGI adapter (flup) is quite
good and performant; but limited in terms of dynamic process/thread
lifetime managing.  a more 'modern' approach could be gunicorn or
Tornado.  since both of them handle HTTP->WSGI, your IIS frontend
would have to proxy those requests, but i guess that's a standard
feature of any webserver

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



Re: MySQL error

2010-12-01 Thread delegbede
Thanks Tom, which one should I download for my django project?
There are about 9 files. 

Kindly revert. 

Regards. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: Tom Evans 
Sender: django-users@googlegroups.com
Date: Wed, 1 Dec 2010 12:46:53 
To: 
Reply-To: django-users@googlegroups.com
Subject: Re: MySQL error

On Wed, Dec 1, 2010 at 10:09 AM,   wrote:
> I am starting out to learn django and I am using the book: Beginning Django 
> E-Commerce by Jim McGaw.
> I was able to create the database using mysql console but when I ran the 
> command:
> $ python manager.py dbshell
>
> I got the following error:
>
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No 
> mo
> dule named MySQLdb
>
> Please what am I doing wrong.
> Let me add that I installed wamp so the mysql I am using in bundled with 
> apache and php. I hope that is not the problem.
>
> I hope to get a feedback.
>

You need to install the python mysql driver. I have no idea what
'wamp' is, but I'm guessing it is some sort of bundled
apache/php/mysql stack? You will need to install the python mysql
driver in addition to that.

http://sourceforge.net/projects/mysql-python/

> Thank you.
> Sent from my BlackBerry wireless device from MTN
>

You wrote all that on a blackberry? Fair play..

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.

-- 
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 in production on Windows

2010-12-01 Thread ashdesigner
Lloyd,

No it is not a must, but is highly desirable by our IT dpt. You see,
currently we don't have a *nix admin, so Windows deployment would be
an advantage.

Anthony

On Dec 1, 5:52 pm, Sithembewena Lloyd Dube  wrote:
> Hi Antony, it's a pleasure.
>
> Regarding your last question - I am sure you could get a Django/ IIS7 setup
> to work,
> but I am also sure that you would get more support from the community for
> deploying on Apache or other open source web servers than on IIS.
>
> Anyhow, here are more links that speak to that:
>
> http://sourceforge.net/apps/trac/pyisapiehttp://pypi.python.org/pypi/PyISAPIe/1.0.130http://stackoverflow.com/questions/704368/django-working-under-iis7http://stackoverflow.com/questions/374760/are-there-any-plans-to-offi...
>
> Is it an absolute must that you use Windows to deploy?
>
> Regards,
> Lloyd
>
> On Wed, Dec 1, 2010 at 3:40 PM, ashdesigner wrote:
>
>
>
> > Pete,
>
> > Does this mean that we shouldn't even try to run it on IIS7 in
> > production?
>
> > On Dec 1, 4:27 pm, CrabbyPete  wrote:
> > > I developed Djano on a windows server and everything went smoothly
> > > except getting it to work with IIS. I loaded apache on windows and it
> > > works great.
>
> > > On Dec 1, 6:43 am, ashdesigner  wrote:
>
> > > > Hello,
>
> > > > I am absolutely new to Python/Django. Being responsible for a large
> > > > corporate startup project and having looked through a number of MVC/
> > > > MVT frameworks I decided to outsource the webproject in Django.
>
> > > > The only undiscovered issue to us is whether we can launch a heavy
> > > > loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> > > > any comment please.
>
> > > > Anthony
>
> > --
> > 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.
>
> --
> Regards,
> Sithembewena Lloyd Dube

-- 
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: Loading CSS

2010-12-01 Thread octopusgrabbus
Your right. I should have looked in the logs, and the directory path
is wrong.

10.100.0.88 - - [01/Dec/2010:10:03:06 -0500] "GET /css/amr.css HTTP/
1.1" 404 228
6 "http://amrserver:8002/; "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:
1.9.2.12)
 Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.6.12"


On Dec 1, 10:02 am, Tom Evans  wrote:
> On Wed, Dec 1, 2010 at 2:48 PM, octopusgrabbus
>
>  wrote:
> > Thank you. I've done made changes according to your suggestions, but
> > the css appears not to load. I am using apache, not the built-in web
> > server.
>
> Are you expecting django to serve the file through apache or apache to
> directly serve the file?
>
> How have you configured apache?
>
> What is output in apache's access log when you try to access the file?
>
> You really need to provide more information. "It doesn't work" doesn't
> really help debug.
>
> 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: Unique querysets

2010-12-01 Thread Tom Evans
On Wed, Dec 1, 2010 at 3:07 PM, cootetom  wrote:
> Hi, I have a question about the ORM.
>
> If I have model class's:
>
> class Event(models.Model):
>    
>
> class Ticket(models.Model):
>    user = models.ForeignKey(User)
>    event = models.ForeignKey(Event)
>    .
>
> Then I have a user who has 2 tickets for the same event. If I have the
> event object and want to see who has tickets I could do this:
>
> an_event.ticket_set.all()
>
> However that will result in a list of tickets which isn't necessarily
> a unique list of people who have tickets to the event. In my example
> the user has 2 tickets for one event so I would get two ticket objects
> back in my query set. How do I limit the query set results to say
> don't give me more than one ticket for the event per user.
>
> Hope that makes sense?
>

User.objects.filter(ticket__event=ev).distinct() ?

HTH

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: Loading CSS

2010-12-01 Thread Tom Evans
On Wed, Dec 1, 2010 at 3:02 PM, Tom Evans  wrote:
> Are you expecting django to serve the file through apache or apache to
> directly serve the file?
>
> How have you configured apache?
>
> What is output in apache's access log when you try to access the file?
>
> You really need to provide more information. "It doesn't work" doesn't
> really help debug.
>
> Cheers
>
> Tom
>

I don't mean to repeat myself, but you still haven't given any of this
information, so there are diminishing returns to helping you further.
How you have configured apache to serve django affects this issue, and
without the information, I'm just speculating.

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.



Unique querysets

2010-12-01 Thread cootetom
Hi, I have a question about the ORM.

If I have model class's:

class Event(models.Model):


class Ticket(models.Model):
user = models.ForeignKey(User)
event = models.ForeignKey(Event)
.

Then I have a user who has 2 tickets for the same event. If I have the
event object and want to see who has tickets I could do this:

an_event.ticket_set.all()

However that will result in a list of tickets which isn't necessarily
a unique list of people who have tickets to the event. In my example
the user has 2 tickets for one event so I would get two ticket objects
back in my query set. How do I limit the query set results to say
don't give me more than one ticket for the event per user.

Hope that makes sense?

-- 
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: Loading CSS

2010-12-01 Thread octopusgrabbus
Thank you. I've done made changes according to your suggestions, but
the css appears not to load. I am using apache, not the built-in web
server.

On Nov 30, 5:14 pm, Robert S  wrote:
> Well - that's one way
> A simpler way is to use your settings.py file to point to your media,
> and remove all reference to .css from your url.py files
>
> ...
>
> # Absolute path to the directory that holds media.
> # Example: "/home/media/media.lawrence.com/"
> MEDIA_ROOT = '/path_to_media_root/static_media/'
>
> # URL that handles the media served from MEDIA_ROOT. Make sure to use
> a
> # trailing slash if there is a path component (optional in other
> cases).
> # Examples: "http://media.lawrence.com;, "http://example.com/media/;
> MEDIA_URL = '/static_media/'
>
> ...

-- 
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: Loading CSS

2010-12-01 Thread Tom Evans
On Wed, Dec 1, 2010 at 2:48 PM, octopusgrabbus
 wrote:
> Thank you. I've done made changes according to your suggestions, but
> the css appears not to load. I am using apache, not the built-in web
> server.
>

Are you expecting django to serve the file through apache or apache to
directly serve the file?

How have you configured apache?

What is output in apache's access log when you try to access the file?

You really need to provide more information. "It doesn't work" doesn't
really help debug.

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: Loading CSS

2010-12-01 Thread octopusgrabbus
Thanks for your comments:

Here are the changes I've made, and it still does not load:

A directory css is under the main media directory

a...@h2oamr:~/django/amr$ ls -l media/css
total 4
-rw-r--r-- 1 amr amr 72 Nov 30 14:45 amr.css


Here are the settings.py changes:

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/home/amr/django/media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com;, "http://example.com/media/;
MEDIA_URL = '/media/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/;, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

ROOT_URLCONF = 'amr.urls'
STATIC_DOC_ROOT = '/home/amr/django/media'

And here's the reference to it in the base template.




{% block title %}Town of Arlington Water Department AMR
System{% endblock %} 

   



On Dec 1, 4:51 am, Tom Evans  wrote:
> On Tue, Nov 30, 2010 at 6:21 PM, octopusgrabbus
>
>  wrote:
> > I am running Django 1.2.3 -- python -c "import django; print
> > django.get_version()" I basically need to know what logs to look at to
> > fix a css file not loading.
>
> > I am trying to load a css file in my base template
>
> > 
> >    
> >    
> >        {% block title %}Town of Arlington Water Department AMR
> > System{% endblock %} 
> >        
> >   
>
> So you are requesting the file '/static_media/amr.css'
>
>
>
> > Here's the css file -- you could say it's a "test file".
>
> > body{ background-color: gray;}
> > p { color: blue; }
> > h3{ color: white; }
>
> > In urls.py this is inserted into
>
> > urlpatterns = patterns('',
>
> >    (r'^site_media/(?P.*)$', 'django.views.static.serve',
> >        {'document_root': '/home/amr/django'}),
>
> and you are enabling file serving from a path starting '/site_media/'
> (assuming this is your root urlconf).
>
> Is it clear why it isn't working now? 'site_media' != 'static_media'.
>
> In your django dev console, it shows each URL requested, and the HTTP
> return code. It will look something like this:
>
> [01/Dec/2010 09:38:47] "GET /static_media/amr.css HTTP/1.1" 404 2572
>
> The first part ('/static_media/') has to match the URL you put in your
> urlconf, and the second part ('amr.css') must exist in the folder that
> you specify as document_root (or subfolder etc).
>
> This isn't exactly rocket science, just make everything match up, and it 
> works.
>
> BTW, in your template you can use {{ MEDIA_URL }} to get the prefix to
> your media - assuming you have correctly set settings.MEDIA_URL, and
> have django.core.context_processors.media in
> TEMPLATE_CONTEXT_PROCESSORS and use a RequestContext to render with,
> which is a few caveats I guess :)
>
> 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.



order by rand not working with postgree

2010-12-01 Thread bastir
Hey,

why is a query like order:by('?') in postgree not working. It works
great in sqlite.

thx
sebastian

-- 
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 in production on Windows

2010-12-01 Thread Sithembewena Lloyd Dube
Hi Antony, it's a pleasure.

Regarding your last question - I am sure you could get a Django/ IIS7 setup
to work,
but I am also sure that you would get more support from the community for
deploying on Apache or other open source web servers than on IIS.

Anyhow, here are more links that speak to that:

http://sourceforge.net/apps/trac/pyisapie
http://pypi.python.org/pypi/PyISAPIe/1.0.130
http://stackoverflow.com/questions/704368/django-working-under-iis7
http://stackoverflow.com/questions/374760/are-there-any-plans-to-officially-support-django-with-iis

Is it an absolute must that you use Windows to deploy?

Regards,
Lloyd

On Wed, Dec 1, 2010 at 3:40 PM, ashdesigner wrote:

> Pete,
>
> Does this mean that we shouldn't even try to run it on IIS7 in
> production?
>
> On Dec 1, 4:27 pm, CrabbyPete  wrote:
> > I developed Djano on a windows server and everything went smoothly
> > except getting it to work with IIS. I loaded apache on windows and it
> > works great.
> >
> > On Dec 1, 6:43 am, ashdesigner  wrote:
> >
> > > Hello,
> >
> > > I am absolutely new to Python/Django. Being responsible for a large
> > > corporate startup project and having looked through a number of MVC/
> > > MVT frameworks I decided to outsource the webproject in Django.
> >
> > > The only undiscovered issue to us is whether we can launch a heavy
> > > loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> > > any comment please.
> >
> > > Anthony
>
> --
> 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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube

-- 
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: minidom parsestring error

2010-12-01 Thread vamsy krishna
I see a 502 Bad Request on the browser and the server is auto-shutting
down. I do not see any error logs even though am using a try except
block for the line

file_xml = minidom.parseString(file_feed)

None of the logs output beyond this line and the execution seems to
halt. I haven't seen a 502 error on the server before. This is a new
code.

On Dec 1, 7:06 pm, Daniel Roseman  wrote:
> On Dec 1, 1:18 pm, vamsy krishna  wrote:
>
>
>
> > Hi,
>
> > I have a function to read and display an RSS feed which is working as
> > expected in my local Apache. However I'm getting a HTTP 502 error when
> > I access the same on Webfaction. Below is a snippet from my code and
> > the error is originating from the last step involving parsing.
>
> > Like i mentioned the below code works locally with the same feed and
> > this also works on the python shell on Webfaction. However is is
> > failing while accessing through my browser. Any help will be
> > appreciated. Thanks
>
> >     feed_url = 'http://blog.ionlab.in/feed/'
> >     file_request = urllib2.Request(feed_url)
> >     file_opener = urllib2.build_opener()
> >     file_feed = file_opener.open(file_request).read()
> >     file_xml = minidom.parseString(file_feed)
>
> Failing how? What is the error?
> --
> 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: minidom parsestring error

2010-12-01 Thread Daniel Roseman
On Dec 1, 1:18 pm, vamsy krishna  wrote:
> Hi,
>
> I have a function to read and display an RSS feed which is working as
> expected in my local Apache. However I'm getting a HTTP 502 error when
> I access the same on Webfaction. Below is a snippet from my code and
> the error is originating from the last step involving parsing.
>
> Like i mentioned the below code works locally with the same feed and
> this also works on the python shell on Webfaction. However is is
> failing while accessing through my browser. Any help will be
> appreciated. Thanks
>
>     feed_url = 'http://blog.ionlab.in/feed/'
>     file_request = urllib2.Request(feed_url)
>     file_opener = urllib2.build_opener()
>     file_feed = file_opener.open(file_request).read()
>     file_xml = minidom.parseString(file_feed)

Failing how? What is the error?
--
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 in production on Windows

2010-12-01 Thread ashdesigner
Pete,

Does this mean that we shouldn't even try to run it on IIS7 in
production?

On Dec 1, 4:27 pm, CrabbyPete  wrote:
> I developed Djano on a windows server and everything went smoothly
> except getting it to work with IIS. I loaded apache on windows and it
> works great.
>
> On Dec 1, 6:43 am, ashdesigner  wrote:
>
> > Hello,
>
> > I am absolutely new to Python/Django. Being responsible for a large
> > corporate startup project and having looked through a number of MVC/
> > MVT frameworks I decided to outsource the webproject in Django.
>
> > The only undiscovered issue to us is whether we can launch a heavy
> > loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> > any comment please.
>
> > Anthony

-- 
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 in production on Windows

2010-12-01 Thread ashdesigner
Hi Lloyd,

Thank you so much for your reply. You see, the new project is still
currently regarded of as probationary, though the choice of the Django
framework is agreed and seems to be confident.

The issue is that we will be running a separate VPS for the project,
and Windows+IIS+MSSQL perfectly suits our current administration
facilities. In other words, we would prefer adminstrating Win+IIS
rather than Unix+Apache or whatever. Nonetheless, I can't afford
making wrong choice of the platform so I need advice from a real
practice.

Regards,
Anthony

On Dec 1, 4:03 pm, Sithembewena Lloyd Dube  wrote:
> Antony, you might also want to have a look at this:
>
> http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts
>
> Regards,
> Lloyd
>
> On Wed, Dec 1, 2010 at 1:43 PM, ashdesigner wrote:
>
>
>
> > Hello,
>
> > I am absolutely new to Python/Django. Being responsible for a large
> > corporate startup project and having looked through a number of MVC/
> > MVT frameworks I decided to outsource the webproject in Django.
>
> > The only undiscovered issue to us is whether we can launch a heavy
> > loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> > any comment please.
>
> > Anthony
>
> > --
> > 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.
>
> --
> Regards,
> Sithembewena Lloyd Dube

-- 
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 in production on Windows

2010-12-01 Thread CrabbyPete
I developed Djano on a windows server and everything went smoothly
except getting it to work with IIS. I loaded apache on windows and it
works great.

On Dec 1, 6:43 am, ashdesigner  wrote:
> Hello,
>
> I am absolutely new to Python/Django. Being responsible for a large
> corporate startup project and having looked through a number of MVC/
> MVT frameworks I decided to outsource the webproject in Django.
>
> The only undiscovered issue to us is whether we can launch a heavy
> loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> any comment please.
>
> Anthony

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



minidom parsestring error

2010-12-01 Thread vamsy krishna
Hi,

I have a function to read and display an RSS feed which is working as
expected in my local Apache. However I'm getting a HTTP 502 error when
I access the same on Webfaction. Below is a snippet from my code and
the error is originating from the last step involving parsing.

Like i mentioned the below code works locally with the same feed and
this also works on the python shell on Webfaction. However is is
failing while accessing through my browser. Any help will be
appreciated. Thanks

feed_url = 'http://blog.ionlab.in/feed/'
file_request = urllib2.Request(feed_url)
file_opener = urllib2.build_opener()
file_feed = file_opener.open(file_request).read()
file_xml = minidom.parseString(file_feed)

-- 
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 in production on Windows

2010-12-01 Thread Sithembewena Lloyd Dube
Antony, you might also want to have a look at this:

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

Regards,
Lloyd


On Wed, Dec 1, 2010 at 1:43 PM, ashdesigner wrote:

> Hello,
>
> I am absolutely new to Python/Django. Being responsible for a large
> corporate startup project and having looked through a number of MVC/
> MVT frameworks I decided to outsource the webproject in Django.
>
> The only undiscovered issue to us is whether we can launch a heavy
> loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> any comment please.
>
> Anthony
>
> --
> 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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube

-- 
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: script adding FileField, no attribute chunks

2010-12-01 Thread Andrew Marder
Awesome! Thanks so much for the help.

Andrew

On Wed, 2010-12-01 at 12:32 +, Tom Evans wrote:
> On Wed, Dec 1, 2010 at 12:23 PM, Andrew Marder
>  wrote:
> > I'm trying to add a bunch of files from disk into my django database.
> > Here's the helper function I've written so far:
> >
> > def django_file(path, field_name, content_type):
> ># adapted from here: 
> > http://groups.google.com/group/django-users/browse_thread/thread/834f988876ff3c45/
> >from django.core.files.uploadedfile import InMemoryUploadedFile
> >f = open(path)
> >return InMemoryUploadedFile(
> >file=f,
> >field_name=field_name,
> >name=file.name,
> 
> This should be 'f.name', not 'file.name'. file is a built in class in
> python, and file.name is a member of that class, not your file name.
> 
> Cheers
> 
> Tom
> 
> >content_type=content_type,
> >size=os.path.getsize(path),
> >charset=None)
> >
> 
> 
> 
> > I'm calling it like so:
> > django_file("path-to-jpg-file", field_name="image",
> > content_type="image/jpeg")
> >
> > Here's the error I'm getting:
> > Traceback (most recent call last):
> >  File "", line 1, in 
> >  File "/home/amarder/Documents/nmis/odk_dropbox/views.py", line 49,
> > in import_instances_folder
> >f = django_file(xml_files[0], field_name="xml_file",
> > content_type="text/xml")
> >  File "/home/amarder/Documents/nmis/odk_dropbox/views.py", line 70,
> > in django_file
> >charset=None)
> >  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
> > packages/django/core/files/uploadedfile.py", line 90, in __init__
> >super(InMemoryUploadedFile, self).__init__(file, name,
> > content_type, size, charset)
> >  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
> > packages/django/core/files/uploadedfile.py", line 30, in __init__
> >super(UploadedFile, self).__init__(file, name)
> >  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
> > packages/django/core/files/base.py", line 17, in __init__
> >self.name = name
> >  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
> > packages/django/core/files/uploadedfile.py", line 46, in _set_name
> >name = os.path.basename(name)
> >  File "/home/amarder/Documents/environments/nmis/lib/python2.6/
> > posixpath.py", line 111, in basename
> >i = p.rfind('/') + 1
> > AttributeError: 'member_descriptor' object has no attribute 'rfind'
> >
> > Any suggestions?
> >
> > Andrew
> >
> > On Nov 16, 4:36 pm, Mitch Anderson  wrote:
> >> On Tue, Nov 16, 2010 at 3:28 AM, Tom Evans  
> >> wrote:
> >> > Django doesn't want a python file or text for a django file field, it
> >> > wants a django.core.files.File. I find the easiest one to use is the
> >> > InMemoryUploadedFile. Here is a snippet I use for fetching an image
> >> > from the web, and creating a django.core.files.File object that can be
> >> > assigned to a FileField or ImageField on a model:
> >>
> >> >  h = httplib2.Http()
> >> >  req, content = h.request(uri)
> >> >  if req['status'] != '200':
> >> >print u'Failed to fetch image from %s' % uri
> >> >return None
> >>
> >> >  import cStringIO
> >> >  from django.core.files.uploadedfile import InMemoryUploadedFile
> >> >  out = cStringIO.StringIO()
> >> >  out.write(content)
> >> >  return InMemoryUploadedFile(
> >> >  file=out,
> >> >  field_name=field,
> >> >  name=name,
> >> >  content_type=req['content-type'],
> >> >  size=out.tell(),
> >> >  charset=None)
> >>
> >> > field should be the name of the field on the model, name should be the
> >> > file name of the resource.
> >>
> >> > There may be neater ways of doing this, but this keeps it in memory
> >> > until django saves it to the upload_to location specified on the
> >> > model, and avoids writing it to disk only for django to write it to
> >> > disk again.
> >>
> >> > Cheers
> >>
> >> > Tom
> >>
> >> Awesome that worked perfectly!  Thanks 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.
> >
> >
> 


-- 
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 in production on Windows

2010-12-01 Thread Sithembewena Lloyd Dube
Hi Anthony,

I was in a situation similar to yours not too long ago - introduced Django
at work and we've enjoyed it. We are getting better time to market than we
would with other options (PHP, .NET etc). Also, coding in Python has been
great fun.
So, good choice.

As to your question, I have no experience running Django on Windows other
than using the development server. I think that you'd be best off finding
good Linux hosting - WebFaction, Linode etc.

Some links that may help:
http://djangofriendly.com/hosts/
http://djangohosting.org/

Regards,
Lloyd

On Wed, Dec 1, 2010 at 1:43 PM, ashdesigner wrote:

> Hello,
>
> I am absolutely new to Python/Django. Being responsible for a large
> corporate startup project and having looked through a number of MVC/
> MVT frameworks I decided to outsource the webproject in Django.
>
> The only undiscovered issue to us is whether we can launch a heavy
> loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> any comment please.
>
> Anthony
>
> --
> 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.
>
>


-- 
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: MySQL error

2010-12-01 Thread Tom Evans
On Wed, Dec 1, 2010 at 10:09 AM,   wrote:
> I am starting out to learn django and I am using the book: Beginning Django 
> E-Commerce by Jim McGaw.
> I was able to create the database using mysql console but when I ran the 
> command:
> $ python manager.py dbshell
>
> I got the following error:
>
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No 
> mo
> dule named MySQLdb
>
> Please what am I doing wrong.
> Let me add that I installed wamp so the mysql I am using in bundled with 
> apache and php. I hope that is not the problem.
>
> I hope to get a feedback.
>

You need to install the python mysql driver. I have no idea what
'wamp' is, but I'm guessing it is some sort of bundled
apache/php/mysql stack? You will need to install the python mysql
driver in addition to that.

http://sourceforge.net/projects/mysql-python/

> Thank you.
> Sent from my BlackBerry wireless device from MTN
>

You wrote all that on a blackberry? Fair play..

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.



problem with media

2010-12-01 Thread Emanuel Vitorino
Hi all!

I've recently updated my django version and now all my projects doesn't have
css and js from admin or from my apps

I've started new projects and it simply doesn't work

I've googled and I find out when we are using the deveopment server the
static files from admin should be server automatticly and yet doesn't work.

>From my own apps I'm using the django.contrib.staticfiles app and my old
code doesn't work.

My settings.py have this code:

import os
PROJECT_ROOT = os.path.dirname(__file__)
ROOT_DIR = os.path.dirname(PROJECT_ROOT)
...
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/s/media/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATIC_URL = '/s/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_DIRS = ()
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
...
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
...
TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
)
...

My urls.py have this code:
urlpatterns += staticfiles_urlpatterns()

#This was the old version:
#if settings.DEBUG:
#urlpatterns += patterns('django.contrib.staticfiles.views',
   #(r'^%s(?P.*)' % settings.STATIC_URL, 'serve',
{'document_root': 'sss'}),#settings.STATIC_ROOT
#)


Before I realized that the admin was also with the same problem, I've edited
the django.contib.static.serve where I put a print statement like this:
print "%s -- %s" $ (path, document_root)
The result was:
/css/main.css -- None
I guess that the var document_root it's not being sent. I don't know...

Thanks in advanced

-- 
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 in production on Windows

2010-12-01 Thread ashdesigner
Hello,

I am absolutely new to Python/Django. Being responsible for a large
corporate startup project and having looked through a number of MVC/
MVT frameworks I decided to outsource the webproject in Django.

The only undiscovered issue to us is whether we can launch a heavy
loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
any comment please.

Anthony

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



Inconsistant Behaviour with TemplateSyntaxError.

2010-12-01 Thread porangi.chris
Hi,

I'm getting very inconsistant behavior with my Django system(s).   I'm
getting errors to this affect:

Caught ViewDoesNotExist while rendering: Tried admin_views in module
client_system. Error was: 'client_system.admin_views' is not a
callable.

or

Caught ViewDoesNotExist while rendering: Tried index in module
client_system.admin_views. Error was: 'module' object has no attribute
'index'

but if I refresh the page then most times it will work just fine.
This example is my simple client-system which runs across a LAN.  It
is on a Ubuntu 10.10 server running apache2 with mod_wsgi.  Its the
latest version of Django 1.2.3 as I installed it only at the weekend.
What's wrong or what have I done wrong.

I've had it with a previous project once I moved it from one server to
another - is it a problem with the pre-compiled pyc files?  Can I
recompile them?

Please please help me!!!

Thanks

Chris

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



MySQL error

2010-12-01 Thread delegbede
I am starting out to learn django and I am using the book: Beginning Django 
E-Commerce by Jim McGaw. 
I was able to create the database using mysql console but when I ran the 
command: 
$ python manager.py dbshell

I got the following error:

ow...@dipo /c/python26/djangojobs/ecomstore
$ python manage.py dbshell
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\managem
ent\__init__.py", line 438, in execute_manager
utility.execute()
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\managem
ent\__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\managem
ent\__init__.py", line 257, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\managem
ent\__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\utils\import
lib.py", line 35, in import_module
__import__(name)
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\managem
ent\commands\dbshell.py", line 4, in 
from django.db import connections, DEFAULT_DB_ALIAS
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\db\__init__.
py", line 75, in 
connection = connections[DEFAULT_DB_ALIAS]
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\db\utils.py"
, line 91, in __getitem__
backend = load_backend(db['ENGINE'])
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\db\utils.py"
, line 32, in load_backend
return import_module('.base', backend_name)
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\utils\import
lib.py", line 35, in import_module
__import__(name)
  File "c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\db\backends\
mysql\base.py", line 14, in 
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo
dule named MySQLdb

Please what am I doing wrong. 
Let me add that I installed wamp so the mysql I am using in bundled with apache 
and php. I hope that is not the problem. 

I hope to get a feedback. 

Thank you. 
Sent from my BlackBerry wireless device from MTN

-- 
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: script adding FileField, no attribute chunks

2010-12-01 Thread Tom Evans
On Wed, Dec 1, 2010 at 12:23 PM, Andrew Marder
 wrote:
> I'm trying to add a bunch of files from disk into my django database.
> Here's the helper function I've written so far:
>
> def django_file(path, field_name, content_type):
>    # adapted from here: 
> http://groups.google.com/group/django-users/browse_thread/thread/834f988876ff3c45/
>    from django.core.files.uploadedfile import InMemoryUploadedFile
>    f = open(path)
>    return InMemoryUploadedFile(
>        file=f,
>        field_name=field_name,
>        name=file.name,

This should be 'f.name', not 'file.name'. file is a built in class in
python, and file.name is a member of that class, not your file name.

Cheers

Tom

>        content_type=content_type,
>        size=os.path.getsize(path),
>        charset=None)
>



> I'm calling it like so:
> django_file("path-to-jpg-file", field_name="image",
> content_type="image/jpeg")
>
> Here's the error I'm getting:
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "/home/amarder/Documents/nmis/odk_dropbox/views.py", line 49,
> in import_instances_folder
>    f = django_file(xml_files[0], field_name="xml_file",
> content_type="text/xml")
>  File "/home/amarder/Documents/nmis/odk_dropbox/views.py", line 70,
> in django_file
>    charset=None)
>  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
> packages/django/core/files/uploadedfile.py", line 90, in __init__
>    super(InMemoryUploadedFile, self).__init__(file, name,
> content_type, size, charset)
>  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
> packages/django/core/files/uploadedfile.py", line 30, in __init__
>    super(UploadedFile, self).__init__(file, name)
>  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
> packages/django/core/files/base.py", line 17, in __init__
>    self.name = name
>  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
> packages/django/core/files/uploadedfile.py", line 46, in _set_name
>    name = os.path.basename(name)
>  File "/home/amarder/Documents/environments/nmis/lib/python2.6/
> posixpath.py", line 111, in basename
>    i = p.rfind('/') + 1
> AttributeError: 'member_descriptor' object has no attribute 'rfind'
>
> Any suggestions?
>
> Andrew
>
> On Nov 16, 4:36 pm, Mitch Anderson  wrote:
>> On Tue, Nov 16, 2010 at 3:28 AM, Tom Evans  wrote:
>> > Django doesn't want a python file or text for a django file field, it
>> > wants a django.core.files.File. I find the easiest one to use is the
>> > InMemoryUploadedFile. Here is a snippet I use for fetching an image
>> > from the web, and creating a django.core.files.File object that can be
>> > assigned to a FileField or ImageField on a model:
>>
>> >  h = httplib2.Http()
>> >  req, content = h.request(uri)
>> >  if req['status'] != '200':
>> >    print u'Failed to fetch image from %s' % uri
>> >    return None
>>
>> >  import cStringIO
>> >  from django.core.files.uploadedfile import InMemoryUploadedFile
>> >  out = cStringIO.StringIO()
>> >  out.write(content)
>> >  return InMemoryUploadedFile(
>> >      file=out,
>> >      field_name=field,
>> >      name=name,
>> >      content_type=req['content-type'],
>> >      size=out.tell(),
>> >      charset=None)
>>
>> > field should be the name of the field on the model, name should be the
>> > file name of the resource.
>>
>> > There may be neater ways of doing this, but this keeps it in memory
>> > until django saves it to the upload_to location specified on the
>> > model, and avoids writing it to disk only for django to write it to
>> > disk again.
>>
>> > Cheers
>>
>> > Tom
>>
>> Awesome that worked perfectly!  Thanks 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.
>
>

-- 
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: script adding FileField, no attribute chunks

2010-12-01 Thread Andrew Marder
I'm trying to add a bunch of files from disk into my django database.
Here's the helper function I've written so far:

def django_file(path, field_name, content_type):
# adapted from here: 
http://groups.google.com/group/django-users/browse_thread/thread/834f988876ff3c45/
from django.core.files.uploadedfile import InMemoryUploadedFile
f = open(path)
return InMemoryUploadedFile(
file=f,
field_name=field_name,
name=file.name,
content_type=content_type,
size=os.path.getsize(path),
charset=None)

I'm calling it like so:
django_file("path-to-jpg-file", field_name="image",
content_type="image/jpeg")

Here's the error I'm getting:
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/amarder/Documents/nmis/odk_dropbox/views.py", line 49,
in import_instances_folder
f = django_file(xml_files[0], field_name="xml_file",
content_type="text/xml")
  File "/home/amarder/Documents/nmis/odk_dropbox/views.py", line 70,
in django_file
charset=None)
  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
packages/django/core/files/uploadedfile.py", line 90, in __init__
super(InMemoryUploadedFile, self).__init__(file, name,
content_type, size, charset)
  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
packages/django/core/files/uploadedfile.py", line 30, in __init__
super(UploadedFile, self).__init__(file, name)
  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
packages/django/core/files/base.py", line 17, in __init__
self.name = name
  File "/home/amarder/Documents/environments/nmis/lib/python2.6/site-
packages/django/core/files/uploadedfile.py", line 46, in _set_name
name = os.path.basename(name)
  File "/home/amarder/Documents/environments/nmis/lib/python2.6/
posixpath.py", line 111, in basename
i = p.rfind('/') + 1
AttributeError: 'member_descriptor' object has no attribute 'rfind'

Any suggestions?

Andrew

On Nov 16, 4:36 pm, Mitch Anderson  wrote:
> On Tue, Nov 16, 2010 at 3:28 AM, Tom Evans  wrote:
> > Django doesn't want a python file or text for a django file field, it
> > wants a django.core.files.File. I find the easiest one to use is the
> > InMemoryUploadedFile. Here is a snippet I use for fetching an image
> > from the web, and creating a django.core.files.File object that can be
> > assigned to a FileField or ImageField on a model:
>
> >  h = httplib2.Http()
> >  req, content = h.request(uri)
> >  if req['status'] != '200':
> >    print u'Failed to fetch image from %s' % uri
> >    return None
>
> >  import cStringIO
> >  from django.core.files.uploadedfile import InMemoryUploadedFile
> >  out = cStringIO.StringIO()
> >  out.write(content)
> >  return InMemoryUploadedFile(
> >      file=out,
> >      field_name=field,
> >      name=name,
> >      content_type=req['content-type'],
> >      size=out.tell(),
> >      charset=None)
>
> > field should be the name of the field on the model, name should be the
> > file name of the resource.
>
> > There may be neater ways of doing this, but this keeps it in memory
> > until django saves it to the upload_to location specified on the
> > model, and avoids writing it to disk only for django to write it to
> > disk again.
>
> > Cheers
>
> > Tom
>
> Awesome that worked perfectly!  Thanks 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: Problema con ForeignKeys hacia una tabla abstracta

2010-12-01 Thread Ferran
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 01/12/10 12:57, Ferran wrote:
> Buenas tardes a todos;

Sorry list, this mail was intended to a spanish django list.

Ignore this mail, thanks.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJM9jiJAAoJEAWOKfEESaOw5X8P/2xbRhGXX0AtpGsLbRtve+Y8
eFlPZgBucOdBNU+wVN3EEE3bfBUv5tY4LK0TKYb4OnWbYsfhi3TW2AmKiBfchPYV
KK19fVh7fyRawsTtmSWvxG8q29i+2DFNvc3mgG8UdJMAuImbxz2tOIvR6p7y2XPI
RfSk4H5pRvC7jtZ/lbHU05PSHw4odoT0+0tOa2ZQIJ42uJvfIViMi90P9HEVhhiP
MpM+jus4YJfkRxqDMS9t/6D+4epnXnS5jiuS8KUsWzJL2V7UbhyoRVWrqr3GavKS
oHxCeufcRaXrcNhob3Zo0sHSvq194SPHZBQt0RFjjuz5ZACOHERDVfyjsNlGLo8L
JyWNhRSoh4SY5UntQnkPzN8Ol+cNY+TP7TLO6ENjDNLI7hxwyarms78gwtIiOtDp
AkboZUy2BpbzqcVBMvnpH2YnWAAoCNiQ2qjb1Nm3LtlGYRbseOsT8Iu3Ofl0tWLZ
LLfBCUQvzzJN3H5yqtSHRbbEq0oNBot52P05UL6gYbX+wMl6hs0xjqq65567uOQT
G2kugUZ8BRcWZv/oyCZ8Agd2lOn8VZ4zR3/KFlvE+h9eh6upme7PupF/RYUEBuS/
//XyQs092q80xfdqFQaGpv3GVA5KG71LKvc4KdChCrg4aGRzjIGZR9wxBizhvLHT
zaEUbvFDcljczp6Z3eEy
=v/YG
-END PGP SIGNATURE-

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



Problema con ForeignKeys hacia una tabla abstracta

2010-12-01 Thread Ferran
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Buenas tardes a todos;

Quiero tener ForeignKeys hacia el modelo padre en las tablas intermedias
(manytomany trough) para tener entradas únicas en las mismas.

El problema es que quiero que este modelo padre sea abstract, ya que
nunca querré instanciarlo, utilizando DomainOwned o DomainPending en vez
de esta.

El error que tengo es este:

  File "/home/ferran/intranet/domains/models.py", line 48,
in ContactType
domain = models.ForeignKey(DomainUbi)
  File
"/usr/lib/python2.7/site-packages/django/db/models/fields/related.py",
line 808, in __init__
assert not to._meta.abstract, "%s cannot define a relation with
abstract class %s" % (self.__class__.__name__, to._meta.object_name)
AssertionError: ForeignKey cannot define a relation with abstract
class DomainUbi

En las foreignkeys a DomainUbi, tanto en ContactType como en
AssociatedNameServer.

Había pensado que podría implementar los fields ns y contacts en ambas
tables (DomainOwned y DomainPending), utiliando generic relationships,
pero no me parece correcto.

Alguien me puede echar una mano?
- ---

class DomainMinimal(models.Model):
sld = models.CharField(
max_length=63
)
tld = models.ForeignKey(common.Tld)
name = property('_domain_name')

def _domain_name(self):
return u'%s.%s' % (self.sld, self.tld)

def __unicode__(self):
return self.name

class Meta:
abstract = True


class DomainUbi(DomainMinimal):
owner = models.ForeignKey(contacts.Contact, related_name='Owner')
contacts = models.ManyToManyField(contacts.Contact,
through='ContactType')
ns = models.ManyToManyField('NameServer',
through='AssociatedNameServer')
period = models.IntegerField(validators=[MaxValueValidator(10)])

class Meta:
abstract = True

class DomainOwned(DomainUbi):
crdate = models.DateField()
exdate = models.DateField()

class DomainPending(DomainUbi):
status = None # just an example, now


class ContactType(models.Model):
contact = models.ForeignKey(contacts.Contact)
domain = models.ForeignKey(DomainUbi)
role = models.CharField(
max_length=10,
choices = (
('admin', 'Administratiu'),
('billing', 'Facturacio'),
('tech', 'Tecnic'),
)
)
class Meta:
unique_together = ('contact', 'domain', 'role')

class AssociatedNameServer(models.Model):
ns = models.ForeignKey('NameServer')
domain = models.ForeignKey(DomainUbi)
priority = models.IntegerField(
validators=[MaxValueValidator(4)]
)
def __unicode__(self):
return "%s (%s)" % (self.ns.host, self.ns.ip)

class Meta:
unique_together = ('ns', 'domain', 'priority')

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJM9jhAAAoJEAWOKfEESaOwaOgP/36oNmwpYoYkqhuYYuR53Vge
YnIAnMoEIJIze9V4zJhDDWGcvRy8cjz86oqdLQ6Qg3BA+1JxrYML3GY4BWAAslrB
SAPKNfSjP5zspNdfEHrmnq1/bEQnqeeRor5AmfyXUhMBWdE26cCiMWgZVE+M6L6i
+jMku/50COW4JUk55mOE54KdicQ5ChCCWBv1G3aP9mBoMkKQLkLAvTK4DY+bv2xm
vWxXdyjKTGjF5Ck8JSXtq4N7rJev68eoTaK+lc392vkqTrQOrOgDan60hoiej8Dk
cr0ITh9fQuIV59tbL2Bf8vYK8OR3yWoVdL+lfw6xbdovq4qVpjDj01ZN3a42+Mvx
0HFJfnGUhu6zlK1LZWAayIGS+bDnwbvIDkVcx5GxnmQYM9jomMojiirhGttx6mlc
zMPXRzFAw2YyWtFYpSn2bA4e42G83sssRqaQlVdNeGFzP6I4Y67I5TDrPgd1tTKJ
QyC1eFNRxhfoRcYVfYMoTSFBd2FLpLPzMb3cNm3GOeasEgxlj3p1nBErljCdBl2w
jyMLE4/bov63szC78iThMuyV+AxO8ENmLe+NRkHMMToHp6eoyikZR9jRhcAJN0nG
UoQObbeRtNBeko63qwykWOHJgZ+zrkRIk2X3rfbHiW0zXcsWXXBReE+eO7mWIbdY
CrByJHKi89DUea6mUtQ4
=S6Gj
-END PGP SIGNATURE-

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



Problem with ForeignKey to an abstract class

2010-12-01 Thread Ferran

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Hello everyone,

I want to have foreign keys to parent model on a manytomany
intermediate table (through) to have unique entries for that domain.

The problem is i want this parent model class to be an abstract one,
because i don't ever want to instantiate it, using DomainOwned or
DomainPending instead.

The error i'm getting is this:

  File "/home/ferran/0_ubilibet/intranet/domains/models.py", line 48,
in ContactType
domain = models.ForeignKey(DomainUbi)
  File
"/usr/lib/python2.7/site-packages/django/db/models/fields/related.py",
line 808, in __init__
assert not to._meta.abstract, "%s cannot define a relation with
abstract class %s" % (self.__class__.__name__, to._meta.object_name)
AssertionError: ForeignKey cannot define a relation with abstract
class DomainUbi

On both the foreignkeys to DomainUbi on models ContactType and
AssociatedNameServer.

I've thought maybe i can implement contacts and ns fields in both
DomainOwned and DomainPending, using generic relationships, but it
does not seems right to me.

Can anyone help me on this, please?

- ---

class DomainMinimal(models.Model):
sld = models.CharField(
max_length=63
)
tld = models.ForeignKey(common.Tld)
name = property('_domain_name')

def _domain_name(self):
return u'%s.%s' % (self.sld, self.tld)

def __unicode__(self):
return self.name

class Meta:
abstract = True


class DomainUbi(DomainMinimal):
owner = models.ForeignKey(contacts.Contact, related_name='Owner')
contacts = models.ManyToManyField(contacts.Contact,
through='ContactType')
ns = models.ManyToManyField('NameServer',
through='AssociatedNameServer')
period = models.IntegerField(validators=[MaxValueValidator(10)])

class Meta:
abstract = True

class DomainOwned(DomainUbi):
crdate = models.DateField()
exdate = models.DateField()

class DomainPending(DomainUbi):
status = None # just an example, now


class ContactType(models.Model):
contact = models.ForeignKey(contacts.Contact)
domain = models.ForeignKey(DomainUbi)
role = models.CharField(
max_length=10,
choices = (
('admin', 'Administratiu'),
('billing', 'Facturacio'),
('tech', 'Tecnic'),
)
)
class Meta:
unique_together = ('contact', 'domain', 'role')

class AssociatedNameServer(models.Model):
ns = models.ForeignKey('NameServer')
domain = models.ForeignKey(DomainUbi)
priority = models.IntegerField(
validators=[MaxValueValidator(4)]
)
def __unicode__(self):
return "%s (%s)" % (self.ns.host, self.ns.ip)

class Meta:
unique_together = ('ns', 'domain', 'priority')
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJM9jX2AAoJEAWOKfEESaOw1xIP/2ijO1VOXmnxoT1VdiuilcgP
qK+9YXS7Y6bwIhy9zGHF5QB/wAVQyYbYEA/mpLPP09ShA7LV2qO5ZRsdR0TYChfF
P/mVoz73BSkFQLw+B4rS2XCTfXCzumFEslrqWtSAyNnxU1+LjtT/GpFfxldU3PiF
oNnNbAJSjLdd1OvtIP7I3iquj+AV5iuzSDmi38zL5xT9mF75+hg0TXkcA04KMNKJ
AfvZ3j5ofRHJCwpu1jYtE85OzXWasffJeYvXiPLHGHb/Pdp0WwvFCBTb9nIRwVVR
mt/d5lIp6ATuakCxMz9TDM3wf0+81ynGI9s/csZuY3c0RAlKpkzgYMYARC81haiQ
mKJJgQ9J9IHcry9XcMcOZ+x4j+c5JYvNQx5YI+LAuLdXGqzlmQ9mz3Ur0Jsu9H5I
b1wOSiIqDF6uITjCjqlQL1zrSgPSD1NKSBzSm/LO3bBjEqqZL31K7NNUtN70GGhS
Qb85TxpitLHMBhsPjQhi6248CoL5s3/MkPHC9JHajPa2G6ZT+gR7tCiXnkmURdU6
UO1YelGx751GUTRZQxhBPorNHgMPtYrZ4+fPfGVxWfjG1vXS9WXgs4O+xYaIpnMK
lCmX431JJstDHFERbc48qvnuyvy0QX4J1iRsbVJJ8yjYG8vSRzKSFMksibH+PCHl
5UipC5zZfUyxNWR8/bDS
=nHpW
-END PGP SIGNATURE-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: list_display with a function

2010-12-01 Thread Daniel Roseman
On Dec 1, 11:17 am, Daniel Carvalho  wrote:
> hi
>
> I have a model that defines a function:
>
> class Test(models.Model):
>     name = models.CharField(max_length=200)
>
>     data_expira = models.DateField()
>
>     def expired(self):
>         return self.data_expira < datetime.date.today()
>
>     expired.short_description = 'Expirou?'
>
> I want to put it in list_display for this model:
> list_display = ["name", "expired"]
>
> BUT
> django admin displays it as a text, "True" or "False"...
>
> can I tell django that it is a boolean field?

>From the admin docs:
"If the string given is a method of the model, ModelAdmin or a
callable that returns True or False Django will display a pretty "on"
or "off" icon if you give the method a boolean attribute whose value
is True."

So just do `expired.boolean = True` underneath the existing
short_description declaration.
--
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.



list_display with a function

2010-12-01 Thread Daniel Carvalho
hi

I have a model that defines a function:

class Test(models.Model):
name = models.CharField(max_length=200)

data_expira = models.DateField()

def expired(self):
return self.data_expira < datetime.date.today()

expired.short_description = 'Expirou?'


I want to put it in list_display for this model:
list_display = ["name", "expired"]

BUT
django admin displays it as a text, "True" or "False"...

can I tell django that it is a boolean field?






signature.asc
Description: OpenPGP digital signature


Re: Django, Python, AJAX position

2010-12-01 Thread Kenneth Gonsalves
On Wed, 2010-12-01 at 09:55 +, Tom Evans wrote:
> And your post is what exactly?
> 
> This is a pretty standard job ad, if you are interested, email the
> recruiter, if not, please don't email the list and moan about it; I've
> now seen this ad 6 times because people keep replying to it, please
> stop* :/ 

and just to add to the confusion, the client has now posted the same
ad ;-)
-- 
regards
Kenneth Gonsalves

-- 
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, Python, AJAX position

2010-12-01 Thread Tom Evans
On Wed, Dec 1, 2010 at 2:38 AM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> 1) The fact you've put the terms "my client" and "work permit" whilst using
> a gmail email address, that doesn't have your real name, kinda says a lot.
> 2) You've broadly used the term AJAX, without specifying what JS framework
> (if any) you wish to be used.
> 3) You've used and/or on HTML5, as if to say, django+python+ajax OR html5,
> wtf?
>
> Please don't take any offense when I say your post is just noise and cancer.
>

And your post is what exactly?

This is a pretty standard job ad, if you are interested, email the
recruiter, if not, please don't email the list and moan about it; I've
now seen this ad 6 times because people keep replying to it, please
stop* :/

Cheers

Tom

* Yes, I get the irony. No need to remind me.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Loading CSS

2010-12-01 Thread Tom Evans
On Tue, Nov 30, 2010 at 6:21 PM, octopusgrabbus
 wrote:
> I am running Django 1.2.3 -- python -c "import django; print
> django.get_version()" I basically need to know what logs to look at to
> fix a css file not loading.
>
> I am trying to load a css file in my base template
>
> 
>    
>    
>        {% block title %}Town of Arlington Water Department AMR
> System{% endblock %} 
>        
>   

So you are requesting the file '/static_media/amr.css'

>
> Here's the css file -- you could say it's a "test file".
>
> body{ background-color: gray;}
> p { color: blue; }
> h3{ color: white; }
>
> In urls.py this is inserted into
>
> urlpatterns = patterns('',
>
>    (r'^site_media/(?P.*)$', 'django.views.static.serve',
>        {'document_root': '/home/amr/django'}),
>

and you are enabling file serving from a path starting '/site_media/'
(assuming this is your root urlconf).

Is it clear why it isn't working now? 'site_media' != 'static_media'.

In your django dev console, it shows each URL requested, and the HTTP
return code. It will look something like this:

[01/Dec/2010 09:38:47] "GET /static_media/amr.css HTTP/1.1" 404 2572

The first part ('/static_media/') has to match the URL you put in your
urlconf, and the second part ('amr.css') must exist in the folder that
you specify as document_root (or subfolder etc).

This isn't exactly rocket science, just make everything match up, and it works.

BTW, in your template you can use {{ MEDIA_URL }} to get the prefix to
your media - assuming you have correctly set settings.MEDIA_URL, and
have django.core.context_processors.media in
TEMPLATE_CONTEXT_PROCESSORS and use a RequestContext to render with,
which is a few caveats I guess :)

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: Project management software

2010-12-01 Thread Thomas Guettler
Hi,

i am interested, but the licence (GPL) ist unfortunately unusable for me. I need
a licence like django (BSD or LGPL).

  Thomas

tiemonster wrote:
> I finally had a chance to put a demo up online:
> 
> http://freeshell.de/~mscahill/projects/
> 
> Now obviously this isn't as pretty as it could be. It's meant to be
> installed within an existing application. I made a half-hearted effort
> to mock up something that would give you an idea of how it might look.
> Please log in and poke around. I'd love feedback, as well as some
> volunteers to make this really happen.
> 
> If you're interested in contributing, or even in using the code, let
> me know either on-list, or by private e-mail. If there is some
> interest, I'll release the code under the GPL in January, and begin
> more active development.
> 

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

-- 
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: php script in django app

2010-12-01 Thread Ferran
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Maybe this?

http://pythonpaste.org/wphp/

- -- 
Abordemos el parlamento! -- http://pirata.cat
En democracia, dos Belén Esteban valen más que tú
Di NO al top-posting!
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJM9hS2AAoJEAWOKfEESaOwmuQQALZpz9hc5UlSoL3EDKMdh3qW
oPOVBqwu1v+8CtOJRh5dIwxNILBuWuyIM5bJLwGcLBK1BPvs2Sw+OHBytqGpgSIe
d1dWd5p755UHCdPeQjn06BcptCbv+9DoUSufmEBNZe7QurZ/ggQL+7bZKTDmuXyw
n9V93Q0SMeSC1pBjElw01eQaHOJ6OCmmebwmkF5UfVpClEL5j2qV+ksRwUG+yd3P
zxhcN/tGTyLcbG2A4GQby651Lb3G4d1UrtpRA5mOS0lFRE0AzRomLc+eVXv1tUpO
Wk6UX3HIsgiILL27DgC03q1/eXZKmwkDx0xF+eVbYBNs6gjw1MFQAzW7Tf2bqe/D
vkspRQbO6DMj1piKOkT7+b+YH63pE5yZ3QmUlNnydjf4qzeJfEa2AWL0rDUZvHTO
IX1FRUTr7tNIKAtLC1FKwb33powpm170a0Hm87onmoobv/rg9+U4ulKtFpk4/XF4
9X38tca1o5I9qhHU5/acjzgfYry5CTRY79n1TYQ5AJHA2XcAQF9fVHgc+lAHns7Q
QARdJz98RKBvPV+ZNZSq3PxKlQRVE2MsuQqWDmUKINYWMGAhlwg7wJkQUCZxK8qx
HDj1UXiNpWyXMoSIB0p4p16z4/PGqHeR7C6CTFga0A06q0iqJQYGNjhWmwSx7+vK
ZQUtQd+l588ya/e/ctyJ
=nl2Z
-END PGP SIGNATURE-

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