Re: passing multiple query sets into a url pattern

2012-02-19 Thread Alfredo Alessandrini
Hi Stanwn,

try this:

def get_keyword():
   return Keyword.objects.all()

UserProfile_info = {
"queryset" : UserProfile.objects.all(),
"extra_context" : {"keyword_list" : get_keyword }
}


Now you can use the variable {{ keyword_list }} to populate the template.



Alfredo


2012/2/19 Stanwin Siow 

> Hi Alfredo,
>
> My apologies for not making my question clear.
>
> I want to pass two different querysets into the url pattern. Is it
> possible?
>
> Best Regards,
>
> Stanwin Siow
>
>
>
> On Feb 19, 2012, at 2:01 AM, Alfredo Alessandrini wrote:
>
> Hi,
>
> I'm not sure that I've understand your question:
>
> url(r'^profile/(?P\d+)/(?P\d+)$', ..)
>
> and now you can use the variable var_1 and var_2 in your function.
>
>
> Alfredo
>
>
>
> 2012/2/18 Stanwin Siow 
>
>> Hello,
>>
>> I want to find out if there is anyway to pass two querysets into a url
>> pattern.
>>
>> i have this url pattern at the moment.
>>
>> UserProfile_info = {
>> "queryset" : UserProfile.objects.all(),
>> "extra_context" : {"keyword_list" : Keyword.objects.all}
>> }
>>
>> url(r'^profile/$', list_detail.object_list, UserProfile_info),
>>
>>
>> I understand from http://www.djangobook.com/en/1.0/chapter09/ that the
>> extra_context field is to defind another query set.
>>
>> in my Userprofile.html i have the following code:
>>
>> {% for userprofile in object_list %}
>> {% if userprofile.username = user.username %}
>>
>> that will give me the list of items in userprofile table in the database.
>>
>> Is there a way to include the list of items from the keyword table as
>> well?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Best Regards,
>>
>> Stanwin Siow
>>
>>
>>
>>
>> --
>> 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: passing multiple query sets into a url pattern

2012-02-18 Thread Alfredo Alessandrini
Hi,

I'm not sure that I've understand your question:

url(r'^profile/(?P\d+)/(?P\d+)$', ..)

and now you can use the variable var_1 and var_2 in your function.


Alfredo



2012/2/18 Stanwin Siow 

> Hello,
>
> I want to find out if there is anyway to pass two querysets into a url
> pattern.
>
> i have this url pattern at the moment.
>
> UserProfile_info = {
> "queryset" : UserProfile.objects.all(),
> "extra_context" : {"keyword_list" : Keyword.objects.all}
> }
>
> url(r'^profile/$', list_detail.object_list, UserProfile_info),
>
>
> I understand from http://www.djangobook.com/en/1.0/chapter09/ that the
> extra_context field is to defind another query set.
>
> in my Userprofile.html i have the following code:
>
> {% for userprofile in object_list %}
> {% if userprofile.username = user.username %}
>
> that will give me the list of items in userprofile table in the database.
>
> Is there a way to include the list of items from the keyword table as well?
>
>
>
>
>
>
>
>
>
>
> Best Regards,
>
> Stanwin Siow
>
>
>
>  --
> 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: ImportError: No module named profiles

2011-11-10 Thread Alfredo Alessandrini
#!/home/alfredo/mysite_env/bin/python
import sys, os
import imaplib
from django.contrib.auth.models import User



popserver = 'pop.gmail.com'
user = 'u...@gmail.com'
password = '---'


def CheckEmail(email):
try:
p = User.objects.get(email = email)
if p.email == email:
if p.is_active == 1:
checkemail = 1
elif p.is_active == 0:
checkemail = 2
except User.DoesNotExist:
checkemail = 0
return checkemail



##
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login(user, password)
mail.select("inbox")

typ, mess_email = mail.search(None, 'ALL')

for num in mess_email[0].split():
r, data = mail.fetch(num, '(UID BODY[TEXT])')
body_text = data[0][1].strip().lower().split()
r, data = mail.fetch(num, '(UID BODY[HEADER.FIELDS (FROM)])')
body_from = data[0][1].lstrip('From:
').strip().lower().split()[-1].replace('<','').replace('>','')
CheckEmail(body_from)
print body_from
print body_text

mail.close()
mail.logout()





2011/11/10 nicolas HERSOG :
> Can you show us your script and how you launch it ?
>
> On Wed, Nov 9, 2011 at 9:27 PM, Alfredo Alessandrini 
> wrote:
>>
>> Hi,
>>
>> I'm running a script to make a query with django.
>>
>> I need to run it in crontab.
>>
>> When I run it I get this error:
>>
>> ImportError: No module named profiles
>>
>> I'm using a virtualenv.
>>
>>
>> Thanks,
>>
>> Alfredo
>>
>> --
>> 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: ImportError: No module named profiles

2011-11-10 Thread Alfredo Alessandrini
Hi,

in crontab I put this:

DJANGO_SETTINGS_MODULE=mysite.settings

0 4 * * * python /path/to/maintenance/script.py


The script is like this:

#!/usr/bin/env(path to virtualenv folder) python

some standard query



Thanks,

Alfredo




2011/11/10 nicolas HERSOG :
> Can you show us your script and how you launch it ?
>
> On Wed, Nov 9, 2011 at 9:27 PM, Alfredo Alessandrini 
> wrote:
>>
>> Hi,
>>
>> I'm running a script to make a query with django.
>>
>> I need to run it in crontab.
>>
>> When I run it I get this error:
>>
>> ImportError: No module named profiles
>>
>> I'm using a virtualenv.
>>
>>
>> Thanks,
>>
>> Alfredo
>>
>> --
>> 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.



ImportError: No module named profiles

2011-11-09 Thread Alfredo Alessandrini
Hi,

I'm running a script to make a query with django.

I need to run it in crontab.

When I run it I get this error:

ImportError: No module named profiles

I'm using a virtualenv.


Thanks,

Alfredo

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



update database by phpmyadmin

2011-10-23 Thread Alfredo Alessandrini
Hi,

I'm trying to import a big database in the django project by phpmyadmin.

The import process is successful. The database by phpmyadmin and mysql
admin is ok.

If I try to make some query by python shell it work.

But the problem is that the database isn't showed in the admin panel.
(I've restart the webserver also).

And if I add a row by phpmyadmin the update is showed in the admin
panel (but I can see only the new row...)

Any idea??


thanks,

Alfredo

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



object value distinct for ForeignKey

2011-07-25 Thread Alfredo Alessandrini
Hi,

I've a model testDB with a foreignkey "country" related to another database.

I need to retrieve the unique value of country.common_name.

With this

country_list = testDB.objects.values('country').distinct

I can retrieve the unique value, but only the ID.

In [63]: testDB.objects.values('country').distinct
Out[63]: 

How can I  retrieve the attribute "common_name" of the country object?


thanks in advance,

Alfredo

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



odering User in a form

2010-04-27 Thread Alfredo Alessandrini
Hi,

I've this model:

class Pubblicazioni(models.Model):
anno = models.DateField(blank=True, null=True,default=datetime.date.today)
autori = models.CharField(max_length=500)
titolo = models.CharField(max_length=500)
autori_daf = models.ManyToManyField(User)

I need to ordering  (by the User.last_name) the field 'autori_daf'
when it is displayed at the form generated by

class PubblicazioniForm(ModelForm):
class Meta:
model = Pubblicazioni



Thanks,

Alfredo

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



file upload formset

2010-04-16 Thread Alfredo Alessandrini
Hi,

I'm trying to upload a file by a formset.


model.py:
---
class Person(models.Model):
user = models.ForeignKey(User)
course = models.TextField(blank=True, null=True)
project = models.TextField(blank=True, null=True)
CV_ENG = models.FileField(upload_to='upload/CV/', blank=True, null=True)
---


views.py:
---
@login_required
def profile(request):
from mysite.people.models import Person
PersonFormSet = modelformset_factory(Person, exclude=('user',),max_num=1)
user = Person.objects.get(user = request.user.id)
if request.method == 'POST':
formset = PersonFormSet(request.POST, request.FILES,
queryset=Person.objects.filter(user=request.user),)
if formset.is_valid():
formset.save()
return HttpResponseRedirect('/accounts/profile/')
else:
formset =
PersonFormSet(queryset=Person.objects.filter(user=request.user),)
return render_to_response('profile.html', {'formset': formset,
'user': user,})
---


profile.html
---

{{ formset }}


---


If I change 'course' or 'project' it's work. But if I try to upload a
file don't work.  Any suggestion?


Thanks,

Alfredo

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



name in the model

2010-04-15 Thread Alfredo Alessandrini
Hi,

I've this model:

class Persone(models.Model):
   CV = models.TextField()


Can I change the name "CV" when I display it in a formset?


Thanks,

Alfredo

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



formset save

2010-04-14 Thread Alfredo Alessandrini
Hi,

I've this views.py:

I need to save the model of current user. But this don't work. What's wrong?


@login_required
def profilo(request):
from daf.Persone.models import Persone
PersoneFormSet = modelformset_factory(Persone, fields=('curriculum_studi'),)
utente = Persone.objects.get(user = request.user.id)
if request.method == 'POST':
formset = PersoneFormSet(request.POST, request.FILES,
queryset=Persone.objects.filter(user=request.user),)
if formset.is_valid():
formset.save()
return HttpResponseRedirect('/accounts/profile/')
else:
formset =
PersoneFormSet(queryset=Persone.objects.filter(user=request.user),)
return render_to_response('profilo.html', {'formset': formset,
'utente': utente,})

and this template:

{{ formset }}



Regards,

Alfredo

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



Re: WSGIScriptAlias

2010-04-14 Thread Alfredo Alessandrini
ok, now work:

WSGIScriptAlias /test /home/alfreale/.

WSGIScriptAlias / /home/alfreale/.

2010/4/13 Tim Shaffer :
> Try reversing the order. The first alias is probably picking up the /
> test URL. If you specify the test alias first, it should work.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
--
Alfredo Alessandrini, Dr.
PhD
Department of Environment and Forest (DAF)
Unitus - Viterbo
http://www.daf.unitus.it/dendro/
--

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



WSGIScriptAlias

2010-04-13 Thread Alfredo Alessandrini
Hi,

I've a problem with the apache configuration:

I'm trying to set www.example.com/ and www.example.com/test, but if I
try this, work only the first site:

WSGIScriptAlias / /home/alfreale/.

WSGIScriptAlias /test /home/alfreale/.


thanks,

Alfredo

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



save_model admin

2010-04-13 Thread Alfredo Alessandrini
Hi,

I've this model:

class Person(models.Model):
user = models.ForeignKey(User)
courses = models.TextField(blank=True, null=True)
research_statement = models.TextField(blank=True, null=True)
..


I will let to save the form only when the user is making changes its
model (user=request.user).


Thanks,

Alfredo

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



display user.email in a custom model

2010-03-31 Thread Alfredo Alessandrini
Hi,

I've this model:

--
class Person(models.Model):
user = models.ForeignKey(User)


Can I display the user.email or user.first_name in the admin site
administration?

I try this:

---
def __unicode__(self):
return u"%s %s" % (self.user, self.user.first_name)


but don't work.


Thanks,

Alfredo

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



search_fields

2009-10-17 Thread Alfredo Alessandrini

Hi,

I've this admin.py:


from chessemail.GAME.models import Game
from django.contrib import admin

class GameAdmin(admin.ModelAdmin):
list_display = ('id', 'white', 'black', 'time_days_W',
'time_days_B', 'move_game', 'last_move_W', 'last_move_B', 'is_active')
ordering = ["id"]
search_fields  = ['id','white__user__username','black__user__username',]
list_filter = ('is_active',)


admin.site.register(Game,GameAdmin)

---

When I search a string return only the query of 'white__user__username'.

Can I search by ( 'white__user__username' OR 'black__user__username' ) ??

Thanks,

Alfredo

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



access to id of current user on admin

2009-05-18 Thread Alfredo Alessandrini

Hi,

I'm write a model for a post.

Can I access to id of current user on admin site?

I'm trying with:

author = models.ForeignKey(User, default=User.id, blank=True, null=True)

But don' work...

Thanks,

Alfredo

--
from django.db import models
from django.contrib.auth.models import User
from django.forms import ModelForm


class Post(models.Model):
title = models.CharField(max_length=30)
author = models.ForeignKey(User, default=User.id, blank=True, null=True)

-

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



two forms in the same view

2008-12-18 Thread Alfredo Alessandrini

Hi,

can I use two form in the same view function?

 if request.method == 'POST':
form = FORM_1(request.POST)
if form.is_valid():
   .
form = FORM_2(request.POST)
if form.is_valid():
   .

It's possible?

Thanks in advance,

Alfredo

--~--~-~--~~~---~--~~
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 query database

2008-12-14 Thread Alfredo Alessandrini

> Sorry but your question is not clear. Are 'min_rating' and
> 'max_rating' fields of the game object ? If yes:

Yes

It's better:

game_list = game.objects.filter(Q(max_rating__gt = player.rating) &
Q(min_rating__lt = player.rating))

or

game_list = 
game.objects.exclude(min_rating__gt=player.rating).exclude(max_rating__lt=player.rating)

??

Thanks,

Alfredo

--~--~-~--~~~---~--~~
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 query database

2008-12-14 Thread Alfredo Alessandrini

> On Sun, 2008-12-14 at 00:46 +0100, Alfredo Alessandrini wrote:
>> Hi,
>>
>> It's possible call a query with max or min value?:
>>
>> like this:
>>
>> game_list = game.objects.filter(Q(max_rating > player.rating) &
>> Q(min_rating < player.rating))
>
> Not yet. Search the archives of this list for the word "aggregates" to
> see a lot more discussion on this and the plans going forwards.
>
> Regards,
> Malcolm


It's possible by:

game_list = 
game.objects.exclude(min_rating__gt=player.rating).exclude(max_rating__lt=player.rating)



Alfredo

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



remove object from queryset

2008-12-14 Thread Alfredo Alessandrini

Hi,

can I remove an objects from the queryset:

In [138]: from CHALLENGE.models import start_game

In [139]: start_game.objects.all()
Out[139]: [, , ]

In [140]: games = start_game.objects.all()

In [142]: games
Out[142]: [, , ]


can I delete the objects with id = 27, for obtain this:

In [142]: games
Out[142]: [, ]


Thanks,

Alfredo

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



django query database

2008-12-13 Thread Alfredo Alessandrini

Hi,

It's possible call a query with max or min value?:

like this:

game_list = game.objects.filter(Q(max_rating > player.rating) &
Q(min_rating < player.rating))



Thanks in advance,

Alfredo

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



forms.ModelChoiceField selected field

2008-12-10 Thread Alfredo Alessandrini

Hi,

I've this form:

class PlayerForm(forms.Form):
challengeable = forms.BooleanField(required=False)
show_name = forms.BooleanField(required=False)
message_move = forms.BooleanField(required=False)
message_confirm = forms.BooleanField(required=False)
country = forms.ModelChoiceField(queryset=Country.objects.all())


and in the template I use this tag:

{{ form.country }}

Can I show the selected field from the current user?

example:

If the user country is 'ALB', show this in the template:

..
AFG
AHO
ALB
ALG
AND
ANT
..


thanks,

Alfredo

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



template tag

2008-12-05 Thread Alfredo Alessandrini

Hi,

I've this variable in my template: {{ challenger.rating }}

It'a a number...

Can I calculate a sum like this:

 {{ challenger.rating }} + 200   ??

I must write a custom tag?


Alfredo

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



forms.ModelMultipleChoiceField

2008-12-02 Thread Alfredo Alessandrini

Hi,

I've set the player form with:

class PlayerForm(forms.Form):
challengeable = forms.BooleanField(required=False)
show_name = forms.BooleanField(required=False)
country = forms.ModelMultipleChoiceField(queryset=Country.objects.all())

and the template with:




I've a problem to set the field 'country':

  http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ordering by models.ForeignKey

2008-11-30 Thread Alfredo Alessandrini

Hi,

I've this model:

class Player(models.Model):
user = models.ForeignKey(User, blank=True, null=True)
country = models.ForeignKey(Country)

If I try to ordering Player by "user", don' work:

Player.objects.order_by("user")

I want ordering Player by user.username


Alfredo

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



checkbox and BooleanField

2008-11-15 Thread Alfredo Alessandrini

Hi,

I've this template:






And this View:

class MoveGameForm(forms.Form):
resign = forms.BooleanField(required=False)
draw = forms.BooleanField(required=False)
move = forms.BooleanField(required=False)


I'm writing the view, with:



 if form.is_valid():
draw = form.cleaned_data['move']
move = form.cleaned_data['draw']
resign = form.cleaned_data['resign']
if resign == 1:


but (if resign == 1) don't work...

where is the error?


thanks,

Alfredo

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



User.email

2008-10-31 Thread Alfredo Alessandrini

Hi,

I've this model:

from django.contrib.auth.models import User

class Player(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
email = models.EmailField()
user = models.ForeignKey(User, blank=True, null=True)

I try to set the email of the Player with the email of the User:

class Player(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
email = models.EmailField(User.email)
user = models.ForeignKey(User, blank=True, null=True)


but I've this error:

email = models.EmailField(User.email)
AttributeError: type object 'User' has no attribute 'email'

Can I set the Player model with the email that automatically take the
value from the User that I choice:

example:

User: username='tommy' email='[EMAIL PROTECTED]"

Player: if I choice the user=tommy the email" automatically take the
value of the User -> [EMAIL PROTECTED]@gmail.com"



Alfredo

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



ifequal and numbers

2008-10-27 Thread Alfredo Alessandrini

There is a method for write this, without write a loop:

{%  ifequal  apple.number <20  %}
..
{%  endifequal  %}


Alfredo

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



Re: customize auth.users

2008-10-27 Thread Alfredo Alessandrini

How can I change the admin class?

Alfredo

2008/10/27 Erik Allik <[EMAIL PROTECTED]>:
>
> I'd suggest maybe inheriting your custom User admin class from the
> original one and only override stuff you need so you can automatically
> take advantage of future changes in contrib.auth.
>
> Erik
>
>
> On 27.10.2008, at 12:52, Alfredo Alessandrini wrote:
>
>>
>> I've solve whit this:
>>
>> http://wolfram.kriesing.de/blog/index.php/2008/customize-admin-for-user-model
>>
>>
>> Alfredo
>>
>> 2008/10/27 Alfredo Alessandrini <[EMAIL PROTECTED]>:
>>> Can I customize the auth.users list of the site administration? I
>>> need
>>> to display also the active status in the list.
>>>
>>> Thanks,
>>>
>>> Alfredo
>>>
>>
>> >
>
>
> >
>

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



Re: customize auth.users

2008-10-27 Thread Alfredo Alessandrini

I've solve whit this:

http://wolfram.kriesing.de/blog/index.php/2008/customize-admin-for-user-model


Alfredo

2008/10/27 Alfredo Alessandrini <[EMAIL PROTECTED]>:
> Can I customize the auth.users list of the site administration? I need
> to display also the active status in the list.
>
> Thanks,
>
> Alfredo
>

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



customize auth.users

2008-10-27 Thread Alfredo Alessandrini

Can I customize the auth.users list of the site administration? I need
to display also the active status in the list.

Thanks,

Alfredo

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



Re: modelForm

2008-10-14 Thread Alfredo Alessandrini

I've a new error :-) :

 File "./mysite/views.py", line 26, in setup_player
   return render_to_response('player_form.html', {'form': form})

UnboundLocalError: local variable 'form' referenced before assignment


2008/10/14 Daniel Roseman <[EMAIL PROTECTED]>:
>
> On Oct 14, 5:37 pm, "Alfredo Alessandrini" <[EMAIL PROTECTED]>
> wrote:
>> I've setup a form from a model:
>>
>> class PlayerForm(ModelForm):
>> class Meta:
>> model = Player
>>
>> I've setup a view function for save the data inserted in the form:
>>
>> def setup_player(request):
>> if request.method == 'POST':
>> form = PlayerForm(request.POST)
>> if form.is_valid():
>> form.save()
>> return HttpResponseRedirect(form_successfully)
>> else:
>> form = PlayerForm()
>> return render_to_response('player_form.html', {'form': form})
>>
>> But I've this error:
>>
>> ValueError: The view mysite.views.setup_player didn't return an
>> HttpResponse object.
>>
>> why??
>>
>> Thanks in advance,
>>
>> Alfredo
>
> The final line, return render_to_response, is indented so that it
> comes inside the initial if request.method=='POST'. This means that if
> it's not a POST - as it won't be when the user initial requests the
> page - nothing is returned.
>
> The simple solution is to move that final line back four spaces, so it
> is always executed.
> --
> DR.
> >
>

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



Re: modelForm

2008-10-14 Thread Alfredo Alessandrini

from http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index 

-
Using a form in a view

The standard pattern for processing a form in a view looks like this:

def contact(request):
if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
return HttpResponseRedirect('/thanks/') # Redirect after POST
else:
form = ContactForm() # An unbound form

return render_to_response('contact.html', {
'form': form,
})

--

I don't understand where is the difference...


Alfredo

2008/10/14 Steve Holden <[EMAIL PROTECTED]>:
>
> Alfredo Alessandrini wrote:
>> I've setup a form from a model:
>>
>> class PlayerForm(ModelForm):
>> class Meta:
>> model = Player
>>
>> I've setup a view function for save the data inserted in the form:
>>
>> def setup_player(request):
>> if request.method == 'POST':
>> form = PlayerForm(request.POST)
>> if form.is_valid():
>> form.save()
>> return HttpResponseRedirect(form_successfully)
>> else:
>> form = PlayerForm()
>> return render_to_response('player_form.html', {'form': form})
>>
>> But I've this error:
>>
>> ValueError: The view mysite.views.setup_player didn't return an
>> HttpResponse object.
>>
>> why??
>>
> Because you have no action when request.method != "POST", and so the
> view is returning None.
>
> regards
>  Steve
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC  http://www.holdenweb.com/
>
> >
>

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



modelForm

2008-10-14 Thread Alfredo Alessandrini

I've setup a form from a model:

class PlayerForm(ModelForm):
class Meta:
model = Player

I've setup a view function for save the data inserted in the form:

def setup_player(request):
if request.method == 'POST':
form = PlayerForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(form_successfully)
else:
form = PlayerForm()
return render_to_response('player_form.html', {'form': form})

But I've this error:

ValueError: The view mysite.views.setup_player didn't return an
HttpResponse object.

why??


Thanks in advance,

Alfredo

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



Re: static html

2008-10-13 Thread Alfredo Alessandrini

ok...it's work.

but If I want customize the url by url.py?


Alfredo

2008/10/13 Daniel Roseman <[EMAIL PROTECTED]>:
>
> On Oct 13, 12:12 pm, "Alfredo Alessandrini" <[EMAIL PROTECTED]>
> wrote:
>> > First of all, why don't you just point the browser at the URL of the
>> > commands.html file in the first place?
>>
>> at the URL?
>>
>> In urls.py?
>>
>> Alfredo
>
> No, nothing to do with Django at all.
>
> If it's a static HTML file, and it's in your /media folder, why can't
> you just point your browser at /media/whatever.html?
> --
> DR.
> >
>

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



Re: static html

2008-10-13 Thread Alfredo Alessandrini

> First of all, why don't you just point the browser at the URL of the
> commands.html file in the first place?

at the URL?

In urls.py?


Alfredo

>> 2008/10/8 Alfredo Alessandrini <[EMAIL PROTECTED]>:
>>> Hi,
>>>
>>> I'm trying to show a static html page...
>>>
>>> The html page is in the /media folder.
>>>
>>> I've some problem with view funcition:
>>>
>>> def list_commands(request):
>>>   commands = 
>>>   return HttpResponse(commands)
>>>
>>> How can I load the html page?
>>>
>>>
>>> Regards,
>>>
>>> Alfredo
>>>
>>
>> >
>
>
> >
>

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



Re: form fields

2008-10-10 Thread Alfredo Alessandrini

I've changed the model form, but don't work...

class GameForm(ModelForm):
class Meta:
model = Game
time_days_W = forms.CharField(max_length=128, verbose_name="time")
fields = ('white', 'black', 'time_days_W', 'inc_time')


I've this error:

TypeError: __init__() got an unexpected keyword argument 'verbose_name'
failed!


Regards,

Alfredo



2008/10/10 Adrian-Bogdan Andreias <[EMAIL PROTECTED]>:
> You can customize the form template and render each field separately or
> define the label in your model, using verbose_name parameter:
>
> class Game(Model):
> # ...
>     time_days_W = CharField(max_length=128, verbose_name="time")
>
> 2008/10/10 Alfredo Alessandrini <[EMAIL PROTECTED]>
>>
>> Hi,
>>
>> I've create a model form by:
>>
>> class GameForm(ModelForm):
>>class Meta:
>>model = Game
>>fields = ('white', 'black', 'time_days_W', 'inc_time')
>>
>>
>> and the form template:
>>
>> 
>> {{ form.as_p }}
>> 
>>
>>
>> The view function is ok, but I want to change the label of a field.
>>
>> I want to change "time_days_W" with "time".
>>
>> I must customizing the form template for this?
>>
>>
>> Alfredo
>>
>>
>
>
>
> --
> http://jquerybox.com - jQuery forum
>
> >
>

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



form fields

2008-10-10 Thread Alfredo Alessandrini

Hi,

I've create a model form by:

class GameForm(ModelForm):
class Meta:
model = Game
fields = ('white', 'black', 'time_days_W', 'inc_time')


and the form template:


{{ form.as_p }}



The view function is ok, but I want to change the label of a field.

I want to change "time_days_W" with "time".

I must customizing the form template for this?


Alfredo

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



Re: static html

2008-10-08 Thread Alfredo Alessandrini

I've solved it with:


def list_commands(request):
commands = open('home/.../commands.html')
return HttpResponse(commands)
commands.close()


2008/10/8 Alfredo Alessandrini <[EMAIL PROTECTED]>:
> Hi,
>
> I'm trying to show a static html page...
>
> The html page is in the /media folder.
>
> I've some problem with view funcition:
>
> def list_commands(request):
>commands = 
>return HttpResponse(commands)
>
> How can I load the html page?
>
>
> Regards,
>
> Alfredo
>

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



static html

2008-10-08 Thread Alfredo Alessandrini

Hi,

I'm trying to show a static html page...

The html page is in the /media folder.

I've some problem with view funcition:

def list_commands(request):
commands = 
return HttpResponse(commands)

How can I load the html page?


Regards,

Alfredo

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



Re: change a value of database

2008-07-16 Thread Alfredo Alessandrini

solved...


from GAME.models import Game

p = Game.objects.get(id=1)

p.name = '2'

p.save()

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



change a value of database

2008-07-16 Thread Alfredo Alessandrini

I've a simple a question...

How can I update a single value of database??

I've try this:

from GAME.models import Game

Game.objects.filter(id=1)

p.name='2'

but don't update...It's add a row.


thanks in advance,

Alfredo

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



working with database

2008-07-15 Thread Alfredo Alessandrini

I must select a column from my database.

I've try with:

from PLAYER.models import Player
player = Player.objects.all()
email = Player.objects.values('email')

ok, work fine, but in the Django Book I read:

"This method is useful when you know you're only going to need values
from a small number of the available fields and you won't need the
functionality of a model instance object. It's more efficient to
select only the fields you need to use."

Is there another method for select a single column?

I must utilise the data of this column and import it by a string
whithin an application write in Python. It's more efficient utilise
the Django API for the database or the Python API, when my database
must interact with an application write in Python?



thanks in advance,

Alfredo

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



delete or update a model

2008-07-15 Thread Alfredo Alessandrini

Hi,

How can I update or delete a model?

Alfredo

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



hosting web

2008-02-09 Thread Alfredo Alessandrini

Hi,

I'm a beginner about django. I've a doubt.

How I can verify if an hosting web can support django?

If it support python is sure that django work?


thanks,

Alfredo

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



web site

2007-09-02 Thread Alfredo Alessandrini
I'm a newby..:-)

Is Django good for make a web site like this?

http://www.ficgs.com/
http://www.chessmail.org/

These are a web site for playing correspondence chess.

The moves are stored with a database, with information about the players,
tournament, rating, ecc..


Alfredo

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