Re: manipulator.do_html2python(new_data) not working?

2007-05-23 Thread Mike Axiak

If you have checkbox fields you also need to run ``prepare``::
   ...
   manipulator.prepare(new_data)
   manipulator.do_html2python(new_data)
   ...

I hope this helps,

-Mike

On May 23, 12:11 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Can you post your manipulator code?
>
> On May 18, 1:35 pm, Mason <[EMAIL PROTECTED]> wrote:
>
> > I'm a Newbie at Django (release ver. 0.96) and I've got a problem with
> > saving data from a Django checkbox to MySQL.
>
> > The code that I'm running looks like this:
>
> > manipulator.do_html2python(new_data)
> > print "\nnew data: ", new_data
> > new_baseline_fsr = manipulator.save(new_data)
>
> > The print statement shows that new_data is providing [True] or [False]
> > values for the boolean fields which are appearing as check boxes, but
> > the error message from the web server is reporting either empty
> > strings or 'on' values as follows:
>
> > OperationalError at /fsr/create_new/140101,13-1001/
> > (1366, "Incorrect integer value: 'on' for column 'coldwork' at row 1")
> > Request Method: POST
> > Request URL:http://127.0.0.1:8000/fsr/create_new/140101,13-1001/
> > Exception Type: OperationalError
> > Exception Value:(1366, "Incorrect integer value: 'on' for column
> > 'coldwork' at row 1")
> > Exception Location: C:\Python24\lib\site-packages\MySQLdb
> > \connections.py in defaulterrorhandler, line 35
>
> > Does anyone out there have any ideas about what I'm doing wrong?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Catch an InvalidPage exception in templatetag? (Django-0.96)

2007-05-23 Thread Jarek Zgoda

I try to catch the InvalidPage exception in my templatetag code, but it
seems still uncaught. The code looks like:

try:
articles = paginator.get_page(paginator.actual_page)
except InvalidPage:
raise Http404

When there's no pages in paginator, I see the TemplateSyntaxError
wrapping InvalidPage as the result.

Am I doing something stupid?

-- 
Jarek Zgoda

"We read Knuth so you don't have to."

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



Re: Django Administration

2007-05-23 Thread samira

Thanks alot. I can find it. another thing, as you can see in tables
all records treted like object, do you think iut has a way to change
this? for example when click to one table, primary keys of it sorted.

On May 13, 11:47 am, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote:
> On Sun, May 13, 2007 at 12:18:22AM -0700, samira wrote:
> > I don't congifured it, how I can do this?
> > the error message is this"Not Found
> > The requested document was not found on this server."
>
> Are you using the apache web 
> server?http://www.djangoproject.com/documentation/modpython/may be helpful for
> you.
>
> With kind regards,
> --
> Baurzhan Ismagulovhttp://www.kz-easy.com/


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



Re: unit tests: database confusion

2007-05-23 Thread jararaca

Thanks Russ, I don't have a stray settings-file but I've spotted the
problem now: One of my files with custom SQL for the models contained
the line USE xy; (with xy being my database, argh!). So everything
before the execution of this line used my test database correctly but
all later commands were executed on the real database.

Happy testing to all of you,
micha

> > But the strangest part is yet to come: When testing, it is obviously
> > always my "real" database that is being read, not the 'test_xy'
> > database, even if I change DATABASE_NAME in settings!


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: {{ perms }} seems to be empty

2007-05-23 Thread Aidas Bendoraitis

Is "django.core.context_processors.auth" set in your
TEMPLATE_CONTEXT_PROCESSORS? Are those new custom permissions in the
auth_permission table? If not - try to delete the test tables and
syncdb again.

Regards,
Aidas Bendoraitis aka Archatas


On 5/23/07, Michael Lake <[EMAIL PROTECTED]> wrote:
>
> Hi all
>
> I have a template and request is being passed to it and so I expected that
> {{ perms }} would be availablke as in Chap 12 of the Django book.
>
> I have this:
>
> Permissions:
> {% for permission in in request.user.get_all_permissions %}
> + {{ permission }}
> {% endfor %}
>
> {% if perms.lab %}
> yes you have permissions
> {% else %}
> no permissions
> {% endif %}
>
> On output I get:
>
> Permissions:
>+ lab.change_test
>+ lab.delete_test
>+ lab.add_test
> no permissions
>
>
> I get the same "no permissions" if I try {% if perms.lab %} or {% if perms %}
>
> What am I doing wrong?
>
> Mike
>
> --
> Michael Lake
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Offline Django Apps

2007-05-23 Thread Tom

On May 22, 11:47 pm, Rob Hudson <[EMAIL PROTECTED]> wrote:
>
> 1) Cross Platform Libraries...
>
> In looking atDjangoKita little I see he's using PyObjC.  I do like
> the idea of using whatever the native widget library is for each
> platform.  I'll have to look at the Democracy Player as an example but
> they did something similar (Mac: PyObjC, Linux: PyGTK, Windows: ???).

DjangoKit is a native-widgets project, and will probably stay that
way. I very much like the idea of Windows and linux-specific native-
widget projects to complement it. The core of the thing was very easy
to write - the hardest part was getting the packaging system to
behave, so there probably won't be a lot of effort duplicated between
the platforms here.

> 2) Database...
>
> It makes sense to me to require SQLite for this to work.  Moving your
> data to SQLite is also a requirement for Slingshot.  I'm pretty sure
> we can use the fixtures library to serialize data from databases other
> than SQLite (MySQL, PostGreSQL), then load it up into SQLite.

This, on the other hand, _can_ be shared nicely. And has nothing to do
with a GUI wrapper. A framework that will do 2-way sync between 2
django applications / databases can be worked on in the absence of
working wrappers.

> 3) Anything else?

(a) One thing I've been finding is that many django apps I've found
aren't really written as apps, but tend to be tied very heavily to the
project they're developed in. I've only just joined django-users, so
maybe this is covered a lot. But because djangokit provides it's own
project and expects the thing you're packaging to be a stand-alone
app, it's hard to find nice demos.

(b We're going to find lots and lots of different deployed versions of
the app's DB schema in the wild, so upgrades will be nasty. With
proper 2-way sync, you could just tell the remote user to sync, blow
away their DB, then re-sync, but if you're trying to write a simple
stand-alone app, you'll need upgrade scripts.

tom


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



Re: Komodo and Django - code completion / code intellisensing

2007-05-23 Thread oliver

I have given up on komodo for now and moved to WingIDE.
It does the code completion quite well, not to the extend that i would
prefer as in including django specific functions. (if any one knows
how to do that in wingide ??? would be handy!)

thanks

On May 23, 3:13 am, ro <[EMAIL PROTECTED]> wrote:
> On May 11, 1:59 am, oliver <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thanks, for both comments but still no luck.
> > I tried multiple various but it still gives me the same error.
>
> > my projects are in c:\django-projects\Project1..
>
> > I installed the latest beta ofkomodo, but has the same thing.
> > Python2.5 is installed in c:/python25 and is in my path (from the CMD
> > i can start pyton any where)
>
> > any other suggestions?
>
> > thanks again for helping
>
> > oli
>
> > On May 10, 3:12 pm, Ceph <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
>
> > > Go to Edit > Preferences. Expand the "Languages" group by clicking the
> > > [+] symbol. Click "Python". Click the little "Add..." button under
> > > "Additional Python Import Directories". Add the directory ABOVE your
> > > project and you should have intellisense enabled.
>
> > > On May 9, 12:01 pm, oliver <[EMAIL PROTECTED]> wrote:
>
> > > > Hi i am evaluatingkomodoas my django/python ide but i can't get the
> > > > code completion to work. It gives me this error:
>
> > > > error evaluating 'models' at models.py#4: NameError: global name 'XXX'
> > > > is not defined (C:\Prog..\Active..\lib\mozilla\python\komodo
> > > > \codintel2\tree_python.py#169 in _members_from_elem) (error
> > > > determining completions)
>
> > > > I am on Windows XP, python 2.5,komodoide 4.0, latest django svn.
> > > > This error appears when you type for example:
>
> > > > class ...
> > > >   name = models.
>
> > > > right after the models "."
>
> > > > any one got this to work or is this a general bug inkomodo?
>
> > > > Thanks!- Hide quoted text -
>
> > - Show quoted text -
>
> I have the same problem with you.
> I think it is a bug of komodo


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is it essential to run setup.py?

2007-05-23 Thread Daniel Ellison

On Wednesday 23 May 2007 01:07:13 Thomas Ashelford wrote:
> Is there any kind soul who could explain what I can do to install 0.96
> without root access?

If you're using Apache, you can include the path to Django in your .htaccess 
file. For example, I have a directory "software" which lives 
alongside "public_html" (aliased to "www") in my account's home directory. In 
there I've svn co'd the latest Django. You could actually have as many Django 
versions in there as you want. In the .htaccess file for a particular 
project, include the path to the Django you want to use for that project:

PythonPath "['/home/[your_home]/software/django', '/home/[your_home]/www'] + 
sys.path

Remember that the paths have to point to the directory in which each Python 
module lives. So inside the "django" directory there is another "django" 
directory which is the actual module that gets imported.

Dan

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



need to know to learn django

2007-05-23 Thread Gigs_

What I need to know to learn django, except python(HTML, javascript,
sql, etc)?

thanks


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



Re: {{ perms }} seems to be empty

2007-05-23 Thread Mike Lake

Hi

Aidas asked .
> Is "django.core.context_processors.auth" set in your
> TEMPLATE_CONTEXT_PROCESSORS? Are those new custom permissions in the
> auth_permission table? If not - try to delete the test tables and
> syncdb again.

1. TEMPLATE_CONTEXT_PROCESSORS is not in my settings file. But the docs say 
that its default is: ("django.core.context_processors.auth", etc...

2. Are the permissions in the auth_permissions table?
I'm not really sure They are listed in the graphical admin page/users/ page 
when you edit a user listed there. The table shows 'Available user permissions' 
and 'Chosen user permissions' and I have added them to the later. I don't know 
if they are custom permissions - I didn't do anything explicit to add then. 
Django got them from my models automatically. 

3. You suggested to reload the Test tables. I have done that via sqlite3 and 
dropped the Test table then did.
$ python manage.py syncdb
Creating table lab_test
$

My template still gives the same output. 

> On 5/23/07, Michael Lake <[EMAIL PROTECTED]> wrote:
> >
> > Hi all
> >
> > I have a template and request is being passed to it and so I 
> expected that
> > {{ perms }} would be availablke as in Chap 12 of the Django book.
> >
> > I have this:
> >
> > Permissions:
> > {% for permission in in request.user.get_all_permissions %}
> > + {{ permission }}
> > {% endfor %}
> >
> > {% if perms.lab %}
> > yes you have permissions
> > {% else %}
> > no permissions
> > {% endif %}
> >
> > On output I get:
> >
> > Permissions:
> >+ lab.change_test
> >+ lab.delete_test
> >+ lab.add_test
> > no permissions
> >
> >
> > I get the same "no permissions" if I try {% if perms.lab %} or {% 
> if perms %}
> >
> > What am I doing wrong?
> >
> > Mike
> >
> > --
> > Michael Lake
> >
> >
> >
> >
> > >
> >
> 
> > 
> 

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Advice on Date-Based Generic Views

2007-05-23 Thread Justin

I'm looking for some advice on what date-based generic view (or a
custom view) is best for this situation:

I have a model in my app called 'Meeting', which contains a
meeting_date field.  The meetings are monthly, so what I would like to
setup the URLs like this:
#1   /meetings/
#2   /meetings/2007/
#3   /meetings/2007/may/

For #2, I'm using the 'year_archive' generic view.

For #3, I'm thinking about using the object_detail generic view, but
I'm not sure how to use the abbreviated month name, rather than the
month number.  Any ideas?

#1 is the one that I really need help with.  I want #1 to always point
to the next meeting.  So if the next meeting_date (after today) is
2007-05-25 I want "/meetings/" to be the same as "/meetings/2007/
may/".  What is the best way to achieve this?  I'd prefer not to just
redirect to the appropriate month, but I would like to use the same
template for the meeting details in #1 & #3.  I came up with a few
options that might work:

a. Use the 'archive_index' generic view with num_latest=1 and
allow_future=True.  The downside to this is that archive_index will
return the meeting in the 'latest' list in the template context AND
meetings would have to be entered each month after the previous
meeting (so the latest meeting is correct).  This latter one is not a
big deal, because some of the fields in Meeting cannot be populated
until after the previous meeting.  Is there an easy way to alias the
one object in 'latest' so that it will work with my
meeting_detail.html template?

b. Use the 'object_detail' for #1, but pass it
Meeting.objects.latest('pub_date').id as the object_id.  This is what
I am currently using, but my question is, does this hit the database
twice?  Once to get the latest object, and then again in
'object_detail' view? SimiIar to (a), I think this one also suffers
from having to enter the meetings after the previous meeting.

c. Write a custom view that determines the next meeting and returns a
context similar to 'object_detail' so I can use the same template both
places.


Justin


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: need to know to learn django

2007-05-23 Thread Anthony DROGON

Gigs_ a écrit :
> What I need to know to learn django, except python(HTML, javascript,
> sql, etc)?
>
> thanks
>
>
> >
>   
Hi Gigs_,

HTML, Javascript, and even CSS, are things you need to know to develop 
static web pages.
Django will, then, allow you to have your pages dynamic.
But you cannot avoid static bases (start with HTML and CSS, as 
Javascript might be useless for what you want).

Since Django has got its own database API, you don't need to know SQL to 
use it.

Anthony.

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



problem with admin look and feel also with dojo

2007-05-23 Thread [EMAIL PROTECTED]

hi i am new to this group
i have installed apache2 and django 0.96 with mysql. i have a small
application installed with this setup. now when i start admin page it
shows plain page without any look and feel. i can see it with django
internal server. i read previous article on it and made some changes
but still does not work.  other things are working just fine. my
configuration is as follows:

lines added in httpd.conf file

Alias /media/ "/usr/local/lib/python2.5/site-packages/django/contrib/
admin/media/"


Order Deny,Allow
Allow from all


remaining is same

settings.py and urls.py is set according to django official guide as
things are working with django internal server

access_log shows
127.0.0.1 - - [23/May/2007:07:09:55 -0500] "GET /admin HTTP/1.1" 301
- this line appears only once when i make some change in
httpd.conf
127.0.0.1 - - [23/May/2007:07:09:55 -0500] "GET /admin/ HTTP/1.1" 200
1620
127.0.0.1 - - [23/May/2007:07:09:56 -0500] "GET /media/css/login.css
HTTP/1.1" 404 2647

yes one more thing i would like to add is previous http status code
was of access denied  unauthorized access 401 before i made above
changes to httpd.conf. if it was unauthorized then how come it went
missing after these changes and if i comment above changes it still
shows 404 instead of 401.

i have also have dojo installed and when i called dojo without any
changes to httpd.conf it was showing 401. now after those changes it
is saying 200 OK. also if i remove those changes from httpd.conf it
still says 200 OK. very strange. i am restarting apache all the time i
make changes. even i tried restarting computer but nothing.

i am using dojo as follows:


  






  dojo.require("dojo.event.*");
  dojo.require("dojo.widget.*");
  dojo.require("dojo.widget.Button");

  function helloPressed()
  {
alert('You pressed the button');
  }

  function init()
  {
var helloButton = dojo.widget.byId('helloButton');
dojo.event.connect(helloButton, 'onClick', 'helloPressed')
  }

  dojo.addOnLoad(init);


  
  
Hello World!



with
Alias /media/ "/usr/local/lib/python2.5/site-packages/django/contrib/
admin/media/"
in httpd.conf

it is loading but not working having following error in javascript
console
No. 1
Error: missing } in XML expression
Source File: http://localhost/test/media/js/dojo/dojo.js
alert ('You pressed the button');
and No 2
Error: dojo is not defined
Source File: http://localhost/test/

help on these above topics is required as soon as possible

thanks in advance

Dushyant


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is it essential to run setup.py?

2007-05-23 Thread Thomas Ashelford


On May 23, 9:47 pm, Daniel Ellison <[EMAIL PROTECTED]> wrote:
> Remember that the paths have to point to the directory in which each Python
> module lives. So inside the "django" directory there is another "django"
> directory which is the actual module that gets imported.
>
> Dan

On May 23, 4:17 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> So it should have a "django/" directory inside it and you would need to
> adjust the Pythonpath to point to /what/ever/dir/Django-0.96/ (you are
> putting Django-0.96/ on the path, too, right? Not stopping one directory
> too soon?)

You have given me a 'doh' moment. I should have figured that out for
myself, but all this has given me a much better understanding of how
Python path works - it was always one of those things I sort-of got
but never really paid enough attention to. Thanks for your help.

Thomas


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



HTTP_X_FORWARDED_FOR on HTTPS connections?

2007-05-23 Thread Leandro Zanuz


Hi Everybody.

There is a way to take HTTP_X_FORWARDED_FOR (the real ip) on HTTPS 
connections?

Thanks
Leandro Zanuz

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Displaying my table data

2007-05-23 Thread [EMAIL PROTECTED]

Ok...then it would be soemthing like this:

choices = Choice.objects.filter(choice=1)
for choice in choices:   # you used filter, not get so I'm assuming
this is not the primary key and you are getting multiple objects back
  a.size.name
  a.price.name


However...if your size/price tables all just contain one field...maybe
you should have a model something like this..where you don't have
separate tables for size/price:

class Style(models.Model):
name = models.CharField(maxlength=200)
theslug = models.SlugField(prepopulate_from=('name',))

class Admin:
search_fields = ['name']

def __str__(self,):
return self.name

class Choice(models.Model):
choice = models.ForeignKey(Style,
edit_inline=models.TABULAR,num_in_admin=5)
size = models.IntegerField(size)
price = models..FloatField(null=True, max_digits=12,
decimal_places=2, blank=True)

def __str__(self,):
return str(self.choice)

On May 23, 1:54 am, Greg <[EMAIL PROTECTED]> wrote:
> Yea, I'm not sure why I used choice as the field name.  I probably
> should of used style.  Anyway, here are all my models
>
> class Size(models.Model):
> name = models.CharField(maxlength=100)
>
> def __str__(self,):
> return self.name
>
> class Admin:
> pass
>
> class Price(models.Model):
> name = models.IntegerField()
>
> def __str__(self,):
> return str(self.name)
>
> class Admin:
> pass
>
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> theslug = models.SlugField(prepopulate_from=('name',))
>
> class Admin:
> search_fields = ['name']
>
> def __str__(self,):
> return self.name
>
> class Choice(models.Model):
> choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> num_in_admin=5)
> size = models.ForeignKey(Size, core=True)
> price = models.ForeignKey(Price, core=True)
>
> def __str__(self,):
> return str(self.choice)
>
> Again my problem is i want to know how to view all the sizes and
> prices for a paticular rug.  In my python shell I do the following.
> I currently have 3 sizes and prices
> associated with style 89b, but I can't seem to figure out how to
> access them.  a.size, a[size], etc
>
> >>> a = Choice.objects.filter(choice=1)
> >>> a
>
> [, , ]
>
> Thanks for any help
>
> On May 22, 11:06 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > What does the model code look like for Size,Price?
>
> > Also,
>
> > choice = models.ForeignKey(Style,
> > edit_inline=models.TABULAR,num_in_admin=5)
>
> > Did you mean for that to be:
>
> > style = models.ForeignKey(Style,
> > edit_inline=models.TABULAR,num_in_admin=5)
>
> > Just curious..as then it would be consistent with the other objects.
>
> > On May 22, 12:43 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > Vance,
> > > Ok...that worked.  However, I have a new problem.  I'm not sure how to
> > > display all the sizes and colors of a particular rug.  In my shell
> > > python I do the following
>
> > > >>> a = Choice.objects.filter(choice=1)
> > > >>> a
>
> > > [, , ]
>
> > > What do I need to type into the shell prompt to get all the sizes and
> > > colors associated with style 89b.  I currently have 3 sizes and colors
> > > associated with style 89b, but I can't seem to figure out how to
> > > access them.  a.size, a[size], etc
>
> > > Here are my model files.
>
> > > class Style(models.Model):
> > > name = models.CharField(maxlength=200)
> > > theslug = models.SlugField(prepopulate_from=('name',))
>
> > > class Admin:
> > > search_fields = ['name']
>
> > > def __str__(self,):
> > > return self.name
>
> > > class Choice(models.Model):
> > > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > > num_in_admin=5)
> > > size = models.ForeignKey(Size, core=True)
> > > price = models.ForeignKey(Price, core=True)
>
> > > def __str__(self,):
> > > return str(self.choice)
>
> > > Thanks
>
> > > On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
>
> > > > My bet would be that this little bit of code right here:
>
> > > > def __str__(self,):
> > > >return self.choice
>
> > > > the return of __str__ needs to be a string not an object.
>
> > > > Vance
>
> > > > On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
> > > > > I am trying to display the table in my Choice table.  However it's
> > > > > error's out everytime I try to see the contents of the table.
>
> > > > > In my python shell prompt I do the following and get the error
>
> > > > > C:\django\mysite>python manage.py shell
> > > > > (InteractiveConsole)
> > > > > >>> from mysite.rugs.models import Choice
> > > > > >>> c = Choice.objects.all()
> > > > > >>> c
> > > > > Traceback (most recent call last):
> > > > >   File "", line 1, in ?
> > > > >   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> > > > > 102, in

Re: Displaying my table data

2007-05-23 Thread [EMAIL PROTECTED]

Ok...then it would be soemthing like this:

choices = Choice.objects.filter(choice=1)
for choice in choices:   # you used filter, not get so I'm assuming
this is not the primary key and you are getting multiple objects back
  a.size.name
  a.price.name


However...if your size/price tables all just contain one field...maybe
you should have a model something like this..where you don't have
separate tables for size/price:

class Style(models.Model):
name = models.CharField(maxlength=200)
theslug = models.SlugField(prepopulate_from=('name',))

class Admin:
search_fields = ['name']

def __str__(self,):
return self.name

class Choice(models.Model):
choice = models.ForeignKey(Style,
edit_inline=models.TABULAR,num_in_admin=5)
size = models.IntegerField(size)
price = models..FloatField(null=True, max_digits=12,
decimal_places=2, blank=True)

def __str__(self,):
return str(self.choice)

On May 23, 1:54 am, Greg <[EMAIL PROTECTED]> wrote:
> Yea, I'm not sure why I used choice as the field name.  I probably
> should of used style.  Anyway, here are all my models
>
> class Size(models.Model):
> name = models.CharField(maxlength=100)
>
> def __str__(self,):
> return self.name
>
> class Admin:
> pass
>
> class Price(models.Model):
> name = models.IntegerField()
>
> def __str__(self,):
> return str(self.name)
>
> class Admin:
> pass
>
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> theslug = models.SlugField(prepopulate_from=('name',))
>
> class Admin:
> search_fields = ['name']
>
> def __str__(self,):
> return self.name
>
> class Choice(models.Model):
> choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> num_in_admin=5)
> size = models.ForeignKey(Size, core=True)
> price = models.ForeignKey(Price, core=True)
>
> def __str__(self,):
> return str(self.choice)
>
> Again my problem is i want to know how to view all the sizes and
> prices for a paticular rug.  In my python shell I do the following.
> I currently have 3 sizes and prices
> associated with style 89b, but I can't seem to figure out how to
> access them.  a.size, a[size], etc
>
> >>> a = Choice.objects.filter(choice=1)
> >>> a
>
> [, , ]
>
> Thanks for any help
>
> On May 22, 11:06 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > What does the model code look like for Size,Price?
>
> > Also,
>
> > choice = models.ForeignKey(Style,
> > edit_inline=models.TABULAR,num_in_admin=5)
>
> > Did you mean for that to be:
>
> > style = models.ForeignKey(Style,
> > edit_inline=models.TABULAR,num_in_admin=5)
>
> > Just curious..as then it would be consistent with the other objects.
>
> > On May 22, 12:43 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > Vance,
> > > Ok...that worked.  However, I have a new problem.  I'm not sure how to
> > > display all the sizes and colors of a particular rug.  In my shell
> > > python I do the following
>
> > > >>> a = Choice.objects.filter(choice=1)
> > > >>> a
>
> > > [, , ]
>
> > > What do I need to type into the shell prompt to get all the sizes and
> > > colors associated with style 89b.  I currently have 3 sizes and colors
> > > associated with style 89b, but I can't seem to figure out how to
> > > access them.  a.size, a[size], etc
>
> > > Here are my model files.
>
> > > class Style(models.Model):
> > > name = models.CharField(maxlength=200)
> > > theslug = models.SlugField(prepopulate_from=('name',))
>
> > > class Admin:
> > > search_fields = ['name']
>
> > > def __str__(self,):
> > > return self.name
>
> > > class Choice(models.Model):
> > > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > > num_in_admin=5)
> > > size = models.ForeignKey(Size, core=True)
> > > price = models.ForeignKey(Price, core=True)
>
> > > def __str__(self,):
> > > return str(self.choice)
>
> > > Thanks
>
> > > On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
>
> > > > My bet would be that this little bit of code right here:
>
> > > > def __str__(self,):
> > > >return self.choice
>
> > > > the return of __str__ needs to be a string not an object.
>
> > > > Vance
>
> > > > On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
> > > > > I am trying to display the table in my Choice table.  However it's
> > > > > error's out everytime I try to see the contents of the table.
>
> > > > > In my python shell prompt I do the following and get the error
>
> > > > > C:\django\mysite>python manage.py shell
> > > > > (InteractiveConsole)
> > > > > >>> from mysite.rugs.models import Choice
> > > > > >>> c = Choice.objects.all()
> > > > > >>> c
> > > > > Traceback (most recent call last):
> > > > >   File "", line 1, in ?
> > > > >   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> > > > > 102, in

Re: Displaying my table data

2007-05-23 Thread [EMAIL PROTECTED]

Ok...then it would be soemthing like this:

choices = Choice.objects.filter(choice=1)
for choice in choices:   # you used filter, not get so I'm assuming
this is not the primary key and you are getting multiple objects back
  a.size.name
  a.price.name


However...if your size/price tables all just contain one field...maybe
you should have a model something like this..where you don't have
separate tables for size/price:

class Style(models.Model):
name = models.CharField(maxlength=200)
theslug = models.SlugField(prepopulate_from=('name',))

class Admin:
search_fields = ['name']

def __str__(self,):
return self.name

class Choice(models.Model):
choice = models.ForeignKey(Style,
edit_inline=models.TABULAR,num_in_admin=5)
size = models.IntegerField(size)
price = models..FloatField(null=True, max_digits=12,
decimal_places=2, blank=True)

def __str__(self,):
return str(self.choice)

On May 23, 1:54 am, Greg <[EMAIL PROTECTED]> wrote:
> Yea, I'm not sure why I used choice as the field name.  I probably
> should of used style.  Anyway, here are all my models
>
> class Size(models.Model):
> name = models.CharField(maxlength=100)
>
> def __str__(self,):
> return self.name
>
> class Admin:
> pass
>
> class Price(models.Model):
> name = models.IntegerField()
>
> def __str__(self,):
> return str(self.name)
>
> class Admin:
> pass
>
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> theslug = models.SlugField(prepopulate_from=('name',))
>
> class Admin:
> search_fields = ['name']
>
> def __str__(self,):
> return self.name
>
> class Choice(models.Model):
> choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> num_in_admin=5)
> size = models.ForeignKey(Size, core=True)
> price = models.ForeignKey(Price, core=True)
>
> def __str__(self,):
> return str(self.choice)
>
> Again my problem is i want to know how to view all the sizes and
> prices for a paticular rug.  In my python shell I do the following.
> I currently have 3 sizes and prices
> associated with style 89b, but I can't seem to figure out how to
> access them.  a.size, a[size], etc
>
> >>> a = Choice.objects.filter(choice=1)
> >>> a
>
> [, , ]
>
> Thanks for any help
>
> On May 22, 11:06 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > What does the model code look like for Size,Price?
>
> > Also,
>
> > choice = models.ForeignKey(Style,
> > edit_inline=models.TABULAR,num_in_admin=5)
>
> > Did you mean for that to be:
>
> > style = models.ForeignKey(Style,
> > edit_inline=models.TABULAR,num_in_admin=5)
>
> > Just curious..as then it would be consistent with the other objects.
>
> > On May 22, 12:43 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > Vance,
> > > Ok...that worked.  However, I have a new problem.  I'm not sure how to
> > > display all the sizes and colors of a particular rug.  In my shell
> > > python I do the following
>
> > > >>> a = Choice.objects.filter(choice=1)
> > > >>> a
>
> > > [, , ]
>
> > > What do I need to type into the shell prompt to get all the sizes and
> > > colors associated with style 89b.  I currently have 3 sizes and colors
> > > associated with style 89b, but I can't seem to figure out how to
> > > access them.  a.size, a[size], etc
>
> > > Here are my model files.
>
> > > class Style(models.Model):
> > > name = models.CharField(maxlength=200)
> > > theslug = models.SlugField(prepopulate_from=('name',))
>
> > > class Admin:
> > > search_fields = ['name']
>
> > > def __str__(self,):
> > > return self.name
>
> > > class Choice(models.Model):
> > > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > > num_in_admin=5)
> > > size = models.ForeignKey(Size, core=True)
> > > price = models.ForeignKey(Price, core=True)
>
> > > def __str__(self,):
> > > return str(self.choice)
>
> > > Thanks
>
> > > On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
>
> > > > My bet would be that this little bit of code right here:
>
> > > > def __str__(self,):
> > > >return self.choice
>
> > > > the return of __str__ needs to be a string not an object.
>
> > > > Vance
>
> > > > On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
> > > > > I am trying to display the table in my Choice table.  However it's
> > > > > error's out everytime I try to see the contents of the table.
>
> > > > > In my python shell prompt I do the following and get the error
>
> > > > > C:\django\mysite>python manage.py shell
> > > > > (InteractiveConsole)
> > > > > >>> from mysite.rugs.models import Choice
> > > > > >>> c = Choice.objects.all()
> > > > > >>> c
> > > > > Traceback (most recent call last):
> > > > >   File "", line 1, in ?
> > > > >   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> > > > > 102, in

newforms + testing

2007-05-23 Thread [EMAIL PROTECTED]

Hello,

I wrote a newforms form, but I have some problems when I want to test
the class.  Here's the definition:

def _users():
print "calling _users()"
return [(u.id, u.get_full_name()) for u in
User.objects.filter(is_active=True)]

class MemoForm(forms.Form):
body = forms.CharField(widget=forms.Textarea, required=True)
recipients = forms.MultipleChoiceField(choices=_users(),
required=True)

This works fine, however when I run my tests, _users() is called at
the very beginning, so the choices in recipients come from my
production database, not from the fixtures I wrote.  Does anyone know
how I could fix this?

Thank you,

Vincent


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Displaying my table data

2007-05-23 Thread [EMAIL PROTECTED]

Ok...then it would be soemthing like this:

choices = Choice.objects.filter(choice=1)
for choice in choices:   # you used filter, not get so I'm assuming
this is not the primary key and you are getting multiple objects back
  a.size.name
  a.price.name


However...if your size/price tables all just contain one field...maybe
you should have a model something like this..where you don't have
separate tables for size/price:

class Style(models.Model):
name = models.CharField(maxlength=200)
theslug = models.SlugField(prepopulate_from=('name',))

class Admin:
search_fields = ['name']

def __str__(self,):
return self.name

class Choice(models.Model):
choice = models.ForeignKey(Style,
edit_inline=models.TABULAR,num_in_admin=5)
size = models.IntegerField(size)
price = models..FloatField(null=True, max_digits=12,
decimal_places=2, blank=True)

def __str__(self,):
return str(self.choice)

On May 23, 1:54 am, Greg <[EMAIL PROTECTED]> wrote:
> Yea, I'm not sure why I used choice as the field name.  I probably
> should of used style.  Anyway, here are all my models
>
> class Size(models.Model):
> name = models.CharField(maxlength=100)
>
> def __str__(self,):
> return self.name
>
> class Admin:
> pass
>
> class Price(models.Model):
> name = models.IntegerField()
>
> def __str__(self,):
> return str(self.name)
>
> class Admin:
> pass
>
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> theslug = models.SlugField(prepopulate_from=('name',))
>
> class Admin:
> search_fields = ['name']
>
> def __str__(self,):
> return self.name
>
> class Choice(models.Model):
> choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> num_in_admin=5)
> size = models.ForeignKey(Size, core=True)
> price = models.ForeignKey(Price, core=True)
>
> def __str__(self,):
> return str(self.choice)
>
> Again my problem is i want to know how to view all the sizes and
> prices for a paticular rug.  In my python shell I do the following.
> I currently have 3 sizes and prices
> associated with style 89b, but I can't seem to figure out how to
> access them.  a.size, a[size], etc
>
> >>> a = Choice.objects.filter(choice=1)
> >>> a
>
> [, , ]
>
> Thanks for any help
>
> On May 22, 11:06 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > What does the model code look like for Size,Price?
>
> > Also,
>
> > choice = models.ForeignKey(Style,
> > edit_inline=models.TABULAR,num_in_admin=5)
>
> > Did you mean for that to be:
>
> > style = models.ForeignKey(Style,
> > edit_inline=models.TABULAR,num_in_admin=5)
>
> > Just curious..as then it would be consistent with the other objects.
>
> > On May 22, 12:43 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > Vance,
> > > Ok...that worked.  However, I have a new problem.  I'm not sure how to
> > > display all the sizes and colors of a particular rug.  In my shell
> > > python I do the following
>
> > > >>> a = Choice.objects.filter(choice=1)
> > > >>> a
>
> > > [, , ]
>
> > > What do I need to type into the shell prompt to get all the sizes and
> > > colors associated with style 89b.  I currently have 3 sizes and colors
> > > associated with style 89b, but I can't seem to figure out how to
> > > access them.  a.size, a[size], etc
>
> > > Here are my model files.
>
> > > class Style(models.Model):
> > > name = models.CharField(maxlength=200)
> > > theslug = models.SlugField(prepopulate_from=('name',))
>
> > > class Admin:
> > > search_fields = ['name']
>
> > > def __str__(self,):
> > > return self.name
>
> > > class Choice(models.Model):
> > > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > > num_in_admin=5)
> > > size = models.ForeignKey(Size, core=True)
> > > price = models.ForeignKey(Price, core=True)
>
> > > def __str__(self,):
> > > return str(self.choice)
>
> > > Thanks
>
> > > On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
>
> > > > My bet would be that this little bit of code right here:
>
> > > > def __str__(self,):
> > > >return self.choice
>
> > > > the return of __str__ needs to be a string not an object.
>
> > > > Vance
>
> > > > On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
> > > > > I am trying to display the table in my Choice table.  However it's
> > > > > error's out everytime I try to see the contents of the table.
>
> > > > > In my python shell prompt I do the following and get the error
>
> > > > > C:\django\mysite>python manage.py shell
> > > > > (InteractiveConsole)
> > > > > >>> from mysite.rugs.models import Choice
> > > > > >>> c = Choice.objects.all()
> > > > > >>> c
> > > > > Traceback (most recent call last):
> > > > >   File "", line 1, in ?
> > > > >   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> > > > > 102, in

How to delete a session

2007-05-23 Thread Ramashish Baranwal

Hi,

How can I delete the session of a request? The docs speak about using
session as a dict and setting and removing specific keys on that, but
I want to remove the session itself, something like del request.session

Any ideas?

Thanks in advance,
Ram


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Where did you put your homepage view?

2007-05-23 Thread David Larlet

Hi,

I'm juste curious, where did you put your homepage view when you've
got a project with a lot of apps? Is there a best practice here?

Thanks,
David

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where did you put your homepage view?

2007-05-23 Thread Julio Nobrega

  On project_name/views.py ?

  Or do you mean the html template? I usually put on the template root
dir, except for my largest project which has a sub-dir named after the
website, where I store site related stuff like TOS, privacy policy...

On 5/23/07, David Larlet <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm juste curious, where did you put your homepage view when you've
> got a project with a lot of apps? Is there a best practice here?
>
> Thanks,
> David
>
> >
>


-- 
Julio Nobrega - http://www.inerciasensorial.com.br

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Query Question ...

2007-05-23 Thread ZebZiggle

Hi all (again),

I'm hoping someone can help me with the syntax for this django
query 

I have three related tables

class User(models.Model):
# stuff ...

class Content(models.Model):
# stuff ...

class Relationship(models.Model):
user = models.ForeignKey(User)
content = models.ForeignKey(Content)
hasRead = models.BooleanField()

I want to get all the Content that the User has NOT read.

The catch:
The Relationship record between the User and the Content may not
exist. It only exists if a piece of content is actually read. If they
haven't, the record doesn't exist.

If I try:

content = Content.objects.filter(relationship_user = user,
relationship__hasRead = False)

I don't get any records. So I try to get crafty:

content = Content.objects.filter( Q(relationship__isnull = False) |
Q(relationship__hasRead = False)).filter(relationship_user = user)

has the same problem.

Looking at the raw SQL you can see the problem:

FROM "content"
INNER JOIN "relationship"
ON "content"."id" = "content__relationship"."content_id"
WHERE
"content__relationship"."id" IS NULL
OR
"content__relationship"."hasRead" = False

--and--

FROM "content"
INNER JOIN ...
WHERE
"content__relationship"."content_id" IS NULL
OR
"relationship"."hasRead" = False


well, I'm sure you see the problem. Perhaps what I need is a subquery,
but I'm not sure.

Can I phrase such a query with the django ORM?

Any suggestions?

Thanks
Sandy


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where did you put your homepage view?

2007-05-23 Thread Greg Donald

On 5/23/07, David Larlet <[EMAIL PROTECTED]> wrote:
> I'm juste curious, where did you put your homepage view when you've
> got a project with a lot of apps? Is there a best practice here?

I usually make a home controller.  Then I typically use an index
action for the home page view.


-- 
Greg Donald
http://destiney.com/

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



Generell Questions on Django

2007-05-23 Thread OliverMarchand

Hi,

I am new to Django (4+years Python experience) and would like to
evaluate for my financial company whether Django may be a good
solution to our problem of designing our applications all a-z from
scratch. Now my colleagues first reaction was very defensive:
a) that's for websites, not serious applications
b) it will be slow, ORMs are always slow
c) those HTML forms are too limiting

I have the feeling that all of the above do have some truth ion them,
but weighed against all of the beneficial factors it seems that a
Django solution would overall be a very good idea.

Now I know that my statements are very generell. I have looked at the
list of sites and some of them are imressive enough to show some of
what I would like to point out. But do you have any quick comments on
these issues?

thanks, Oliver


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Generell Questions on Django

2007-05-23 Thread Atilla

On 23/05/07, OliverMarchand <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I am new to Django (4+years Python experience) and would like to
> evaluate for my financial company whether Django may be a good
> solution to our problem of designing our applications all a-z from
> scratch. Now my colleagues first reaction was very defensive:
> a) that's for websites, not serious applications
> b) it will be slow, ORMs are always slow
> c) those HTML forms are too limiting
>
> I have the feeling that all of the above do have some truth ion them,
> but weighed against all of the beneficial factors it seems that a
> Django solution would overall be a very good idea.
>
> Now I know that my statements are very generell. I have looked at the
> list of sites and some of them are imressive enough to show some of
> what I would like to point out. But do you have any quick comments on
> these issues?
>
> thanks, Oliver

It all depends on what do you want to do. Maybe you can give us some
details - django is good, but it's not good for Everything.

a - I thought websites should be serious applications.

b - That statement is weak, many things are "slow" compared to lower
level implementation, but are a lot better in other ways. With the
hardware that "serious applications" will be running on, "slow" is a
term that does not apply. The amount of requests per second I can get
out of my django-based systems is impressive.

c - noone is forcing you to use them in the way they're defined. You
can make your own, or not use them at all, if you don't need them.

Again, it only depends on what are you trying to write.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Generell Questions on Django

2007-05-23 Thread Jarek Zgoda

OliverMarchand napisał(a):

> a) that's for websites, not serious applications

All web application programming is about websites.

> b) it will be slow, ORMs are always slow

Indeed. Plain nothing beats plain SQL in terms of data access, but it
may be tedious work to actually write these statements by hand. And
Django's ORM is not that bad, if you don't mind fine-tuning your
database objects. And, oh, don't forget to employ some memcache.

> c) those HTML forms are too limiting

True. To get the "feel" of desktop application, one must employ a wide
range of hacks. Including hated-by-all javascript.

> I have the feeling that all of the above do have some truth ion them,
> but weighed against all of the beneficial factors it seems that a
> Django solution would overall be a very good idea.

As always, it depends. If web application fits your needs, Django will
ease the development and make it fun again. But the objections of you
colleagues seems to target web applications in general, not the Django
by itself.

-- 
Jarek Zgoda

"We read Knuth so you don't have to."

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



Re: Generell Questions on Django

2007-05-23 Thread Jacob Kaplan-Moss

Hi Oliver --

http://en.wikipedia.org/wiki/FUD :)

Seriously, though... None of your colleagues' statements display any
actual investigation of their claims; they're all almost completely
wrong.

On 5/23/07, OliverMarchand <[EMAIL PROTECTED]> wrote:
> a) that's for websites, not serious applications

If you can explain the difference between a "website" and a "serious
application" I'll be impressed.  Django's used for external
applications by companies as large as AOL, the Washington Post and
Scripps; it's also used within corporate firewalls by Google, AMD, and
many others.

There's nothing in the tools that dictate how they're used; the level
of "seriousness" only comes from the skills of the developers.

> b) it will be slow, ORMs are always slow

WIthout benchmarks this is a meaningless claim. Yes, there's an
overhead, but I'd it's negligible compared to all the other things a
system under load needs to do. In practice, the bottleneck in a Django
site is the speed of the underlying database (and its IO systems).

Take the time you save not having to write and maintain messy SQL
queries and spend it tuning your database :)

> c) those HTML forms are too limiting

I'm not quite sure how to respond to that... This seems to be an
argument against web applications in general; Django in no way limits
your use of HTML, so if HTML is too limiting for you then stick to
desktop apps.

... but learn how to work around the limitations of HTML. Programmers
who can't develop web apps aren't going to be very employable in the
near future.

Good luck selling Django at your company; I hope my answers help.

Jacob

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



Re: Where did you put your homepage view?

2007-05-23 Thread Kyle Fox

> I usually make a home controller.  Then I typically use an index
> action for the home page view.

This is normally what I do as well, I just define a view called
'index' somewhere and point r'^$' at it.

But this seems like a good place for me to ask a related question I've
often puzzled over: in what module or py file does everyone else place
this view function?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where did you put your homepage view?

2007-05-23 Thread Kyle Fox

> I usually make a home controller.  Then I typically use an index
> action for the home page view.

This is normally what I do as well, I just define a view called
'index' somewhere and point r'^$' at it.

But this seems like a good place for me to ask a related question I've
often puzzled over: in what module or py file does everyone else place
this view function?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where did you put your homepage view?

2007-05-23 Thread Kyle Fox

> I usually make a home controller.  Then I typically use an index
> action for the home page view.

This is normally what I do as well, I just define a view called
'index' somewhere and point r'^$' at it.

But this seems like a good place for me to ask a related question I've
often puzzled over: in what module or py file does everyone else place
this view function?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where did you put your homepage view?

2007-05-23 Thread Kyle Fox

> I usually make a home controller.  Then I typically use an index
> action for the home page view.

This is normally what I do as well, I just define a view called
'index' somewhere and point r'^$' at it.

But this seems like a good place for me to ask a related question I've
often puzzled over: in what module or py file does everyone else place
this view function?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Generell Questions on Django

2007-05-23 Thread Julio Nobrega

On 5/23/07, OliverMarchand <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Now my colleagues first reaction was very defensive:
> a) that's for websites, not serious applications

  My website is a serious application :)

  And so are, for example, the ljworld.com website where Django was
born, or Tabblo, which HP bought.

  On the inside, it's all Python code. When you're doing a Django's
view, you're just manipulating data to display them on the user's
browser. So you're limited to this plataform, to the browser. Some
things can't be done on the browser. Everything else is just
server-side programming, so it's as serious as the programmer's are
serious.

  That said, you might find that Django lacks, let's say, "enterprise"
features, but so does every other web framework. Its objectives are to
make it easier to build stuff on the web. It's a tradeoff. There are
quite a few "web apps" that should never be made using only a web
framework alone. Say, for example, Amazon. You can hardly get more
serious than that. But Amazon would never use a... third party
framework. There's a treshold that you achieve where you have to build
your own stuff, either for infrastructure or competitive reasons.

> b) it will be slow, ORMs are always slow

  ORMs are slower, not slow. Besides, its lack of efficiency compared
to manually written sql queries are nothing compared to gains when you
do proper load balancing of web servers and cache. It's negligeble.
And when doing web apps you'll do caches even if you use ORMs or not.

> c) those HTML forms are too limiting

  True. Compared to what can be done on desktop apps...

  But it seems your colleagues have issues with web applications in
general, not specifically to Django (your form comment led me to think
this). That's a problem that choosing Django or any other web
framework won't ever solve. I would just show them, well, the web.
Google. Yahoo. Amazon. You'll have to change some paradigms on your
application to insert it on this enviroment. But like you said, there
are benefits. It's the damn internet after all :p

  Good luck!

-- 
Julio Nobrega - http://www.inerciasensorial.com.br

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Displaying my table data

2007-05-23 Thread Greg

Carole,
I've tried what you suggeted and it still didn't work.  I haven't
changed my db structure.  Here is what I get when I do it in the
command prompt

>>> from mysite.rugs.models import Choice, Size, Price
>>> c = Choice.objects.filter(choice=1)
>>> c
[, , ]
>>> c.size.name
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'QuerySet' object has no attribute 'size'

I still can't access the size and price's tied to style number 89b.  I
thought that c.size.name would work (guess not),

Thanks for any help





On May 23, 8:24 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Ok...then it would be soemthing like this:
>
> choices = Choice.objects.filter(choice=1)
> for choice in choices:   # you used filter, not get so I'm assuming
> this is not the primary key and you are getting multiple objects back
>   a.size.name
>   a.price.name
>
> However...if your size/price tables all just contain one field...maybe
> you should have a model something like this..where you don't have
> separate tables for size/price:
>
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> theslug = models.SlugField(prepopulate_from=('name',))
>
> class Admin:
> search_fields = ['name']
>
> def __str__(self,):
> return self.name
>
> class Choice(models.Model):
> choice = models.ForeignKey(Style,
> edit_inline=models.TABULAR,num_in_admin=5)
> size = models.IntegerField(size)
> price = models..FloatField(null=True, max_digits=12,
> decimal_places=2, blank=True)
>
> def __str__(self,):
> return str(self.choice)
>
> On May 23, 1:54 am, Greg <[EMAIL PROTECTED]> wrote:
>
>
>
> > Yea, I'm not sure why I used choice as the field name.  I probably
> > should of used style.  Anyway, here are all my models
>
> > class Size(models.Model):
> > name = models.CharField(maxlength=100)
>
> > def __str__(self,):
> > return self.name
>
> > class Admin:
> > pass
>
> > class Price(models.Model):
> > name = models.IntegerField()
>
> > def __str__(self,):
> > return str(self.name)
>
> > class Admin:
> > pass
>
> > class Style(models.Model):
> > name = models.CharField(maxlength=200)
> > theslug = models.SlugField(prepopulate_from=('name',))
>
> > class Admin:
> > search_fields = ['name']
>
> > def __str__(self,):
> > return self.name
>
> > class Choice(models.Model):
> > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > num_in_admin=5)
> > size = models.ForeignKey(Size, core=True)
> > price = models.ForeignKey(Price, core=True)
>
> > def __str__(self,):
> > return str(self.choice)
>
> > Again my problem is i want to know how to view all the sizes and
> > prices for a paticular rug.  In my python shell I do the following.
> > I currently have 3 sizes and prices
> > associated with style 89b, but I can't seem to figure out how to
> > access them.  a.size, a[size], etc
>
> > >>> a = Choice.objects.filter(choice=1)
> > >>> a
>
> > [, , ]
>
> > Thanks for any help
>
> > On May 22, 11:06 pm, "[EMAIL PROTECTED]"
>
> > <[EMAIL PROTECTED]> wrote:
> > > What does the model code look like for Size,Price?
>
> > > Also,
>
> > > choice = models.ForeignKey(Style,
> > > edit_inline=models.TABULAR,num_in_admin=5)
>
> > > Did you mean for that to be:
>
> > > style = models.ForeignKey(Style,
> > > edit_inline=models.TABULAR,num_in_admin=5)
>
> > > Just curious..as then it would be consistent with the other objects.
>
> > > On May 22, 12:43 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > > Vance,
> > > > Ok...that worked.  However, I have a new problem.  I'm not sure how to
> > > > display all the sizes and colors of a particular rug.  In my shell
> > > > python I do the following
>
> > > > >>> a = Choice.objects.filter(choice=1)
> > > > >>> a
>
> > > > [, , ]
>
> > > > What do I need to type into the shell prompt to get all the sizes and
> > > > colors associated with style 89b.  I currently have 3 sizes and colors
> > > > associated with style 89b, but I can't seem to figure out how to
> > > > access them.  a.size, a[size], etc
>
> > > > Here are my model files.
>
> > > > class Style(models.Model):
> > > > name = models.CharField(maxlength=200)
> > > > theslug = models.SlugField(prepopulate_from=('name',))
>
> > > > class Admin:
> > > > search_fields = ['name']
>
> > > > def __str__(self,):
> > > > return self.name
>
> > > > class Choice(models.Model):
> > > > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > > > num_in_admin=5)
> > > > size = models.ForeignKey(Size, core=True)
> > > > price = models.ForeignKey(Price, core=True)
>
> > > > def __str__(self,):
> > > > return str(self.choice)
>
> > > > Thanks
>
> > > > On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
>
> > > > > My bet would be that this

A Few Questions with How to Work With Views

2007-05-23 Thread rockstar_

Hi guys-

  I'm not new to Python, or to web development, but I am new to web
development with python and new to Django.  I've been reading about
Django, and been dabbling with it for about six months.  It's about
time I crap or get off the pot.  And, well, Django has been fun so
far, so I'm gonna crap...  :)

  I've been using Django to design a new iteration of my website, and
replace all the third party software I've been using because either I
can't customize that software, or I'm sure I could write something
much better.  So far, I've created two different apps in my project, a
blog software and a photo manager.  I've got all the logic working,
and I'm really liking how it works.  The only problem is, now I've got
to get into how the templates work.  So here are my questions:

  (1) I'd like to include little snippets from each app on another
app's pages.  For instance, a little "widget" in a sidebar of my blog
software that has some random pictures from the photo management.  Is
there any suggestion on how to do this?
  (2) I'd like to create a global header and footer, which will apply
to all pages, and have in abstracted into their own template files.
That way, if I need to add a new javascript file, or make a change to
a meta tag, I can do that without having to write some mad crazy sed
scripts.
  (3) I'd like to create a tagging app that allows tags for blog posts
and for photos.  I know how the database model for this might look,
and I've read a bit on the many-to-many relationship in Django, but
does anyone have any pointers here?

  I'm excited to actually finish and deploy some Django code!

rockstar_


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms + testing

2007-05-23 Thread [EMAIL PROTECTED]

I fixed my problem, but it's very much a hack.  If anyone has a better
solution, please post it.

My fix was a simple hack: after every instantiation of my MemoForm
class, I called a method "replace_recipients" where I changed the
value of form_object.base_fields['recipients'].choices.  Like I said,
a hack and not a pretty one, but it works.

Vincent.

On May 23, 9:01 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I wrote a newforms form, but I have some problems when I want to test
> the class.  Here's the definition:
>
> def _users():
> print "calling _users()"
> return [(u.id, u.get_full_name()) for u in
> User.objects.filter(is_active=True)]
>
> class MemoForm(forms.Form):
> body = forms.CharField(widget=forms.Textarea, required=True)
> recipients = forms.MultipleChoiceField(choices=_users(),
> required=True)
>
> This works fine, however when I run my tests, _users() is called at
> the very beginning, so the choices in recipients come from my
> production database, not from the fixtures I wrote.  Does anyone know
> how I could fix this?
>
> Thank you,
>
> Vincent


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms + testing

2007-05-23 Thread [EMAIL PROTECTED]

I fixed my problem, but it's very much a hack.  If anyone has a better
solution, please post it.

My fix was a simple hack: after every instantiation of my MemoForm
class, I called a method "replace_recipients" where I changed the
value of form_object.base_fields['recipients'].choices.  Like I said,
a hack and not a pretty one, but it works.

Vincent.

On May 23, 9:01 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I wrote a newforms form, but I have some problems when I want to test
> the class.  Here's the definition:
>
> def _users():
> print "calling _users()"
> return [(u.id, u.get_full_name()) for u in
> User.objects.filter(is_active=True)]
>
> class MemoForm(forms.Form):
> body = forms.CharField(widget=forms.Textarea, required=True)
> recipients = forms.MultipleChoiceField(choices=_users(),
> required=True)
>
> This works fine, however when I run my tests, _users() is called at
> the very beginning, so the choices in recipients come from my
> production database, not from the fixtures I wrote.  Does anyone know
> how I could fix this?
>
> Thank you,
>
> Vincent


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms + testing

2007-05-23 Thread [EMAIL PROTECTED]

I fixed my problem, but it's very much a hack.  If anyone has a better
solution, please post it.

My fix was a simple hack: after every instantiation of my MemoForm
class, I called a method "replace_recipients" where I changed the
value of form_object.base_fields['recipients'].choices.  Like I said,
a hack and not a pretty one, but it works.

Vincent.

On May 23, 9:01 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I wrote a newforms form, but I have some problems when I want to test
> the class.  Here's the definition:
>
> def _users():
> print "calling _users()"
> return [(u.id, u.get_full_name()) for u in
> User.objects.filter(is_active=True)]
>
> class MemoForm(forms.Form):
> body = forms.CharField(widget=forms.Textarea, required=True)
> recipients = forms.MultipleChoiceField(choices=_users(),
> required=True)
>
> This works fine, however when I run my tests, _users() is called at
> the very beginning, so the choices in recipients come from my
> production database, not from the fixtures I wrote.  Does anyone know
> how I could fix this?
>
> Thank you,
>
> Vincent


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms + testing

2007-05-23 Thread [EMAIL PROTECTED]

I fixed my problem, but it's very much a hack.  If anyone has a better
solution, please post it.

My fix was a simple hack: after every instantiation of my MemoForm
class, I called a method "replace_recipients" where I changed the
value of form_object.base_fields['recipients'].choices.  Like I said,
a hack and not a pretty one, but it works.

Vincent.

On May 23, 9:01 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I wrote a newforms form, but I have some problems when I want to test
> the class.  Here's the definition:
>
> def _users():
> print "calling _users()"
> return [(u.id, u.get_full_name()) for u in
> User.objects.filter(is_active=True)]
>
> class MemoForm(forms.Form):
> body = forms.CharField(widget=forms.Textarea, required=True)
> recipients = forms.MultipleChoiceField(choices=_users(),
> required=True)
>
> This works fine, however when I run my tests, _users() is called at
> the very beginning, so the choices in recipients come from my
> production database, not from the fixtures I wrote.  Does anyone know
> how I could fix this?
>
> Thank you,
>
> Vincent


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Explicit SQL not working ...

2007-05-23 Thread ZebZiggle

I'm doing a very simple direct SQL call

cursor = connection.cursor()
cursor.execute(sql)


which works when I issue the SQL directly in the database, but via
django does nothing.

cursor.rowcount returns correctly, but there are no rows to fetch and
the database isn't updated.

Any ideas?

Thx,
S


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "showable" but not "editable" field in the Admin screens

2007-05-23 Thread Atilla

On 23/05/07, Brian Rosner <[EMAIL PROTECTED]> wrote:
>
> You may also want to check out http://code.djangoproject.com/ticket/3990.
>
> On May 22, 5:19 am, "Seiji - technics" <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > Is there a way to show as specific field in the admin screens but
> > without permitting to edit it?
> > I want something similar to "editable=False" option but without
> > excluding the field from the screen.
> >
> > Thanks in advance for the help.
> >
> > Seiji

On that note - the name "editable" is a bit misleading. i expected it
to define the field as read-only, not as completely invisible in
generic forms.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



subclassing of models

2007-05-23 Thread OliverMarchand

Dear Djangos,

Is it possible to subclass a model? This example somehow doesn't work
for in the sense that I only see the geography on the admin screen.


from django.db import models

class Geography(models.Model):
name = models.CharField(maxlength=30)
def __str__(self):
return self.name
class Admin:
pass

class Continent(Geography):
pass

class Country(Geography):
continent = models.ForeignKey(Continent)
---

Any ideas?

greetings, Oliver


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A Few Questions with How to Work With Views

2007-05-23 Thread David Reynolds


On 23 May 2007, at 4:23 pm, rockstar_ wrote:



Hi guys-

  I'm not new to Python, or to web development, but I am new to web
development with python and new to Django.  I've been reading about
Django, and been dabbling with it for about six months.  It's about
time I crap or get off the pot.  And, well, Django has been fun so
far, so I'm gonna crap...  :)

  I've been using Django to design a new iteration of my website, and
replace all the third party software I've been using because either I
can't customize that software, or I'm sure I could write something
much better.  So far, I've created two different apps in my project, a
blog software and a photo manager.  I've got all the logic working,
and I'm really liking how it works.  The only problem is, now I've got
to get into how the templates work.  So here are my questions:

  (1) I'd like to include little snippets from each app on another
app's pages.  For instance, a little "widget" in a sidebar of my blog
software that has some random pictures from the photo management.  Is
there any suggestion on how to do this?


Template Tags!

http://www.djangoproject.com/documentation/templates_python/#writing- 
custom-template-tags



  (2) I'd like to create a global header and footer, which will apply
to all pages, and have in abstracted into their own template files.
That way, if I need to add a new javascript file, or make a change to
a meta tag, I can do that without having to write some mad crazy sed
scripts.


You can do this pretty easily using the {% block thing %}{% endblock  
%} tags. There is also the {% include %} tag, if you need it.


http://www.djangoproject.com/documentation/templates/


  (3) I'd like to create a tagging app that allows tags for blog posts
and for photos.  I know how the database model for this might look,
and I've read a bit on the many-to-many relationship in Django, but
does anyone have any pointers here?


Someone has made a fairly generic tagging application:

http://code.google.com/p/django-tagging/

Hope that helps!

Dave
--
David Reynolds
[EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature


Re: subclassing of models

2007-05-23 Thread Atilla

On 23/05/07, OliverMarchand <[EMAIL PROTECTED]> wrote:
>
> Dear Djangos,
>
> Is it possible to subclass a model? This example somehow doesn't work
> for in the sense that I only see the geography on the admin screen.
>
> 
> from django.db import models
>
> class Geography(models.Model):
> name = models.CharField(maxlength=30)
> def __str__(self):
> return self.name
> class Admin:
> pass
>
> class Continent(Geography):
> pass
>
> class Country(Geography):
> continent = models.ForeignKey(Continent)
> ---
>
> Any ideas?
>
> greetings, Oliver
>

Model Inheritance is, sadly, not supported and the branch that
implements that is stalled (or is it ?).

For now  - one of the ways people prefer to do similar things is to
associate entries in the models, via a relationship. You can search
the mailing list archive for different solutions that people have
tried.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to define unsigned integer primary keys with auto increment for MySQL

2007-05-23 Thread Atilla

On 23/05/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Tue, 2007-05-22 at 06:43 -0700, Fay wrote:
> > I'm using MySQL. The primary key field generated by django uses
> > integer, not unsigned. I'd like to us unsigned integer instead. I can
> > explicitly specify PositiveIntegerField with primary_key option, but
> > that doesn't seem to give me auto increment. Any ideas? Thanks.
>
> Write the necessary SQL to alter the table after it's created and put it
> in the "initial SQL" file for that model. See the model-api docs for
> more information on initial SQL.
>
> Regards,
> Malcolm
>

However, it doesn't make much sense to have signed auto-incremental
keys, does it?

I'd say that unsigned should be the default result, instead of having
to define this yourself. What are the reasons for having them signed
by default ? Database engines with no support for signed/unsigned
columns ?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where did you put your homepage view?

2007-05-23 Thread afarnham

> I'm juste curious, where did you put your homepage view when you've
> got a project with a lot of apps?

I create a django app called "site" and put my index view in there. I
also put any template tags and filters that will be used across the
project in that app.

~Aaron


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A Few Questions with How to Work With Views

2007-05-23 Thread Tim Chase

>> (1) I'd like to include little snippets from each app on
>> another app's pages.  For instance, a little "widget" in a
>> sidebar of my blog software that has some random pictures
>> from the photo management.  Is there any suggestion on how
>> to do this?
> 
> Template Tags!
> 
> http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags

I second David's recommendation.  In particular, I suggest 
skimming down from there to

http://www.djangoproject.com/documentation/templates_python/#inclusion-tags

which makes it fairly easy to separate the presentation (stashed 
in a template, where editing the HTML becomes fairly easy) from 
the data view.

As a side question:
Is there any convention used by the Django overlords for storing 
inclusion-tag templates?  Just toss all the inclusion-tag 
templates in the projname/appname/templates/ with the full page 
templates?  Or cordon them off in a separate sub-directory?  And 
if using a separate sub-directory, is there a preferred naming 
convention (such as "templates/tags/")?  Or shove them in some 
place outside of the projname/appname/templates/ directory?

-tim







--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



need to know to start learn django

2007-05-23 Thread Gigs_

What i need to know, except python before i start learn django?


thank you


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



Re: need to know to start learn django

2007-05-23 Thread Tim Chase

> What i need to know, except python before i start learn django?

*Need* to know?  Nothing more than Python and HTML--even that, 
you might be able to get by with a point-and-drool GUI editor for 
your HTML editing.

However, the more you know about HTML, HTTP, and SQL, the more 
fewer limitations you'll encounter.  And if you have certain 
requirements, you may need additional knowledge (such as 
interfacing with web services might require knowing something 
about XML; using unit tests, it would help to know about the 
python doctest and unittest modules as well as knowing about 
Django's fixtures & JSON).

You can get by without knowing much at all, but to wow the world, 
you might need a little more than just python and Django.

-tim




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do I Sort Years in Template

2007-05-23 Thread Frank Peterson

thanks, I had to use dictsortreversed and that puts them in newest
year first :)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



LIKE '%something%' custom queries

2007-05-23 Thread [EMAIL PROTECTED]

I'm reimplementing an in-database tree system and I'm using custom SQL
queries. I want to use % in LIKE but Django doesn't let me.

The code:
##
def getBranch(table_name, parent_depth, parent_cutLevel, max_depth):
cursor = connection.cursor()
cursor.execute("SELECT *, INSTR(level,'0')-1 AS depth,
INSTR(level,'0')-1 - "+ parent_depth +" AS relativeDepth FROM  " +
table_name + " WHERE level LIKE '"+ parent_cutLevel +"%' AND
INSTR(level,'0')-1 <= ("+ max_depth +"+"+ parent_depth +") ORDER BY
level")
row = cursor.fetchall()
return row
##

The exception:
##
not enough arguments for format string
Exception Location: /usr/lib64/python2.4/site-packages/django/db/
backends/util.py in execute, line 19
##
I can "print" the query string, but can't make the query as cursor
code uses %letters... Is there a solution for this. ( \ doesn't work,
% in variable also)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: Displaying my table data

2007-05-23 Thread Chris Brand

> >>> from mysite.rugs.models import Choice, Size, Price
> >>> c = Choice.objects.filter(choice=1)
> >>> c
> [, , ]

You can see here that your queryset maps to three objects.

> >>> c.size.name
> Traceback (most recent call last):
>   File "", line 1, in ?
> AttributeError: 'QuerySet' object has no attribute 'size'

I'd try to get at just one of those three objects first.
Something like
c[0].size.name
except that you might need to use list(c)[0], I can't remember.

Chris




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



newforms: how to report multiple cross-field validation errors?

2007-05-23 Thread mario

I'm using newforms library and it is really a great improvement over
"oldforms".

However, how would I report more than a single error when doing cross-
field validation in the form clean() method?

I mean, since the errors are reported by raising an exception, on the
first raised validation error the clean() method stops validating.
Thus the user will only see the first error in the form. He has to fix
it and resubmit to see (if any) the next errors.

Is there any workaround for this?

Thanks for any help.


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



Re: How to delete a session

2007-05-23 Thread Joseph Heck

The session is a model in Django - so you can delete it like any other -

x=request.session
x.delete()

There's also the daily_cleanup.py script included with Django that
just goes straight to the database:
http://code.djangoproject.com/browser/django/trunk/django/bin/daily_cleanup.py

-joe

On 5/23/07, Ramashish Baranwal <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> How can I delete the session of a request? The docs speak about using
> session as a dict and setting and removing specific keys on that, but
> I want to remove the session itself, something like del request.session
>
> Any ideas?
>
> Thanks in advance,
> Ram
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: LIKE '%something%' custom queries

2007-05-23 Thread Joseph Heck

Don't put the % inside of " characters, or Python will attempt to
evaluate it out. Alternately, escape it so it doesn't eval. I
generally form up my custom SQL strings outside of the execute()
method to make debugging this kind of thing a tad easier.

-joe

On 5/23/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I'm reimplementing an in-database tree system and I'm using custom SQL
> queries. I want to use % in LIKE but Django doesn't let me.
>
> The code:
> ##
> def getBranch(table_name, parent_depth, parent_cutLevel, max_depth):
> cursor = connection.cursor()
> cursor.execute("SELECT *, INSTR(level,'0')-1 AS depth,
> INSTR(level,'0')-1 - "+ parent_depth +" AS relativeDepth FROM  " +
> table_name + " WHERE level LIKE '"+ parent_cutLevel +"%' AND
> INSTR(level,'0')-1 <= ("+ max_depth +"+"+ parent_depth +") ORDER BY
> level")
> row = cursor.fetchall()
> return row
> ##
>
> The exception:
> ##
> not enough arguments for format string
> Exception Location: /usr/lib64/python2.4/site-packages/django/db/
> backends/util.py in execute, line 19
> ##
> I can "print" the query string, but can't make the query as cursor
> code uses %letters... Is there a solution for this. ( \ doesn't work,
> % in variable also)
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Explicit SQL not working ...

2007-05-23 Thread ZebZiggle

More info ...

I wrote a little program to execute the query directly via psycopg and
it works fine. Even if I take this test code and put it in the running
django code, it continues to work fine.

The SQL is an UPDATE command, like

UPDATE
content
SET
"voteTotal" = "voteTotal" + 1,
"voteCount" = "voteCount" + 1
WHERE
id = 25

It seems like there something about the CursorWrapper or the
DatabaseWrapper that is preventing the execute() from working ...

anyone?

-S


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Explicit SQL not working ...

2007-05-23 Thread ZebZiggle

More info ...

I wrote a little program to execute the query directly via psycopg and
it works fine. Even if I take this test code and put it in the running
django code, it continues to work fine.

The SQL is an UPDATE command, like

UPDATE
content
SET
"voteTotal" = "voteTotal" + 1,
"voteCount" = "voteCount" + 1
WHERE
id = 25

It seems like there something about the CursorWrapper or the
DatabaseWrapper that is preventing the execute() from working ...

anyone?

-S


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: LIKE '%something%' custom queries

2007-05-23 Thread Atilla

On 23/05/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I'm reimplementing an in-database tree system and I'm using custom SQL
> queries. I want to use % in LIKE but Django doesn't let me.
>
> The code:
> ##
> def getBranch(table_name, parent_depth, parent_cutLevel, max_depth):
> cursor = connection.cursor()
> cursor.execute("SELECT *, INSTR(level,'0')-1 AS depth,
> INSTR(level,'0')-1 - "+ parent_depth +" AS relativeDepth FROM  " +
> table_name + " WHERE level LIKE '"+ parent_cutLevel +"%' AND
> INSTR(level,'0')-1 <= ("+ max_depth +"+"+ parent_depth +") ORDER BY
> level")
> row = cursor.fetchall()
> return row
> ##
>
> The exception:
> ##
> not enough arguments for format string
> Exception Location: /usr/lib64/python2.4/site-packages/django/db/
> backends/util.py in execute, line 19
> ##
> I can "print" the query string, but can't make the query as cursor
> code uses %letters... Is there a solution for this. ( \ doesn't work,
> % in variable also)
>

Umm... the "%" symbol has a special meaning in a string, which is to
interpolate it and fill it with arguments from a provided list. In a
cursor it's a variable placeholder used for prepared (or normal)
queries. If you want it literal, you must escape it properly.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Explicit SQL not working ...

2007-05-23 Thread ZebZiggle

More info ...

I wrote a little program to execute the query directly via psycopg and
it works fine. Even if I take this test code and put it in the running
django code, it continues to work fine.

The SQL is an UPDATE command, like

UPDATE
content
SET
"voteTotal" = "voteTotal" + 1,
"voteCount" = "voteCount" + 1
WHERE
id = 25

It seems like there something about the CursorWrapper or the
DatabaseWrapper that is preventing the execute() from working ...

I'm using 0.96 with DATABASE_ENGINE = 'postgresql' backend. Everything
else about django works fine.

anyone?

-S


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Explicit SQL not working ...

2007-05-23 Thread Joseph Heck

When you're done with the command (assuming you're not being explicit
about the transactions), use:

 transaction.commit_unless_managed()

to force the commit.

-joe

On 5/23/07, ZebZiggle <[EMAIL PROTECTED]> wrote:
>
> More info ...
>
> I wrote a little program to execute the query directly via psycopg and
> it works fine. Even if I take this test code and put it in the running
> django code, it continues to work fine.
>
> The SQL is an UPDATE command, like
>
> UPDATE
> content
> SET
> "voteTotal" = "voteTotal" + 1,
> "voteCount" = "voteCount" + 1
> WHERE
> id = 25
>
> It seems like there something about the CursorWrapper or the
> DatabaseWrapper that is preventing the execute() from working ...
>
> I'm using 0.96 with DATABASE_ENGINE = 'postgresql' backend. Everything
> else about django works fine.
>
> anyone?
>
> -S
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: LIKE '%something%' custom queries

2007-05-23 Thread Ivan Sagalaev

[EMAIL PROTECTED] wrote:
> I'm reimplementing an in-database tree system and I'm using custom SQL
> queries. I want to use % in LIKE but Django doesn't let me.
> 
> The code:
> ##
> def getBranch(table_name, parent_depth, parent_cutLevel, max_depth):
>   cursor = connection.cursor()
>   cursor.execute("SELECT *, INSTR(level,'0')-1 AS depth,
> INSTR(level,'0')-1 - "+ parent_depth +" AS relativeDepth FROM  " +
> table_name + " WHERE level LIKE '"+ parent_cutLevel +"%' AND
> INSTR(level,'0')-1 <= ("+ max_depth +"+"+ parent_depth +") ORDER BY
> level")
>   row = cursor.fetchall()
>   return row
> ##

The error says that Python tries to replace '%' with parameters but 
there aren't any. To escape them duplicate them:

 " WHERE level LIKE '"+ parent_cutLevel +"%%' AND ...

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Explicit SQL not working ...

2007-05-23 Thread ZebZiggle

More info ...

I wrote a little program to execute the query directly via psycopg and
it works fine. Even if I take this test code and put it in the running
django code, it continues to work fine.

The SQL is an UPDATE command, like

UPDATE
content
SET
"voteTotal" = "voteTotal" + 1,
"voteCount" = "voteCount" + 1
WHERE
id = 25

It seems like there something about the CursorWrapper or the
DatabaseWrapper that is preventing the execute() from working ...

I'm using 0.96 with DATABASE_ENGINE = 'postgresql' backend. Everything
else about django works fine.

anyone?

-S


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Explicit SQL not working ...

2007-05-23 Thread ZebZiggle

More info ...

I wrote a little program to execute the query directly via psycopg and
it works fine. Even if I take this test code and put it in the running
django code, it continues to work fine.

The SQL is an UPDATE command, like

UPDATE
content
SET
"voteTotal" = "voteTotal" + 1,
"voteCount" = "voteCount" + 1
WHERE
id = 25

It seems like there something about the CursorWrapper or the
DatabaseWrapper that is preventing the execute() from working ...

I'm using 0.96 with DATABASE_ENGINE = 'postgresql' backend. Everything
else about django works fine.

anyone?

-S


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Explicit SQL not working ...

2007-05-23 Thread ZebZiggle

Joseph ... you da man!

Next time your in Halifax, Nova Scotia ... the beer is on me.

I was looking at that method and ignored it since I'm not using
transactions.

THANK YOU!

-Sandy


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



GeoDjango Admin interface - Invalid HEX given!

2007-05-23 Thread mikeyparker

I'm just moving an application that we were writing over to the
GeoDjango branch and I've come across a small problem that I was
hoping that someone may be able to shed a little light on.

I have a model

class CityArea(models.Model, models.GeoMixin):

name = models.CharField(blank=False, maxlength=100, core=True)
city = models.ForeignKey('City')
poly = models.PolygonField(blank=True)

objects = models.GeoManager()

And I can interact with and create instances of this model using the
shell interface:

ca = CityArea(name='Jesmond', city=c, poly='POLYGON(( 10 10, 10 20, 20
20, 20 15, 10 10))')
ca.save()

This works fine. However I am unable to add a new one using the admin
interface. I can however edit those that are already created. So the
above example becomes available in the admin interface and I can
happily use the interfaces functionality to manipulate it. Like I said
the problem only occurs when attempting to create a new instance. When
ever I try this I get the following error:

Request Method: GET
Request URL:http://0.0.0.0:8000/admin/properties/cityarea/add/
Exception Type: GEOSException
Exception Value:Invalid HEX given!
Exception Location: /sw/lib/python2.5/site-packages/django/contrib/gis/
geos/GEOSGeometry.py in __init__, line 143

Any help would be much appreciated. Thanks

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



user object in templates

2007-05-23 Thread John

it seems like I have no user object in my templates, which is weird,
as it comes w/ my request object, and I can access it in my views. In
other words, request.user.is_authenticated evaluates to True in my
views, but to False in my templates.

Before you ask, I do have 'django.core.context_processors.auth' in my
TEMPLATE_CONTENTS_PROCESSORS, and AuthenticationMiddleware and
SessionMiddleware in my MIDDLEWARE_CLASES.

I am running the trunk version of django as of today.

Has the sintax for accessing the user object ( {{ user.foo }} )
changed, or am I missing something really, really silly?

Thanks.


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



NEWBIE: joining two tables problem

2007-05-23 Thread Rogelio

Hello.  Newbie to django and first-time poster to this group.

I've got two models (basic structure shown below):

class Employee(models.Model):
 name = models.CharField(maxlength=50)
 office = models.CharField(maxlength=20)
 phone= models.CharField(maxlength=15)

class Photo(models.Model):
 filename = models.CharField(maxlength=50)
 master_photo = models.BooleanField()
 employee = models.ForeignKey(Employee)

In one of my views I'd like to have a table consisting of rows like:



but if I say:

object_list = Employee.objects.order_by('name')

and pass "object_list" to my listing.html template, it doesn't have
the Photo information.

I've resorted to using straight SQL to build the query:

def employee_view_list(self):
 from django.db import connection
 cursor = connection.cursor()
 cursor.execute("select e.id, e.name, e.office, p.filename
from company_employee e, company_photo p where p.employee_id=e.id and
p.master_photo='T'")
 rows = cursor.fetchall()
 return rows

This sort of works and returns  a list-of-lists, but I can't use the
convention {{employee.name}} in the
template since the returned rows do not include the header
information.

Questions:

1) Is there a better way to join these tables using the django model
methods?
2) Is there an better way to use straight SQL and still be able to use
things like {{employee.name}}
in the templates?
3) I tried making the Photo table have a "many2manyfield" on Employee
rather an
a ForeignKey.  I rebuilt the database using syncdb, but when I tried
to enter photo info
via the admin interface, I got an "operational error".  I could edit
the other database tables
fine.  Ideas?  I tried using the latest stable django and the SVN from
today with the same
result.

Thanks in advance.
Rogelio


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to delete a session

2007-05-23 Thread Ramashish Baranwal

On May 23, 10:18 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote:
> The session is a model in Django - so you can delete it like any other -
>
> x=request.session
> x.delete()
>
> There's also the daily_cleanup.py script included with Django that
> just goes straight to the 
> database:http://code.djangoproject.com/browser/django/trunk/django/bin/daily_c...
>

Thanks Joe, but thats not working. I'm getting the following error-

AttributeError
'SessionWrapper' object has no attribute 'delete'
Exception Type: AttributeError
Exception Value:'SessionWrapper' object has no attribute 'delete'

-Ram


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to delete a session

2007-05-23 Thread Ramashish Baranwal

On May 23, 10:18 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote:
> The session is a model in Django - so you can delete it like any other -
>
> x=request.session
> x.delete()
>
> There's also the daily_cleanup.py script included with Django that
> just goes straight to the 
> database:http://code.djangoproject.com/browser/django/trunk/django/bin/daily_c...
>

Thanks Joe, but thats not working. I'm getting the following error-

AttributeError
'SessionWrapper' object has no attribute 'delete'
Exception Type: AttributeError
Exception Value:'SessionWrapper' object has no attribute 'delete'

-Ram


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to delete a session

2007-05-23 Thread Ramashish Baranwal

On May 23, 10:18 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote:
> The session is a model in Django - so you can delete it like any other -
>
> x=request.session
> x.delete()
>
> There's also the daily_cleanup.py script included with Django that
> just goes straight to the 
> database:http://code.djangoproject.com/browser/django/trunk/django/bin/daily_c...
>

Thanks Joe, but thats not working. I'm getting the following error-

AttributeError
'SessionWrapper' object has no attribute 'delete'
Exception Type: AttributeError
Exception Value:'SessionWrapper' object has no attribute 'delete'

-Ram


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to delete a session

2007-05-23 Thread Ramashish Baranwal

> On May 23, 10:18 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote:
>
> > The session is a model in Django - so you can delete it like any other -
>
> > x=request.session
> > x.delete()
>
> > There's also the daily_cleanup.py script included with Django that
> > just goes straight to the 
> > database:http://code.djangoproject.com/browser/django/trunk/django/bin/daily_c...
>
> Thanks Joe, but thats not working. I'm getting the following error-
>
> AttributeError
> 'SessionWrapper' object has no attribute 'delete'
> Exception Type: AttributeError
> Exception Value:'SessionWrapper' object has no attribute 'delete'

Sorry for the multiple postings. It was due to some network problem at
my end.

-Ram


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NEWBIE: joining two tables problem

2007-05-23 Thread Tim Chase

> Hello.  Newbie to django and first-time poster to this group.

welcome!

  > class Employee(models.Model):
>  name = models.CharField(maxlength=50)
>  office = models.CharField(maxlength=20)
>  phone= models.CharField(maxlength=15)
> 
> class Photo(models.Model):
>  filename = models.CharField(maxlength=50)
>  master_photo = models.BooleanField()
>  employee = models.ForeignKey(Employee)
> 
> In one of my views I'd like to have a table consisting of rows like:
> 
>  td>
> 
> but if I say:
> 
> object_list = Employee.objects.order_by('name')

I think you want something like

   object_list = Photo.objects.select_related().order_by(SORT_FIELD)

and then in your template you want

   {% for photo in object_list %}

 photo.filename
 photo.employee.name
 photo.employee.office

   {% endfor %}

I never remember what the value for SORT_FIELD should be off the 
top of my head...so you'd have to try some combination of your 
app-name, object-name, and field-name, joined by either 
underscores or periods.  My first attempt would be

   SORT_FIELD = 'app_employee.name'

though it might be something like one of these

   SORT_FIELD = 'app_employee__name'
   SORT_FIELD = 'employee.name'
   SORT_FIELD = 'employee__name'

where "app" is the name of the app in your project.

Alternatively, you might be able to do something like

   object_list = Employee.objects.select_related().order_by('name')

and then use

   {% for emp in object_list %}
 {% for photo in emp.photo_set %}
  
   photo.filename
   emp.name
   emp.office
  
 {% endfor %}
   {% endfor %}

or even

   {% for emp in object_list %}
 
  emp.name
  emp.office
  
   
{% for photo in emp.photo_set %}
 photo.filename
{% endfor %}
   
  
 
   {% endfor %}

HTH,

-tim


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: need to know to start learn django

2007-05-23 Thread Christian Markwart Hoeppner

El mié, 23-05-2007 a las 11:46 -0500, Tim Chase escribió:
> > What i need to know, except python before i start learn django?

I went onto my first django-powered project without knowing a bit of
python, django, whatever. Actually, I jumped over mid-project! Python is
amazingly easy to learn, and I had a firm background of web-related
stuff anyways, so the learning path was quite amusing.

Want to learn it quick? Start someting you'd like to have, like a blog
or so. Your own passion for it will keep you learning, doing, and
learning again.

Kind regards,
Chris Hoeppner
www.pixware.org


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RESOLVED: Re: Query Question ...

2007-05-23 Thread ZebZiggle

Took some custom SQL, but this works well:

content = Content.objects \
.filter(approved__isnull = False) \
.extra(where=['id not in (SELECT content_id FROM
relationship WHERE user_id = %d and "hasRead" = TRUE)' % user.id]) \
.order_by('-created')

Phew.

Enjoy,
Sandy


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NEWBIE: joining two tables problem

2007-05-23 Thread Rogelio

Thank you so much!  I was able to get your first method to work.  The
second method
seemed to be complaining that I was using a for-loop on an empty
"photo_set".
I'll play around it some more.

Rogelio


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NEWBIE: joining two tables problem

2007-05-23 Thread Rogelio

Thank you so much!  I was able to get your first method to work.  The
second method
seemed to be complaining that I was using a for-loop on an empty
"photo_set".
I'll play around it some more.

Rogelio


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NEWBIE: joining two tables problem

2007-05-23 Thread Rogelio

Thank you so much!  I was able to get your first method to work.  The
second method
seemed to be complaining that I was using a for-loop on an empty
"photo_set".
I'll play around it some more.

Rogelio


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NEWBIE: joining two tables problem

2007-05-23 Thread Rogelio

On May 23, 3:10 pm, Rogelio <[EMAIL PROTECTED]> wrote:
> Thank you so much!  I was able to get your first method to work.  The
> second method
> seemed to be complaining that I was using a for-loop on an empty
> "photo_set".
> I'll play around it some more.
>
> Rogelio


Sorry for the multiple "thanks" -- on my end I was getting a message
that there
was an error posting the reply and I should try again later -- which I
did several
times.  I guess there was no error after 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where did you put your homepage view?

2007-05-23 Thread Christian Markwart Hoeppner

> I'm juste curious, where did you put your homepage view when you've
> got a project with a lot of apps? Is there a best practice here?

An extra app? Man... Views do not *have* to reside inside some app.
Whenever I have some view not specific to some app, I create a module
for those in the project root. Same with project-specific middleware and
the such.

For example, I have lately gotten a maintenance-middleware solution from
this list, and it's being implemented in a module called "common_views"
that resides in the project folder.

Remember, you can have your code anywhere, as long as it's on the
pythonpath.

Be adventurous. We coders need to be.

Kind regards,
Chris Hoeppner
www.pixware.org


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms + testing

2007-05-23 Thread Doug B

If you put the call to your _users() function in the form __init__() I
think it will be what you are looking for.  initi s called
automatically whenever an instance is created.

class MemoForm(forms.Form):
-snip-
def __init__(self,*args,**kwarg)
super(MemoForm,self).__init__(*args,**kwargs)
self.fields['recipients'].choices = _users()



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms + testing

2007-05-23 Thread Doug B

If you put the call to your _users() function in the form __init__() I
think it will be what you are looking for.  initi s called
automatically whenever an instance is created.

class MemoForm(forms.Form):
-snip-
def __init__(self,*args,**kwarg)
super(MemoForm,self).__init__(*args,**kwargs)
self.fields['recipients'].choices = _users()



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms + testing

2007-05-23 Thread Doug B

If you put the call to your _users() function in the form __init__() I
think it will be what you are looking for.  initi s called
automatically whenever an instance is created.

class MemoForm(forms.Form):
-snip-
def __init__(self,*args,**kwarg)
super(MemoForm,self).__init__(*args,**kwargs)
self.fields['recipients'].choices = _users()



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to delete a session

2007-05-23 Thread Joseph Heck

Ah - right. The middleware returns that all wrapped up. You can use
the _session attribute on it to get down to the actual session object
(I think - at least based on a quick glance through the code).

So (I think)

x=request.session._session
x.delete()

-joe

On 5/23/07, Ramashish Baranwal <[EMAIL PROTECTED]> wrote:
>
> > On May 23, 10:18 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote:
> >
> > > The session is a model in Django - so you can delete it like any other -
> >
> > > x=request.session
> > > x.delete()
> >
> > > There's also the daily_cleanup.py script included with Django that
> > > just goes straight to the 
> > > database:http://code.djangoproject.com/browser/django/trunk/django/bin/daily_c...
> >
> > Thanks Joe, but thats not working. I'm getting the following error-
> >
> > AttributeError
> > 'SessionWrapper' object has no attribute 'delete'
> > Exception Type: AttributeError
> > Exception Value:'SessionWrapper' object has no attribute 'delete'
>
> Sorry for the multiple postings. It was due to some network problem at
> my end.
>
> -Ram
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: {{ perms }} seems to be empty

2007-05-23 Thread Martin J Hsu



> 1. TEMPLATE_CONTEXT_PROCESSORS is not in my settings file. But the docs say 
> that its default is: ("django.core.context_processors.auth", etc...
>
That is correct:
http://www.djangoproject.com/documentation/settings/#template-context-processors

The default isn't explicitly defined in settings.py.  If you really
wanted to be sure it's in there, set it.  For example,

TEMPLATE_CONTEXT_PROCESSORS=
("django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n")

I think it would have been better to have it explicit set in
settings.py.  It would be more clear (as in your case) and easier to
modify (you wouldn't have to go find the documentation and copy/paste
it in).

There is probably a better way to check TEMPLATE_CONTEXT_PROCESSORS,
but setting it will help you eliminate 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: {{ perms }} seems to be empty

2007-05-23 Thread Martin J Hsu



> 1. TEMPLATE_CONTEXT_PROCESSORS is not in my settings file. But the docs say 
> that its default is: ("django.core.context_processors.auth", etc...
>
That is correct:
http://www.djangoproject.com/documentation/settings/#template-context-processors

The default isn't explicitly defined in settings.py.  If you really
wanted to be sure it's in there, set it.  For example,

TEMPLATE_CONTEXT_PROCESSORS=
("django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n")

I think it would have been better to have it explicit set in
settings.py.  It would be more clear (as in your case) and easier to
modify (you wouldn't have to go find the documentation and copy/paste
it in).

There is probably a better way to check TEMPLATE_CONTEXT_PROCESSORS,
but setting it will help you eliminate 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: {{ perms }} seems to be empty

2007-05-23 Thread Martin J Hsu



> 1. TEMPLATE_CONTEXT_PROCESSORS is not in my settings file. But the docs say 
> that its default is: ("django.core.context_processors.auth", etc...
>
That is correct:
http://www.djangoproject.com/documentation/settings/#template-context-processors

The default isn't explicitly defined in settings.py.  If you really
wanted to be sure it's in there, set it.  For example,

TEMPLATE_CONTEXT_PROCESSORS=
("django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n")

I think it would have been better to have it explicit set in
settings.py.  It would be more clear (as in your case) and easier to
modify (you wouldn't have to go find the documentation and copy/paste
it in).

There is probably a better way to check TEMPLATE_CONTEXT_PROCESSORS,
but setting it will help you eliminate 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: {{ perms }} seems to be empty

2007-05-23 Thread Jeremy Dunck

On 5/23/07, Aidas Bendoraitis <[EMAIL PROTECTED]> wrote:
>
> Is "django.core.context_processors.auth" set in your
> TEMPLATE_CONTEXT_PROCESSORS? Are those new custom

You must also render the template using RequestContext rather than
Context in order for TEMPLATE_CONTEXT_PROCESSORS to be run.

How is 'request' getting into your template context?

Show us the view. :)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Displaying data in the admin using list_display

2007-05-23 Thread Greg

I'm having a problem displaying data in my admin using list_display.
I want to be able to show the Manufacturer in the admin from my styles
page.  Here are my models:

class Manufacturer(models.Model):
name = models.CharField(maxlength=200)
manufacturerslug = models.SlugField(prepopulate_from=["name"])
description = models.TextField(maxlength=1000)

def __str__(self,):
return self.name

class Admin:
pass

class Collection(models.Model):
name = models.CharField(maxlength=200)
collectionslug = models.SlugField(prepopulate_from=["name"])
description = models.TextField(maxlength=1000)
manufacturer = models.ForeignKey(Manufacturer)

def __str__(self,):
return self.name

class Admin:
pass


class Style(models.Model):
name = models.CharField(maxlength=200)
theslug = models.SlugField(prepopulate_from=('name',))
collection = models.ForeignKey(Collection)


class Admin:
search_fields = ['name']
list_display = ('name', 'theslug','collection',
'collection.manufacturer')


def __str__(self,):
return self.name



When I view my style table in the admin I want to be able to display
the manufacturer.  However, I don't have a manufacturer field in the
Style table.  All I have is a foreign key to collection, which
contains a foreignkey to manufacturer.  I have no problem displaying
the collection that the style is associated with.  I want to be able
to show the manufacturer of the style in the admin.

I currently do "list_display = ('name', 'theslug', 'collection',
'collection.manufacturer')" However it errors when
'collection.manufacurer'.  Is it possible for me to show the
Manufacturer of the style in the admin?

Thanks for any help.


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



Re: newforms + testing

2007-05-23 Thread Malcolm Tredinnick

On Wed, 2007-05-23 at 06:01 -0700, [EMAIL PROTECTED] wrote:
> Hello,
> 
> I wrote a newforms form, but I have some problems when I want to test
> the class.  Here's the definition:
> 
> def _users():
> print "calling _users()"
> return [(u.id, u.get_full_name()) for u in
> User.objects.filter(is_active=True)]
> 
> class MemoForm(forms.Form):
> body = forms.CharField(widget=forms.Textarea, required=True)
> recipients = forms.MultipleChoiceField(choices=_users(),
> required=True)
> 
> This works fine, however when I run my tests, _users() is called at
> the very beginning, 

The reason this is happening is because the "recipients" line of code,
including the function call to _users() is executed at *import* time, so
very early in the game.

You could replace choices=_users() with "choices=_users" and change the
_users() function to be an iterable. That will mean it is evaluated the
first time you need the choices (so, as late as possible). It will only
be evaluated once, though, so you can't use this to make the choices act
like a ForeignKey (updated every time you use it).

See
http://www.pointy-stick.com/blog/2007/03/26/django-tips-variable-choice-lists/ 
for a reasonably detailed example.

Regards,
Malcolm



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



Re: subclassing of models

2007-05-23 Thread Malcolm Tredinnick

On Wed, 2007-05-23 at 17:49 +0200, Atilla wrote:
> On 23/05/07, OliverMarchand <[EMAIL PROTECTED]> wrote:
> >
> > Dear Djangos,
> >
> > Is it possible to subclass a model? This example somehow doesn't work
> > for in the sense that I only see the geography on the admin screen.
> >
> > 
> > from django.db import models
> >
> > class Geography(models.Model):
> > name = models.CharField(maxlength=30)
> > def __str__(self):
> > return self.name
> > class Admin:
> > pass
> >
> > class Continent(Geography):
> > pass
> >
> > class Country(Geography):
> > continent = models.ForeignKey(Continent)
> > ---
> >
> > Any ideas?
> >
> > greetings, Oliver
> >
> 
> Model Inheritance is, sadly, not supported and the branch that
> implements that is stalled (or is it ?).


Given that there is no branch, that statement is incorrect.

Model inheritance is two stations down the line. Unicode gets finished
first, then query refactor then model inheritance.

Regards,
Malcolm



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



Re: newforms: how to report multiple cross-field validation errors?

2007-05-23 Thread Malcolm Tredinnick

On Wed, 2007-05-23 at 10:16 -0700, mario wrote:
> I'm using newforms library and it is really a great improvement over
> "oldforms".
> 
> However, how would I report more than a single error when doing cross-
> field validation in the form clean() method?
> 
> I mean, since the errors are reported by raising an exception, on the
> first raised validation error the clean() method stops validating.
> Thus the user will only see the first error in the form. He has to fix
> it and resubmit to see (if any) the next errors.

Your form-level clean method should run through all of its validation,
collecting the errors as it goes and then raise a ValidationError. Note
that ValidationError can take a list of error messages in its
constructor, so just collect all your errors into a list and pass them
all at once to a single ValidationError raiser.

Regards,
Malcolm



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



Re: Displaying data in the admin using list_display

2007-05-23 Thread Malcolm Tredinnick

On Wed, 2007-05-23 at 14:33 -0700, Greg wrote:
> I'm having a problem displaying data in my admin using list_display.
> I want to be able to show the Manufacturer in the admin from my styles
> page.  Here are my models:
> 
> class Manufacturer(models.Model):
>   name = models.CharField(maxlength=200)
>   manufacturerslug = models.SlugField(prepopulate_from=["name"])
>   description = models.TextField(maxlength=1000)
> 
> def __str__(self,):
>   return self.name
> 
>   class Admin:
>   pass
> 
> class Collection(models.Model):
>   name = models.CharField(maxlength=200)
>   collectionslug = models.SlugField(prepopulate_from=["name"])
>   description = models.TextField(maxlength=1000)
>   manufacturer = models.ForeignKey(Manufacturer)
> 
>   def __str__(self,):
>   return self.name
> 
>   class Admin:
>   pass
> 
> 
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> theslug = models.SlugField(prepopulate_from=('name',))
> collection = models.ForeignKey(Collection)
> 
> 
> class Admin:
>   search_fields = ['name']
>   list_display = ('name', 'theslug','collection',
> 'collection.manufacturer')
> 
> 
> def __str__(self,):
>   return self.name
> 
> 
> 
> When I view my style table in the admin I want to be able to display
> the manufacturer.  However, I don't have a manufacturer field in the
> Style table.  All I have is a foreign key to collection, which
> contains a foreignkey to manufacturer.  I have no problem displaying
> the collection that the style is associated with.  I want to be able
> to show the manufacturer of the style in the admin.
> 
> I currently do "list_display = ('name', 'theslug', 'collection',
> 'collection.manufacturer')" However it errors when
> 'collection.manufacurer'.  Is it possible for me to show the
> Manufacturer of the style in the admin?

Doing list_display lookups across models like this doesn't work, as
you've discovered. One day we might even fix that, because it's about a
four line change to fix.

For the time being, the simplest solution is to create a method that
returns collection.manufacturer and use that method name in the
list_display list. You can even make this field sortable using the
admin_order_field attribute on the function (search the model-api docs
for more information), I suspect.

Regards,
Malcolm



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



Re: How to define unsigned integer primary keys with auto increment for MySQL

2007-05-23 Thread Malcolm Tredinnick

On Wed, 2007-05-23 at 17:52 +0200, Atilla wrote:
> On 23/05/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> >
> > On Tue, 2007-05-22 at 06:43 -0700, Fay wrote:
> > > I'm using MySQL. The primary key field generated by django uses
> > > integer, not unsigned. I'd like to us unsigned integer instead. I can
> > > explicitly specify PositiveIntegerField with primary_key option, but
> > > that doesn't seem to give me auto increment. Any ideas? Thanks.
> >
> > Write the necessary SQL to alter the table after it's created and put it
> > in the "initial SQL" file for that model. See the model-api docs for
> > more information on initial SQL.
> >
> > Regards,
> > Malcolm
> >
> 
> However, it doesn't make much sense to have signed auto-incremental
> keys, does it?
> 
> I'd say that unsigned should be the default result, instead of having
> to define this yourself. What are the reasons for having them signed
> by default ? Database engines with no support for signed/unsigned
> columns ?

No bigs reason, but it doesn't hurt and it isn't worth changing now. If
the difference between unsigned and signed is a showstopper for a
particular project, then the extra factor of two doesn't really buy you
much safety anyway. You might as well switch to some kind of really huge
field.

One advantage of this setup is that you could manually set the primary
key values yourself and providing you stuck to negative values, there
would be no chance of a clash.

Regards,
Malcolm



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



Re: subclassing of models

2007-05-23 Thread Atilla

> Given that there is no branch, that statement is incorrect.
>
> Model inheritance is two stations down the line. Unicode gets finished
> first, then query refactor then model inheritance.
>
> Regards,
> Malcolm


Well, I'm certainly  glad to know this. I hadn't checked up on it for
a long time. I'll do my research  better next time.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to delete a session

2007-05-23 Thread urielka

just do this:
from django.contrib.sessions.models import Session

Session.objects.filter(session_key=request.session.session_key).delete()

On May 23, 3:26 pm, Ramashish Baranwal <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> How can I delete the session of a request? The docs speak about using
> session as a dict and setting and removing specific keys on that, but
> I want to remove the session itself, something like del request.session
>
> Any ideas?
>
> Thanks in advance,
> Ram


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Inconsistent SQL generated for ForeignKey fields

2007-05-23 Thread Fay

Hi,


I encountered a situation that foreign key constraints were generated
differently for the same data model.

Below is my test model that has 2 identical sets of 1-to-many tables.
When I run django sqlall command, however the foreign key constraints
were built differently, one used column constraint while the other
used table constraint. It seems the table names contribute to this
behavior. Although they function very similarly, I wonder why that
happened.


from django.db import models

class a1(models.Model):
a1c1 = models.CharField(maxlength=200)

class a2(models.Model):
a2c1 = models.ForeignKey(a1)
a2c2 = models.CharField(maxlength=200, core=True)

class x1(models.Model):
x1c1 = models.CharField(maxlength=200)

class x2(models.Model):
x2c1 = models.ForeignKey(x1)
x2c2 = models.CharField(maxlength=200, core=True)


Results from sqlall command:


BEGIN;
CREATE TABLE `test_a1` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`a1c1` varchar(200) NOT NULL
);
CREATE TABLE `test_x2` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`x2c1_id` integer NOT NULL,
`x2c2` varchar(200) NOT NULL
);
CREATE TABLE `test_x1` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`x1c1` varchar(200) NOT NULL
);
ALTER TABLE `test_x2` ADD CONSTRAINT x2c1_id_refs_id_11de27b2 FOREIGN
KEY (`x2c1_id`) REFERENCES `test_x1` (`id`);
CREATE TABLE `test_a2` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`a2c1_id` integer NOT NULL REFERENCES `test_a1` (`id`),
`a2c2` varchar(200) NOT NULL
);
CREATE INDEX `test_x2_x2c1_id` ON `test_x2` (`x2c1_id`);
CREATE INDEX `test_a2_a2c1_id` ON `test_a2` (`a2c1_id`);
COMMIT;


Thanks.


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



Re: Inconsistent SQL generated for ForeignKey fields

2007-05-23 Thread Fay

Forgot to mention, I use MySQL 5.1.



On May 23, 4:29 pm, Fay <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I encountered a situation that foreign key constraints were generated
> differently for the same data model.
>
> Below is my test model that has 2 identical sets of 1-to-many tables.
> When I run django sqlall command, however the foreign key constraints
> were built differently, one used column constraint while the other
> used table constraint. It seems the table names contribute to this
> behavior. Although they function very similarly, I wonder why that
> happened.
>
> from django.db import models
>
> class a1(models.Model):
> a1c1 = models.CharField(maxlength=200)
>
> class a2(models.Model):
> a2c1 = models.ForeignKey(a1)
> a2c2 = models.CharField(maxlength=200, core=True)
>
> class x1(models.Model):
> x1c1 = models.CharField(maxlength=200)
>
> class x2(models.Model):
> x2c1 = models.ForeignKey(x1)
> x2c2 = models.CharField(maxlength=200, core=True)
>
> Results from sqlall command:
>
> BEGIN;
> CREATE TABLE `test_a1` (
> `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
> `a1c1` varchar(200) NOT NULL
> );
> CREATE TABLE `test_x2` (
> `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
> `x2c1_id` integer NOT NULL,
> `x2c2` varchar(200) NOT NULL
> );
> CREATE TABLE `test_x1` (
> `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
> `x1c1` varchar(200) NOT NULL
> );
> ALTER TABLE `test_x2` ADD CONSTRAINT x2c1_id_refs_id_11de27b2 FOREIGN
> KEY (`x2c1_id`) REFERENCES `test_x1` (`id`);
> CREATE TABLE `test_a2` (
> `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
> `a2c1_id` integer NOT NULL REFERENCES `test_a1` (`id`),
> `a2c2` varchar(200) NOT NULL
> );
> CREATE INDEX `test_x2_x2c1_id` ON `test_x2` (`x2c1_id`);
> CREATE INDEX `test_a2_a2c1_id` ON `test_a2` (`a2c1_id`);
> COMMIT;
>
> Thanks.


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



Best Place To Start Learning Django/Python

2007-05-23 Thread Peter Pluta


I don't really have any programming experience outside of hacking up a few
lines of php, but it'd like to start learning python and the django web
framework. I haven't been able to find too many intuitive guides like those
for php, so i'd thought i'd ask here. Does anyone have any good suggestions?




-- 
View this message in context: 
http://www.nabble.com/Best-Place-To-Start-Learning-Django-Python-tf3806250.html#a10771766
Sent from the django-users mailing list archive at Nabble.com.


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



Re: Best Place To Start Learning Django/Python

2007-05-23 Thread Tyson Tate

Learning a bit of Python first helps. I'd start with the official  
Python tutorial:



Then give the official Django tutorial a shot:



Other than that, there's no better way to get started than by getting  
down and dirty and hacking through your own projects.

Regards,
Tyson

On May 23, 2007, at 1:07 PM, Peter Pluta wrote:

> I don't really have any programming experience outside of hacking  
> up a few
> lines of php, but it'd like to start learning python and the django  
> web
> framework. I haven't been able to find too many intuitive guides  
> like those
> for php, so i'd thought i'd ask here. Does anyone have any good  
> suggestions?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >