OS X install, not in home directory?

2010-04-24 Thread Rob
Hi,

Maybe this is more of a general python question, but when I run `sudo
python setup.py install` it insists on putting the django package in ~/
Library/Python/2.6/site-packages.  I want to install it in the system
site-packages, so it get's picked up by apache and mod_wsgi.  For now
I'll hand copy the files, but there must be a way with setup.py.  ?

thanks,
Rob

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



Re: OS X install, not in home directory?

2010-04-24 Thread pjmorse
On Apr 24, 3:03 am, Rob  wrote:
> Maybe this is more of a general python question, but when I run `sudo
> python setup.py install` it insists on putting the django package in ~/
> Library/Python/2.6/site-packages.  I want to install it in the system
> site-packages, so it get's picked up by apache and mod_wsgi.  For now
> I'll hand copy the files, but there must be a way with setup.py.  ?

Try the --prefix or --install-base options to `setup.py install`.
`python setup.py install --help` will run down the options for you; I
think --prefix=/Library/Python/2.6/site-packages/ is worth a shot?

pjm

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



Localization and date format

2010-04-24 Thread pjmorse
Is there any way to force a particular localization on date
formatting?

Our site (Django 1.0.2, Python 2.5) was set up with "UK" as the
language code for the U.K. This apparently didn't cause any problems
for years, but now that the person who made that decision is out of
arm's reach, it's been discovered that dates in the UK localization
are being displayed in... wait for it... Ukranian.

Swapping the language code to "en" (which would be correct) breaks
most of the rest of the site for reasons I don't fully understand yet.

Is there any way to either override the localization on date
formatting, or provide a parameter with the correct language code?

Thanks,

pjm

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



Test failing on @login_required view

2010-04-24 Thread eka (Esteban)
Hi all,

I'm trying to build a test for a view that's decorated with
@login_required, since I failed to make it work, I did a simple test
and still can't make it pass.

Here is the code for the simple test and the view:

def test_login(self):
user = self._create_new_user()
self.assertTrue(user.is_active)
login = self.client.login(username=user.username,
password=self.data['password1'])
self.failUnless(login, 'Could not log in')
response = self.client.get('/accounts/testlogin/')
self.assertEqual(response.status_code, 200)

@login_required
def testlogin(request):
print 'testlogin !! '
return HttpResponse('OK')

_create_new_user() is saving the user and there is a test inside that
method to see that is working.

The test fails in the response.status_code, returning 302 and the
response instance is of a HttpResponseRedirect, is redirecting it as
if not logged in.

Any clue? I'm missing something?

Regards
Esteban

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



Re: error with forms

2010-04-24 Thread Daniel Roseman
On Apr 17, 1:14 am, JoJo  wrote:
> Hi all, i have an error here im not sure what it means can anyone help
> me
>
> here is my models.py file##
> class AddStuffForm(forms.Form):
>
>         title = forms.CharField(max_length=100)
>         body = forms.CharField(widget = forms.Textarea())
>
>         def save(self):
>             new_gossip =  Gossip.objects.create(title  =['title'],
>                                                 body =['body'])
>


> Exception Type: TypeError at /add_gossip/
> Exception Value: 'body' is an invalid keyword argument for this
> function
>
> Thanks in advance
>

You haven't shown the definition of your Gossip model, but it
apparently doesn't have a `body` field.

Also, not the cause of your error, but you do realise that what you're
trying to do here is set the value of the title and body fields to
'title' and 'body' respectively - although it won't work because
you're wrapping them in lists? Presumably you mean
title = self.cleaned_data['body']
etc.
--
DR.

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



Re: form class

2010-04-24 Thread Daniel Roseman
On Apr 23, 9:03 pm, xpanta  wrote:
> Thank you for the answers.
>
> The link provided by George is an excellent resource and I should
> thank him for that.
>
> However my task is a bit simpler. Let's say I own a car company and I
> have dealers in various cities. By clicking on each city name I get a
> list of cars this city's dealer sells. This list varies from city to
> city. Also, this list comes as a form where I (as the car company
> owner) need to write the minimum and maximum selling price for each
> car and submit it. It is a hypothetical scenario, but my project deals
> with a very similar problem.
>
> in this example is the django's form class approach "better" than the
> "classic" one (i.e. the one where I use a {% for car in citycars %}
> loop and attach a car.id and the dealer.id to each input field and
> process accordingly in the view)?
>
> I am new to django, so bear with me if I ask something trivial.
> Thanks for your time,
> Chris

OK, so that's an easy way of showing the fields. But now what? If you
need to validate that the user has filled them in properly, how will
you do it? How will you redisplay the form to show the errors? And
presumably you want to do something with the data once the user has
filled them in - so how will you save it to the database?

All these things are taken care of by Django's form class. In your
case, the model you describe doesn't seem to require the dynamic form
technique, it's a simple matter of formsets - which again Django can
define for you automatically from your model.
--
DR.

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



Re: Localization and date format

2010-04-24 Thread Skylar Saveland
I presume that you mean date formatting in the templates:

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

you can use the strftime format bits iirc:

http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior

you can set the default with a setting

http://docs.djangoproject.com/en/dev/ref/settings/#date-format

The language code shouldn't mess with the l10n date formatting that
I'm aware of, not sure. ... I think that UK locale is  ... hrm ..

you should be able to take care of your dates with the above info
though .. hrm ..

On Apr 24, 9:41 am, pjmorse  wrote:
> Is there any way to force a particular localization on date
> formatting?
>
> Our site (Django 1.0.2, Python 2.5) was set up with "UK" as the
> language code for the U.K. This apparently didn't cause any problems
> for years, but now that the person who made that decision is out of
> arm's reach, it's been discovered that dates in the UK localization
> are being displayed in... wait for it... Ukranian.
>
> Swapping the language code to "en" (which would be correct) breaks
> most of the rest of the site for reasons I don't fully understand yet.
>
> Is there any way to either override the localization on date
> formatting, or provide a parameter with the correct language code?
>
> Thanks,
>
> pjm
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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