Problem with pyExcelerator and response

2008-10-28 Thread laspal

Hi,
I am trying to create Excel file using pyExcelerator but my problem is
I am not able
to attach file to response.

code :
workbook = Workbook()
worksheet = workbook.add_sheet('My Test Sheet')

worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
worksheet.write(1,1, 'Hello World!', font_style('left', 1,
'black'))
worksheet.write(1,0, 'Hello World!', font_style('left', 1, 'red'))

response = HttpResponse( mimetype='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment;
filename=output.xls'
workbook.save('output.xls')

   return response.

I am able to generate output.xl file but without any data.
Can anyone help me out
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: 500 displayed instead of 404

2008-10-28 Thread Karen Tracey
On Tue, Oct 28, 2008 at 4:08 PM, janedenone <[EMAIL PROTECTED]>wrote:

>
> Hi Karen,
>
> I did that, but the message was never sent to me.
>

That's the first problem I'd be working on fixing, then.  Long term you are
likely to want that mechanism working, you've got a problem to solve right
now for which it would be useful -- I'd be figuring out what's wrong with
the settings that is causing the error email to go astray.


> Anyway, when I create a new project with a single app, containing
> nothing but a single view which raises a Http404, along with a
> urlpattern which refers to that view – the 500 template is still
> displayed when I request the URL.
>
> This must be easily reproducible on any machine using the following
> code:
>
> # urls.py:
> urlpatterns = patterns('myproject.myapp.views',
>   (r'^test/$', 'test'),
> )
>
> # views.py:
> def test(request):
>raise Http404
>

Well yes if that is all you have in views.py then you'll get a 500 error
because Http404 has not been imported.  But for the DEBUG=True case you'd
also be seeing a debug page that starts with:

NameError at /test/

and goes on to complain that "global name 'Http404' is not defined" instead
of:

Page not found (404)

and that doesn't match what you said earlier so I'm unsure if you skipped
over some details in reporting the code for your minimal example or what it
is you see when you have DEBUG set to True.

I assure you, if I insert "raise Http404" into the beginning of one of my
views, I get my customized 404 template, not a 500 error.  Whatever is going
on is something specific to your code (or 400.html template), not something
fundamentally broken in Django when Http404 is raised with DEBUG set to
False.

Karen

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



Re: What does FieldFile._required_file() do?

2008-10-28 Thread varikin



On Oct 28, 10:05 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On Tue, Oct 28, 2008 at 10:31 PM, varikin <[EMAIL PROTECTED]> wrote:
> > try:
> >     object.photo._require_file()
> > except ValueError:
> >      #handle exception
>
> Wow, I never expected anybody to do something like that. :(
>
> > But I just don't know what this does or is suppose to. The way I read
> > it, if self is None, raise ValueError() which calls self.field.name
> > which would be invalid since self is None. Also, since calling this
> > method is done through a FieldFile object (or ImageFieldFile in this
> > case), it can't be None.
>
> Well, it can't be None, but it doesn't necessarily have a valid value.
> "if not self" doesn't actually check to see if it's None, but rather
> checks to see if the filename is blank. This can happen if you have a
> FileField that hasn't yet gotten a file attached to it, such a field
> with blank=True that never got a file in the admin or a new model
> instance created in a view that hasn't attached a file.
>
> The leading underscore means that it's meant to be a private method.
> It's there as a way to make Django's internal code simpler, so we
> didn't have to keep copying that ValueError message in a bunch of
> methods that all require a filename before they can proceed. That code
> you see is somebody checking to see if the field has a file attached
> to it or not. That's not really the best way to go about it though;
> this would be better:
>
> if not self:
>     # handle "exception"
>
> -Gul

I never knew you could do that and it really threw me. Thanks for the
explanation. At least now that I understand it, I can change it to "if
not self" since I have to update the file handling in this app.

Thanks,
John
--~--~-~--~~~---~--~~
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 Apps

2008-10-28 Thread Mike Hart

Eldon, maybe we could get together and set up some basic structures
for what we want to accomplish. Let me know.
--~--~-~--~~~---~--~~
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: template system file extensions

2008-10-28 Thread Malcolm Tredinnick


On Tue, 2008-10-28 at 15:52 -0700, IMTheNachoMan wrote:
> I have a thought for improvement. Currently the template files use
> a .html extension for template files.

That's not correct. Template files can have any extension you like.
Django deliberately does not use the file extension to mean anything.


>  While this system works I think
> it could be improved.
> 
> Having a file as .html implies it is an HTML file. The template files
> are not complete HTML therefore not valid HTML files, in my opinion.
> 
> Like from an IDE or editors perspective. If an IDE/editor opens
> a .html file it has no way of knowing it is a template verses a true
> HTML file.

An editor that uses file extensions as the sole means to determine the
file type has a bug. There are many file types that incorporate data
from multiple formats and tools have to be able to handle that. It's
really a solved problem. Django's templates are just one example: they
will often include both Django template directives and HTML code (and
also Javascript and CSS code, which are common in files with .html
extensions).

>  A user can quickly look at the contents and know. An editor
> could look at all the code and look for certain words like {% blah %}
> but that's in-efficient.

Claims of inefficiency are invariably subjective. Yes, it's more work
than zero, but that's also just a strawman. The point is whether the
amount of work required is noticeable or wasteful. And in the case of
filetype detection, the answer is "no". It's the normal way to do file
type detection: look at the first X number of bytes (X can be small, but
can be as large as the whole file, since files aren't really that big
and computers are very fast). Your OS does this all the time and you
never notice.

A very good way to detect Django template files for example is to check
for "{% block %}" or "{% extends %}". I know of a couple of different
editors that use that. Often combining it with their normal detection
for HTML or Javascript so that they can use both groups of syntax
highlighting and code completion at once.

If don't want to use .html as the extension for you predominantly
HTML-including tempaltes, you don't have to. The same as you don't need
to use .txt for your text-based templates and so on. Django leaves it
entirely up to you. But please let's not wheel out the old "editors only
use file extensions" red-herring. Tool writers (at least outside of
Microsoft) have known for years that that is both unreliable and
insecure.

Best wishes,
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: What does FieldFile._required_file() do?

2008-10-28 Thread Marty Alchin

On Tue, Oct 28, 2008 at 10:31 PM, varikin <[EMAIL PROTECTED]> wrote:
> try:
> object.photo._require_file()
> except ValueError:
>  #handle exception

Wow, I never expected anybody to do something like that. :(

> But I just don't know what this does or is suppose to. The way I read
> it, if self is None, raise ValueError() which calls self.field.name
> which would be invalid since self is None. Also, since calling this
> method is done through a FieldFile object (or ImageFieldFile in this
> case), it can't be None.

Well, it can't be None, but it doesn't necessarily have a valid value.
"if not self" doesn't actually check to see if it's None, but rather
checks to see if the filename is blank. This can happen if you have a
FileField that hasn't yet gotten a file attached to it, such a field
with blank=True that never got a file in the admin or a new model
instance created in a view that hasn't attached a file.

The leading underscore means that it's meant to be a private method.
It's there as a way to make Django's internal code simpler, so we
didn't have to keep copying that ValueError message in a bunch of
methods that all require a filename before they can proceed. That code
you see is somebody checking to see if the field has a file attached
to it or not. That's not really the best way to go about it though;
this would be better:

if not self:
# handle "exception"

-Gul

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



template system file extensions

2008-10-28 Thread IMTheNachoMan

I have a thought for improvement. Currently the template files use
a .html extension for template files. While this system works I think
it could be improved.

Having a file as .html implies it is an HTML file. The template files
are not complete HTML therefore not valid HTML files, in my opinion.

Like from an IDE or editors perspective. If an IDE/editor opens
a .html file it has no way of knowing it is a template verses a true
HTML file. A user can quickly look at the contents and know. An editor
could look at all the code and look for certain words like {% blah %}
but that's in-efficient.

It would make more sense if django template files had a different
extension like maybe .dtf for django template file.

I don't know how the django template system works on the backend. Like
if it sends a complete HTML file or just the HTML text but if it used
a template file it could either dynamically generate a .html file or
just send the generated html. However it would work

Just a thought.

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



What does FieldFile._required_file() do?

2008-10-28 Thread varikin

I was looking at someone else's code and saw the following code:

try:
 object.photo._require_file()
except ValueError:
  #handle exception

Where object is a model instance and photo is an ImageField attribute.
Can someone tell me what _require_file() does?

Here is the definition of it in django/db/models/fields/files.py
class FieldFile(File):
   def _require_file(self):
if not self:
raise ValueError("The '%s' attribute has no file
associated with it." % self.field.name)

But I just don't know what this does or is suppose to. The way I read
it, if self is None, raise ValueError() which calls self.field.name
which would be invalid since self is None. Also, since calling this
method is done through a FieldFile object (or ImageFieldFile in this
case), it can't be None.

I am sure I am missing some strange tricky bit of Python classes and
objects, but I can't find anything on this.

Thanks,
John
--~--~-~--~~~---~--~~
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: looping to create an array of category breadcrumbs

2008-10-28 Thread coderb

sorry, had not finished this post before accidently submitting it...

for myslug not null
catcrumb_list = Category.objects.filter(slug=myslug)
myslug = catcrumb_list.parent

basically, I want to loop through the category model a parent is not
found, and each pass, store the model tupel in catcrumblist.

I tried catcrumb_list.append, but returns read-only error on 'list'

any help would be apprec-ated.

thank you




On Oct 29, 2:06 am, coderb <[EMAIL PROTECTED]> wrote:
> hi all,
>
> am having trouble finding the syntax to build an array that contains
> the full hierarchy of the current category.
>
> so the slug of the current category is passed to the method  from the
> URL request data.
>
> for myslug not null
> catcrumb_list = Category.objects.filter(slug=myslug)
>
> catcrumb_list.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



looping to create an array of category breadcrumbs

2008-10-28 Thread coderb

hi all,

am having trouble finding the syntax to build an array that contains
the full hierarchy of the current category.

so the slug of the current category is passed to the method  from the
URL request data.

for myslug not null
catcrumb_list = Category.objects.filter(slug=myslug)

catcrumb_list.

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



Re: case insensitive search

2008-10-28 Thread DULMANDAKH Sukhbaatar
> "(A bug: SQLite only understands upper/lower case for 7-bit Latin
> characters. Hence the LIKE operator is case sensitive for 8-bit iso8859
> characters or UTF-8 characters. For example, the expression 'a' LIKE 'A' is
> TRUE but 'æ' LIKE 'Æ' is FALSE.)."

Got it.

> So it sounds like you will need to move to a different DB if you want
> case-insensitive searching to work for Cyrillic chars.

also sqlite3 seemed very slow compared to MySQL. then I'll switch to
mysql. thank you.


-- 
Regards
Dulmandakh

--~--~-~--~~~---~--~~
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: Admin page customization for a single model

2008-10-28 Thread Fabio Natali

Daniel Roseman wrote:
> > [0]http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs...
[...]
> Read the two paragraphs above the one you linked to. Which directory
> you put your overridden template determines what gets overridden - all
> models, all models in one app, or one model.

No... it was so easy! I can't believe it! :-)

Thank you very much Daniel.

> DR.

Fabio.

-- 
Fabio Natali

--~--~-~--~~~---~--~~
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: Admin page customization for a single model

2008-10-28 Thread Daniel Roseman

On Oct 28, 9:34 pm, Fabio Natali <[EMAIL PROTECTED]> wrote:
> Hi everybody!
>
> I need to add a link to the admin page of one of my models. [0]
> provides a step-by-step explanation on how to get this.
>
> The point is that, contrarily to the docs statement, that procedure
> will modify the "change list admin page" of all of my models, while I
> need to change it for just one of them.
>
> Any tips about this?
>
> Are the docs wrong when they say "To continue the example above, we
> want to add a new link next to the History tool for the Page model."
> and then the change affects every model? Or, as it probably is, am I
> just missing something?
>
> All the best to all of you, Fabio.
>
> [0]http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs...
>
> --
> Fabio Natali

Read the two paragraphs above the one you linked to. Which directory
you put your overridden template determines what gets overridden - all
models, all models in one app, or one model.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django along with PHP - avoiding Apache crashes

2008-10-28 Thread Graham Dumpleton



On Oct 28, 11:58 pm, Giles Thomas <[EMAIL PROTECTED]>
wrote:
> Graham,
>
> Thank you again for the help - as you might have guessed, my separate
> question that you answered on themod_wsgilist was because I'd decided
> to try out the WSGI solution to the problem first.
>
> What's very strange is that although I did get the same crash when I
> first tried running up Apache + PHP  +mod_wsgias I had with mod_python
> - as you would expect - it now works fine!  I *think* that the change
> that fixed it was when I ran apt-get remove libapache2-mod-python - but
> I'm not quite sure why that worked.

If mod_python or mod_wsgi is compiled against Python static libraries,
then using them together can causes crashes. See:

  http://code.google.com/p/modwsgi/wiki/InstallationIssues

Thus, one you uninstalled mod_python and did a full stop and start of
Apache, problem would go away.

> So I'm now in the uncomfortable position of having a server that works
> perfectly well, when I'm pretty sure that it should not.  One
> possibility: I'm using PHP5, and although the Django page [1] just says
> that there can be problems with PHP, the mod_python description of the
> bug [2] in one place refers to PHP4 - so perhaps the problem wasn't with
> PHP in the first place, but was instead some kind of mod_python version
> incompatibility.
>
> Anyway, for now I'll leave this alone and just keep an eye on it in case
> things start going wrong again.  In case it's of any interest, here's
> what I got when I checked the MySQL library versions in the current
> working setup:
>
> ---
> # ldd /usr/lib/python2.4/site-packages/_mysql.so | grep mysql
>         libmysqlclient_r.so.15 => /usr/lib/libmysqlclient_r.so.15
> (0x2b8df786)
> # ldd /usr/lib/apache2/modules/mod_*.so | grep mysql
> # ldd /usr/lib/php5/20060613/* | grep mysql
> /usr/lib/php5/20060613/mysqli.so:
>         libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15
> (0x2b8f8bd3f000)
> /usr/lib/php5/20060613/mysql.so:
>         libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15
> (0x2b28d2295000)
> /usr/lib/php5/20060613/pdo_mysql.so:
>         libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15
> (0x2ba328e47000)

There is still the risk of conflicts as Python module is using a
reentrant version of library and PHP isn't.

What this means is that if doing multithreaded stuff in Python, it
could crash in MySQL client library if PHP library taking precedence.
If data structures sizes are different for each library type, it could
crash without multithread use.

Graham

> Cheers,
>
> Giles
>
> [1]http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-y...
>
> [2]http://modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp
>
> --
> Giles Thomas
> MD & CTO, Resolver Systems Ltd.
> [EMAIL PROTECTED]
> +44 (0) 20 7253 6372
>
> Try out Resolver One! 
>
> 17a Clerkenwell Road, London EC1M 5RD, UK
> VAT No.: GB 893 5643 79
> Registered in England and Wales as company number 5467329.
> Registered address: 843 Finchley Road, London NW11 8NA, UK
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Admin page customization for a single model

2008-10-28 Thread Fabio Natali

Hi everybody!

I need to add a link to the admin page of one of my models. [0]
provides a step-by-step explanation on how to get this.

The point is that, contrarily to the docs statement, that procedure
will modify the "change list admin page" of all of my models, while I
need to change it for just one of them.

Any tips about this?

Are the docs wrong when they say "To continue the example above, we
want to add a new link next to the History tool for the Page model."
and then the change affects every model? Or, as it probably is, am I
just missing something?

All the best to all of you, Fabio.

[0] 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-template

-- 
Fabio Natali

--~--~-~--~~~---~--~~
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: web 2.0 apps with django

2008-10-28 Thread Kenneth Gonsalves

On Tuesday 28 October 2008 01:06:26 am Ravi Kondamuru wrote:
> Hi,Is there any simple app/ tutorial to understand web 2.0 application
> development with django?thanks,

http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01

-- 
regards
KG
http://lawgon.livejournal.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: Test failures with SQLite :memory: database - contenttypes, auth and sites

2008-10-28 Thread Brian Gershon

Hi Chris,

I just ran into this same issue.  I eventually figured out that adding
TEST_DATABASE_NAME to settings.py (to prevent Django from using the
default memory database for sqlite) works around the issue.

As far as debugging the memory database problem, I was getting the
"IntegrityError: django_content_type.name may not be NULL" error.

I traced this down to this line:

emit_post_sync_signal(models.get_models(), verbosity, interactive)

in /django/core/management/commands/flush.py

If I comment out that line, the error does not arise.

-Brian

On Oct 25, 9:50 am, "Chris H." <[EMAIL PROTECTED]> wrote:
> I've noticed at work and with my personal code that since the upgrade
> to Django 1.0 that I'm getting test failures when I run the unit tests
> under a SQLite :memory: database.
>
> I thought it might be something to do with those two codebases, so
> this morning I started a fresh project and I'm seeing the same
> problem.
>
> Is anyone else seeing this... the steps I took to reproduce were:
> 1. django-admin startproject sqlitetest
> 2. Edit sqlitetest/settings.py:
> DATABASE_ENGINE = 'mysql'
> DATABASE_NAME = 'sqlitetest_local'
> DATABASE_USER = '(your awesome username)'
> DATABASE_PASSWORD = '(your awesome password)'
> DATABASE_HOST = ''
> DATABASE_PORT = ''
>
> INSTALLED_APPS = (
>     'django.contrib.admin',
>     'django.contrib.admindocs',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
> )
> 3. django-admin.py syncdb
> 4. django-admin.py test
> (tests pass)
> 5. Create a settings_test.py file:
> from settings import *
> DATABASE_ENGINE = 'sqlite3'
> DATABASE_NAME = ':memory:'
> DATABASE_USER = ''
> DATABASE_PASSWORD = ''
> DATABASE_HOST = ''
> DATABASE_PORT = ''
> 6. Run tests, get 3 errors (the rest pass):
> IntegrityError: django_site.domain may not be NULL
> IntegrityError: auth_permission.name may not be NULL
> IntegrityError: django_content_type.name may not be NULL
>
> It's kind of a bummer because the tests run so much faster against
> a :memory: database and I didn't know if anyone had encountered this
> yet?
>
> Thanks,
>
> Chris H.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: 500 displayed instead of 404

2008-10-28 Thread janedenone

Hi Karen,

I did that, but the message was never sent to me.

Anyway, when I create a new project with a single app, containing
nothing but a single view which raises a Http404, along with a
urlpattern which refers to that view – the 500 template is still
displayed when I request the URL.

This must be easily reproducible on any machine using the following
code:

# urls.py:
urlpatterns = patterns('myproject.myapp.views',
   (r'^test/$', 'test'),
)

# views.py:
def test(request):
raise Http404

The same thing happens when I try any other URL: in debug mode, I get
the well-known

"Using the URLconf defined in djangoanke.urls, Django tried these URL
patterns, in this order:
^test/
The current URL, teste, didn't match any of these."

But with DEBUG = False, Django sends the 500.html template.

Clueless,
Jan

On 28 Okt., 20:09, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Oct 28, 2008 at 2:58 PM, janedenone <[EMAIL PROTECTED]>wrote:
>
>
>
> > Hi,
>
> > it must be some kind of unhandled exception, but I fail to see where
> > it might occur. I now boiled down the app to a single URL pattern and
> > a single view:
>
> [snipped]
>
> If you configure ADMINS and EMAIL_HOST, etc. so that Django can successfully
> send email, then the traceback from the uncaught exception will be mailed to
> whatever email address you include in ADMINS.  Much easier than guessing
> what might be happening.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin page: How to add a column for user that added an item

2008-10-28 Thread Robert Dailey

On Oct 28, 11:17 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> Robert Dailey wrote:
> > On Oct 28, 10:29 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> >> Robert Dailey wrote:
>
> >>> Hi,
>
> >>> I currently have the following model:
>
> >>> class Note( models.Model ):
> >>>    content = models.TextField()
>
> >>> I've setup the admin page to allow users to add "notes", which
> >>> basically lets them fill in the content variable. However, on the
> >>> admin page I want to add a column to show the user that added that
> >>> note. This would be the username in the admin page that they logged in
> >>> with. I hope that I can do this without adding any information to my
> >>> Note class, but if I must then I don't mind.
>
> >>> So column 1 should be the user that added that note, and Column 2
> >>> should be the note itself.
>
> >> The usual way to do this is to establish a relationship between User and
> >> Note. Since each note will only be created by a single user, and each
> >> user can (presumably) issue many notes the sensible thing to do would be
> >> to add a foreign key to Note to express which user created it.
>
> >> OK, assuming you can import your User model into the module that defines
> >> your Note model, you would just need to add
>
> >>     user = models.ForeignKey(User)
>
> >> to the Note model.
>
> > Thanks for your help. I tried the following:
>
> > from django.db import models
> > from django.contrib.auth.models import User
>
> > # Create your models here.
> > class Note( models.Model ):
> >    content = models.TextField()
> >    user = models.ForeignKey( User )
>
> > However, now when I visit the page that lists my notes, I get the
> > following error:
>
> > OperationalError at /admin/core/note/
> > (1054, "Unknown column 'core_note.user_id' in 'field list'")
>
> > Any idea what is going on?
>
> You'll need to add the corresponding field to your database. If you
> don't have any data worth keeping on the Note table (it will be called
> YourappnameNote in the database) then the easiest thing to do is delete
> the whole table then run
>
>   python manage.py syncdb
>
> to re-create the table with the additional field.

Awesome, thank you!

I'm have some more questions for you if you don't mind. When I add a
note, now there is a combo box with a list of users to choose from. I
would like for this combo box to not be visible and for it to
automatically choose the user submitting the note (The user currently
logged in). Is there a way to do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin / Model - "Page" model has many "Component" models

2008-10-28 Thread Liquidrums

After digging some more (trying every combination of keywords in
Google & these forums), I found this:
>> http://www.djangoproject.com/documentation/models/generic_relations/

This seems to be what I need.  In the example in the URL, a single tag
could be assigned to many objects, in the same way that many
"components" would be tied to a single "Page".

On Oct 28, 2:14 pm, Liquidrums <[EMAIL PROTECTED]> wrote:
> This may be beyond the reach of Django, but I figured it was worth a
> shot.
>
> I have a site tool not unlike many blogs or CMSs for adding/editing
> pages.  Recently, to enable common components to pages (such as
> contact forms, site-maps, carts, pre-filled content pages, etc.), the
> needs for the "Page" administration has changed from:
>
> >> Title:  Foo
> >> Content:  Bar Baz
>
> to
>
> >> Title:  Foo
> >> Content:  Bar Baz
> >> Components:
> >>  |- Header
> >>  |- Footer
> >>  |- Sitemap
> >>  |- Contact Form
>
> Where each "Component" is its own inherited model that defines any
> config settings needed.  For example, the Contact Form model may have
> a "To:" field defaulted, while the Footer component has no config
> settings.  The components are assembled in the view.
>
> Is there a way to achieve this, or is this beyond the scope of Django?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Admin / Model - "Page" model has many "Component" models

2008-10-28 Thread Liquidrums

This may be beyond the reach of Django, but I figured it was worth a
shot.

I have a site tool not unlike many blogs or CMSs for adding/editing
pages.  Recently, to enable common components to pages (such as
contact forms, site-maps, carts, pre-filled content pages, etc.), the
needs for the "Page" administration has changed from:

>> Title:  Foo
>> Content:  Bar Baz

to

>> Title:  Foo
>> Content:  Bar Baz
>> Components:
>>  |- Header
>>  |- Footer
>>  |- Sitemap
>>  |- Contact Form

Where each "Component" is its own inherited model that defines any
config settings needed.  For example, the Contact Form model may have
a "To:" field defaulted, while the Footer component has no config
settings.  The components are assembled in the view.

Is there a way to achieve this, or is this beyond the scope of Django?

--~--~-~--~~~---~--~~
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: 500 displayed instead of 404

2008-10-28 Thread Karen Tracey
On Tue, Oct 28, 2008 at 2:58 PM, janedenone <[EMAIL PROTECTED]>wrote:

>
> Hi,
>
> it must be some kind of unhandled exception, but I fail to see where
> it might occur. I now boiled down the app to a single URL pattern and
> a single view:
>
[snipped]

If you configure ADMINS and EMAIL_HOST, etc. so that Django can successfully
send email, then the traceback from the uncaught exception will be mailed to
whatever email address you include in ADMINS.  Much easier than guessing
what might be happening.

Karen

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



Re: 500 displayed instead of 404

2008-10-28 Thread janedenone

Hi,

it must be some kind of unhandled exception, but I fail to see where
it might occur. I now boiled down the app to a single URL pattern and
a single view:

# urls.py:
urlpatterns = patterns('myproject.myapp.views',
   (r'^test/$', 'test'),
)

# views.py:
def test(request):
raise Http404

When I rename the template 500.html to something else, this is
printed:

...

File "/Library/Python/2.5/site-packages/django/core/handlers/base.py",
line 116, in get_response
return self.handle_uncaught_exception(request, resolver,
sys.exc_info())

  File "/Library/Python/2.5/site-packages/django/core/handlers/
base.py", line 158, in handle_uncaught_exception
return callback(request, **param_dict)

  File "/Library/Python/2.5/site-packages/django/views/defaults.py",
line 88, in server_error
t = loader.get_template(template_name) # You need to create a
500.html template.

...

So there is indeed an uncaught exception which makes Django use the
500.html. It must be something that happens after Http404 is raised,
and my whole app/project are not involved anymore (except for
providing the template for the 404 page).

Kind regards,
Jan

On 28 Okt., 16:33, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I guess that you get 500 because there is an unhandled exception. Can
> you see
> a traceback in your error log?
>
> What happens if you write "return django.http.HttpResponse('OK')"
> instead of raise Http404?
>
>  Thomas
>
> janedenoneschrieb:
>
>
>
> > Hi,
>
> > I use the following simple view
>
> > def index(request, page_id, current_subpage=1):
> >    try:
> >            current_page = get_object_or_404(Page, pk=page_id)
> >    except:
> >            # if anything else goes wrong, display the 404 anway
> >            raise Http404
>
> > In debug mode, my app returns the detailed 'page not found' page for
> > non-existing pages, but as soon as I switch debug to false, the
> > 500 template is shown. I can, however, display render and return the
> > 404 template manually.
>
> > What could possibly go wrong when a Http404 exception is raised, i.e.
> > why does Django use the 500 template in this case?
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Noon Help

2008-10-28 Thread Johnny Utah

Thanks a lot Peter and Jeff.  Your posts have definitely pointed me in
the right direction.

I'll see what I come up with.  If its anything functional, I'll be
sure to give you guys the link. :)

Also, if anybody wants to contribute code - I need all the help I can
get! (and I might have some code questions later)

Thanks again guys.



On Oct 27, 12:01 pm, "Peter Herndon" <[EMAIL PROTECTED]> wrote:
> I might also suggest django-registration
> (http://code.google.com/p/django-registration) to handle your user
> registration needs.
>
> On Mon, Oct 27, 2008 at 2:34 PM, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> > Johnny Utah wrote:
> >> Thanks for the input.
>
> >> When you say Django.admin would be useful, do you mean users would
> >> access the admin interface?
>
> > Please respond to the list when asking further questions.
>
> > That being said: no-- users shouldn't access the admin interface. Admins
> > should. It's there to make your life much easier, and it does that very
> > well. You'll still need to build views for your app, but if you need to
> > go in and change something manually, the admin interface is way better
> > than dropping to SQL.
>
> > Jeff Anderson
--~--~-~--~~~---~--~~
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 along with PHP - avoiding Apache crashes

2008-10-28 Thread Wes Winham

I'm currently in production with Apache2, mod_php, mod_python, Django
1.0, MySQL 5.x, and PHP5 using everything (except django) out of the
Ubuntu 8.04 repository with no troubles, if that helps at all.

On Oct 28, 8:58 am, Giles Thomas <[EMAIL PROTECTED]>
wrote:
> Graham,
>
> Thank you again for the help - as you might have guessed, my separate
> question that you answered on the mod_wsgi list was because I'd decided
> to try out the WSGI solution to the problem first.
>
> What's very strange is that although I did get the same crash when I
> first tried running up Apache + PHP  + mod_wsgi as I had with mod_python
> - as you would expect - it now works fine!  I *think* that the change
> that fixed it was when I ran apt-get remove libapache2-mod-python - but
> I'm not quite sure why that worked.
>
> So I'm now in the uncomfortable position of having a server that works
> perfectly well, when I'm pretty sure that it should not.  One
> possibility: I'm using PHP5, and although the Django page [1] just says
> that there can be problems with PHP, the mod_python description of the
> bug [2] in one place refers to PHP4 - so perhaps the problem wasn't with
> PHP in the first place, but was instead some kind of mod_python version
> incompatibility.
>
> Anyway, for now I'll leave this alone and just keep an eye on it in case
> things start going wrong again.  In case it's of any interest, here's
> what I got when I checked the MySQL library versions in the current
> working setup:
>
> ---
> # ldd /usr/lib/python2.4/site-packages/_mysql.so | grep mysql
>         libmysqlclient_r.so.15 => /usr/lib/libmysqlclient_r.so.15
> (0x2b8df786)
> # ldd /usr/lib/apache2/modules/mod_*.so | grep mysql
> # ldd /usr/lib/php5/20060613/* | grep mysql
> /usr/lib/php5/20060613/mysqli.so:
>         libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15
> (0x2b8f8bd3f000)
> /usr/lib/php5/20060613/mysql.so:
>         libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15
> (0x2b28d2295000)
> /usr/lib/php5/20060613/pdo_mysql.so:
>         libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15
> (0x2ba328e47000)
> #
> ---
>
> Cheers,
>
> Giles
>
> [1]http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-y...
>
> [2]http://modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp
>
> --
> Giles Thomas
> MD & CTO, Resolver Systems Ltd.
> [EMAIL PROTECTED]
> +44 (0) 20 7253 6372
>
> Try out Resolver One! 
>
> 17a Clerkenwell Road, London EC1M 5RD, UK
> VAT No.: GB 893 5643 79
> Registered in England and Wales as company number 5467329.
> Registered address: 843 Finchley Road, London NW11 8NA, UK
--~--~-~--~~~---~--~~
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: Donation Application

2008-10-28 Thread Brian Neal

On Oct 27, 8:03 pm, unklbeemer <[EMAIL PROTECTED]> wrote:
> I did some searching and found nothing. I was wondering if anyone knew
> of any django applications out there for receiving donations and/or
> tracking those donations (capital campaign progress, pledges donated,
> etc.)
>
> Thanks

I'll be porting, well that may be too strong a word...creating a
django app based on the functionality of the (don't laugh) PHP-Nuke
Donations module/block soon. I'm going to use the IPN code that Paul
Kenjora kindly posted here: http://blog.awarelabs.com/?p=74.
--~--~-~--~~~---~--~~
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 get value of query string in template

2008-10-28 Thread bruno desthuilliers

On 28 oct, 17:47, "yuanyun.ken" <[EMAIL PROTECTED]> wrote:
> Hi,I am a newbie to Django, and will use it in my latest project right
> away.
> now I encounter a little problem.
>
> How can I get value of query string in 
> template?http://localhost/mysite/login/?next=/mysite/product/

> My aim is to set next value in my login.html, if there is "next" in
> query string, use its value, otherwise set "next" a default value.
> 

If you add "django.core.context_processors.request" to your
settings.CONTEXT_PROCESSORS and use RequestContext objects in your
views, you'll have access to the request object in your templates.
Then it's just a matter of using the appropriate request attribute, in
your case probably something like request.REQUEST['next'] (or, since
it's in a template, {{ request.REQUEST.next }}

cf http://docs.djangoproject.com/en/dev/ref/request-response/ for more
on the request object.

Now note that if you use your own login view, this should be handled
in the view function itself, and passed to the template via the
context.

HTH
--~--~-~--~~~---~--~~
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: Donation Application

2008-10-28 Thread Frank Malina @ vizualbod.com

This maybe isn't what you are looking for, but 
http://vizualbod.com/articles/paypaldonationlink

--~--~-~--~~~---~--~~
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: Foreign key with tons of items

2008-10-28 Thread Frank Malina @ vizualbod.com

Use "raw_id_field" useful when you have a Foreign Key on another model
with lots of records. This changes the default interface from the a
select box to a custom widget
--~--~-~--~~~---~--~~
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: Donation Application

2008-10-28 Thread unklbeemer



On Oct 27, 8:24 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I don't know of any applications for this specifically, however you
> can probably steal various parts of Satchmo, specifically all the
> payment stuff.
>
> On Oct 27, 9:03 pm, unklbeemer <[EMAIL PROTECTED]> wrote:
>
> > I did some searching and found nothing. I was wondering if anyone knew
> > of any django applications out there for receiving donations and/or
> > tracking those donations (capital campaign progress, pledges donated,
> > etc.)
>
> > Thanks


How easy would it be to pull the payment data to create some charts?
I'm guessing it would be quite difficult
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



FormWizard and ChoiceFields

2008-10-28 Thread David koblas

I've recently discovered FormWizard -- trying to replace my own "Wizard" 
in some code.

I've got the following flow -- roughly :
1) authentication info (username/password)
2) use auth info to get a list of things -- present list in choice 
field...
3) given that choice, present another list -- technically optionally 
[there might be only one choice]

The problem is that FormWizard creates a new object everytime you call 
get_form(), so the ability to populate the choices field in step #2 is 
defeated. 

has anybody worked around this problem,  or did I miss something?

--koblas

--~--~-~--~~~---~--~~
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: Creating a system with multiple types of users

2008-10-28 Thread itsnotvalid

Any reply yet?
I also looked at the profile functionality from auth. Seems that I can
only define a single profile for each user. What if I need to have
different profiles for different users?

On Oct 25, 1:25 am, itsnotvalid <[EMAIL PROTECTED]> wrote:
> Is there any posts related to the permission system? I didn't looked
> into that part yet, but seems interesting. Of course groups also seems
> to solve the problem as well.
>
> However I also saw @user_passes_test in the doc. What is the
> difference or use cases from @user_passes_test and
> @permission_required?
> On Oct 23, 7:54 am, felix <[EMAIL PROTECTED]> wrote:
>
> > perhaps when you create-save the models (Providers, Customers etc.) it adds
> > that User to the appropriate group.
>
> > but I'm not sure I would use groups.  That would make the most sense if
> > there were people with overlapping roles.  somebody who is Agent + Provider
>
> > you could use the permissions system.  again, also saving it to the User at
> > the time you create the Agent, Provider etc.
>
> > I have a form that creates a Person and optionally creates a User account at
> > the same time linked to it.  you can also create a User (an account) later
> > for some person who is in the contact database.  so I do that action in the
> > Form.  its the form's responsibility (it represents/encapsulates the action
> > that the admin is taking)
>
> > I guess what you are asking is : how can you check on the template or in the
> > views what type of person the user is and show them certain things.
>
> > you can make use of the template tags that check for perms.
>
> > and some views are only accessible for certain types of peoples.  for that,
> > using perms is good.
>
> > @permission_required("app.provider.can_view")
> > def view_func(request):
>
> > also this way you can give the staff or Agents perms that the plebs also
> > have.
>
> > you could also set a cookie/session var on login for is_a
> > that would be less db hits
>
> > -f;lix
>
> > On Tue, Oct 21, 2008 at 10:39 PM, itsnotvalid <[EMAIL PROTECTED]> wrote:
>
> > > I am going to help some people making a website that has a few admins,
> > > a crowd of service providers (individuals) and customers. There could
> > > be agents who invites people to become service providers or customers
> > > as well.
>
> > > Looking at the user system provided by django, and as a new programmer
> > > to django, I am not sure how can I separate different kinds of user
> > > here. I actually want to make it look like that different people login
> > > in different location, and do not share the same view after they
> > > logged in.
>
> > > So I am thinking a model schema like this:
>
> > > Users (as usual)
>
> > > Providers(link to a specific user, one-to-one)
>
> > > Customers(link to a specific user, many-to-one, as one user may find
> > > services for more that one actual person)
>
> > > Agents(link to a specific user, one-to-one)
>
> > > But how effectively can I separate their views? By defining different
> > > apps? Any other 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
-~--~~~~--~~--~--~---



Re: Ordering M2M field?

2008-10-28 Thread euglena

most of the time, intermediate model is more useful than M2M
relationship...

On Oct 24, 10:16 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> OK, I have a model with a many to many relationship.. pretty
> straightforward pre-1.0 code:
>
> class SpecialEvent(models.Model):
>     sponsors = models.ManyToManyField(Advertiser, related_name="event
> sponsors", null=True, blank=True)
>
> Problem is, the Powers That Be want those sponsors in a certain order.
> I thought they just showed up in the order in which they were added in
> the admin (ordered by id on their table)
>
> That does not appear to be the case. They appear to order themselves
> based on their own id.
>
> So, how can I set the order in which they appear?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to get value of query string in template

2008-10-28 Thread yuanyun.ken

Hi,I am a newbie to Django, and will use it in my latest project right
away.
now I encounter a little problem.

How can I get value of query string in template?
http://localhost/mysite/login/?next=/mysite/product/

My aim is to set next value in my login.html, if there is "next" in
query string, use its value, otherwise set "next" a default value.


thanks for any help in advance.
--~--~-~--~~~---~--~~
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 get site's root path in Django

2008-10-28 Thread Karen Tracey
On Tue, Oct 28, 2008 at 11:10 AM, yuanyun.ken <[EMAIL PROTECTED]> wrote:

>
> Graham, thanks for your kindly help.
>
> I know we don't need root url when configure url mapping. but it seems
> that LOGIN_URL is somewhat special.
>
> When I set LOGIN_URL = '/login/'
> accessing http://localhost/root_url/login/ is ok,
> but when I access some pages which need login first, I will got 404
> error, and in apache's error log, it logs:
> File does not exist: D:/Program Files/Apache Software Foundation/
> Apache2.2.9/htdocs/login
>
> and the only way to work is adding root url to LOGIN_URL.
> LOGIN_URL = '/root_url/login/'
>
> I can not figure out whether there are problems in my configuration,
> or anything else.
>

Sounds like:

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

So (assuming you are not "levity") someone else has reported the same
thing.  It sounds like there may be a problem in Django code here, but no
one has yet investigated far enough to confirm that or suggest a fix.

Karen

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



Re: Splitting models.py won't install models

2008-10-28 Thread Rock

I tried to do this several months ago during the run up to the 1.0
release and, at that time, the capability was broken. Furthermore I
recall having a discussion with some core developer that it was not on
the short list to fix for 1.0. I didn't submit a ticket for this, but
it may have been because someone else had already done so. I suggest
searching the tickets before spending any more time trying to make
this work.


--~--~-~--~~~---~--~~
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: Admin page: How to add a column for user that added an item

2008-10-28 Thread Steve Holden

Robert Dailey wrote:
> On Oct 28, 10:29 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>   
>> Robert Dailey wrote:
>> 
>>> Hi,
>>>   
>>> I currently have the following model:
>>>   
>>> class Note( models.Model ):
>>>content = models.TextField()
>>>   
>>> I've setup the admin page to allow users to add "notes", which
>>> basically lets them fill in the content variable. However, on the
>>> admin page I want to add a column to show the user that added that
>>> note. This would be the username in the admin page that they logged in
>>> with. I hope that I can do this without adding any information to my
>>> Note class, but if I must then I don't mind.
>>>   
>>> So column 1 should be the user that added that note, and Column 2
>>> should be the note itself.
>>>   
>> The usual way to do this is to establish a relationship between User and
>> Note. Since each note will only be created by a single user, and each
>> user can (presumably) issue many notes the sensible thing to do would be
>> to add a foreign key to Note to express which user created it.
>>
>> OK, assuming you can import your User model into the module that defines
>> your Note model, you would just need to add
>>
>> user = models.ForeignKey(User)
>>
>> to the Note model.
>> 
>
> Thanks for your help. I tried the following:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> # Create your models here.
> class Note( models.Model ):
>   content = models.TextField()
>   user = models.ForeignKey( User )
>
> However, now when I visit the page that lists my notes, I get the
> following error:
>
> OperationalError at /admin/core/note/
> (1054, "Unknown column 'core_note.user_id' in 'field list'")
>
> Any idea what is going on?
>   
You'll need to add the corresponding field to your database. If you
don't have any data worth keeping on the Note table (it will be called
YourappnameNote in the database) then the easiest thing to do is delete
the whole table then run

  python manage.py syncdb

to re-create the table with the additional field.

regards
 Steve



--~--~-~--~~~---~--~~
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 full text search best solution

2008-10-28 Thread alain D.

Being inside database transactions is a good reason to use database's
full text index ... but the sake of simplicity, a full text index
created by python code inside the models declaration (easily
maintainable) would be nice ...

> Since all external full text indexing (sphinx, lucene) won't be part of
> the database transaction,
> I choose the full text index of postgres.
>
> I wrote an own to_tsvector method in python, instead of customizing
> the to_tsvector method of postgres.

--~--~-~--~~~---~--~~
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.pl has been officially launched

2008-10-28 Thread Stan Dyck

Am I the only one who, upon seeing the subject line of this email, asked 
"Why would someone want to rewrite django in perl?"

;-)

StanD.

Dominik Szopa wrote:
>
> On 26 Paź, 18:01, Marek Kubica <[EMAIL PROTECTED]> wrote:
>   
>> On Sun, 26 Oct 2008 06:32:11 -0700, Dominik Szopa wrote:
>> 
>>> Django Polish community site -http://www.django.plhas been officially
>>> launched.
>>>   
>> I just took a look - the design is definitely good. The examples of
>> polish sites using Django are also a good idea.
>> 
>
>   


--~--~-~--~~~---~--~~
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: Admin page: How to add a column for user that added an item

2008-10-28 Thread Robert Dailey

On Oct 28, 10:29 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> Robert Dailey wrote:
> > Hi,
>
> > I currently have the following model:
>
> > class Note( models.Model ):
> >    content = models.TextField()
>
> > I've setup the admin page to allow users to add "notes", which
> > basically lets them fill in the content variable. However, on the
> > admin page I want to add a column to show the user that added that
> > note. This would be the username in the admin page that they logged in
> > with. I hope that I can do this without adding any information to my
> > Note class, but if I must then I don't mind.
>
> > So column 1 should be the user that added that note, and Column 2
> > should be the note itself.
>
> The usual way to do this is to establish a relationship between User and
> Note. Since each note will only be created by a single user, and each
> user can (presumably) issue many notes the sensible thing to do would be
> to add a foreign key to Note to express which user created it.
>
> OK, assuming you can import your User model into the module that defines
> your Note model, you would just need to add
>
>     user = models.ForeignKey(User)
>
> to the Note model.

Thanks for your help. I tried the following:

from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Note( models.Model ):
content = models.TextField()
user = models.ForeignKey( User )

However, now when I visit the page that lists my notes, I get the
following error:

OperationalError at /admin/core/note/
(1054, "Unknown column 'core_note.user_id' in 'field list'")

Any idea what is going on?
--~--~-~--~~~---~--~~
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: Splitting models.py won't install models

2008-10-28 Thread Alistair Marshall

On Oct 28, 1:43 pm, patrickk <[EMAIL PROTECTED]> wrote:
> you could try changing the import in __init__.py to someting like
> this:
> from app_name.models.model_file import Model1, Model2, ...
> e.g.
> from library.models.material import Material, MaterialImage
>
> ... might work.
>
Thanks for your reply,

unfortunately it made no difference.
If I miss type a model name or try to import from a non existent file,
I get an error (as expected) however if all is typed correct I get no
error but my models are still not inserted into my database.

any other ideas?

Thanks again
--~--~-~--~~~---~--~~
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 full text search best solution

2008-10-28 Thread Thomas Guettler

alain D. schrieb:
> Hi,
>
> I'm looking at all the available solutions to implement a full text
> index for django models and I found various projects at different
> stages of maturity but none of them seems to have a strong community
> support ... so here is the list along with my comments (and last
> commit time) ... it any of you has some advice or feedback on any of
> those (or can propose an alternative solution), I'll be glad to here
> from you!
>   
Since all external full text indexing (sphinx, lucene) won't be part of
the database transaction,
I choose the full text index of postgres.

I wrote an own to_tsvector method in python, instead of customizing
the to_tsvector method of postgres.

 Thomas



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


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Admin page: How to add a column for user that added an item

2008-10-28 Thread Steve Holden

Robert Dailey wrote:
> Hi,
>
> I currently have the following model:
>
> class Note( models.Model ):
>   content = models.TextField()
>
> I've setup the admin page to allow users to add "notes", which
> basically lets them fill in the content variable. However, on the
> admin page I want to add a column to show the user that added that
> note. This would be the username in the admin page that they logged in
> with. I hope that I can do this without adding any information to my
> Note class, but if I must then I don't mind.
>
> So column 1 should be the user that added that note, and Column 2
> should be the note itself.
>   
The usual way to do this is to establish a relationship between User and
Note. Since each note will only be created by a single user, and each
user can (presumably) issue many notes the sensible thing to do would be
to add a foreign key to Note to express which user created it.

OK, assuming you can import your User model into the module that defines
your Note model, you would just need to add

user = models.ForeignKey(User)

to the Note model.

regards
 Steve


--~--~-~--~~~---~--~~
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: 500 displayed instead of 404

2008-10-28 Thread Thomas Guettler

Hi,

I guess that you get 500 because there is an unhandled exception. Can
you see
a traceback in your error log?

What happens if you write "return django.http.HttpResponse('OK')"
instead of raise Http404?

 Thomas

janedenone schrieb:
> Hi,
>
> I use the following simple view
>
> def index(request, page_id, current_subpage=1):
>   try:
>   current_page = get_object_or_404(Page, pk=page_id)
>   except:
>   # if anything else goes wrong, display the 404 anway
>   raise Http404
>
> In debug mode, my app returns the detailed 'page not found' page for
> non-existing pages, but as soon as I switch debug to false, the
> 500 template is shown. I can, however, display render and return the
> 404 template manually.
>
> What could possibly go wrong when a Http404 exception is raised, i.e.
> why does Django use the 500 template in this case?
>   


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


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

2008-10-28 Thread Steve Holden

janedenone wrote:
> Hi,
>
> I use the following simple view
>
> def index(request, page_id, current_subpage=1):
>   try:
>   current_page = get_object_or_404(Page, pk=page_id)
>   except:
>   # if anything else goes wrong, display the 404 anway
>   raise Http404
>
> In debug mode, my app returns the detailed 'page not found' page for
> non-existing pages, but as soon as I switch debug to false, the
> 500 template is shown. I can, however, display render and return the
> 404 template manually.
>
> What could possibly go wrong when a Http404 exception is raised, i.e.
> why does Django use the 500 template in this case?
>
>   
That depends whether your site does anything special with 404 errors.
Some sites display them with full decoration, and so there's always the
chance that 404 processing goes squiffy, in which case you may well see
a 500.

It's clear that some code is being executed in processing the 404
without debug that *isn't* executed when you process a 404 with debug
set. Now you just have to find out what ...

regards
 Steve


--~--~-~--~~~---~--~~
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: case insensitive search

2008-10-28 Thread Karen Tracey
On Tue, Oct 28, 2008 at 10:54 AM, DULMANDAKH Sukhbaatar <
[EMAIL PROTECTED]> wrote:

>
> > Use   search_fields = ['name'] in the corresponding
> > class inside admin.py
>
> I did. Actually my text is Cyrillic. Just now I tested searching
> sample latin or english text, and search workin fine. Is it problem
> with non-english text? if so how i can fix it, and make work?
>
>
Django's case-insensitive  search is going to map to a LIKE query for
sqlite.  According to this page:

http://www.sqlite.org/lang_expr.html

sqlite doesn't handle case-insensitive searches for anything except 7-bit
ASCII:

"(A bug: SQLite only understands upper/lower case for 7-bit Latin
characters. Hence the LIKE operator is case sensitive for 8-bit iso8859
characters or UTF-8 characters. For example, the expression *'a' LIKE
'A'*is TRUE but
*'æ' LIKE 'Æ'* is FALSE.)."

So it sounds like you will need to move to a different DB if you want
case-insensitive searching to work for Cyrillic chars.

Karen

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



Re: How to get site's root path in Django

2008-10-28 Thread yuanyun.ken

Graham, thanks for your kindly help.

I know we don't need root url when configure url mapping. but it seems
that LOGIN_URL is somewhat special.

When I set LOGIN_URL = '/login/'
accessing http://localhost/root_url/login/ is ok,
but when I access some pages which need login first, I will got 404
error, and in apache's error log, it logs:
File does not exist: D:/Program Files/Apache Software Foundation/
Apache2.2.9/htdocs/login

and the only way to work is adding root url to LOGIN_URL.
LOGIN_URL = '/root_url/login/'

I can not figure out whether there are problems in my configuration,
or anything else.
--~--~-~--~~~---~--~~
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: 500 displayed instead of 404

2008-10-28 Thread Ronaldo Zacarias Afonso

Hi Jane,

Are you sure your index view is being executed?
It just seems that django can't find a URLconf rule defined for your view.

[]s
Ronaldo.

On Tue, Oct 28, 2008 at 11:36 AM, janedenone <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I use the following simple view
>
> def index(request, page_id, current_subpage=1):
>try:
>current_page = get_object_or_404(Page, pk=page_id)
>except:
># if anything else goes wrong, display the 404 anway
>raise Http404
>
> In debug mode, my app returns the detailed 'page not found' page for
> non-existing pages, but as soon as I switch debug to false, the
> 500 template is shown. I can, however, display render and return the
> 404 template manually.
>
> What could possibly go wrong when a Http404 exception is raised, i.e.
> why does Django use the 500 template in this case?
>
> Kind regards,
> Jan
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: case insensitive search

2008-10-28 Thread DULMANDAKH Sukhbaatar

> Use   search_fields = ['name'] in the corresponding
> class inside admin.py

I did. Actually my text is Cyrillic. Just now I tested searching
sample latin or english text, and search workin fine. Is it problem
with non-english text? if so how i can fix it, and make work?


-- 
Regards
Dulmandakh

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



500 displayed instead of 404

2008-10-28 Thread janedenone

Hi,

I use the following simple view

def index(request, page_id, current_subpage=1):
try:
current_page = get_object_or_404(Page, pk=page_id)
except:
# if anything else goes wrong, display the 404 anway
raise Http404

In debug mode, my app returns the detailed 'page not found' page for
non-existing pages, but as soon as I switch debug to false, the
500 template is shown. I can, however, display render and return the
404 template manually.

What could possibly go wrong when a Http404 exception is raised, i.e.
why does Django use the 500 template in this case?

Kind regards,
Jan



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



Admin page: How to add a column for user that added an item

2008-10-28 Thread Robert Dailey

Hi,

I currently have the following model:

class Note( models.Model ):
content = models.TextField()

I've setup the admin page to allow users to add "notes", which
basically lets them fill in the content variable. However, on the
admin page I want to add a column to show the user that added that
note. This would be the username in the admin page that they logged in
with. I hope that I can do this without adding any information to my
Note class, but if I must then I don't mind.

So column 1 should be the user that added that note, and Column 2
should be the note itself.
--~--~-~--~~~---~--~~
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: edit_inline does not save?

2008-10-28 Thread Daniel Austria

Hi Daniel,

thanks for your response. You were absolutely right with your idea.

i removed the core=True ... and it works.

Thanks again,
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
-~--~~~~--~~--~--~---



Re: Getting a NameError: global name 'Lesson' is not defined

2008-10-28 Thread bruno desthuilliers

On 28 oct, 14:05, Daniel Strasser <[EMAIL PROTECTED]> wrote:
> > You have a circular reference between students.models and
> > lessons.models. The first want to import the second, which want to
> > import the first, etc... This just can't work.
>
> Thank you very much. I played around but I don't come to a solution. I
> think I'll try again. I just don't understand where this circular
> reference should be (Problem exists also if I remove them from one
> place or another)

Sorry, it appears I jumped to conclusion a bit too fast. Re-reading
the traceback:

1/ students.models imports lessons.models.Lesson
2/ lessons.models.Lesson try to reference students.models.Student -
which is not defined.

IOW : you don't _actually_ have a circular reference, but you would
have one if you tried to solve this NameError by import
students.models in lessons.models.

The solution is to declare the foreign key on Students using a
app_label.model_name string instead of a model object, ie (not
tested...) :

class Lesson(models.Model):
   # ...
   student = models.ForeignKey('students.Student')


cf 
http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey
for more on this.

A bit OT, but using a models.ForeignKey here means that a Lesson can
have *at most one* single student. I can't of course tell whether
that's ok for your app, but it sure looks a bit weird to me.

And while we're at it: given the existence of this foreign key, the
Student.lesson_hours method mentioned in your first post should make
use of it, ie:

class Student(models.Model):
  # ...
  def lesson_hours(self):
  return self.lesson_set.count()

HTH
--~--~-~--~~~---~--~~
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: Splitting models.py won't install models

2008-10-28 Thread patrickk

you could try changing the import in __init__.py to someting like
this:
from app_name.models.model_file import Model1, Model2, ...
e.g.
from library.models.material import Material, MaterialImage

... might work.

patrick.


On 28 Okt., 10:36, Alistair Marshall <[EMAIL PROTECTED]>
wrote:
> I have been trying to split my models.py file into several smaller
> more manageable files. I have created a folder named models, an in
> there, created a __init__.py file which contains:
>
> from other import *
> from streams import *
> from units import *
>
> I have then split my models into the three files making sure to add
> app_label = 'process' to the metatag of each model. Then when I run
> 'python manage.py syncdb', It runs through and creates tables for
> models from other application but doesn't create any models to do with
> my process app.
>
> If I insert a syntax error into one of my models, it does raise an
> error when I syncdb.
> If I remove app_label, it does not raise an error or change the
> behaviour in any way.
>
> am I missing anything else?
> any other suggestions?
>
> Thanks
> Alistair
--~--~-~--~~~---~--~~
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: about WebServices

2008-10-28 Thread fire-eater

Tim, Do you know about a reference where I can read a full functional
example???

thanks

PS- Sorry about the images, I did not realize that my mail-client was
sending the footer images,, sorry again
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Splitting models.py won't install models

2008-10-28 Thread Alistair Marshall

I have been trying to split my models.py file into several smaller
more manageable files. I have created a folder named models, an in
there, created a __init__.py file which contains:

from other import *
from streams import *
from units import *

I have then split my models into the three files making sure to add
app_label = 'process' to the metatag of each model. Then when I run
'python manage.py syncdb', It runs through and creates tables for
models from other application but doesn't create any models to do with
my process app.

If I insert a syntax error into one of my models, it does raise an
error when I syncdb.
If I remove app_label, it does not raise an error or change the
behaviour in any way.

am I missing anything else?
any other suggestions?

Thanks
Alistair

--~--~-~--~~~---~--~~
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: case insensitive search

2008-10-28 Thread srini

Mr.Dulmandakh

 Use   search_fields = ['name'] in the corresponding
class inside admin.py

 Their is no such a case sensitive exists in Django search field ,
It will show
 it's matches either case sensitive or case insensitive.



> Hello all.
>
> Just now I've deployed my first django web app. it's kind of address
> book. everything went 
> smoothly.http://docs.djangoproject.com/en/dev/ref/contrib/admin/says that
> search_fields is case insensitive. but when I search some person using
> django admin, it shows exact matches with case. I need to search
> everything no mater what the case is.
>
> I'm using django 1.0, and sqlite3 as a storage.
>
> --
> Regards
> Dulmandakh
--~--~-~--~~~---~--~~
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: Getting a NameError: global name 'Lesson' is not defined

2008-10-28 Thread Daniel Strasser

> You have a circular reference between students.models and
> lessons.models. The first want to import the second, which want to
> import the first, etc... This just can't work.

Thank you very much. I played around but I don't come to a solution. I
think I'll try again. I just don't understand where this circular
reference should be (Problem exists also if I remove them from one
place or another)

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



Re: Django along with PHP - avoiding Apache crashes

2008-10-28 Thread Giles Thomas

Graham,

Thank you again for the help - as you might have guessed, my separate 
question that you answered on the mod_wsgi list was because I'd decided 
to try out the WSGI solution to the problem first.

What's very strange is that although I did get the same crash when I 
first tried running up Apache + PHP  + mod_wsgi as I had with mod_python 
- as you would expect - it now works fine!  I *think* that the change 
that fixed it was when I ran apt-get remove libapache2-mod-python - but 
I'm not quite sure why that worked.

So I'm now in the uncomfortable position of having a server that works 
perfectly well, when I'm pretty sure that it should not.  One 
possibility: I'm using PHP5, and although the Django page [1] just says 
that there can be problems with PHP, the mod_python description of the 
bug [2] in one place refers to PHP4 - so perhaps the problem wasn't with 
PHP in the first place, but was instead some kind of mod_python version 
incompatibility.

Anyway, for now I'll leave this alone and just keep an eye on it in case 
things start going wrong again.  In case it's of any interest, here's 
what I got when I checked the MySQL library versions in the current 
working setup:

---
# ldd /usr/lib/python2.4/site-packages/_mysql.so | grep mysql
libmysqlclient_r.so.15 => /usr/lib/libmysqlclient_r.so.15 
(0x2b8df786)
# ldd /usr/lib/apache2/modules/mod_*.so | grep mysql
# ldd /usr/lib/php5/20060613/* | grep mysql
/usr/lib/php5/20060613/mysqli.so:
libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15 
(0x2b8f8bd3f000)
/usr/lib/php5/20060613/mysql.so:
libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15 
(0x2b28d2295000)
/usr/lib/php5/20060613/pdo_mysql.so:
libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15 
(0x2ba328e47000)
#
---

Cheers,

Giles

[1] 
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-segmentation-fault

[2] http://modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp

-- 
Giles Thomas
MD & CTO, Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

Try out Resolver One! 

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 
Registered in England and Wales as company number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK



--~--~-~--~~~---~--~~
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: Easiest way to pass django documentation from rest to HTML?

2008-10-28 Thread James Bennett

On Mon, Oct 27, 2008 at 9:27 PM, Mr. Z <[EMAIL PROTECTED]> wrote:
> Which is the easiest way to pass the new django documentation from
> rest to HTML?

This is covered in the documentation:

http://docs.djangoproject.com/en/dev/internals/documentation/



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

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



case insensitive search

2008-10-28 Thread DULMANDAKH Sukhbaatar

Hello all.

Just now I've deployed my first django web app. it's kind of address
book. everything went smoothly.
http://docs.djangoproject.com/en/dev/ref/contrib/admin/ says that
search_fields is case insensitive. but when I search some person using
django admin, it shows exact matches with case. I need to search
everything no mater what the case is.

I'm using django 1.0, and sqlite3 as a storage.

-- 
Regards
Dulmandakh

--~--~-~--~~~---~--~~
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: edit_inline does not save?

2008-10-28 Thread Daniel Roseman

On Oct 28, 10:47 am, Daniel Austria <[EMAIL PROTECTED]> wrote:
> Hello,
>
> i got a huge problem. I have got an Idea class and an ideacomment
> class. You can guess what these classes are used for. What i do is the
> following:
>
> - the ideacomment class has an foreignkey
> - this foreignkey is marked as edit_inline
> - when i edit an idea instance in the admin i can also add some
> comments in the same html page
> - BUT: the comments are not saved  ??
>
> Strange... what should i try / debugg or look at .
>
> Dan
>
> ps. i did not write any views or else... the code below is the whole
> code i have 
>
> -- CODE-

> class IdeaComment(models.Model):
>     Header = models.CharField('Header', maxlength=500, core=True)
>     Text = models.TextField('Description', core=True)
>     IsParticipant = models.ForeignKey(Participant, core=True)
>     LastModified = models.DateTimeField('Last Modified', core=True,
> auto_now = True)
>     IsIdea = models.ForeignKey(Idea, edit_inline=models.STACKED,
> min_num_in_admin=6, num_extra_on_change=6)
>
>     def __unicode__(self):
>         return self.Header
>     def __str__(self):
>         return self.__unicode__()

As Erik has pointed out, this is code for an old version of Django, so
I'm not entirely sure about this.

But if I had to guess, I would say that the problem is that
LastModified has core=True. The old admin would only save an inline
element if all 'core' fields were filled in. But since LastModified
has auto_now_add, it doesn't appear in the admin - so it may well be
that that's stopping it from saving.

Try removing either core=True or auto_now_add=True from LastModified
and see if that works.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django full text search best solution

2008-10-28 Thread alain D.

Hi,

I'm looking at all the available solutions to implement a full text
index for django models and I found various projects at different
stages of maturity but none of them seems to have a strong community
support ... so here is the list along with my comments (and last
commit time) ... it any of you has some advice or feedback on any of
those (or can propose an alternative solution), I'll be glad to here
from you!

* django-search-lucene (http://code.google.com/p/django-search-lucene)
no issues ... wiki not updated since django 1.0
last commit : aug 08

* djapian (http://code.google.com/p/djapian)
seems fairly active (not much issues added / resolved though)
last commit : oct 08

* django-sphinx (http://code.google.com/p/django-sphinx)
sphinx looks like it's the most difficult backend to setup
last commit : oct 08

* using database full text index
postgresql (in code since release 8.3) and mysql have full text
indexes

* djangosearch (http://code.google.com/p/djangosearch)
multi backend (Solr being the preferred). Wiki says to be used in
production but "API still very unstable"
last commit : oct 08

* django-search (http://code.google.com/p/django-search/)
does not seems to be very active
last commit : may 08

My understanding is that djangosearch and djapian are the most
interesting projects at the moment ...
--~--~-~--~~~---~--~~
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 get site's root url path in Django

2008-10-28 Thread Steve Holden

The answer to your question is the same as the first time you posted it,
about fourteen hours previously. Please do not just repeat the same
question - wait patiently for the answer, and if no answer comes in a
couple of days then add more information to your request or otherwise
change it to increase the probability of a reply.

Graham Dumpleton has told you the solution in the other thread.

regards
 Steve

yuanyun.ken wrote:
> Hi, all great Django users and developers, I have a little problem.
> To make @login_required work,
> I have to configure those in settings.py:
> root_url = '/root_url/'
> LOGIN_URL = root_url + '/login/'
> LOGOUT_URL =  root_url + '/logout/'
>
>   
[...]


--~--~-~--~~~---~--~~
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: Foreign key with tons of items

2008-10-28 Thread Steve Holden

Fabio Natali wrote:
> gearheart wrote:
>   
>> maybe limit_choices_to is what you're looking for
>> i had similar problem and solved with ajax autocomplete widget.
>> 
>
> I haven't yet get rid of those too-much-long inline drop down menus.
>
> I was thinking to use js to open up a window and let the user choose
> from some hyerarchical menu... something like a first drop down menu
> for the category and then a second drop down menu for the real
> product, the latter being properly filtered by category.
>
> Could anyone provide some tips on how to get this?
>
> Thank you so much,
>
>   
The generic solution to this problem is to have a link in your main form
that opens up the sub-window, then have the sub-window (before closing
itself) set an appropriate attribute of its "opener", to set the form
value in the main form. Was that what you wanted?

regards
 Steve



--~--~-~--~~~---~--~~
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: Easiest way to pass django documentation from rest to HTML?

2008-10-28 Thread Steve Holden

Mr. Z wrote:
> Which is the easiest way to pass the new django documentation from
> rest to HTML?
>
> Thank you,
>
>   
I believe you will find a makefile that drives the Sphinx tool in the
docs subdirectory. The command "make html" will create HTML
documentation in docs/_build/html.

regards
 Steve


--~--~-~--~~~---~--~~
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: Filtering QuerySet (exclude)

2008-10-28 Thread janedenone

Hi,

On 28 Okt., 10:56, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Oct 28, 9:33 am, janedenone <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > I need to exclude certain elements from a QuerySet. My models look
> > like this (simplified):
>
> > class Author(models.Model):
> >         first_name = models.CharField(max_length=90, blank=True)
> >         last_name = models.CharField(max_length=90, blank=True)
>
> > class Page(models.Model):
> >         author = models.ForeignKey(Author)
> >         mother = models.ForeignKey('self', blank=True, null=True,
> > related_name='child_set')
>
> > For each author, I need to get the set of pages representing all top-
> > level works by that author (so I don't need the chapters, sections
> > etc.). I guess the solution looks something:
>
> > def _get_top_level_children(self):
> >         return self.page_set.exclude(author=mother.author)
> > top_level_children = property(_get_top_level_children)
>
> > Obviously, it does not work like this. How can I limit the queryset to
> > all entries where the 'author' object of a page does not match the
> > 'author' object of the page's 'mother' object?
>
> > Kind regards,
> > Jan
>
> Well the only thing wrong with your code is you need a self in there -
> author=self.mother.author

Many thanks, but the method above is a method of Author objects, so
self refers to the current author. I need to get all elements (pages)
written by that author if (and only if) the parent page has a
different author. The literal SQL would be something like:

SELECT pages.id, pages.author_id, motherpages.author_id AS
motherauthor
FROM pages, pages AS motherpages
WHERE motherpages.page_id = pages.mother_id
AND pages.author_id = 1234
AND pages.author_id <> motherpages.author_id

> But I wouldn't do it like that. If you just want all top-level Page
> objects, you could do
> Page.objects.filter(mother__isnull=True)
>
> and if you want all top-level Pages belonging to a particular author,
> it would be
> author.page_set.filter(mother__isnull=True)

Sorry, that was misleading – I need all pages heading a sub-tree
written by the same author. These pages are not necessarily top-level
pages.

>
> (BTW in English we would usually say 'parent' rather than 'mother'...)

Thanks – the name "mother" was chosen for historical reasons.

Cheers,
Jan
--~--~-~--~~~---~--~~
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.pl has been officially launched

2008-10-28 Thread Dominik Szopa



On 26 Paź, 18:01, Marek Kubica <[EMAIL PROTECTED]> wrote:
> On Sun, 26 Oct 2008 06:32:11 -0700, Dominik Szopa wrote:
> > Django Polish community site -http://www.django.plhas been officially
> > launched.
>
> I just took a look - the design is definitely good. The examples of
> polish sites using Django are also a good idea.

We also have there English sites, the one is  curce.com, but recently
heared that they are not powered by Django any more, anybody knows if
thats true ?
--~--~-~--~~~---~--~~
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 get the Html representation of forms.Fields

2008-10-28 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-10-28, o godz. 10:07, przez shabda:

> I have some forms.Fields, which are not attached to any forms.Form.
> How can I get the Html representation of it?

Fields are abstract and do not have HTML representations (contrary to  
widgets, which are concrete - their representation can be obtained by  
calling render()).

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R&D, Redefine
[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: edit_inline does not save?

2008-10-28 Thread Daniel Austria

Oh... i m currently using 0.96.2 ...


if not necessary, i ll not migrate to 1.0 ..

:-)
Dan



On 28 Okt., 11:49, Erik Allik <[EMAIL PROTECTED]> wrote:
> Which version of Django are you using? edit_inline is deprecated (or  
> even removed) in Django 1.0. You should be using admin inlines instead.
>
> Erik
>
> On 28.10.2008, at 12:47, Daniel Austria wrote:
>
>
>
> > Hello,
>
> > i got a huge problem. I have got an Idea class and an ideacomment
> > class. You can guess what these classes are used for. What i do is the
> > following:
>
> > - the ideacomment class has an foreignkey
> > - this foreignkey is marked as edit_inline
> > - when i edit an idea instance in the admin i can also add some
> > comments in the same html page
> > - BUT: the comments are not saved  ??
>
> > Strange... what should i try / debugg or look at .
>
> > Dan
>
> > ps. i did not write any views or else... the code below is the whole
> > code i have 
>
> > -- CODE-
>
> > from django.db import models
> > from base.models import Participant
> > from settings import MEDIA_DIR, BASE_DIR
>
> > STATUS_CHOICES = ((1, 'IN_DISCUSSION'), (2, 'ACCEPTED'), (3,
> > 'DONT_KNOW'))
>
> > class Category(models.Model):
> >    Name = models.CharField('Category Name', maxlength=50, core=True)
> >    LastModified = models.DateTimeField('Last Modified', core=True,
> > auto_now = True)
>
> >    def __unicode__(self):
> >        return self.Name
> >    def __str__(self):
> >        return self.__unicode__()
>
> >    class Admin:
> >        list_display = ('Name', 'LastModified')
> >        search_fields = ['Name']
> >        ordering = ['-LastModified']
>
> >    class Meta:
> >        ordering = ['id']
>
> > class IdeaProject(models.Model):
> >    Name = models.CharField('Ideation-Project name', maxlength=50,
> > core=True)
> >    UrlLocation = models.CharField('URL location', maxlength=20,
> > core=True, unique=True)
> >    Active = models.BooleanField('Project active')
> >    Version = models.TextField('A short description', blank=True)
> >    Categories = models.ManyToManyField(Category,
> > related_name='Category', null=True)
> >    Template = models.CharField('Template directory', maxlength=50,
> > core=True, default='ideation')
> >    DefaultLang = models.CharField('Default language', maxlength=2,
> > core=True, default='en')
> >    LastModified = models.DateTimeField('Last Modified', core=True,
> > auto_now = True)
>
> >    def __unicode__(self):
> >        return self.Name
> >    def __str__(self):
> >        return self.__unicode__()
>
> >    class Admin:
> >        list_display = ('Name', 'Active', 'UrlLocation',
> > 'LastModified', 'Version')
> >        search_fields = ['Name']
> >        ordering = ['-LastModified']
>
> >    class Meta:
> >        ordering = ['id']
>
> > class Idea(models.Model):
> >    Header = models.CharField('Header', maxlength=500, core=True)
> >    Text = models.TextField('Description', core=True)
> >    IsParticipant = models.ForeignKey(Participant, null=True)
> >    IsIdeaProject = models.ForeignKey(IdeaProject, null=True)
> >    Categories = models.ManyToManyField(Category,
> > related_name='Categories', null=True)
> >    LastModified = models.DateTimeField('Last Modified', core=True,
> > auto_now = True)
> >    Points = models.IntegerField('Idea points', core=True, default=0)
> >    Status = models.IntegerField('Idea status',
> > choices=STATUS_CHOICES, default=1)
> >    UrlToPic = models.CharField('Url path 2 picture', maxlength=50,
> > blank=True, null=True)
>
> >    def __unicode__(self):
> >        return self.Header
> >    def __str__(self):
> >        return self.__unicode__()
>
> >    class Admin:
> >        list_display = ('Header', 'LastModified', 'IsParticipant')
> >        search_fields = ['Name']
> >        ordering = ['-LastModified']
>
> >    class Meta:
> >        ordering = ['id']
>
> > class IdeaComment(models.Model):
> >    Header = models.CharField('Header', maxlength=500, core=True)
> >    Text = models.TextField('Description', core=True)
> >    IsParticipant = models.ForeignKey(Participant, core=True)
> >    LastModified = models.DateTimeField('Last Modified', core=True,
> > auto_now = True)
> >    IsIdea = models.ForeignKey(Idea, edit_inline=models.STACKED,
> > min_num_in_admin=6, num_extra_on_change=6)
>
> >    def __unicode__(self):
> >        return self.Header
> >    def __str__(self):
> >        return self.__unicode__()
--~--~-~--~~~---~--~~
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: edit_inline does not save?

2008-10-28 Thread Erik Allik

Which version of Django are you using? edit_inline is deprecated (or  
even removed) in Django 1.0. You should be using admin inlines instead.

Erik

On 28.10.2008, at 12:47, Daniel Austria wrote:

>
> Hello,
>
> i got a huge problem. I have got an Idea class and an ideacomment
> class. You can guess what these classes are used for. What i do is the
> following:
>
> - the ideacomment class has an foreignkey
> - this foreignkey is marked as edit_inline
> - when i edit an idea instance in the admin i can also add some
> comments in the same html page
> - BUT: the comments are not saved  ??
>
> Strange... what should i try / debugg or look at .
>
>
> Dan
>
> ps. i did not write any views or else... the code below is the whole
> code i have 
>
> -- CODE-
>
> from django.db import models
> from base.models import Participant
> from settings import MEDIA_DIR, BASE_DIR
>
>
> STATUS_CHOICES = ((1, 'IN_DISCUSSION'), (2, 'ACCEPTED'), (3,
> 'DONT_KNOW'))
>
>
> class Category(models.Model):
>Name = models.CharField('Category Name', maxlength=50, core=True)
>LastModified = models.DateTimeField('Last Modified', core=True,
> auto_now = True)
>
>def __unicode__(self):
>return self.Name
>def __str__(self):
>return self.__unicode__()
>
>class Admin:
>list_display = ('Name', 'LastModified')
>search_fields = ['Name']
>ordering = ['-LastModified']
>
>class Meta:
>ordering = ['id']
>
>
> class IdeaProject(models.Model):
>Name = models.CharField('Ideation-Project name', maxlength=50,
> core=True)
>UrlLocation = models.CharField('URL location', maxlength=20,
> core=True, unique=True)
>Active = models.BooleanField('Project active')
>Version = models.TextField('A short description', blank=True)
>Categories = models.ManyToManyField(Category,
> related_name='Category', null=True)
>Template = models.CharField('Template directory', maxlength=50,
> core=True, default='ideation')
>DefaultLang = models.CharField('Default language', maxlength=2,
> core=True, default='en')
>LastModified = models.DateTimeField('Last Modified', core=True,
> auto_now = True)
>
>def __unicode__(self):
>return self.Name
>def __str__(self):
>return self.__unicode__()
>
>class Admin:
>list_display = ('Name', 'Active', 'UrlLocation',
> 'LastModified', 'Version')
>search_fields = ['Name']
>ordering = ['-LastModified']
>
>class Meta:
>ordering = ['id']
>
>
>
> class Idea(models.Model):
>Header = models.CharField('Header', maxlength=500, core=True)
>Text = models.TextField('Description', core=True)
>IsParticipant = models.ForeignKey(Participant, null=True)
>IsIdeaProject = models.ForeignKey(IdeaProject, null=True)
>Categories = models.ManyToManyField(Category,
> related_name='Categories', null=True)
>LastModified = models.DateTimeField('Last Modified', core=True,
> auto_now = True)
>Points = models.IntegerField('Idea points', core=True, default=0)
>Status = models.IntegerField('Idea status',
> choices=STATUS_CHOICES, default=1)
>UrlToPic = models.CharField('Url path 2 picture', maxlength=50,
> blank=True, null=True)
>
>def __unicode__(self):
>return self.Header
>def __str__(self):
>return self.__unicode__()
>
>class Admin:
>list_display = ('Header', 'LastModified', 'IsParticipant')
>search_fields = ['Name']
>ordering = ['-LastModified']
>
>class Meta:
>ordering = ['id']
>
>
> class IdeaComment(models.Model):
>Header = models.CharField('Header', maxlength=500, core=True)
>Text = models.TextField('Description', core=True)
>IsParticipant = models.ForeignKey(Participant, core=True)
>LastModified = models.DateTimeField('Last Modified', core=True,
> auto_now = True)
>IsIdea = models.ForeignKey(Idea, edit_inline=models.STACKED,
> min_num_in_admin=6, num_extra_on_change=6)
>
>def __unicode__(self):
>return self.Header
>def __str__(self):
>return self.__unicode__()
>
> >


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



edit_inline does not save?

2008-10-28 Thread Daniel Austria

Hello,

i got a huge problem. I have got an Idea class and an ideacomment
class. You can guess what these classes are used for. What i do is the
following:

- the ideacomment class has an foreignkey
- this foreignkey is marked as edit_inline
- when i edit an idea instance in the admin i can also add some
comments in the same html page
- BUT: the comments are not saved  ??

Strange... what should i try / debugg or look at .


Dan

ps. i did not write any views or else... the code below is the whole
code i have 

-- CODE-

from django.db import models
from base.models import Participant
from settings import MEDIA_DIR, BASE_DIR


STATUS_CHOICES = ((1, 'IN_DISCUSSION'), (2, 'ACCEPTED'), (3,
'DONT_KNOW'))


class Category(models.Model):
Name = models.CharField('Category Name', maxlength=50, core=True)
LastModified = models.DateTimeField('Last Modified', core=True,
auto_now = True)

def __unicode__(self):
return self.Name
def __str__(self):
return self.__unicode__()

class Admin:
list_display = ('Name', 'LastModified')
search_fields = ['Name']
ordering = ['-LastModified']

class Meta:
ordering = ['id']


class IdeaProject(models.Model):
Name = models.CharField('Ideation-Project name', maxlength=50,
core=True)
UrlLocation = models.CharField('URL location', maxlength=20,
core=True, unique=True)
Active = models.BooleanField('Project active')
Version = models.TextField('A short description', blank=True)
Categories = models.ManyToManyField(Category,
related_name='Category', null=True)
Template = models.CharField('Template directory', maxlength=50,
core=True, default='ideation')
DefaultLang = models.CharField('Default language', maxlength=2,
core=True, default='en')
LastModified = models.DateTimeField('Last Modified', core=True,
auto_now = True)

def __unicode__(self):
return self.Name
def __str__(self):
return self.__unicode__()

class Admin:
list_display = ('Name', 'Active', 'UrlLocation',
'LastModified', 'Version')
search_fields = ['Name']
ordering = ['-LastModified']

class Meta:
ordering = ['id']



class Idea(models.Model):
Header = models.CharField('Header', maxlength=500, core=True)
Text = models.TextField('Description', core=True)
IsParticipant = models.ForeignKey(Participant, null=True)
IsIdeaProject = models.ForeignKey(IdeaProject, null=True)
Categories = models.ManyToManyField(Category,
related_name='Categories', null=True)
LastModified = models.DateTimeField('Last Modified', core=True,
auto_now = True)
Points = models.IntegerField('Idea points', core=True, default=0)
Status = models.IntegerField('Idea status',
choices=STATUS_CHOICES, default=1)
UrlToPic = models.CharField('Url path 2 picture', maxlength=50,
blank=True, null=True)

def __unicode__(self):
return self.Header
def __str__(self):
return self.__unicode__()

class Admin:
list_display = ('Header', 'LastModified', 'IsParticipant')
search_fields = ['Name']
ordering = ['-LastModified']

class Meta:
ordering = ['id']


class IdeaComment(models.Model):
Header = models.CharField('Header', maxlength=500, core=True)
Text = models.TextField('Description', core=True)
IsParticipant = models.ForeignKey(Participant, core=True)
LastModified = models.DateTimeField('Last Modified', core=True,
auto_now = True)
IsIdea = models.ForeignKey(Idea, edit_inline=models.STACKED,
min_num_in_admin=6, num_extra_on_change=6)

def __unicode__(self):
return self.Header
def __str__(self):
return self.__unicode__()

--~--~-~--~~~---~--~~
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 get site's root url path in Django

2008-10-28 Thread Erik Allik

I don't think you need to even know the root URL as Django takes care  
of this automatically. Check the mod_python documentation for details.  
mod_wsgi and FastCGI deployment methods should take care of this  
transparently.

Erik

On 28.10.2008, at 8:28, yuanyun.ken wrote:

>
> Hi, all great Django users and developers, I have a little problem.
> To make @login_required work,
> I have to configure those in settings.py:
> root_url = '/root_url/'
> LOGIN_URL = root_url + '/login/'
> LOGOUT_URL =  root_url + '/logout/'
>
> But this is obviously not a good idea, as it couples with project's
> root url.
>
> I tried to use:
> LOGIN_URL = '/login/'
> or
> LOGIN_URL = 'login/'
>
> the first can not work, apache would try to access http://localhost/login/ 
> ,
> not http://localhost/root_url/login/
> the second option would not work, when access 
> http://localhost/root_url/dira/pageb 
> ,
> this would lead to access http://localhost/root_url/dira/login
>
> urls.py
> (r'^login/$', 'django.contrib.auth.views.login'),
> (r'^logout/$', 'django.contrib.auth.views.logout')
>
> The following are my configuration in apache's httpd.conf
> Alias /root_url/ D:/ws/django/myproject/
> 
>   SetHandler python-program
>   PythonHandler django.core.handlers.modpython
>   SetEnv DJANGO_SETTINGS_MODULE Regrroot_url.settings
>   PythonOption django.root /root_url
>   PythonDebug On
>   PythonPath "['D:/ws/django/myproject/'] + sys.path"
> Options ExecCGI
> Options +Indexes
> Order allow,deny
> Allow from all
> 
>
> Any help is appreciated, and Thanks in advance.
>
> >


--~--~-~--~~~---~--~~
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: REQ: Help with row-level perms and model (item, user) method problems.

2008-10-28 Thread [EMAIL PROTECTED]

Hi,

Try django-granular-permissions [1]. I've just started working with it
and it is quite nice. I have written a template tag to check user
permissions on an object and I'll be contributing it back to the
project in the next few days so keep an eye on the issues list for a
patch.

[1] http://code.google.com/p/django-granular-permissions/

cheers

Matthew

http://wadofstuff.blogspot.com

On Oct 27, 3:26 am, jfine <[EMAIL PROTECTED]> wrote:
> Hi
>
> I'm now doing serious (for me) work with Django (which I like a lot)
> and have come up against a problem.
>
> My application requires row-level permissions.  I think I've got most
> of it sorted out, but I'm having problems with templates and views.
>
> My basis idea is this.  Add a field
>         edit_groups = models.ManyToManyField(Group)
> which tells us which group members can edit the object.
>
> Then define a method
>     def is_editable_by(self, user):
>         if self.owner.pk == user.pk:
>             return True
>         if self.edit_groups.filter(user=user):
>             return True
>         return False
>
> This allows me to determine if a user can edit the object.
>
> Now for the problem.  In the detail template for the object I'd like
> to know if I can edit the object (so I can offer a link for doing
> that).  I don't see an easier and straightforward way of doing this,
> particularly as I want to continue to use generic views.
>
> The problem is that the request (with .user as an attribute) and the
> item (with .is_editable_by as a method) meet only in the template, and
> not before.  This is, it seems to me, part of the architecture of
> Django.  For example, MIDDLEWARE_CLASSES and
> TEMPLATE_CONTEXT_PROCESSORS are passed only the request object.
>
> By the way, in the list view we'd like to tell the user which are the
> items she can edit, so a single global won't do.
>
> What would work is an 'attribute' of item, so we could write
>     {% if item.is_editable %}
> but we have to know the user to make the calculation.  The best I can
> think of is something like
>    {% get_is_editable as myvar %}
>    {% if myvar %}
> but that's not at all nice.
>
> Here's a couple of related URLs.  FIrst, a discussion in this group
>     Status of pre-object-level 
> permissionshttp://groups.google.com/group/django-users/browse_thread/thread/ad87...
>
> Next, a clever hack
>     Django Admin Hack - Fields varying with user permissions
>    http://lukeplant.me.uk/blog.php?id=1107301634
> referred to by this FAQ 
> entryhttp://docs.djangoproject.com/en/dev/faq/admin/#how-do-i-automaticall...
>
> Does anyone have any ideas or suggestions?  I'd like to do something
> that was aligned with future Django developments.
>
> Jonathan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Filtering QuerySet (exclude)

2008-10-28 Thread Daniel Roseman

On Oct 28, 9:33 am, janedenone <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I need to exclude certain elements from a QuerySet. My models look
> like this (simplified):
>
> class Author(models.Model):
>         first_name = models.CharField(max_length=90, blank=True)
>         last_name = models.CharField(max_length=90, blank=True)
>
> class Page(models.Model):
>         author = models.ForeignKey(Author)
>         mother = models.ForeignKey('self', blank=True, null=True,
> related_name='child_set')
>
> For each author, I need to get the set of pages representing all top-
> level works by that author (so I don't need the chapters, sections
> etc.). I guess the solution looks something:
>
> def _get_top_level_children(self):
>         return self.page_set.exclude(author=mother.author)
> top_level_children = property(_get_top_level_children)
>
> Obviously, it does not work like this. How can I limit the queryset to
> all entries where the 'author' object of a page does not match the
> 'author' object of the page's 'mother' object?
>
> Kind regards,
> Jan

Well the only thing wrong with your code is you need a self in there -
author=self.mother.author

But I wouldn't do it like that. If you just want all top-level Page
objects, you could do
Page.objects.filter(mother__isnull=True)

and if you want all top-level Pages belonging to a particular author,
it would be
author.page_set.filter(mother__isnull=True)

(BTW in English we would usually say 'parent' rather than 'mother'...)
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ifequal and numbers

2008-10-28 Thread Daniel Roseman

On Oct 27, 10:36 pm, "Alfredo Alessandrini" <[EMAIL PROTECTED]>
wrote:
> There is a method for write this, without write a loop:
>
> {%  ifequal  apple.number <20  %}
> ..
> {%  endifequal  %}
>
> Alfredo

On Oct 27, 11:52 pm, "R. Gorman" <[EMAIL PROTECTED]> wrote:
> You would probably be better off writing a custom template tag (http://
> docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-
> template-tags).
>
> R.

Actually a filter would be easier. A filter can return True or False,
so you would just do
def islessthan(var1, var2):
return var1http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: URL handling and porting from 0.96 to 1.0

2008-10-28 Thread Philippe Raoult


For anyone who searches this group, i've just figured that i needed to
use

ur'^fichier_numerique/(?P\d+)/(?P'+REGEX_FICHIER
> +')/$'

so the regex is a unicode object.

I've also noticed that parentheses weren't working anymore (in 0.96 i
could match opening but not closing).

Last but not least, it seems my arguments now arrive url-quoted (ie
%20 instead of space) to my view while this used not to be the case in
0.96. Maybe I was doing something wrong back then (?).

Philippe

On Oct 27, 5:37 pm, Philippe Raoult <[EMAIL PROTECTED]> wrote:
> Thanks for the tip, it indeed worked. I'm now trying to figure out how
> to use exotic characters in my url regex and so far I'm failing.
>
> My 0.96 url file looked like this:
>
> accents = "áâàäãéêèëíîìïóôòöõúûùüçøñÁÂÀÄÉÊÈËÍÎÌÏÓÔÒÖÚÛÙÜÇØÑ¡¿"
> REGEX_FICHIER = "[\w/\-+_,@!%'°&\.#$\[\](} "+accents+']*'
>
>         (r'^fichier_numerique/(?P\d+)/(?P'+REGEX_FICHIER
> +')/$', 'vue_fichier_dossier'),
>
> So far it worked in 0.96, so now i'm just adding 'u' in front of
> accents and REGEX_FICHIER strings but no luck:
> NoReverseMatch: Reverse for ' 0x113bed8>' with arguments '(56650L, u'blah/blih')' and keyword
> arguments '{}' not found.
>
> Has anyone managed to use accented caracters in urls with 1.0.X ?
>
> Regards,
> Philippe
>
> On Oct 18, 1:58 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
> > On Sat, Oct 18, 2008 at 6:10 PM, Philippe Raoult
>
> > <[EMAIL PROTECTED]> wrote:
>
> > > Hello all,
>
> > > I've startingportingmy little app (20k loc) from 0.96 to 1.0 and
> > > I've been hitting a wall of reverse/urlerrors. I haven't seen
> > > anything in theportingwiki page so I'm wondering if anyone has
> > > already encountered similar issues ?
>
> > > I'm seeing stuff like: Reverse for ' > > 0x1ae55f0>' with arguments '(34L,)' and keyword arguments '{}' not
> > > found.
> > > Obviously since the reverse has a function object it imported it
> > > correctly (I provided the view path as a reverse argument). Is there
> > > any change in theurlpatterns not mentionned in theportingwiki page
> > > and worth knowing about ?
>
> > > I'm going to be fiddling with this a bit, if I don't figure it out
> > > I'll post a detailedurlfile...
>
> > It sounds like you may have found a version of ticket #9038. This
> > ticket was fixed in changeset [9087]; if you use a current trunk
> > checkout (or a checkout from the v1.0.X branch), the issue should be
> > resolved.
>
> > Yours,
> > Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Filtering QuerySet (exclude)

2008-10-28 Thread janedenone

Hi,

I need to exclude certain elements from a QuerySet. My models look
like this (simplified):

class Author(models.Model):
first_name = models.CharField(max_length=90, blank=True)
last_name = models.CharField(max_length=90, blank=True)

class Page(models.Model):
author = models.ForeignKey(Author)
mother = models.ForeignKey('self', blank=True, null=True,
related_name='child_set')

For each author, I need to get the set of pages representing all top-
level works by that author (so I don't need the chapters, sections
etc.). I guess the solution looks something:

def _get_top_level_children(self):
return self.page_set.exclude(author=mother.author)
top_level_children = property(_get_top_level_children)

Obviously, it does not work like this. How can I limit the queryset to
all entries where the 'author' object of a page does not match the
'author' object of the page's 'mother' object?

Kind regards,
Jan
--~--~-~--~~~---~--~~
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 get site's root path in Django

2008-10-28 Thread Graham Dumpleton



On Oct 28, 2:24 am, "yuanyun.ken" <[EMAIL PROTECTED]> wrote:
> Hi, all great Django users and developers, I have a little problem.
> To make @login_required work,
> I have to configure those in settings.py:
> root_url = '/root_url/'
> LOGIN_URL = root_url + '/login/'
> LOGOUT_URL =  root_url + '/logout/'
>
> But this is obviously not a good idea, as it couples with project's
> root url.
>
> I tried to use:
> LOGIN_URL = '/login/'
> or
> LOGIN_URL = 'login/'
>
> the first can not work, apache would try to accesshttp://localhost/login/,
> nothttp://localhost/root_url/login/
> the second option would not work, when 
> accesshttp://localhost/root_url/dira/pageb,
> this would lead to accesshttp://localhost/root_url/dira/login
>
> urls.py
> (r'^login/$', 'django.contrib.auth.views.login'),
> (r'^logout/$', 'django.contrib.auth.views.logout')
>
> The following are my configuration in apache's httpd.conf
> Alias /root_url/ D:/ws/django/myproject/
> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE Regrroot_url.settings
>     PythonOption django.root /root_url
>     PythonDebug On
>     PythonPath "['D:/ws/django/myproject/'] + sys.path"
> Options ExecCGI
> Options +Indexes
> Order allow,deny
> Allow from all
> 
>
> Any help is appreciated, and Thanks in advance.

When mounting at sub URL of a site, you shouldn't be adding the mount
point into anything in settings or in urls.py. For mod_python, the
only point you should need to added it is the PythonOption setting for
django.root. Thus, your settings for LOGIN_URL and LOGOUT_URL were
wrong when you were including root url in them.

Do note though that mounting at a sub URL possibly only works properly
if using Django 1.0, so make sure you aren't using an older version of
Django.

Graham

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



How to get the Html representation of forms.Fields

2008-10-28 Thread shabda

I have some forms.Fields, which are not attached to any forms.Form.
How can I get the Html representation of it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Foreign key with tons of items

2008-10-28 Thread Fabio Natali

gearheart wrote:
> maybe limit_choices_to is what you're looking for
> i had similar problem and solved with ajax autocomplete widget.

I haven't yet get rid of those too-much-long inline drop down menus.

I was thinking to use js to open up a window and let the user choose
from some hyerarchical menu... something like a first drop down menu
for the category and then a second drop down menu for the real
product, the latter being properly filtered by category.

Could anyone provide some tips on how to get this?

Thank you so much,

-- 
Fabio Natali


--~--~-~--~~~---~--~~
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: Getting a NameError: global name 'Lesson' is not defined

2008-10-28 Thread bruno desthuilliers

On 28 oct, 08:54, Daniel Strasser <[EMAIL PROTECTED]> wrote:
> Hi Daniel
>
> > This is why it's a bad idea to do from x import *. You should always
> > import the things you need explicitly, then you can tell what's going
> > wrong. Try doing
> > from schoolutil.lesson.models import Lesson
> > and see if it still goes wrong - or if you get a more informative
> > error message.
>
> Thanks for your tip. I've done this, now I'm getting the following
> error when I try to start the built-in development server:
>
> [EMAIL PROTECTED]:~/work/schoolutil$ python manage.py runserver
> Validating models...
> could not import in lesson.models
(snip)
> File "/home/daniel/work/schoolutils/../schoolutils/student/
> models.py", line 3, in 
> from schoolutils.lesson.models import Lesson
>   File "/home/daniel/work/schoolutils/lesson/models.py", line 7, in
> 
> class Lesson(models.Model):
>   File "/home/daniel/work/schoolutils/lesson/models.py", line 8, in
> Lesson
> student = models.ForeignKey(Student)
> NameError: name 'Student' is not defined

You have a circular reference between students.models and
lessons.models. The first want to import the second, which want to
import the first, etc... This just can't work.

--~--~-~--~~~---~--~~
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: web 2.0 apps with django

2008-10-28 Thread Artis Caune
On Tue, Oct 28, 2008 at 10:20 AM, 王晓 <[EMAIL PROTECTED]> wrote:
> how can i get the "Learning Website Development with Django"?
> can you give me a link?

Google can give you a link, just search for:
  "Learning Website Development with Django.pdf"




-- 
regards,
Artis Caune

<. CCNA | BSDA
<|
<' didii FreeBSD

--~--~-~--~~~---~--~~
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: web 2.0 apps with django

2008-10-28 Thread 王晓
how can i get the "Learning Website Development with Django"?
can you give me a link?

2008/10/28 Artis Caune <[EMAIL PROTECTED]>

>
> On Mon, Oct 27, 2008 at 9:36 PM, Ravi Kondamuru <[EMAIL PROTECTED]>
> wrote:
> > Hi,
> > Is there any simple app/ tutorial to understand web 2.0 application
> > development with django?
>
> Check "Learning Website Development with Django".
> You will learn how to build a bookmarking application and there is one
> nice chapter for web 2.0.
>
>
>
>
> --
> regards,
> Artis Caune
>
> <. CCNA | BSDA
> <|
> <' didii FreeBSD
>
> >
>

--~--~-~--~~~---~--~~
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: web 2.0 apps with django

2008-10-28 Thread Artis Caune

On Mon, Oct 27, 2008 at 9:36 PM, Ravi Kondamuru <[EMAIL PROTECTED]> wrote:
> Hi,
> Is there any simple app/ tutorial to understand web 2.0 application
> development with django?

Check "Learning Website Development with Django".
You will learn how to build a bookmarking application and there is one
nice chapter for web 2.0.




-- 
regards,
Artis Caune

<. CCNA | BSDA
<|
<' didii FreeBSD

--~--~-~--~~~---~--~~
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: Getting a NameError: global name 'Lesson' is not defined

2008-10-28 Thread Daniel Strasser

Hi Daniel

> This is why it's a bad idea to do from x import *. You should always
> import the things you need explicitly, then you can tell what's going
> wrong. Try doing
> from schoolutil.lesson.models import Lesson
> and see if it still goes wrong - or if you get a more informative
> error message.

Thanks for your tip. I've done this, now I'm getting the following
error when I try to start the built-in development server:

[EMAIL PROTECTED]:~/work/schoolutil$ python manage.py runserver
Validating models...
could not import in lesson.models
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/core/management/
commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 122, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 128, in get_app_errors
self._populate()
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "/home/daniel/work/schoolutils/../schoolutils/student/
models.py", line 3, in 
from schoolutils.lesson.models import Lesson
  File "/home/daniel/work/schoolutils/lesson/models.py", line 7, in

class Lesson(models.Model):
  File "/home/daniel/work/schoolutils/lesson/models.py", line 8, in
Lesson
student = models.ForeignKey(Student)
NameError: name 'Student' is not defined
--~--~-~--~~~---~--~~
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: Template syntax question

2008-10-28 Thread Daniel Roseman

On Oct 27, 10:04 pm, Robocop <[EMAIL PROTECTED]> wrote:
> So i'm looking to have an admin controlled news list, and one thing in
> particular i'd like them to be able to control is how many headlines
> are shown on the front page, and my current code is not doing that.
>
> The line i care about is:
>
>         {% for New in news_list|slice:":{{limit}}"%}
>
> where limit is some admin controlled variable that i'm certain is an
> integer.  Is this possible?  Or is there just some error in my code
> somewhere  that i have not seen?  Thanks!

You can't nest tags like that.

There are various options - have you tried defining a string in your
view which is ":" + limit, and passing that to the template? Or
perhaps limiting news_list in your view?

Or, you could define a custom filter which takes a value and returns a
list sliced to that length. Something like (untested):
def slice_to_var(lst, lngth):
return lst[:lngth]
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting a NameError: global name 'Lesson' is not defined

2008-10-28 Thread Daniel Roseman

On Oct 28, 7:32 am, Daniel Strasser <[EMAIL PROTECTED]>
wrote:
> Hello Djangonauts,
>
> I get a NameError and I don't know why, I'm really getting mad. What I
> want to do is to list the number of Lessons a Student has passed.
>
> My schoolutil/student model looks like this:
>
> from django.db import models
> from schoolutil.lesson.models import *
>

>
>         def LessonHours(self):
>                 l = Lesson.objects.all()
>                 return
> len(Lesson.objects.filter(student__email__exact='[EMAIL PROTECTED]'))
>
> I'm getting the following error:
> File "/home/daniel/work/schoolutil/../schoolutil/student/models.py",
> line 28, in LessonHours
>     l = Lesson.objects.all()
> NameError: global name 'Lesson' is not defined
>
> But I _did_ import that (second line of the model). I also tried it
> with try...except, and there is no exception when importing
> schoolutil.lesson.models. Please note that the object filter in
> LessonHours() is not correct. For testing, I've hardcoded an email
> address.
>
> What am I doing wrong?


Well, does your lesson.models file definitely define a class called
Lesson?

This is why it's a bad idea to do from x import *. You should always
import the things you need explicitly, then you can tell what's going
wrong. Try doing
from schoolutil.lesson.models import Lesson
and see if it still goes wrong - or if you get a more informative
error message.

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



Re: web 2.0 apps with django

2008-10-28 Thread 王凯王凯
 aggua.com  haokanbu.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
-~--~~~~--~~--~--~---



Getting a NameError: global name 'Lesson' is not defined

2008-10-28 Thread Daniel Strasser

Hello Djangonauts,

I get a NameError and I don't know why, I'm really getting mad. What I
want to do is to list the number of Lessons a Student has passed.

My schoolutil/student model looks like this:

from django.db import models
from schoolutil.lesson.models import *

class Student(models.Model):
first_name = models.CharField('Vorname', max_length=30)
last_name = models.CharField('Name', max_length=30)
username = models.CharField('Benutzername', max_length=15,
unique=True)
password = models.CharField('Passwort', max_length=15)
active = models.BooleanField('Aktiv?')
street = models.CharField('Strasse', max_length=30)
street2 = models.CharField('Zusatz zur Strasse', max_length=30,
blank=True)
zip = models.CharField('PLZ', max_length=8)
city = models.CharField('Ort', max_length=30)
phonenumber = models.CharField('Telefonnummer', max_length=15)
email = models.EmailField('E-Mail', max_length=30)

def __unicode__(self):
return self.first_name + ' ' + self.last_name

def fullName(self):
return '%s %s' % (self.first_name, self.last_name)

def LessonHours(self):
l = Lesson.objects.all()
return
len(Lesson.objects.filter(student__email__exact='[EMAIL PROTECTED]'))

I'm getting the following error:
File "/home/daniel/work/schoolutil/../schoolutil/student/models.py",
line 28, in LessonHours
l = Lesson.objects.all()
NameError: global name 'Lesson' is not defined

But I _did_ import that (second line of the model). I also tried it
with try...except, and there is no exception when importing
schoolutil.lesson.models. Please note that the object filter in
LessonHours() is not correct. For testing, I've hardcoded an email
address.

What am I 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
-~--~~~~--~~--~--~---



Re: Model that calls a function in another model

2008-10-28 Thread Michael Meier

Hi Karen

> You might want to read this section of the docs:
> http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects

Thank you very much, that helped.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---