Re: Pinax: worth installing?

2011-01-18 Thread Gath
Magee,

Wow! Now thats what we call a response.

You made me understand this subject more.

Thanks a lot Magee.

Gath.

On Jan 18, 5:32 pm, Russell Keith-Magee 
wrote:
> On Tue, Jan 18, 2011 at 9:43 PM, Cal Leeming [Simplicity Media Ltd]
>
>  wrote:
> > I would be interested to hear from anyone who has used Pinax in production.
> > Although I am discouraged by the maturity (only 2 years old?), it does seem
> > to contain some useful features.
> > Personally, I would have liked to have seen some of these features merged
> > into the Django core, rather than forked into a separate project, but that's
> > just me.
>
> I think we need to clear up some misconceptions here.
>
> Pinax isn't a "fork" of Django. That would be like saying Zope is a
> "fork" of Python. It isn't a fork - one is a tool built using the
> facilities provided by the other.
>
> Django is a low level tool. It provides the essentials to route HTTP
> requests to views, and return responses. Django doesn't mandate what
> you build, or how you build it, or the right apps for the job. Django
> only specifies something when it's clearly in the interest of all (or
> at least, most) web developers to  -- thus, Django provides a Forms
> framework, a template rendering system, and a Sessions framework.
>
> However, there are many things that Django *doesn't* have an opinion
> on. For example, there are many ways to implement tagging. There are
> many tagging applications available. Depending on your circumstances,
> one implementation might be better than another. So Django doesn't
> ship with a tagging app -- it's up to end users to find a tagging app
> that meets their needs.
>
> There are some exceptions to this rule. For example, the auth
> framework isn't as good as it could be, and not every website has a
> need for comments. However, the broad principle stands -- Django isn't
> trying to provide every tool for every possible web job.
>
> Pinax, on the other hand, works at a higher level. Pinax targets a
> specific domain -- social web apps -- and as a result, they *are* in a
> position to be opinionated about the best way to do tasks like
> tagging. They haven't done this by "forking" Django. They have taken
> Django, and the wide community of available apps, and selected a
> subset of apps that complement each other, integrate well together,
> and are appropriate for their target class of websites. Pinax is more
> like a meta-packaging framework for Django apps. Every Pinax site has,
> at it's core, a completely vanilla Django install.
>
> And, to follow up on the criticism/wish -- elements of Pinax *have*
> made it back to Django. For example, the static files framework that
> will be in Django 1.3 started life as an external app, and proved
> itself to be a useful tool due, in part, to being a recommended part
> of Pinax installs.
>
> So - you really don't have to make a "Pinax or Django" decision. Any
> app that can be installed in a Django site can also be installed in a
> Pinax site, and every Pinax site is a Django site.
>
> As for the original question -- are there any drawbacks? Well, not
> really. Pinax suggests a particular collection of apps, but you can
> use any other app you want in parallel. Pinax mandates a few standards
> for project layout and the like, but for the most part, they're just
> using the best practices commonly understood by experienced members of
> the Django community, but the Django project itself hasn't gone to the
> trouble of formalizing.
>
> About the only potential downside I can see is that If you're not
> building something in Pinax's sweet spot -- i.e., a social web site --
> you won't get all the benefits that Pinax has to offer. If you're
> building something *really* different, you might find that Pinax's
> conventions obstruct you in ways that a raw Django install wouldn't.
> However, for most "websitey" websites, this won't be an issue --
> Pinax's conventions are, for the most part, a bunch of practices that
> you should probably be following anyway -- Pinax just forces/provides
> the tools to help you to follow them :-)
>
> 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



adding fields into another apps forms (in plugin style)

2011-01-18 Thread Michael Buckley
I have been looking at the docs, but so far I can't find anything to help.  
I am looking to set up some kind of plugin system, so for example I set up 
my base user registration form, then I might have another app that when 
added to INSTALLED_APPS automatically adds fields into that form.

Been looking in django for a way of easily injecting those extra fields into 
the form, but I can't find anything.  Is there?  Or do I need to write my 
own system?

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



Re: Django API efficient enough for filtering tens of millions of records?

2011-01-18 Thread Nick Arnett
On Tue, Jan 18, 2011 at 12:04 PM, Sithembewena Lloyd Dube  wrote:

> Hi all,
>
> I am building a search app. that will query an API. The app. will also
> store search terms in a very simple table structure.
>
> Big question: if the app. eventually hit 10 million searches and I was
> storing every single search term, would the table hold or would I run into
> issues?


As someone else said, 10 million records is no big deal for MySQL, in
principle.

However, you probably would do better to avoid all the overhead of a
database transaction for storing each of these.  I'm going to assume that
there will be duplicates, especially if you normalize the queries.  It would
make a lot more sense to log the queries into a text file, which has
extremely low overhead.  Then you'd periodically process the log files,
normalizing and eliminating duplicates, producing a bulk insert to load into
the database.  Bulk inserts will be FAR more efficient than using Django.

Nick

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



Re: Django API efficient enough for filtering tens of millions of records?

2011-01-18 Thread Russell Keith-Magee
On Wed, Jan 19, 2011 at 4:04 AM, Sithembewena Lloyd Dube
 wrote:
> Hi all,
>
> I am building a search app. that will query an API. The app. will also store
> search terms in a very simple table structure.
>
> Big question: if the app. eventually hit 10 million searches and I was
> storing every single search term, would the table hold or would I run into
> issues?
>
> Also, is it "ok" to check if each search query exists or not while I save
> it, so I can update it's count (times searched), or should I rather forget
> that and do the counts in a custom reporting function/ sql query?
>
> I am kind of worried that the Django database API is may not deal with all
> these too gracefully. NB - I am not cool with tinkering with models
> (especially not object relationships) too much when I have to maintain this
> in a year or two.
>
> I guess I am learning about proper database schema design.

Django won't be a the constraining factor here. Django's ORM is a
relatively light wrapper around SQL. So the real question is "can you
create a 10 million row database with SQL"?

The answer is "of course you can... but".

If you've done everything right -- good schema design, index use
appropriate to your queries, and so on -- then 10 million rows won't
pose a major problem.

However, it's also fairly easy to set up a 10 million row table that
you *can't* search efficiently.

Using Django doesn't change anything in this equation -- it just
composes the query and wraps the result.

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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to plug in Python: CGI

2011-01-18 Thread Graham Dumpleton


On Wednesday, January 19, 2011 12:52:14 AM UTC+11, tonton wrote:
>
> now it is seems to be mod_wsgi 
>
> in apache/conf.d/ yoursite.conf 
>
>  WSGIScriptAlias / /path/to/your/djangoproject/wsgi_handler.py
>
>WSGIDaemonProcess djangoproject user=CCC group=CCC processes=5 
> threads=1
>WSGIProcessGroup djangoproject  
>

They are on Windows so they can't use mod_wsgi daemon mode.

The best choice for Python web hosting would be not to use Windows in the 
first place. ;-)

Graham
 

> and had to write an wsgi_handler in djangoproject root where you have 
> settings.py like 
>
> import sys
> import os
> sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'Djangoproject.settings'
>
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> things to replace DjangoProject by the name of your project ! 
> / is your web root 
> so no other path will work instead  you add an alias for apache
>
> Alias /aOtherPath/ /taget/to/a/OtehrPater/
>
> tonton
>
> On Tue, Jan 18, 2011 at 2:22 PM, ashdesigner  wrote:
>
>> Hello,
>>
>> On my VPS, I've got Apache running on MS Windows Server 2008 R2. What
>> is the best way you suggest to plug in Python to be used in a
>> relatively highly loaded webproject (on Django)? mod_python,
>> fastCGI?... What are advantages and drawbacks, from your real
>> experience? I'm new to both Python and Django, so I would appreciate
>> how-tos as well (particular urls to faqs/docs will do, of course).
>>
>> Thanks,
>> Anthony
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



len(qs.all()) != qs.count()

2011-01-18 Thread mack the finger
>>> p=EtilizeProduct.objects.all().using('etilize')[23424]
>>> p.productdescription_set.all()
[]
>>> p.productdescription_set.count()
4

Does anybody have any idea why count() returns 4, but all() returns an empty 
list? I'm not using any custom routers.

>>> str(p.productdescription_set.all().query)
'SELECT "productdescriptions"."id", "productdescriptions"."productid", 
"productdescriptions"."description", "productdescriptions"."isdefault", 
"productdescriptions"."type", "productdescriptions"."
localeid" FROM "productdescriptions" WHERE "productdescriptions"."productid" 
= 1015433472 '

When I try to enter that command into a dbshell, I get a syntax error. If I 
remove the quotation marks, I'll get the 4 results:

$ ./manage.py dbshell --database etilize
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 269
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input 
statement.

mysql> SELECT "productdescriptions"."id", "productdescriptions"."productid", 
"productdescriptions"."description", "productdescriptions"."isdefault", 
"productdescriptions"."type", "productdescriptions"."localeid" FROM 
"productdescriptions" WHERE "productdescriptions"."productid" = 1011081147;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual 
that corresponds to your MySQL server version for the right syntax to use 
near '."id", "productdescriptions"."productid", 
"productdescriptions"."description", "' at line 1
mysql> SELECT "productdescriptions".* FROM "productdescriptions" WHERE 
"productdescriptions"."productid" = 1011081147;ERROR 1064 (42000): You have 
an error in your SQL syntax; check the manual that corresponds to your MySQL 
server version for the right syntax to use near '.* FROM 
"productdescriptions" WHERE "productdescriptions"."productid" = 10110811' at 
line 1
mysql> SELECT productdescriptions.* FROM productdescriptions WHERE 
productdescriptions.productid = 1011081147;
+++---+--+--+
| productid  | description   
 | isdefault | 
type | localeid |
+++---+--+--+
| 1011081147 | Symantec (10888497) Software Licensing   
  | 0 | 
   0 |1 |
| 1011081147 | Symantec VERITAS Storage Foundation v.5.0 Enterprise HA for 
DB2 Crossgrade License - Government - 1 Server - Price Level S | 1 | 
   1 |1 |
| 1011081147 | Symantec VERITAS Storage Foundation v.5.0 Enterprise HA for 
DB2| 0 | 
   2 |1 |
| 1011081147 | Crossgrade License - Government - 1 Server - Price Level S   
  | 0 | 
   3 |1 |
+++---+--+--+
4 rows in set (0.12 sec)

mysql> Bye

What could be causing 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django API efficient enough for filtering tens of millions of records?

2011-01-18 Thread Sithembewena Lloyd Dube
Hi all,

I am building a search app. that will query an API. The app. will also store
search terms in a very simple table structure.

Big question: if the app. eventually hit 10 million searches and I was
storing every single search term, would the table hold or would I run into
issues?

Also, is it "ok" to check if each search query exists or not while I save
it, so I can update it's count (times searched), or should I rather forget
that and do the counts in a custom reporting function/ sql query?

I am kind of worried that the Django database API is may not deal with all
these too gracefully. NB - I am not cool with tinkering with models
(especially not object relationships) too much when I have to maintain this
in a year or two.

I guess I am learning about proper database schema design.

PS - I know this is not a MySQL mailing list, but there are people here who
have solved the sort of problem I describe, in Django + MySQL.

Thanks.

-- 
Regards,
Sithembewena Lloyd Dube

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



Re: Problem with overriding the default Django admin page.

2011-01-18 Thread Jiten Singh
Hi,

I am sending my project file details ... Hope this helps

*Project Hierarchy*

mysite/
   |--->/templates/
   |   |--->/books/(another app like dateapp)
   |   |-->/dateapp/
   |   |  |>*current_datetime.html*
   |   |  |>*hours_ahead.html*
   |   |-->*base.html*
   |
   |--->*settings.py*

*current_datetime.html*

{% extends "base.html" %}

{% block title %}The current time{% endblock %}

{% block content %}
It is now {{ current_date }}.
{% endblock %}

---
my projects settings file TEMPLATE_DIR

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


I my case template inheritance works quite fine. [?]


It is usually not recommended to meddle with admin app of django.

I hope instead of giving the path of the file in admin app, if you copy that
file (your base.html) in you project's template dir , it may help



On Tue, Jan 18, 2011 at 8:34 AM, Mike Dewhirst wrote:

> On 18/01/2011 1:59pm, Mike Dewhirst wrote:
>
>> This is what I do ...
>>
>> in settings.py
>>
>> # this is the directory containing settings.py
>> PROJECT_DIR = os.path.realpath(os.path.dirname(__file__))
>>
>> # if templates are not found here look in app_name/templates
>> TEMPLATE_DIRS = (os.path.join(PROJECT_DIR, 'templates/'),)
>>
>> This makes my templates directory a sub-dir of the project dir and
>> inside that there are other sub-dirs one for each app and one for the
>> admin.
>>
>> I don't really need one for the admin because django knows where the
>> admin templates live inside the django tree.
>>
>> However, there is one admin template I override so that I can
>> personalise the admin. That is called base_site.html. It is ...
>>
>> PROJECT_DIR/templates/admin/base_site.html
>>
>> It is the only admin template I change
>>
>
>
> AND it is the only template in my PROJECT_DIR/templates/admin directory.
>
>
>
> and it only contains ...
>
>>
>> {% extends "admin/base.html" %}
>> {# admin/base.html is in
>> site-packages/django/contrib/admin/templates/admin #}
>> {% load i18n %}
>> {% block title %}{{ title }} | {% trans 'My site admin' %}{% endblock %}
>>
>> {% block branding %}
>> {% trans 'My administration' %}
>> {% endblock %}
>>
>> Note the comment which indicates that it inherits from the django tree
>> of admin templates.
>>
>> How does django know to look at my base_site.html while it is processing
>> the django tree of templates?
>>
>> The answer is simple and can be found in your settings.py file here ...
>>
>> TEMPLATE_LOADERS = (
>> 'django.template.loaders.filesystem.Loader',
>> 'django.template.loaders.app_directories.Loader',
>> )
>>
>> If the filesystem loader is ahead of the app_directories loader, django
>> looks in your project templates before its own. Here is the doc
>> reference ...
>>
>> http://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
>>
>> Hope this helps
>>
>> Mike
>>
>>
>>
>>
>> On 18/01/2011 12:26pm, Chen Xu wrote:
>>
>>> I did try this, and I tried again, but it still doesn't work.
>>> Do I need to do something extra like quit the server, and restart again?
>>> By the way I did try this too.
>>>
>>> Now, I am totally lost.
>>>
>>> Thanks
>>>
>>> On Mon, Jan 17, 2011 at 3:17 AM, Vovk Donets >> > wrote:
>>>
>>> You must specify in the TEMPLATE_DIRS path to the dir where
>>> templates were placed, not abs path file
>>> So
>>> TEMPLATE_DIRS = (
>>> "/Users/xuchen81/Django/mysite/",
>>>
>>> )
>>> should work, coz' "In order to override one or more of them, first
>>> create an admin directory in your project's templates directory.
>>> This can be any of the directories you specified in TEMPLATE_DIRS
>>> <
>>> http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATE_DIRS
>>> >."
>>>
>>>
>>> 2011/1/17 Chen Xu >
>>>
>>> Hi, Django group:
>>> I am floowing the tutorial 1 on Django site, which is a poll
>>> application
>>> I have problem with overriding the admin page
>>> I copied admin/base_site.html from
>>> (django/contrib/admin/templates) to
>>> /Users/xuchen81/Django/mysite/admin/base_site.html
>>>
>>> and add this line
>>> "/Users/xuchen81/Django/mysite/admin/base_site.html"
>>> to TEMPLATE_DIRS in my settings.py file. It looks like the
>>> following:
>>>
>>> TEMPLATE_DIRS = (
>>> "/Users/xuchen81/Django/mysite/admin/base_site.html",
>>> )
>>>
>>> but the admin is just doesn't use this file, it still uses the
>>> default base_site.html.
>>>
>>> Could anyone please help me?
>>>
>>> --
>>> *Vovk Donets*
>>> python/django 

Re: How to plug in Python: CGI

2011-01-18 Thread ashdesigner
Ok, thank you, will try to handle it))

On Jan 18, 4:52 pm, Tonton  wrote:
> now it is seems to be mod_wsgi
>
> in apache/conf.d/ yoursite.conf
>
>  WSGIScriptAlias / /path/to/your/djangoproject/wsgi_handler.py
>
>        WSGIDaemonProcess djangoproject user=CCC group=CCC processes=5
> threads=1
>        WSGIProcessGroup djangoproject
>
> and had to write an wsgi_handler in djangoproject root where you have
> settings.py like
>
> import sys
> import os
> sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'Djangoproject.settings'
>
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> things to replace DjangoProject by the name of your project !
> / is your web root
> so no other path will work instead  you add an alias for apache
>
> Alias /aOtherPath/ /taget/to/a/OtehrPater/
>
> tonton
>
> On Tue, Jan 18, 2011 at 2:22 PM, ashdesigner wrote:
>
> > Hello,
>
> > On my VPS, I've got Apache running on MS Windows Server 2008 R2. What
> > is the best way you suggest to plug in Python to be used in a
> > relatively highly loaded webproject (on Django)? mod_python,
> > fastCGI?... What are advantages and drawbacks, from your real
> > experience? I'm new to both Python and Django, so I would appreciate
> > how-tos as well (particular urls to faqs/docs will do, of course).
>
> > Thanks,
> > Anthony
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.> To post to this group, send email 
> > todjango-us...@googlegroups.com.
> > To unsubscribe from this group, send email 
> > to>django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: 404 view -> redirect to index

2011-01-18 Thread natebeacham
Thomas: That is what he has.

Make sure you turn DEBUG off. Your custom 404 handler will only be
used when you are not in debug mode.

Cheers

On Jan 18, 5:10 am, Thomas  wrote:
> The book "The definitive Guide to Django" says on page 476:
>
> ---8<---
>
> ... if you want to override the 404 view, you can specify 'handler404' in 
> your URLconf, like so:
>
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns ('',
> ...
> )
>
> handler404 = 'mysite.views.my_custom_404_view'
>
> Behind the scenes ...
>
> ---8<---
>
> hope this helps,
>
> good luck,
> TR
>
> Am 18.01.2011 um 13:42 schrieb Ivo Brodien:
>
>
>
>
>
>
>
> > I guess that django catches the 404 Error Code somehow somewhere else than 
> > in the handler? Maybe you have to set the HTTP Code to 200?
>
> > On 18.01.2011, at 13:35, galago wrote:
>
> >> Yes I have a index pattern:
> >> urlpatterns = patterns('',
> >>     url(r'^$', 'index.views.index', name='index'),...
>
> >> When I add print to my method:
> >> def custom404(request):
> >>     print 'foo'
> >>     return HttpResponseRedirect(reverse('index'))
>
> >> It prints out but it doesn't redirect me to index. Instead it displays my 
> >> 404.html page.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to 
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



Re: forms, hidden fields

2011-01-18 Thread Brian Neal
On Jan 18, 8:32 am, niall-oc  wrote:
> ...
> There is a simple form.  My question is how do you set a field to be
> hidden.
>
> http://docs.djangoproject.com/en/1.1/topics/forms/#looping-over-the-f...
>
> This document explains how you may check if a field is hidden, however
> there seems to be no information on how to initially set the field to
> be hidden. I've tried adding hidden=True and is_hidden=True to the
> above class but to no avail.
>
> Any help would be really appreciated

Hi - please see the docs on form widgets and how you can change out a
form field's default widget:

http://docs.djangoproject.com/en/1.2/ref/forms/widgets/
http://docs.djangoproject.com/en/1.2/ref/forms/widgets/#specifying-widgets

I suspect you'll want to specify a HiddenInput widget for one or more
of your form fields.

Best,
BN

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



Re: Change CSS file in base template depending on browser

2011-01-18 Thread mongoose
Thanks guys. Just saw this in the admin contrib pages too:D win!

On Jan 18, 7:36 pm, Dave Sayer  wrote:
> +1 for conditional comments. They're what all the cool kids are using these
> days.
> On 18 Jan 2011 15:00, "Michel Thadeu Sabchuk"  wrote:
>
> > Hi,
>
> >> I have 2 css files. One specifically for IE because it's so horrible.
> >> I'd like to load either or css files depending on the browser.
>
> > Why don't you use conditional comments?
>
> >http://www.quirksmode.org/css/condcom.html
>
> > Best regards,
>
> > --
> > Michel Sabchuk
>
> > --
> > You received this message because you are subscribed to the Google Groups
>
> "Django users" group.> To post to this group, send email to 
> django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
>
> django-users+unsubscr...@googlegroups.com
> .> For more options, visit this group at
>
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Change CSS file in base template depending on browser

2011-01-18 Thread Dave Sayer
+1 for conditional comments. They're what all the cool kids are using these
days.
On 18 Jan 2011 15:00, "Michel Thadeu Sabchuk"  wrote:
> Hi,
>
>> I have 2 css files. One specifically for IE because it's so horrible.
>> I'd like to load either or css files depending on the browser.
>
> Why don't you use conditional comments?
>
> http://www.quirksmode.org/css/condcom.html
>
> Best regards,
>
> --
> Michel Sabchuk
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: template tag arithmetic

2011-01-18 Thread niall-oc
http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#add

There is loop.counter and loop.counter0. loop.counter starts from 1,
and loop.counter0 starts from 0.  The 3rd time through a for loop
loop.counter is 3 and loop.counter0 is 2.

If you want to add things try something like this:

{{ value|add:"2" }}

if value was 3 then 5 would be output.



On Jan 18, 1:53 pm, GD  wrote:
> Hi everyone,
>      Is there a way to do simple loop counter manipulation within the
> template? I.e something along the lines of:
>
> {% for x in a %}
>       loop number = {{forloop.counter +1}}
> {% endfor %}
>
> with the intention of
>
> 2
> 3
> 4
> 
>
> as output. I realise the above doesn't work, but is there any scope
> for this sort of thing within the templating language itself?
>
> Regards,
> G

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



forms, hidden fields

2011-01-18 Thread niall-oc
class VerificationForm(forms.Form):
domain = forms.CharField(max_length=100,
label='Domain name',
help_text='This is the domain name you chose
during the signup process',
)
mobile_number = forms.CharField(max_length=10,
label='Domain name',
help_text='This is the mobile number you chose
during the signup process',
)
verification_code = forms.CharField(max_length=10,
label='Domain name',
help_text='This is the verification code you
received in your SMS message',
)

There is a simple form.  My question is how do you set a field to be
hidden.

http://docs.djangoproject.com/en/1.1/topics/forms/#looping-over-the-form-s-fields

This document explains how you may check if a field is hidden, however
there seems to be no information on how to initially set the field to
be hidden. I've tried adding hidden=True and is_hidden=True to the
above class but to no avail.

Any help would be really appreciated

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



Re: template tag arithmetic

2011-01-18 Thread Łukasz Rekucki
On 18 January 2011 15:46, Konrad Delong  wrote:
> On 18 January 2011 15:02, Thomas  wrote:
>>
>> Am 18.01.2011 um 14:53 schrieb GD:
>>
>>>
>>> Hi everyone,
>>>     Is there a way to do simple loop counter manipulation within the
>>> template? I.e something along the lines of:
>>>
>>> {% for x in a %}
>>>      loop number = {{forloop.counter +1}}
>>> {% endfor %}
>>>
>>> with the intention of
>>>
>>> 2
>>> 3
>>> 4
>>> 
>>>
>>> as output. I realise the above doesn't work, but is there any scope
>>> for this sort of thing within the templating language itself?
>>>
>
>
> You can write a filter:
>
> http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/#writing-custom-template-filters
>
>>> {% for x in a %}
>>>      loop number = {{forloop.counter|increase}}
>>> {% endfor %}
>
> cheers,
> Konrad
>

Actually, that case is already covered by builtin filter "add":

{% for x in a %} {{ forloop_counter|add:"1" }} {% endfor %}

:)

-- 
Łukasz Rekucki

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



Re: Django forms

2011-01-18 Thread Hakim
Thanks man, the only problem I still have is the following

class Book(models.Model):
user  = models.ForeignKey(User)
title = models.CharField(max_length = 100)
author= models.CharField(max_length = 100)
publisher = models.CharField(max_length = 100)
publication_date = models.DateField()
front_page   = models.FileField(upload_to='books')

def __unicode__(self):
return self.title

@csrf_exempt
@login_required
def update_book(request):
dontvalidate = request.POST['dontvalidate']
book_id = int(request.POST['book_id'])
book = get_object_or_404(Book, id = book_id)
if dontvalidate == 'yes':
bookform = BookForm(instance = book)
else:
booknoteform = BookForm(request.POST, request.Files)
if bookform.is_valid():
bookform.save()
return render_to_response(
'books/update_book.html',
{
'bookform':bookform,
'dontvalidate': dontvalidate,
'is_authenticated' : request.user.is_authenticated(),
},
context_instance = RequestContext(request)
)

the problem is simply that I can return back the information of the
model to be updated except that of the front_page field.
I did add enctype in the form template but this also didn't work. is
there a way out?
On Jan 18, 10:31 am, Derek  wrote:
> First read and 
> understand:http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> Then:
> 1.http://stackoverflow.com/questions/1645444/django-modelform-accessing...
> 2.http://neverfear.org/blog/view/123/Auto_Generate_Forms_With_Django_s_...
>
> On Jan 16, 8:43 am, Benchouia Ahmed Abdelhakim 
> wrote:
>
> > Hello there,
>
> > I am new to django developement model.  If someone know
> > 1- how to access to the ModelForm fields instance in the view?
> > 2- I am trying to developpe a website that contains many forms,  is
> > there a way to make the same template (new and update) for a given
> > model.Models class
>
> > 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django forms

2011-01-18 Thread Hakim
Thanks man, but I am still suffering from another thing,

look at this code:

@csrf_exempt
@login_required
def update_book(request):
dontvalidate = request.POST['dontvalidate']
book_id = int(request.POST['book_id'])
book = get_object_or_404(Book, id = book_id)
if dontvalidate == 'yes':
bookform = BookForm(instance = book)
else:
booknoteform = BookForm(request.POST, request.Files)
if bookform.is_valid():
bookform.save()
return render_to_response(
'books/update_book.html',
{
'bookform':bookform,
'dontvalidate': dontvalidate,
'is_authenticated' : request.user.is_authenticated(),
},
context_instance = RequestContext(request)
)

Once the update code is printed on the screen, all old fields are
there except the one for the FileField.
I coundn't fill out the file data filed with old file saved when the
form was created.
The Book model is like

class Book(models.Model):
user  = models.ForeignKey(User)
title = models.CharField(max_length = 100)
author= models.CharField(max_length = 100)
publisher = models.CharField(max_length = 100)
publication_date = models.DateField()
front_page   = models.FileField(upload_to='books')

def __unicode__(self):
return self.title

On Jan 18, 10:31 am, Derek  wrote:
> First read and 
> understand:http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> Then:
> 1.http://stackoverflow.com/questions/1645444/django-modelform-accessing...
> 2.http://neverfear.org/blog/view/123/Auto_Generate_Forms_With_Django_s_...
>
> On Jan 16, 8:43 am, Benchouia Ahmed Abdelhakim 
> wrote:
>
> > Hello there,
>
> > I am new to django developement model.  If someone know
> > 1- how to access to the ModelForm fields instance in the view?
> > 2- I am trying to developpe a website that contains many forms,  is
> > there a way to make the same template (new and update) for a given
> > model.Models class
>
> > 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Change CSS file in base template depending on browser

2011-01-18 Thread mongoose
Hi there,

I have 2 css files. One specifically for IE because it's so horrible.
I'd like to load either or css files depending on the browser.

I know I have to use
agent = request.META['HTTP_USER_AGENT']

I looked at this http://djangosnippets.org/snippets/77/ but it seems
complex.

All I want is something like this.
{% if request.META['HTTP_USER_AGENT'] == 'IE' %}

{% else %}

{% endif %}

Can I have some advice or point me to a place which shows what to do.
Thanks a lot.

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



Re: Change CSS file in base template depending on browser

2011-01-18 Thread Michel Thadeu Sabchuk
Hi,

> I have 2 css files. One specifically for IE because it's so horrible.
> I'd like to load either or css files depending on the browser.

Why don't you use conditional comments?

http://www.quirksmode.org/css/condcom.html

Best regards,

--
Michel Sabchuk

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



Re: template tag arithmetic

2011-01-18 Thread Konrad Delong
On 18 January 2011 15:02, Thomas  wrote:
>
> Am 18.01.2011 um 14:53 schrieb GD:
>
>>
>> Hi everyone,
>>     Is there a way to do simple loop counter manipulation within the
>> template? I.e something along the lines of:
>>
>> {% for x in a %}
>>      loop number = {{forloop.counter +1}}
>> {% endfor %}
>>
>> with the intention of
>>
>> 2
>> 3
>> 4
>> 
>>
>> as output. I realise the above doesn't work, but is there any scope
>> for this sort of thing within the templating language itself?
>>


You can write a filter:

http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/#writing-custom-template-filters

>> {% for x in a %}
>>      loop number = {{forloop.counter|increase}}
>> {% endfor %}

cheers,
Konrad

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



Re: Localisation

2011-01-18 Thread David Walker
Thanks Lachlan.

The middleware was the bit I was missing.  The only mention of it on
the Django website appears to be on the Middleware page.  Perhaps it
should go on the localisation pages?

The middleware allows the pages to be localised to the browser's
locale, although there are still a number of strange behaviours

There seem to be two main places where date formats originate.  They
are set in settings.py and in the locale's formats.py
(django.conf.locale..formats).

formats.py sets (amongst others) DATE_FORMAT and SHORT_DATE_FORMAT for
the locale in question (along with a load of other datetime formats).
setings.py sets L10N, and also DATE_FORMAT and SHORT_DATE_FORMAT.

If L10N is True, the SHORT_DATE_FORMAT in settings.py is not used in
rendering, with the localised version from the appropriate formats.py
being used instead.
However, Django uses two versions of DATE_FORMAT.  The settings.py one
defaults to to the US format of 'N j, Y', but can be changed.  The
formats.py one contains the appropriate setting for your locale (but
see en_GB below!).

So, what does all this mean for rendering?  I think that the following
happens (assuming that d is a date):
{{d|date:"SHORT_DATE_FORMAT"}}
produces a localised short date: 'd/m/Y' here in the UK
{{d}}
produces a localised long date: 'j \de F \de Y' in Portugal
{{d|date}}
produces a date based on the settings.DATE_FORMAT ( 'N j, Y'
unless changed), but incredibly the month name is translated to the
browser locale.  This often produces date that no one would ever use
like: Março 10, 2010 (the default setting with a Portuguese browser).
I seem to remember seeing in some documentation somewhere (that I now
can't find) that it was intended that the date filter without
arguments would produce a consistent, machine readable date format.

While it may be useful to have a locale independent date format, this,
to me, has a number of problems:
1. re-using the variable name DATE_FORMAT is bound to cause confusion
2. using a common human format for locale independent machine readable
dates is likely to cause confusion.
3. translating the result renders the whole process pointless.

Meanwhile, the documentation says:
http://docs.djangoproject.com/en/dev/ref/settings/#date-format
Note that if USE_L10N is set to True, then the locale-dictated
format has higher precedence and will be applied instead.
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
When used without a format string...the formatting string defined
in the DATE_FORMAT setting will be used, without applying any
localization.

Neither of these statements correctly describe the actual behaviour I
have observed.

To add to my confusion, django.conf.locale.en_GB.formats contains
DATE_FORMAT='N j, Y', whereas I think it should be something like 'j F
Y', 'j N Y' or 'jS F Y'.  The Unicode Common Locale Data Repository
seems to agree with me, plumping for 'd  y' or 'd MMM
y' (obviously these are in a different format).

Have I got this right?
Where do I/we go from here?
Is there a better forum for this?
Can I help improve things by writing bug reports?  enhancements
requests? patches? documentation? or taking part in discussions?

Cheers,

Dave


On Jan 17, 4:39 am, Lachlan Musicman  wrote:
> On Sun, Jan 16, 2011 at 04:23, David Walker  wrote:
> > Despite reading round and round in circles in the documentation, I am
> > completely baffled aboutlocalisationand how it works.  I am not
> > trying to do any translation yet, but want to code money and date
> > formats right so that I don't have to rewrite things later.
>
> > It isn't even clear to me which locale things are being localised to.
> > I had presumed that everything would be localised to the browser's
> > locale, using the language setting, however it seems to be localised
> > to the LANGUAGE_CODE setting from settings.py.  Am I doing something
> > wrong?
>
> I have successfully seen changing the language setting in the/a
> browser work (in Japanese) when it comes tolocalisationof a django
> based site, with LANGUAGE_CODE set to "en".
>
> You may need to send more information, for eg:
>
> which version of django on what platform (these are less important,
> but you never know)
>
> Do you have USE_L10N = True in settings.py?
>
> Do you have 'django.middleware.locale.LocaleMiddleware', in 
> MIDDLEWARE_CLASSES?
>
> cheers
> L.
>
>
>
> > Any help would be gratefully received.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> "... imagine a puddle waking up one morning and thinking, 'This is an
> interesting world I find myself in - an interesting hole I 

Re: Pinax: worth installing?

2011-01-18 Thread Russell Keith-Magee
On Tue, Jan 18, 2011 at 9:43 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> I would be interested to hear from anyone who has used Pinax in production.
> Although I am discouraged by the maturity (only 2 years old?), it does seem
> to contain some useful features.
> Personally, I would have liked to have seen some of these features merged
> into the Django core, rather than forked into a separate project, but that's
> just me.

I think we need to clear up some misconceptions here.

Pinax isn't a "fork" of Django. That would be like saying Zope is a
"fork" of Python. It isn't a fork - one is a tool built using the
facilities provided by the other.

Django is a low level tool. It provides the essentials to route HTTP
requests to views, and return responses. Django doesn't mandate what
you build, or how you build it, or the right apps for the job. Django
only specifies something when it's clearly in the interest of all (or
at least, most) web developers to  -- thus, Django provides a Forms
framework, a template rendering system, and a Sessions framework.

However, there are many things that Django *doesn't* have an opinion
on. For example, there are many ways to implement tagging. There are
many tagging applications available. Depending on your circumstances,
one implementation might be better than another. So Django doesn't
ship with a tagging app -- it's up to end users to find a tagging app
that meets their needs.

There are some exceptions to this rule. For example, the auth
framework isn't as good as it could be, and not every website has a
need for comments. However, the broad principle stands -- Django isn't
trying to provide every tool for every possible web job.

Pinax, on the other hand, works at a higher level. Pinax targets a
specific domain -- social web apps -- and as a result, they *are* in a
position to be opinionated about the best way to do tasks like
tagging. They haven't done this by "forking" Django. They have taken
Django, and the wide community of available apps, and selected a
subset of apps that complement each other, integrate well together,
and are appropriate for their target class of websites. Pinax is more
like a meta-packaging framework for Django apps. Every Pinax site has,
at it's core, a completely vanilla Django install.

And, to follow up on the criticism/wish -- elements of Pinax *have*
made it back to Django. For example, the static files framework that
will be in Django 1.3 started life as an external app, and proved
itself to be a useful tool due, in part, to being a recommended part
of Pinax installs.

So - you really don't have to make a "Pinax or Django" decision. Any
app that can be installed in a Django site can also be installed in a
Pinax site, and every Pinax site is a Django site.

As for the original question -- are there any drawbacks? Well, not
really. Pinax suggests a particular collection of apps, but you can
use any other app you want in parallel. Pinax mandates a few standards
for project layout and the like, but for the most part, they're just
using the best practices commonly understood by experienced members of
the Django community, but the Django project itself hasn't gone to the
trouble of formalizing.

About the only potential downside I can see is that If you're not
building something in Pinax's sweet spot -- i.e., a social web site --
you won't get all the benefits that Pinax has to offer. If you're
building something *really* different, you might find that Pinax's
conventions obstruct you in ways that a raw Django install wouldn't.
However, for most "websitey" websites, this won't be an issue --
Pinax's conventions are, for the most part, a bunch of practices that
you should probably be following anyway -- Pinax just forces/provides
the tools to help you to follow them :-)

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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pinax: worth installing?

2011-01-18 Thread Javier Guerra Giraldez
On Tue, Jan 18, 2011 at 8:43 AM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Personally, I would have liked to have seen some of these features merged
> into the Django core, rather than forked into a separate project, but that's
> just me.

AFAICT, it's not a fork, it's a set of apps that you use on top of Django.

And _very_ few of those apps would be any better in the core.

-- 
Javier

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



Re: template tag arithmetic

2011-01-18 Thread Thomas

Am 18.01.2011 um 14:53 schrieb GD:

> 
> Hi everyone,
> Is there a way to do simple loop counter manipulation within the
> template? I.e something along the lines of:
> 
> {% for x in a %}
>  loop number = {{forloop.counter +1}}
> {% endfor %}
> 
> with the intention of
> 
> 2
> 3
> 4
> 
> 
> as output. I realise the above doesn't work, but is there any scope
> for this sort of thing within the templating language itself?
> 


http://docs.djangoproject.com/en/dev/ref/templates/builtins/

look for 'forloop.counter'

good luck,
TR



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

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



template tag arithmetic

2011-01-18 Thread GD

Hi everyone,
 Is there a way to do simple loop counter manipulation within the
template? I.e something along the lines of:

{% for x in a %}
  loop number = {{forloop.counter +1}}
{% endfor %}

with the intention of

2
3
4


as output. I realise the above doesn't work, but is there any scope
for this sort of thing within the templating language itself?

Regards,
G

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



Re: How to plug in Python: CGI

2011-01-18 Thread Tonton
now it is seems to be mod_wsgi

in apache/conf.d/ yoursite.conf

 WSGIScriptAlias / /path/to/your/djangoproject/wsgi_handler.py

   WSGIDaemonProcess djangoproject user=CCC group=CCC processes=5
threads=1
   WSGIProcessGroup djangoproject

and had to write an wsgi_handler in djangoproject root where you have
settings.py like

import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'Djangoproject.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

things to replace DjangoProject by the name of your project !
/ is your web root
so no other path will work instead  you add an alias for apache

Alias /aOtherPath/ /taget/to/a/OtehrPater/

tonton

On Tue, Jan 18, 2011 at 2:22 PM, ashdesigner wrote:

> Hello,
>
> On my VPS, I've got Apache running on MS Windows Server 2008 R2. What
> is the best way you suggest to plug in Python to be used in a
> relatively highly loaded webproject (on Django)? mod_python,
> fastCGI?... What are advantages and drawbacks, from your real
> experience? I'm new to both Python and Django, so I would appreciate
> how-tos as well (particular urls to faqs/docs will do, of course).
>
> Thanks,
> Anthony
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Pinax: worth installing?

2011-01-18 Thread Cal Leeming [Simplicity Media Ltd]
I would be interested to hear from anyone who has used Pinax in production.

Although I am discouraged by the maturity (only 2 years old?), it does seem
to contain some useful features.

Personally, I would have liked to have seen some of these features merged
into the Django core, rather than forked into a separate project, but that's
just me.

On Tue, Jan 18, 2011 at 1:26 PM, ashdesigner wrote:

> Guys, are there any considerable drawbacks of using Pinax for Django?
> Is it worth installing, or is it better to launch and develop on
> "pure" 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
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Fwd: PostGISAdapter error

2011-01-18 Thread Derek
Not an answer, I know, but did you try the GeoDjango group?
http://groups.google.com/group/geodjango/topics


On Jan 17, 7:31 pm, "Robinson B. Heath" 
wrote:
> It has been a couple of weeks without a reply.  Is there somewhere else I 
> should post this or am I on my own?
>
> Begin forwarded message:
>
> > From: "Robinson B. Heath" 
> > Date: January 4, 2011 11:41:48 PM CST
> > To: django-users@googlegroups.com
> > Subject: PostGISAdapter error
>
> > I am getting the following error when the queryset tries to generate the 
> > SQL: "'str' object has no attribute 'ewkb'"
>
> > Here is what I am doing that causes the problem:
> >    shapes = Shape.objects.filter(geom__bboverlaps=bbx)
> >         shape_info = shape_info.filter(shape__in=shapes)
>
> > Models are:
> >    class Shape(models.Model):
> >            …
> >            geom = models.PolygonField()
> >            color = models.IntegerField()
>
> >    class ShapeInfo(models.Model):
> >            …
> >            name = models.CharField(max_length=25)
> >            shape = models.ForeignKey(Shape)
>
> > The code causing the problem seems to be:
>
> >         if (len(params) == 1 and params[0] == '' and lookup_type == 'exact'
> >             and connection.features.interprets_empty_strings_as_nulls):
> >             lookup_type = 'isnull'
> >             value_annot = True
>
> > Is this not an appropriate way to use this?
>
> > Here is the stacktrace:
> > /Library/Python/2.6/site-packages/django/db/models/query.py in _result_iter
> >                 self._fill_cache() ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/db/models/query.py in _fill_cache
> >                     self._result_cache.append(self._iter.next()) ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/db/models/query.py in iterator
> >         for row in compiler.results_iter(): ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in 
> > results_iter
> >         for rows in self.execute_sql(MULTI): ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in 
> > execute_sql
> >             sql, params = self.as_sql() ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in as_sql
> >         where, w_params = self.query.where.as_sql(qn=qn, 
> > connection=self.connection) ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/db/models/sql/where.py in as_sql
> >                     sql, params = child.as_sql(qn=qn, 
> > connection=connection) ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/db/models/sql/where.py in as_sql
> >                     sql, params = self.make_atom(child, qn, connection) ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/db/models/sql/where.py in make_atom
> >         if (len(params) == 1 and params[0] == '' and lookup_type == 'exact' 
> > ...
> > ▶ Local vars
> > /Library/Python/2.6/site-packages/django/contrib/gis/db/backends/postgis/adapter.py
> >  in __eq__
> >         return (self.ewkb == other.ewkb) and (self.srid == other.srid) ...
> > ▼ Local vars
> > Variable   Value
> > other      
> > ''
> > self      
> >  > 0x10663bf90>

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



Pinax: worth installing?

2011-01-18 Thread ashdesigner
Guys, are there any considerable drawbacks of using Pinax for Django?
Is it worth installing, or is it better to launch and develop on
"pure" 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to plug in Python: CGI

2011-01-18 Thread ashdesigner
Hello,

On my VPS, I've got Apache running on MS Windows Server 2008 R2. What
is the best way you suggest to plug in Python to be used in a
relatively highly loaded webproject (on Django)? mod_python,
fastCGI?... What are advantages and drawbacks, from your real
experience? I'm new to both Python and Django, so I would appreciate
how-tos as well (particular urls to faqs/docs will do, of course).

Thanks,
Anthony

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



Re: 404 view -> redirect to index

2011-01-18 Thread Thomas

The book "The definitive Guide to Django" says on page 476:

---8<---

... if you want to override the 404 view, you can specify 'handler404' in your 
URLconf, like so:


from django.conf.urls.defaults import *

urlpatterns = patterns ('',
...
)

handler404 = 'mysite.views.my_custom_404_view'



Behind the scenes ...

---8<---


hope this helps,

good luck,
TR



Am 18.01.2011 um 13:42 schrieb Ivo Brodien:

> I guess that django catches the 404 Error Code somehow somewhere else than in 
> the handler? Maybe you have to set the HTTP Code to 200?
> 
> 
> On 18.01.2011, at 13:35, galago wrote:
> 
>> Yes I have a index pattern:
>> urlpatterns = patterns('',
>> url(r'^$', 'index.views.index', name='index'),...
>> 
>> When I add print to my method:
>> def custom404(request):
>> print 'foo'
>> return HttpResponseRedirect(reverse('index'))
>> 
>> It prints out but it doesn't redirect me to index. Instead it displays my 
>> 404.html page.
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: 404 view -> redirect to index

2011-01-18 Thread Thomas

why just not copy the 'templates/index.html' template to 'templates/404.html' - 
ready

*not*sure*about*the*correctness*of*this*


Am 18.01.2011 um 13:42 schrieb Ivo Brodien:

> I guess that django catches the 404 Error Code somehow somewhere else than in 
> the handler? Maybe you have to set the HTTP Code to 200?
> 
> 
> On 18.01.2011, at 13:35, galago wrote:
> 
>> Yes I have a index pattern:
>> urlpatterns = patterns('',
>> url(r'^$', 'index.views.index', name='index'),...
>> 
>> When I add print to my method:
>> def custom404(request):
>> print 'foo'
>> return HttpResponseRedirect(reverse('index'))
>> 
>> It prints out but it doesn't redirect me to index. Instead it displays my 
>> 404.html page.
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: 404 view -> redirect to index

2011-01-18 Thread Ivo Brodien
I guess that django catches the 404 Error Code somehow somewhere else than in 
the handler? Maybe you have to set the HTTP Code to 200?


On 18.01.2011, at 13:35, galago wrote:

> Yes I have a index pattern:
> urlpatterns = patterns('',
> url(r'^$', 'index.views.index', name='index'),...
> 
> When I add print to my method:
> def custom404(request):
> print 'foo'
> return HttpResponseRedirect(reverse('index'))
> 
> It prints out but it doesn't redirect me to index. Instead it displays my 
> 404.html page.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: listpage question

2011-01-18 Thread Bobby Roberts
does modelb.modelavalue need a FK relationship with modela.id or does
django do this automatically?




On Jan 17, 11:15 pm, Vovk Donets  wrote:
> 2011/1/18 Bobby Roberts 
>
>
>
> > let's say  i have two simple models
>
> > model a
> > id=IntegerField...
> > description = CharField...
>
> > model b
> > id=IntegerField...
> > modelavalue=IntegerField...   (a value form modela.id)
> > description=CharField...
>
> > ok in the /admin listing page for model B, how can i return
> > modela.description  for modelb.modelavalue
>
> you can do it by inserting "modelAvalue__description" in the admin.py in the
> list_display for modelB model.Admin:
>
> class modelBAdmin(admin.ModelAdmin):
>     list_display = ( 'id','modelAvalue__description', 'description')
> admin.site.register(modelB, modelBAdmin)

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



Re: 404 view -> redirect to index

2011-01-18 Thread galago
Yes I have a index pattern:
urlpatterns = patterns('',
url(r'^$', 'index.views.index', name='index'),...

When I add print to my method:
def custom404(request):
print 'foo'
return HttpResponseRedirect(reverse('index'))

It prints out but it doesn't redirect me to index. Instead it displays my 
404.html page.

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



Re: 404 view -> redirect to index

2011-01-18 Thread Ivo Brodien
Are you sure, that you have a url pattern called ‘’view? in reverse you have to 
pass the name of the rule, not the views method name.

On 18.01.2011, at 13:22, galago wrote:

> I try to redirect from 404 view to my index page. In url.py i added: 
> handler404 = 'index.views.custom404'
> 
> in my index i have:
> def custom404(request):
> return HttpResponseRedirect(reverse('index'))
> 
> But it doesn't work.
> Should I do something more?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



404 view -> redirect to index

2011-01-18 Thread galago
I try to redirect from 404 view to my index page. In url.py i added: 
handler404 = 'index.views.custom404'

in my index i have:
def custom404(request):
return HttpResponseRedirect(reverse('index'))

But it doesn't work.
Should I do something more?

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



Re: a chicken and egg - help please?

2011-01-18 Thread David De La Harpe Golden
On 18/01/11 07:26, Jani Tiainen wrote:

> It's just not possible to run any arbitrary Python code 
> in a database.

Well, technically there's a pl/python module for postgresql. ;-)
(doesn't really help, I'm just saying)

http://www.postgresql.org/docs/9.0/interactive/plpython.html

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



Re: ForeignKey to User

2011-01-18 Thread Praveen Krishna R
*Thank You
*
On Tue, Jan 18, 2011 at 12:08 PM, Ivo Brodien  wrote:

>
> from the 
> docs
> :
>
> If you'd prefer Django didn't create a backwards relation, set
> related_name to '+'. For example, this will ensure that the Usermodel
> won't get a backwards relation to this model:
>
> If your Model is called: MyModel then you could do for a user instance:
>
> user.mymodel_set , but if you define a '+’ as related_name, you can’t
> because django does not create the ‘reverse relationship’
>
>
>
>
> On 18.01.2011, at 10:00, Praveen Krishna R wrote:
>
> *Hi,*
> *
> *
> *Could any of you tell me about the things which I should take care while
> defining a *
> *foreign key to User model. ? *
> *
> *
> *Do I need to define the related_name ='+' as it says in the
> documentation? and what does it do?*
> *
>
> user = models.ForeignKey(User, related_name='+')
>
>  *
> --
> *Praveen Krishna R*
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
*Praveen Krishna R*

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



Django saving problem, logging in/out fixes it

2011-01-18 Thread Stefan
Hi,

Currently we're having some issues with a user of our product who uses
a proxy on their internal network.

According to their system administrator the proxy is open to port 80
and 443, and doesn't do anything with cookies and such, only blocks
out some sites.

Now, with Django we wrote an application who doesn't function really
good within their network.

The problem; example 1:

1. User takes a test, ten questions on ten different pages
2. User completes the test, his score is saved and a session is
removed (with which question where already answered, and that the user
is in a test)
3. User get's redirected to the homepage, which opens the correct page
when the test is succesfully completed

Now, at step 3 the right page doesn't get loaded. Only AFTER the user
is logged out, and then logged in again it works.

Example 2:

But this doesn't only happen with a test (as describe as above), also
at some pages with a small memory-like quiz (only javascript used),
when that is succesfully completed (checked with a ajax-request), the
next page is set active (also in the ajax call) and the user gets
redirected to the next page.

Also, when this doesn't go right. Logging out and in fixes it.

Example 3:

ALSO, which is weird: when the user opens the application on a
computer, he is logged in as a user who didn't use the computer before
(but is behind the same proxy)?! This shouldn't be possible (django
default auth app is used).

The software we're using is Apache, Nginx, Django 1.0 and Postgresql.
Also note that it does work when run with runserver, but not with
nginx.

This only occurs with this user with the proxy, everywhere else, it
does work.

Anyone experienced this before? If so, how'd you solve it?

Thanks in advance!

Stefan

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



Automatic parent link with multi-table inheritance

2011-01-18 Thread Alendit
Hi,

according to Django docs (http://docs.djangoproject.com/en/1.2/topics/
db/models/#multi-table-inheritance) there should be a automaticly set
parent link, when using multi-table inheritance. I'd like to do
something like that:

Class A(models.Model):
.

Class B(A):
.

a = A.objects.get(pk=100)
b = B.objects.get(pk=100)

# Does work
a.b # is the same as b

# Doesn't work
b.a # should return a

I can set-up an OneToOne field in each child class, but, obviously,
it's not the optimal way to go. Now i'm using an abstract class in the
middle, which defines a parent_link field, but i wonder, if there is
an easier way.

Alendit

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



Re: ForeignKey to User

2011-01-18 Thread Ivo Brodien

from the docs:

If you'd prefer Django didn't create a backwards relation, set related_name to 
'+'. For example, this will ensure that the Usermodel won't get a backwards 
relation to this model:

If your Model is called: MyModel then you could do for a user instance:

user.mymodel_set , but if you define a '+’ as related_name, you can’t because 
django does not create the ‘reverse relationship’




On 18.01.2011, at 10:00, Praveen Krishna R wrote:

> Hi,
> 
> Could any of you tell me about the things which I should take care while 
> defining a 
> foreign key to User model. ? 
> 
> Do I need to define the related_name ='+' as it says in the documentation? 
> and what does it do?
> 
> user = models.ForeignKey(User, related_name='+')
> 
> -- 
> Praveen Krishna R
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: Dates BC

2011-01-18 Thread Alex Kamedov
Hi!

I have the same problem in one of my projects. I used 2 fields for it. One
is standart DateField and another is BooleanField. If the second is True I
suppose the date is BC. This aprouch is very simply and work with all
Django supported databases.

On Tue, Jan 18, 2011 at 3:52 AM, Christophe Pettus  wrote:

>
> On Jan 17, 2011, at 2:00 PM, Ben Dembroski wrote:
> > I'm a relative newbie to both Python and Django, and in the middle of
> > my first Django project.   My client is asking me to store and process
> > dates -- including dates BC.
>
> Unless you have a strong need to do date arithmetic on the dates, or you
> can use a different database (like PostgreSQL) that has more robust date
> support, it might be easier to represent the dates as stylized strings, or
> as integers on a uniform calendar like the proleptic Julian calendar,
> instead of using the built-in date type.
>
> --
> -- Christophe Pettus
>   x...@thebuild.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Alex Kamedov
skype: kamedovwww: kamedov.ru

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



Re: Dates BC

2011-01-18 Thread Ben Dembroski
Thanks.   I do need to do some basic date arithmetic, but it doesn't
really need to be super accurate.   I might be able to get away with
this approach.

Thanks for the advice!

Best,
Ben

On Jan 17, 10:52 pm, Christophe Pettus  wrote:
> On Jan 17, 2011, at 2:00 PM, Ben Dembroski wrote:
>
> > I'm a relative newbie to both Python and Django, and in the middle of
> > my first Django project.   My client is asking me to store and process
> > dates -- including dates BC.
>
> Unless you have a strong need to do date arithmetic on the dates, or you can 
> use a different database (like PostgreSQL) that has more robust date support, 
> it might be easier to represent the dates as stylized strings, or as integers 
> on a uniform calendar like the proleptic Julian calendar, instead of using 
> the built-in date type.
>
> --
> -- Christophe Pettus
>    x...@thebuild.com

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



Re: django custom signals

2011-01-18 Thread bruno desthuilliers
On 18 jan, 10:08, Mo Mughrabi  wrote:
> Hi,
>
> am having problem with django custom signals not being able to see signals
> across application. I made a simple call in my
>
> *core/signals.py*
>
>   *  from django.dispatch.dispatcher import Signal*
> *    # Signal-emitting code... emits whenever a file upload is received*
> *    # *
> *    *
> *    upload_recieved = Signal(providing_args=['data'])*

(snip)

> *in blog/admin.py*
>
> *    from libs.shared.core import signals*
(snip)
> *    *
> *    *
> *    class ArticleModelAdmin(admin.ModelAdmin):*
> *        def save_model(self, request, obj, form, change):*
> *            upload_recieved.send(sender=self, data='ddd')*

You want:
   signals.upload_recieved.send(sender=self, data='ddd')

(snip)
> *    *
>
> this is what I did, but am getting an error in the runtime unable to see
> upload_received function. any ideas?


http://docs.python.org/tutorial/modules.html


Also and while we're at it : avoid adding '*' around your code
snippets, it really doesn't help.
;)

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



Re: Django forms

2011-01-18 Thread Derek
First read and understand:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

Then:
1. 
http://stackoverflow.com/questions/1645444/django-modelform-accessing-a-fields-value-in-the-view-template
2. 
http://neverfear.org/blog/view/123/Auto_Generate_Forms_With_Django_s_ModelForm

On Jan 16, 8:43 am, Benchouia Ahmed Abdelhakim 
wrote:
> Hello there,
>
> I am new to django developement model.  If someone know
> 1- how to access to the ModelForm fields instance in the view?
> 2- I am trying to developpe a website that contains many forms,  is
> there a way to make the same template (new and update) for a given
> model.Models class
>
> 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: newbie

2011-01-18 Thread Derek
1) I have not had any problems or conflicts; just make sure you load
the .js libraries into whichever pages need them (using a "parent"
template is probably the most sensible way).

2) You can only use .js inside templates - it does not make sense to
use them elsewhere - templates deal with your application "interface"
and so the jQuery "UI".  But within templates you should be able to
use any/all of its capabilities.

On Jan 15, 9:27 pm, km  wrote:
> I have been reading django forms with media.
> But I would like to use the latest jquery (1.4.4) + jquery-ui (1.8.7)
> with a django (v1.2.4) based  web-application for forms and ui-design
> in general.
>
> 1) does the latest jquery installed under MEDIA_ROOT conflict with the
> default jquery library(v1.4.2) ?
> 2) jquery-ui provides widgets otherthan those act on form elements.
> for example most jquery widgets manipulate  elements to make tabs
> or accordion appear. In that case does the ui-design have to be
> manually designed  and restricted to the templates ?
>
> pls let me know.
> thank you
> regards,
> KM

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



Re: django-admin.py not working?

2011-01-18 Thread Derek
You're right - they don't (and you can suggest they do - other code on
the same page does show this e.g. python manage.py runserver).

However... Django is written in Python and it does say right on the
"Getting started"  page (http://docs.djangoproject.com/en/dev/intro/)
that "If you’re new to Python, you might want to start by getting an
idea of what the language is like. Django is 100% Python, so if you’ve
got minimal comfort with Python you’ll probably get a lot more out of
Django.".  Assuming that you have programmed before (but not in
Python), you would then follow the link to "Dive into Python".  It
would tell you how to install ActivePython on Windows (http://
diveintopython.org/installing_python/windows.html).  You would then
want to see how to run a program, so you'd read "Diving In" (http://
diveintopython.org/getting_to_know_python/index.html), where it tells
you how to run a program under the ActivePython IDE on Windows.  If
you do not want to (or cannot) do it this way, then you would need to
dig a little deeper... one clue is provided at the end of this "Diving
In" page - "you can run a Python program from the command line: python
odbchelper.py", which implies that the word "python" is needed in
front of a program name to make it run... makes sense?

In summary; the developers have done a fantastic job and built a
complex tool that hugely  simplifies your life.  While the docs do
their best to make getting started really easy, they do not (and
should not) repeat the Python fundamentals that are well documented
elsewhere. Getting to grips with some Python basics will make your
learning curve so much easier.

P.S. This blog article may also shed some light in a much broader
sense  - http://dougalmatthews.com/articles/2009/dec/14/django-its-just-python/

On Jan 15, 8:24 pm, nai  wrote:
> OMG THAT WORKED! Thank you so much but I don't understand why NONE of
> the documentation mentioned anything about putting a python in front
> of it. URGH!!
>
> Thanks again!
>
> On Jan 15, 6:19 pm, Acorn  wrote:
>
> > You will have to specially run the script with python.. so:
>
> >    python FULLPATH\django-admin.py startproject webapp1
>
> > I'm not sure why it behaves like this.
>
> > On 15 January 2011 18:00, nai  wrote:
>
> > > I'm running Windows Vista and Im trying to create a project.
>
> > > When I try to run FULLPATH\django-admin.py startproject webapp1, I get
> > > back the help list. This happens no matter what subcommand I use. I
> > > took a screen shot an posted a similar question on SO here
> > >http://stackoverflow.com/questions/4696831/help-with-django-installation
>
> > > Any help would be much appreciated.
>
> > > Nai
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.

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



django custom signals

2011-01-18 Thread Mo Mughrabi
Hi,

am having problem with django custom signals not being able to see signals
across application. I made a simple call in my

*core/signals.py*

  *  from django.dispatch.dispatcher import Signal*
*# Signal-emitting code... emits whenever a file upload is received*
*# *
**
*upload_recieved = Signal(providing_args=['data'])*
**
**
*def upload_received_handler(sender, data, **kwargs):*
*print 'upload received handler'*
**
*print 'connecting signal'*
*upload_recieved.connect(upload_received_handler)*

*in core/models.py*

   * import signals*
**
*[the model]*

*in blog/admin.py*

 *   from models import article, category, media *
*from django.contrib import admin*
*from libs.shared.core.tasks import Create_Audit_Record*
*from libs.shared.core import signals*
**
**
**
*class ArticleModelAdmin(admin.ModelAdmin):*
*def save_model(self, request, obj, form, change):*
*upload_recieved.send(sender=self, data='ddd')*
*instance = form.save()*
*return instance*
**
**
**
*admin.site.register(article, ArticleModelAdmin)*
*admin.site.register(category)*
*admin.site.register(media)*


this is what I did, but am getting an error in the runtime unable to see
upload_received function. any ideas?

Regards,

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



ForeignKey to User

2011-01-18 Thread Praveen Krishna R
*Hi,*
*
*
*Could any of you tell me about the things which I should take care while
defining a *
*foreign key to User model. ? *
*
*
*Do I need to define the related_name ='+' as it says in the documentation?
and what does it do?*
*

user = models.ForeignKey(User, related_name='+')

*
-- 
*Praveen Krishna R*

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