Re: Django crash when accessing User instance containing ManyToMany field only through request.user

2009-11-01 Thread nostradamnit

Hi,

I'm not sure what's causing your error, but it appears that using
User.add_to_class is not the recommended approach for extending the
user model.

James Bennet explains it very well here -
http://groups.google.com/group/django-users/browse_thread/thread/a35d94ce1a7893b0/9e45e7bfc58cfa05?lnk=gst&q=add_to_class#9e45e7bfc58cfa05

Basically, create a UserProfile class and associate it to your user
via the User.profile property. There are many resources online, just
search for 'django user.profile'

I use and prefer this approach
http://www.codekoala.com/blog/2009/quick-django-tip-user-profiles/

Good luck,
Sam


On Nov 1, 3:26 am, ewoudenberg  wrote:
> Hi,
>
> I'm adding row level permissions to the admin using this 
> guideline:http://www.djangosnippets.org/snippets/1054/. Everything works fine
> when I add a simple ForeignKey to the User object and use that to
> identify records 'owned' by the user. e.g.:
>
>   from django.contrib.auth.models import User
>   User.add_to_class('venue', models.ForeignKey(Venue))
>
> However, when I add a ManyToManyField, so that a user can effectively
> be many owners, e.g.:
>
>   from django.contrib.auth.models import User
>   User.add_to_class('venues', models.ManyToManyField(Venue))
>
> I get this Django crash:
>
> Exception Value:
> Cannot resolve keyword 'user' into field. Choices are:   fields of the Venue object>
>
> Exception Location:     C:\Python25\lib\site-packages\django-trunk\django
> \db\models\sql\query.py in setup_joins, line 1737
>
> Here is the offending line:
>
>         print request.user.venues.all()
>
> However, this same operation works fine from the command line:
>
> >>> from django.db import models
> >>> from django.contrib.auth.models import User
> >>> from dharmaseed.talks.models import Venue
> >>> User.add_to_class('venues', models.ManyToManyField(Venue))
> >>> dennis = User.objects.get(id=7)
> >>> dennis.venues.count()
> 2
> >>> dennis.venues.all()
>
> [,  Meditation Society - Retreat Center>]
>
> Is this a Django bug? What could be different about request.user
> during a web fetch and the user instance I get from the command line?
> Should I just go back to ForeignKey ownership instead of ManyToMany?
>
> Any help or hints would be greatly appreciated!
>
> Thank you,
> Eric Woudenberg
>
> Trace:
>
> Environment:
>
> Request Method: GET
> Request URL:http://127.0.0.1:8000/admin/talks/talk/
> Django Version: 1.1 rc 1
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.flatpages',
>  'django.contrib.redirects',
>  'dharmaseed.talks',
>  'dharmaseed.quicklinks',
>  'zilbo.accounts']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.doc.XViewMiddleware',
>  'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
>  'django.contrib.redirects.middleware.RedirectFallbackMiddleware')
>
> Traceback:
> File "C:\Python25\lib\site-packages\django-trunk\django\core\handlers
> \base.py" in get_response
>   92.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "C:\Python25\lib\site-packages\django-trunk\django\contrib\admin
> \sites.py" in root
>   490.                 return self.model_page(request, *url.split('/',
> 2))
> File "C:\Python25\lib\site-packages\django-trunk\django\views
> \decorators\cache.py" in _wrapped_view_func
>   44.         response = view_func(request, *args, **kwargs)
> File "C:\Python25\lib\site-packages\django-trunk\django\contrib\admin
> \sites.py" in model_page
>   509.         return admin_obj(request, rest_of_url)
> File "C:\Python25\lib\site-packages\django-trunk\django\contrib\admin
> \options.py" in __call__
>   1090.             return self.changelist_view(request)
> File "C:\Python25\lib\site-packages\django-trunk\django\contrib\admin
> \options.py" in changelist_view
>   897.                 self.date_hierarchy, self.search_fields,
> self.list_select_related, self.list_per_page, self.list_editable,
> self)
> File "C:\Python25\lib\site-packages\django-trunk\django\contrib\admin
> \views\main.py" in __init__
>   39.         self.root_query_set = model_admin.queryset(request)
> File "..\dharmaseed\talks\admin.py" in queryset
>   12.         return self.filter_user_queryset(queryset, request)
> File "..\dharmaseed\talks\admin.py" in filter_user_queryset
>   110.         print request.user.venues.all()
> File "C:\Python25\lib\site-packages\django-trunk\django\db\models
> \manager.py" in all
>   105.         return self.get_query_set()
> File "C:\Python25\lib\site-packages\django-trunk\django\db\models
> \fields\related.py" in get_query_set
>   424.             return superclass.get_query_set
> (self)._next_is_sticky().filter(**(self.core_filters))
> File "C:\

Unrelated Inline admin objects

2009-11-01 Thread Daniele Procida

Every example discussing inline admin objects invovles (naturally)
models that are related to one another, for example, a books model
placed inline on an authors model admin:



But what if there were no relation? How does the admin know which inline
items belong to it? 

Daniele


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



Paginate huge file

2009-11-01 Thread Angel Talavera
How can I create a view to paginate thru a huge table?


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



Re: Unrelated Inline admin objects

2009-11-01 Thread Karen Tracey
On Sun, Nov 1, 2009 at 6:48 AM, Daniele Procida
wrote:

>
> Every example discussing inline admin objects invovles (naturally)
> models that are related to one another, for example, a books model
> placed inline on an authors model admin:
>
>  #inlinemodeladmin-objects
> >
>
> But what if there were no relation? How does the admin know which inline
> items belong to it?
>
>
You can't list an unrelated model inline with another.  I believe you'll get
an error about no ForeignKey pointing to the parent model existing in the
one you are trying to inline.

Karen

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



Re: Bad Marshal Data error

2009-11-01 Thread Karen Tracey
Try deleting all your .pyc files and it might go away.

Karen

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



Re: Paginate huge file

2009-11-01 Thread Karen Tracey
On Sun, Nov 1, 2009 at 7:14 AM, Angel Talavera wrote:

>  How can I create a view to paginate thru a huge table?
>
>
You could use a generic view (
http://docs.djangoproject.com/en/dev/ref/generic-views/) -- these allow you
to specify how many items per page. If you want to write your own view, use
a Paginator (http://docs.djangoproject.com/en/dev/topics/pagination/)
directly.

Karen

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



Re: Unrelated Inline admin objects

2009-11-01 Thread Daniele Procida

On Sun, Nov 1, 2009, Karen Tracey  wrote:

>> But what if there were no relation? How does the admin know which inline
>> items belong to it?
>>
>>
>You can't list an unrelated model inline with another.  I believe you'll get
>an error about no ForeignKey pointing to the parent model existing in the
>one you are trying to inline.

Thanks. 

I was then going to ask: suppose you have two ForeignKeys pointing to
the parent model? But I've just found the fk_name option for inlines,
which controls it.

Daniele


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



file-download question

2009-11-01 Thread birkin

I expect the following views.py file-download code to work, but am
getting an error, and would like feedback.

The function:

def item( request, item_id ):
  from django.http import HttpResponse, HttpResponseNotFound
  ## valid-item check
  if not item_id == '123':
return HttpResponseNotFound( '404 / Not Found' )
  ## access
  path = '%s/cats.jpg' % ( settings_app.FOLDER_PATH )
  f = open( path, mode='rb' )
  ## delivery
  response = HttpResponse( f )
  return response
  # end def item()

The error:

mod_wsgi (pid=1196): Exception occurred processing WSGI script '/Users/
birkin/Documents/Brown_Library/djangoProjects/testbed/apache/
django.wsgi'.
Traceback (most recent call last):
  File "/Developer_3rd/django_src/django/core/handlers/wsgi.py", line
243, in __call__
response = middleware_method(request, response)
  File "/Developer_3rd/django_src/django/middleware/cache.py", line
93, in process_response
cache.set(cache_key, response, timeout)
  File "/Developer_3rd/django_src/django/core/cache/backends/
locmem.py", line 80, in set
self._set(key, pickle.dumps(value), timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/copy_reg.py", line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle file objects

Background info -- what surprises me so with this is that similar code
in another project's views.py works fine:

def itemStatus( request, pid, SSL=None ):
  from django.http import HttpResponse, HttpResponseForbidden
  from studio_app.models import Identity, Item
  if not 'REMOTE_ADDR' in request.META:
return HttpResponseForbidden( '403 / forbidden' )
  if not request.META['REMOTE_ADDR'] in
studio_app_settings.FEDORA_METS_INGESTER_LEGIT_IPS:
## authentication
authentication_result = utility_code.authenticateViaHttpBasic
(request)
if type(authentication_result) == Identity:
  pass   # if authentication is successful, an identity-instance
will be returned
else:
  auth_required_response =
utility_code.makeHttpBasicAuthRequiredResponse()   # if authentication
fails, the string 'not_legit' is returned, and an 'authorization-
required' response will be returned
  return auth_required_response
  ## access
  item = Item.objects.get( fedora_id=pid )
  path = '%s%s' %
( studio_app_settings.STUDIO_APP_FILE_UPLOAD_LOCATION,
item.original_file )
  f = open( path, mode='rb' )
  ## delivery
  response = HttpResponse( f )
  response['Content-Disposition'] = 'attachment; filename=%s' %
item.name
  return response
  # end def itemStatus()

In the working code there are some differences. I have an Item model
that contains a FileField field which uploads to a specified
FileSystemStorage location. But I don't think the differences are
relevant, because I've examined the response.__dict__ for the working
code and non-working code -- before and after the updated content-
disposition -- and it looks like what is being handled by 'return
response' in both code-blocks is the same.

Thanks in advance.

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



Re: file-download question

2009-11-01 Thread birkin

I forgot to note that the referenced mod_wsgi error is from the apache
error log; it is *not* a django exception. But because of the nearly
identical working code, I am suspecting my issue is with my django
code.

-Birkin

On Nov 1, 7:21 am, birkin  wrote:
> ...
> The error:
>
> mod_wsgi (pid=1196): Exception occurred processing WSGI script '/Users/
> birkin/Documents/Brown_Library/djangoProjects/testbed/apache/
> django.wsgi'.
> Traceback (most recent call last):
> ...

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



Re: file-download question

2009-11-01 Thread Karen Tracey
On Sun, Nov 1, 2009 at 8:44 AM, birkin  wrote:

>
> I forgot to note that the referenced mod_wsgi error is from the apache
> error log; it is *not* a django exception. But because of the nearly
> identical working code, I am suspecting my issue is with my django
> code.
>
>
I'm not sure what you mean by saying it is not a Django exception.  If you
read the traceback:

Traceback (most recent call last):
 File "/Developer_3rd/django_src/django/core/handlers/wsgi.py", line 243, in
__call__
   response = middleware_method(request, response)
 File "/Developer_3rd/django_src/django/middleware/cache.py", line 93, in
process_response
   cache.set(cache_key, response, timeout)
 File "/Developer_3rd/django_src/django/core/cache/backends/locmem.py", line
80, in set
   self._set(key, pickle.dumps(value), timeout)
 File
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/copy_reg.py",
line 70, in _reduce_ex
   raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle file objects

you see Django code identified.  (Which doesn't necessarily mean it's a
problem in Django itself, it could equally well be your code or
configuration that is the real issue.)

You also see cache is mentioned in the traceback, and the end error message
is that file object cannot be pickled.  It sounds like the problem is you
have set up the results from this view to be cached, yet this response
cannot be cached as it contains a file.

(If your working view is also cached, then perhaps there is some difference
in the headers being set that cause the cache to not attempt to cache the
attached file.  I don't have time to look too closely at either the code
you've posted or how the cache behaves for attached files right now.  But
the traceback is pointing out exactly what the problem is, you need to pay
attention to what it is saying and start investigating in the areas it is
identifying.)

Karen

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



Re: file-download question

2009-11-01 Thread Birkin James Diana

Karen,

> ...It sounds like the problem is you have set up the results from  
> this view to be cached, yet this response cannot be cached as it  
> contains a file...

Got it; thanks so much. You were exactly right. Not only had I  
forgotten that I'd set up project-wide caching for this testbed  
project looong ago, I also hadn't updated it properly for django 1.x.

> ...I'm not sure what you mean by saying it is not a Django  
> exception...

I had enclosed my non-working code in a try-except block and the  
except wasn't picking up the error. From previous experience with mis- 
configuring mod_wsgi  --  :)  --  I knew that some errors only appear  
in the apache error log, which is where I found that traceback. I  
hadn't meant that django wasn't involved; was just trying to give more  
info.

> ...you need to pay attention to what it is saying and start  
> investigating in the areas it is identifying...

Since for a long time now my caching has been more explicit, not  
project-wide, I just didn't see what the traceback was really telling  
me. I'm much too embarrassed to let you know how much time I spent  
googling mod-wsgi & pickling, and python file pickling, so I won't. (I  
sometimes think that if developers would spend more time asking  
questions than banging their heads, we'd be up to web-8.0 by now.) A  
sincere thanks again.

-Birkin


On Nov 1, 2009, at 7:58 AM, Karen Tracey wrote:

> On Sun, Nov 1, 2009 at 8:44 AM, birkin  wrote:
>
> I forgot to note that the referenced mod_wsgi error is from the apache
> error log; it is *not* a django exception. But because of the nearly
> identical working code, I am suspecting my issue is with my django
> code.
>
> I'm not sure what you mean by saying it is not a Django exception.   
> If you read the traceback:
>
> Traceback (most recent call last):
>  File "/Developer_3rd/django_src/django/core/handlers/wsgi.py", line  
> 243, in __call__
>response = middleware_method(request, response)
>  File "/Developer_3rd/django_src/django/middleware/cache.py", line  
> 93, in process_response
>cache.set(cache_key, response, timeout)
>  File "/Developer_3rd/django_src/django/core/cache/backends/ 
> locmem.py", line 80, in set
>self._set(key, pickle.dumps(value), timeout)
>  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
> python2.6/copy_reg.py", line 70, in _reduce_ex
>raise TypeError, "can't pickle %s objects" % base.__name__
> TypeError: can't pickle file objects
>
> you see Django code identified.  (Which doesn't necessarily mean  
> it's a problem in Django itself, it could equally well be your code  
> or configuration that is the real issue.)
>
> You also see cache is mentioned in the traceback, and the end error  
> message is that file object cannot be pickled.  It sounds like the  
> problem is you have set up the results from this view to be cached,  
> yet this response cannot be cached as it contains a file.
>
> (If your working view is also cached, then perhaps there is some  
> difference in the headers being set that cause the cache to not  
> attempt to cache the attached file.  I don't have time to look too  
> closely at either the code you've posted or how the cache behaves  
> for attached files right now.  But the traceback is pointing out  
> exactly what the problem is, you need to pay attention to what it is  
> saying and start investigating in the areas it is identifying.)
>
> Karen


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



RE: Paginate huge file

2009-11-01 Thread Angel Talavera
thanks

 

  _  

From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of Karen Tracey
Sent: Sunday, November 01, 2009 7:59 AM
To: django-users@googlegroups.com
Subject: Re: Paginate huge file

 

On Sun, Nov 1, 2009 at 7:14 AM, Angel Talavera 
wrote:

How can I create a view to paginate thru a huge table?

 


You could use a generic view
(http://docs.djangoproject.com/en/dev/ref/generic-views/) -- these allow you
to specify how many items per page. If you want to write your own view, use
a Paginator (http://docs.djangoproject.com/en/dev/topics/pagination/)
directly.

Karen
 




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



Re: Many-toMany with list_display in Admin-Site with django 1.1

2009-11-01 Thread Tobias Kabbeck

Like described in this thread:

http://groups.google.com/group/django-users/browse_thread/thread/1f97ae29f23f71d4

with the method

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



Re: Making the case for Django (vs. Drupal)

2009-11-01 Thread Preston Holmes



On Oct 31, 8:44 am, shacker  wrote:
> At the university where I work, there is a LOT of momentum behind
> Drupal. A large and active users group, and dozens of departmental
> sites running it. I've succeeded in building a few departmental sites
> with Django but still feel like it's an uphill battle convincing
> managers to agree to go with a relative unknown, both in terms of
> language (Python) and platform. Things like the announcement that
> whitehouse.gov switched to Drupal just cement the deal in many
> managers' minds.
>
> I'd like to put together a summary sheet and blog post summarizing all
> the reasons why I feel Django is the better choice for many sites, to
> try and help make the "sale" to managers. I have my own set of reasons
> but am not going to include them in this message. I'm especially
> interested in hearing from people who have done development in both
> Django and Drupal (or WordPress or Joomla, or other). Would be
> interested in hearing comments on things like:
>

I helped produce a med-large site in drupal for a local non-profit.
This was at the tail of Drupal 5, and haven't used it a ton since, but
had set up several smaller drupal sites before then.

There are going to be lots of "it depends"

> - Overall development time

For a basic CMS site - Drupal will be faster and more full featured
out of the box.

Page design time is going to be about the same either way

> - Ease of making changes to templates

Implementing templates for Django is easier as they are just simple
files and the inheritance system is simple - there are books about
doing templates in Drupal


> - Ease of finding 3rd party functionality (modules vs. reusable apps)
Both have the problem of often complex dependencies.  The biggest
problem with Drupal is its relatively fast moving core - so that
modules for the "current version" are hard to find, or often
abandoned.  Also Drupal modules almost always seem to do 80% of what
you need.


> - Ease of building data models that reflect the needs of the
> organization

Depends on the complexity - for relatively "flat" data, Drupal's CCK
is usable by non devs to create custom content types, and the Views
module allow for simple generic_view style pages.  When it comes to
more complex objects, Django's ORM is far superior.


> - Ease of finding other developers to take on a project when someone
> leaves

In my experience it was hard to find any Drupal devs who wanted to do
small fixes, or maintenance.  Everyone was looking for the big fish of
bigger full site design with more $$$ involved.

> - User friendliness (admin and editorial interface)

While both can have a decent staff-admin UI, Django's user-admin UI
can be made much more clear and focused.  Where Drupal has its single
biggest advantage, is that a technical user, a sys-admin etc, can get
Drupal up and running.  Someone doesn't have to know PHP AT ALL to get
drupal going.  This is because Drupal has a decent admin-UI - where
modules are pretty much drop in, activate and configure.

Setting up even a basic Django site REQUIRES someone who has some
programming skills, even if thats just a matter of setting up the
settings.py file.

What happens is that non-developer/technical decision makers will
evaluate Drupal and think that all their needs will be met out of the
box.  When they find out they aren't, they need to hire developers,
and then those developers have to massage existing modules to
customize and tweak.  Then at some point they have this monster of
hodgepodge code.  But its that entry point that is the key to Drupal's
popularity.

What Django needs IMHO is an admin UI for Pinax. Pinax project plans
to do this "someday".  When Pinax can have a web-based install, with
an admin UI to enable/disable pluggable apps - Django will experience
huge win.  Because the same thing will happen as does for Drupal,
there will be technical users who evaluate pinax and think it can do
everything for them.  At some point they will need a custom app - they
HIRE a django dev.  That Django dev writes a well done reusable app -
and often with the blessing of the hiring company, releases that into
the world.  Let this process continue and you can see that eventually
the Django app universe will grow.

I don't think people appreciate how much Drupal development is spawned
by this existence of a usable entry point for Drupal by non-
developers. (and that it has 1-click installs on hosts, and in general
uses the far more common infrastructure of PHP-MySQL)

> - Ease of getting the system to do highly custom tasks

Django just wins this so hands down.  Here is part of the reason why.
Drupals assumptions translate into your code having to jump through a
lot of hoops - where as in Django, you make the assumptions and you
make the hoops.

> - Ease of upgrades
> - Security
>
> etc. etc. - anything at all. Please indicate whether it's OK to quote
> you (I can paraphrase you if not)
>
> Thanks in advance,
> Scot
--~--~-~--

Re: Bad Marshal Data error

2009-11-01 Thread Jeff

That did the trick, thank you!

On Nov 1, 6:52 am, Karen Tracey  wrote:
> Try deleting all your .pyc files and it might go away.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best Practices: How to best implement Rating-Stars in Django Templates

2009-11-01 Thread David

thank you very much. very interesting answers that will help me!
David

On 31 Okt., 17:54, Ethan Jucovy  wrote:
> Hey,
>
> I actually just did 5-star ratings for a project I'm working on, and have
> been trying to figure out if I have anything reusable worth releasing as a
> package (and trying to find the time to figure that out..)  I'll outline
> what I did and what I used to do it.
>
> I used django-ratings[1,2] for the backend and hooked up its RatingField to
> my rateable models.
>
> I like jQuery, so for the frontend I used the jquery-star-rating plugin[3,4]
> as a base.  It turns a collection of radio buttons into a star widget.  I
> haven't looked closely at the implementation but I think it's basically
> using the same CSS technique described in your link.  To get started you
> just need to include its JS and CSS and add class="star" to the radio
> buttons in your form.
>
> I then just wrote some view code that sends the request data from the radio
> buttons to django-ratings.  Super simple stuff, just used the django-ratings
> RatingManager API and handled the exceptions it throws -- I've pasted the
> snippet from my code at [5].  (I'm using a somewhat old version of
> django-ratings b/c I haven't had the time to upgrade; it might look a little
> different now, I'm not sure.)
>
> Finally, I wanted two more things:
>
> 1) If a user has already rated an item and views the "rate this item" form
> again, the "star widget" should be preset with the user's previous rating,
> instead of just showing five blank stars.  I realized the easiest way to do
> this was from the client side: an onload event that simulates the user
> clicking on the star he already clicked on.  My view and template code for
> that is at [6]; I just figured out the HTML formats that jquery-star-rating
> sets and expects, and clicked on the appropriate star for the user's
> existing rating.
>
> 2) When viewing the item, users' ratings should show up as non-interactive
> stars, instead of as numbers.  I wrote a dumb-as-nails template filter
> designed to take a number (the rating) and return a bunch of star images.
> Again, I just used the HTML formatting and CSS classes from
> jquery-star-rating.  My code for this is at [7].
>
> I was thinking it'd be neat to put some of this in a django-form Field that
> renders the radio buttons and triggers jquery-star-rating all in one go, and
> handles the submission to the django-ratings backend.  But I haven't had a
> chance to figure that out yet.
>
> Anyway, hope this helps,
> Ethan
>
> [1]http://github.com/dcramer/django-ratings
> [2]http://pypi.python.org/pypi/django-ratings
> [3]http://www.fyneworks.com/jquery/star-rating/
> [4]http://code.google.com/p/jquery-star-rating-plugin/
> [5]http://pastebin.ca/1650596
> [6]http://pastebin.ca/1650609
> [7]http://pastebin.ca/1650616
>
> On Sat, Oct 31, 2009 at 11:20 AM, Mike Ramirez  wrote:
> > On Saturday 31 October 2009 07:40:05 David wrote:
> > > I would like to have reusable ratings (typical layout with 5 stars). I
> > > have found thishttp://www.thebroth.com/blog/119/css-rating-starsthat
> > > explains how to display this using css. For actually collecting the
> > > rating I was thinking of using an image map or maybe simple radio
> > > buttons. I would like to use this on various different models.
>
> > > How would you do this? Shall I create a widget or can I do this with a
> > > template? Actually I was pretty surprised not to find anything on this
> > > on the web. Is it that simple, or uncommon?
>
> > Well you can create a widget, I like a seperate rating model myself.  That
> > collects the value and then adds that to a total and creates a score or
> > average.  The model stores the total votes and the total score, which I
> > divide
> > and get my average, (I do the math in the view).  Adding it to other models
> > with a foreign key relation.  Enforcing that users vote only once is rarely
> > enforced outside of the current session or cookie lifetime.   If you want
> > it
> > persistance, I'm notfgv6gw33TT   sure off the top of my head what is best
> > for
> > this, but would require only registered users vote.
>
> > Now, you just display the rating form, I would do it as a template
> > inclusion
> > tag and put the tag in my templates.  This tag has the basic submit form,
> > the
> > form it's self is two fields, with a select box (I went simple this way)
> > and a
> > hidden field labeled next that points back to this page, that I can
> > redirect
> > to. When the user submits, in my views to handle the forms action, I just
> > increment the votes and total score and redirect back to the page the vote
> > was
> > taken on.  This is using the traditional submit button, posting the form to
> > a
> > url, returning a full view.
>
> > If you do something with javascript that illuminates the number of stars
> > for
> > the rating and click on the stars to submit, here you might want to post it
> > as
> > json object using xhr request, 

Re: GROUP results in views.py

2009-11-01 Thread TiNo
On Fri, Oct 30, 2009 at 22:10, Javier Guerra  wrote:

>
> On Fri, Oct 30, 2009 at 4:05 PM, TiNo  wrote:
> > SQL's GROUP BY is made for this isn't it?
>
> no, it's not.
>
> SQL's GROUP BY discards 'individual' rows off the result, showing only
> 'grouping' rows.
>

Oops, too quick.

You might be able to do it with GROUP_CONCAT[1] if you are on MySQL. You
would have to write raw sql though. That way you don't have to load all the
results into memory, but you could just split the string of id's per result.

Tino

[1]
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat


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



debug toolbar problem

2009-11-01 Thread bax...@gretschpages.com

I finally installed the django debug toolbar, which looks like a very
nice piece of work, but it's not reporting sql queries for me. Every
page: 0 queries, 0 seconds.

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



Re: Django Model inheritance and foreignkeys

2009-11-01 Thread Andew Gee

That works great...thanks

bruno desthuilliers wrote:
> On 29 oct, 23:49, Andew Gee  wrote:
> > Hi,
> >
> > I have the following models
> >
> >     class Person(models.Model):
> >       name = models.CharField(max_length=100)
> >
> >     class Employee(Person):
> >       job = model.Charfield(max_length=200)
> >
> >     class PhoneNumber(models.Model):
> >       person = models.ForeignKey(Person)
> >
> > How do I access the PhoneNumbers associated with an employee if I have
> > the employee id?
> >
> > Currently I am using
> >
> > phones = PhoneNumbers.objects.filter(person__id=employee.id)
> >
>
> In  that case you not only have the employee id, you do have the whole
> employee instance, so you can just use employee.phonenumber_set.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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django admin stops showing all apps

2009-11-01 Thread Greg

Hi all,

I have a very strange problem with one of my django sites - when I
start apache, everything works fine, but after a while, all of my site-
specific apps will stop showing in the admin site. Library apps and
django's built in apps are still there. Does anyone have any ideas as
to why this might happen?

It seems like a path issue, but I have no idea why it works at the
start and then dies for no apparent reason down the track.

I'm running it via mod_wsgi, on webfaction. In my wsgi file, I'm
setting the python path like so:

> import os
> import sys
>
> for directory in [
> '/PATH/django',
> '/PATH/django/library',
> '/PATH/django/nzmusic',
> '/PATH/django/lib'
> ]:
> if not directory in sys.path:
> sys.path.insert(0, directory)
>
> from django.core.handlers.wsgi import WSGIHandler
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'nzmusic.settings'
> os.environ['LD_LIBRARY_PATH'] = '/PATH/lib'
> application = WSGIHandler()



Thanks,
Greg


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



Rendering Group Labels for Checkboxes and Radio Groups

2009-11-01 Thread mviamari

Hi,

When I render a CheckBoxGroup or a Radiobox group and I apply a label
to whole widget (independent of the labels for each of the choices), I
get something like this:

Group Label






The problem is that because the top label has the attribute
"for='element_0'" if you click on it, it activates the first check box
(id='element_0').  I'd like to stop this functionality from happening,
but I can't find where to change the rendering for the group label,
without affecting the labeling of each individual input.

Any ideas or suggestions?

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



Re: debug toolbar problem

2009-11-01 Thread Antoni Aloy

2009/11/1 bax...@gretschpages.com :
>
> I finally installed the django debug toolbar, which looks like a very
> nice piece of work, but it's not reporting sql queries for me. Every
> page: 0 queries, 0 seconds.
>
> Any suggestions on where the problem may lie?

Are you caching your pages?
Are you using Django ORM?



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Distributing a Django site along with Apache and MySQL

2009-11-01 Thread kRON

I have a web application developed as a Django site that I'd like to
distribute along to my clients on Windows; their production
environment won't have Apache and MySQL preinstalled. To avoid having
to manually deploy Apache and MySQL and look silly if I run into any
hiccups whilst configuring them, I thought it it would be fun to learn
how to automate the process, since I've never done it before.

I've looked at the Python `distutils` docs, but found myself greatly
overwhelmed with all the information. I gained an impression that I
could do something like this by doing a clean deployment of Apache and
MySQL within my package; package everything; write a post-install
script that would then configure the servers (edit Apache's configs to
set it's paths based on where it's located on the production server,
create a MySQL root account, the database for Django) and also use
pywin32 to install Apache and MySQL as services on the account that
was used for the installation. Later I can test everything by
installing it on my virtual machine running Windows.

It would really help if anyone could share on how do you do your build
automation with such requirements? How to best layout your project's
structure to build the package?


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



Can't use ModelForm, basic template and ajax to submit a form, over and over...can I?

2009-11-01 Thread robinne

I'm giving up on something I was so close to getting to work...just
want to make sure there isn't a simple solution. I have  ModelForm and
I have a simple template that iterates and creates the form fields. I
update the form using YUI.io ajax submit. It works great. I am able to
post the data to the database using ajax and the form fields are now
updated with the new data. The problem is, subsequent posts will not
submit any new data entered. It has lost knowledge of the form or
something (the form and it's id is not regenerated from the ajax call,
but the form fields are). I have my code posted here
http://stackoverflow.com/questions/1655486/yui-io-ajax-and-django-update-works-only-once-yui-cant-find-form-again

Any advice is appreciated. I am now going to hand code all fields and
use json to manually handle every field (ugh, there goes all that
django was providing 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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



solving the %20 problem

2009-11-01 Thread Kenneth Gonsalves

hi,
when I switched from apache to nginx, I found that all my spaces in urls were 
being replaced with '%20' which caused the urls to fail and database lookup 
also to fail. I used urllib.unquote in views and a \S in urls to work around 
this. Is there some cleaner solution to this?
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

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



Remote developer opportunity

2009-11-01 Thread morab007

Currently seeking a talented, self-motivated and passionate python/
django developer to join an already establish firm specialising in
Django-based development. This position is 100% remote/virtual, using
communication tools such as Co-op, Assembla, email, IM.

We're smart, idealistic, and passionate about the web. We believe in
making the internet even more amazing than it already is, and have a
solid client base from USA, Australia and Europe.

If you're interested, please get in touch. We want to hear from you!

This is a full-time position, available immediately. Working hours are
flexible.

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



Re: solving the %20 problem

2009-11-01 Thread Mike Ramirez
On Sunday 01 November 2009 17:27:08 Kenneth Gonsalves wrote:
> hi,
> when I switched from apache to nginx, I found that all my spaces in urls
>  were being replaced with '%20' which caused the urls to fail and database
>  lookup also to fail. I used urllib.unquote in views and a \S in urls to
>  work around this. Is there some cleaner solution to this?
> 

maybe if you can change the spaces to hyphens?  I really do think hypens or 
underscores should be used in urls instead of spaces, which is why I love slug 
fields for urls.

Mike
-- 
Yow!  Are we wet yet?


signature.asc
Description: This is a digitally signed message part.


Re: solving the %20 problem

2009-11-01 Thread Kenneth Gonsalves

On Monday 02 Nov 2009 8:14:22 am Mike Ramirez wrote:
> > hi,
> > when I switched from apache to nginx, I found that all my spaces in urls
> >  were being replaced with '%20' which caused the urls to fail and
> > database lookup also to fail. I used urllib.unquote in views and a \S in
> > urls to work around this. Is there some cleaner solution to this?
> > 
> 
> maybe if you can change the spaces to hyphens?  I really do think hypens
>  or  underscores should be used in urls instead of spaces, which is why I
>  love slug fields for urls.
> 
these are usually user generated - they love to put spaces. I can handle 
spaces, but would like to know how the spaces become %20 and how to prevent 
this.
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

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



Re: solving the %20 problem

2009-11-01 Thread Mike Ramirez
On Sunday 01 November 2009 19:04:06 Kenneth Gonsalves wrote:
> these are usually user generated - they love to put spaces. I can handle
> spaces, but would like to know how the spaces become %20 and how to prevent
> this.
> 
Firefox usually encodes them to %20 when it's copied and pasted from the 
browser.  That's the time I do notice when it's added in firefox.  Sometimes 
I've been known to add them to make the url continuous so the full link is 
clickable, other wise most text based tools urlizing will break at the first 
space.  I avoid spaces in my urls like the plague for that reason and not sure 
if the rendered page in ff will do the same.  As for I.E. and/or opera I'm far 
from an expert on them (same with ff too tbh) and not sure how they handle 
spaces.

Can't you add a django.template.defaultfilters.slugify() to the url before it 
is added/saved?  If not, don't worry about it.

Mike

-- 
I might be able to shoehorn a reference count in on top of the numeric
value by disallowing multiple references on scalars with a numeric value,
but it wouldn't be as clean.  I do occasionally worry about that. --lwall


signature.asc
Description: This is a digitally signed message part.


Re: solving the %20 problem

2009-11-01 Thread Graham Dumpleton



On Nov 2, 2:04 pm, Kenneth Gonsalves  wrote:
> On Monday 02 Nov 2009 8:14:22 am Mike Ramirez wrote:> > hi,
> > > when I switched from apache to nginx, I found that all my spaces in urls
> > >  were being replaced with '%20' which caused the urls to fail and
> > > database lookup also to fail. I used urllib.unquote in views and a \S in
> > > urls to work around this. Is there some cleaner solution to this?
>
> > maybe if you can change the spaces to hyphens?  I really do think hypens
> >  or  underscores should be used in urls instead of spaces, which is why I
> >  love slug fields for urls.
>
> these are usually user generated - they love to put spaces. I can handle
> spaces, but would like to know how the spaces become %20 and how to prevent
> this.

As someone else pointed out, likely from the browser.

The issue is that your web server is supposed to decode % escapes when
supplying parameters to CGI like request environment. Thus an
application would expect to see:

PATH_INFO: '/sadfaskf sadfasdf'
QUERY_STRING: ''
REQUEST_URI: '/echo.wsgi/sadfaskf%20sadfasdf'
SCRIPT_NAME: '/echo.wsgi'

Note how it is decoded in PATH_INFO.

If your web server of choice and means of hosting applications in
conjunction with it isn't doing it, then that hosting stack,
underneath Django, is arguably broken.

It should be really easy to verify whether the hosting stack is doing
something wrong. If using WSGI at application interface level then you
can use simple WSGI test program below to echo back what the WSGI
application is getting. This takes Django completely out of the
picture.

import cStringIO
import os

def application(environ, start_response):
headers = []
headers.append(('Content-Type', 'text/plain'))
write = start_response('200 OK', headers)

input = environ['wsgi.input']
output = cStringIO.StringIO()

print >> output, "PID: %s" % os.getpid()
print >> output

keys = environ.keys()
keys.sort()
for key in keys:
print >> output, '%s: %s' % (key, repr(environ[key]))
print >> output

output.write(input.read(int(environ.get('CONTENT_LENGTH', '0'

return [output.getvalue()]


Graham

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



Re: solving the %20 problem

2009-11-01 Thread Kenneth Gonsalves

On Monday 02 Nov 2009 9:36:23 am Graham Dumpleton wrote:
> > these are usually user generated - they love to put spaces. I can handle
> > spaces, but would like to know how the spaces become %20 and how to
> > prevent this.
> 
> As someone else pointed out, likely from the browser.

it is not from the browser - I have not changed my browser recently, and it 
was not converting the strings. The change has come when I shifted to 
nginx+tornado - one of these is doing it.
> 
> The issue is that your web server is supposed to decode % escapes when
> supplying parameters to CGI like request environment. Thus an
> application would expect to see:
> 
> PATH_INFO: '/sadfaskf sadfasdf'
> QUERY_STRING: ''
> REQUEST_URI: '/echo.wsgi/sadfaskf%20sadfasdf'
> SCRIPT_NAME: '/echo.wsgi'
> 
> Note how it is decoded in PATH_INFO.
> 
> If your web server of choice and means of hosting applications in
> conjunction with it isn't doing it, then that hosting stack,
> underneath Django, is arguably broken.
> 
> It should be really easy to verify whether the hosting stack is doing
> something wrong. If using WSGI at application interface level then you
> can use simple WSGI test program below to echo back what the WSGI
> application is getting. This takes Django completely out of the
> picture.
> 
> import cStringIO
> import os
> 
> def application(environ, start_response):
> headers = []
> headers.append(('Content-Type', 'text/plain'))
> write = start_response('200 OK', headers)
> 
> input = environ['wsgi.input']
> output = cStringIO.StringIO()
> 
> print >> output, "PID: %s" % os.getpid()
> print >> output
> 
> keys = environ.keys()
> keys.sort()
> for key in keys:
> print >> output, '%s: %s' % (key, repr(environ[key]))
> print >> output
> 
> output.write(input.read(int(environ.get('CONTENT_LENGTH', '0'
> 
> return [output.getvalue()]
> 
 thanks - will try this out

-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

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



Legacy database - does every table need an id column?

2009-11-01 Thread Nick Arnett

I'm hoping to use Django with a legacy database and I'm suspecting
that things are not working as they should because the database has
tables that lack the "id" column that Django generates from the same
model.  Searching the documentation, I don't see anything that
indicates this is required, but I'm bumping into problems that I
believe are due to this.

The tables in question have a primary key that consists of two foreign
keys.

Anybody know?

I was hoping to use the data as-is... and I'm not sure if I can just
add an auto-increment "id" column to the tables who use the foreign
key combination as their primary keys.

As I ask the question, it now seems clear to me that the column is
needed.

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



Re: Legacy database - does every table need an id column?

2009-11-01 Thread James Bennett

On Sun, Nov 1, 2009 at 10:56 PM, Nick Arnett  wrote:
> As I ask the question, it now seems clear to me that the column is
> needed.

There must be a field on the model with "primary_key=True". If a model
is defined without such a field, Django assumes an implicit
auto-incrementing field named "id" as the primary key.

Note also that composite primary keys are not currently supported.


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

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



Display a value from another table

2009-11-01 Thread Denis Bahati
Hi All,
Am developing an application where by it links two tables author and book,
the id of author is a foreign key to book table. How can i display the name
of the author when am displaying the book list.

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



Re: Display a value from another table

2009-11-01 Thread Rishabh Manocha
On Mon, Nov 2, 2009 at 1:43 PM, Denis Bahati  wrote:

> Hi All,
> Am developing an application where by it links two tables author and book,
> the id of author is a foreign key to book table. How can i display the name
> of the author when am displaying the book list.
>
> >
>
I'm not sure how you the id of an author can be a ForeignKey to a Book. Can
you paste your models so that we can get a clearer picture. Assuming your
Book model looks something like the below:

class Book(models.Model):
...
author = models.ForeignKey(Author)

You would do:

>>> my_author = Author.objects.create('James Joyce')
>>> my_book = Book.objects.create(..., author = my_author)
>>> my_book.author


-- 

Best,

R

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



Re: Remote developer opportunity

2009-11-01 Thread Kashif Azeem
Hi,

I am interested. If you can write a little bit about yourself, type of work,
how to apply?

-Kashif

On Mon, Nov 2, 2009 at 7:05 AM, morab007  wrote:

>
> Currently seeking a talented, self-motivated and passionate python/
> django developer to join an already establish firm specialising in
> Django-based development. This position is 100% remote/virtual, using
> communication tools such as Co-op, Assembla, email, IM.
>
> We're smart, idealistic, and passionate about the web. We believe in
> making the internet even more amazing than it already is, and have a
> solid client base from USA, Australia and Europe.
>
> If you're interested, please get in touch. We want to hear from you!
>
> This is a full-time position, available immediately. Working hours are
> flexible.
>
> >
>

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