Friday, December 31, 2010

Re: merge 2 views?

The one downside to this solution is that these variables will fetched
for every request, even if navigation.html was not included in the
output template.

An alternative solution would be to create a template tag that fetches
these variables, and only load and use this template tag in
navigation.html. That way those variables are only fetched if
navigation.html is included.

It's a little bit more complicated in code though (made a lot easier
in Django 1.3 with simple_tag), and might not be worthwhile if you
aren't doing complicated computations.

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/

On 30 December 2010 05:32, Thom van Ledden <tvledden@gmail.com> wrote:
> Thanks a lot for pointin me in the right direction!
>
> made a context_processor.py for my navigation, and added it to my
> settings.py
>
> from basic.blog.models import Category
> from common.models import fillNavigationFinishedProjects
> from common.models import fillNavigationUnfinishedProjects
>
> def navigation(request):
>    """
>    Adds navigation  variables to the context.
>
>    """
>    return {
>    'finishedProjects':fillNavigationFinishedProjects(),
>    'unfinishedProjects':fillNavigationUnfinishedProjects(),
>    'blogCategories':Category.objects.all(),
>    }
>
> Seems to work perfectly!
> thanks much!
>
> On 29 dec, 18:51, Michael <mhall...@gmail.com> wrote:
>> Look into context processors, that sounds like what you need.
>>
>> http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-c...
>> --
>> Michael <mhall...@gmail.com>
>>
>> On Wed, 2010-12-29 at 08:51 -0800, Thom van Ledden wrote:
>> > Hi django developers,
>>
>> > Ive got a seperate navigation.html file which need to be rendered on
>> > each page, but the page need some vars for that. how can i get those
>> > vars to be defined just only once?
>>
>> > my idea: the main_page should add the vars for the navigation, and the
>> > views of the content pages will have their own vars, and those need to
>> > be merged some how
>> > some files i uploaded:http://thomvl.pastebin.com/gGjGj4NP
>> >http://thomvl.pastebin.com/uYUp5iCjhttp://thomvl.pastebin.com/Yv6fPTP7
>>
>> > could anyone point me where i go wrong? (the main_page 's vars are the
>> > ones i need, aside of title ofcourse)
>>
>> > Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

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

Re: De-coupling settings.py from project

On 31 December 2010 03:50, eblume <blume.erich@gmail.com> wrote:
> In particular, I'm having trouble specifying the static content URL
> and the fixtures directories at a per-application level rather than in
> the project settings.py file.

Can't you implement a static files finder, in the similar way to
template loaders to achieve the same effect?

http://docs.djangoproject.com/en/dev/howto/static-files/

New in Django 1.3.

> Is there a way to specify settings like STATIC_URL or FIXTURES_DIRS
> per-application rather than per-site? Even better - is there a
> mechanism to use a settings.py file in the application rather than in
> the site?

As Christophe explained, it is possible, but I also agree with
Christophe - you're going to the extreme for very unlikely use cases.
Also keep in mind that every time Django handles a request, it will
import the settings for *every* app, instead of just the app you think
will be used to handle the request. Settings could then clash, making
debugging a pain.

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

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

Re: DJANGO BOOTCAMP

On Sat, Jan 1, 2011 at 00:17, <delegbede@dudupay.com> wrote:
> Hi all,
>
> I recently started working on a project which is based on django. I've had reasons to work through the documentation several times to get things done.
> However, each time I check the documentation, I find out there is more to learn hence, my thought.
>
> Is there any or can there be a django clinic for beginners or a bootcamp for beginners where people can go through the process of learning django.
>
> With the little I have seen of the so many that is possible, can there not be such arrangement for beginners like me to tap into. Reading the documentation alone may not help as having a guide.

The four part tutorials! I used to get frustrated that they just ended
too. I did them numerous times. In the end, it was starting my own
project and then hanging out in the boot camp known as [mailing
list|irc|docs]. That's it. I'm sure I'm not alone here in not knowing
Django inside out. Build it, and as you need something, look read and
ask. I don't think there's a short cut. The intro tutorials are
excellent for a broad overview and getting started on your own project
though.

cheers
L.

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

--
"... imagine a puddle waking up one morning and thinking, 'This is an
interesting world I find myself in - an interesting hole I find myself
in - fits me rather neatly, doesn't it? In fact it fits me
staggeringly well, must have been made to have me in it!' This is such
a powerful idea that as the sun rises in the sky and the air heats up
and as, gradually, the puddle gets smaller and smaller, it's still
frantically hanging on to the notion that everything's going to be
alright, because this world was meant to have him in it, was built to
have him in it; so the moment he disappears catches him rather by
surprise."
Douglas Adams

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

Re: Local flavor and admin (zip-code)

On Dec 2 2008, 1:16 pm, Fabio Natali <nat...@poisson.phc.unipi.it> wrote:
> Dear Sergio, thank you very much for your reply.
>
> sergioh wrote:
>
> [...]
>
> > from django.contrib.localflavor.it.forms import ITZipCodeField
> > from django import forms
> > from django.utils.translation import ugettext_lazy as _
>
> > class DittaDipendentiAdmin(admin.ModelAdmin):
> > cap = ITZipCodeField(_('ZIP Code'))
>
> > class Meta:
> > model= DittaDipendenti
>
> > Just overriding the form field using the ITZipCodeField, works fine.
>
> If I write:
>
> class DittaProva(models.Model):
> cap = models.IntegerField("Cap",max_length=5)
>
> from django.contrib.localflavor.it.forms import ITZipCodeField
> from django import forms
> from django.utils.translation import ugettext_lazy as _
> class DittaProvaAdmin(admin.ModelAdmin):
> cap = ITZipCodeField(_('ZIP Code'))
> class Meta:
> model= DittaProva
>
> then I get this error at the command line:
>
> $ python manage.py syncdb
> [...]
> class DittaProvaAdmin(admin.ModelAdmin):
> File "/home/fabio/my_django/arteak/../arteak/anagrafiche/models.py", line 20, in DittaProvaAdmin
> cap = ITZipCodeField(_('ZIP Code'))
> File "/home/fabio/my_django/django-trunk/django/contrib/localflavor/it/forms.py", line 18, in __init__
> max_length=None, min_length=None, *args, **kwargs)
> TypeError: __init__() got multiple values for keyword argument 'max_length'
>
> Do I miss anything? Any other tips?

I'm quite confused and stuck on this too.
As you, I want to override a model field by a django.contrib.localflavor class.

Let me know if you got any success.

Thanks!
--
Vinicius Massuchetto
http://vinicius.soylocoporti.org.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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Linux password authentication for django

Hi Marc,

Thank you so much! You really helped me!

Bill

On Dec 30, 10:24 am, Marc Aymerich <glicer...@gmail.com> wrote:
> On Thu, Dec 30, 2010 at 6:35 AM, Bill <billchen...@gmail.com> wrote:
> > Hi there,
>
> > I want to know is there any authentication module base on Linux passwd/
> > shadow file for django?
>
> http://atlee.ca/software/pam/module-index.html
>
> import pam
> from django.contrib.auth.models import User
>
> class PamBackend:
>
>     def authenticate(self, username=None, password=None):
>         # Check the username/password and return a User.
>         if pam.authenticate(username, password, service='login'):
>              try:
>                 return User.objects.get(username=username)
>             except User.DoesNotExist:
>                 pass
>         return None
>
> --
> Marc

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

cannot login to admin site with superuser

Hi,

It seems that for some reason I can't login to admin site or my
webpage using the admin user. I even created a new superuser with
manage.py createsuperuser using plain numbers as my password ('123').
So it is not a password issue.

However when I try to django-admin validate I get an import error like
this:

Error: Could not import settings 'myproject.settings' (Is it on
sys.path? Does it have syntax errors?): No module named
myproject.settings

c:\workspace\myproject is on my sys.path. I also did a
sys.path.append() c:\workspace but I still get the same error.

I also tried this:

http://coderseye.com/2007/howto-reset-the-admin-password-in-django.html

but still I can't login.

Admin user cannot login to the myproject web page. Other users can. I
use a postgresql database. I used to have a mysql db but I switched to
postgresql. Don't know if that matters.

I also use django 1.2.1 on windows 7.

Any help would be appreciated. I have tried hard and now I am
completely lost.

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

ANN: The django CMS 2.1 Release Candidate 2 has been released!

The second Release Candidate for the Django-CMS 2.1 was just released
and is
ready for testing. Please keep in mind that this is a release candidate,
and not
a final release yet!

Download: http://pypi.python.org/pypi/django-cms/2.1.0.rc2
Documentation: http://django-cms.rtfd.org
Source: https://github.com/divio/django-cms/tree/2.1.0.rc2

Please report any issues you find with this release to our issue tracker at
https://github.com/divio/django-cms/issues, thank you.


This second Release Candidate fixes a few bugs found in 2.1 RC1 as well
as a
compatibility problem with Django 1.2.4 which was released shortly after
RC1.

The bugs fixed in RC2 are:

- #621: Page changelist in admin is incompatible with Django 1.2.4 when
using multiple sites
- #624: Saving pages with a language not available to the site currently
being browsed, but available to the target site of the page
- #631: MultilingualURLMiddleware does not work with single-quoted urls
in templates
- #630: Pages cannot be added if CMS_MODERATOR is False

There are currently no known issues with RC2.


So what's new in 2.1?


* Frontend Editing!
You can edit your contents directly on the site, as an alternative to
the more
abstract admin panel.

* Better integration of 3rd party applications!
It is now easier then ever to integrate any 3rd party Django
applications into
your CMS or make your Django application CMS-Ready.

* "Placeholders"
It is now possible to use the Django-CMS Plugin based content
architecture in
any Django model using the new Placeholder Fields! This even comes
with full
blown frontend editing.

* Menu Refactor
The menu code has been strongly refactored since 2.0 and it is now
easier to
extend and alter the menus.

* Better Docs, Better Tests, Better Code
Our documentation is now hosted on the amazaing readthedocs.org and was
improved vastly and is still being improved until 2.1 final. On top
of that
our testing infrastructure, our test suite and our test coverage has
improved
significantly as well. And in the process of fixing a lot of bugs, we
have
also improved the readability and maintainability of the Django-CMS
codebase
to make it easier for new developers to get around.

* And lots more!


In the name of the django CMS Core Developers team I wish you all a
happy new year and enjoy our RC2!

Jonas Obris

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

RE: DJANGO BOOTCAMP

That would be wonderful!

--
Yudhvir Singh Sidhu
CEO, MediGrail LLC

DJANGO BOOTCAMP

Hi all,

I recently started working on a project which is based on django. I've had reasons to work through the documentation several times to get things done.
However, each time I check the documentation, I find out there is more to learn hence, my thought.

Is there any or can there be a django clinic for beginners or a bootcamp for beginners where people can go through the process of learning django.

With the little I have seen of the so many that is possible, can there not be such arrangement for beginners like me to tap into. Reading the documentation alone may not help as having a guide.

Regards.
Sent from my BlackBerry wireless device from MTN

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

Working with django signals

Hi,

Am new to this group, I hope to learn more from reading exchange
emails. As for now, wish everyone a happy new year :)


I posted a question earlier on stackoveeflow and am wondering if
anyone here might be able to point me to the right direction,

http://stackoverflow.com/questions/4569844/django-signals-implementing-on-save-listner


Regards,

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

Re: Extracting days,months,years from datefield.

On Fri, Dec 31, 2010 at 5:53 AM, Malte Beckmann
<monolithcalls@googlemail.com> wrote:
> I got a models.DateField and would like to extract months and years from
> that field so I can do calculations like a 'day in month' in a 'for month in
> months' loop in a 'for year in years' loop. How can I extract that info from
> a datefield? I have tried to read code written by others but their solutions
> are not very obvious to me.

The value of a Datefield is a Python datetime.date object. To see the
attributes of datetime.date instances, which include what you want
here, see the Python datetime documentation:

http://docs.python.org/library/datetime.html#date-objects


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

Extracting days,months,years from datefield.

I got a models.DateField and would like to extract months and years from that field so I can do calculations like a 'day in month' in a 'for month in months' loop in a 'for year in years' loop. How can I extract that info from a datefield? I have tried to read code written by others but their solutions are not very obvious to 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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Thursday, December 30, 2010

Show HTML in Labels for Model Choice Fields

Hi I have a situation like this

class AppearanceThemesForm(forms.Form):
page_theme =
forms.ModelChoiceField(widget=forms.RadioSelect(attrs={'title':'Select
the appropriate theme for your pages.'}),

queryset=Theme.objects.filter(section="1"),

initial=Theme.objects.get(section="1",representation="").pk,
label="Page Theme")

And my Theme model is like this:

class Theme(models.Model):
name = models.CharField(max_length=32)
image = models.ImageField(upload_to="images/themes", null=True)

def __unicode__(self):
return "%s" % (self.name)


When I render AppearanceThemesForm in my template, i would like to be
able to show a link next to the label. If a user clicks the link, the
webpage displays the image associated with Theme.

I tried putting in a custom field that extends the ModelChoiceField,
and in the label_from_instance method, tried to output the HTML, but
that gets escaped.

What is the proper way to achieve what i am trying to do?

Alternatively, how do i get access the underlying model object behind
the modelchoice field in my templates?

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

Sorry -- Re: Django not seeing AuthenticationMiddleware for some reason ...

Sorry for the repeats! I was already a member of the
group from another email address, but Google kept sending
me bounce messages even after I joined from this address
and resent -- then all 3 copies came at once ... oops. :(

Steve

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

Django not seeing AuthenticationMiddleware for some reason ...

I am baffled, and it's probably something simple I'm missing ...
I just need to send a message for help and then I'll see it ...
(maybe ... ;)

My set up:
* apache2 on Ubuntu 10.04
* mod_wsgi 3.3, compiled with python 2.6.5 (the system python)
(but Ubuntu's mod_wsgi package was apparently not the problem)
* django installed in a virtualenv with python 2.6.5 also
* 2 django apps, one running on ':80' virtual host and one on
':8000' virtual host, each with a separate wsgi script (of course)
* apache server config (apache.conf) has WSGIPythonHome directive:
'WSGIPythonHome [path to virtualenv directory]'
* virtualenv directory has python interpreter in its bin dir and
python packages installed in its lib dir, including all django
libs
* I have verified that AuthenticationMiddleware can be imported
successfully from the command line within the virtualenv using
the virtualenv's python intepreter
* both django apps live within the virtualenv directory,
each in its own "project" directory there
* both apps are configured in apache with WSGIDaemonProcess directive

The error I continue to get is:

"ImproperlyConfigured at /

"The Django remote user auth middleware requires the
authentication middleware to be installed. Edit your
MIDDLEWARE_CLASSES setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware' before
the RemoteUserMiddleware class."

The relevant sections of the settings.py files for the apps are:
--------------
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
)

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)
---------------

Ultimately I'll be using Active Directory (Kerberos) auth, but for
purposes of testing the REMOTE_USER stuff I've configured Basic
Authentication, and it is working (I authenticate successfully
before seeing that error message).

One thing that puzzles me is that in spite of a WSGIPythonHome
directive that points to the virtualenv, the error message lists
the "Python Executable" as "/usr/bin/python". The "Python Path"
shown in the error message seems correct: it includes the
virtualenv's site-packages directory, which is where django is
installed (there is no system-level django installed, Ubuntu's or
otherwise), and as I say I tested that the middleware classes
that the error message complains about can be imported using the
virtualenv's python interpreter on the command line.

Any suggestions welcome! (I can send the whole error page if it
would help, but I'll need to launder it a little.)

TIA!
Steve

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

Re: Caught NoReverseMatch while rendering:Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

Message error tells that you are trying to reach "index" url, which doesn't exists. Maybe you are calling "index" url instead of "login".

2010/12/30 aaron <aaron.jerling@gmail.com>
Any idea what this means?

The URL entry is as per the django tutorial as:

(r'^login/$', 'django.contrib.auth.views.login', {'template_name':
'registration/login.html'}),

And in my settings.py file I specify
LOGIN_URL = 'login/'

cheers,
A

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


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

Caught NoReverseMatch while rendering:Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

Any idea what this means?

The URL entry is as per the django tutorial as:

(r'^login/$', 'django.contrib.auth.views.login', {'template_name':
'registration/login.html'}),

And in my settings.py file I specify
LOGIN_URL = 'login/'

cheers,
A

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

Re: ModelForm validation in 1.2.3

The question is how do I get the modelform to only check for form
validity, and not model validity (like it did before). I don't see
what your link has to do with that.

On Dec 30, 7:32 pm, Ferran <fer...@fompi.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On 30/12/10 17:25, Burhan wrote:
>
> >  In 1.2.3, this logic always fails because "is_clean()" fails if an
> > existing customer enter's their email address. How can I do the same
> > using django 1.2.3?
>
> http://docs.python.org/tutorial/errors.html
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/
>
> iQIcBAEBCAAGBQJNHLQCAAoJEAWOKfEESaOw/KkQAJpykIq4NuWT2pFlzT/jg2Ck
> ZLPnKTABp7JmvDdNflreKhKDKmhMSmYTu9/ThF8RtGgtstq5oUtdhZmKoRnpnuWe
> GHFPPidSBD9NOs1MFgj1+8kkvcTFLE6kPRupfNN9nJKFm4gZ8dpV602WOJWlK1dJ
> 4ViK5fFU4AwOoGpqZrmMG6J8bzOKs6U6rNJP4YLSvMyRyEOj5qVwAo9x4V+NpgHg
> 5NiWADvWnwISc7QdB84ViYsmF3ocIIZnzAgLbRa7kej/8NQ/ikndc7gAvjpseJi7
> R3GiaW816m/PElkXlbiszKxjJQSYP9uDfzURJ9oJyU5LNa1cNkr1RrWAtlh/j5RI
> mCwyq7I7MbFodsJe7ZGpUzspZfyk9lxSYAfaVZcE9v9fVJc1y6JbW0KyMl3MJyZG
> K0x+PA+X03gEDnr9fso3cijBc1gz3sVGyj3C5rOgaCnlasRQzbjcjOaIx8GpUTgU
> 4OgP5k/Agz6eYr08JES1cvOeug7TYGY4x84MRwe++RgaOhf/1W7v4Hrvm22hBGcA
> ivBr0xt0rdzCQKeX2JriDMcqWE99KTEEqqWX4bA1l47UiaWg16wvyoxgexQT7Y0O
> larKwMr/5G9+2fQOoYzHL9EcDmzzWJHNjrIZmjrIMv+6fQ5b30aTIh+qI8yvg2vw
> roI7MOFS6TYefl0QhP8R
> =jP4n
> -----END PGP SIGNATURE-----

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

Re: django using wrong python???

Are you having this problem with Django development server, or with a production type hosting setup such as mod_wsgi?

Need to know which.

Graham

On Friday, December 31, 2010 1:34:22 AM UTC+11, yelbuke wrote:
Hi,

I'm on centos and have two pythons 2.5 and 2.6.

I tried in models.py:

from fractions import Fraction

and got the error: No module named fractions

But when i use shell and type "from fractions import Fraction" it's OK, it uses python2.6 installation.

How can i modify django installation to use python2.6???

I already defined alias in bash_profile for python2.6, but it seems it doesnt work for django.

Thanks,

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

ModelForm and checkbox from choices

In my model i have that part:
... 
STATUSES_CHOICES = (
        (0, _(u'one')),
        (1, _(u'two')),
        (2, _(u'three'))
    )
...
status = models.SmallIntegerField(default=0, choices=STATUSES_CHOICES, null=True, blank=True)
....



then in my form based on that model I wanto to make that field as checkbox list. I know that I can make it as:
class Meta:
        widgets = {'categories' : forms.CheckboxSelectMultiple, }

but, I want to change that field's label. How can I do that to server that list with changed label?

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

Re: Attempting to save instance with null ID?

Jonathan ...

The problem is in the difference in SQLite and Oracle.  Unlike MySQL, PostgresQL, and SQLIte, Oracle doesn't have auto-generated primary keys.  To make up for that, Django on Oracle uses a trigger for each Django-managed table that recognizes a NULL primary key on insert, and generates a key by using a dedicated sequence for that table.  Usually if you're creating the tables from scratch, the Django management tools (syncdb, sqlall, etc) will create the sequence and trigger for you.  Without knowing more about how your populated your schema, it's hard to say what went wrong, but if you run 'python manage.py sqlall invdb' it should print out the DDL to create the trigger and sequence, and you can manually add them.

- Craig -

On Thu, Dec 30, 2010 at 11:09, Jonathan Hayward <christos.jonathan.hayward@gmail.com> wrote:

I'm migrating from SQLite to Oracle, and I'm getting an error thrown on the line disn_requisition.save() claiming that it has a null ID. I have not attempted to manually set or fiddle with id fields on any model, although I do read them.

Any insight on what I need to do to address this?

IntegrityError at /upload/storage

ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID") 
Request Method: POST
Request URL: http://cmlnxbld01:8000/upload/storage
Django Version: 1.2.3
Exception Type: IntegrityError
Exception Value:
ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID") 
Exception Location: /tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/backends/oracle/base.py in execute, line 507
Python Executable: /tools/python/2.7/Linux_x86_64/bin/python
Python Version: 2.7.0
Python Path: ['/home/jhayward/invdb', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django_filter-0.5.3-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/ez_setup-0.9-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/hgsvn-0.1.8-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/paramiko-1.7.6-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/pycrypto-2.3-py2.7-linux-x86_64.egg', '/tools/python/cx_Oracle/10g/2.6/Linux_x86_64/lib/python2.6/site-packages', '/home/jhayward', '/home/jhayward/invdb/HOME_DIRECTORY', '/home/jhayward/invdb/HOME_DIRECTORY/invdb', '/tools/python/2.7/Linux_x86_64/lib/python27.zip', '/tools/python/2.7/Linux_x86_64/lib/python2.7', '/tools/python/2.7/Linux_x86_64/lib/python2.7/plat-linux2', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-tk', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-old', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-dynload', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time: Thu, 30 Dec 2010 10:04:24 -0600

--
Christos Jonathan Hayward
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio • Books • Email • Facebook • LinkedIn • Twitter • Web • What's New?

I invite you to visit my "theology, literature, and other creative works" site.

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

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

Re: User authentication in Django

According to the docs you just need to add
{% csrf_token %}

to each form.

sorry for the noise.

On Dec 30, 5:15 pm, aaron <aaron.jerl...@gmail.com> wrote:
> okay, so I added a url directing accounts/login requests to a view
> which in turn directs it to the login.html template suggested at
>
> http://docs.djangoproject.com/en/dev/topics/auth/
>
> Which is:
>
> {% extends "base.html" %}
> {% load url from future %}
>
> {% block content %}
>
> {% if form.errors %}
> <p>Your username and password didn't match. Please try again.</p>
> {% endif %}
>
> <form method="post" action="{% url 'django.contrib.auth.views.login'
> %}">
> {% csrf_token %}
> <table>
> <tr>
>     <td>{{ form.username.label_tag }}</td>
>     <td>{{ form.username }}</td>
> </tr>
> <tr>
>     <td>{{ form.password.label_tag }}</td>
>     <td>{{ form.password }}</td>
> </tr>
> </table>
>
> I've taken out the "base.html" stuff. When I now submit a user and
> login (even though I've not yet created a user) I expect to see {% if
> form.errors %}
> <p>Your username and password didn't match. Please try again.</p>
> {% endif %}
>
> However instead I get an error: CSRF verification failed. Request
> aborted.
>
> Any ideas?

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

Re: ModelForm validation

Ah :) . I should have thought of that ... pretty stupid of me :)

Thanks for the clarification, I'll try that, makes perfect sense!


/Axel.



2010/12/30 derek <gamesbook@gmail.com>
Alex

And I seem to have been equally unclear :}

I agree that cleaned_data is only available after is_valid() - the
point being that your form *will* be valid if you have set the value
for that field in a hidden input.  I do not see that this can be a
"security risk" - the default that you are setting beforehand is a
dummy (meaningless) value which, in any case, you are going to be
overriding.  How is this done?  Consider this example from the Django
Book (http://www.djangobook.com/en/1.0/chapter07/):

def contact(request):
   if request.method == 'POST':
       form = ContactForm(request.POST)
       if form.is_valid():
           topic = form.clean_data['topic']

Now if you wanted to overide the topic, you could instead have:
           topic = 'my custom text'


Hope this is clearer!

Derek

On Dec 29, 4:07 pm, Axel Bock <mr.axel.b...@gmail.com> wrote:
> hi derek,
>
> thanks for your hints - was I really that unclear? hm.
>
> anyway, could you please give an example about how to "override/check the
> value for that field after the form POST"? I don't seem to be able to do
> that, and believe me, I have read the docs.
>
> I think cleaned_data is only available after is_valid() was called, but
> is_valid() throws an exception because the required field is missing - and I
> can't set it.
>
> The hidden field thing is the last thing I wanted to try. bad style, you
> know :) , cause security risk.
>
> thanks!
> Axel.
>
> 2010/12/29 derek <gamesb...@gmail.com>
>
>
>
>
>
>
>
> > Axel
>
> > Not sure I have followed all your requirements, but perhaps you can
> > try:
> > * set a default value for the required field
> > * mask the required field on the form being shown to the user (make it
> > hidden)
> > * override/check the value for that field after the form POST and data
> > "clean" (see:
> >http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#proce...
> > )
>
> > HTH
> > Derek
>
> > On Dec 28, 10:21 pm, Axel Bock <justsomeoneoutth...@gmail.com> wrote:
> > > Hi all,
>
> > > I have this little problem. In my little webapp I have a data model which
> > > defines several required fields. Depending on WHO is logged on, some of
> > > these fields should not be changed by the user and be pre-filled (or
> > better:
> > > post-filled) by the application.
>
> > > Currently I delete the fields out of the formset like this:
> > >             # prevent entering missions for all other bases
> > >             del missionform.fields['base']
>
> > > so the field gets not rendered in the view. Which works nicely.
>
> > > Unfortunately base is required, so the validation fails. Now how can I
> > > insert the missing values into the POST data? I tried this:
> > >         if request.user.userflag.is_student:
> > >             logging.error("studen")
> > >             inst=FlownMission(
> > >                 student=request.user,
> > >                 base=request.user.studentinfo.current_base
> > >             )
> > >         flownmission = FlownMissionForm(request.POST, instance=inst)
>
> > > which does not work at all :( . The validation fails all the time ... . I
> > > just need to inject 2 required values somewhere in the POST data, but I
> > have
> > > no clue how.
>
> > > Any help would be greatly appreciated, and I am a total django "newb" ...
> > :)
>
> > > Thanks & greetings,
> > > Axel.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscribe@googlegroups.com<django-users%2Bunsubscribe@google groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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


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

Re: De-coupling settings.py from project

On Dec 30, 2010, at 8:50 AM, eblume wrote:
> Is there a way to specify settings like STATIC_URL or FIXTURES_DIRS
> per-application rather than per-site? Even better - is there a
> mechanism to use a settings.py file in the application rather than in
> the site?

I think that your overall goal is quite admirable, but this may be an optimization too far. One way to think of the way Django organizes its code is that a project is the platform on which applications are deployed. The role of settings.py (and the top-level urls.py) is to configure the applications for a particular deployment, so things like STATIC_URL that are specific to a particular deployment of the app should not be in the app itself.

Thus, the top-level settings.py should include stuff that is:

1. General across all applications, or,
2. Used to configure a particular application for a particular deployment.

All that being said, it's no big deal to emulate the urls.py include facility in settings.py; just include your app-specific settings. You can also have a 'settings.py' (or whatever) file within the application that only that app imports.

--
-- Christophe Pettus
xof@thebuild.com

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

Re: User authentication in Django

Okay, that problem is fixed. I just added the /accounts/login to the
url file.

New problem:

my login page is giving me: CSRF verification failed. Request aborted

This is the html from login.html

{% block content %}

{% if form.errors %}
<p class="error">Sorry, that's not a valid username or password</
p>
{% endif %}

<form action="" method="post">
{% csrf_token %}
<label for="username">User name:</label>
<input type="text" name="username" value="" id="username">
<label for="password">Password:</label>
<input type="password" name="password" value="" id="password">

<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next|escape }}" />
</form>

{% endblock %}

Any ideas?

Cheers,
Aaron

On Dec 30, 4:33 pm, aaron <aaron.jerl...@gmail.com> wrote:
> Hi guys,
>
> I'm attempting to follow the very simple setup for user authentication
> in Django as detailed in the documentation here:
>
> http://docs.djangoproject.com/en/dev/topics/auth/
>
> I've got a database synced, the apps installed as detailed, but when I
> attempt to access a password protected url it gives me the following
> 404 message:
>
> Using the URLconf defined in logintest.urls, Django tried these URL
> patterns, in this order:
> ^logintest/
> ^admin/doc/
> ^admin/
> ^secret/
> The current URL, accounts/login/, didn't match any of these.
>
> Secret is the app that simply renders a page that says 'secret'. It
> works fine when the @login decorator is commented out.
>
> Any ideas?

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

Re: User authentication in Django

okay, so I added a url directing accounts/login requests to a view
which in turn directs it to the login.html template suggested at

http://docs.djangoproject.com/en/dev/topics/auth/

Which is:

{% extends "base.html" %}
{% load url from future %}

{% block content %}

{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}

<form method="post" action="{% url 'django.contrib.auth.views.login'
%}">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>

I've taken out the "base.html" stuff. When I now submit a user and
login (even though I've not yet created a user) I expect to see {% if
form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}

However instead I get an error: CSRF verification failed. Request
aborted.

Any ideas?

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

De-coupling settings.py from project

I'm new to Django and trying to create an office intranet web service.
Because I value pragmatic programming, I want to take the time to 'do
it right' and so I'm spending as much time as possible de-coupling the
'django application' from the 'django project' (or 'django site' -
these seem to be synonyms.)

To that end, I've managed to de-couple the urls.py file by using the
url importing system, and the templates by using a template loader.
However, a few settings seem to be impossible to de-couple from the
project to the application.

In particular, I'm having trouble specifying the static content URL
and the fixtures directories at a per-application level rather than in
the project settings.py file.

Is there a way to specify settings like STATIC_URL or FIXTURES_DIRS
per-application rather than per-site? Even better - is there a
mechanism to use a settings.py file in the application rather than in
the site?

Thanks,
eblume

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

User authentication in Django

Hi guys,

I'm attempting to follow the very simple setup for user authentication
in Django as detailed in the documentation here:

http://docs.djangoproject.com/en/dev/topics/auth/

I've got a database synced, the apps installed as detailed, but when I
attempt to access a password protected url it gives me the following
404 message:

Using the URLconf defined in logintest.urls, Django tried these URL
patterns, in this order:
^logintest/
^admin/doc/
^admin/
^secret/
The current URL, accounts/login/, didn't match any of these.

Secret is the app that simply renders a page that says 'secret'. It
works fine when the @login decorator is commented out.

Any ideas?

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

Re: ModelForm validation in 1.2.3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 30/12/10 17:25, Burhan wrote:
> In 1.2.3, this logic always fails because "is_clean()" fails if an
> existing customer enter's their email address. How can I do the same
> using django 1.2.3?

http://docs.python.org/tutorial/errors.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJNHLQCAAoJEAWOKfEESaOw/KkQAJpykIq4NuWT2pFlzT/jg2Ck
ZLPnKTABp7JmvDdNflreKhKDKmhMSmYTu9/ThF8RtGgtstq5oUtdhZmKoRnpnuWe
GHFPPidSBD9NOs1MFgj1+8kkvcTFLE6kPRupfNN9nJKFm4gZ8dpV602WOJWlK1dJ
4ViK5fFU4AwOoGpqZrmMG6J8bzOKs6U6rNJP4YLSvMyRyEOj5qVwAo9x4V+NpgHg
5NiWADvWnwISc7QdB84ViYsmF3ocIIZnzAgLbRa7kej/8NQ/ikndc7gAvjpseJi7
R3GiaW816m/PElkXlbiszKxjJQSYP9uDfzURJ9oJyU5LNa1cNkr1RrWAtlh/j5RI
mCwyq7I7MbFodsJe7ZGpUzspZfyk9lxSYAfaVZcE9v9fVJc1y6JbW0KyMl3MJyZG
K0x+PA+X03gEDnr9fso3cijBc1gz3sVGyj3C5rOgaCnlasRQzbjcjOaIx8GpUTgU
4OgP5k/Agz6eYr08JES1cvOeug7TYGY4x84MRwe++RgaOhf/1W7v4Hrvm22hBGcA
ivBr0xt0rdzCQKeX2JriDMcqWE99KTEEqqWX4bA1l47UiaWg16wvyoxgexQT7Y0O
larKwMr/5G9+2fQOoYzHL9EcDmzzWJHNjrIZmjrIMv+6fQ5b30aTIh+qI8yvg2vw
roI7MOFS6TYefl0QhP8R
=jP4n
-----END PGP SIGNATURE-----

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

ModelForm validation in 1.2.3

Hello:

In 1.2 ModelForm validation was changed so that not only does it
check the form validation, but it does validation of the model as
well.

I have a model that has custom validation for one of its fields,
which should be unique in the table. Now I have a front end form,
created by ModelForm for this model.

I want do to the following:

1. Check if the fields are correctly filled in, as per the custom
validator written for this model.
2. If an entry already exists for using the 'unique' field, return
that object.
3. If and entry doesn't exist, create a new object.

In the old django, before this change, I could easily do it:

if request.method = 'POST':
form = CustomerForm(request.POST)
if form.is_clean():
try:
customer =
Customer.objects.get(email=form.cleaned_data['email'])
except Customer.DoesNotExist:
customer = form.save()

In 1.2.3, this logic always fails because "is_clean()" fails if an
existing customer enter's their email address. How can I do the same
using django 1.2.3?

Thanks.

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

Attempting to save instance with null ID?

I'm migrating from SQLite to Oracle, and I'm getting an error thrown on the line disn_requisition.save() claiming that it has a null ID. I have not attempted to manually set or fiddle with id fields on any model, although I do read them.

Any insight on what I need to do to address this?

IntegrityError at /upload/storage

ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID") 
Request Method: POST
Request URL: http://cmlnxbld01:8000/upload/storage
Django Version: 1.2.3
Exception Type: IntegrityError
Exception Value:
ORA-01400: cannot insert NULL into ("INVDB"."INVDB_DISK_REQUISITION"."ID") 
Exception Location: /tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/backends/oracle/base.py in execute, line 507
Python Executable: /tools/python/2.7/Linux_x86_64/bin/python
Python Version: 2.7.0
Python Path: ['/home/jhayward/invdb', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django_filter-0.5.3-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/ez_setup-0.9-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/hgsvn-0.1.8-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/paramiko-1.7.6-py2.7.egg', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/pycrypto-2.3-py2.7-linux-x86_64.egg', '/tools/python/cx_Oracle/10g/2.6/Linux_x86_64/lib/python2.6/site-packages', '/home/jhayward', '/home/jhayward/invdb/HOME_DIRECTORY', '/home/jhayward/invdb/HOME_DIRECTORY/invdb', '/tools/python/2.7/Linux_x86_64/lib/python27.zip', '/tools/python/2.7/Linux_x86_64/lib/python2.7', '/tools/python/2.7/Linux_x86_64/lib/python2.7/plat-linux2', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-tk', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-old', '/tools/python/2.7/Linux_x86_64/lib/python2.7/lib-dynload', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages', '/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time: Thu, 30 Dec 2010 10:04:24 -0600

--
Christos Jonathan Hayward
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio • Books • Email • Facebook • LinkedIn • Twitter • Web • What's New?

I invite you to visit my "theology, literature, and other creative works" site.

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

Re: django using wrong python???

2010/12/30 ozgur yilmaz <yelbuke@gmail.com>:
> I have Centos, and it comes with python2.4(sorry, not 2.5). I installed
> python2.6 and django is under:

I work with CentOS too but installing different python versions in
parallel seemed like a lot of unnecessary work to maintain. So I
developed python-schizoid [0], a script that installs a virtual
environment with python 2.7, django trunk and many other useful
software.

It tries to install as much software inside the virtual environment as
possible to avoid depending on the (old) software installed on the
system. The only thing it does not install is the database engine.

Working like this makes packaging and deploying *a lot* easier because
your whole project and its dependencies (and even the python binaries)
are inside one directory. You also have the script bin/activate that
sets some useful environment variables that help working inside the
environment.

I know this doesn't actually answers your question but I thought you
may find it useful.

Regards,

[0] https://github.com/tooxie/python-schizoid

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

Re: Linux password authentication for django



On Thu, Dec 30, 2010 at 4:41 PM, Marc Aymerich <glicerinu@gmail.com> wrote:


On Thu, Dec 30, 2010 at 4:24 PM, Marc Aymerich <glicerinu@gmail.com> wrote:


On Thu, Dec 30, 2010 at 6:35 AM, Bill <billchen001@gmail.com> wrote:
Hi there,

I want to know is there any authentication module base on Linux passwd/
shadow file for django?

import pam from django.contrib.auth.models import User 
class PamBackend:
    def authenticate(self, username=None, password=None):         # Check the username/password and return a User.         if pam.authenticate(username, password, service='login'):              try:                 return User.objects.get(username=username)             except User.DoesNotExist:                 pass         return None 


ouch, I misunderstood your question. if you're using mysql as a db backend for you django project, you can use pam-mysql http://pam-mysql.sourceforge.net/ for the authentication on your servers. 

also you can look for libpam-mysql package on your distro. repositories .  

--
Marc

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

Re: ModelForm validation

Alex

And I seem to have been equally unclear :}

I agree that cleaned_data is only available after is_valid() - the
point being that your form *will* be valid if you have set the value
for that field in a hidden input. I do not see that this can be a
"security risk" - the default that you are setting beforehand is a
dummy (meaningless) value which, in any case, you are going to be
overriding. How is this done? Consider this example from the Django
Book (http://www.djangobook.com/en/1.0/chapter07/):

def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
topic = form.clean_data['topic']

Now if you wanted to overide the topic, you could instead have:
topic = 'my custom text'


Hope this is clearer!

Derek

On Dec 29, 4:07 pm, Axel Bock <mr.axel.b...@gmail.com> wrote:
> hi derek,
>
> thanks for your hints - was I really that unclear? hm.
>
> anyway, could you please give an example about how to "override/check the
> value for that field after the form POST"? I don't seem to be able to do
> that, and believe me, I have read the docs.
>
> I think cleaned_data is only available after is_valid() was called, but
> is_valid() throws an exception because the required field is missing - and I
> can't set it.
>
> The hidden field thing is the last thing I wanted to try. bad style, you
> know :) , cause security risk.
>
> thanks!
> Axel.
>
> 2010/12/29 derek <gamesb...@gmail.com>
>
>
>
>
>
>
>
> > Axel
>
> > Not sure I have followed all your requirements, but perhaps you can
> > try:
> > * set a default value for the required field
> > * mask the required field on the form being shown to the user (make it
> > hidden)
> > * override/check the value for that field after the form POST and data
> > "clean" (see:
> >http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#proce...
> > )
>
> > HTH
> > Derek
>
> > On Dec 28, 10:21 pm, Axel Bock <justsomeoneoutth...@gmail.com> wrote:
> > > Hi all,
>
> > > I have this little problem. In my little webapp I have a data model which
> > > defines several required fields. Depending on WHO is logged on, some of
> > > these fields should not be changed by the user and be pre-filled (or
> > better:
> > > post-filled) by the application.
>
> > > Currently I delete the fields out of the formset like this:
> > >             # prevent entering missions for all other bases
> > >             del missionform.fields['base']
>
> > > so the field gets not rendered in the view. Which works nicely.
>
> > > Unfortunately base is required, so the validation fails. Now how can I
> > > insert the missing values into the POST data? I tried this:
> > >         if request.user.userflag.is_student:
> > >             logging.error("studen")
> > >             inst=FlownMission(
> > >                 student=request.user,
> > >                 base=request.user.studentinfo.current_base
> > >             )
> > >         flownmission = FlownMissionForm(request.POST, instance=inst)
>
> > > which does not work at all :( . The validation fails all the time ... . I
> > > just need to inject 2 required values somewhere in the POST data, but I
> > have
> > > no clue how.
>
> > > Any help would be greatly appreciated, and I am a total django "newb" ...
> > :)
>
> > > Thanks & greetings,
> > > Axel.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscribe@googlegroups.com<django-users%2Bunsubscribe@google groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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

Re: Linux password authentication for django



On Thu, Dec 30, 2010 at 4:24 PM, Marc Aymerich <glicerinu@gmail.com> wrote:


On Thu, Dec 30, 2010 at 6:35 AM, Bill <billchen001@gmail.com> wrote:
Hi there,

I want to know is there any authentication module base on Linux passwd/
shadow file for django?

import pam from django.contrib.auth.models import User 
class PamBackend:
    def authenticate(self, username=None, password=None):         # Check the username/password and return a User.         if pam.authenticate(username, password, service='login'):              try:                 return User.objects.get(username=username)             except User.DoesNotExist:                 pass         return None 


ouch, I misunderstood your question. if you're using mysql as a db backend for you django project, you can use pam-mysql http://pam-mysql.sourceforge.net/ for the authentication on your servers. 



--
Marc

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

Re: Linux password authentication for django



On Thu, Dec 30, 2010 at 6:35 AM, Bill <billchen001@gmail.com> wrote:
Hi there,

I want to know is there any authentication module base on Linux passwd/
shadow file for django?

  import pam from django.contrib.auth.models import User 
class PamBackend:
    def authenticate(self, username=None, password=None):         # Check the username/password and return a User.         if pam.authenticate(username, password, service='login'):              try:                 return User.objects.get(username=username)             except User.DoesNotExist:                 pass         return None 
 
--
Marc

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

Re: django using wrong python???

you can try ln -s python2.6 to default python, and then modify the yum script to python2.4.
--


On Thu, Dec 30, 2010 at 10:53 PM, ozgur yilmaz <yelbuke@gmail.com> wrote:
I have Centos, and it comes with python2.4(sorry, not 2.5). I installed python2.6 and django is under:

/usr/lib/python2.4/site-packages/django
/usr/lib/python2.6/site-packages/django

i defined alias in bash_profile, so when i give "python" command from shell, python2.6 works...

2010/12/30 Robbington <robbington@hotmail.co.uk>

Why/how have you two versions of Python installed?

Where is Django installed?

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


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

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

Re: django using wrong python???

I have Centos, and it comes with python2.4(sorry, not 2.5). I installed python2.6 and django is under:

/usr/lib/python2.4/site-packages/django
/usr/lib/python2.6/site-packages/django

i defined alias in bash_profile, so when i give "python" command from shell, python2.6 works...

2010/12/30 Robbington <robbington@hotmail.co.uk>
Why/how have you two versions of Python installed?

Where is Django installed?

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


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

Re: django using wrong python???

Why/how have you two versions of Python installed?

Where is Django installed?

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

django using wrong python???

Hi,

I'm on centos and have two pythons 2.5 and 2.6.

I tried in models.py:

from fractions import Fraction

and got the error: No module named fractions

But when i use shell and type "from fractions import Fraction" it's OK, it uses python2.6 installation.

How can i modify django installation to use python2.6???

I already defined alias in bash_profile for python2.6, but it seems it doesnt work for django.

Thanks,

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

Re: django test framework with no models.py

On 12/27/2010 09:58 AM, Henrik Genssen wrote:
> Hi,
>
> I wanted to write a test for an app, that does not have a models.py itself.
> Doing so I get:
> django.core.exceptions.ImproperlyConfigured: App with label service could not be found
>
> if I create a models.py with just a "pass" in it everything works as expected.
> I use Django 1.1

I worked around the same problem (in 1.2, at least) with just an empty
models.py file—I didn't even need the "pass".

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

Re: django and eclipse

You have to set up the run environment. Make sure on run manage.py and
the parameters are runserver x.x.x.x:000 where x.x.x.x is the server
and :000 is the port you want to run from. After that it should not
ask anything and run off your settings.

On Dec 29, 7:38 pm, Emmanuel Mayssat <emays...@gmail.com> wrote:
> I installed the pydev plugin in eclipse.
> I configured it.
> Imported my django project and it almost works.
>
> Is any one of you using django/eclipse?
>
> Well, all goes well until I start the django development server.
> 1/ how can I change the default port, it is running on ?
> 2/ My sqlite db files is regenerated by the runserver (I had never
> seen  that!) in a different directory (at the project level).
> If I symlink the 2 db files, it works as expected.
> Any clue?
>
> BTW, I noticed that when creating a django project in eclipse, it ask
> for the path to the db files (when using sqlite3)
> It is configured to point to the right location, but runserver doesn't get that.
> So what is this db file path used for ? (settings.py is created but
> not even configured...)
>
> --
> Emmanuel Mayssat

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

Re: database migration

Hallöchen!

Torsten Bronger writes:

> Hallöchen!
>
> Michael P. Soulier writes:
>
>> On 29/12/10 Torsten Bronger said:
>>
>>> I don't recommend that. If the database exceeds a certain size
>>> (and "certain" is MBs, not GBs), this simply fails.
>>
>> Is there a bug report for this issue? I find that very
>> disappointing.
>
> [...]

Sorry, an addition for Adblock occupied my clipboard. The real link
is http://code.djangoproject.com/ticket/5423

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: torsten.bronger@jabber.rwth-aachen.de
or http://bronger-jmp.appspot.com

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

Re: database migration

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 30/12/10 13:17, Torsten Bronger wrote:
>> Is there a bug report for this issue? I find that very
>> > disappointing.
> http://1.2.3.12/bmi/stc.celeb.gate.cc/banner/pi/0120.gif

What i found disappointing is sending a NSFW image to a django list
without a note.

Thank your for my first post-xmas first boss talk :D
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJNHIMpAAoJEAWOKfEESaOw7rEQAI8AUH7EeF51ZocVJJOzi5sa
gavH1N9MesBtEiraN1t+sQyXy7m/wzlO4qRbhDkb56V8LrS2UME6kse7OY6TmmLV
Qkmqfmg4s0RdVQnWaOPEQax0oqb19kwjetr2HSleVV/uWB6DV5xiDVqojtuP7s9x
Tj3PJs8V1kUBpK5twHkRFSJRFqv5Yy/KRNiOdLXrRpenqivbqVHb8jwLPtZFN4Cc
FSpOljQ/A08jI644vhfUCOQJuI40IRaRQjVINolRhqmR5i0nI7ZOEz/rIgksgiIq
m+T//vuXKfJJ7QxMw5zl8ERpqwl67uebkKEeeFgKzIW8Y1v39OWNcK0TkJlI3bgW
MHicwZ+TNkmzNwINPDbnuNiBmZdLE6Ypg+Cng5na4j7IKr/aiyRcRAQl2MWR67XK
hS+MPCmEZMyPFVyM0cnKz3DIMhVZWXVyCu6rf1iR4yyI/5FAdYLxAwsRKGeh9Llp
BLM4fozVrkx6aUnEaAgLpaOLTSD41M3lQiIlT/NtXM3zqWUWWFtYZT2/m5XwWins
yaeFSHiYobmAuYz6Z6uwLLsejpsv/TTLpuxi5vyOWAVZd1UBdTnLtYEtX5+twrur
/4qHgxs8S7y3XnDvc/Hei1sDq9QA9OLs+UXD8cOHqtFrDoS22g7rxzQnU2dSsal8
GdMSrAYBtIjeTnqJSiLS
=tOGZ
-----END PGP SIGNATURE-----

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