streaming response, missing something simple

2009-11-28 Thread Preston Holmes
My expectation was that it was possible to 'stream' a response back to
a browser from a view, where that response is 'trickled' onto the
browser page.  I had done this a while back in cherrypy and it worked
as expected.

a super simple view demonstrates the issue.  Instead of a series of
numbers marching onto the page, there is a delay and then the whole
response is written to the page.  I had disabled commonmiddleware to
avoid any chance that I was hitting #7581

Is this some limitation of runserver?

from django.http import HttpResponse
import time

def streamer():
for x in range(50):
yield str(x)
time.sleep(.2)

def writeback (request):
return HttpResponse(streamer(), mimetype="text/plain")

insight welcome

-Preston

--

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




Re: How to list all parents and their children if any?

2009-11-28 Thread Karen Tracey
On Sat, Nov 28, 2009 at 11:50 PM, adelaide_mike  wrote:

> I have three models:
>
> class Connector(models.Model):
>connectorname = models.CharField(max_length=32)
>
> class Cable(models.Model):
>cablename = models.CharField(max_length=32)
>
> class Node(models.Model):
>connector = models.ForeignKey(Connector)
>cable = models.ForeignKey(Cable)
>node_specific_data = models.CharField(max_length=32)
>
> I wish to make a report displaying all Connector names at least once,
> and the Cable name that the Node model relates them to.  If I did not
> need the nodespecificdata I could have used a many-to-many between
> Connector and Cable.  Sadly I do need it.
>

The extra information doesn't prohibit use of ManyToMany, see:

http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 list all parents and their children if any?

2009-11-28 Thread adelaide_mike
I have three models:

class Connector(models.Model):
connectorname = models.CharField(max_length=32)

class Cable(models.Model):
cablename = models.CharField(max_length=32)

class Node(models.Model):
connector = models.ForeignKey(Connector)
cable = models.ForeignKey(Cable)
node_specific_data = models.CharField(max_length=32)

I wish to make a report displaying all Connector names at least once,
and the Cable name that the Node model relates them to.  If I did not
need the nodespecificdata I could have used a many-to-many between
Connector and Cable.  Sadly I do need it.

A Connector may have any number of related nodes, including none.

I need to obtain a report displaying all connectors at least once,
with their related cablename(s), if any, shown (on additional rows if
necessary).  Can I do this without resorting to raw SQL?

Thanks (yet again)

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-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: newbie: unable to open database file

2009-11-28 Thread Karen Tracey
On Sat, Nov 28, 2009 at 10:46 PM, ccl4r  wrote:

> I'm tryin out the tutorial and am very new to this...I have my
> settings.py as:
>
> DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> DATABASE_NAME = 'C:\Users\Student\Desktop\mysite'
>

In Python, backslashes in string literals are escape characters.  You either
need to double the backslashes or use forward slashes, which will work fine
in path names, even on Windows.

Karen

--

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




newbie: unable to open database file

2009-11-28 Thread ccl4r
I'm tryin out the tutorial and am very new to this...I have my
settings.py as:

DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'C:\Users\Student\Desktop\mysite'

and when I run the command:
 python manage.py syncdb

I get a  the error:
self.connection = Database.connect(**kwargs)
sqlite3.OparationalError: unable to open database file

I saw related posts but can't find a way to resolve.

--

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: Many-to-many through multiple tables

2009-11-28 Thread Jonathan
The BusinessVersion isn't relevant, I posted the whole model to put it
in context. It's a web app to track software through the software
development lifecycle.

Regardless of the lifecyle stage (development, test, production), all
instances of an application consist of the same Group of packages
(python, django). What differs during the lifecycle stages are the
PackageVersion's.

The Group is a generic placeholder to indicate what Package's should
be included in the Profile. The Profile needs to adapt to changes, so
if another Package is added to a Group then all existing Profile's
automatically prompt for the new Package.

I've been reading a bit and perhaps model inheritance is what I'm
after. A VersionedPackage (renamed from PackageVersion) is really just
a Package with an extra field. Does that sound right?

Jonathan


On Nov 29, 2:31 am, t0ster  wrote:
> May be Group should include packages of specific versions:
>
> class Group(models.Model):
>     name = models.CharField(max_length=100)
>     product = models.ForeignKey(Product)
>     -packages = models.ManyToManyField(Package)
>     +packages = models.ManyToManyField(PackageVersion)
>
> class Profile(models.Model):
>     name = models.CharField(max_length=100)
>     businessversion = models.ForeignKey(BusinessVersion)
>     lifecyclestage = models.ForeignKey(LifecycleStage)
>     group = models.ForeignKey(Group)
>     -packageversions = models.ManyToManyField(PackageVersion)
>
> So:
>
> for package in profile.profile.group.packages.all():
>     print package.package.name
>     print package.version
>
> And what is BusinessVersion I didn't understand.
>
> On Nov 28, 4:59 pm, Jonathan  wrote:
>
> > Hi,
>
> > I've slimmed it down to the relevant fields. I'm a bit of a noob, but
> > I think I'm basically trying to build a generic framework that can be
> > made specific in a profile.
>
> > Profile = BusinessVersion + Group + LifecycleStage + Package.Versions
>
> > Jonathan
>
> > class Product(models.Model):
> >     name = models.CharField(max_length=20)
>
> > class BusinessVersion(models.Model):
> >     version = models.CharField(max_length=10)
> >     description = models.CharField(max_length=100)
> >     product = models.ForeignKey(Product)
>
> > class LifecycleStage(models.Model):
> >     name = models.CharField(max_length=40)
> >     sequence = models.DecimalField(max_digits=2, decimal_places=0)
>
> > class Package(models.Model):
> >     name = models.CharField(max_length=100)
>
> > class PackageVersion(models.Model):
> >     version = models.CharField(max_length=10)
> >     package = models.ForeignKey(Package)
> >     lifecyclestage = models.ForeignKey(LifecycleStage)
>
> > class Group(models.Model):
> >     name = models.CharField(max_length=100)
> >     product = models.ForeignKey(Product)
> >     packages = models.ManyToManyField(Package)
>
> > class Profile(models.Model):
> >     name = models.CharField(max_length=100)
> >     businessversion = models.ForeignKey(BusinessVersion)
> >     lifecyclestage = models.ForeignKey(LifecycleStage)
> >     group = models.ForeignKey(Group)
> >     packageversions = models.ManyToManyField(PackageVersion)
>
> > class Stream(models.Model):
> >     name = models.CharField(max_length=4)
> >     businessversion = models.ForeignKey(BusinessVersion)
>
> > On Nov 29, 1:19 am, t0ster  wrote:
>
> > > Could you post your models.py code here?
>
> > > On Nov 28, 1:10 pm, Jonathan  wrote:
>
> > > > This may be more of a general database design question, but I want to
> > > > come up with something that works with Django's ORM.
>
> > > > I have four bits of information that I want to link together. Generic
> > > > packages, package versions, groups of packages and a profile that
> > > > brings them together.
>
> > > > The final goal is a Profile that binds the Packages from a Group to
> > > > specific Versions.
>
> > > > I have a solution at the moment but it seems a bit clumsy for what
> > > > seems like something that would be commonly encountered.
>
> > > > 4 models: Package, Version, Group and Profile. I've omitted the id
> > > > primary key column on the examples.
>
> > > > Package:
> > > > | name   |
> > > > --
> > > > | django |
> > > > | python |
>
> > > > Version:
> > > > | package_id | version |
> > > > --
> > > > |          1 |     1.0 |
> > > > |          1 |     1.1 |
> > > > |          2 |     2.4 |
> > > > |          2 |     2.6 |
>
> > > > Group:
> > > > | name |
> > > > --
> > > > | django_stack |
>
> > > > group_packages:
> > > > | group_id | package_id |
> > > > --
> > > > |        1 |          1 |
> > > > |        1 |          2 |
>
> > > > Profile:
> > > > |        name | group_id |
> > > > --
> > > > | django_prod |        1 |
> > > > |  django_dev |        1 |
>
> > > > profile_packageversion:
> > > > | profile_id | version_id |
> > > > --
> > > > |          1 |          1 |
> > > > |          1 |          2 |

Re: IDLE (Python GUI)

2009-11-28 Thread Mikey3D
The first task I get an error:

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.


Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface.  This connection is not visible on any external
interface and no data is sent to or received from the Internet.


IDLE 2.6.4
>>> import os
>>> os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
>>> import mysite
>>> from mysite.polls.models import Poll, Choice

Traceback (most recent call last):
  File "", line 1, in 
from mysite.polls.models import Poll, Choice
  File "C:\Python26\Lib\site-packages\mysite\polls\models.py", line 1,
in 
from django.db import models
  File "C:\Python26\Lib\site-packages\django\db\__init__.py", line 10,
in 
if not settings.DATABASE_ENGINE:
  File "C:\Python26\Lib\site-packages\django\utils\functional.py",
line 269, in __getattr__
self._setup()
  File "C:\Python26\Lib\site-packages\django\conf\__init__.py", line
40, in _setup
self._wrapped = Settings(settings_module)
  File "C:\Python26\Lib\site-packages\django\conf\__init__.py", line
75, in __init__
raise ImportError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE,
e)
ImportError: Could not import settings 'settings' (Is it on sys.path?
Does it have syntax errors?): No module named settings
>>>
===

The second task I put the code what you suggest in mysite\settings.py:

# Django settings for mysite project.

import os
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'C:/Python26/Lib/site-packages/mysite/
sqlite3.db' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

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

# 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 = ''

# 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/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'yl)c4ch6k_2u8zjvx_ad!1!ffqllb4k%ry^w(%y9=8g%$d%web'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'mysite.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite.polls'
)
==

I try this but get an error:

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more 

admin: uploading files problem

2009-11-28 Thread Heronman
Hello, all

I'm a newbie in django, and I have a problem with uploading files in
django admin
after submitting a form with FileField or ImageField, if a file is
bigger than ~100KB, my browser tell me "sending a request..." and then
nothing happens. and nothing happens on the server side
FILE_UPLOAD_MAX_MEMORY_SIZE and other file uploading settings are
default
permissions on /tmp directory is 0777 (anyway, that problem persists
even if django is running under root)

when using a file-upload forms in my own pages under django, all works
good, with any file size

what can I do to solve this problem?

--

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: IDLE (Python GUI)

2009-11-28 Thread Nick Arnett
On Sat, Nov 28, 2009 at 3:21 PM, Mikey3D  wrote:

> Windows 7:
>
> My project is in: C:\Python26\Lib\site-packages\mysite
>
> I'm working on this section: Playing with the API
> http://docs.djangoproject.com/en/dev/intro/tutorial01/#playing-with-the-api
>
> When I do (Windows+R >cmd >OK) to do python shell (python manage.py
> shell) it works. But I have try other tool that come with Python26 is
> IDLE (Python GUI) and I get an error:


I think what you need is the following before you import anything from
Django: (or any module that imports from Django):

import os
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"

(The absolute or relative path to your settings file.)

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




IDLE (Python GUI)

2009-11-28 Thread Mikey3D
Windows 7:

My project is in: C:\Python26\Lib\site-packages\mysite

I'm working on this section: Playing with the API
http://docs.djangoproject.com/en/dev/intro/tutorial01/#playing-with-the-api

When I do (Windows+R >cmd >OK) to do python shell (python manage.py
shell) it works. But I have try other tool that come with Python26 is
IDLE (Python GUI) and I get an error:


Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.


Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface.  This connection is not visible on any external
interface and no data is sent to or received from the Internet.


IDLE 2.6.4   No Subprocess 
>>> import mysite
>>> from mysite.polls.models import Poll, Choice
Traceback (most recent call last):
  File "", line 1, in 
from mysite.polls.models import Poll, Choice
  File "C:\Python26\Lib\site-packages\mysite\polls\models.py", line 1,
in 
from django.db import models
  File "C:\Python26\Lib\site-packages\django\db\__init__.py", line 10,
in 
if not settings.DATABASE_ENGINE:
  File "C:\Python26\Lib\site-packages\django\utils\functional.py",
line 269, in __getattr__
self._setup()
  File "C:\Python26\Lib\site-packages\django\conf\__init__.py", line
38, in _setup
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
>>>


I don't understand how and where to settings DJANGO_SETTINGS_MODULE?

Thanks, Mikey3D

--

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.




View returns no queryset

2009-11-28 Thread R. Gorman
I've got a real stumper. Well, a stumper for me; I'm hoping someone
has some insight. Here's the view I'm calling:

def season_schedule_month(request, league_slug, year, month):
"""Given a league slug, retrieve the season's schedule
month by month.
return date_based.archive_month(
request,
year = year,
#month_format = "%m"
month = month,
date_field = 'date',
queryset = Game.season.schedule(league_slug),
template_name ='season_schedule.html')"""
#games = Game.season.schedule(league_slug).filter
(date__month=month)
games = Game.objects.all()
return render_to_response('season_schedule.html',
{games:"object_list"},context_instance = RequestContext(request))

It was originally a generic view, but I've reduced it down to a simple
all objects request because of the bug in my code I'm trying to figure
out. So the generic view does not work either. The same query run in
the Django shell produces something like 30 objects. This page is
returned without any errors but also without any queryset. It doesn't
even give an empty set of brackets, denoting an empty queryset. I've
looked at the django debug-toolbar and it does not show the SQL query
in the queries list, so it appears the query is not even run. Rest of
the site, which often accesses the same model, runs fine. I have no
idea why this simple query will not run correctly. It is code related
because I've moved the code to a different server with a different
setup and the problem follows.

Anyone run into this before?

--

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.




ModelMultipleChoiceField with checkboxes: How to generate the HTML "checked" option?

2009-11-28 Thread Gloria
Hi all,
I've spent way too much time getting trying to get this widget to work
the way I am envisioning.
In the forms, I want to initialize it, but in the view I need to
determine which boxes are checked.
Has anyone done this without writing their own widget? It would be
great to know how.
Thank you in advance,
Gloria

--

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.




CSRF Flatpages

2009-11-28 Thread John Leith
I have a problem with the CSRF framework, and i'm just checking here
to see if anyone else ran into this problem and hopefully found a
solution. Here is my problem:

I have a login form on the base template of my site. The home page is
just a flatpage. My login processor is csrf protected. I have the
middleware and the {% csrf_token %} is set in the template.

The problem is that there is no output from the template tag, it
dosen't contribute anything at all to the rendered HTML. So naturally,
I can't login from the homepage.

I poked around in the code, and i planning on digging some more.
However, if someone else has encountered this, i sure would appreciate
some guidance.

--

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: newbee issues with 'python manage.py adminindex myApp'

2009-11-28 Thread dogfuel
Thanks ... bear with me as I'm new to this and not the brightest
bulb ...

I used 'python manage.py adminindex myApp' last week on .96 with what
I thought was nothing other than the base installed (from the Debian
repository).  I moved to 1.1.1 and it doesn't work and as you point
out, it is not in the docs.

It is in the .96 docs so I assume it was dropped from the current
version.  I'll just customize the admin index template manually.

Before I drop the subject, is modifying the template and "hardcoding"
the admin menu I want the best way to customize the content on the
admin index page?

Thanks!

On Nov 28, 2:29 pm, Karen Tracey  wrote:
> On Sat, Nov 28, 2009 at 1:59 PM, dogfuel  wrote:
> > I believe I'm missing the obvious ... on 1.1.1, I am trying to use the
> > adminindex command with manage.py ... I see the below"
>
> > # python manage.py adminindex myApp
> > Unknown command: 'adminindex'
> > Type 'manage.py help' for usage.
>
> > My INSTALLED_APPS does include  'django.contrib.admin'.
>
> > Thanks in advance - I realize I could manually create the output of
> > this command but fear it is a symptom of a larger installation issue.
>
> What doc are you looking at that mentions an adminindex command?  The
> subcommands that come with Django are listed here:
>
> http://docs.djangoproject.com/en/dev/ref/django-admin/#available-subc...
>
> adminindex is not there.  Possibly it is something supplied by an add-on
> project, and that needs to be listed in INSTALLED_APPS, but it is not a
> subcommand I have heard of before so I don't know.  So whatever doc you are
> looking at that has mentioned adminindex might give a clue, since presumably
> it is doc for something other than base Django.
>
> Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: newbee issues with 'python manage.py adminindex myApp'

2009-11-28 Thread Karen Tracey
On Sat, Nov 28, 2009 at 1:59 PM, dogfuel  wrote:

> I believe I'm missing the obvious ... on 1.1.1, I am trying to use the
> adminindex command with manage.py ... I see the below"
>
> # python manage.py adminindex myApp
> Unknown command: 'adminindex'
> Type 'manage.py help' for usage.
>
> My INSTALLED_APPS does include  'django.contrib.admin'.
>
> Thanks in advance - I realize I could manually create the output of
> this command but fear it is a symptom of a larger installation issue.
>

What doc are you looking at that mentions an adminindex command?  The
subcommands that come with Django are listed here:

http://docs.djangoproject.com/en/dev/ref/django-admin/#available-subcommands

adminindex is not there.  Possibly it is something supplied by an add-on
project, and that needs to be listed in INSTALLED_APPS, but it is not a
subcommand I have heard of before so I don't know.  So whatever doc you are
looking at that has mentioned adminindex might give a clue, since presumably
it is doc for something other than base Django.

Karen

--

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




newbee issues with 'python manage.py adminindex myApp'

2009-11-28 Thread dogfuel
I believe I'm missing the obvious ... on 1.1.1, I am trying to use the
adminindex command with manage.py ... I see the below"

# python manage.py adminindex myApp
Unknown command: 'adminindex'
Type 'manage.py help' for usage.

My INSTALLED_APPS does include  'django.contrib.admin'.

Thanks in advance - I realize I could manually create the output of
this command but fear it is a symptom of a larger installation issue.

Joe

--

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: Stuck with simple query

2009-11-28 Thread Benjamin Wolf
Hi Steve,

thx for the hint with de debug toolbar, very nice.
It's working now,
greets ben

Steve Howell schrieb:
> On Nov 28, 8:36 am, Benjamin Wolf  wrote:
>   
>> Hi,
>>
>> I'm trying to create a query like this with django:
>> SELECT count(*) As total FROM `disposal` group by(salesman_id)
>>
>> This gives me the number of total sales for every salesman.
>> In django I tried this:
>> data = Disposal.objects.annotate(total=Count('salesman'))
>> print str(x[0].total)
>>
>> But total is always 1.
>>
>> 
>
> What happens when you run the query outside of Django?
>
> You can see the SQL that Django is generating for you by looking at
> something like db.connection.queries[-1]['sql'], or for more debugging
> goodness, you can install the Django debug toolbar.
>
> --
>
> 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.




solution found to ch. 7 in ch. 8

2009-11-28 Thread John Blake Arnold
I needed single quotes about pathway in urls.py like so, Thanks:


from django.conf.urls.defaults import *
from mysite import views
from mysite.views import hello, current_datetime, hours_ahead
from mysite.books import views
from mysite.contact import views

#, my_homepage_view
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
   (r'^admin/doc/', include('django.contrib.admindocs.urls')),
#20 Uncomment the next line to enable the admin:
)
urlpatterns = patterns('',
(r'^hello/$', hello),
(r'^time/$', current_datetime),
(r'^time/plus/(\d{1,2})/$', hours_ahead),
(r'^admin/', include(admin.site.urls)),
(r'^contact/thanks/$', 'mysite.contact.views.contact'),
(r'^contact/$', 'mysite.contact.views.contact'),
(r'^search-form/$', 'mysite.books.views.search_form'),
(r'^search/$', 'mysite.books.views.search'),
)

--

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.




working djangobook ch.7 cant get urls.py running books and contact at same time

2009-11-28 Thread John Blake Arnold
Hi,
My name is John and I'm running Django1.1.1 on XAMPP for Windows with Apache
2.2.12, Python 2.5.2,mod_python3.3.1,using the default sqlite3 database for
the examples.
I am working through the Apress The Definitve Guide To Django Web
Development Done Right 2nd Edition between pg. 129 and the end of the
chapter 7.

Basically, I can get either my contact or my book search to work, but not
both at the same time. The views are in different directories and don't
include or import to each other. I first got the contact working in the
books view in mysite/books/views.py, then moved it to its own folder in
mysite/contact/views as suggested, once I did that I thought the conflict in
my urls.py folder was due to views identifier conflicting as they had the
same name for the views file but not the completely specific pathway

urlpatterns = patterns('',
(r'^hello/$', hello),
(r'^time/$', current_datetime),
(r'^time/plus/(\d{1,2})/$', hours_ahead),
(r'^admin/', include(admin.site.urls)),
(r'^contact/thanks/$', views.contact),   <--
(r'^contact/$', views.contact),  <---
(r'^search-form/$', views.search_form),   <
(r'^search/$', views.search),  <---

so i changed it to this:

urlpatterns = patterns('',
(r'^hello/$', hello),
(r'^time/$', current_datetime),
(r'^time/plus/(\d{1,2})/$', hours_ahead),
(r'^admin/', include(admin.site.urls)),
(r'^contact/thanks/$', contact.views.contact),
(r'^contact/$', contact.views.contact),
(r'^search-form/$', books.views.search_form),
(r'^search/$', books.views.search),

now all of my web views are nuked because "contact is not defined", how do I
accurately assign the right extended path to the required classes?
Any help is appreciated, 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: Stuck with simple query

2009-11-28 Thread Steve Howell

On Nov 28, 8:36 am, Benjamin Wolf  wrote:
> Hi,
>
> I'm trying to create a query like this with django:
> SELECT count(*) As total FROM `disposal` group by(salesman_id)
>
> This gives me the number of total sales for every salesman.
> In django I tried this:
> data = Disposal.objects.annotate(total=Count('salesman'))
> print str(x[0].total)
>
> But total is always 1.
>

What happens when you run the query outside of Django?

You can see the SQL that Django is generating for you by looking at
something like db.connection.queries[-1]['sql'], or for more debugging
goodness, you can install the Django debug toolbar.

--

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: is_valid error/bug when unique_together fields are both ForeignKey fields

2009-11-28 Thread cerberos
The problem ("Foo bar with this None and None already exists.") only
happens when I use a ModelForm and choose to specify the field details
myself. Here is an example

Models

class Foo(models.Model):
f = models.IntegerField(unique=True)
def __unicode__(self):
return 'Foo with f = %d' % self.f

class Bar(models.Model):
b = models.IntegerField(unique=True)
def __unicode__(self):
return 'Bar with b = %d' % self.b

class FooBar(models.Model):
   foo = models.ForeignKey('Foo')
   bar = models.ForeignKey('Bar')

   class Meta:
   unique_together = (('foo','bar'),)


Form

class FooBarForm(forms.ModelForm):
foo = forms.ModelChoiceField(Foo.objects.all())
bar = forms.ModelChoiceField(Bar.objects.all())

class Meta:
model = FooBar


Try to save a combination of foo and bar that already exists and the
error message says "this None and None", comment out the field
overrides and there's no problem. I have had a look at the ModelForm
and the unique_together code but didn't find anything.

--

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.




Stuck with simple query

2009-11-28 Thread Benjamin Wolf
Hi,

I'm trying to create a query like this with django:
SELECT count(*) As total FROM `disposal` group by(salesman_id)

This gives me the number of total sales for every salesman.
In django I tried this:
data = Disposal.objects.annotate(total=Count('salesman'))
print str(x[0].total)

But total is always 1.

Thanks a lot for your help!

--

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




Re: Many-to-many through multiple tables

2009-11-28 Thread t0ster
May be Group should include packages of specific versions:

class Group(models.Model):
name = models.CharField(max_length=100)
product = models.ForeignKey(Product)
-packages = models.ManyToManyField(Package)
+packages = models.ManyToManyField(PackageVersion)


class Profile(models.Model):
name = models.CharField(max_length=100)
businessversion = models.ForeignKey(BusinessVersion)
lifecyclestage = models.ForeignKey(LifecycleStage)
group = models.ForeignKey(Group)
-packageversions = models.ManyToManyField(PackageVersion)

So:

for package in profile.profile.group.packages.all():
print package.package.name
print package.version


And what is BusinessVersion I didn't understand.


On Nov 28, 4:59 pm, Jonathan  wrote:
> Hi,
>
> I've slimmed it down to the relevant fields. I'm a bit of a noob, but
> I think I'm basically trying to build a generic framework that can be
> made specific in a profile.
>
> Profile = BusinessVersion + Group + LifecycleStage + Package.Versions
>
> Jonathan
>
> class Product(models.Model):
>     name = models.CharField(max_length=20)
>
> class BusinessVersion(models.Model):
>     version = models.CharField(max_length=10)
>     description = models.CharField(max_length=100)
>     product = models.ForeignKey(Product)
>
> class LifecycleStage(models.Model):
>     name = models.CharField(max_length=40)
>     sequence = models.DecimalField(max_digits=2, decimal_places=0)
>
> class Package(models.Model):
>     name = models.CharField(max_length=100)
>
> class PackageVersion(models.Model):
>     version = models.CharField(max_length=10)
>     package = models.ForeignKey(Package)
>     lifecyclestage = models.ForeignKey(LifecycleStage)
>
> class Group(models.Model):
>     name = models.CharField(max_length=100)
>     product = models.ForeignKey(Product)
>     packages = models.ManyToManyField(Package)
>
> class Profile(models.Model):
>     name = models.CharField(max_length=100)
>     businessversion = models.ForeignKey(BusinessVersion)
>     lifecyclestage = models.ForeignKey(LifecycleStage)
>     group = models.ForeignKey(Group)
>     packageversions = models.ManyToManyField(PackageVersion)
>
> class Stream(models.Model):
>     name = models.CharField(max_length=4)
>     businessversion = models.ForeignKey(BusinessVersion)
>
> On Nov 29, 1:19 am, t0ster  wrote:
>
>
>
> > Could you post your models.py code here?
>
> > On Nov 28, 1:10 pm, Jonathan  wrote:
>
> > > This may be more of a general database design question, but I want to
> > > come up with something that works with Django's ORM.
>
> > > I have four bits of information that I want to link together. Generic
> > > packages, package versions, groups of packages and a profile that
> > > brings them together.
>
> > > The final goal is a Profile that binds the Packages from a Group to
> > > specific Versions.
>
> > > I have a solution at the moment but it seems a bit clumsy for what
> > > seems like something that would be commonly encountered.
>
> > > 4 models: Package, Version, Group and Profile. I've omitted the id
> > > primary key column on the examples.
>
> > > Package:
> > > | name   |
> > > --
> > > | django |
> > > | python |
>
> > > Version:
> > > | package_id | version |
> > > --
> > > |          1 |     1.0 |
> > > |          1 |     1.1 |
> > > |          2 |     2.4 |
> > > |          2 |     2.6 |
>
> > > Group:
> > > | name |
> > > --
> > > | django_stack |
>
> > > group_packages:
> > > | group_id | package_id |
> > > --
> > > |        1 |          1 |
> > > |        1 |          2 |
>
> > > Profile:
> > > |        name | group_id |
> > > --
> > > | django_prod |        1 |
> > > |  django_dev |        1 |
>
> > > profile_packageversion:
> > > | profile_id | version_id |
> > > --
> > > |          1 |          1 |
> > > |          1 |          2 |
> > > |          2 |          3 |
> > > |          2 |          4 |
>
> > > I can get what I need from a two step process, but is this the best or
> > > most direct way to achieve this?
>
> > > for package in profile.group.packages.all():
> > >     print package.name
> > >     for version in package.versions.all():
> > >         print version
>
> > > Is there a nicer way to do this? Is there a different model structure
> > > that I could use?
>
> > > Jonathan

--

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

2009-11-28 Thread Sandman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

If the problem is with extracting the files from the tar.gz, you might
want to make sure that you are using the command tar -xvzf ... and not
tar xvzf (Note the hyphen '-') before the xvzf. These are options passed
to the tar command.

I hope this helps. If this doesn't work, you might want to copy paste
the output from the terminal.
Take care.


Christophe Pettus wrote:
> On Nov 27, 2009, at 1:01 PM, Eric wrote:
>> Why doesn't
>> Mac have an easy way to install stuff.
> 
> I think we'll need a bit more information about the problem you're  
> having; installing Django 1.1 on my Leopard MacBook Pro was entirely  
> painless.  What errors are you getting at which steps?
> 
> --
> -- Christophe Pettus
> x...@thebuild.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.
> 
> 

-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJLETt4AAoJEMBDbtUxk6zPVhkH/AogIB2I+Wurn4n83Y0tv+38
PVyqEjeiOIaUEanJM6zpP+zfiD2oppohhAv3fIXlWe0ShLVv40KOht3i2nPFB5/2
93TrVjVAb21p6VZtS9//1PgANTcduGTqrjyvVlNvyb5shSW44Sb31mC8b/LBt1d3
Rb7P5fE6LscZwd4EQthCl/TrOBhd+IkIHHG/h6eRcnPJVvXwGE3rWU15Q/mNaYjA
DuDlFXTFx6fw7lQe9pBZs6l2hBgE/1Y/4djge86W/1zXWn/Ykl95gS9RVDICkw2M
1RdsWPFJCxzLZ/GKAY5dKCuOynppcqOKAArzE3AbiWFz197m2I8y+hNhwCr5LDI=
=I1p6
-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: Many-to-many through multiple tables

2009-11-28 Thread Jonathan
Hi,

I've slimmed it down to the relevant fields. I'm a bit of a noob, but
I think I'm basically trying to build a generic framework that can be
made specific in a profile.

Profile = BusinessVersion + Group + LifecycleStage + Package.Versions

Jonathan

class Product(models.Model):
name = models.CharField(max_length=20)

class BusinessVersion(models.Model):
version = models.CharField(max_length=10)
description = models.CharField(max_length=100)
product = models.ForeignKey(Product)

class LifecycleStage(models.Model):
name = models.CharField(max_length=40)
sequence = models.DecimalField(max_digits=2, decimal_places=0)

class Package(models.Model):
name = models.CharField(max_length=100)

class PackageVersion(models.Model):
version = models.CharField(max_length=10)
package = models.ForeignKey(Package)
lifecyclestage = models.ForeignKey(LifecycleStage)

class Group(models.Model):
name = models.CharField(max_length=100)
product = models.ForeignKey(Product)
packages = models.ManyToManyField(Package)

class Profile(models.Model):
name = models.CharField(max_length=100)
businessversion = models.ForeignKey(BusinessVersion)
lifecyclestage = models.ForeignKey(LifecycleStage)
group = models.ForeignKey(Group)
packageversions = models.ManyToManyField(PackageVersion)

class Stream(models.Model):
name = models.CharField(max_length=4)
businessversion = models.ForeignKey(BusinessVersion)

On Nov 29, 1:19 am, t0ster  wrote:
> Could you post your models.py code here?
>
> On Nov 28, 1:10 pm, Jonathan  wrote:
>
> > This may be more of a general database design question, but I want to
> > come up with something that works with Django's ORM.
>
> > I have four bits of information that I want to link together. Generic
> > packages, package versions, groups of packages and a profile that
> > brings them together.
>
> > The final goal is a Profile that binds the Packages from a Group to
> > specific Versions.
>
> > I have a solution at the moment but it seems a bit clumsy for what
> > seems like something that would be commonly encountered.
>
> > 4 models: Package, Version, Group and Profile. I've omitted the id
> > primary key column on the examples.
>
> > Package:
> > | name   |
> > --
> > | django |
> > | python |
>
> > Version:
> > | package_id | version |
> > --
> > |          1 |     1.0 |
> > |          1 |     1.1 |
> > |          2 |     2.4 |
> > |          2 |     2.6 |
>
> > Group:
> > | name |
> > --
> > | django_stack |
>
> > group_packages:
> > | group_id | package_id |
> > --
> > |        1 |          1 |
> > |        1 |          2 |
>
> > Profile:
> > |        name | group_id |
> > --
> > | django_prod |        1 |
> > |  django_dev |        1 |
>
> > profile_packageversion:
> > | profile_id | version_id |
> > --
> > |          1 |          1 |
> > |          1 |          2 |
> > |          2 |          3 |
> > |          2 |          4 |
>
> > I can get what I need from a two step process, but is this the best or
> > most direct way to achieve this?
>
> > for package in profile.group.packages.all():
> >     print package.name
> >     for version in package.versions.all():
> >         print version
>
> > Is there a nicer way to do this? Is there a different model structure
> > that I could use?
>
> > Jonathan

--

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

2009-11-28 Thread Karen Tracey
On Fri, Nov 27, 2009 at 6:35 AM, Ryan  wrote:

> I realize that I should be validating my data before saving it, but
> I'll admit I don't guard against every eventuality.  My question is,
> should I be doing something in my code to prevent this kind of poor
> exception handling, or should I file a bug against django?  I would
> certainly prefer the whole server not to break when the transaction
> commit fails for whatever reason -- it should rollback the transaction
> and give a 500 error page.
>

I think there is already a ticket filed on this:

http://code.djangoproject.com/ticket/6094

Karen

--

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




Apache unicode problem!why it is OK in "manage.py runserver 8000" ? but it is not OK when "apach + mod_python" !

2009-11-28 Thread hao he
hi all:
 I write a tag "model_as_table_with", used like this  in template :

{{model_instance | *model_as_table_with*:"real_name,gender,birthdate,}}


problem was raise in my  "*model_as_table_with*" function.
this following code is ok when I runserver with "manage.py runserver 8000"
*col = "%s:%s" % (field.name and field.verbose_name,
getattr(model_instance, **field**.name)) *
but, when I run my project with " apache + mod_python ".
it raise this Exception :
"Exception=,e='ascii' codec can't decode byte
0xe7 in position 4: ordinal not in range(128)"
I have to modify the code like this :
*col = "%s:%s" % (field.name and field.verbose_name,
getattr(**model_instance**, **field**.name).encode('utf-8')  **)*

all of my code files are set to utf-8, why it is still need to *encode('utf-8')
?*
why it is OK in "manage.py runserver 8000" ? but it is not OK when "apach +
mod_python"

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: Many-to-many through multiple tables

2009-11-28 Thread t0ster
Could you post your models.py code here?

On Nov 28, 1:10 pm, Jonathan  wrote:
> This may be more of a general database design question, but I want to
> come up with something that works with Django's ORM.
>
> I have four bits of information that I want to link together. Generic
> packages, package versions, groups of packages and a profile that
> brings them together.
>
> The final goal is a Profile that binds the Packages from a Group to
> specific Versions.
>
> I have a solution at the moment but it seems a bit clumsy for what
> seems like something that would be commonly encountered.
>
> 4 models: Package, Version, Group and Profile. I've omitted the id
> primary key column on the examples.
>
> Package:
> | name   |
> --
> | django |
> | python |
>
> Version:
> | package_id | version |
> --
> |          1 |     1.0 |
> |          1 |     1.1 |
> |          2 |     2.4 |
> |          2 |     2.6 |
>
> Group:
> | name |
> --
> | django_stack |
>
> group_packages:
> | group_id | package_id |
> --
> |        1 |          1 |
> |        1 |          2 |
>
> Profile:
> |        name | group_id |
> --
> | django_prod |        1 |
> |  django_dev |        1 |
>
> profile_packageversion:
> | profile_id | version_id |
> --
> |          1 |          1 |
> |          1 |          2 |
> |          2 |          3 |
> |          2 |          4 |
>
> I can get what I need from a two step process, but is this the best or
> most direct way to achieve this?
>
> for package in profile.group.packages.all():
>     print package.name
>     for version in package.versions.all():
>         print version
>
> Is there a nicer way to do this? Is there a different model structure
> that I could use?
>
> Jonathan

--

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

2009-11-28 Thread Christian Schilling
http://github.com/initcrash/django-object-permissions/
implements this on 1.1 (it's not hard at all, so i don't really
understand the change planed for 1.2)
there are no docs yet, but the testproject shows how to use it: just
use ObjectPermissionAdmin
as base for the admin classes instead of ModelAdmin, that's it.

On Nov 25, 2:49 pm, rebus_  wrote:
> 2009/11/25 Gamliel Roi :
>
>
>
> > Any idea when 1.2 will be released?
>
> > On Wed, Nov 25, 2009 at 3:31 PM, rebus_  wrote:
>
> >> 2009/11/25 Russell Keith-Magee :
> >> > On Tue, Nov 24, 2009 at 11:16 PM, rebus_  wrote:
> >> >> 2009/11/24 nek4life :
> >> >>> You should look into django-authority.  I'm pretty sure that has per-
> >> >>> object-permissions.
>
> >> >>>http://packages.python.org/django-authority/index.html
>
> >> >>> On Nov 24, 7:00 am, gamliel roi  wrote:
> >>  Hello all,
>
> >>  I have the admin site up and running but I need to create a group of
> >>  users,
> >>  such that each of the users will be able to edit objects that are
> >>  only
> >>  relevant to them (e.g Project objects that the user is also the
> >>  ProjectManager).
>
> >>  I know that in the past Django had a Per-object permissions branch,
> >>  which is
> >>  now abandoned.
>
> >>  Should I peruse this direction and try to incorporate this branch to
> >>  my
> >>  current code? is it documented and running properly?
>
> >>  Any other ideas/suggestions/resources regarding this problem?
>
> >> >> Row level permisions should be implemented in Django version  1.2 [1]
> >> >> if you have the time to wait...
>
> >> >> [1]http://code.djangoproject.com/wiki/Version1.2Features
>
> >> > To be clear - that ticket *doesnt'* implement row-level permissions;
> >> > it modifies the calls for permission checks to allow you to build a
> >> > row-level permissions checker external to Django.
>
> >> > Yours,
> >> > Russ Magee %-)
>
> >> That's true, i probably wasn't too clear on this.
>
> >> But i would rather use Django API to implement row-level permissions
> >> then start building my own implementation from scratch, if you have
> >> the luxury of waiting till it hits trunk or comes out in 1.2 that is.
>
> >> Davor
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django-us...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Best
> > Roi Gamliel
>
> > --
>
> http://code.djangoproject.com/wiki/Version1.2Roadmap

--

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




Re: CSRF gone haywire

2009-11-28 Thread rebus_
2009/11/27 Tim Valenta :
> Also, I've figured out just now while rereading the reply I got, that
> "AFAIK" must mean "as far as I know".  Please... can we not use
> ridiculous short forms for a language that works better when not
> profusely abbreviated?  That would have been a hundred times harder to
> figure out if I were a not a native speaker of English.  I can handle
> a few of those, like IMHO, but I can't say that I've come across
> "AFAIK" often enough to compute that in record time.
>

You must be joking :)

--

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.




Many-to-many through multiple tables

2009-11-28 Thread Jonathan
This may be more of a general database design question, but I want to
come up with something that works with Django's ORM.

I have four bits of information that I want to link together. Generic
packages, package versions, groups of packages and a profile that
brings them together.

The final goal is a Profile that binds the Packages from a Group to
specific Versions.

I have a solution at the moment but it seems a bit clumsy for what
seems like something that would be commonly encountered.

4 models: Package, Version, Group and Profile. I've omitted the id
primary key column on the examples.

Package:
| name   |
--
| django |
| python |

Version:
| package_id | version |
--
|  1 | 1.0 |
|  1 | 1.1 |
|  2 | 2.4 |
|  2 | 2.6 |

Group:
| name |
--
| django_stack |

group_packages:
| group_id | package_id |
--
|1 |  1 |
|1 |  2 |

Profile:
|name | group_id |
--
| django_prod |1 |
|  django_dev |1 |

profile_packageversion:
| profile_id | version_id |
--
|  1 |  1 |
|  1 |  2 |
|  2 |  3 |
|  2 |  4 |

I can get what I need from a two step process, but is this the best or
most direct way to achieve this?

for package in profile.group.packages.all():
print package.name
for version in package.versions.all():
print version

Is there a nicer way to do this? Is there a different model structure
that I could use?

Jonathan

--

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




filter_horizontal not working properly

2009-11-28 Thread hugis
Hi,

I'm using django 1.0.2 (from debian lenny). I have this in model.py:

from django.contrib.auth.models import User
class Tc_server:
tc_url = models.CharField(max_length=200)
...
class Vrstva(Vrstvy_zaklad):
...
tc_server = models.ManyToManyField(Tc_server, blank=True)
aktivna_pre = models.ManyToManyField(User, blank=True)
...

and when i add this in admin.py:

class Vrstva_Admin(admin.ModelAdmin):
fields = (..., 'aktivna_pre', 'tc_server', ...)
filter_horizontal = ('aktivna_pre','tc_server')
admin.site.register(Vrstva, Vrstva_Admin)

I get js widget for "tc_server" but not for "aktivna_pre". If I remove
filter_horizontal line I get multiple select box for both fields. What
am I doing wrong?

h

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Cannot assign None, does not allow null values

2009-11-28 Thread Martin Lundberg
Is it not that you forget to give the published property a value?

On Sat, Nov 28, 2009 at 9:07 AM, onoxo  wrote:

> Hi!
>
> when i go to create Actual class. i get this error:
> Cannot assign None: "Actual.published" does not allow null values.
>
> and it makes this error with each class that has published propertie.
>
>
>
> On Nov 28, 3:32 am, Tim Valenta  wrote:
> > You've got a lot of models in that file.  Which one are you trying to
> > save when it throws the error?
> >
> > By the way, I notice that your "ItemWithMedia" class is probably
> > creating a database table.. if you never need to manipulate it direct
> > (ie, you only make subclasses of it), I might suggest putting this in
> > the definition:
> >
> > class ItemWithMedia(models.Model):
> > # ... all of your old stuff goes here
> > class Meta:
> > abstract = True
> >
> > That way Django knows it's just a base class.
> >
> > Not sure what the problem is, yet...
> >
> > On Nov 27, 3:27 pm, onoxo  wrote:
> >
> >
> >
> > > btw. here is a full code:
> >
> > > models.pyhttp://
> snipt.net/vedran/django-models-cannot-assign-none?key=ba151d53...
> >
> > > admin.pyhttp://
> snipt.net/vedran/django-admin-cannot-assign-none?key=53222b89c...
> >
> > > so... when i go to create new Actual item i get this error:
> > > Cannot assign None: "Actual.published" does not allow null values.
> >
> > > On Nov 27, 10:57 pm, onoxo  wrote:
> >
> > > > i get this error when i try to create new item in admin site.
> >
> > > > here is my models.py
> > > > import datetime
> > > > from django.db import models
> > > > from tinymce import models as tinymce_models
> > > > from filebrowser.fields import FileBrowseField
> >
> > > > class ItemWithMedia(models.Model):
> > > > created = models.DateTimeField(auto_now_add=True)
> > > > modified = models.DateTimeField(auto_now=True)
> >
> > > > class Actual(ItemWithMedia):
> > > > published = models.DateField('Published')
> > > > title_hr = models.CharField('(hr)', max_length=200)
> > > > title_en = models.CharField('(en)', max_length=200)
> > > > body_text_hr = models.TextField('(hr)')
> > > > body_text_en = models.TextField('(en)')
> >
> > > > def __unicode__(self):
> > > > return self.title_hr
> >
> > > > class Meta:
> > > > verbose_name = "Aktualno"
> > > > verbose_name_plural = "Aktualni"
> > > > ordering = ['-published']
> >
> > > > what could be the problem?
>
> --
>
> 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: Cannot assign None, does not allow null values

2009-11-28 Thread onoxo
Hi!

when i go to create Actual class. i get this error:
Cannot assign None: "Actual.published" does not allow null values.

and it makes this error with each class that has published propertie.



On Nov 28, 3:32 am, Tim Valenta  wrote:
> You've got a lot of models in that file.  Which one are you trying to
> save when it throws the error?
>
> By the way, I notice that your "ItemWithMedia" class is probably
> creating a database table.. if you never need to manipulate it direct
> (ie, you only make subclasses of it), I might suggest putting this in
> the definition:
>
>     class ItemWithMedia(models.Model):
>         # ... all of your old stuff goes here
>         class Meta:
>             abstract = True
>
> That way Django knows it's just a base class.
>
> Not sure what the problem is, yet...
>
> On Nov 27, 3:27 pm, onoxo  wrote:
>
>
>
> > btw. here is a full code:
>
> > models.pyhttp://snipt.net/vedran/django-models-cannot-assign-none?key=ba151d53...
>
> > admin.pyhttp://snipt.net/vedran/django-admin-cannot-assign-none?key=53222b89c...
>
> > so... when i go to create new Actual item i get this error:
> > Cannot assign None: "Actual.published" does not allow null values.
>
> > On Nov 27, 10:57 pm, onoxo  wrote:
>
> > > i get this error when i try to create new item in admin site.
>
> > > here is my models.py
> > > import datetime
> > > from django.db import models
> > > from tinymce import models as tinymce_models
> > > from filebrowser.fields import FileBrowseField
>
> > > class ItemWithMedia(models.Model):
> > >     created = models.DateTimeField(auto_now_add=True)
> > >     modified = models.DateTimeField(auto_now=True)
>
> > > class Actual(ItemWithMedia):
> > >     published = models.DateField('Published')
> > >     title_hr = models.CharField('(hr)', max_length=200)
> > >     title_en = models.CharField('(en)', max_length=200)
> > >     body_text_hr = models.TextField('(hr)')
> > >     body_text_en = models.TextField('(en)')
>
> > >     def __unicode__(self):
> > >         return self.title_hr
>
> > >     class Meta:
> > >         verbose_name = "Aktualno"
> > >         verbose_name_plural = "Aktualni"
> > >         ordering = ['-published']
>
> > > what could be the problem?

--

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.