Re: Questions on learning curve

2007-06-18 Thread Kelvin Nicholson


> Now, maybe a stupid question but for how long does it take to really
> understand Django/Python and start actually creating some code for the
> game?

There are only parts of python you really need to learn to use Django,
and other parts can be learned later.  I read the book Beginning Python
-- From Novice to Professional in about three days, then took about
three days to go through the Django tutorial and the Django book.  After
that my first project was redoing my blog, which I felt totally
comfortable with.

I haven't hit any limitations since then.

My .02c,

Kelvin



--~--~-~--~~~---~--~~
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: Questions on learning curve

2007-06-18 Thread Kenneth Gonsalves


On 19-Jun-07, at 11:21 AM, [EMAIL PROTECTED] wrote:

> Now, maybe a stupid question but for how long does it take to really
> understand Django/Python and start actually creating some code for the
> game?

from what i see on the IRC channel, you can pretty much start  
producing your game by day 3

>
> Do I have to read XXX amount of Python books to be able to be
> productive ?

not at the outset - you can do the django tutorial and the python  
tutorial, both together would take you about three days. Then you can  
be productive - but to continue to be productive you will have to  
keep working on your python continously.

-- 

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



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



Re: Mysql sleeping queries

2007-06-18 Thread David Reynolds


On 19 Jun 2007, at 6:56 am, Gábor Farkas wrote:


hi,

i have no idea what went wrong, but to the developers it certainly  
would

  help, if you could find out exactly which revision broke the mysql
behaviour.


Difficult to tell since we hadn't svn up'd for a while...

--
David Reynolds
[EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature


Re: Mysql sleeping queries

2007-06-18 Thread Gábor Farkas

David Reynolds wrote:
> Morning,
> 
> We are experiencing a problem with Mysql with django.  Since an svn up 
> yesterday (which seems to be revision 5492) we have lots of sleeping 
> (hanging) mysql processes and we keep hitting our limit of processes 
> (which we weren't doing before). Anyone have any idea why it may be 
> doing this?
> 
> Versions:
> 
> apache 2.0.54
> mysql 4.0.24
> mysqldb 1.2.1c2-1
> 
> If anyone can shed any light, I'd be very interested to know.
> 

hi,

i have no idea what went wrong, but to the developers it certainly would 
  help, if you could find out exactly which revision broke the mysql 
behaviour.

gabor

--~--~-~--~~~---~--~~
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: recommendations for hosts

2007-06-18 Thread Gábor Farkas

shabda wrote:
> Hi,
> 
> What host do you people recommend for hosting a small-medium traffic
> django site. Its just a hobby hobby site so I dont want too costly a
> host, but since this is the first django app I would be hosting, I
> would prefer a host with reasonable support and one which specialises
> in django.
> 

i cannot recommend to you anything specific, but for a list of 
django-hosts, check this page:

http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts

gabor

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



Mysql sleeping queries

2007-06-18 Thread David Reynolds

Morning,

We are experiencing a problem with Mysql with django.  Since an svn  
up yesterday (which seems to be revision 5492) we have lots of  
sleeping (hanging) mysql processes and we keep hitting our limit of  
processes (which we weren't doing before). Anyone have any idea why  
it may be doing this?


Versions:

apache 2.0.54
mysql 4.0.24
mysqldb 1.2.1c2-1

If anyone can shed any light, I'd be very interested to know.

Thanks,

David

--
David Reynolds
[EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature


Questions on learning curve

2007-06-18 Thread [EMAIL PROTECTED]

Hello everyone,

A few days ago I got an idea to build an online turnbased game (like
thecrims.com) for example.
I am pretty much a novice when it comes to PHP so I started to look at
Ruby on rails to maybe make my development easier and faster.
Stopped with Rails and found Django.

Now, maybe a stupid question but for how long does it take to really
understand Django/Python and start actually creating some code for the
game?

Do I have to read XXX amount of Python books to be able to be
productive ?

What is really bugging me is that everything that has to do with
computers/script/web/programming takes a long time. I am more of the
hands on type of guy and get easy frustrated.
Even though its fun from time to time to built and create something,
but what is bothering me is the time it takes to develop something.

A house can be built in 2 months, but a advanced script with design
etc can take up to 1 year...something is wrong here =)

So can someone let me know what I should do to be able to create such
a game?

Cheers to all


--~--~-~--~~~---~--~~
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: FastCGI Shared host

2007-06-18 Thread rtconner

On second though.. nope, I still get a ton of errors...

WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
etc, etc

Its just no longer complains about ADD_SLASH. So why am I getting all
of these errors?


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



html validator middleware

2007-06-18 Thread Brian St. Pierre

I recently hacked together a small middleware that validates all
outgoing html and if it encounters a validation error, throws a 500
status code and error page with the validation error message(s) and
html source.

Similar in aim to Luke Plant's Validator App (http://lukeplant.me.uk/
resources/djangovalidator/), but lighter weight.

Requires python 2.4 (for the subprocess module).
Requires the offline "validate" utility for HTML validation from
HTMLHelp.com, or its equivalent.

Available here: http://bstpierre.org/Projects/HtmlValidatorMiddleware/

Comments & questions welcome.

-Brian St. Pierre
[EMAIL PROTECTED]


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



Re: django book chpt. 3 bug?

2007-06-18 Thread Jeremy Dunck

On 6/18/07, walterbyrd <[EMAIL PROTECTED]> wrote:
...
> (r'^now/$', 'survey.views.current_datetime'),

That's only necessary due to the old Django version.

> I tried that, and it still didn't work. Then I changed the parameter
> to:
>
> (r'^now/$', 'views.current_datetime'),

This is due to your local python path.  The string given there is an
import path, and if you can't import 'survey' from regular python,
Django won't be able to either.  Consider adding the parent directory
of 'survey' to your python path.

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



Re: django book chpt. 3 bug?

2007-06-18 Thread Jeremy Dunck

On 6/18/07, walterbyrd <[EMAIL PROTECTED]> wrote:
>
...
> AttributeError at /now/
> 'function' object has no attribute 'rindex'

I think you're using an old version of Django.  The latest stable is
0.96.  Please update to that.

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



Re: django book chpt. 3 bug?

2007-06-18 Thread walterbyrd

Googling around some more, I managed to get it to work. But, I still
don't think it's right. According to this site:

http://notkeepingitreal.com/articles/category/django

According to the blog on that site, parameter in urls.py needs to be
changed from:

(r'^now/$', current_datetime),

To:

(r'^now/$', 'survey.views.current_datetime'),

I tried that, and it still didn't work. Then I changed the parameter
to:

(r'^now/$', 'views.current_datetime'),

And it worked.

The blog on that site was written last January. Numerous other errors
were cited. If these are known problems, that have been around that
long, that's pretty bad.

JMHO.


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



django book chpt. 3 bug?

2007-06-18 Thread walterbyrd

I believe this is a bug, and I think it's been reported. I think it
was also reported as fixed, but I don't think it is fixed.

When I try to run the example program, I get a page full of errors,
with this heading:

---
AttributeError at /now/
'function' object has no attribute 'rindex'
Request Method: GET
Request URL:http://127.0.0.1:8000/now/
Exception Type: AttributeError
Exception Value:'function' object has no attribute 'rindex'
Exception Location: /var/lib/python-support/python2.4/django/core/
urlresolvers.py in get_mod_func, line 23
---

The problem seems t be in line 23 of urlresolvers.py.

---
23 dot = callback.rindex('.')
---

Apparently, there is some problem with the "rindex" attribute.

I am brand new to Django. I have no idea what to do about this. Is
this a bug? Or did I do something wrong?


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



recommendations for hosts

2007-06-18 Thread shabda

Hi,

What host do you people recommend for hosting a small-medium traffic
django site. Its just a hobby hobby site so I dont want too costly a
host, but since this is the first django app I would be hosting, I
would prefer a host with reasonable support and one which specialises
in django.


--~--~-~--~~~---~--~~
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: FastCGI Shared host

2007-06-18 Thread rtconner

Dude was right, I turned APPEND_SLASH off it spit HTML out.
Now it won't render in the browser. Freeking .htaccess problems I
wager.

On Jun 18, 8:19 pm, SmileyChris <[EMAIL PROTECTED]> wrote:
> On Jun 19, 2:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Tue, 2007-06-19 at 01:54 +, rtconner wrote:
> > > I followed the instruction at the bottom of this page:
> > >http://www.djangoproject.com/documentation/fastcgi/
> > > I can't seem to get this running on a shared host. I've also try using
> > > the WSGIHander against jonpy, but I can't get that to work either. Any
> > > helps?
>
> > Based on the error message, [...]
>
> Actually, that's a common error message if I remember back to my fcgi
> Dreamhost days.
>
> You can't just test the server like that (with
> settings.APPEND_SLASH=True) because it chokes when there's nothing in
> request.url to see if it ends with a slash.


--~--~-~--~~~---~--~~
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: FastCGI Shared host

2007-06-18 Thread rtconner

Python 2.4.3

~/www/django> uname -a
Linux  2.6.9-55.ELsmp #1 SMP Wed May 2 14:28:44 EDT 2007
i686 i686 i386 GNU/Linux

It's a shared server. I can't control the python binary. I guess I
could install virutal python, but that would be a pain, plus I think
that only is python 2.4 also.

On Jun 18, 8:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2007-06-19 at 01:54 +, rtconner wrote:
> > I followed the instruction at the bottom of this page:
> >http://www.djangoproject.com/documentation/fastcgi/
> > I can't seem to get this running on a shared host. I've also try using
> > the WSGIHander against jonpy, but I can't get that to work either. Any
> > helps?
>
> Based on the error message, I'm going to guess that you are using Ubuntu
> Feisty with the Python 2.5.1c2 release. If that is the case, you need to
> upgrade your Python package to 2.5.1 (2.5.1c2 was a pre-release with a
> regression in it that Django hits).
>
> If that isn't the case, can you provide some details about your OS and
> Python version, please?
>
> Regards,
> Malcolm


--~--~-~--~~~---~--~~
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: FastCGI Shared host

2007-06-18 Thread SmileyChris



On Jun 19, 2:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2007-06-19 at 01:54 +, rtconner wrote:
> > I followed the instruction at the bottom of this page:
> >http://www.djangoproject.com/documentation/fastcgi/
> > I can't seem to get this running on a shared host. I've also try using
> > the WSGIHander against jonpy, but I can't get that to work either. Any
> > helps?
>
> Based on the error message, [...]

Actually, that's a common error message if I remember back to my fcgi
Dreamhost days.

You can't just test the server like that (with
settings.APPEND_SLASH=True) because it chokes when there's nothing in
request.url to see if it ends with a slash.


--~--~-~--~~~---~--~~
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: CheckboxSelectMultiple error: Select a valid choice. That choice is not one of the available choices.

2007-06-18 Thread Gabriel Farrell

On Jun 15, 3:13 pm, Gabriel Farrell <[EMAIL PROTECTED]> wrote:
> I've just replaced the RadioSelect widget with CheckboxSelectMultiple
> for one field in my view.  Here's the relevant code:
>
> self.fields['patron_type'] = forms.ChoiceField(choices=(
> (pt.id, pt.name) for pt in patron_type_choices),
> widget=widgets.CheckboxSelectMultiple())
>
> It shows up fine in the browser, but now I receive the "Select a valid
> choice. That choice is not one of the available choices." error no
> matter which box I check on that field.  Have I missed something?
>
> Gabe

Ah.  Figured it out.  ChoiceField needs to be MultipleChoiceField.
Thanks for the help, everybody! ;)


--~--~-~--~~~---~--~~
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: FastCGI Shared host

2007-06-18 Thread Malcolm Tredinnick

On Tue, 2007-06-19 at 01:54 +, rtconner wrote:
> I followed the instruction at the bottom of this page:
> http://www.djangoproject.com/documentation/fastcgi/
> I can't seem to get this running on a shared host. I've also try using
> the WSGIHander against jonpy, but I can't get that to work either. Any
> helps?

Based on the error message, I'm going to guess that you are using Ubuntu
Feisty with the Python 2.5.1c2 release. If that is the case, you need to
upgrade your Python package to 2.5.1 (2.5.1c2 was a pre-release with a
regression in it that Django hits).

If that isn't the case, can you provide some details about your OS and
Python version, please?

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: SelectDateWiget Problem

2007-06-18 Thread Bryan Veloso

Yep, the other fields are populated correctly.

My Form:
class ProfileForm(forms.Form):
name= forms.CharField(required=False)
avatar  = forms.Field(widget=forms.FileInput,
required=False)
photo   = forms.Field(widget=forms.FileInput,
required=False)
city= forms.CharField(max_length=50, required=False)
state   = forms.CharField(min_length=2, required=False)
country = forms.CharField(required=False)
zip = forms.CharField(max_length=10, required=False)
latitude= forms.DecimalField(max_digits=11,
decimal_places=6, required=False)
longitude   = forms.DecimalField(max_digits=11,
decimal_places=6, required=False)
display_on_map  = forms.BooleanField(required=False)
primary_mii = forms.CharField(required=False)
favorite_game   = forms.ChoiceField(choices=[(1, 'Baseball'), (2,
'Bowling'), (3, 'Boxing'), (4, 'Golf'), (5, 'Tennis')],
widget=forms.Select)
friend_code = forms.CharField(min_length=16, max_length=19,
required=False)
gender  = forms.ChoiceField(choices=[('N', 'Neither'),
('M', 'Male'), ('F', 'Female'), ('B', 'Both')], widget=forms.Select)
birthday=
forms.DateField(widget=SelectDateWidget(years=range(today.year,
1900,-1)), required=False)
homepage= forms.URLField(required=False,
verify_exists=True)
icq = forms.CharField(required=False)
aim = forms.CharField(required=False)
yahoo   = forms.CharField(required=False)
google  = forms.EmailField(widget=forms.TextInput,
required=False)
msn = forms.EmailField(widget=forms.TextInput,
required=False)
interests   = forms.CharField(required=False)
occupation  = forms.CharField(required=False)


My View:
def edit_profile(request, slug=None):
"""
Allows a Player to edit their profile.
"""

from django.views.generic.create_update import update_object
try:
if slug:
auth_user = User.objects.get(username=slug)
elif request.user:
auth_user = request.user
except(User.DoesNotExist):
raise Http404

user_id = auth_user.id
username = auth_user.username
instance = Player.objects.get(player=user_id)
profileform = form_for_instance(instance, form=ProfileForm)
form = profileform(instance.__dict__)

if request.method == 'POST':
form = profileform(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect("/players/%s/" % username)
else:
form = profileform(instance.__dict__)

return update_object(
request,
model=Player,
extra_context={ 'form' : form },
object_id=user_id,
login_required=True,
template_name="players/player_edit_form.html",
)



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



FastCGI Shared host

2007-06-18 Thread rtconner

I followed the instruction at the bottom of this page:
http://www.djangoproject.com/documentation/fastcgi/
I can't seem to get this running on a shared host. I've also try using
the WSGIHander against jonpy, but I can't get that to work either. Any
helps?



~/www/django> python mysite.fcgi
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/flup/server/fcgi_base.py", line
558, in run
  File "build/bdist.linux-i686/egg/flup/server/fcgi_base.py", line
1112, in handler
  File "/home//lib/python2.4/site-packages/django/core/
handlers/wsgi.py", line 189, in __call__
response = self.get_response(request)
  File "/home//lib/python2.4/site-packages/django/core/
handlers/base.py", line 59, in get_response
response = middleware_method(request)
  File "/home//lib/python2.4/site-packages/django/middleware/
common.py", line 41, in process_request
if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not
in old_url[1].split('/')[-1]):
IndexError: string index out of range
Content-Type: text/html



Unhandled Exception

Unhandled Exception
An unhandled exception was thrown by the application.



--~--~-~--~~~---~--~~
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: SelectDateWiget Problem

2007-06-18 Thread [EMAIL PROTECTED]

When you edit the object, do the other fields get populated correctly?
Maybe you should paste your view and your form code?

On Jun 18, 7:10 pm, Bryan Veloso <[EMAIL PROTECTED]> wrote:
> birthday=
> forms.DateField(widget=SelectDateWidget(years=range(today.year,
> 1900,-1)), required=False)
>
> I have this in my forms.py, and it defaults to January 1, 2007. So, I
> set my birthday, save, come back and it's back to that default, so if
> I were to save the form without changing that value, it'll save my
> birthday as 01/01/07. Shouldn't the widget automatically inherit the
> database value like the rest of the form fields?


--~--~-~--~~~---~--~~
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: User profile views - Does something like this make sense?

2007-06-18 Thread zenx

Thank you Gábor!

I will make "clear_old" a static method.

thanks!!!



On 18 jun, 15:27, Gábor Farkas <[EMAIL PROTECTED]> wrote:
> zenx wrote:
> > I want to show the user the latest users that have seen his profile.
> > So everytime a logged user views another user's profile a ProfieView
> > object is stored in the database (or the date is updated if the user
> > that is viewing the profile has already viewed it before). I know this
> > can make the database grow too much, so I think I can run a cron
> > script daily that deletes all profile views older than a week (see
> > clear_old method). I don't know if the code is 100% correct, but is
> > the concept ok? Does it make sense to add a new object to the database
> > everytime another user views a profile?
>
> > class ProfileViews(models.Model):
> > user = models.ForeignKey(User,related_name='latest_profile_views')
> > viewer = models.ForeignKey(User)
> > date = models.DateTimeField()
>
> > def clear_old(self):
> > d = datetime.now()-timedelta(weeks=1)
> > p = ProfileViews.objects.filter(date__lte=d)
> > p.delete()
>
> i think this approach makes sense.
>
> the only change i would recommend is to make "clear_old" into a static
> method.
>
> gabor


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



SelectDateWiget Problem

2007-06-18 Thread Bryan Veloso

birthday=
forms.DateField(widget=SelectDateWidget(years=range(today.year,
1900,-1)), required=False)

I have this in my forms.py, and it defaults to January 1, 2007. So, I
set my birthday, save, come back and it's back to that default, so if
I were to save the form without changing that value, it'll save my
birthday as 01/01/07. Shouldn't the widget automatically inherit the
database value like the rest of the form fields?


--~--~-~--~~~---~--~~
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: Problems with running Django on a remote machine

2007-06-18 Thread Malcolm Tredinnick

On Mon, 2007-06-18 at 15:04 +0200, Dirk van Oosterbosch, IR labs wrote:
> 
> On 15-jun-2007, at 0:18, Malcolm Tredinnick wrote:
> 
> >
> > On Thu, 2007-06-14 at 16:37 +0200, Dirk van Oosterbosch, IR labs  
> > wrote:
> > [...]
> >>
> >> Exactly. It runs untill I try to load a page (from another ssh  
> >> shell).
> >> And I just get the prompt back:
> >
> > [...]
> > So maybe shove some debug prints in handle(), but, in general, you're
> > going to have to try to work out how far it gets before stopping. I
> > cannot imagine what is going wrong here. The whole silent failure  
> > bit is
> > confusing.
> 
> 
> Indeed, it is very confusing. This is as it gets before stopping:
> 
> (basehttp.py, run() method of ServerHandler class, line 271)
> try:
>   self.setup_environ()
> 
> The server hangs on the next line, 272:
>   self.result = application(self.environ, self.start_response)
> and just exits, without even getting to the except:

Query: it hangs or it exits? Since they are opposites, it can't do both.
Are you saying it never returns from that function call but still exits?

What should be happening, by the way, is that run() method is called
once per request.

The "application" here will be an AdminMediaServer instance (so you can
plug things into the __call__ method of that class, further down in the
same basehttp.py file). The AdminMediaServer class also has an
"application" attribute and that is a WSGIHandler instance (from
django.core.handlers.wsgi).

I'd start by checking how far through AdminMediaServer.__call__ you get.
If it gets as far as line 613, start putting traps into
WSGIHandler.__call__ to see what's going on.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: The going rate for Django-based web developers ...

2007-06-18 Thread Nic James Ferrier

ZebZiggle <[EMAIL PROTECTED]> writes:

> Strong python, javascript, CSS, postgres, jquery (or alike), debugging
> and lots of general experience in software development. And when I say
> CSS, I don't mean graphic design skills, but knowing how to take a
> graphic design and translate it into CSS. Someone that can take a
> concept and turn it into reality.

It's that CSS bit that I find difficult to find.

I have a good grasp of CSS... but I still can't do that very well
(takes me ages). The people who can are worth a good amount of money
(+$50 an hour).

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

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



post a job

2007-06-18 Thread Neubauer, Marissa
Hi - how can I post a job under the pages section of the group?

Thanks,
Marissa

Marissa Neubauer
Senior Recruiter | Travelocity | 682-605-4612
3150 Sabre Drive | Southlake, TX | 76092
www.travelocity.com | You'll Never Roam Alone!


--~--~-~--~~~---~--~~
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: Total noob needs some help installing

2007-06-18 Thread walterbyrd



On Jun 18, 12:14 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> > >>> django-admin.py startproject mysite
>
> Are you putting that in the python interactive shell? If so, that
> would seem to be your problem. You'd probably want to do "python
> django-admin.py startproject mysite" from the normal terminal prompt.
>

D'Oh! That was it. Thanks again.


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



Re: newforms, manytomany, default value.

2007-06-18 Thread Yishai

Not much more than a noob myself - I hope the following will be
useful:

1. form_from_model (and form_from_instance) are merely shortcuts -
allowing you to build a form that has all the fields from the target
model. In most real-life cases, you only need some of the fields, and
as mentioned you are probably getting user input for more than just
one model at a time. So you can go with the basic newforms approach of
defining your form class *as per how you want the HTML form to look
like*, and map back into instance data in your view function that
handled the post data. After checking that the form is valid you
simply instantiate what you need from your models and assign values
from the relevant form fields into the instances you have created.
Then you save() them.

Obviously this means you have manual code that copies data from the
form fields to the instance fields, and that will need to be
maintained in parallel to the changes in the model. But as in many
cases the HTML forms are pretty far from being a 1-to-1 representation
of the models (admin interface is the exception), the form-for-model
shortcut is probably not what you need anyway.

2. For M2M data, which is not saved by the form_for_model shortcut on
save(), you can still use the form_for_model shortcut but you will
need to iterate over the M2M field's (form field) data, and call the
relevant *add() method (I'm assuming you're only adding refs to
existing M2M target instances). For instance if you have:

class Client(model):
   name = CharField(...)
   tags = M2MField(Tag,...)
   ...
class Tag(model):
   name = CharField(...)
   ...

then a paraphrase of your original code snippet would go like:

if client_form.is_valid():
  client = client_form.save(commit=False)
  client.institution =
  Institution.objects.get(pk=site_id)

  # repeat this for any m2m field
  client.tags.add(*client_form.clean_data['tags']) # add
accepts a variable number of args - note use of '*'

  client.save()
return HttpResponseRedirect('/myapp/client/%s' %
(client.id))




On Jun 5, 4:52 pm, larry <[EMAIL PROTECTED]> wrote:
> > I'm not sure what "a patch in the development tree" means here. Current
> > subversion trunk doesn't seem to have anything like that.
>
> Sorry for not being clear -- I'm (obviously) not familiar with the
> mechanism of open source / django development.  What I was referring
> to is the ticket you mentioned (4001) and the "patch" is the file
> attached to that ticket (save_instance_m2m.patch).
>
> > Remember that the situation where a form maps precisely onto a model is
> > a very specialised case. In the general case, you need to build the
> > objects you are going to save manually anyway (since one form provides
> > information for many models). So the workaround that springs to mind in
> > this case is to forget about using form_for_model() and just build the
> > form by hand and construct the save objects in your view. It's only a
> > few lines of code.
>
> That sounds great (in fact, I was forced to combine two tables into
> one in order to coerce the data into something that can be easily used
> by form_for_model).  However, I'm not sure where to start to come to
> grips with the concepts of "objects you are going to save", "build the
> form by hand", and "construct the save objects".
>
> I'm guessing that this means instantiating models, creating the form
> bound to data from several different model classes, then (on POST)
> instantiating new model instances, somehow unpacking the data from the
> form into the appropriate model classes, and saving the instances.
>
> If you can direct me to a simple example of a view that does this
> (including a many-to-many field in one of the models if such a field
> requires any special handling in the view) it would be greatly
> appreciated.  I guess my three sticking points are 1) how to create a
> form from _several_ objects, 2) how to create the form from several
> _models_ when the user is trying to add new information and 3) how to
> instantiate the multiple save objects from the POSTed form.
>
> Many thanks for your kind assistance in what I know must be quite a
> simple operation.
> --
> Larry Lustig


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



Django Job: Naples Daily News

2007-06-18 Thread Stephan Schonberg

Hi folks,

I just wanted to mention that the Naples Daily News in Naples, Florida
has an immediate opening for a full-time Django developer.  If you're
a web programmer with Python and Django experience, and want to work
in sunny Florida, we want to hear from you!

Full job posting and details are at: 
http://jobs.scripps.com/details.html?id=6290

For those unfamiliar with Naples, we're located in southwest Florida,
(south of Tampa and west of Miami). 
http://maps.google.com/maps?f=q&hl=en&q=naples,+fl&ie=UTF8&z=12&om=1

Thank you,
-Stephan


--~--~-~--~~~---~--~~
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: cannot import name User (from django.contrib.auth.models)

2007-06-18 Thread RajeshD

> I was making an application that included user profiles, and I thought
> I was done with the first part so I entered an sql command and got
> this:
>
> Ian-Smiths-Computer:~/Sites/matches ismith$ python manage.py sql nest
> matches.cafe: cannot import name User


Notice that the error is in 'matches.cafe' and not in 'nest'. You
might want to look at your import statements in the former.


--~--~-~--~~~---~--~~
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: Q Objects: Can you do this?

2007-06-18 Thread Jeremy Dunck

On 6/18/07, johnny <[EMAIL PROTECTED]> wrote:
> I am getting the following error:
>
> citylist = CityList.objects.get(
> NameError: name 'Q' is not defined

from django.db.models.query import Q

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



Q Objects: Can you do this?

2007-06-18 Thread johnny

Can you do this?

citylist = CityList.objects.get(
Q(city="%s" % (line[3])),
Q(state=slist.id)
)

I am getting the following error:

citylist = CityList.objects.get(
NameError: name 'Q' is not defined


--~--~-~--~~~---~--~~
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: delete obsolete content type entries...

2007-06-18 Thread Gabriel Farrell

On May 7, 4:32 am, Jens Diemer <[EMAIL PROTECTED]> wrote:
> That surprises me. Does nobody have the same problems?
> Still nobody delete a model class?
>
> How to clean up the django tables? With phpMyAdmin?
>

I've just run into a similar issue when I removed an app from a
project.  After some attempt to fix the tables myself, I held my
breath, dropped the tables (auth_permission and django_content_type),
then ran "python manage.py syncdb".  Voila, the tables were re-created
correctly, without the app I had removed.

> --
> Mfg.
>
> Jens Diemer
>
> 
> A django powered CMS:http://www.pylucid.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Total noob needs some help installing

2007-06-18 Thread [EMAIL PROTECTED]

> >>> django-admin.py startproject mysite

Are you putting that in the python interactive shell? If so, that
would seem to be your problem. You'd probably want to do "python
django-admin.py startproject mysite" from the normal terminal prompt.

On Jun 18, 1:33 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
> I am running debian  4.x testing at home. I also have dreamhost. My
> plan is to try to get something working on my home box, then I'll try
> to install django on dreamhost. My plan is to keep the installations
> as similar as possible - I think that might make it easier.
>
> My home box:
> I have python 2.3 and 2.4 installed (not sure how that happend), but
> 2.4 comes up by default. I have apache, mysql, sqlite3, pysqlite, and
> django installed. I am a little more familiar with mysql, but I think
> I might get better performance out of sqlite - especially on the
> hosted site.
>
> I don't want to use postgresql, or mod_python, because those are not
> available on dreamhost.  I think dreamhost has python 2.4.1 available,
> and I think I can install sqlite 3.3.
>
> Here is where I'm lost:
>
> >From the django book, chapter 2, getting started:
>
> http://www.djangobook.com/en/beta/chapter02/
>
> --
> Starting a project
> If this is your first time using Django, you'll have to take care of
> some initial setup.
> Run the command django-admin.py startproject mysite. That'll create a
> mysite directory in your current directory.
>
> I can import django, but "django-admin.py startproject mysite" causes
> a syntax error.
>
> >>> django-admin.py startproject mysite
>
>   File "", line 1
> django-admin.py startproject mysite
>^
> SyntaxError: invalid syntax
> --
>
> I'm sure it's something simple, but I don't know what to do. Any help
> appreciated. Also would appreciate any advise on my overall plan.
>
> Thank you in advance.


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



Re: Developing without tempplates

2007-06-18 Thread Vincent Foley

There's more than one way to do it (with apologies if you don't like
Perl).  One thing I like to use is IPython which allows you to start a
Python interpreter from any point in your code with the entire
context.
So to test a function, you could add the following lines at the bottom
of
the function body:

from IPython.Shell import IPShellEmbed
IPShellEmbed()()

When this point is reached, you will have a complete interactive
Python
interpreter to play around with your variables.

Another way would be to use the pprint module (standard in Python) to
display only the variables you want.

On Jun 18, 1:04 pm, shabda <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am prototyping an app. Since I am just prtotyping I do not want to
> write templates yet. SO is there some way wherein all my variables in
> the view method get out put to the screen, so that I can debug them?


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



Earn $2000 a few times a week

2007-06-18 Thread [EMAIL PROTECTED]

Huge Profits Instantly
You get paid instantly.  High-demand software.
Create a huge income quickly and easily.
http://www.tellmemoresite.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
-~--~~~~--~~--~--~---



Re: classes

2007-06-18 Thread Joseph Heck

x = '123'
x.__class__ will give a reasonable answer, x.type() doesn't. (Python 2.4)

If you can get away with using type(), it's probably a lot cleaner to use...

-joe

On 6/18/07, Aidas Bendoraitis <[EMAIL PROTECTED]> wrote:
>
> or type()
>
> On 6/7/07, Joseph Heck <[EMAIL PROTECTED]> wrote:
> >
> > .__class__
> >
> > On 6/7/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote:
> > > how can I know insede a method the type of my class dynamicaly?
> > >
> > > --
> > > Lic. José M. Rodriguez Bacallao
> > > Cupet
> > >  >
> > >
> >
> > >
> >
>
> >
>

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



Total noob needs some help installing

2007-06-18 Thread walterbyrd

I am running debian  4.x testing at home. I also have dreamhost. My
plan is to try to get something working on my home box, then I'll try
to install django on dreamhost. My plan is to keep the installations
as similar as possible - I think that might make it easier.

My home box:
I have python 2.3 and 2.4 installed (not sure how that happend), but
2.4 comes up by default. I have apache, mysql, sqlite3, pysqlite, and
django installed. I am a little more familiar with mysql, but I think
I might get better performance out of sqlite - especially on the
hosted site.

I don't want to use postgresql, or mod_python, because those are not
available on dreamhost.  I think dreamhost has python 2.4.1 available,
and I think I can install sqlite 3.3.

Here is where I'm lost:

>From the django book, chapter 2, getting started:
http://www.djangobook.com/en/beta/chapter02/

--
Starting a project
If this is your first time using Django, you'll have to take care of
some initial setup.
Run the command django-admin.py startproject mysite. That'll create a
mysite directory in your current directory.

I can import django, but "django-admin.py startproject mysite" causes
a syntax error.

>>> django-admin.py startproject mysite
  File "", line 1
django-admin.py startproject mysite
   ^
SyntaxError: invalid syntax
--

I'm sure it's something simple, but I don't know what to do. Any help
appreciated. Also would appreciate any advise on my overall plan.

Thank you in advance.


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



RE: Providing defaults to models

2007-06-18 Thread Chris Brand

> > class Link(models.Model):
> > link = models.URLField()
> > user = models.ForeignKey(User, unique=False)
> > text = models.TextField(maxlength = 20)
> > votes = models.IntegerField()
> >
> > I want some of the fields to have defaults, like I want votes to have
> > a default value of 0. How can I achieve this. I dont seem to find any
> > documentation for this, but seems to common a case to not be possible.

http://www.djangoproject.com/documentation/model-api/#default

Chris




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



django-registration question

2007-06-18 Thread [EMAIL PROTECTED]

I'm looking at using James Bennett's django-registration app instead
of what I have now (a modified version of what Jeff Croft's old Lost-
Theories code, which in turn came by way of Zyons), but one thing I
really like about what I have now is that no db record is created
until after the activation key has been sent and responded to. I like
that no information is gathered or stored until I've verified that the
user is for real, and I think it keeps the db cleaner.

So, my question is, how would I modify django-registration to not
create the user at all until after the activation key is followed.
It's in newforms, which I'm only starting to work with, so I'm a
little mystified.


--~--~-~--~~~---~--~~
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: Developing without tempplates

2007-06-18 Thread shabda

Also using locals() and printing is not very useful as it dumps too
much data to screen to be any use.

On Jun 18, 10:04 pm, shabda <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am prototyping an app. Since I am just prtotyping I do not want to
> write templates yet. SO is there some way wherein all my variables in
> the view method get out put to the screen, so that I can debug them?


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



Developing without tempplates

2007-06-18 Thread shabda

Hi,

I am prototyping an app. Since I am just prtotyping I do not want to
write templates yet. SO is there some way wherein all my variables in
the view method get out put to the screen, so that I can debug them?


--~--~-~--~~~---~--~~
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: Providing defaults to models

2007-06-18 Thread shabda

Also this page, http://code.djangoproject.com/changeset/5202 , says
that

>> If you specify ``fields`` when creating a form with ``form_for_model()``
>>   make sure that the fields that are *not* specified can provide default
>>   values, or are allowed to have a value of ``None``

So providing default values for models should be possible.

On Jun 18, 9:30 pm, shabda <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a model class like this
>
> class Link(models.Model):
> link = models.URLField()
> user = models.ForeignKey(User, unique=False)
> text = models.TextField(maxlength = 20)
> votes = models.IntegerField()
>
> I want some of the fields to have defaults, like I want votes to have
> a default value of 0. How can I achieve this. I dont seem to find any
> documentation for this, but seems to common a case to not be possible.


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



Providing defaults to models

2007-06-18 Thread shabda

Hi,

I have a model class like this

class Link(models.Model):
link = models.URLField()
user = models.ForeignKey(User, unique=False)
text = models.TextField(maxlength = 20)
votes = models.IntegerField()

I want some of the fields to have defaults, like I want votes to have
a default value of 0. How can I achieve this. I dont seem to find any
documentation for this, but seems to common a case to not be possible.


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

2007-06-18 Thread Aidas Bendoraitis

or type()

On 6/7/07, Joseph Heck <[EMAIL PROTECTED]> wrote:
>
> .__class__
>
> On 6/7/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote:
> > how can I know insede a method the type of my class dynamicaly?
> >
> > --
> > Lic. José M. Rodriguez Bacallao
> > Cupet
> >  >
> >
>
> >
>

--~--~-~--~~~---~--~~
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: Using Ajax to edit my admin page

2007-06-18 Thread Aidas Bendoraitis

Yes. If you want to use AJAX, you will need a separate view, taking
manufacturer id or slug and returning
1. either the HTML with the collection select field, which should
replace a default collection select field,
2 or the JSON-based collection options, which should replace the
options of the collection select field, iterating through all the
received items.

Learn yourself, how to use yahoo-provided library. Don't forget to
check user permissions in the custom views for AJAX.

An alternative to AJAX would be to overwrite the admin template for
the style model and use some custom template tag which would return a
complex array structure with manufacturers and corresponding
collections.

Regards,
Aidas Bendoraitis aka Archatas



On 6/7/07, Greg <[EMAIL PROTECTED]> wrote:
>
> I'm building a site where I'm going to have 10 manufacturers and each
> of those manufacturers is going to have 10 collections and each of
> those collections will contain 20 style.  Confused Yet?
>
> In my admin i have a table called styles.  It looks like this:
>
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> theslug = models.SlugField(prepopulate_from=('name',))
> manufacturer = models.ForeignKey(Manufacturer)
> collection = models.ForeignKey(Collection)
> sandp = models.ManyToManyField(Choice)
>
> class Admin:
> search_fields = ['name']
> list_filter = ('collection',)
> list_display = ('name', 'theslug','collection', 'rmanu')
>
> js = (
> '/site_media/ajax_yahoo.js',
> )
>
> def __str__(self,):
> return self.name
>
> def rmanu(self):
> return self.collection.manufacturer
>
>
> We'll when I'm entering a style I want to be able to select a
> manufacturer and then the collection drop-down list only shows those
> collections that are tied to the manufacturer that I selected.  I'm
> guessing that I'm going to need to use AJAX to accomplish this
>
> I already have it setup to where when I'm in the admin and I'm adding
> a style when I select a manufacturer a alert pops up.  So I know that
> my YUI addlisteners is working.  I get confused on the part on how I
> would update my collection form field with only those entries that are
> tied to the manufacturer I selected.  Do I need to have a function
> within my ajax.js file which call a Django view?  How would that
> Django view update the contents of my collection form field?
>
> I know these are some tough questions...but would very much appreciate
> it if somebody could help me out.
>
>
> >
>

--~--~-~--~~~---~--~~
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: Simple Template Dict Problem

2007-06-18 Thread Tim Terlegård

On Mon, Jun 18, 2007 at 03:44:03PM +0200, Aidas Bendoraitis wrote:
> 
> Hello Trey!
> 
> You can iterate by the entries of a dictionary, using this:
> 
> {% for i in d.items %}
>  {{ i.0 }}: {{ i.1 }}
> {% endfor %}
> 
> Regards,
> Aidas Bendoraitis aka Archatas
> 
> 
> 
> On 6/7/07, Trey <[EMAIL PROTECTED]> wrote:
> >
> > Thanks Russ, I think my answer for today is three dimensional lists...
> > Hooray for complex datastructures :)
> >
> > Tim, that's a very cool idea. I will research this some and see if I
> > can abstract the calendar control.
> >
> > On Jun 7, 11:02 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > > > Somehow I doubt this should really be in the view either. Maybe it's
> > > > just one of those out liers that doesn't have a good place.
> > >
> > > Sounds like you're describing template tags.  They're ways of
> > > creating reusable bits you can just drop into your templates to
> > > abstract away the logic required to build them.
> > >
> > > http://www.djangoproject.com/documentation/templates_python/#writing-...
> > >
> > > particularly, the sections on simple tags and inclusion tags:
> > >
> > > http://www.djangoproject.com/documentation/templates_python/#shortcut...http://www.djangoproject.com/documentation/templates_python/#inclusio...
> > >
> > > You can just create a custom calendar control and then use that
> > > new tag in your HTML--much like one might drop a control in a GUI
> > > editor.
> > >
> > > -tim
> >
> >
> > >
> >
> 
> > 


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



Re: Simple Template Dict Problem

2007-06-18 Thread Aidas Bendoraitis

Hello Trey!

You can iterate by the entries of a dictionary, using this:

{% for i in d.items %}
 {{ i.0 }}: {{ i.1 }}
{% endfor %}

Regards,
Aidas Bendoraitis aka Archatas



On 6/7/07, Trey <[EMAIL PROTECTED]> wrote:
>
> Thanks Russ, I think my answer for today is three dimensional lists...
> Hooray for complex datastructures :)
>
> Tim, that's a very cool idea. I will research this some and see if I
> can abstract the calendar control.
>
> On Jun 7, 11:02 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > > Somehow I doubt this should really be in the view either. Maybe it's
> > > just one of those out liers that doesn't have a good place.
> >
> > Sounds like you're describing template tags.  They're ways of
> > creating reusable bits you can just drop into your templates to
> > abstract away the logic required to build them.
> >
> > http://www.djangoproject.com/documentation/templates_python/#writing-...
> >
> > particularly, the sections on simple tags and inclusion tags:
> >
> > http://www.djangoproject.com/documentation/templates_python/#shortcut...http://www.djangoproject.com/documentation/templates_python/#inclusio...
> >
> > You can just create a custom calendar control and then use that
> > new tag in your HTML--much like one might drop a control in a GUI
> > editor.
> >
> > -tim
>
>
> >
>

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



Re: User profile views - Does something like this make sense?

2007-06-18 Thread Gábor Farkas

zenx wrote:
> I want to show the user the latest users that have seen his profile.
> So everytime a logged user views another user's profile a ProfieView
> object is stored in the database (or the date is updated if the user
> that is viewing the profile has already viewed it before). I know this
> can make the database grow too much, so I think I can run a cron
> script daily that deletes all profile views older than a week (see
> clear_old method). I don't know if the code is 100% correct, but is
> the concept ok? Does it make sense to add a new object to the database
> everytime another user views a profile?
> 
> 
> class ProfileViews(models.Model):
> user = models.ForeignKey(User,related_name='latest_profile_views')
> viewer = models.ForeignKey(User)
> date = models.DateTimeField()
> 
> def clear_old(self):
> d = datetime.now()-timedelta(weeks=1)
> p = ProfileViews.objects.filter(date__lte=d)
> p.delete()
> 

i think this approach makes sense.

the only change i would recommend is to make "clear_old" into a static 
method.


gabor

--~--~-~--~~~---~--~~
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: Problems with running Django on a remote machine

2007-06-18 Thread Dirk van Oosterbosch, IR labs


On 15-jun-2007, at 0:18, Malcolm Tredinnick wrote:

>
> On Thu, 2007-06-14 at 16:37 +0200, Dirk van Oosterbosch, IR labs  
> wrote:
> [...]
>>
>> Exactly. It runs untill I try to load a page (from another ssh  
>> shell).
>> And I just get the prompt back:
>
> [...]
> So maybe shove some debug prints in handle(), but, in general, you're
> going to have to try to work out how far it gets before stopping. I
> cannot imagine what is going wrong here. The whole silent failure  
> bit is
> confusing.


Indeed, it is very confusing. This is as it gets before stopping:

(basehttp.py, run() method of ServerHandler class, line 271)
try:
self.setup_environ()

The server hangs on the next line, 272:
self.result = application(self.environ, self.start_response)
and just exits, without even getting to the except:


Any ideas? What would the next step to debug this?

(Note: I'm now trying to get the runserver going from an empty  
('python-admin.py startproject mysite') project, just to be sure the  
error is not somewhere in my code (the one I tested successfully on  
my PowerBook)

best
dirk



--~--~-~--~~~---~--~~
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: CSS on dev server, same old problem

2007-06-18 Thread AnaReis

It works Thank you so much! :D


On Jun 18, 10:52 am, Vincent Nijs <[EMAIL PROTECTED]>
wrote:
> I think it should work if you use:
>
> (r'^appsmedia/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/nobackup/reis/Project/Manager/templates/
> appsmedia'}),
>
> On the template:
> 
>
> Or
>
> (r'^manager/appsmedia/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/nobackup/reis/Project/Manager/templates/
> appsmedia'}),
>
> On the template:
>  href="/manager/appsmedia/css/css1.css" />
>
> This is what I used:
>
> (r'^site_media/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/home/user/django/project/site_media'}),
>
> Works fine.
>
> Vincent
>
> On 6/18/07 3:29 AM, "AnaReis" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jun 15, 5:22 pm, alg <[EMAIL PROTECTED]> wrote:
> >>>  >>> I can see the css files code on the web browser
> >>> through:http://145.23.6.135:8000/manager/appsmedia/css/css1.css
>
> >> You're using an absolute path in the link element's href.
>
> > Hum... How do I use a dynamic path? (Sorry if it's a lame question...)
>
> --
> Vincent R. Nijs
> Assistant Professor of Marketing
> Kellogg School of Management, Northwestern University
> 2001 Sheridan Road, Evanston, IL 60208-2001
> Phone: +1-847-491-4574 Fax: +1-847-491-2498
> E-mail: [EMAIL PROTECTED]
> Skype: vincentnijs


--~--~-~--~~~---~--~~
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: Survey: FileBrowser and FancyUpload

2007-06-18 Thread Dirk van Oosterbosch, IR labs

I think to have a progress bar is a *big* pro, but if Flash could be  
avoided, I would be happy too.

my $0.02
dirk

On 18-jun-2007, at 10:42, patrick k. wrote:

>
> thanks for the feedback so far. I´m just waiting, if there´s more
> feedback.
>
> so far, it´s very clear that the integration of fancyupload is  
> disliked.
>



--~--~-~--~~~---~--~~
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: CSS on dev server, same old problem

2007-06-18 Thread Vincent Nijs

I think it should work if you use:

(r'^appsmedia/(?P.*)$', 'django.views.static.serve',
{'document_root': '/nobackup/reis/Project/Manager/templates/
appsmedia'}),

On the template:


Or

(r'^manager/appsmedia/(?P.*)$', 'django.views.static.serve',
{'document_root': '/nobackup/reis/Project/Manager/templates/
appsmedia'}),

On the template:


This is what I used:

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

Works fine.

Vincent

On 6/18/07 3:29 AM, "AnaReis" <[EMAIL PROTECTED]> wrote:

> 
> 
> 
> On Jun 15, 5:22 pm, alg <[EMAIL PROTECTED]> wrote:
>>> >> I can see the css files code on the web browser
>>> through:http://145.23.6.135:8000/manager/appsmedia/css/css1.css
>> 
>> You're using an absolute path in the link element's href.
> 
> Hum... How do I use a dynamic path? (Sorry if it's a lame question...)
> 
> 
> > 

-- 
Vincent R. Nijs
Assistant Professor of Marketing
Kellogg School of Management, Northwestern University
2001 Sheridan Road, Evanston, IL 60208-2001
Phone: +1-847-491-4574 Fax: +1-847-491-2498
E-mail: [EMAIL PROTECTED]
Skype: vincentnijs




--~--~-~--~~~---~--~~
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: get subversion revision-number in a django-project

2007-06-18 Thread Frank Tegtmeyer

"Joseph Heck" <[EMAIL PROTECTED]> writes:

> generally invoking "svnversion" is the easiest way to get this.

This works only if you are not using an export.
What works there also is keyword replacement (LastChangedRevision).
Unfortunately you have to change the file that tracks the revision
for use in the source code everytime you check something in.

You have to explicitely enable keyword replacement in svn.

Regards, Frank

--~--~-~--~~~---~--~~
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: Survey: FileBrowser and FancyUpload

2007-06-18 Thread patrick k.

thanks for the feedback so far. I´m just waiting, if there´s more  
feedback.

so far, it´s very clear that the integration of fancyupload is disliked.

thanks,
patrick

Am 16.06.2007 um 17:54 schrieb itsnotvalid:

>
> By the way I like the idea of Gmail upload methods too.
> But a flash plugin could do something like "drag 'n drop" file
> uploading which, javascript doesn't seem to cut right now.
> It could be integrated as an option, not a requirement.
>
>
> >


--~--~-~--~~~---~--~~
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: CSS on dev server, same old problem

2007-06-18 Thread AnaReis



On Jun 15, 5:22 pm, alg <[EMAIL PROTECTED]> wrote:
> >  > I can see the css files code on the web browser 
> > through:http://145.23.6.135:8000/manager/appsmedia/css/css1.css
>
> You're using an absolute path in the link element's href.

Hum... How do I use a dynamic path? (Sorry if it's a lame question...)


--~--~-~--~~~---~--~~
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: Bug with regroup ? (which does not regroup as he shoud / I hope...)

2007-06-18 Thread Nicolas Steinmetz

Florian Apolloner a écrit :
> I am not quite sure wheter my answer is correct, as you didn't post
> your view, 

My view is quite simple :

# Display the detail for a given CV
def cv_detail(request, firstname, lastname):
 user = User.objects.get(first_name=firstname, last_name=lastname)
 user_civilstate = user.civilstate_set.all()
 user_summary = user.summary_set.all()
 user_formation = user.formation_set.all()
 user_language = user.language_set.all()
 user_hobby = user.hobby_set.all()
 user_contact = user.contact_set.all()
 user_skill = user.skill_set.all().order_by('domain',)
 user_firm = user.entreprise_set.all().order_by('-start_date',)
 user_experience = user.experience_set.all().order_by('-start_date',)
 user_document = user.document_set.all()
 return render_to_response('cv/cv_detail.html', {'user_civilstate': 
user_civilstate, 'user_summary': user_summary, 'user_formation': 
user_formation, 'user_language': user_language, 'user_hobby': 
user_hobby, 'user_contact': user_contact, 'user_skill': user_skill, 
'user_firm': user_firm, 'user_experience': user_experience, 
'user_document': user_document})
# cv_detail = cache_page(cv_detail, 60 * 60 * 12)

> but I think this is your problem (copy&paste from
> http://www.djangoproject.com/documentation/templates/#regroup):
> Note that {% regroup %} does not work when the list to be grouped is
> not sorted by the key you are grouping by! This means that if your
> list of people was not sorted by gender, you'd need to make sure it is
> sorted before using it, i.e.:
> {% regroup people|dictsort:"gender" by gender as grouped %}

I tried this but the bug persists. Sometimes it works well (technical 
skills are well regrouped by technical domaines) but if I refresh, it's 
no longer the case.

I even tried this on an easier object and it does not work more 
efficiently (user_skill in my view). If I do not add .order_by() in the 
view, and add the |dictsort:"" filter, I have the same bug. If I add the 
order_by() and the dictsort filter, bug remains. It only works well if I 
add the order_by() and remove the dictsort filter.

However for the 1st object on which I had the bug, I cannot sort it in 
my views unless I decompose my model...

Any other clue ?


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