more info to the user

2012-08-14 Thread heni yemun
Hi,
I have set up a UserProfile using the technique outlined in the standard. 
What i can do give values to the fields in the user profile model. So if 
i've a city field in the UserProfile, how can i put the value 'Asmara' to 
it and save it in the database?

Second question is whenever i try to save a field it says '*fieldname*cannot be 
NULL'. What is this? THANK YOU!

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



Re: 'NoneType' object has no attribute 'datetime' bug?

2012-08-14 Thread Peter of the Norse
I had a similar problem in one of my views. It looked like:

from X import y

def my_func():
foo = y.baz()
...
y = foo + bar;

Since I was assigning to y later in the function, “y” represented a local 
variable throughout the function. Somewhere you have “datetime =”, but it might 
be later in the method.

On Jul 14, 2012, at 6:01 AM, dobrysmak wrote:

> Hi guys,
> i have run into this.
> 
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in 
> get_response
>   111. response = callback(request, *callback_args, 
> **callback_kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py" in 
> _wrapped_view
>   20. return view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> _wrapped_view
>   91. response = view_func(request, *args, **kwargs)
> File "/home/user/dev/xyz/coupon/views.py" in enter_game
>   69. Coupon(coupon=coupon, player=player, 
> credicts=credicts).save()
> File "/home/user/dev/xyz/coupon/models.py" in save
>   253. self.coupon.close_coupon()
> File "/home/user/dev/xyz/coupon/models.py" in close_coupon
>   78. current_date = datetime.datetime.now()
> 
> Exception Type: AttributeError at /wejdz-do-gry/49/
> Exception Value: 'NoneType' object has no attribute 'datetime'
> Request information:
> GET: No GET data
> 
> and the cuntion "close_coupon" looks like this
> 
> class Coupon(models.Model):
> .
> 
> .
> .
> end_date= models.DateTimeField(default=None, null=True, blank=True)
> 
> 
> def close_coupon(self):
> 
> current_date = datetime.datetime.now()
> today = datetime.datetime.combine(datetime.date.today(), 
> datetime.time(19,30))
> 
> .
> .
> end_date = current_date
> 
> Don't know if that's a bug. Does anyone know how to deal with this issue? 
> Cheers!

Peter of the Norse
rahmc...@radio1190.org



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



Re: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2012-08-14 Thread Sky
I've having a similar problem here using Django 1.4 and I can't quite figure 
what's wrong. The error reads: Could not import polls.views.index. View does 
not exist in module polls.views.

urls.py

from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView
from polls.models import Poll

Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^$',
ListView.as_view(
queryset = Poll.objects.order_by('-pub_date')[:5],
context_object_name = 'latest_poll_list',
template_name = 'polls/index.html')),
url(r'^(?P\d+)/$',
DetailView.as_view(
model = Poll,
template_name = 'polls/detail.html')),
url(r'^(?P\d+)/results/$',
DetailView.as_view(
model = Poll,
template_name = 'polls/results.html'),
name='poll_results'),
url(r'^(?P\d+)/vote/$', 'polls.views.vote'),
)

urlpatterns = patterns('',
url(r'^polls/', include('polls.urls')),   
url(r'^admin/', include(admin.site.urls)),
)

# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

views.py
# Create your views here.
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext
from polls.models import Choice, Poll

def vote(request, poll_id):
p = get_object_or_404 (Poll, pk = poll_id)
try: 
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
return render_to_response('polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
}, context_instance = RequestContext(request))
else:
selected_choice.votes += 1
selected_choice.save()
return HttpResponseRedirect(reverse('poll_results', args = 
(p.id,)))


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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Carlos Andre
Thanks for all! i'm solving this problem!

2012/8/14 Melvyn Sopacua 

> On 15-8-2012 1:02, Furbee wrote:
>
> > DJANGO_SETTINGS_MODULE is an environment variable that must be set. I
> > believe this is taken care of for you when you create a project using
> > django-admin. You may need to create it manually.
>
> No, the trick is to run the manage.py script from the project's
> directory. This manage.py script is created by django-admin.py
> startproject. I realize you were on the right track, but putting it down
> correctly. The full details are in the manual as linked previously.
>
> From the tips and tricks department:
> You can use a shell (as in zsh/sh/bash/ksh) alias to run that script:
> alias djmanage='python manage.py'
> --
> Melvyn Sopacua
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



'bool' object has no attribute 'render'

2012-08-14 Thread yao ge
When delete a record in admin  raise error :

Request Method: POST
Request URL:http://localhost/admin/tvplays/news/
Django Version: 1.4
Exception Type: AttributeError
Exception Value:
'bool' object has no attribute 'render'
Exception Location: 
E:\Python25\Lib\site-packages\django\template\response.py in rendered_content, 
line 81
Python Executable:  E:\xampp\apache\bin\httpd.exe
Python Version: 2.5.5

in Model.py:

class News(models.Model):
title = models.CharField(max_length=150)
newstype = models.ForeignKey(NewsType)
newssource = models.CharField(null=True,blank=True,max_length=250)
newsurl = models.CharField(null=True,blank=True,max_length=250)
newsdate = models.DateTimeField(auto_now=True, editable = False)
newscontext=HTMLField(verbose_name='news')
rateperson = models.ManyToManyField(Person,null=True, 
blank=True,related_name="news_person")
ratetvplay = 
models.ManyToManyField(Tvplay,null=True,blank=True,related_name="news_tvplay")
edtor = models.ForeignKey(User)
published = models.BooleanField(default=False)

def __unicode__(self):
return self.title

In admin.py:

class NewsAdmin(admin.ModelAdmin):
list_display = ('title','newstype','newsdate',)
search_fields=('title',)
list_filter =('newstype',)   
delete_selected_confirmation_template = True
raw_id_fields = ('rateperson','ratetvplay',)   
admin.site.register(News,NewsAdmin)

When I delete multi record by delete action in django-admin form
Raise error:  'bool' object has no attribute 'render'

Why??




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



Re: New to dj: relational limitations

2012-08-14 Thread Melvyn Sopacua
On 15-8-2012 1:49, Russell Keith-Magee wrote:

>> SERIAL was not mapped to AutoField (all my primary keys have either
>> SERIAL or BIGSERIAL), no AutoField with BigInteger (AFAICS), 
>> referential constraint action was not mapped to
>> ForeignKey.on_delete, ENUM type not supprted (I found a way to
>> create one as custom field), custom types not mapped to their
>> (standard) parent types,
> 
> Most of these limitations are an extension of the way Django views
> the world. In the vanilla Django usage model, you use your Django
> model to generate your SQL tables. The SQL that is exposed is
> therefore focussed on those features that you can expose in a
> meaningful way in Python code. Python doesn't have a concept of an
> enumerated type, so there hasn't been a whole lot of effort focussed
> on that feature.

But django has a choices field attribute. Figuring out the underlying
type of the enum would be the challenge, but it makes a lot of sense to
populate choices with them.

-- 
Melvyn Sopacua

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



Re: New to dj: relational limitations

2012-08-14 Thread Russell Keith-Magee
On Wed, Aug 15, 2012 at 12:48 AM, Axel Rau  wrote:
> Hi,
>
> I'm starting to investigate django while designing a web GUI for an already 
> productive DB.
> 3 applications are currently maintaining the DB contents, one of them is a 
> real-time app (email server), others are periodic background tasks.
> ERM is the central design method
> 
> https://www.chaos1.de/svn-public/repos/network-tools/ERDB/trunk/database/ERD.pdf
> (supplemented by use-case-modelling for the oo code)
> and the implementation is in SQL:2003 (PostgreSQL 9.1):
> 
> https://www.chaos1.de/svn-public/repos/network-tools/ERDB/trunk/database/erdb.sql
> 
> https://www.chaos1.de/svn-public/repos/network-tools/ERDB/trunk/database/dd.sql
>
> I was impressed, how well inspectdb turned my schema into classes (100% 
> automatic) after working around the missing schema concept in dj (I have a 
> operational and a development DB both with a set of identical schemas). (I 
> learned that schemas will be supported in 1.5).>

By way of managing your expectations -- schemas *may* be supported in
1.5. Someone is working on them, but that doesn't mean they are
guaranteed to be in the 1.5 release.

> The next step (after working through the tutorial) was to make some of my 
> tables accessible in the admin site, which exposed some limitations of 
> inspectdb (the SQL standard describes how to get meta data from the 
> INFORMATION SCHEMA, which all RDBMS must implement, in an vendor independent 
> manner):

This SQL "Standard" of which you speak… do you know of anyone that
implements it? :-)

Seriously -- I've spent many years working on Django, and a good chunk
of that time has been spent finding ways to work around the
differences in the SQL "standard" implementations provided by SQLite,
MySQL and PostgreSQL. The fact that the SQL standard says something
should be provided, and should be provided in a particular way, is in
no way a guarantee that an implementation actually provides that
feature in the way described.

> SERIAL was not mapped to AutoField (all my primary keys have either SERIAL or 
> BIGSERIAL),
> no AutoField with BigInteger (AFAICS),
> referential constraint action was not mapped to ForeignKey.on_delete,
> ENUM type not supprted (I found a way to create one as custom field),
> custom types not mapped to their (standard) parent types,

Most of these limitations are an extension of the way Django views the
world. In the vanilla Django usage model, you use your Django model to
generate your SQL tables. The SQL that is exposed is therefore
focussed on those features that you can expose in a meaningful way in
Python code. Python doesn't have a concept of an enumerated type, so
there hasn't been a whole lot of effort focussed on that feature.

If you're coming from a "database first" world, you're going to have a
bit of a bumpy road, mostly due to the leaky abstractions between the
way Django represents models, and the pre-existing expectations of
your database tables.

> but the real stopper was that dj does not support NULL on TEXT columns.

Incorrect. At a model level, you can certainly store NULL in a
TextField column (or any other char-like column for that matter).
However, Django's form tools may not make this easy from a user
interface point of view. For example, in order for the admin to allow
for an "empty" input, you'll need to set the field as 'blank=True',
which means the NULL will be converted to a blank string.

This could be addressed at the form level, but it will involve a
little bit of tinkering (specifically, overriding the to_python method
on django.forms.CharField). However, once you've written a CharField
that treats blanks the way you want, you just need to remember to use
your own form library rather than Django's defaults.

So - the fact that you have a database with a bunch of pre-existing
expectations is going to cause you some difficulties, but they
shouldn't be impossible to overcome. You are, however, going to be
spending some quality time overriding defaults, and getting to know
Django's internals pretty well. :-)

Yours,
Russ Magee %-)

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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Melvyn Sopacua
On 15-8-2012 1:02, Furbee wrote:

> DJANGO_SETTINGS_MODULE is an environment variable that must be set. I
> believe this is taken care of for you when you create a project using
> django-admin. You may need to create it manually.

No, the trick is to run the manage.py script from the project's
directory. This manage.py script is created by django-admin.py
startproject. I realize you were on the right track, but putting it down
correctly. The full details are in the manual as linked previously.

>From the tips and tricks department:
You can use a shell (as in zsh/sh/bash/ksh) alias to run that script:
alias djmanage='python manage.py'
-- 
Melvyn Sopacua

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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Furbee
DJANGO_SETTINGS_MODULE is an environment variable that must be set. I
believe this is taken care of for you when you create a project using
django-admin. You may need to create it manually. Without that
environmental variable set, the Django shell won't open. As Jirka said,
please review the tutorials and documentation, especially Tutorial 1-4.
This will get you on your way to installing and using Django via the web,
and shell.

Furbee

On Tue, Aug 14, 2012 at 2:50 PM, Jirka Vejrazka wrote:

> > right, I was being very brief in my description!
> > But it is the following:
> > I want to insert data into the database from the shell, django shell, but
> > the result is always that you can not import the settings because the va
> > riavel DJANGO_SETTINGS_MODULE is not set
>
> Did you read my previous email and checked the documentation at all?
> It's all described there:
>
> https://docs.djangoproject.com/en/1.4/faq/usage/
> https://docs.djangoproject.com/en/1.4/ref/django-admin/
>
> If you read this and *still* have a problem, come back and ask a
> specific question with what you already tried (e.g. do you have a
> database defined and created?) and what specific error(s) are you
> experiencing.
>
>   HTH
>
>  Jirka
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Jirka Vejrazka
> right, I was being very brief in my description!
> But it is the following:
> I want to insert data into the database from the shell, django shell, but
> the result is always that you can not import the settings because the va
> riavel DJANGO_SETTINGS_MODULE is not set

Did you read my previous email and checked the documentation at all?
It's all described there:

https://docs.djangoproject.com/en/1.4/faq/usage/
https://docs.djangoproject.com/en/1.4/ref/django-admin/

If you read this and *still* have a problem, come back and ask a
specific question with what you already tried (e.g. do you have a
database defined and created?) and what specific error(s) are you
experiencing.

  HTH

 Jirka

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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Carlos Andre
right, I was being very brief in my description!
But it is the following:
I want to insert data into the database from the shell, django shell, but
the result is always that you can not import the settings because the va
riavel DJANGO_SETTINGS_MODULE is not set


2012/8/14 

> **
> It's always good to copy the error message you're getting. It seems that
> you try to run "python manage.py shell" ang getting an error that
> DJANGO_SETTINGS_MODULE is not set.
>
> Please follow at least a bit of the tutorial on docs.djangoproject.comwhich 
> will teach you how to set this variable properly.
>
> HTH
>
> Jirka
> --
> *From: * Carlos Andre 
> *Sender: * django-users@googlegroups.com
> *Date: *Tue, 14 Aug 2012 15:48:18 -0300
> *To: *
> *ReplyTo: * django-users@googlegroups.com
> *Subject: *Re: DJANGO_DEFAULT_SETTINGS
>
> Ok, the  quest is relative  a how that work with forms of data in
> settins.py!
> not relative to date time.
> in  real i'm want insert data in databases athroughl shell  and thi error
> is show!
>
> 2012/8/14 Satinderpal Singh 
>
>> On Tue, Aug 14, 2012 at 9:42 PM, Carlos Andre  wrote:
>> > hi developers i'm with a ptoblem in this date. How work?
>> > thanks!
>> Please clear your question, if you are looking for date and time at
>> your page please follow the following tutorial:
>> http://www.djangobook.com/en/2.0/chapter03/
>>
>> --
>> Satinderpal Singh
>> http://satindergoraya.blogspot.in/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread jirka . vejrazka
It's always good to copy the error message you're getting. It seems that you 
try to run "python manage.py shell" ang getting an error that 
DJANGO_SETTINGS_MODULE is not set.

Please follow at least a bit of the tutorial on docs.djangoproject.com which 
will teach you how to set this variable properly.

 HTH

Jirka
-Original Message-
From: Carlos Andre 
Sender: django-users@googlegroups.com
Date: Tue, 14 Aug 2012 15:48:18 
To: 
Reply-To: django-users@googlegroups.com
Subject: Re: DJANGO_DEFAULT_SETTINGS

Ok, the  quest is relative  a how that work with forms of data in
settins.py!
not relative to date time.
in  real i'm want insert data in databases athroughl shell  and thi error
is show!

2012/8/14 Satinderpal Singh 

> On Tue, Aug 14, 2012 at 9:42 PM, Carlos Andre  wrote:
> > hi developers i'm with a ptoblem in this date. How work?
> > thanks!
> Please clear your question, if you are looking for date and time at
> your page please follow the following tutorial:
> http://www.djangobook.com/en/2.0/chapter03/
>
> --
> Satinderpal Singh
> http://satindergoraya.blogspot.in/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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


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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Kurtis Mullins
Hey Carlos,

Unfortunately I'm having a difficult time understanding your English. I do
apologize!
If I understand correctly, it sounds like you want to insert some data
using the shell and you're running into an error. Can you show us the error
you are getting?


On Tue, Aug 14, 2012 at 2:48 PM, Carlos Andre  wrote:

> Ok, the  quest is relative  a how that work with forms of data in
> settins.py!
> not relative to date time.
> in  real i'm want insert data in databases athroughl shell  and thi error
> is show!
>
>
> 2012/8/14 Satinderpal Singh 
>
>> On Tue, Aug 14, 2012 at 9:42 PM, Carlos Andre  wrote:
>> > hi developers i'm with a ptoblem in this date. How work?
>> > thanks!
>> Please clear your question, if you are looking for date and time at
>> your page please follow the following tutorial:
>> http://www.djangobook.com/en/2.0/chapter03/
>>
>> --
>> Satinderpal Singh
>> http://satindergoraya.blogspot.in/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Carlos Andre
Ok, the  quest is relative  a how that work with forms of data in
settins.py!
not relative to date time.
in  real i'm want insert data in databases athroughl shell  and thi error
is show!

2012/8/14 Satinderpal Singh 

> On Tue, Aug 14, 2012 at 9:42 PM, Carlos Andre  wrote:
> > hi developers i'm with a ptoblem in this date. How work?
> > thanks!
> Please clear your question, if you are looking for date and time at
> your page please follow the following tutorial:
> http://www.djangobook.com/en/2.0/chapter03/
>
> --
> Satinderpal Singh
> http://satindergoraya.blogspot.in/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Using Forms without Request Data

2012-08-14 Thread Kurtis Mullins
Thanks a lot! I was curious on how to grab the raw POST data but didn't
spend any time looking into it. This will definitely come in handy.

On Tue, Aug 14, 2012 at 12:35 PM, S.Prymak  wrote:

> Here is the code snippet about JSON validation I use in my application:
>
> try:
> json_data = json.loads(request.raw_post_data)
> except Exception, e:
> return HttpResponseBadRequest()
>
> form = forms.AttributeForm(json_data)
> if not form.is_valid():
> return render_to_json_response({
> 'success': False,
> 'errors': [(k, unicode(v[0])) for k, v in
> form.errors.items()],
> 'level': messages.DEFAULT_TAGS[messages.ERROR],
> 'data': form.data,
> })
>
> name = form.cleaned_data['name']
> ...
>
> This works for me very well. Hope it will work for you too.
>
> вторник, 14 августа 2012 г., 0:14:14 UTC+3 пользователь Kurtis написал:
>
>> On Mon, Aug 13, 2012 at 5:10 PM, Melvyn Sopacua wrote:
>>>
>>>
>>> data argument to a form instance must be a dictionary-like object. Other
>>> then that there's no requirements.
>>> I'm kinda curious why you need a form if you're using a non-html data
>>> format.
>>>
>>>
>> I figured it out :) It was as simple as creating a QueryDict and sending
>> it in. Thanks for the suggestions!
>>
>> The reason I'm using a Form (specifically a ModelForm) is to make my job
>> of setting up the Validation a *whole* lot easier.
>>
>> Here's the code I basically used. Maybe there's a better way to do it?
>>
>> json_object = json.loads(request.POST['some_**json_field'])
>> q = QueryDict('')
>> q = q.copy()
>> q.update(json_object)
>> form = MyModelForm(q)
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/ZOaSBbu8xYQJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Satinderpal Singh
On Tue, Aug 14, 2012 at 9:42 PM, Carlos Andre  wrote:
> hi developers i'm with a ptoblem in this date. How work?
> thanks!
Please clear your question, if you are looking for date and time at
your page please follow the following tutorial:
http://www.djangobook.com/en/2.0/chapter03/

-- 
Satinderpal Singh
http://satindergoraya.blogspot.in/

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



New to dj: relational limitations

2012-08-14 Thread Axel Rau
Hi,

I'm starting to investigate django while designing a web GUI for an already 
productive DB.
3 applications are currently maintaining the DB contents, one of them is a 
real-time app (email server), others are periodic background tasks.
ERM is the central design method

https://www.chaos1.de/svn-public/repos/network-tools/ERDB/trunk/database/ERD.pdf
(supplemented by use-case-modelling for the oo code)
and the implementation is in SQL:2003 (PostgreSQL 9.1):

https://www.chaos1.de/svn-public/repos/network-tools/ERDB/trunk/database/erdb.sql

https://www.chaos1.de/svn-public/repos/network-tools/ERDB/trunk/database/dd.sql

I was impressed, how well inspectdb turned my schema into classes (100% 
automatic) after working around the missing schema concept in dj (I have a 
operational and a development DB both with a set of identical schemas). (I 
learned that schemas will be supported in 1.5).

The next step (after working through the tutorial) was to make some of my 
tables accessible in the admin site, which exposed some limitations of 
inspectdb (the SQL standard describes how to get meta data from the INFORMATION 
SCHEMA, which all RDBMS must implement, in an vendor independent manner):
SERIAL was not mapped to AutoField (all my primary keys have either SERIAL or 
BIGSERIAL),
no AutoField with BigInteger (AFAICS),
referential constraint action was not mapped to ForeignKey.on_delete,
ENUM type not supprted (I found a way to create one as custom field),
custom types not mapped to their (standard) parent types,
but the real stopper was that dj does not support NULL on TEXT columns.

Mapping empty strings in the GUI to NULLs in the DB and vice versa would be 
acceptable (as done with Oracle), but simply not allowing NULLs at all is a 
serious breaking with relational technology. 

Some examples:

If I have defined a DEFAULT on a columns, it will be used by the backend on 
NULL but not on empty string.

Similar with CONSTRAINTs and RULEs or DOMAINs with CONSTRAINTs (see dd.sql 
above): They all fail with empty string on NULLable field but not with NULL, 
like:
CREATE DOMAIN dd.secondLevelDomain
AS CHARACTER VARYING(75)-- '64+"."+10'
CHECK(VALUE ~ E'^[a-z][-a-z0-9]+\.[a-z]{2,10}$');

So this would require to rewrite lots of code, stored procedures and schema 
definition, which is not acceptable.

Questions:

Is a work-around available?
Can one be created?
Perhaps a custom subclass of backends.postgresql_psycopg2.* ?
 
Thanks vor listening,
Axel
---
PGP-Key:29E99DD6  ☀ +49 151 2300 9283  ☀ computing @ chaos claudius

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



Re: Using Forms without Request Data

2012-08-14 Thread S.Prymak
Here is the code snippet about JSON validation I use in my application:

try:
json_data = json.loads(request.raw_post_data)
except Exception, e:
return HttpResponseBadRequest()

form = forms.AttributeForm(json_data)
if not form.is_valid():
return render_to_json_response({
'success': False,
'errors': [(k, unicode(v[0])) for k, v in 
form.errors.items()],
'level': messages.DEFAULT_TAGS[messages.ERROR],
'data': form.data,
})

name = form.cleaned_data['name']
...

This works for me very well. Hope it will work for you too.

вторник, 14 августа 2012 г., 0:14:14 UTC+3 пользователь Kurtis написал:
>
> On Mon, Aug 13, 2012 at 5:10 PM, Melvyn Sopacua 
>  > wrote:
>>
>>  
>> data argument to a form instance must be a dictionary-like object. Other
>> then that there's no requirements.
>> I'm kinda curious why you need a form if you're using a non-html data
>> format.
>>
>>
> I figured it out :) It was as simple as creating a QueryDict and sending 
> it in. Thanks for the suggestions!
>
> The reason I'm using a Form (specifically a ModelForm) is to make my job 
> of setting up the Validation a *whole* lot easier.
>
> Here's the code I basically used. Maybe there's a better way to do it?
>
> json_object = json.loads(request.POST['some_json_field'])
> q = QueryDict('')
> q = q.copy()
> q.update(json_object)
> form = MyModelForm(q)
>

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



DJANGO_DEFAULT_SETTINGS

2012-08-14 Thread Carlos Andre
hi developers i'm with a ptoblem in this date. How work?
thanks!

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



(demo included) Switching Languages still relies on LANGUAGE_CODE for forms

2012-08-14 Thread Houmie
Hello,

I have created a small demo to show the problem. Please open the demo here: 
http://sandbox.chasebot.com/

When you click on British English, you can see how both the date- and Time 
format change.

Now if you click on Add, you will see how both date and time are 
pre-populated for you.  However they still carry the American date format, 
instead of the British language selection.

The only way to fix that was to change LANGUAGE_CODE = 'en-us' to 
LANGUAGE_CODE = 'en-gb' in settings.py. 
This approach would be obviously useless.

I have created formats.py to override the 'en' and 'en_GB' so I am clueless 
what else I could do.

Please be so kind and download my demo (22 kb) from my dropbox: 
https://dl.dropbox.com/u/4430/Sandbox.zip
All you have to do is to edit settings.py and adjust the path to sqlite.db 
to your path.

Have I overlooked something or is this a Django bug?

Many Thanks for your help,
Houman

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



Re: NoReverseMatch Error

2012-08-14 Thread Serge G. Spaolonzi
Try removing the quotes from 'polls.views.vote':



Regards

-- 
Serge G. Spaolonzi
Cobalys Systems
http://www.cobalys.com


On Mon, Aug 13, 2012 at 11:46 PM, Syam Palakurthy
wrote:

> Hi - I could not find any explanation that fixed the problem, until I ran
> across this person's abridged Django tutorial:
> http://tony.abou-assaleh.net/web-development/stripped-down-django-tutorial
>
> It's basically a line in the details template, which should be:
>
> 
>
>
> Instead of:
>
> 
>
>
> I'm not sure why this fixed the issue, but it did for me.  I'd love an
> explanation if anyone has one.
>
> Thanks,
> Syam
>
> On Thursday, June 9, 2011 12:28:30 AM UTC-7, bh.hoseini wrote:
>>
>> hi there,
>> this is my views.py that doesn't have any problem:
>>
>> from django.shortcuts import get_object_or_404, render_to_response
>> from django.core.urlresolvers import reverse
>> .
>> .
>> .
>> return HttpResponseRedirect(reverse('**polls.views.results',
>> args=(p.id,)))
>>
>> def results(request, poll_id):
>> p = get_object_or_404(Poll, pk=poll_id)
>> return render_to_response('(...)/**polls/results.html', {'poll': p})
>> --**--**
>> --**--
>> but when i edit my urls.py like this:
>>
>> #...
>> urlpatterns = patterns('',
>> (r'^$',
>> ListView.as_view(
>> queryset=Poll.objects.order_**by('-pub_date')[:5],
>> context_object_name='latest_**poll_list',
>> template_name='(...)polls/**index.html')),
>> (r'^(?P\d+)/$',
>> DetailView.as_view(
>> model=Poll,
>> template_name='(...)polls/**detail.html')),
>> url(r'^(?P\d+)/results/$',
>> DetailView.as_view(
>> model=Poll,
>> template_name='(...)polls/**results.html'),
>> name='poll_results'),
>> (r'^(?P\d+)/vote/$', 'polls.views.vote'),
>> --**--**
>> --**
>> and open my browser with the link (http://localhost:8000/polls/**
>> id=1/vote ), I'd face this error:
>> can anybody help please?
>>
>> Reverse for 'polls.views.results' with arguments '(id=1,)' and keyword 
>> arguments '{}' not found.
>>
>> can anybody help?
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/2MW2j_RVlfYJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Hot to use widgets with generic views

2012-08-14 Thread Tomas Neme
well, for starters, you won't magically get "on keyup" behavior by
adding something on your backend, you'll need to use ajax for this,
and, depending on your expected number of elements, it might be better
to send everything and do any filtering on the client side (if you're
handling, say, up to a few thousands of records, and not up to tens of
thousands or more).

In any way, you'll need to give your view some parameter to do the
filtering. For this, I'd recommend passing a ?q=keywords GET argument
to your view, and with that in mind, I link you here:
https://docs.djangoproject.com/en/dev/topics/class-based-views/generic-display/#dynamic-filtering

Just do something like that, but instead of using self.args or
self.kwargs, use self.request.GET for the filtering

--
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



Re: multiple profile

2012-08-14 Thread Tomas Neme
Well, it depends on what you want to do exactly, you could create something
like this:

class UserProfile(models.Model):
common_data

class ClientProfile(UserProfile):
specific_data

class StudentProfile(UserProfile):
specific_data

class TeacherProfile(UserProfile):
specific_data

...

AUTH_PROFILE_MODULE = 'appname.UserProfile'

This would ensure that 3rd party apps that don't know about your
3-user-types system work in your site, but whether you do this, or ignore
AUTH_PROFILE_MODULE, you'll have to set up a specific way of creating the
profiles on user creation. Save signals are your friend here, probably,
and/or the views you use to create the different types of user.

-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



Re: join models on Timestamp field without foreign keys

2012-08-14 Thread Melvyn Sopacua
On 14-8-2012 6:58, Jeff Dickens wrote:

> class Md_model(models.Model):
> Timestamp = 
> models.DateTimeField(auto_now_add=True,unique=True,db_index=True)
> def __unicode__(self):
> return self.Timestamp.strftime('%Y %m %d %H:%M')
> def as_dict(self):
> return(model_to_dict(self))
> class Meta:
> abstract = True
> 
> class md_10_1(Md_model):
> name='md_10_1'
> dataSource = 'http://192.168.0.10/auto/001'
> n1 = models.DecimalField(max_digits=10,decimal_places=3)
> n2 = models.DecimalField(max_digits=10,decimal_places=3)
> n3 = models.DecimalField(max_digits=10,decimal_places=3)
> 
> class md_10_2(Md_model):
> name='md_10_2'
> dataSource = 'http://192.168.0.10/auto/002'
> n4 = models.DecimalField(max_digits=10,decimal_places=3)
> n5 = models.DecimalField(max_digits=10,decimal_places=3)

I'm wondering if this design isn't better:
class DataBatch(models.Model) :
name = models.CharField(max_length=10)
url = models.URLField(max_length=200)
time_stamp = models.DateTimeField(auto_now_add=True, db_index=True)

class DataType(models.Model) :
"""Different data types, n1 through n5 in your example"""
name = models.CharField(max_length=10)

class CollectedData(models.Model) :
batch = models.ForeignKey(DataBatch, related_name='data')
data_type = models.ForeignKey(DataType)
data = models.DecimalField(max_digits=10,decimal_places=3)


> Using a foreign key does't make sense to me since I can't predict that any 
> particular model will be in every query.

If you need your own design, then you can actually set a foreign key to
NULL and use hasattr(Md_model, related_name) to test if the foreign key
is available.

-- 
Melvyn Sopacua

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



Re: Not reading from TEMPLATE_DIRS in settings.py

2012-08-14 Thread Alexis Roda

Al 14/08/12 12:50, En/na madala ha escrit:


So I carried on and started tutorial 3 till I got halfway down and had
to do same thing but no matter what I try can't get Django to recognize
my directories.

Can anyone see where I am going wrong please? thanks in anticipation.


What error are you getting? template not found? please pastebin the 
traceback.




Regards

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



Re: Not reading from TEMPLATE_DIRS in settings.py

2012-08-14 Thread ephan
Have you checked the permissions of the directory and template
files?
run ls -l in the parent directory of the template folder and inside
the folder itself .
madala wrote:
> Have followed tutorial 2 instructions carefully. So far everything has
> worked as described in tutorials but cannot get django to load files from
> my own template directory. Seems a very simple problem.
>
> here's the part of my settings.py:
>
> TEMPLATE_DIRS = (
> '/home/madala/WebsiteCode/templates',
> "/home/madala/Website/templates",
> # Put strings here, like "/home/html/django_templates" or
> "C:/www/django/templates".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> )
>
> So I carried on and started tutorial 3 till I got halfway down and had to
> do same thing but no matter what I try can't get Django to recognize my
> directories.
>
> Can anyone see where I am going wrong please? thanks in anticipation.

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



Re: Django 1.4 pkbdf2 password hashing issue

2012-08-14 Thread José Moreira
Created a new virtualenv, this time based on Python 2.7[.2] , ran the unit 
tests and wasn't able to reproduce the issue.

Terça-feira, 14 de Agosto de 2012 14:36:11 UTC+1, José Moreira escreveu:
>
> I can also reproduce it on a new project.
>
> Terça-feira, 14 de Agosto de 2012 14:22:34 UTC+1, José Moreira escreveu:
>>
>> Hi, i'm test upgrading a 1.1 project to 1.4 and the password hasher is 
>> raising an exception
>>  while generating passwords (on several Django unit tests):
>>
>>
>> ==
>> ERROR: test_pkbdf2 (django.contrib.auth.tests.hashers.TestUtilsHashPass)
>> --
>> Traceback (most recent call last):
>>   File 
>> "/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/tests/hashers.py",
>>  
>> line 33, in test_pkbdf2
>> encoded = make_password('letmein', 'seasalt', 'pbkdf2_sha256')
>>   File 
>> "/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/hashers.py",
>>  
>> line 69, in make_password
>> return hasher.encode(password, salt)
>>   File 
>> "/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/hashers.py",
>>  
>> line 204, in encode
>> hash = pbkdf2(password, salt, iterations, digest=self.digest)
>>   File 
>> "/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/utils/crypto.py",
>>  
>> line 143, in pbkdf2
>> raise OverflowError('dklen too big')
>> OverflowError: dklen too big
>>
>>
>> Any pointers on what could be causing it?
>>
>> - Python 2.5.6 on OSX (Mountain Lion)
>> - $ pip freeze:
>>
>> Django==1.4.1
>> PIL==1.1.7
>> distribute==0.6.27
>> wsgiref==0.1.2
>>
>>
>> ps.: Changing the PASSWORD_HASHERS to use 'SHA1PasswordHasher' (at least) 
>> doesn't raise any issue.
>>
>

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



Re: Django 1.4 pkbdf2 password hashing issue

2012-08-14 Thread José Moreira
I can also reproduce it on a new project.

Terça-feira, 14 de Agosto de 2012 14:22:34 UTC+1, José Moreira escreveu:
>
> Hi, i'm test upgrading a 1.1 project to 1.4 and the password hasher is 
> raising an exception
>  while generating passwords (on several Django unit tests):
>
>
> ==
> ERROR: test_pkbdf2 (django.contrib.auth.tests.hashers.TestUtilsHashPass)
> --
> Traceback (most recent call last):
>   File 
> "/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/tests/hashers.py",
>  
> line 33, in test_pkbdf2
> encoded = make_password('letmein', 'seasalt', 'pbkdf2_sha256')
>   File 
> "/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/hashers.py",
>  
> line 69, in make_password
> return hasher.encode(password, salt)
>   File 
> "/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/hashers.py",
>  
> line 204, in encode
> hash = pbkdf2(password, salt, iterations, digest=self.digest)
>   File 
> "/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/utils/crypto.py",
>  
> line 143, in pbkdf2
> raise OverflowError('dklen too big')
> OverflowError: dklen too big
>
>
> Any pointers on what could be causing it?
>
> - Python 2.5.6 on OSX (Mountain Lion)
> - $ pip freeze:
>
> Django==1.4.1
> PIL==1.1.7
> distribute==0.6.27
> wsgiref==0.1.2
>
>
> ps.: Changing the PASSWORD_HASHERS to use 'SHA1PasswordHasher' (at least) 
> doesn't raise any issue.
>

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



Django 1.4 pkbdf2 password hashing issue

2012-08-14 Thread José Moreira
Hi, i'm test upgrading a 1.1 project to 1.4 and the password hasher is 
raising an exception
 while generating passwords (on several Django unit tests):


==
ERROR: test_pkbdf2 (django.contrib.auth.tests.hashers.TestUtilsHashPass)
--
Traceback (most recent call last):
  File 
"/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/tests/hashers.py",
 
line 33, in test_pkbdf2
encoded = make_password('letmein', 'seasalt', 'pbkdf2_sha256')
  File 
"/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/hashers.py",
 
line 69, in make_password
return hasher.encode(password, salt)
  File 
"/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/contrib/auth/hashers.py",
 
line 204, in encode
hash = pbkdf2(password, salt, iterations, digest=self.digest)
  File 
"/Users/zemanel/.virtualenvs/digpedia/lib/python2.5/site-packages/django/utils/crypto.py",
 
line 143, in pbkdf2
raise OverflowError('dklen too big')
OverflowError: dklen too big


Any pointers on what could be causing it?

- Python 2.5.6 on OSX (Mountain Lion)
- $ pip freeze:

Django==1.4.1
PIL==1.1.7
distribute==0.6.27
wsgiref==0.1.2


ps.: Changing the PASSWORD_HASHERS to use 'SHA1PasswordHasher' (at least) 
doesn't raise any issue.

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



Re: Django: How to get American date format in a form?

2012-08-14 Thread houmie
I found here what I needed: 
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date

There are shortcuts to customize the settings.

Thanks for your kind help Melvyn.

Regards,
Houman


On 13/08/12 21:52, Melvyn Sopacua wrote:

On 13-8-2012 22:41, Melvyn Sopacua wrote:

On 13-8-2012 17:40, houmie wrote:


Its just a bit odd that templates show 11:15 p.m. Slight difference in
the formatting.  Also the dates within templates are defined like Aug
13, 2012.  Doesn't confirm with my definition in formats.py.
Are they stored somewhere else?

No, but you need the localize filter or tag:


Wait, if this is the same data from the model, then you need to change
the DATE_FORMAT. DATE_INPUT_FORMAT is for form fields, since the form
field needs to be able to change it back to a format that python's
datetime.date will understand. DATE_FORMAT is used for plain output.



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



Incorrect string value when running GeoDjango tutorial

2012-08-14 Thread Matias Burak
Hi, I was trying to go through the GeoDjango tutorial and when I try to 
import data with LayerMapping I'm getting the following error:

  Warning: Incorrect string value: '\xC2\x85land...' for column 'name' 
at row 1

I'm using MySQL and my charset and collation are set to latin1 (I also 
tried utf8).

Any help is appreciated.
Matias.

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



Not reading from TEMPLATE_DIRS in settings.py

2012-08-14 Thread madala
Have followed tutorial 2 instructions carefully. So far everything has 
worked as described in tutorials but cannot get django to load files from 
my own template directory. Seems a very simple problem.  

here's the part of my settings.py:

TEMPLATE_DIRS = (
'/home/madala/WebsiteCode/templates',
"/home/madala/Website/templates",
# Put strings here, like "/home/html/django_templates" or 
"C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

So I carried on and started tutorial 3 till I got halfway down and had to 
do same thing but no matter what I try can't get Django to recognize my 
directories.

Can anyone see where I am going wrong please? thanks in anticipation.

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



Hot to use widgets with generic views

2012-08-14 Thread mjd
This is a general question.
 
Im am using generic views to display all objects in a model.  This is 
working great.
However, i want to add text field widget to filter the objects onkeyup.  
That is, I want the text field to re-render the generic view after applying 
the text filter in the queryset used in the generic view. 
 
Can I use widgets with generic views?
If not do I simply implement the text input widget in html?

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



join models on Timestamp field without foreign keys

2012-08-14 Thread Jeff Dickens
Hi all.  I have a number of models, each of which is based on an abstract 
class that includes a Timestamp field.  The model definitions look like 
this:

class Md_model(models.Model):
Timestamp = 
models.DateTimeField(auto_now_add=True,unique=True,db_index=True)
def __unicode__(self):
return self.Timestamp.strftime('%Y %m %d %H:%M')
def as_dict(self):
return(model_to_dict(self))
class Meta:
abstract = True

class md_10_1(Md_model):
name='md_10_1'
dataSource = 'http://192.168.0.10/auto/001'
n1 = models.DecimalField(max_digits=10,decimal_places=3)
n2 = models.DecimalField(max_digits=10,decimal_places=3)
n3 = models.DecimalField(max_digits=10,decimal_places=3)

class md_10_2(Md_model):
name='md_10_2'
dataSource = 'http://192.168.0.10/auto/002'
n4 = models.DecimalField(max_digits=10,decimal_places=3)
n5 = models.DecimalField(max_digits=10,decimal_places=3)


What I want to do is join them all (actually some programatically defined 
subset of them) into a single query set or some other data structure that I 
can pass into the template.  This set would have only one Timestamp field, 
and all of the other fields from all of the other models that are to be 
joined.  She thre result would have Timestamp, n1, n2, n3, n4, n5 in the 
example above,

Using a foreign key does't make sense to me since I can't predict that any 
particular model will be in every query.

I think that what I need to do is iterate in parallel over three or more 
iterables and merge them, but I don't know how.


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



Re: invoking a funcion or module as root

2012-08-14 Thread Jirka Vejrazka
Hi there,

   you definitely don't want to allow apache to setuid() to root as
you've pointed out. You have a few options, probably the easiest one
is to write a pair of scripts for each task you want your application
to perform with root privileges.

  - the first script will only contain "sudo "
  - the second script should contain the necessary step(s) that need
to be performed with root privileges. It should be simple to minimize
chances for security issues

  Then you'd configure your sudoers file to allow apache process to
call the "second script" *including the right set of parameters* (if
applicable) with sudo permissions.

  You'd then call your "first script" using subprocess() call from
your views.py (or whereever appropriate).

  (you could technically bypass the whole "first script", but it'll
greatly improve readability if you do it this way, no one will have to
read your python code to match it to your sudoers file if problems
occur).

  Even better solution would be fixing your security model, having a
web application perform high-privileged tasks on a system seems flawed
in 99% of cases I can think of, but maybe you have a good reason why
you need it that way.

  HTH

Jirka

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



invoking a funcion or module as root

2012-08-14 Thread Blaxton
Hi

I have setup Django with wsgi and Apache on Linux and all is good,
but the application that I am building should be able to modify
Linux files which are only allowed by root.

so, I have created a function named myfunc in a module named mymodule.py
and has invoked the function in my application's views.py.

now , How can i invoke mymodule.py as root, or is there any way to invoke
only myfunc as root ?

I already setup sudo , and was able to create directory as root with mkdir 
command
but what about python methods such as open(), how can I open( ) a file as root 

while funciton is being invoked as apache user ? tried adding mymodule.py and 
python
to a list of commands in suduers file , but still there is a problem with 
creating the file. 


even , os.setuid() won't work, because function is being invoked as apache user.

thought about setting setuid on python executable, but setuid is not working on 
scripts and have to write
a program in C or C++ and make it setuid and then invoke it through Django and 
python
but don't want to go that way to keep every thing in Python language.

the main question is "how to invoke a python function or module as root from 
view"
but I am open for any better solution.

Thanks

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



Re: calling perl script from HTML on submit button

2012-08-14 Thread Joris
On Tuesday, August 14, 2012 7:15:45 AM UTC+2, Pervez Mulla wrote:
>
> Thank you for your time and concern,
>
> Actually the entire back-end is in perl so, Am using Django for front-end. 
> So am asking is there any why to call perl objects in python .
>

You can always use subprocess() to run perl scripts, but I guess that is as 
far as it goes 

JB

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