creating an api using python

2010-12-03 Thread Margarita Ladera
Hi, just wanna ask are there any tutorials available for step by step
procedures in creating an API using django/python? Thanks

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



Re: Project management software

2010-12-03 Thread ydjango
 try http://www.agilewrap.com

written in Django. It is commercial tool but Free for open source and
non profit. Also free for up to 5 users for commercial orgs.


On Dec 3, 1:21 pm, tiemonster  wrote:
> I've done the initial checkin under LGPL license as agreed. Anyone
> that is interested in contributing, let me know your Google Code login
> and I'll give you commit access to the svn repo. Any further questions
> or comments can probably be directed to me personally instead of on-
> list. Thanks!
>
> http://code.google.com/p/django-project-manager/
>
> -Mark

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



Re: Named URLs and class-based generic views

2010-12-03 Thread Łukasz Rekucki
On 3 December 2010 22:40, Andrew Willey  wrote:
> So it works as
>
>> url(r'^location/$', WouldLoveToHaveClassBasedView.as_view(), 
>> name='name_for_convenience')
>
> Didn't realize I could just pass the class object.  Makes sense.
> Guess I'm getting old and change fearing.

To be clear here - you're not passing the class object here -
as_view() returns a normal function that takes care of everything:
creating a View instance and passing request and URL params to it's
dispatch method. Class-based views get no special handling in Django,
so you could just copy the 'django.views.generic' package to your
Django<1.3 project and use them (I did :).

>
> I think the only thing that's bugging me is that you have to include
> the whole views.py in your url conf.  Just feels less graceful than
> having the dispatcher nab what it needs on demand.  I'll get over it.

You should avoid doing "from ... import *" and just explicitly name
the views you need. It's easier to see which views are actually used
this way. If you really want to use the string syntax:

# views.py

my_view = MyView.as_view()

# urls.py

urlpatterns('myapp.views',
   url(r'some_pattern/', 'my_view', name="myapp-my_view")
)

There is not way to use a string like 'myapp.views.MyView' - you need
the alias.  Also, you most likely want to name all your URL patterns
that use class-based views or you won't have a way to use reverse()
with them.

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



Re: Named URLs and class-based generic views

2010-12-03 Thread wayne

> I think the only thing that's bugging me is that you have to include
> the whole views.py in your url conf.  Just feels less graceful than
> having the dispatcher nab what it needs on demand.  I'll get over it.
>

Yeah, it does feel less graceful, doesn't it?  That said, there might
be a way, I just don't know it.

I wouldn't see why you couldn't do it, just like before (specify the
string name)--I just didn't recall seeing that example in the docs for
class based views.  Then again, I'm just trying to get my boss to move
us over to 1.2, so I haven't really looked at trunk or projected 1.3
stuff yet (like the new views).

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



Re: Named URLs and class-based generic views

2010-12-03 Thread Andrew Willey
So it works as

> url(r'^location/$', WouldLoveToHaveClassBasedView.as_view(), 
> name='name_for_convenience')

Didn't realize I could just pass the class object.  Makes sense.
Guess I'm getting old and change fearing.

I think the only thing that's bugging me is that you have to include
the whole views.py in your url conf.  Just feels less graceful than
having the dispatcher nab what it needs on demand.  I'll get over it.

Unless someone has a better idea!

On Dec 3, 3:12 pm, Daniel Roseman  wrote:
> On Dec 3, 8:47 pm, Andrew Willey  wrote:
>
> > Forgot to in mention the actual question from the subject.
>
> > Is there a "blessed" way to use class-based views with named urls in
> > the
>
> > > url(r'^location/$', view='WouldLoveToHaveClassBasedView.as_view', 
> > > name='name_for_convenience')
>
> I don't understand what one thing has got to do with the other. You
> can still use a named URL even if you use the object rather than a
> string to refer to it:
>
>     url(r'^location/$', view=WouldLoveToHaveClassBasedView.as_view(),
> name='name_for_convenience')
>
> It's the `url` function that allows you to use the name kwarg, not
> anything to do with the view function that's being called.
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Project management software

2010-12-03 Thread tiemonster
I've done the initial checkin under LGPL license as agreed. Anyone
that is interested in contributing, let me know your Google Code login
and I'll give you commit access to the svn repo. Any further questions
or comments can probably be directed to me personally instead of on-
list. Thanks!

http://code.google.com/p/django-project-manager/

-Mark

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



Re: Named URLs and class-based generic views

2010-12-03 Thread Daniel Roseman
On Dec 3, 8:47 pm, Andrew Willey  wrote:
> Forgot to in mention the actual question from the subject.
>
> Is there a "blessed" way to use class-based views with named urls in
> the
>
> > url(r'^location/$', view='WouldLoveToHaveClassBasedView.as_view', 
> > name='name_for_convenience')
>

I don't understand what one thing has got to do with the other. You
can still use a named URL even if you use the object rather than a
string to refer to it:

url(r'^location/$', view=WouldLoveToHaveClassBasedView.as_view(),
name='name_for_convenience')

It's the `url` function that allows you to use the name kwarg, not
anything to do with the view function that's being called.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Named URLs and class-based generic views

2010-12-03 Thread wayne
On Dec 3, 2:47 pm, Andrew Willey  wrote:
> Forgot to in mention the actual question from the subject.
>
> Is there a "blessed" way to use class-based views with named urls in
> the
>
> > url(r'^location/$', view='WouldLoveToHaveClassBasedView.as_view', 
> > name='name_for_convenience')
>

Oh, I see ( I think ;) ).  I don't know, but I am guessing no.
However, you could decorate the view and use the decorator as some
sort of dispatcher, although I am not sure that would really give you
what you want.

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



Re: Named URLs and class-based generic views

2010-12-03 Thread Andrew Willey
Forgot to in mention the actual question from the subject.

Is there a "blessed" way to use class-based views with named urls in
the
> url(r'^location/$', view='WouldLoveToHaveClassBasedView.as_view', 
> name='name_for_convenience')

On Dec 3, 1:46 pm, Andrew Willey  wrote:
> Can someone point me in the right direction here?
>
> How does one use class-based generic views and named URLs?
>
> Example (doesn't work):
>
> > urls.py
> > urlpatterns += patterns('myapp.views',
> >    (r'^location/$', MyGenericView.as_view()),
> > )
> > views.py
> > class MyGenericView(TemplateView):
> >    template_name = 'example.html'
>
> Now, I can make that work if I did this instead in
>
> > urls.py
> > from myapp.views import *
> > urlpatterns += patterns('',
> >     (r'^location/$', MyGenericView.as_view()),
> > )
>
> That approach just feels weird, am I doing it wrong or is that the new
> normal?

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



Re: Named URLs and class-based generic views

2010-12-03 Thread wayne


On Dec 3, 1:46 pm, Andrew Willey  wrote:
> Can someone point me in the right direction here?
>
> How does one use class-based generic views and named URLs?
>
> Example (doesn't work):
>
> > urls.py
> > urlpatterns += patterns('myapp.views',
> >    (r'^location/$', MyGenericView.as_view()),
> > )
> > views.py
> > class MyGenericView(TemplateView):
> >    template_name = 'example.html'
>
> Now, I can make that work if I did this instead in
>
> > urls.py
> > from myapp.views import *
> > urlpatterns += patterns('',
> >     (r'^location/$', MyGenericView.as_view()),
> > )
>
> That approach just feels weird, am I doing it wrong or is that the new
> normal?

No, that looks right to me.  You import the view in the second case,
which means you can pass it like an object, as you do.

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



Re: Project management software

2010-12-03 Thread tiemonster
I'm not able to access the demo, and can't seem to figure out how to
install the application correctly.

-Mark




On Dec 2, 11:56 am, "piz...@gmail.com"  wrote:
> My PMA is unfinished and it's more a coding exercise than an end  
> product, but you can take a look to it (MIT license):
>
> Repository:
>
> git://halcyon.zapto.org/supervise
>
> Navigate repo (cgit):
>
> http://halcyon.zapto.org
>
> Demo (only a few url's working right now):
>
> http://halcyon.zapto.org:8000
>
> User: demo
> Pass: demo
>
> Working url's:
>
> http://halcyon.zapto.org/issueshttp://halcyon.zapto.org/projectshttp://halcyon.zapto.org/admin
>
> - Oscar
>
> El 02/12/2010, a las 17:40, tiemonster escribió:
>
> > Baurzhan,
> > I explicitly will not provide support for time-tracking in this
> > software. It is one of many features that I feel movesproject
> >managementsoftware beyond the realm of understanding for business
> > users and into the realm of theprojectmanager. That's not the point
> > of thisproject.
>
> > Venkatraman,
> > There are lots of goodprojectmanagementapplications out there, but
> > the couple written in Django that I found were full applications. I
> > was looking for something I could embed within an existing Django
> > application. The idea is to haveprojectmanagementsoftware within an
> > existingprojecttoolset (ticket system, reporting environment) that
> > business users can utilize to better manage their projects.
>
> > Thomas,
> > The LGPL would also be acceptable. I'll keep this in mind when I
> > release the code.
>
> > -Mark

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



Named URLs and class-based generic views

2010-12-03 Thread Andrew Willey
Can someone point me in the right direction here?

How does one use class-based generic views and named URLs?

Example (doesn't work):

> urls.py
> urlpatterns += patterns('myapp.views',
>(r'^location/$', MyGenericView.as_view()),
> )

> views.py
> class MyGenericView(TemplateView):
>template_name = 'example.html'

Now, I can make that work if I did this instead in
> urls.py
> from myapp.views import *
> urlpatterns += patterns('',
> (r'^location/$', MyGenericView.as_view()),
> )

That approach just feels weird, am I doing it wrong or is that the new
normal?

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



Debug internalization

2010-12-03 Thread Joakim Hove
Hello,

I am trying to use Djangos internalization framework - but struggling
a bit ...

In my settings.py file I have:

LANGUAGES = (
("en" , ugettext("English")),
("no" , ugettext("Norwegian")),
("sv" , ugettext("Swedish")),
("dk" , ugettext("Danish")))

LANGUAGE_CODE = 'en-us'


MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
.


In my view I have:


from django.utils.translation   import ugettext

def view_local(request):
  msg = ugettext("Local message")
  return render_to_context()


Now my problem is that the ugettext() function will only return the
literal input string, whatever I pass it. In the beginning I of course
passed in strings I had a translation for, but e.g.

msg = ugettext("Message_without_any_translation")

will just work "fine". So I guess I wonder if it is possible to get
some debug info from this, i.e. in development mode I would prefer the
ugettext() function to crash and burn if the msgid can not be found
instead of just return the msgid. Any tips on this?



Regards Joakim




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



Re: how can I clean a form field before the clean method?

2010-12-03 Thread wayne
On Dec 3, 11:59 am, refreegrata  wrote:
> Ok, with hidden fields. But if the user manually, with some tool,
> change the value, thats will be a problem. For my safety I must to use
> the hidden fields and still keep the clean methods to overwrite any
> possible editing over the fields value. Originally the idea of this
> post was search a way to prevent the double assign(in the init and the
> clean methods), but apparently isn't possible.
>
> Thanks for the answer.

It isn't possible because you are, in actuality, asking two questions:

1.  How can I set the value of a field on the server w/o client
interaction, and
2.  Ensure that the client doesn't do something malicious

Number one is something that you should take care of in your view or
model (__init__, perhaps), and number 2 is a validation issue.

Since you said you didn't want to handle it in your POST processing,
which is the only way you can set it once and take care of both issues
(because you're doing it at the end of the chain), you will have to do
it twice, no matter what method/idea/framework you use.

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



Re: how can I clean a form field before the clean method?

2010-12-03 Thread refreegrata
Ok, with hidden fields. But if the user manually, with some tool,
change the value, thats will be a problem. For my safety I must to use
the hidden fields and still keep the clean methods to overwrite any
possible editing over the fields value. Originally the idea of this
post was search a way to prevent the double assign(in the init and the
clean methods), but apparently isn't possible.

Thanks for the answer.

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



Re: query date by string

2010-12-03 Thread owidjaya
so you are saying that  SELECT * FROM some_table WHERE some_date LIKE
"2010%"
is not possible?

On Dec 3, 9:30 am, bruno desthuilliers 
wrote:
> On 3 déc, 17:37, owidjaya  wrote:
>
> > in php I can run the following query for mysql
>
> > SELECT * FROM some_table WHERE some_date LIKE "2010%"
>
> > How do i do this in django using cursor.execute()?
>
> sql = "SELECT * FROM some_table WHERE YEAR(some_date)=%s"
> cursor.execute(sql, (2010,))

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



Re: query date by string

2010-12-03 Thread bruno desthuilliers
On 3 déc, 17:37, owidjaya  wrote:
> in php I can run the following query for mysql
>
> SELECT * FROM some_table WHERE some_date LIKE "2010%"
>
> How do i do this in django using cursor.execute()?

sql = "SELECT * FROM some_table WHERE YEAR(some_date)=%s"
cursor.execute(sql, (2010,))

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



Re: ORA-01425

2010-12-03 Thread Ian
On Dec 2, 3:17 pm, Tim Sawyer  wrote:
> I unpatched mine (changed LIKEC to LIKE) and then ran:
>
>  >>> from django.db import connection
>  >>> cursor = connection.cursor()
>  >>> result = cursor.execute(r"SELECT 1 FROM DUAL WHERE TRANSLATE('A'
> USING NCHAR_CS) LIKE TRANSLATE('A' USING NCHAR_CS) ESCAPE TRANSLATE('\'
> USING NCHAR_CS)")
>  >>> rows = cursor.fetchall()
>  >>> for row in rows:
>  > ...   print row[0]
>  > ...
>  > 1
>  >>> print rows
>  > ((1,),)

Nuts.  What if you remove the first TRANSLATE call, i.e.

cursor.execute(r"SELECT 1 FROM DUAL WHERE 'A' LIKE TRANSLATE('A' USING
NCHAR_CS) ESCAPE TRANSLATE('\' USING NCHAR_CS)")

If that also doesn't trigger the error, then maybe we need an actual
column in the mix.  Please try this also:

cursor.execute(r"SELECT 1 FROM DUAL WHERE DUMMY LIKE TRANSLATE('X'
USING NCHAR_CS) ESCAPE TRANSLATE('\' USING NCHAR_CS)")

Thanks,
Ian

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



Re: query date by string

2010-12-03 Thread wayne


On Dec 3, 11:13 am, oscar widjaya  wrote:
> It's for mysql
> it still does not work. I tried it with the following sql statement
> "SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%'

Well, I assume that the double % at the end of your query is
unintentional, as I don't think it should be there, but I'm not an sql
guru.

I just know that when I was having to craft some custom sql a couple
of months ago (using Postgres) I had to toy with the formatting a bit
to get it working.  I also had to make sure I passed everything as a
str, and not unicode.

Maybe someone else how knows sql better will come along.

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



Re: Conflict trying to save models when roles metaclass is applied.

2010-12-03 Thread bruno desthuilliers


On 3 déc, 08:00, juacompe  wrote:
> Hi Bruno,
>
> Thank you very much!! Adding an inner Meta class works like charm.

Cool 8)

Now beware, there _might_ be a couple other dark corners... I strongly
suggest you take a look at ModelBase implementation and possibly
extend your test cases, at least to make sure you spotted all possible
side-effects of the role+model combo.

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



Re: models don't show in tamplate

2010-12-03 Thread wayne
Are you seeing anything?  I mean, is the rest of the template
rendering fine?

There are only two things that I notice:  the extra dict you pass with
the template_object_name (why not put it in info_dict?), and while I'm
not fluent in spanish, are you iterating through the variable
'object_list'?  That is the name of the list that will have your
queryset objects after the generic view is executed.

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



Re: query date by string

2010-12-03 Thread owidjaya
It's for mysql
it still does not work. I tried it with the following sql statement
"SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%'

On Dec 3, 9:04 am, wayne  wrote:
> On Dec 3, 10:47 am, owidjaya  wrote:
>
> > It says incorrect date value.
>
> What database are you using?  I'm wondering if this is an issue of
> formatting the sql correctly.  Did you read the snippet near the
> bottom of the page I linked to?  Try:
>
> SELECT * FROM some_table WHERE some_date LIKE "%s" % '2010%'

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



Re: query date by string

2010-12-03 Thread oscar widjaya
It's for mysql
it still does not work. I tried it with the following sql statement
"SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%'


On Fri, Dec 3, 2010 at 9:04 AM, wayne  wrote:

>
>
> On Dec 3, 10:47 am, owidjaya  wrote:
> > It says incorrect date value.
> >
>
> What database are you using?  I'm wondering if this is an issue of
> formatting the sql correctly.  Did you read the snippet near the
> bottom of the page I linked to?  Try:
>
> SELECT * FROM some_table WHERE some_date LIKE "%s" % '2010%'
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: how to define choices option per model's instance

2010-12-03 Thread Cal Leeming [Simplicity Media Ltd]

Hi Alex,

Sorry it took me a while to reply, only just saw the thread update. 
Yeah, thinking about it, the previous method probably wouldn't have 
worked due to the way Django handles the db model objects.


Okay, in this particular case, I would suggest re-thinking the way this 
is being done. For example, rather than restricting this at the option 
level, perhaps override the save() and add in some custom checking 
there. Athough the below code segment isn't perfect, it might be a good 
starting ground.


class Something(models.Model):
   range_marks = models.IntegerField(choices = _choices, verbose_name = 
'Marks of Something')

   def __init__(self, *args, **kwargs):
   if kwargs.has_key('range_marks'):
   _choices = kwargs.get('range_marks')
   del kwargs['range_marks']
   else:
   _choices = (('default', 'default'), )
   self._choices_dict = dict(_choices)
   self._choices = dict(_choices)
   super(Something, self).__init__(*args, **kwargs)

def save(self, *args, **kwargs):
if self.range_marks and not 
self._choices_dict.has_key(self.range_marks):
raise Exception, "Invalid option" # replace this with 
whatever exception is raised when django doesnt like your option, i cant 
remember it off the top of my head though, sry

super(Something, self).save(*args, **kwargs)

Hope this helps.

Cal

On 02/12/2010 19:00, Alex Boyko wrote:

Hi Cal!

Thank you very much for your reply and advice, but unfortunately it 
doesn't work. It seems like in __init__ method we can't re-assign the 
choices. Even if I try:


class Something(models.Model):
   def __init__(self, *args, **kwargs):
   _choices = ((SomeValue, 'SomeString'), )
   self.range_marks = models.IntegerField(choices = _choices, 
verbose_name = 'Marks of Something')

   super(Something, self).__init__(*args, **kwargs)

In admin page I see that my field has choices option initially defined 
in global scope (I've showed that definition in my first letter).
Any suggestions about how I can assign choice attribute on the fly 
during instance creation. In future It doesn't change but my instances 
have to have different ranges in choices option.


Best Regards,
Alex



On 2 December 2010 10:15, Cal Leeming [Simplicity Media Ltd] 
> wrote:


Hi Alex,

I think this is what you might be looking for.


class Something(models.Model):
   def __init__(self, *args, **kwargs):
   if kwargs.has_key('range_marks'):
   _choices = kwargs.get('range_marks')
   del kwargs['range_marks']
   else:
   _choices = (('default', 'default'), )
   self.range_marks = models.IntegerField(choices = _choices,
verbose_name = 'Marks of Something')
   super(Something, self).__init__(*args, **kwargs)

Let us know if it works :)

Cheers

Cal


On 02/12/2010 06:53, Alex Boyko wrote:

Hi!

I got such kind of problem.
I'd like to define the tuple(list) of choices option at the
moment of instance created on the fly
In the future these choices will not change.
Hence I've found just one way to do it - override __init__()
of my model and
pass there the particular predefined list of choices that
depends on current model's instance (in code - 'range_list')
But this approach seems doesn't work properly.
Would You be so kind to help with advice  - how I can solve my
task with dynamical choices per model's instance.

---
RANGE_CHOICES = ()

class Something(models.Model):
   def __init__(self, *args, **kwargs):
   range = kwargs.pop('range_list', None)
   super(Covenant, self).__init__(*args, **kwargs)
   self._meta.get_field_by_name('range_marks')[0]._choices
= range

   range_marks = models.IntegerField(choices = RANGE_CHOICES,
verbose_name = 'Marks of Something')
-


Thanks in Advance!
Best Regards!
Alex
-- 
You received this message because you are subscribed to the

Google 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 

Django Developer Requirement, [Full-time] Gurgaon, India

2010-12-03 Thread Subhranath Chunder
Hi,

There is opening and requirement for some Django developers in the company I
work in.
This is one the top Media companies in India, who are basically moving their
major projects and products to the Django platform.

If interested, please contact HR Parul Gupta for more details at
parul85gu...@gmail.com or 9717148584.

Thanks,
Subhranath Chunder.

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



Re: query date by string

2010-12-03 Thread wayne


On Dec 3, 10:47 am, owidjaya  wrote:
> It says incorrect date value.
>

What database are you using?  I'm wondering if this is an issue of
formatting the sql correctly.  Did you read the snippet near the
bottom of the page I linked to?  Try:

SELECT * FROM some_table WHERE some_date LIKE "%s" % '2010%'

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



Re: main categories in menu

2010-12-03 Thread wayne
On Dec 3, 2:11 am, Rob  wrote:
> I want to make main categories on my site like:
> /main1/page1
> /main2/page2
> /main3/page3

It sounds like you have 3 views, and each one can pick from a pool of
categories.  If this is correct, all you need to do is enter a line
for each view (main#), and pass the category (page#) as a variable to
the view, which can then do the lookup.  You will use something like:

r'^main1/\w+/$'

which will pass all characters matching the regex (here, alphanumeric
chars) to the view you specify as a positional arg.  You can also pass
them as a kwarg.  Read here:  
http://docs.djangoproject.com/en/dev/topics/http/urls/

>
> Is there a way to do something like: (r'^(.*)/(.*)/$', view), (I know
> this doesn't work)

To do something like that, instead of wildcarding everything greedily,
just pass a range of characters and symbols you will not accept
(whitespace, etc.) by using [^don't_accept_these] in your regex.

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



Re: query date by string

2010-12-03 Thread owidjaya
It says incorrect date value.

On Dec 3, 8:44 am, wayne  wrote:
> You should be able to do it just as you mention, passing the query
> string to cursor.execute().
>
> Seehttp://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-...
>
> Have you tried this?  Are you getting an error?  If so, what is 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: weird template escaping

2010-12-03 Thread wayne
Turn autoescape off (http://docs.djangoproject.com/en/dev/ref/
templates/builtins/?from=olddocs#autoescape) or mark it as safe by
using the "safe" template filter tag (lower on the 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: query date by string

2010-12-03 Thread wayne
You should be able to do it just as you mention, passing the query
string to cursor.execute().

See 
http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly

Have you tried this?  Are you getting an error?  If so, what is 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how can I clean a form field before the clean method?

2010-12-03 Thread wayne
Well, it depends on how sensitive and dynamic my_field needs to be.
You could always pre-populate the form with my_field set to a value,
and mark its input type as hidden (if it is not sensitive).

If you are working with a ModelForm, you could use one of the methods
here:  
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form.

Lastly, you could do it in the view during your processing of
request.POST, as you mention.  Doing it in one of the validation
methods like you mention _should_ work, but I usually like to keep my
clean methods validation-only (and not use them to manipulate data).

Wayne

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



query date by string

2010-12-03 Thread owidjaya
in php I can run the following query for mysql

SELECT * FROM some_table WHERE some_date LIKE "2010%"

How do i do this in django using cursor.execute()?

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



how can I clean a form field before the clean method?

2010-12-03 Thread refreegrata
Hello list, I want to do something like my_field = 1000(this value can
change depending of some situations, but the idea is a value injected
with Django, not with some data entered by the user in the HTML form.

I already try this:
-
def clean(self):
cleaned_data = self.cleaned_data
cleaned_data['my_field'] = 44
return cleaned_data
-
and this

def clean_my_field(self):
 return 44


but don't work, I think that the exception is launched before of the
summoning to any of this functions. How can I solve this situation?
The idea isn't do an edition in the view of the request.POST

Thanks for read, and sorry for my poor english.

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



Re: Fwd: Django in production on Windows

2010-12-03 Thread ashdesigner
Pete,

Thank you for your advice, and considering our rather long discussion
I already think now that Win+Apache+MSSQL is the best way out for us
indeed. Both for performance and support matters.

Anthony

On Dec 3, 4:57 pm, CrabbyPete  wrote:
> Windows is a great platform to work on. There are loads of tools and
> support for Windows. The issue is not Windows vs Linux
> the issue is Apache ( which works great on Windows ) v IIS. If your
> admin is wants to use Windows by all means stick with it, and just
> install Apache. I developed on Windows and deployed on both Windows
> servers and Unix servers. Stay platform neutral and it won't matter.
>
> On Dec 2, 10:32 am, ashdesigner  wrote:
>
> > Javier,
>
> > Under "hack approach" I meant PyISAPIe + IIS (wich is weird by itself,
> > but still).
>
> > Anthony
>
> > On Dec 2, 6:25 pm, Javier Guerra Giraldez  wrote:
>
> > > On Thu, Dec 2, 2010 at 10:05 AM, ashdesigner  
> > > wrote:
> > > > not to use Python/Django
> > > > +IIS+Windows because of lack of support and tools immaturity ("hack"
> > > > approach).
>
> > > not at all.   there are lots of goods reasons to go the *nix route (be
> > > it Linux, BSD, Solaris, etc).  but Django does work anywhere Python
> > > does.
>
> > > FastCGI is _not_ a 'hack'.  It's a standard
>
> > > --
> > > 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Fwd: Django in production on Windows

2010-12-03 Thread ashdesigner
Matt,

Thank you so much for your posting. My initial question was indeed
about both the webserver AND the database, but I believe you're the
first who commented on the latter.
I am already aware about the Django + MSSQL issue, but compared to the
Django+IIS, there are stable solutions that run solid in production
mode.

As mentioned in the SO blog you indicated, we as well have a heavily
invested MSSQL environment, direct interface to which (as opposed to
XML-RPC calls, for instance) is more than just an advantage.

Anthony

On Dec 3, 5:26 pm, Matt Conrad  wrote:
> I notice that the conversation is mostly about IIS vs Apache.
>
> You'll also want to think about the database. Django doesn't have
> built in support for MSSQL. You could run Postgres or MySQL on
> Windows, or there are some adapters for Django that will let it talk
> to SQL Server. Either way, you'll probably want to think about this up
> front.
>
> I haven't got any experience with this, but others here probably do.
> If you want to stick with MSSQL, here's a discussion from a year ago
> on SO to get you 
> started:http://stackoverflow.com/questions/842831/using-sql-server-with-djang...
>
> Matt
>
> On Fri, Dec 3, 2010 at 5:32 AM, ashdesigner  wrote:
> > Ok, I see. Happily, this is not the case with us. We've discussed the
> > issue with the crew, and our decision is that most likely we'll deploy
> > on Win+Apache.
> > Hope there won't be any considerable development limitations due to
> > the use of the Windows Server OS.
>
> > Thank you a lot!
>
> > Regards,
> > 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-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.



weird template escaping

2010-12-03 Thread Robin Becker

Hi, I have a custom Form that's attempting to expand the following

field.label=u'Elegant, sophisticated, discover Egypt\u2019s local customs'

in a template. The template code looks like


  {{ field.label }}

using some special debugging tricks I can determine that, immediately prior to 
the expansion, the field.label value is still in unicode and has the right value.


However, when the expansion takes place I see the following in the output html



Elegant, sophisticated, discover Egyptâ€s local customs
  

so it looks as though something is being silly and doing the following

1) translate to utf8 ie 'Elegant, sophisticated, discover Egypt\xe2\x80\x99s 
local customs'


2) escaping \x99 as  (trademark char is  == )

where should I start looking to locate the problem?
--
Robin Becker

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



Re: Fwd: Django in production on Windows

2010-12-03 Thread Matt Conrad
I notice that the conversation is mostly about IIS vs Apache.

You'll also want to think about the database. Django doesn't have
built in support for MSSQL. You could run Postgres or MySQL on
Windows, or there are some adapters for Django that will let it talk
to SQL Server. Either way, you'll probably want to think about this up
front.

I haven't got any experience with this, but others here probably do.
If you want to stick with MSSQL, here's a discussion from a year ago
on SO to get you started:
http://stackoverflow.com/questions/842831/using-sql-server-with-django-in-production

Matt


On Fri, Dec 3, 2010 at 5:32 AM, ashdesigner  wrote:
> Ok, I see. Happily, this is not the case with us. We've discussed the
> issue with the crew, and our decision is that most likely we'll deploy
> on Win+Apache.
> Hope there won't be any considerable development limitations due to
> the use of the Windows Server OS.
>
> Thank you a lot!
>
> Regards,
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Fwd: Django in production on Windows

2010-12-03 Thread CrabbyPete
Windows is a great platform to work on. There are loads of tools and
support for Windows. The issue is not Windows vs Linux
the issue is Apache ( which works great on Windows ) v IIS. If your
admin is wants to use Windows by all means stick with it, and just
install Apache. I developed on Windows and deployed on both Windows
servers and Unix servers. Stay platform neutral and it won't matter.

On Dec 2, 10:32 am, ashdesigner  wrote:
> Javier,
>
> Under "hack approach" I meant PyISAPIe + IIS (wich is weird by itself,
> but still).
>
> Anthony
>
> On Dec 2, 6:25 pm, Javier Guerra Giraldez  wrote:
>
> > On Thu, Dec 2, 2010 at 10:05 AM, ashdesigner  
> > wrote:
> > > not to use Python/Django
> > > +IIS+Windows because of lack of support and tools immaturity ("hack"
> > > approach).
>
> > not at all.   there are lots of goods reasons to go the *nix route (be
> > it Linux, BSD, Solaris, etc).  but Django does work anywhere Python
> > does.
>
> > FastCGI is _not_ a 'hack'.  It's a standard
>
> > --
> > 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ORA-01425

2010-12-03 Thread Tim Sawyer

On 03/12/10 12:52, Jani Tiainen wrote:

On Thursday 02 December 2010 17:13:48 Tim Sawyer wrote:

Hello,

I'm using Django against an Oracle 10 database.  It used to work.  Then
they upgraded it to 10.2.0.5 (not sure what from, I can probably find out).

This query now gives: ORA-01425: escape character must be character
string of length 1.

'SELECT "BROKER_LENDER_LOG"."BLL_SECURITY_TOKEN",
"BROKER_LENDER_LOG"."BLL_TRANSACTION",
"BROKER_LENDER_LOG"."BLL_TYPE",
"BROKER_LENDER_LOG"."BLL_AGREEMENT_NUMBER",
"BROKER_LENDER_LOG"."BLL_MODULE",
"BROKER_LENDER_LOG"."BLL_LENDER",
"BROKER_LENDER_LOG"."BLL_SERIAL",
"BROKER_LENDER_LOG"."BLL_VERSION",
"BROKER_LENDER_LOG"."BLL_JOBID",
"BROKER_LENDER_LOG"."BLL_PROJECT",
"BROKER_LENDER_LOG"."BLL_XML",
"BROKER_LENDER_LOG"."BLL_LENDER_RESPONSE", "BROKER_LENDER_LOG"."BLL_DATE"
FROM "BROKER_LENDER_LOG" WHERE ("BROKER_LENDER_LOG"."BLL_JOBID" LIKE
TRANSLATE(%s USING NCHAR_CS) ESCAPE TRANSLATE(\'\\\' USING NCHAR_CS) AND
"BROKER_LENDER_LOG"."BLL_MODULE" = %s ) ORDER BY
"BROKER_LENDER_LOG"."BLL_SERIAL" ASC'

I guess the problem is:

LIKE TRANSLATE(%s USING NCHAR_CS) ESCAPE TRANSLATE(\'\\\' USING NCHAR_CS)

where it thinks that \'\\\' is more than one character?

Cheers for any clues,


I'm running against 10.2.0.5 (64 bit) and I don't see that problem appear.
Same appliest to other 10.2.0.x series, all of them work with that LIKE part.

Reason just was that LIKEC queries took ages in my modest 21M rows containing
address table.

Could that be some artifacts from upgrade migration progress - I know it has
happened sometimes.

Can you also post you charsets you're using, maybe they're causing some
oddities here - with Oracle you never know .


Hi,

We're on Solaris Sparc, 64-bit.  Charset is WE8MSWIN1252

Tim.

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



Re: Initial Create Table Script

2010-12-03 Thread Tim Sawyer

Excellent, thanks.

I needed to run

./manage.py sql auth
./manage.py sql sites
./manage.py sql sessions
./manage.py sql admin
./manage.py sql contenttypes

to get what I needed.

Cheers,

Tim.

On 03/12/10 12:45, Anurag Chourasia wrote:

Yes there is.

You need to use

*./manage.py sql auth*

instead of

*./manage.py sql django.contrib.auth*

Regards,
Anurag

On Fri, Dec 3, 2010 at 5:48 PM, Tim Sawyer > wrote:

Is there a way to generate a sql script that gets the entire table
structure required for a django project?  Including contrib.auth etc.

./manage.py sql django.contrib.auth is giving me:

Error: App with label django.contrib.auth could not be found. Are
you sure your INSTALLED_APPS setting is correct?

INSTALLED_APPS = (
'django.contrib.auth',
...
)

I don't have direct access to the database that I'm running against
on a customer site - therefore I need a script to create the database.

Thanks,

Tim.

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


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


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



Re: Initial Create Table Script

2010-12-03 Thread Anurag Chourasia
Yes there is.

You need to use

*./manage.py sql auth*

instead of

*./manage.py sql django.contrib.auth*

Regards,
Anurag

On Fri, Dec 3, 2010 at 5:48 PM, Tim Sawyer wrote:

> Is there a way to generate a sql script that gets the entire table
> structure required for a django project?  Including contrib.auth etc.
>
> ./manage.py sql django.contrib.auth is giving me:
>
> Error: App with label django.contrib.auth could not be found. Are you sure
> your INSTALLED_APPS setting is correct?
>
> INSTALLED_APPS = (
>'django.contrib.auth',
> ...
> )
>
> I don't have direct access to the database that I'm running against on a
> customer site - therefore I need a script to create the database.
>
> Thanks,
>
> Tim.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Initial Create Table Script

2010-12-03 Thread Tim Sawyer
Is there a way to generate a sql script that gets the entire table 
structure required for a django project?  Including contrib.auth etc.


./manage.py sql django.contrib.auth is giving me:

Error: App with label django.contrib.auth could not be found. Are you 
sure your INSTALLED_APPS setting is correct?


INSTALLED_APPS = (
'django.contrib.auth',
...
)

I don't have direct access to the database that I'm running against on a 
customer site - therefore I need a script to create the database.


Thanks,

Tim.

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



100-Continue

2010-12-03 Thread mrz
I need to implement the server side of a REST API that allows file
upload from client processes (not from browsers). The request is a
PUT, with an Expect: 100-Continue header (among other usual header
fields). This should allow the server to check the header fields and
abort the rest of the upload in case authentication fails or any
header is missing. How can I implement a handler for this in Django?
Anybody implemented 100-Continue handling?

It happens to be that the client script is also written in Python,
using the httplib library. I can debug it, but I am not supposed to
change its behavior. In other words, I have to support 100-Continue by
my server, I do not have a choice.

If I step through the sender script, I can see that my Django view
handler function is called right when the client executes the
http_connection.endheaders() method. I can see all the headers on the
server side. Then the client starts sending the file content with
repeated calls to http_connection.send(data), but on typically the
second call it receives an exception with a broken pipe: obviously the
server closed the connection. How do I send back the 100-Continue
response without loosing the connection? It seems that whatever I
return from the view handler method, the connection is closed right
away. Correct?

I only tested this on the built-in development server.

Any help would be 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-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.



main categories in menu

2010-12-03 Thread Rob
I want to make main categories on my site like:
/main1/page1
/main2/page2
/main3/page3

I would like to make those categories dynamically with a m2m . In that
case I can assign pages to one or more main categories.

I have a problem now with urls.py As far as I know I can only "catch"
one variable like:
(r'^main1/(.*)/$', view), In this way I have to add every main
category manually to urls.py

Is there a way to do something like: (r'^(.*)/(.*)/$', view), (I know
this doesn't work)

Or should I catch everything from the url and try to split the url in
the view?
(r'^(.*)$', view),

A consideration I have that I will end up having double content (which
is bad for Google). Is it also an option to remember the choice made
in a session, and render the menu on page load (through middleware)?



Rob

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



Re: Fwd: Django in production on Windows

2010-12-03 Thread ashdesigner
Ok, I see. Happily, this is not the case with us. We've discussed the
issue with the crew, and our decision is that most likely we'll deploy
on Win+Apache.
Hope there won't be any considerable development limitations due to
the use of the Windows Server OS.

Thank you a lot!

Regards,
Anthony

On Dec 3, 2:13 pm, Javier Guerra Giraldez  wrote:
> On Fri, Dec 3, 2010 at 4:04 AM, ashdesigner  wrote:
> > Frankly, I just don't quite get the #3 option. Do you mean switching
> > to *nix would entail considerable support/management issues? If so,
> > why *nix - native to Django - as you say, could be a limitation to the
> > framework? Is this what you mean?
>
> No,  I mean that, if you're in a windows-only organization, and your
> admins don't cooperate, just suggesting another platform for Django
> could be seen by management as a limitation of Django and not a
> problem of their chosen platform.
>
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Fwd: Django in production on Windows

2010-12-03 Thread Javier Guerra Giraldez
On Fri, Dec 3, 2010 at 4:04 AM, ashdesigner  wrote:
> Frankly, I just don't quite get the #3 option. Do you mean switching
> to *nix would entail considerable support/management issues? If so,
> why *nix - native to Django - as you say, could be a limitation to the
> framework? Is this what you mean?

No,  I mean that, if you're in a windows-only organization, and your
admins don't cooperate, just suggesting another platform for Django
could be seen by management as a limitation of Django and not a
problem of their chosen platform.



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



models don't show in tamplate

2010-12-03 Thread Carlos Aboim
Hi guys,
Is there a reason for my models don't show up in my template?

my urls on app folder:
http://dpaste.com/hold/282583/

my template:
http://dpaste.com/hold/282586/

I can access through shell to models instaces,


Any help whould be apreciated

thank you
Aboim

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



Re: ANN: django-currencies 0.2.2

2010-12-03 Thread Isaac XxX
Nice app!

I will keep an eye to it, maybe it can be useful for one of my projects

On Fri, Dec 3, 2010 at 11:17 AM, Panos Laganakos
wrote:

> Description:
>
> django-currencies allows you to define different currencies, and
> includes template tags/filters to allow easy conversion between them.
>
> Download: http://pypi.python.org/pypi/django-currencies/0.2.2
> Documentation: http://packages.python.org/django-currencies/
> Source Code: https://launchpad.net/django-currencies
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



ANN: django-currencies 0.2.2

2010-12-03 Thread Panos Laganakos
Description:

django-currencies allows you to define different currencies, and
includes template tags/filters to allow easy conversion between them.

Download: http://pypi.python.org/pypi/django-currencies/0.2.2
Documentation: http://packages.python.org/django-currencies/
Source Code: https://launchpad.net/django-currencies

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



Re: Fwd: Django in production on Windows

2010-12-03 Thread ashdesigner
Javier,

Frankly, I just don't quite get the #3 option. Do you mean switching
to *nix would entail considerable support/management issues? If so,
why *nix - native to Django - as you say, could be a limitation to the
framework? Is this what you mean?

Anthony

On Dec 2, 7:23 pm, Javier Guerra Giraldez  wrote:
> On Thu, Dec 2, 2010 at 10:57 AM, ashdesigner  
> wrote:
> > browsing through techy blogs I often saw FastCGI mentioned as someway 
> > 'slow',
> > 'deprecated',
>
> you're reading the wrong blogs
>
> > 'IIS7-incompatible'
>
> that might be true, i have no idea.  a big reason to stay far from IIS
>
> unfortunately, i've just checked that both Gunicorn and Tornado are
> *nix only.  no big surprise, since both use modern prefork+events
> architectures, which are clumsy on windows (to say the least).
>
> so, i think you have few options:
>
> 1: find if IIS can do FastCGI (and it should)
>
> 2: switch to a complete webserver (apache, ligthttp, nginx)
>
> 3: switch platforms.
>
> in the long run, option 3 is the best; but dealing with management,
> inertia and zealotry are huge obstacles, and it would be seen as a
> Django limitation; so i would seriously try option 1 first.
>
> option 2 is very good also, and note that both ligthttp and nginx are
> growing in usage precisely because they're extremely light and fast.
> also, see the fact that both use FastCGI as the main method to connect
> with backend apps.
>
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Records detected by admin site, but not displayed?

2010-12-03 Thread Sithembewena Lloyd Dube
Hi Wayne,

Thanks for responding. This actually helped me to trace the problem. Yes, I
did extend the admin User (default django user) as follows - this is in
models.py:

from django.contrib.auth.models import User

class BlogUser(models.Model):
 user = models.ForeignKey(User, unique=True)
 avatar = ThumbnailerImageField(upload_to='avatars/users', blank=False)

The point is that I wanted the default user to have an avatar by 'extending'
the model.


I then have a BlogPost class with a field as follows:

author =  models.ForeignKey(User)

and a BlogComment class with a field as follows:

blog_post =   models.ForeignKey(BlogPost)

If I display a Blog Post by the default user and wish to show their avatar,
I need to map the author foreignkey relationship in the BlogPost model to
the extension model, BlogUser because that is where the field is.

Unfortunately, this seems to break the admin. Is there a way I can get the
extension model in code from the default, or extended, model?

Thanks,
Lloyd


On Thu, Dec 2, 2010 at 6:46 PM, wayne  wrote:

> On Dec 2, 8:15 am, Sithembewena Lloyd Dube  wrote:
> > Hi all,
> >
> > I have an admin site enabled for my Django project. For some reason, some
> > records are no longer displayed (they were displayed just fine before).
> >
> > Tried restarting the dev server to no avail.
> >
> > Please see the attached screen dump? What could be causing this?
>
> Have you made any recent changes?  Have you overridden any admin
> templates?  Did you specify anything in a Blog Admin class?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


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