newforms for idiots and designers?

2007-07-20 Thread Austin Govella

I'm *almost* getting forms to work, but not quite.

Can anyone recommend a newforms tutorial written for designers?
Something akin to Zoolander's School for Kids Can't Program Good.



(And I *have* been reading. What's odd is that I used similar
structures when I was coding php and coldfusion, but I can't get it to
work here.)



-- 
Austin Govella
Thinking & Making: IA, UX, and IxD
http://thinkingandmaking.com
[EMAIL PROTECTED]

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



Re: foreign key on database not created with models referencing from other application

2007-07-20 Thread james_027

Hi,

I dont know what you mean by what_I_have_done?

I just follow the django tutorial. the one with poll and choice model.
I did every step. and that's my result.

However I have discover something 

this setting
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',

)

vs this setting

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',

)

will produce a different result ... the first setting will have
foreign key on the django_admin_log table while the 2nd table dont
have the foreign key. I have do this multiple time, changing the
settings between the first and the second and the result is constant.

do we have ordering in creating models?

thanks
james
On Jul 21, 12:49 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote:
>
>
>
> > I didn't say that the relation aren't working, I just wondering why
> > foreign key wasn't created in my case. I am using both SQL Manager
> > 2005 lite and MySQL Administrator just to take a look at the table
> > created.
>
> When I run your example, the foreign key IS created. You are not the
> first person to create a foreign key reference across applications,
> and we haven't had any other complaints to date, so I am almost 100%
> confident that the problem isn't with Django.
>
> I would like to help you solve your problem. Unfortunately, I'm not
> telepathic. I can't help you if refuse to tell me WHAT YOU HAVE DONE.
>
> Yours,
> Russ Magee %-)


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



Re: foreign key on database not created with models referencing from other application

2007-07-20 Thread Russell Keith-Magee

On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> I didn't say that the relation aren't working, I just wondering why
> foreign key wasn't created in my case. I am using both SQL Manager
> 2005 lite and MySQL Administrator just to take a look at the table
> created.

When I run your example, the foreign key IS created. You are not the
first person to create a foreign key reference across applications,
and we haven't had any other complaints to date, so I am almost 100%
confident that the problem isn't with Django.

I would like to help you solve your problem. Unfortunately, I'm not
telepathic. I can't help you if refuse to tell me WHAT YOU HAVE DONE.

Yours,
Russ Magee %-)

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



Deleting an item out of my dictionary?

2007-07-20 Thread Greg

Hello,
I have the following views

def showcart(request, style_id, choice_id):
s = Style.objects.get(id=style_id)
#assert False,s
c = Choice.objects.get(id=choice_id)
#x = c.size, " ", c.price
cart = request.session.get('cart', [])
cart.append({'style': s, 'choice': c})
request.session['cart'] = cart
pr = 0
for a in cart:
pr = pr + a['choice'].price.name
return render_to_response('show_test.html', {'mychoice': cart, 'p':
pr})


def deletecart(request):
del request.session['cart'][0]
# x = request.session['cart'][0]
# assert False,x
return render_to_response('themainpage.html', {})



Shouldn't the line in the 'deletecart' view delete the first item in
my dictionary?  Whenever I access the 'deletecart' view I don't get an
error, but it doesn't delete the dictionary[0] element.

Whenever I do a 'assert False, x' I get the following error:

{'style': , 'choice': ,
)>}

so why isn't the above line getting deleted from my dictionary when
using 'del request.session['cart'][0]'?

Thanks for any help


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



Re: foreign key on database not created with models referencing from other application

2007-07-20 Thread james_027

I didn't say that the relation aren't working, I just wondering why
foreign key wasn't created in my case. I am using both SQL Manager
2005 lite and MySQL Administrator just to take a look at the table
created.

any idea?

james

On Jul 21, 11:16 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am doing this in winxp , mysql 5 , python 2.5 , latest mysql driver
> > for python. Hope I've provided enough info.
>
> Not even close.
>
> Perhaps I'm not being clear. I have tried your example. It works for
> me. The fact that many thousands of other people use Django and
> haven't experienced this problem leads me to suspect that the problem
> lies with you, not Django.
>
> However, you are obviously having a problem. What I need you to do is
> provide me STEP BY STEP INSTRUCTIONS of EXACTLY what you have done.
> Starting with no database in existence, and no django project at all,
> how did you get into the situation?
>
> I also need to know HOW DO YOU KNOW THAT THE RELATION DOESN'T EXIST.
> Are you guessing? Is a query not working like you expect? Are you
> inspecting a GUI somewhere? Are you issuing an SQL query manually?
>
> Yours,
> Russ Magee %-)


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



get 5$ cash for free in your paypal account

2007-07-20 Thread newbar

get 5$ cash for free in your paypal account


check it !!!

http://www.cash-dreams.biz


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



Re: Newforms - attributes for splitdatetimewidget

2007-07-20 Thread Russell Keith-Magee

On 7/21/07, jeffhg58 <[EMAIL PROTECTED]> wrote:
>
> I am just digging into the newforms functionality. I am looking at the
> splitdatetimewidget.
> I am trying to having a different attributes for the first field and
> the second field, and would like to know how to go about doing it.

I would suggest setting up some purpose based widgets - a DateWidget
and a TimeWidget - that define their attributes. Then, compose your
SplitDateTimeWidget out of the two custom widgets, rather than using
two standard TextInputs and trying to pass attributes down to 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: foreign key on database not created with models referencing from other application

2007-07-20 Thread Russell Keith-Magee

On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> I am doing this in winxp , mysql 5 , python 2.5 , latest mysql driver
> for python. Hope I've provided enough info.

Not even close.

Perhaps I'm not being clear. I have tried your example. It works for
me. The fact that many thousands of other people use Django and
haven't experienced this problem leads me to suspect that the problem
lies with you, not Django.

However, you are obviously having a problem. What I need you to do is
provide me STEP BY STEP INSTRUCTIONS of EXACTLY what you have done.
Starting with no database in existence, and no django project at all,
how did you get into the situation?

I also need to know HOW DO YOU KNOW THAT THE RELATION DOESN'T EXIST.
Are you guessing? Is a query not working like you expect? Are you
inspecting a GUI somewhere? Are you issuing an SQL query manually?

Yours,
Russ Magee %-)

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



Re: I have a class in my Models that contains one field which happens to be an integer type

2007-07-20 Thread Russell Keith-Magee

On 7/21/07, jeffself <[EMAIL PROTECTED]> wrote:
>
> How do I get the season to
> display in the select box of my season field on the Game form?
> Normally this would be fixed by using def __unicode__(self) but since
> its not a CharField, I can't use that.  I tried def __integer__(self)
> but that didn't make a difference.

You were on the right track with __unicode__().

__unicode__ is the instructions to Python as to how to produce a
human-readable representation of this object (in unicode). I'm
guessing what you tried was:

def __unicode__(self):
   return self.year

which failed. This failed because what you are returning is an
integer, not a unicode string, so when the return value is combined
with other strings it raises an error. However, if you make a slight
change to convert the year into a string before it is returned:

def __unicode__(self):
   return unicode(self.year)

Everything should work nicely. You can even get creative, and add in
other bits of text:

def __unicode__(self):
   return unicode(self.year) + u" Season"

So that what gets display isn't just a year, but "1999 Season".

Hope this helps.

Yours,
Russ Magee %-)

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



Re: foreign key on database not created with models referencing from other application

2007-07-20 Thread james_027

Hi,

The table was created fine with only a small problem and it's the
foreign key. I have my application listed on settings.py, code my
model on models.py, then perform manage.py syncdb my_app as I am aware
that if the table exist it wont recreate it. I did a number of times
of deleting my tables and do manage.py syncdb my_app.

As I stated the django_admin_log table should also have foreign key
which also doesn't have it since it has a relation to auth_user table.

I am doing this in winxp , mysql 5 , python 2.5 , latest mysql driver
for python. Hope I've provided enough info.

Thanks
james

On Jul 21, 10:38 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote:
>
>
>
> > When the relationship is within the same namespace (am I using the
> > right term, pls correct me) the manage.py syncdb create the tables
> > without a problem if all the tables are create on the same time, but
> > if the tables weren't created the same time it also fail to create the
> > foreign keys.
>
> I think you need to be a little bit more clear on what you have done -
> and I mean precise instructions. _EXACTLY_ what steps have you taken,
> and how have you come to the conclusion that the foreign key hasn't
> been created?
>
> Creating tables is an operation that gets done every day by many
> people, without difficulty. I have tried the models file you provide,
> in various orders of creation, and have had no problems. Without
> knowing exactly what you have done, it is impossible to know what has
> gone wrong.
>
> Yours,
> Russ Magee %-)


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



Re: Accessing the backend's string-quoting functionality?

2007-07-20 Thread Russell Keith-Magee

On 7/21/07, Tim Chase <[EMAIL PROTECTED]> wrote:
>
> >> Is there a way to access the back-end's string-quoting mechanism?
> >
> > from django.db import backend
> > foo_quoted = backend.quote_name('foo')
>
> This seems to be (browsing the code) the table/field-name
> escaping mechanism, not the "escaping/quoting dangerous
> characters in a string so it can be put in a query" function.

Are you sure you're not looking for the 'params' argument to extra?
This will use the cursors string substitution, which should to the
escaping/quoting you are looking for (IIRC).

Yours,
Russ Magee %-)

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



Re: Mapping models to CRUD urls?

2007-07-20 Thread Russell Keith-Magee

On 7/21/07, John Matthew <[EMAIL PROTECTED]> wrote:

> Given that, I assume that the cache will look at the http://.../model3/add/
> and cache that?  meaning it doesn't add the parameters to the cache lookup?

Ultimately it will depend on your caching mechanism, but in theory,
any page that has been retrieved with GET should be cacheable, without
consequence, parameters and all. GET is intended to be a resource
retrieval, and if you're just retrieving, you're not modifying the
server, so it should be cachable.

Remember, the object isn't created until you POST the data, and it's
the POST that can't be cached. Caching the GET ..model3/add/?model1=2
page just means that the unsubmitted form with a hinted value for
model1 has been cached, ready for the next person that wants to add an
instance of model3 with the same hinted value.

> Thanks again for all your help.

No problems. Happy to help.

Yours,
Russ Magee %-)

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



Re: foreign key on database not created with models referencing from other application

2007-07-20 Thread Russell Keith-Magee

On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> When the relationship is within the same namespace (am I using the
> right term, pls correct me) the manage.py syncdb create the tables
> without a problem if all the tables are create on the same time, but
> if the tables weren't created the same time it also fail to create the
> foreign keys.

I think you need to be a little bit more clear on what you have done -
and I mean precise instructions. _EXACTLY_ what steps have you taken,
and how have you come to the conclusion that the foreign key hasn't
been created?

Creating tables is an operation that gets done every day by many
people, without difficulty. I have tried the models file you provide,
in various orders of creation, and have had no problems. Without
knowing exactly what you have done, it is impossible to know what has
gone wrong.

Yours,
Russ Magee %-)

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



Re: Django, python 2.5 and macports 1.5

2007-07-20 Thread jeffself



On Jul 20, 4:50 am, lars <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> yesterday I tried to install django on my macbook. Since I wanted to
> have a more recent python interpreter I installed the one from
> macports.
> There's a pitfall, however. Because in order to get MD5 running you
> have to install the package py25-hashlib as well! Otherwise you will
> face the "ImportError: No module named _md5" error.
>
> Just wanted to post this hint in case someone else runs into the same
> problem :-)
>
> Yours,
> Lars

I ran into that problem a few weeks ago.  I believe I posted something
about it.  Basically, I was told install Python from source.  So I did
and everything worked fine.


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



I have a class in my Models that contains one field which happens to be an integer type

2007-07-20 Thread jeffself

In my model for my application, I've created a class called Season.
There is only one field in this class and that is called year and its
of type integer.  In another class called Game, I have a field called
season which is a ForeignKey to Season.  When I bring up the add Game
form in the Admin, my Season select box only displays 'Season Object'
instead of the value of the season.  How do I get the season to
display in the select box of my season field on the Game form?
Normally this would be fixed by using def __unicode__(self) but since
its not a CharField, I can't use that.  I tried def __integer__(self)
but that didn't make a difference.

I'm pretty new to Django and I'm loving it so far.

Thanks!


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



foreign key on database not created with models referencing from other application

2007-07-20 Thread james_027

I am very new to django, I am creating a model with a field of
models.ForeignKey(User) #django.contrib.auth.models import User. When
I look at the database, my table has no foreign key define. Another
example is the django.contrib.admin.models.LogEntry model it has user
= models.ForeignKey(User) which is also from
django.contrib.auth.models.user.

When the relationship is within the same namespace (am I using the
right term, pls correct me) the manage.py syncdb create the tables
without a problem if all the tables are create on the same time, but
if the tables weren't created the same time it also fail to create the
foreign keys.

Where should I look to correct this problem.

from django.db import models

from django.contrib.auth.models import User



# Create your models here.

DEPARTMENTS = (
 ('HRD', 'HRD'),
 ('ACT', 'Accounting'),
 ('PUR', 'Purchasing'),
 ('LOG', 'Logistics'),
 ('PRO', 'Production'),
 ('MKG', 'Marketing'),
 ('EXP', 'Export'),
 ('ITD', 'IT'),
)



LEVELS = (
 ('SM', 'Senior Manager'),
 ('MR', 'Manager'),
 ('SP', 'Supervisor'),
 ('ST', 'Staff'),
)

class Profile(models.Model):
 """KSK Employee accounts to use this application""
 user = models.ForeignKey(User)
 department = models.CharField(maxlength=3, choices=DEPARTMENTS)
 level = models.CharField(maxlength=3, choices=LEVELS)


Thanks james


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



Re: Which database, and why?

2007-07-20 Thread theju

On Jul 20, 10:50 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
> I know that PostgreSQL is recommended, but why? Are the django
> developers assuming a high-traffic, database intensive site. Are the
> django developers assuming that you will not be using shared hosting?

> I seems to me, that if you are using shared hosting, and if your
database needs are modest, Sqlite3 might be the best choice.

Most shared hosting providers provide support for postgresql also (I
can quote the case of webfaction here). Postgresql is an ACID
compliant database server and has a lot of features that databases
like MySQL do not support like check constraints. If you plan to have
a moderate traffic website (with less than 1000 hits per day) I would
recommend SQLite (which too is ACID compliant). The primary reason
most Django developers prefer Postgresql is that it scales very well.
The only reason to go for MySQL should be if you have no alternative.
MySQL may be very easy to setup and administer but it isn't ACID
compliant.

Cheers
Thejaswi Puthraya


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



Newforms - attributes for splitdatetimewidget

2007-07-20 Thread jeffhg58

Hi,

I am just digging into the newforms functionality. I am looking at the
splitdatetimewidget.
I am trying to having a different attributes for the first field and
the second field, and would like to know how to go about doing it.

Here is the snippet of my code

calendar_widget =
forms.widgets.SplitDateTimeWidget(attrs={'class':"vDateField
required", 'size':10})

AddEventFormClass.base_fields['event_date'].widget = calendar_widget

I am trying to use the class of vTimeField for the second field.

Thanks,
Jeff


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



Re: Which database, and why?

2007-07-20 Thread Joe Bloggs
PostgreSQL scales better with more users

http://tweakers.net/reviews/649/7

MySQL accepts the date 31st February 2007 and has several other lax views of
rounding data or squeezing it in when it should reject it.

http://safari.oreilly.com/0596002114/msql2-CHP-16-SECT-3

MySQL only supports transactions with the InnoDB backend which has been
bought by Oracle.

http://www.innodb.com/

You can do a hot backup  ( backup when the database is open ) of PostgreSQL
without buying software - you have to buy the InnoDB hot backup software.

The best point for MySQL is that the query "select count(*) from table" is
much quicker than PostgreSQL.

You have to remember to auto vaccuum a postgresql database to get rid of old
data that is no longer required.

MySQL is dual licensed both open source and commercial. I still haven't got
my head around this one - if you distribute a product that includes MySQL
for money then you need to buy a license. PostgreSQL is the BSD license so
is totally free to use as you wish.

In general if you don't already have expertise in MySQL then you should
always choose PostgreSQL - my opinion for what it's worth :-)



On 7/20/07, walterbyrd <[EMAIL PROTECTED]> wrote:
>
>
> I know that PostgreSQL is recommended, but why? Are the django
> developers assuming a high-traffic, database intensive site. Are the
> django developers assuming that you will not be using shared hosting?
>
> I seems to me, that if you are using shared hosting, and if your
> database needs are modest, Sqlite3 might be the best choice.
> Especially when Python 2.5 becomes more standard on shared hosting.
>
> For one thing, with sqlite, you don't have to share a database server
> with others. Judging from the way Drupal runs on dot5hosting, or
> dreamhost, this might make a real difference. Also sqlite is almost
> trivial to setup and administrate.
>
> Has anybody had any particular difficulties with MySQL?
>
>
> >
>

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



Re: Some questions on Django's authentication system

2007-07-20 Thread Nathan Ostgard

Regarding the first question, you can do this by creating a middleware
class which checks for authenticated users by default. You could also
created a decorator to tag view functions as public. For example...

in file yourproject/yourapp/middleware.py:

  from django.conf import settings
  from django.contrib.auth import REDIRECT_FIELD_NAME
  from django.http import HttpResponseRedirect
  from urllib import quote

  def allow_anonymous(view_func):
view_func.allow_anonymous = True
return view_func

  class RequireLogin:
def process_view(self, request, view_func, view_args,
view_kwargs):
  if not getattr(view_func, 'allow_anonymous', False) and not
request.user.is_authenticated():
return HttpResponseRedirect('%s?%s=%s' % (settings.LOGIN_URL,
REDIRECT_FIELD_NAME, quote(request.get_full_path(

Then add 'yourproject.yourapp.middleware.RequireLogin' to
MIDDLEWARE_CLASSES in settings.py.

Now you can use it in your view:

  from yourproject.yourapp.middleware import allow_anonymous

  def some_private_view(request):
# won't be accessible unless user is logged in
return HttpResponse('Hello, user!')

  @allow_anonymous
  def some_public_view(request):
return HttpResponse('Hello, world!')

eXt wrote:
> Hi all!
>
>I build an application which will use Django's authentication
> system. This is my first Django application that uses auth system, so
> sorry if the questions below are trivial.
>
>1. Do I have to decorate all views with login_required if I want to
> keep them secured? Isn't there any inversed method which will secure
> all views by default, and I will only enable some of them to public?
>
>2. My use case is that I need to save ip addresses of users who are
> logging into my application. First thing is how to extend user model,
> but I think that I found the proper solution in Django Book (user
> profile). Second thing is what to do to catch 'logging in' event to be
> able to read an ip from request and save it (even if the
> authentication isn't successful)? Is it possible to set an event on
> existing login method (django.contrib.auth.views.login), or should I
> do something different, for example write my own login view?
>
> Hmm.. thats all :)
>
> Thanks in advance.
>
> --
> Jakub Wisniowski


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



Re: removal of Django

2007-07-20 Thread Julio Nobrega

  Hi,

  You probably went to a website and saw a 404 error message saying
that Django could not find the page. The thing is that what you're
seeing is the message sent by Django installed on the server, not on
your computer. There's no Django installed on your PC.

On 7/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi all.Django auto loaded onto my computer from( I believe) a Harry
> Potter web site.I want to remove it,as it is messing up one of the web
> sites that I frequent.The site shows a 404 error.As I am a newby to
> computer with NO codeing experience,I am at a loss as to removing
> it.Hope that this is posted in the correct place.Thanks for any help
> that you can give.
> Leo
>
>
> >
>


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

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



Re: Accessing the backend's string-quoting functionality?

2007-07-20 Thread Tim Chase

>> Is there a way to access the back-end's string-quoting mechanism?
> 
> from django.db import backend
> foo_quoted = backend.quote_name('foo')

This seems to be (browsing the code) the table/field-name
escaping mechanism, not the "escaping/quoting dangerous
characters in a string so it can be put in a query" function.
The backend.quote_name function wraps a string in the back-end's
quote-chars (back-ticks in one, double-quotes in another).  The
function of interest usually doubles single-quotes, as well as
handling oddball control/unicode characters.  A little digging
shows this to be mysqldb.escape_string(), sqlite.escape, and the
psycopg.QuotedString object.


I didn't see them mentioned in any of the code in the backends/
directory.  Would a patch be considered?

-tim




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



Re: removal of Django

2007-07-20 Thread SH

This is awesome. Did it uninstall your rails stack too? UR pwnd

On Jul 20, 3:57 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi all.Django auto loaded onto my computer from( I believe) a Harry
> Potter web site.I want to remove it,as it is messing up one of the web
> sites that I frequent.The site shows a 404 error.As I am a newby to
> computer with NO codeing experience,I am at a loss as to removing
> it.Hope that this is posted in the correct place.Thanks for any help
> that you can give.
> Leo


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



Some questions on Django's authentication system

2007-07-20 Thread eXt

Hi all!

   I build an application which will use Django's authentication
system. This is my first Django application that uses auth system, so
sorry if the questions below are trivial.

   1. Do I have to decorate all views with login_required if I want to
keep them secured? Isn't there any inversed method which will secure
all views by default, and I will only enable some of them to public?

   2. My use case is that I need to save ip addresses of users who are
logging into my application. First thing is how to extend user model,
but I think that I found the proper solution in Django Book (user
profile). Second thing is what to do to catch 'logging in' event to be
able to read an ip from request and save it (even if the
authentication isn't successful)? Is it possible to set an event on
existing login method (django.contrib.auth.views.login), or should I
do something different, for example write my own login view?

Hmm.. thats all :)

Thanks in advance.

--
Jakub Wisniowski


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



IOError: Client read error (Timeout?) - When doing an AJAX Post

2007-07-20 Thread Udi

This seems to only be happening when I perform an ajax request from
IE7 using POST.  Anyone have any ideas?

 File "/var/www/html/production/feo/reader/views/rest.py", line 693,
in request_has_inputs
   if not request.has_key(input):

 File "/usr/local/lib/python2.5/site-packages/django/http/
__init__.py", line 37, in has_key
   return key in self.GET or key in self.POST

 File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 69, in _get_post
   self._load_post_and_files()

 File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 52, in _load_post_and_files
   self._post, self._files = http.QueryDict(self.raw_post_data),
datastructures.MultiValueDict()

 File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 119, in _get_raw_post_data
   self._raw_post_data = self._req.read()

IOError: Client read error (Timeout?)

,
POST:,
...
META:{'AUTH_TYPE': None,
 'CONTENT_LENGTH': 0L,
 'CONTENT_TYPE': None,
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': 'text/javascript, text/html, application/xml, text/
xml, */*',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-us',
 'HTTP_CACHE_CONTROL': 'no-cache',
 'HTTP_CONNECTION': 'Keep-Alive',
 'HTTP_CONTENT_LENGTH': '102',
 'HTTP_CONTENT_TYPE': 'application/x-www-form-urlencoded;
charset=utf-8',
...
'HTTP_UA_CPU': 'x86',
 'HTTP_USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT
5.1; .NET CLR 1.1.4322; InfoPath.1)',
 'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest',
 'PATH_INFO': '/',
 'PATH_TRANSLATED': None,
 'QUERY_STRING': None,
...


Thanks!!
Udi


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



PILOT__AIR_HOSTESS__SCANDAL__HIDDEN_VIDEO

2007-07-20 Thread Britnee

PILOT__AIR_HOSTESS__SCANDAL__HIDDEN_VIDEO




Download video


or


http://tinyurl.com/32qcql

















-


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



Re: Which database, and why?

2007-07-20 Thread [EMAIL PROTECTED]

I have had some really annoying performance problems with sqlite
concerning multiple joins partially over views.

The query optimizer did not do his job there and switching two joins
brought a performance boost of several orders of magnitude. This is
actually a thing that is hard to do with djangos ORM, since you are
not really writing SQL.

Thus I would recommend a full scale dbms once you have a more complex
ER model.


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



Re: removal of Django

2007-07-20 Thread Collin Grady

> Hi all.Django auto loaded onto my computer from( I believe) a Harry
> Potter web site.I want to remove it,as it is messing up one of the web
> sites that I frequent.The site shows a 404 error.

That's impossible.


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



Re: Accessing the backend's string-quoting functionality?

2007-07-20 Thread James Bennett

On 7/20/07, Tim Chase <[EMAIL PROTECTED]> wrote:
> Is there a way to access the back-end's string-quoting mechanism?

from django.db import backend
foo_quoted = backend.quote_name('foo')


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

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



removal of Django

2007-07-20 Thread [EMAIL PROTECTED]

Hi all.Django auto loaded onto my computer from( I believe) a Harry
Potter web site.I want to remove it,as it is messing up one of the web
sites that I frequent.The site shows a 404 error.As I am a newby to
computer with NO codeing experience,I am at a loss as to removing
it.Hope that this is posted in the correct place.Thanks for any help
that you can give.
Leo


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



Accessing the backend's string-quoting functionality?

2007-07-20 Thread Tim Chase

When working with an extra() call, I need to pass massaged
parameters to a subselect using the where=[""].  However, I'd
like to be able to access the back-end's quoting abilities.  As a
stop-gap, I currently am simply doing a replace of a single-quote
with two single-quotes.  However, I've heard there's that should
be escaped depending on the back-end.

Is there a way to access the back-end's string-quoting mechanism?

-tim




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



Re: Which database, and why?

2007-07-20 Thread Tim Chase

> I know that PostgreSQL is recommended, but why? Are the django
> developers assuming a high-traffic, database intensive site. Are the
> django developers assuming that you will not be using shared hosting?

Any of the big three (PostgreSQL, MySQL, and sqlite) are quite
well supported in Django.  In my (highly subjective) experience,
the following applies:

PostgreSQL:
 -scaling: +2
 -able to be run on a 2nd server: yes
 -easy administration: 0
 -easy configuration/installation: -1
 -ANSI SQL compliance: +2

MySQL:
 -scaling: +1
 -able to be run on a 2nd server: yes
 -easy administration: +1
 -easy configuration/installation: 0
 -ANSI SQL compliance: +1 (formerly "-1.5")

sqlite:
 -scaling: -1
 -able to be run on a 2nd server: not really
 -easy administration: +1
 -easy configuration/installation: +1.5
 -ANSI SQL compliance: +1.5


To me, that means, if you've got a site that doesn't need to
scale because it should experience minimal traffic, go with
sqlite.  Especially for local development.

If you're entertaining a site that needs to scale, go with
PostgreSQL unless you have a reason to prefer MySQL
(pre-existence on the hosting service, or ease of getting it
running).

MySQL's ANSI compliance has improved considerably since the days
I cursed its lack of things like views and subselects, but there
are still a few common ANSI features missing, or you have to
specify features on the table creation (though Django does
provide initial-sql hooks on a per-backend basis).  I think it's
this historical baggage of non-ANSI-compliance for MySQL that
dings it to a lower status than PostgreSQL.  As the newer, more
compliant versions of MySQL begin to be more available on hosting
services, this gap will close.

My $0.02

-tim









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



Re: django-discussion

2007-07-20 Thread Robert

On 20 Lip, 17:40, "Jonathan Buchanan" <[EMAIL PROTECTED]>
wrote:
> > Hello,
>
> > Has anybody been using the django-discussion at:
> >http://code.google.com/p/django-discussion/?
>
> So far I've only used it as part of the reddit clone in the demo
> project [1] for django-tagging, django-voting and django-discussion,
> which I haven't worked on for *ages* now... which is why
> django-discussion is currently sitting with two of its generic views
> unimplemented.
>
> Still, if you want to see it in use (generic style - it's being used
> exclusively via urls.py and template tags in the reddit clone app),
> check out the project below, which may or may not be broken due to
> recent changes related to URL reverse lookups, as I've *just* noticed
> that one of the URLConf entries points at a view which doesn't exist
> :)
>
> [1] darcs gethttp://www.jonathanbuchanan.plus.com/repos/devdocs/

Will take a look!

Thanks for great django-* apps published so far.

Regards,

--
Robert


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



Re: Newbie Question: Static Media With Development Server - Not The Same Old Question

2007-07-20 Thread Nathan Ostgard

Interesting! Didn't know document_root would figure out relative
paths. Glad you got it working.

Re. media -- yeah, sorry about that, I've taken to renaming the
admin's to media_admin.

On Jul 20, 12:26 pm, cjl <[EMAIL PROTECTED]> wrote:
> Nathan:
>
> Thank you for your reply.
>
> Your solution seems practical, but I found another solution. In
> 'settings.py' I have:
>
> MEDIA_ROOT = './static/'
> MEDIA_URL = 'static/'
>
> and in 'urls.py' I have:
>
> (r'^static/(?P.*)$', 'django.views.static.serve',
> {'document_root': 'static'}),
>
> Then in the templates I can have:
>
> http://localhost:8000/static/picture.png;>
>
> Which seems to work for me, and avoids any hardcoded paths for my
> tutorial.
>
> Also, note that with your solution calling your media url 'media' will
> clash with the default name for admin media, although I'm sure that
> you knew that, and that you were only providing an example.
>
> Thanks again,
> cjlesh


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



Re: Blog engine

2007-07-20 Thread Kai Kuehne

Hi Kyle,

On 7/18/07, Kyle Fox <[EMAIL PROTECTED]> wrote:
>
> It's easy to write a "basic" blog in Django.  If that's all people
> want, then great.  Something like that will work perfectly for the
> majority of bloggers (who probably won't get that much readership
> anyway)...
>
> But all this talk about making a "full-featured" blog app in Django --
> one that will really get noticed (and thus get django noticed): what
> we need is a blog with *more features* that could actually begin to
> compete with something like Wordpress**.

Ok, not 20 minutes but 10 hours. Just start it.
No one stops you from doing it.

Kai

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



Re: Django advocacy in a commercial environment

2007-07-20 Thread Nic James Ferrier

Rob Hudson <[EMAIL PROTECTED]> writes:

> Python and Django wouldn't be my concern when hiring new employees
> since they are easy to learn.  It's all the other stuff that comes
> with web development that together is harder to find (eg: valid
> (x)HTML, CSS, Javascript, database, source control, unix/linux, HTTP,
> etc.)

I agree with this. I'd be happy to teach anyone django and python. But
finding people who know about CSS differences between browsers - now
that is hard.

-- 
Nic Ferrier
http://www.tapsellferrier.co.uk   

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



Re: Blog engine

2007-07-20 Thread James Bennett

On 7/20/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
> #2 is particularly interesting to me because I've written a simple
> blog in Django and there are some non-obvious things that having a
> reference implementation to look at would be nice.  Things like:

To be fair, though, a lot of these things are already implemented, as
part of Django itself, as contrib applications or as freely-available
third-party applications.

> * Feeds (Atom, RSS, both)

django.contrib.syndication

> * Comments (with spam filters)

django.conrtib.comments + comment_utils

> * Open-ID enabled comments?

There are a couple good OpenID implementations around; Simon
Willison's already doing OpenID for comments and has written up how he
did it.

> * Writing a script executed by cron to pull content from other sources
> and save them to your models.  (I did this for Magnolia recently.)

http://code.google.com/p/jellyroll/

etc.

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

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



Re: Django advocacy in a commercial environment

2007-07-20 Thread Rob Hudson

On Jul 20, 2:09 am, "Jon Atkinson" <[EMAIL PROTECTED]> wrote:
> I don't mean to pry, but at your workplace have you had any difficulty
> hiring into Python/Django roles at your company (compared to PHP)? Do
> you get less applicants? A better quality of applicant?

We only have 2 developers and because of Django, that's all we need.
We hired the 2nd awhile ago and he had some Python experience and
picked up Django very quickly.  The good documentation helped a lot in
that regard.  That in itself is another point -- a home grown CMS in
PHP with no docs would have taken much longer to figure out and get up
to speed with.

The MVC model, I think, would also help.  As the new employees are
learning they can work in something less technical like templates.  As
they learn, they can then do views.  And the senior devs can do things
like model design, middleware, new features, whatever.

Python and Django wouldn't be my concern when hiring new employees
since they are easy to learn.  It's all the other stuff that comes
with web development that together is harder to find (eg: valid
(x)HTML, CSS, Javascript, database, source control, unix/linux, HTTP,
etc.)

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



Re: Blog engine

2007-07-20 Thread Rob Hudson

A lot of the same arguments against making a standard blog project
could probably be applied to Rails, but here's a blog app in Rails...
http://simplelog.net/

I think an open-source Django blog project would be good because
1) It would be Usable to many (as evidenced by this thread and others
before)
2) Useful to many as a reference and resource

#2 is particularly interesting to me because I've written a simple
blog in Django and there are some non-obvious things that having a
reference implementation to look at would be nice.  Things like:

* Feeds (Atom, RSS, both)
* Comments (with spam filters)
* Open-ID enabled comments?
* Grouping blogs and links and whatever other objects by date using
generic relations (possibly?)
* Previewing links that aren't "published" yet, possibly using the
ADMINS option, while returning a 404 for anyone else?
* Writing a script executed by cron to pull content from other sources
and save them to your models.  (I did this for Magnolia recently.)
* etc.

If anyone wants to start one I'd be interesting in joining in and
playing.

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



Re: Newbie Question: Static Media With Development Server - Not The Same Old Question

2007-07-20 Thread cjl

Nathan:

Thank you for your reply.

Your solution seems practical, but I found another solution. In
'settings.py' I have:

MEDIA_ROOT = './static/'
MEDIA_URL = 'static/'

and in 'urls.py' I have:

(r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': 'static'}),

Then in the templates I can have:

http://localhost:8000/static/picture.png;>

Which seems to work for me, and avoids any hardcoded paths for my
tutorial.

Also, note that with your solution calling your media url 'media' will
clash with the default name for admin media, although I'm sure that
you knew that, and that you were only providing an example.

Thanks again,
cjlesh


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



Re: shortcut for assigning values to model?

2007-07-20 Thread Tim Chase

> I am also new to python, where can I learn more about **kwargs?

The python docs have some examples here:

http://www.python.org/doc/current/tut/node6.html#SECTION00672



-tim





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



Re: shortcut for assigning values to model?

2007-07-20 Thread james_027

@canen
An example is if your forms are dealing with two or more models
wherein form_for_model is for one model only.

@nathan
I am also new to python, where can I learn more about **kwargs?

Cheers,
james


On Jul 21, 12:46 am, canen <[EMAIL PROTECTED]> wrote:
> I may be mistaken but isn't this what form_for_model is for?
>
> On Jul 20, 11:23 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
>
> > Python also allows you to use ** to unpack a dict into a set of
> > kwargs:
>
> > b = Book(**bf.cleaned_data)
>
> > On Jul 20, 4:28 am, LaundroMat <[EMAIL PROTECTED]> wrote:
>
> > > On 20 jul, 10:53, james_027 <[EMAIL PROTECTED]> wrote:
>
> > > > hi,
>
> > > > is there a short cut for assigning input data to model's data
> > > > attribute?
>
> > > > if Book is a model then
>
> > > > b = Book(request.POST)
> > > > b.save()
>
> > > > the assignment will be done on all the match key of  the request.POST
> > > > QueryDict and data attribute of the Book Model.
>
> > > > or
>
> > > > if BookForm is a newform then
>
> > > > bf = BookForm()
> > > > if bf.is_valid():
> > > > b = Book(bf.cleaned_data)
>
> > > > thanks
> > > > james
>
> > > You could run through the request.POST's keys and assign them to the
> > > Model's attributes:
> > > b = Book()
> > > for key in request.POST.keys():
> > > ---b.__setattribute__(key, request.POST[key])
> > > b.save()


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



Re: Can Django call cscript.exe to run vbscripts

2007-07-20 Thread Dennis Allison


actually, look at module subprocess rather than os as the subprocess 
module contains the current best practice solution.   (Check the Python 
3000 docs to see what will be going away and avoid using them.  :-) )

BUT, the vbscript GUI will not be available throught the web, at least not
easily.  




On Fri, 20 Jul 2007, Andrey Khavryuchenko wrote:

> 
> 
>  b> I'm an Windows System Administrator and for my job i often use
>  b> vbscripts to automate my tasks. I was wondering if Django can call
>  b> cscript.exe to execute a vbscript file (Offcourse django is assumed to
>  b> run under Windows)? I know that i can also script wmi with python but
>  b> i'm allready mastering vbscript and have a huge library of function
>  b> vbscripts.
>  b> Can someone help me pls ?
> 
> Django app is a plain python script.  So check python doc for starting
> external applications (module os).
> 
> 

-- 


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



Which database, and why?

2007-07-20 Thread walterbyrd

I know that PostgreSQL is recommended, but why? Are the django
developers assuming a high-traffic, database intensive site. Are the
django developers assuming that you will not be using shared hosting?

I seems to me, that if you are using shared hosting, and if your
database needs are modest, Sqlite3 might be the best choice.
Especially when Python 2.5 becomes more standard on shared hosting.

For one thing, with sqlite, you don't have to share a database server
with others. Judging from the way Drupal runs on dot5hosting, or
dreamhost, this might make a real difference. Also sqlite is almost
trivial to setup and administrate.

Has anybody had any particular difficulties with MySQL?


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



What does it mean to restart Apache?

2007-07-20 Thread walterbyrd

As I understand it, if you run django under mod_python, then you have
to restart Apache every time you make a change to the django code.

Does restarting apache mean that apache is completely shut down? So if
I'm on shared hosting, then anybody else using the apache server, will
have to wait until apache restarts?

I can't imagine that any shared-host service would allow that.
Although, I think some hosts, like WebFaction, give everybody their
own apache server.

Can anybody clear this up for me?


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



Re: Newbie Question: Static Media With Development Server - Not The Same Old Question

2007-07-20 Thread Nathan Ostgard

Assuming cwd is the projects folder:

settings.py:

import os.path
MEDIA_ROOT = os.abspath('./media')

urls.py:

from django.conf import settings
urlpatterns = patterns('',
  (r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)


On Jul 20, 6:13 am, cjl <[EMAIL PROTECTED]> wrote:
> Djangoholics:
>
> I am working on a portable Django development environment for windows,
> and I'm trying to write a tutorial for newbies to go along with it.
>
> My initial -- poorly executed and incomplete -- website is 
> athttp://www.instantdjango.com
>
> One problem I am trying to overcome is how to make paths relative, as
> I want this environment to work from USB thumb drives.  Right now it
> does this by executing a stupid and simple batch file, which actually
> seems to work, for the most part.
>
> It appears that using the Django development server I can use a
> relative path for the template dir in 'settings.py', which is working
> fine.
>
> However, I am stuck on how to use relative paths for serving static
> media from the development server.
>
> Any ideas on how I might tackle this?
>
> -cjlesh


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



Re: Can Django call cscript.exe to run vbscripts

2007-07-20 Thread Andrey Khavryuchenko


 b> I'm an Windows System Administrator and for my job i often use
 b> vbscripts to automate my tasks. I was wondering if Django can call
 b> cscript.exe to execute a vbscript file (Offcourse django is assumed to
 b> run under Windows)? I know that i can also script wmi with python but
 b> i'm allready mastering vbscript and have a huge library of function
 b> vbscripts.
 b> Can someone help me pls ?

Django app is a plain python script.  So check python doc for starting
external applications (module os).

-- 
Andrey V Khavryuchenko
Django NewGate -  http://www.kds.com.ua/djiggit/
Development - http://www.kds.com.ua 
Call akhavr1975 on www.gizmoproject.com

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



Can Django call cscript.exe to run vbscripts

2007-07-20 Thread braveheart

Hello guys.
I'm an Windows System Administrator and for my job i often use
vbscripts to automate my tasks. I was wondering if Django can call
cscript.exe to execute a vbscript file (Offcourse django is assumed to
run under Windows)? I know that i can also script wmi with python but
i'm allready mastering vbscript and have a huge library of function
vbscripts.
Can someone help me pls ?
Thanks


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



Re: shortcut for assigning values to model?

2007-07-20 Thread canen

I may be mistaken but isn't this what form_for_model is for?


On Jul 20, 11:23 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
> Python also allows you to use ** to unpack a dict into a set of
> kwargs:
>
> b = Book(**bf.cleaned_data)
>
> On Jul 20, 4:28 am, LaundroMat <[EMAIL PROTECTED]> wrote:
>
> > On 20 jul, 10:53, james_027 <[EMAIL PROTECTED]> wrote:
>
> > > hi,
>
> > > is there a short cut for assigning input data to model's data
> > > attribute?
>
> > > if Book is a model then
>
> > > b = Book(request.POST)
> > > b.save()
>
> > > the assignment will be done on all the match key of  the request.POST
> > > QueryDict and data attribute of the Book Model.
>
> > > or
>
> > > if BookForm is a newform then
>
> > > bf = BookForm()
> > > if bf.is_valid():
> > > b = Book(bf.cleaned_data)
>
> > > thanks
> > > james
>
> > You could run through the request.POST's keys and assign them to the
> > Model's attributes:
> > b = Book()
> > for key in request.POST.keys():
> > ---b.__setattribute__(key, request.POST[key])
> > b.save()


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



Re: Mapping models to CRUD urls?

2007-07-20 Thread John Matthew
Russ,

This is GREAT stuff, thank you so much.

Since I'm so new to this web stuff, and django is really the only thing I've
ever used for web programming, I hadn't gotten into the GET dictionary (or
parameters as I call them).

Given that, I assume that the cache will look at the http://.../model3/add/
and cache that?  meaning it doesn't add the parameters to the cache lookup?

This actually makes my setup a little simpler, and i'll start on it soon.

Thanks again for all your help.

John

On 7/19/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
>
> On 7/20/07, John M <[EMAIL PROTECTED]> wrote:
> >
> > Does caching matter that much in my example, since it's dynamic data
> > anyway?
>
> Don't let the fact that the data is dynamic distract you. All database
> backed websites are dynamic at some level. However, when you have
> thousands of requests for a resource every second, does it really
> matter if the version delivered to the user is 1 second out of date?
> 10 seconds? A minute?
>
> You should be able to serve a reasonably sized Django application
> without ever having to care about caching. However, It pays to get
> into a good habits early. It is a lot easier to add caching to the top
> of a clean ReSTful application than it is to refactor a messy,
> non-ReSTful application so that you can add caching.
>
> As a bonus, URL spaces that are easily cached are also the ones that
> match the browsing metaphor the best (i.e., are ReSTful), so asking
> the question "could I cache this" is one way of validating a design.
>
> Yours,
> Russ Magee %-)
>
> >
>

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



Adding permission in admin causes error

2007-07-20 Thread Todd O'Bryan

In the most recent from trunk, I get the following error when I try to
add a permission (either default or custom) to a user. Is this a bug or
am I doing something wrong?

Todd

TypeError at /dmi/admin/auth/user/2/
Cannot resolve keyword 'name' into field. Choices are: groups,
user_permissions, logentry, message, info, labelqueueset, checkout, id,
username, first_name, last_name, email, password, is_staff, is_active,
is_superuser, last_login, date_joined
  Request Method:
POST
Request URL:
http://localhost:8000/dmi/admin/auth/user/2/
  Exception Type:
TypeError
  Exception Value:
Cannot resolve keyword 'name' into
field. Choices are: groups,
user_permissions, logentry, message,
info, labelqueueset, checkout, id,
username, first_name, last_name,
email, password, is_staff,
is_active, is_superuser, last_login,
date_joined
Exception Location:
/usr/lib/python2.5/site-packages/django/db/models/query.py in lookup_inner, 
line 1026
 Python Executable:
/usr/bin/python
  Python Version:
2.5.1




















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



Re: shortcut for assigning values to model?

2007-07-20 Thread Nathan Ostgard

Python also allows you to use ** to unpack a dict into a set of
kwargs:

b = Book(**bf.cleaned_data)

On Jul 20, 4:28 am, LaundroMat <[EMAIL PROTECTED]> wrote:
> On 20 jul, 10:53, james_027 <[EMAIL PROTECTED]> wrote:
>
>
>
> > hi,
>
> > is there a short cut for assigning input data to model's data
> > attribute?
>
> > if Book is a model then
>
> > b = Book(request.POST)
> > b.save()
>
> > the assignment will be done on all the match key of  the request.POST
> > QueryDict and data attribute of the Book Model.
>
> > or
>
> > if BookForm is a newform then
>
> > bf = BookForm()
> > if bf.is_valid():
> > b = Book(bf.cleaned_data)
>
> > thanks
> > james
>
> You could run through the request.POST's keys and assign them to the
> Model's attributes:
> b = Book()
> for key in request.POST.keys():
> ---b.__setattribute__(key, request.POST[key])
> b.save()


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



Re: template preprocessor ?

2007-07-20 Thread Jannis Leidel

as a matter of fact I just uploaded a new version [1] of the  
dbtemplates module, which is kind of pieced together from its  
original patch for a contrib app [2] and some ideas from james'  
django-registration app :)

it's a standalone app now and lives on the python path. installation  
and usage instructions included.
please don't hesitate to test it and complain [3] if it isn't working.

best,
jannis

1: http://django-databasetemplateloader.googlecode.com/files/ 
dbtemplates-0.2.tar.gz
2: http://code.djangoproject.com/attachment/ticket/632/dbtemplates4.diff
3: http://code.google.com/p/django-databasetemplateloader/issues/list

Am 19.07.2007 um 02:03 schrieb James Bennett:

> there's also a third-party loader by Jannis Leidel which pulls
> templates from a database[3] you might want to look at as an example
> of rolling your own.


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



Re: Authentication for application with subdomains

2007-07-20 Thread SH



On Jul 20, 1:06 am, David Marko <[EMAIL PROTECTED]> wrote:
> > One possible solution would be to append the domain name to the
> > username before authentication. The user types in 'bob', then the
> > system munges it to 'bob.sub.domain.com' before doing the validation.
>
> ### this approach should work . Do you use it for your app? Any
> experiences?

Nope - haven't tried it. I'm still in the early stages of design.

One thing I realized last night, is that it would be better to append
a key to a subdomains table than the actual subdomain. That would make
changes a lot easier.


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



Re: Updating multiple rows with Django DB API?

2007-07-20 Thread Jeff

cursor.commit()

On Jul 15, 9:12 pm, "Steven Hilton" <[EMAIL PROTECTED]> wrote:
> On 7/15/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 7/14/07, Steven Hilton <[EMAIL PROTECTED]> wrote:
> > > I could be updating any number of rows in bar. I want to do this
> > > without do a select on bar.
>
> > Also, it's worth noting that this is also fairly easy to do, it just
> > involves a little bit more code. Something like the following example
> > should get you started (this would be the save() method on the 'foo'
> > class, and a custom method also on that class):
>
> Thanks. This is very similar to what I'm doing -- although I'm not
> using the _meta.db_table variable, which I will correct.
>
> The problem with this, now that I've gone down this path, is that the
> sql is not committing. I've posted in another thread titled 'commiting
> custom update sql' in this group, available online at:
>
> http://groups.google.com/group/django-users/browse_thread/thread/7923...
>
> --
> Steven Hilton <[EMAIL PROTECTED]>
> 
>
> "It is the duty of the patriot to protect
>  his country from its government." -- Thomas Paine
>
> "There is no heart so black
>   as the black, black heart
>   of the phony leper." -- Adrian Monk


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



Re: form_for_model with custom modifications and save()

2007-07-20 Thread ilDave

Ok, I resolved just adding a 'codice' key with the right value to the
f.clean_data dict before saving...
Is there a better way or can I stay with this?


On Jul 20, 4:35 pm, ilDave <[EMAIL PROTECTED]> wrote:
> Hello!
> I'm using form_for_model to create a form for a particulary complex
> model.
> I don't want to show a particular field of the model in the form, so I
> did this:
>
> PreventivoForm =  form_for_model(Preventivo)  #Preventivo is the name
> of the model
> del PreventivoForm.base_fields['codice'] # codice is the field I don't
> want to show, because it's value must
> be
>#
> calculated from other data
>
> and the form is nicely displayed like I want.
>
> But when I try to save the data in the form in a new model, I get an
> exception, because the 'codice' field is a required field in the
> model:
>
> f = PreventivoForm(request.POST)
> if f.is_valid():
>p = f.save()
>
> Is there a way to add the field I need before saving or have I to
> handle the saving of the object manually?


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



Terminate HTTP connection

2007-07-20 Thread meledictas

Hi,
Can I terminate a connect without receiving all HTTP request
package? I have to check if there are some important data, if not,
just terminate it.

Thank


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



form_for_model with custom modifications and save()

2007-07-20 Thread ilDave

Hello!
I'm using form_for_model to create a form for a particulary complex
model.
I don't want to show a particular field of the model in the form, so I
did this:

PreventivoForm =  form_for_model(Preventivo)  #Preventivo is the name
of the model
del PreventivoForm.base_fields['codice'] # codice is the field I don't
want to show, because it's value must
be
   #
calculated from other data

and the form is nicely displayed like I want.

But when I try to save the data in the form in a new model, I get an
exception, because the 'codice' field is a required field in the
model:

f = PreventivoForm(request.POST)
if f.is_valid():
   p = f.save()

Is there a way to add the field I need before saving or have I to
handle the saving of the object manually?


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



Re: How to loop through a Dict to add values?

2007-07-20 Thread Greg

Ok...on to a new problem.  I'm able to add stuff to my session and
also delete the entire sesssion.  However, I'm not sure how to delete
a particular entry into my session variable.  This is how i add stuff
to my session

cart = request.session.get('cart', [])
cart.append({'style': s, 'choice': c})

What method do I use on request.session to delete only one "row" in my
cart dictionary?  Does cart have an id field that I can access?

Thanks

On Jul 20, 8:44 am, Greg <[EMAIL PROTECTED]> wrote:
> Yep...that worked.  Thanks for your help Nis and Derek.  I'll try to
> modify my model file with your suggestions
>
> On Jul 20, 5:46 am, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
>
> > Greg skrev:> Derek,
> > > Ok...I made the change and I'm now getting the error:
>
> > > TypeError at /rugs/cart/1/4/
> > > unsupported operand type(s) for +: 'int' and 'Price'
>
> > > Is 'a['choice'].price' not an Int?  It says it is in my model file.
>
> > No it doesn't - "price" is defined as a ForeignKey to Price, so it holds
> > a Price object.
>
> > > class Price(models.Model):
> > >name = models.IntegerField()
>
> > >def __str__(self,):
> > >return str(self.name)
>
> > >class Admin:
> > >pass
>
> > > class Choice(models.Model):
> > > choice = models.ForeignKey(Collection, edit_inline=models.TABULAR,
> > > num_in_admin=5)
> > > size = models.ForeignKey(Size, core=True)
> > > price = models.ForeignKey(Price, core=True)
> > > def __str__(self,):
> > >return str((self.size, self.price))
>
> > The only integer defined is Price.name. Does this work:
>
> >  pr = pr + a['choice'].price.name
>
> > ?
>
> > I would suggest that you change the name of that field ... "name" does
> > not really convey that this is the value of the price - it sounds more
> > like a label for it (like "SuperSaver").
>
> > Perhaps you could get rid of the Price class altogether? If it just
> > holds an integer, you could use an IntegerField directly in Choice ...
>
> > Nis


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



Re: newforms

2007-07-20 Thread Russell Keith-Magee

On 7/20/07, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
>
> It might be worth finally writing the "form processing" chapter in the
> Django Book, Russ :)

The Django Book isn't my bailiwick - that's Adrian and Jacob's
project. While I'm sure it will be a wonderful tutorial and reference
when it is published, it won't ever replace the official
documentation.

The 'official' newforms documentation
(http://djangoproject.com/documentation/newforms) is a work in
progress, but should be solid enough for the common use cases.

Of course, any suggestions on how the docs could be improved are
welcome, and any contributions of improvements are also welcome
(although they will probably be edited).

Yours,
Russ Magee %-)

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



Re: schema evolution

2007-07-20 Thread Derek Anderson

understandable.  i do have both, but not integrated into django's 
framework.  when i finish such, would you suggest a patch posted to the 
list, or attached to a bug report?  (if the latter, a new bug or is 
there a schema evolution bug already in discussion?)

danke,
derek


Russell Keith-Magee wrote:
> On 7/20/07, Derek Anderson <[EMAIL PROTECTED]> wrote:
>> but i use django
>> quite a bit now and am surprised some sort of this hasn't been merged
>> yet, so i figured i'd bring it up to date and re-release.
> 
> By casting a quick eye over the patch, I caught at least two reasons
> that this hasn't been merged (or taken particularly seriously by the
> core developers):
> 
> - No tests.
> - No documentation.
> 
> I agree that schema evolution would be a valuable addition to Django.
> However, if you (or anyone else) is serious about getting this into
> trunk, adding a comprehensive test suite and draft documentation is a
> non-negotiable prerequisite for .
> 
> The testing requirement is especially relevant for schema-evolution
> because I suspect the existing test framework will require some
> modifications to enable models to be evolved during a test run. If you
> want to prove to me that you are serious, show me the tests.
> 
> Yours,
> Russ Magee %-)
> 
> > 
> 


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



Re: How to loop through a Dict to add values?

2007-07-20 Thread Greg

Yep...that worked.  Thanks for your help Nis and Derek.  I'll try to
modify my model file with your suggestions

On Jul 20, 5:46 am, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
> Greg skrev:> Derek,
> > Ok...I made the change and I'm now getting the error:
>
> > TypeError at /rugs/cart/1/4/
> > unsupported operand type(s) for +: 'int' and 'Price'
>
> > Is 'a['choice'].price' not an Int?  It says it is in my model file.
>
> No it doesn't - "price" is defined as a ForeignKey to Price, so it holds
> a Price object.
>
>
>
> > class Price(models.Model):
> >name = models.IntegerField()
>
> >def __str__(self,):
> >return str(self.name)
>
> >class Admin:
> >pass
>
> > class Choice(models.Model):
> > choice = models.ForeignKey(Collection, edit_inline=models.TABULAR,
> > num_in_admin=5)
> > size = models.ForeignKey(Size, core=True)
> > price = models.ForeignKey(Price, core=True)
> > def __str__(self,):
> >return str((self.size, self.price))
>
> The only integer defined is Price.name. Does this work:
>
>  pr = pr + a['choice'].price.name
>
> ?
>
> I would suggest that you change the name of that field ... "name" does
> not really convey that this is the value of the price - it sounds more
> like a label for it (like "SuperSaver").
>
> Perhaps you could get rid of the Price class altogether? If it just
> holds an integer, you could use an IntegerField directly in Choice ...
>
> Nis


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



django-discussion

2007-07-20 Thread Robert

Hello,

Has anybody been using the django-discussion at:
http://code.google.com/p/django-discussion/ ?

Any thoughts ?

Thanks,

--
Robert


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



Newbie Question: Static Media With Development Server - Not The Same Old Question

2007-07-20 Thread cjl

Djangoholics:

I am working on a portable Django development environment for windows,
and I'm trying to write a tutorial for newbies to go along with it.

My initial -- poorly executed and incomplete -- website is at
http://www.instantdjango.com

One problem I am trying to overcome is how to make paths relative, as
I want this environment to work from USB thumb drives.  Right now it
does this by executing a stupid and simple batch file, which actually
seems to work, for the most part.

It appears that using the Django development server I can use a
relative path for the template dir in 'settings.py', which is working
fine.

However, I am stuck on how to use relative paths for serving static
media from the development server.

Any ideas on how I might tackle this?

-cjlesh


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



Many-to-many using intermediary table

2007-07-20 Thread Jarek Zgoda

I have to rewrite large parts of older code where we used plain M2M
without defining intermediary table. Now the junction in intermediary
table must get few additional fields so I guess we need to create the
model for the junction table and add these fields there, defining
ForeignKeys to both data tables. Unfortunately we had 'related_name'
defined on M2M fields and current code relies on this feature heavily.
Anybody can suggest the solution that wouldn't require rewriting all the
code that used related name? I just cann't imagine how can I do that...

BTW, we're on 0.96.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

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



Multiple Edit

2007-07-20 Thread Christopher

I've been looking for a way to have a model and in the Admin be able
to edit a couple at one.  Is this even possible?  I know models that
have Foreign keys etc to each other this can be done.

I want one model, stand-alone, and edit multiple.

class Test(models.Model):
name = models.CharField(maxlength=30)
description = models.CharField(maxlength=200)

etc etc... and then have an Admin option or something for multiple
edits like the form would look something like:

name: | |  decription:
||
name: | |  decription:
||
name: | |  decription:
||
name: | |  decription:
||
name: | |  decription:
||

| save |

Thanks :)


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



Re: newforms

2007-07-20 Thread Chris Hoeppner
Russell Keith-Magee escribió:
> On 7/20/07, Alper KANAT <[EMAIL PROTECTED]> wrote:
>> What is newforms any way ? A new looking (style) of a form or something
>> ? If so, can somebody post a screenshot please ?
> 
> Newforms is the replacement for the old manipulator framework. The old
> forms framework was based around the concept of Manipulators. The
> manipulator framework was starting to become a maintenance problem, as
> their were some problems with the underlying architecture that were
> exposing some nasty bugs.
> 
> So - we went back to the drawing board, and the result is newforms.
> The format for defining forms, fields, and widgets is much cleaner and
> much more extensible. The forms themselves look the same (they are
> just HTML, after all) - but the view code you use to interact with
> them is very different.
> 
> Oldforms (and manipulators) are now deprecated; they will remain in
> the next Django release, but will not be present in v1.0.
> 
> In short, if you are starting out with Django, newforms is what you
> should be using.
> 
> Yours,
> Russ Magee %-)
> 
> --~--~-~--~~~---~--~~
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com
> To unsubscribe from this group, send email to [EMAIL PROTECTED]
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en
> -~--~~~~--~~--~--~---
> 

It might be worth finally writing the "form processing" chapter in the
Django Book, Russ :)



signature.asc
Description: OpenPGP digital signature


Re: shortcut for assigning values to model?

2007-07-20 Thread LaundroMat



On 20 jul, 10:53, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> is there a short cut for assigning input data to model's data
> attribute?
>
> if Book is a model then
>
> b = Book(request.POST)
> b.save()
>
> the assignment will be done on all the match key of  the request.POST
> QueryDict and data attribute of the Book Model.
>
> or
>
> if BookForm is a newform then
>
> bf = BookForm()
> if bf.is_valid():
> b = Book(bf.cleaned_data)
>
> thanks
> james

You could run through the request.POST's keys and assign them to the
Model's attributes:
b = Book()
for key in request.POST.keys():
---b.__setattribute__(key, request.POST[key])
b.save()


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



Re: newforms

2007-07-20 Thread Russell Keith-Magee

On 7/20/07, Alper KANAT <[EMAIL PROTECTED]> wrote:
>
> What is newforms any way ? A new looking (style) of a form or something
> ? If so, can somebody post a screenshot please ?

Newforms is the replacement for the old manipulator framework. The old
forms framework was based around the concept of Manipulators. The
manipulator framework was starting to become a maintenance problem, as
their were some problems with the underlying architecture that were
exposing some nasty bugs.

So - we went back to the drawing board, and the result is newforms.
The format for defining forms, fields, and widgets is much cleaner and
much more extensible. The forms themselves look the same (they are
just HTML, after all) - but the view code you use to interact with
them is very different.

Oldforms (and manipulators) are now deprecated; they will remain in
the next Django release, but will not be present in v1.0.

In short, if you are starting out with Django, newforms is what you
should be using.

Yours,
Russ Magee %-)

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



Re: How to loop through a Dict to add values?

2007-07-20 Thread Nis Jørgensen

Greg skrev:
> Derek,
> Ok...I made the change and I'm now getting the error:
>
> TypeError at /rugs/cart/1/4/
> unsupported operand type(s) for +: 'int' and 'Price'
>
> Is 'a['choice'].price' not an Int?  It says it is in my model file.
>   
No it doesn't - "price" is defined as a ForeignKey to Price, so it holds
a Price object.

> class Price(models.Model):
>   name = models.IntegerField()
>
>   def __str__(self,):
>   return str(self.name)
>
>   class Admin:
>   pass
>
>
> class Choice(models.Model):
> choice = models.ForeignKey(Collection, edit_inline=models.TABULAR,
> num_in_admin=5)
> size = models.ForeignKey(Size, core=True)
> price = models.ForeignKey(Price, core=True)
> def __str__(self,):
>   return str((self.size, self.price))
>   
The only integer defined is Price.name. Does this work:

 pr = pr + a['choice'].price.name


?

I would suggest that you change the name of that field ... "name" does
not really convey that this is the value of the price - it sounds more
like a label for it (like "SuperSaver").

Perhaps you could get rid of the Price class altogether? If it just
holds an integer, you could use an IntegerField directly in Choice ...

Nis


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



Re: Usage of {% trans ....%} tag in templates related to inclusion tags

2007-07-20 Thread Peter Melvyn

On 7/20/07, eXt <[EMAIL PROTECTED]> wrote:

> Do you have: {% load i18n %} in your template?

Certainly not - I forgot it - now it works fine.

Thank you for help

 Peter

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



Re: Django, python 2.5 and macports 1.5

2007-07-20 Thread Benoit Chesneau

If you look the port source, you will see files/patch-setup.py in
which it disable md5 and such things like openssl. The only way to
have them back is :
1) modify this patch,
2) increment the release number in portfile
3) reindex all the port tree with portindex
4) finally reinstall the port after deinstalling old one.

I should open a bug about it one day...

Benoit.

On 7/20/07, lars <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> yesterday I tried to install django on my macbook. Since I wanted to
> have a more recent python interpreter I installed the one from
> macports.
> There's a pitfall, however. Because in order to get MD5 running you
> have to install the package py25-hashlib as well! Otherwise you will
> face the "ImportError: No module named _md5" error.
>
> Just wanted to post this hint in case someone else runs into the same
> problem :-)
>
> Yours,
> Lars
>
>
> >
>


-- 
bchesneau.info | neurofriends.net | osbud.net

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



HttpRequest.get_full_path() does not work with Apache 2.x

2007-07-20 Thread Mambaragi

Hello,

I use HttpRequest.get_full_path() for saving current url.
When I use this with Django manage.py runserver, it works perfectly
fine.
But when I use get_full_path with Apache + mod_python, it does not
work. I only gives me HttpRequest.path value without QUERY_STRING.
I just use like the following

def some_view(req, id):
  return_url = req.get_full_path()
  return render_to_resposne("/some.html", {'return_url': return_url})

What should I do for getting proper full_path?

Regards,
KwonNam


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



Re: Django advocacy in a commercial environment

2007-07-20 Thread Kenneth Gonsalves


On 20-Jul-07, at 2:39 PM, Jon Atkinson wrote:

> I don't mean to pry, but at your workplace have you had any difficulty
> hiring into Python/Django roles at your company (compared to PHP)? Do
> you get less applicants? A better quality of applicant?

my experience is: no qualified applicants - they have to be trained/ 
learn on the job as far as python/django is concerned

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



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



Re: Django advocacy in a commercial environment

2007-07-20 Thread Jon Atkinson

Thanks for your reply, Rob.

Personally, the reason we're looking to push Django is that our
business needs very much match a statement Simon made in the talk I
mentioned above: 'Web development on journalism deadlines' (that might
not be entirely accurate).

I was also considering putting together a report, but we all know the
problems with code metrics - do we measure LoC, speed of development,
or the very nebulous 'simplicity' concept which will be quite
difficult to communicate to management.

I don't mean to pry, but at your workplace have you had any difficulty
hiring into Python/Django roles at your company (compared to PHP)? Do
you get less applicants? A better quality of applicant?

Cheers,

--Jon

On 7/19/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
>
> On Jul 19, 1:19 am, "Jon Atkinson" <[EMAIL PROTECTED]> wrote:
> > If anyone has any good resources which show off the power of Django
> > (and by association, the benefits of PHP), then please share them with
> > us.
>
> Where I work we migrated away from PHP to Django with great success
> but it depends on your environment.
>
> For us the Django admin was a huge factor since we have teams entering
> content and the default Django admin was way better than anything we
> had going so far.
>
> There are some performance articles and blog posts, for example:
> http://wiki.rubyonrails.org/rails/pages/Framework+Performance
>
> We benefitted from the Django workflow with its built-in web server.
>
> There's also the fact that Django is improving everyday which
> translates into free new features or things that were hard to do are
> easy now.  For example, databrowse or djangosnippets.
>
> And we love Python and also love our jobs more because of the
> switch.  :)
>
> Those aren't really resources for you but depending on your in-house
> requirements it's not hard to find resources online to help guide the
> decision.  When I had to convince my superiors of the choice, I wrote
> a PDF document looking at the best choices in each language (Ruby,
> PHP, Python) and Django won out for our particular needs.
>
> -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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Usage of {% trans ....%} tag in templates related to inclusion tags

2007-07-20 Thread eXt

Hi

Do you have: {% load i18n %} in your template?

Regards


--
Jakub Wisniowski



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



shortcut for assigning values to model?

2007-07-20 Thread james_027

hi,

is there a short cut for assigning input data to model's data
attribute?

if Book is a model then

b = Book(request.POST)
b.save()

the assignment will be done on all the match key of  the request.POST
QueryDict and data attribute of the Book Model.

or

if BookForm is a newform then

bf = BookForm()
if bf.is_valid():
b = Book(bf.cleaned_data)

thanks
james


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



Django, python 2.5 and macports 1.5

2007-07-20 Thread lars

Hi all,

yesterday I tried to install django on my macbook. Since I wanted to
have a more recent python interpreter I installed the one from
macports.
There's a pitfall, however. Because in order to get MD5 running you
have to install the package py25-hashlib as well! Otherwise you will
face the "ImportError: No module named _md5" error.

Just wanted to post this hint in case someone else runs into the same
problem :-)

Yours,
Lars


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



Re: newforms

2007-07-20 Thread james_027

Hi Alper,

I am very new to django so I dont know how does the oldform look like,
anyway here is what I like in this new form

* helps me create the necessary html code to use in my forms very fast
(needs some enhancement, I've already create a ticket)
* with new forms you can handle forms for partial fields of a single
model, fields from multiple model, fields that even does link to a
particular model at all
* validation is cool, easy & nice

cheers,
james


On Jul 20, 4:37 pm, Alper KANAT <[EMAIL PROTECTED]> wrote:
> What is newforms any way ? A new looking (style) of a form or something
> ? If so, can somebody post a screenshot please ?
>
> Alper KANAT ([EMAIL PROTECTED])http://raptiye.org
>
> Thomas Guettler yazmış:
>
> > Am Freitag, 20. Juli 2007 07:53 schrieb james_027:
> >> Which official django apps are using the newforms? I just want to take
> >> a look at the coding as I am trying to learn the django's newforms.
>
> > Hi,
>
> > there is a newforms admin branch. I think you can use this as an example.
>
> > I have not look at the branch up to now. I use newforms, but often I look
> > into djang/newforms/*.py to find how to use and misuse it.
>
> >  Thomas


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



Re: newforms

2007-07-20 Thread Alper KANAT

What is newforms any way ? A new looking (style) of a form or something
? If so, can somebody post a screenshot please ?


Alper KANAT ([EMAIL PROTECTED])
http://raptiye.org


Thomas Guettler yazmış:
> Am Freitag, 20. Juli 2007 07:53 schrieb james_027:
>> Which official django apps are using the newforms? I just want to take
>> a look at the coding as I am trying to learn the django's newforms.
> 
> Hi,
> 
> there is a newforms admin branch. I think you can use this as an example.
> 
> I have not look at the branch up to now. I use newforms, but often I look
> into djang/newforms/*.py to find how to use and misuse it.
> 
>  Thomas
> 
> > 
> 

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



Re: Problem with image upload

2007-07-20 Thread ilDave

Thanks, it works!
I missed the forms.ModelChoiceField in the documentation!


On Jul 20, 10:23 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
> Use forms.ModelChoiceField instead:
>
> immagine =
> forms.ModelChoiceField(queryset=Pics.objects.all().order_by('immagine'),
> cache_choices=False, label='Pic', required=False)
>
> On Jul 20, 1:15 am, ilDave <[EMAIL PROTECTED]> wrote:
>
> > I've a form that handles file uploading to the database: it works
> > fine, the file is uploaded in the right place and the path is written
> > on the database (I use a models.ImageField field in a model).
>
> > Than I have another form, that uses newforms, with a  field
> > that should be populated with all the images path inside the db:
>
> > class MyForm(forms.Form):
> > imgchoice = [('', 'Select:'),]
> > imgs = Pics.objects.all().order_by('immagine')
> > for i in imgs:
> > imgchoice.append((i.id, i.immagine))
>
> > immagine = forms.ChoiceField(choices=imgchoice, label='Pic',
> > initial='', required=False)
>
> > The problem is that if I insert a new image and that I open the other
> > form, the image that i just uploaded does not show in the select
> > field.
> > I'm using Apache and mod_pyton, and I noticed that if I restart Apache
> > the new images whow up.
>
> > How can I do to resolve without the need to restart the webserver?
>
> > Thanks.


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



Re: Problem with image upload

2007-07-20 Thread Nathan Ostgard

Use forms.ModelChoiceField instead:

immagine =
forms.ModelChoiceField(queryset=Pics.objects.all().order_by('immagine'),
cache_choices=False, label='Pic', required=False)

On Jul 20, 1:15 am, ilDave <[EMAIL PROTECTED]> wrote:
> I've a form that handles file uploading to the database: it works
> fine, the file is uploaded in the right place and the path is written
> on the database (I use a models.ImageField field in a model).
>
> Than I have another form, that uses newforms, with a  field
> that should be populated with all the images path inside the db:
>
> class MyForm(forms.Form):
> imgchoice = [('', 'Select:'),]
> imgs = Pics.objects.all().order_by('immagine')
> for i in imgs:
> imgchoice.append((i.id, i.immagine))
>
> immagine = forms.ChoiceField(choices=imgchoice, label='Pic',
> initial='', required=False)
>
> The problem is that if I insert a new image and that I open the other
> form, the image that i just uploaded does not show in the select
> field.
> I'm using Apache and mod_pyton, and I noticed that if I restart Apache
> the new images whow up.
>
> How can I do to resolve without the need to restart the webserver?
>
> Thanks.


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



Usage of {% trans ....%} tag in templates related to inclusion tags

2007-07-20 Thread Peter Melvyn

Hi all,

I'am embedding a piece of information into each page using inclusion
tag and it seems everything works fine except tag {% trans ... %}. Its
occurence in the inclusion template raises expcetion
TemplateSyntaxError saying "Invalid block tag: 'trans'".

Did I miss anything or it is neccessary to translate text out of the
template and pass it as an item in the dictionary returned by
underlying function?


Thanks, Peter

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



Re: schema evolution

2007-07-20 Thread Russell Keith-Magee

On 7/20/07, Derek Anderson <[EMAIL PROTECTED]> wrote:
>
> but i use django
> quite a bit now and am surprised some sort of this hasn't been merged
> yet, so i figured i'd bring it up to date and re-release.

By casting a quick eye over the patch, I caught at least two reasons
that this hasn't been merged (or taken particularly seriously by the
core developers):

- No tests.
- No documentation.

I agree that schema evolution would be a valuable addition to Django.
However, if you (or anyone else) is serious about getting this into
trunk, adding a comprehensive test suite and draft documentation is a
non-negotiable prerequisite for .

The testing requirement is especially relevant for schema-evolution
because I suspect the existing test framework will require some
modifications to enable models to be evolved during a test run. If you
want to prove to me that you are serious, show me the tests.

Yours,
Russ Magee %-)

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



Problem with image upload

2007-07-20 Thread ilDave

I've a form that handles file uploading to the database: it works
fine, the file is uploaded in the right place and the path is written
on the database (I use a models.ImageField field in a model).

Than I have another form, that uses newforms, with a  field
that should be populated with all the images path inside the db:

class MyForm(forms.Form):
imgchoice = [('', 'Select:'),]
imgs = Pics.objects.all().order_by('immagine')
for i in imgs:
imgchoice.append((i.id, i.immagine))

immagine = forms.ChoiceField(choices=imgchoice, label='Pic',
initial='', required=False)


The problem is that if I insert a new image and that I open the other
form, the image that i just uploaded does not show in the select
field.
I'm using Apache and mod_pyton, and I noticed that if I restart Apache
the new images whow up.

How can I do to resolve without the need to restart the webserver?

Thanks.


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



Problems with fastcgi and pidfile

2007-07-20 Thread Nis Jørgensen

I cannot seem to get
manage.py runfcgi pidfile=myfile.pid
to work unless I have
daemonize=false
 as well. I haven't started investigating what actually happens -
thought I'd hear if I am doing something stupid first.

Django is [EMAIL PROTECTED], Debian Etch, python 2.4.4, flup 0.2126-1

Sample output below. Any idea why this doesn't work.

Nis

# This is how I've been doing it until now:

$ ./manage.py runfcgi host=127.0.0.1 port=8001
$ netstat -l |grep 8001
tcp0  0 nohouse.cust.gigah:8001 *:* LISTEN

# This doesn't work for some reason

$ ./manage.py runfcgi host=127.0.0.1 port=8001 pidfile=fcgi.pid
$ netstat -l |grep 8001
$ ll fcgi.pid
ls: fcgi.pid: No such file or directory

# This does work.

$ ./manage.py runfcgi host=127.0.0.1 port=8001 pidfile=fcgi.pid
daemonize=false &
[1] 9309
$ netstat -l |grep 8001
tcp0  0 nohouse.cust.gigah:8001 *:* LISTEN
$ ll fcgi.pid
-rw-r--r-- 1 nohouse nohouse 5 2007-07-20 07:49 fcgi.pid



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



Re: newforms

2007-07-20 Thread Thomas Guettler

Am Freitag, 20. Juli 2007 07:53 schrieb james_027:
> Which official django apps are using the newforms? I just want to take
> a look at the coding as I am trying to learn the django's newforms.

Hi,

there is a newforms admin branch. I think you can use this as an example.

I have not look at the branch up to now. I use newforms, but often I look
into djang/newforms/*.py to find how to use and misuse it.

 Thomas

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



Re: Mapping models to CRUD urls?

2007-07-20 Thread Russell Keith-Magee

On 7/20/07, John M <[EMAIL PROTECTED]> wrote:
>
> Does caching matter that much in my example, since it's dynamic data
> anyway?

Don't let the fact that the data is dynamic distract you. All database
backed websites are dynamic at some level. However, when you have
thousands of requests for a resource every second, does it really
matter if the version delivered to the user is 1 second out of date?
10 seconds? A minute?

You should be able to serve a reasonably sized Django application
without ever having to care about caching. However, It pays to get
into a good habits early. It is a lot easier to add caching to the top
of a clean ReSTful application than it is to refactor a messy,
non-ReSTful application so that you can add caching.

As a bonus, URL spaces that are easily cached are also the ones that
match the browsing metaphor the best (i.e., are ReSTful), so asking
the question "could I cache this" is one way of validating a design.

Yours,
Russ Magee %-)

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



Re: Mapping models to CRUD urls?

2007-07-20 Thread John M

Russ,

Wow, thanks so much for clearing that up, I was never sure about the
parameters part of the URL, since this is my first real web program
EVER, and I figured django was the right way to go.

Does caching matter that much in my example, since it's dynamic data
anyway?

John


On Jul 19, 5:43 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/20/07, John M <[EMAIL PROTECTED]> wrote:
>
>
>
> >http://.../model3/add/#   - calls a view to add a new model3, with
> > foreign key model2 of #
> >http://.../model3/edit/#   - calls a view to edit a model3 of ID#
>
> > It seems simple enough, but wanted to get everyones feedback on
> > anything I'm missing, or is it just this simple?
>
> It's pretty much that simple, although there are a few details I would 
> suggest:
>
> - You have add and edit views, but no 'view' view - i.e., just show me
> the object. The best place for this is probablyhttp://.../model1/#
> for model1, ID # (repeated for other models). Alternatively, if there
> is no such thing as a non-editing view - if you want an object to be
> editable whenever it is viewed, just make thehttp://.../model1/#view
> the edit view. If you do this, make sure you do a HttpResponseRedirect
> when you POST to prevent the POST request ending up in the browser
> history.
>
> - You might want to have a think about your method of foreign key
> hinting using the URL. Each URL should be a unique, cachable resource
> - in this case, "add an instance of model3". Adding
> transient/suggested data to your URL would generally violate this
> principle. On top of that, what do you do to the URL space if you need
> to specify 2 foreign keys?
>
> A alternate approach would be to pass in the preferred foreign key as
> part of the GET dictionary i.e., your request would be:
> /model3/add/?model1=3. That way, there is only 1 URL resource (the add
> page at /model3/add/), and the view can still work if you have no or
> multiple specified foreign key references (just modify the handling of
> the GET dictionary to inspect 0, 1 or many keys).
>
> Yours,
> Russ Magee %-)


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



Re: Authentication for application with subdomains

2007-07-20 Thread David Marko

> One possible solution would be to append the domain name to the
> username before authentication. The user types in 'bob', then the
> system munges it to 'bob.sub.domain.com' before doing the validation.

### this approach should work . Do you use it for your app? Any
experiences?


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