Re: issue with django tagging

2008-12-10 Thread [EMAIL PROTECTED]

thanks
after I imported tagging,the errors is following:
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in 
import tagging
  File "C:\Python25\Lib\site-packages\tagging\__init__.py", line 3, in

from tagging.managers import ModelTaggedItemManager, TagDescriptor
  File "C:\Python25\Lib\site-packages\tagging\managers.py", line 5, in

from django.contrib.contenttypes.models import ContentType
  File "C:\Python25\Lib\site-packages\django\contrib\contenttypes
\models.py", line 1, in 
from django.db import models
  File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 9,
in 
if not settings.DATABASE_ENGINE:
  File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
28, in __getattr__
self._import_settings()
  File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
57, in _import_settings
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

On Dec 10, 12:00 am, Mario <[EMAIL PROTECTED]> wrote:
> Try typing the following:
>
> python manage.py shell
>
> from the python shell, type:
>
> import tagging
> tagging.VERSION
>
> Regards
>
> On Dec 9, 8:24 am, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > hi
> > I got it from trunk,and the version is 0.3. After I installed
> > tagging , I cannot import it. The error information is following:
>
> > Thank you very much
>
> > ---
> > IDLE 1.2.2
>
> > >>> import tagging
>
> > Traceback (most recent call last):
> >   File "<pyshell#0>", line 1, in 
> > import tagging
> >   File "C:\Python25\Lib\site-packages\tagging\__init__.py", line 3, in
> > 
> > from tagging.managers import ModelTaggedItemManager, TagDescriptor
> >   File "C:\Python25\Lib\site-packages\tagging\managers.py", line 5, in
> > 
> > from django.contrib.contenttypes.models import ContentType
> >   File "C:\Python25\Lib\site-packages\django\contrib\contenttypes
> > \models.py", line 1, in 
> > from django.db import models
> >   File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 9,
> > in 
> > if not settings.DATABASE_ENGINE:
> >   File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
> > 28, in __getattr__
> > self._import_settings()
> >   File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
> > 57, in _import_settings
> > raise ImportError("Settings cannot be imported, because
> > environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
> > ImportError: Settings cannot be imported, because environment variable
> > DJANGO_SETTINGS_MODULE is undefined.
--~--~-~--~~~---~--~~
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: issue with django tagging

2008-12-10 Thread [EMAIL PROTECTED]

Thank you very much. I'll try it at once.BTW:when will the 0.3 version
release?
:)

On Dec 10, 12:14 am, garagefan <[EMAIL PROTECTED]> wrote:
> I had the same issue... you need to do two things...
>
> copy this into the setup.py
>
> from django.conf import settings
> settings.configure()
>
> and make sure you have python-devel installed
>
> On Dec 9, 8:24 am, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > hi
> > I got it from trunk,and the version is 0.3. After I installed
> > tagging , I cannot import it. The error information is following:
>
> > Thank you very much
>
> > ---
> > IDLE 1.2.2
>
> > >>> import tagging
>
> > Traceback (most recent call last):
> >   File "<pyshell#0>", line 1, in 
> > import tagging
> >   File "C:\Python25\Lib\site-packages\tagging\__init__.py", line 3, in
> > 
> > from tagging.managers import ModelTaggedItemManager, TagDescriptor
> >   File "C:\Python25\Lib\site-packages\tagging\managers.py", line 5, in
> > 
> > from django.contrib.contenttypes.models import ContentType
> >   File "C:\Python25\Lib\site-packages\django\contrib\contenttypes
> > \models.py", line 1, in 
> > from django.db import models
> >   File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 9,
> > in 
> > if not settings.DATABASE_ENGINE:
> >   File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
> > 28, in __getattr__
> > self._import_settings()
> >   File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
> > 57, in _import_settings
> > raise ImportError("Settings cannot be imported, because
> > environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
> > ImportError: Settings cannot be imported, because environment variable
> > DJANGO_SETTINGS_MODULE is undefined.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



issue with django tagging

2008-12-09 Thread [EMAIL PROTECTED]

hi
I got it from trunk,and the version is 0.3. After I installed
tagging , I cannot import it. The error information is following:

Thank you very much

---
IDLE 1.2.2
>>> import tagging

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in 
import tagging
  File "C:\Python25\Lib\site-packages\tagging\__init__.py", line 3, in

from tagging.managers import ModelTaggedItemManager, TagDescriptor
  File "C:\Python25\Lib\site-packages\tagging\managers.py", line 5, in

from django.contrib.contenttypes.models import ContentType
  File "C:\Python25\Lib\site-packages\django\contrib\contenttypes
\models.py", line 1, in 
from django.db import models
  File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 9,
in 
if not settings.DATABASE_ENGINE:
  File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
28, in __getattr__
self._import_settings()
  File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
57, in _import_settings
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

--~--~-~--~~~---~--~~
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: How to import DoesNotExist exception ???

2008-12-08 Thread [EMAIL PROTECTED]

I'm not sure where you got that code snippet from, but DoesNotExist is
an attribute on model classes, so that shoul read:

except Tag.DoesNotExist.

On Dec 8, 2:52 pm, Info Cascade <[EMAIL PROTECTED]> wrote:
> How do I import the DoesNotExist exception?
>
> This doesn't seem to work:> from django.db.models.query import DoesNotExist
> > try:
> >     tag = Tag.objects.get(name=cat_name)
> > except DoesNotExist:
> >     # do something else
>
> Doesn't DoesNotExist exist?
--~--~-~--~~~---~--~~
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: Ruby on Rails vs Django

2008-12-05 Thread [EMAIL PROTECTED]

I worked with Rails for about 2 years.
I see a lot of innovative ideas in Rails; however, I was constantly
running into issues with them changing the API.
Add to that, the documentation is poor relative to that of Python
Django.

Metaphorically that Python/Djangois for a conservative engineer
mindset, Rails is for a hacker and let's create something innovative
crowd.
Rails does a lot of stuff implicitly, which is fine if you understand
what's going or if no issues rrise.
Python is explicit by design.

Both are Great, but I always felt I was forced to learn something new.
I like learning new things, but sometime you just want to build
something from tools you already understand.

YMMV,
Bryan
p.s. I have not worked with Python3k. That will be a change, but it's
a big number change.

On Dec 5, 8:30 am, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 5 déc, 13:06, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Hi All,
>
> > I'm new to the django world and I was just wondering how Django
> > compears with  Ruby on Rails ?
>
> Mostly just like Python compares with (with ??? to ???) Ruby IMHO.
> Quite close overall, and yet very different philosophies.

--~--~-~--~~~---~--~~
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: Ruby on Rails vs Django

2008-12-05 Thread [EMAIL PROTECTED]

yes... I saw that thread... but it is 14 months old !!! and in IT 14
months is a LOT

On 5 dic, 10:17, "Marinho Brandao" <[EMAIL PROTECTED]> wrote:
> http://www.google.com.br/search?q=Ruby+on+Rails+vs+Django
>
> 2008/12/5 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
>
> > Hi All,
>
> > I'm new to the django world and I was just wondering how Django
> > compears with  Ruby on Rails ?
>
> > did anybody try Ruby on Rails so can give us a feedback ?
>
> > thanks
>
> --
> Marinho Brandão (José Mário)http://marinhobrandao.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
-~--~~~~--~~--~--~---



Ruby on Rails vs Django

2008-12-05 Thread [EMAIL PROTECTED]

Hi All,

I'm new to the django world and I was just wondering how Django
compears with  Ruby on Rails ?

did anybody try Ruby on Rails so can give us a feedback ?

thanks

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



Re: More User/Profile troubles

2008-12-04 Thread [EMAIL PROTECTED]

Ah that did it. The other thing I was doing wrong, the reason all the
different things i was trying didnt get me anywhere- I hadnt run
syncdb when I should of. That stupid mistake wasted a lot of time..
Its taken a while but it appears to be working perfectly now! Thanks
for your help.
Phil

On 4 Dec, 18:17, Brian Neal <[EMAIL PROTECTED]> wrote:
> On Dec 4, 11:08 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:> I apologise for spamming everyone, here i stuck it up at dpaste with
> > the comments which makes it a bit clearer-http://dpaste.com/96128/
>
> You are almost there. You are assigning a form instance to your custom
> profile's user foreign key. That is not what you want. You want to
> assign the appropriate user instance to that foreign key field.
>
> Instead of:
> extraformedit.user = userformInstance
>
> Try this:
> extraformedit.user = request.user
> or
> extraformedit.user = userforminstance.user
>
> Another suggestion: you probably need to check to see if both forms
> are valid before going ahead with the saving.
>
> if form.is_valid() and extraform.is_valid():
>
> I recently did something similiar, I found my code and dpasted it. In
> my case I am showing the view for a user to edit her existing profile.
> I hope it helps:http://dpaste.com/96150/
--~--~-~--~~~---~--~~
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: More User/Profile troubles

2008-12-04 Thread [EMAIL PROTECTED]

I apologise for spamming everyone, here i stuck it up at dpaste with
the comments which makes it a bit clearer-
http://dpaste.com/96128/

On 4 Dec, 17:01, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I dont know why the margins are squashing everything, ill try and post
> my code again this time without the comments
>
>     if request.method == 'POST':
>         form = UserCreationForm(request.POST)
>         extraform =  CustomProfileForm(request.POST)
>         if form.is_valid():
>             userformInstance = form.save()
>             extraformedit = extraform.save(commit=False)
>             extraformedit.user = userformInstance
>             extraformedit.save()
>             return HttpResponseRedirect("/")
>
> Hope that works a bit better.
>
> On 4 Dec, 16:57, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Thanks for your help Brian, Im still quite confused. I think what Im
> > really not sure about is how to set the foreignkey manually as it
> > doesnt really talk about that in the documentation.
>
> > Here is what I have now, if extraformedit.user is a foreignkey, how do
> > i connect it to the form I just saved?-
>
> >     if request.method == 'POST':
> >         form = UserCreationForm(request.POST)
> >         extraform =  CustomProfileForm(request.POST)
> >         if form.is_valid():
> >             userformInstance = form.save
> > ()                                #save the form with the user data
> > and create an instance i can hook my profile to
> >             extraformedit = extraform.save(commit=False)
> > #save the profile form with commit=false so i can modify it
> >             extraformedit.user = userformInstance
> > #!!i think this is where im going wrong? assigning the user the
> > profile is attached to
> >             extraformedit.save
> > ()                                                 #save the edited
> > form to the database.
> >             return HttpResponseRedirect("/")
>
> > Am I way off? Again I am very new to this so sorry if this is a stupid
> > question.
>
> > Phil
>
> > On 3 Dec, 18:52, Brian Neal <[EMAIL PROTECTED]> wrote:
>
> > > On Dec 3, 12:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > ...
> > > > And here is my view for my signup page -
>
> > > > def signup(request):
> > > >     if request.method == 'POST':
> > > >         form = UserCreationForm(request.POST)
> > > >         extraform =  CustomProfileForm(request.POST)
> > > >         if form.is_valid():
> > > >             form.save()
> > > >             extraform.save()
> > > >             return HttpResponseRedirect("/")
> > > >     else:
> > > >         form = UserCreationForm()
> > > >         extraform =  CustomProfileForm()
>
> > > >     return render_to_response('signup.html', {
> > > >         'form': form,
> > > >         'extraform': extraform
> > > >     })
>
> > > > This view doesnt work because it is not saving 'user' in
> > > > CustomProfileForm.
>
> > > > Ok now the problem I am having is with the foreignkey in the custom
> > > > profile model, and successfully linking that to the User.
>
> > > Yes. You need to set the user foreign key inside the extraform before
> > > you save it. See the discussion here about ModelForms save() with
> > > commit=False:
>
> > >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
--~--~-~--~~~---~--~~
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: More User/Profile troubles

2008-12-04 Thread [EMAIL PROTECTED]

I dont know why the margins are squashing everything, ill try and post
my code again this time without the comments

if request.method == 'POST':
form = UserCreationForm(request.POST)
extraform =  CustomProfileForm(request.POST)
if form.is_valid():
userformInstance = form.save()
extraformedit = extraform.save(commit=False)
extraformedit.user = userformInstance
extraformedit.save()
return HttpResponseRedirect("/")

Hope that works a bit better.

On 4 Dec, 16:57, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Thanks for your help Brian, Im still quite confused. I think what Im
> really not sure about is how to set the foreignkey manually as it
> doesnt really talk about that in the documentation.
>
> Here is what I have now, if extraformedit.user is a foreignkey, how do
> i connect it to the form I just saved?-
>
>     if request.method == 'POST':
>         form = UserCreationForm(request.POST)
>         extraform =  CustomProfileForm(request.POST)
>         if form.is_valid():
>             userformInstance = form.save
> ()                                #save the form with the user data
> and create an instance i can hook my profile to
>             extraformedit = extraform.save(commit=False)
> #save the profile form with commit=false so i can modify it
>             extraformedit.user = userformInstance
> #!!i think this is where im going wrong? assigning the user the
> profile is attached to
>             extraformedit.save
> ()                                                 #save the edited
> form to the database.
>             return HttpResponseRedirect("/")
>
> Am I way off? Again I am very new to this so sorry if this is a stupid
> question.
>
> Phil
>
> On 3 Dec, 18:52, Brian Neal <[EMAIL PROTECTED]> wrote:
>
> > On Dec 3, 12:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
>
> > > ...
> > > And here is my view for my signup page -
>
> > > def signup(request):
> > >     if request.method == 'POST':
> > >         form = UserCreationForm(request.POST)
> > >         extraform =  CustomProfileForm(request.POST)
> > >         if form.is_valid():
> > >             form.save()
> > >             extraform.save()
> > >             return HttpResponseRedirect("/")
> > >     else:
> > >         form = UserCreationForm()
> > >         extraform =  CustomProfileForm()
>
> > >     return render_to_response('signup.html', {
> > >         'form': form,
> > >         'extraform': extraform
> > >     })
>
> > > This view doesnt work because it is not saving 'user' in
> > > CustomProfileForm.
>
> > > Ok now the problem I am having is with the foreignkey in the custom
> > > profile model, and successfully linking that to the User.
>
> > Yes. You need to set the user foreign key inside the extraform before
> > you save it. See the discussion here about ModelForms save() with
> > commit=False:
>
> >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
--~--~-~--~~~---~--~~
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: More User/Profile troubles

2008-12-04 Thread [EMAIL PROTECTED]

Thanks for your help Brian, Im still quite confused. I think what Im
really not sure about is how to set the foreignkey manually as it
doesnt really talk about that in the documentation.

Here is what I have now, if extraformedit.user is a foreignkey, how do
i connect it to the form I just saved?-

if request.method == 'POST':
form = UserCreationForm(request.POST)
extraform =  CustomProfileForm(request.POST)
if form.is_valid():
userformInstance = form.save
()#save the form with the user data
and create an instance i can hook my profile to
extraformedit = extraform.save(commit=False)
#save the profile form with commit=false so i can modify it
extraformedit.user = userformInstance
#!!i think this is where im going wrong? assigning the user the
profile is attached to
extraformedit.save
() #save the edited
form to the database.
return HttpResponseRedirect("/")

Am I way off? Again I am very new to this so sorry if this is a stupid
question.

Phil


On 3 Dec, 18:52, Brian Neal <[EMAIL PROTECTED]> wrote:
> On Dec 3, 12:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > ...
> > And here is my view for my signup page -
>
> > def signup(request):
> >     if request.method == 'POST':
> >         form = UserCreationForm(request.POST)
> >         extraform =  CustomProfileForm(request.POST)
> >         if form.is_valid():
> >             form.save()
> >             extraform.save()
> >             return HttpResponseRedirect("/")
> >     else:
> >         form = UserCreationForm()
> >         extraform =  CustomProfileForm()
>
> >     return render_to_response('signup.html', {
> >         'form': form,
> >         'extraform': extraform
> >     })
>
> > This view doesnt work because it is not saving 'user' in
> > CustomProfileForm.
>
> > Ok now the problem I am having is with the foreignkey in the custom
> > profile model, and successfully linking that to the User.
>
> Yes. You need to set the user foreign key inside the extraform before
> you save it. See the discussion here about ModelForms save() with
> commit=False:
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



More User/Profile troubles

2008-12-03 Thread [EMAIL PROTECTED]

Hi all,
I have another newbie question. The user registration + profiles seems
to always be giving me a lot of trouble, I think Im nearly there but
Im sort of stuck at the moment and not sure how to proceed. I am
having trouble setting a user profile that is hooked up to the user
all in one page.

Ive set up a custom profile for my users, here is the model with a
form-

class CustomProfile(models.Model):
user = models.ForeignKey(User, unique=True)

GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
birthday = models.DateField()
country = models.CharField(max_length=50)

class CustomProfileForm(ModelForm):
class Meta:
model = CustomProfile
fields = ('gender', 'birthday', 'country')



And here is my view for my signup page -

def signup(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
extraform =  CustomProfileForm(request.POST)
if form.is_valid():
form.save()
extraform.save()
return HttpResponseRedirect("/")
else:
form = UserCreationForm()
extraform =  CustomProfileForm()

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

This view doesnt work because it is not saving 'user' in
CustomProfileForm.

Ok now the problem I am having is with the foreignkey in the custom
profile model, and successfully linking that to the User. I imagine I
could do it easily with two web pages - I would make a
usercreationform on one page and then direct to a page to customise a
profile, but I am trying to do it all at once. I have to save 'form'
first, to be able to save 'extraform', but then I dont know how to set
the user setting in extraform to the one ive just created. All my
configurations seem to fail.

I hope I havent made this too confusing, am I on the right track at
least? Any help Would be great!
Phil
--~--~-~--~~~---~--~~
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: Disappearing inline in admin

2008-12-03 Thread [EMAIL PROTECTED]



On Dec 3, 10:49 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
>  When I go to Article, the sections are there, inline, as they should
> be. When I SAVE, all the sections disappear. Suggestions?

Turns out there was a unicode error in the inline. Maybe it will help
someone else somewhere down the line.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Disappearing inline in admin

2008-12-03 Thread [EMAIL PROTECTED]

Very strange. This is the admin for the model:

from django.contrib import admin
from articles.models import *

class SectionInline(admin.StackedInline):
model = section

class ArticleAdmin(admin.ModelAdmin):
model=Article
filter_horizontal = ('related_articles',)
prepopulated_fields = {'slug': ('title',)}
search_fields = ['author__username','main_section','title']
list_display = ('title', 'author','slug',
'created','issue','publication',)
list_filter = ('created','last_modified','sites','publication',)
radio_fields = {'publication': admin.VERTICAL}
inlines = [
SectionInline,
]
admin.site.register(Article, ArticleAdmin)

Pretty straightforward. Only thing unusual I'm seeing is that I didn't
capitalize the Section class (it's not capped in the model, either).
When I go to Article, the sections are there, inline, as they should
be. When I SAVE, all the sections disappear. Suggestions?
--~--~-~--~~~---~--~~
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: Query API: get all users without a group

2008-12-02 Thread [EMAIL PROTECTED]

You could do User.objects.exclude(groups__in=Group.objects.all
().query) which will actually generate a subquery.

Alex

On Dec 2, 10:45 am, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to get all objects where the corresponding many-to-many field is
> empty.
>
> Example:  get all users without a group
>
> My solution:
>    User.objects.exclude(groups__in=Group.objects.all())
>
> I think this is not optimal, since Group.objects.all() gets evaluated.
>
> Resulting SQL:
>
> SELECT "auth_user"."id", "auth_user"."username",
>     "auth_user"."first_name", "auth_user"."last_name",
> "auth_user"."email", "auth_user"."password", "auth_user"."is_staff",
>     "auth_user"."is_active", "auth_user"."is_superuser",
> "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user" WHERE
>     NOT ("auth_user"."id" IN (SELECT U1."user_id" FROM "auth_user" U0
> INNER JOIN "auth_user_groups" U1 ON (U0."id" = U1."user_id")
>     WHERE U1."group_id" IN (9, 10, 11, 8))) LIMIT 21
>
> Any better way to do this?
>
> Should the extra() method be used for this?
>
>   Thomas
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
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: dynamic associations?

2008-11-29 Thread [EMAIL PROTECTED]

> Ah, yes, I fell back on the add() function only because setattr wasn't
> doing what I needed it to do.  I know I am getting the DoesNotExist
> exception because the related model doesn't exist, but that's the
> problem entirely: I have no way to pass an argument to setattr because
> getattr raises this exception, and it's not going to exist until I
> call
>
> mymodel.some_relation_or_fk = related_model
>
> This is the problem, because I don't know the name of the attribute
> being used to define some_relation_or_fk.  However, since the
> attribute that defines the relation seems to be a property, any
> reference to it acts like a call to a get_function itself, which
> raises the error.  So, given two model instances as per my previous
> post:


Slightly different situation, I think, but I was getting the same
error.

And in my case, when I retrieved an object and a foreign key reference
in the object was NULL, it gave me this error.

What I needed to do was edit the models.py definitions and add a
"null=TRUE" attribute to the Foreign key.

It stopped the exception being thrown then.

Not sure if you did the same to all the Foreign key references for
that object  that your attribute can potentially be would solve your
problem.

Anyway, hope this helps.
- Chai



--~--~-~--~~~---~--~~
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: adding with ORM is slow

2008-11-28 Thread [EMAIL PROTECTED]

Ah, you're correct, not sure what I was thinking of.

Alex

On Nov 28, 9:35 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-11-28 at 18:26 -0800, [EMAIL PROTECTED] wrote:
> > Can you try doing Country.objects.create(name=name) instead?
>
> Have a look at the implementation of create(). It's not some kind of
> secret sauce. It's a shortcut. We could remove it from Django and
> nothing would be slower or less functional.
>
> 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: Raw SQL and model instances

2008-11-28 Thread [EMAIL PROTECTED]

Malcolm, I believe that should be params = dict(zip(fields, row))

On Nov 28, 8:34 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-11-28 at 19:54 +0900, Russell Keith-Magee wrote:
>
> [...]
>
> > >>> cursor.execute('SELECT ...')
> > >>> row = cursor.fetchone()
> > >>> a = Author(*row)
>
> > At this point, a will be a fully populated Author instance,
> > indistinguishable from one retrieved using a queryset.
>
> > The caveat on this technique is that the SELECT you execute using the
> > cursor to obtain the row must contain all the columns in your model,
> > specified in the same order that your model defines them. This
> > includes the auto-added id column, if appropriate. If you're uncertain
> > which fields will be required, and in what order, Author._meta.fields
> > contains the list that Django will expect.
>
> If you only have a subset of the fields, or if they aren't in the
> expected order, you can also supply the values as keyword argument
> parameters to the model initialisation function. Zip up the values with
> the names of the parameters they represent and pass that in:
>
>         fields = ('name', 'age', 'data')
>         results = []
>         for row in cursor.fetchall():
>            params = zip(fields, row)
>            results.append(Author(**params)
>
> 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: adding with ORM is slow

2008-11-28 Thread [EMAIL PROTECTED]

Can you try doing Country.objects.create(name=name) instead?

On Nov 28, 8:50 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-11-28 at 08:40 -0800, burb wrote:
>
> [...]
>
> > Code with cursor runs 100x faster than ORM code.
>
> [...]
>
> > this is 5x faster than work with ORM.
>
> > Where am I doing mistake in using Django ORM?
>
> The only mistake is assuming the ORM should be as fast as that raw SQL.
> The ORM is doing a lot more work (for a start, there's some transaction
> handling in there, as well as creating a bunch of Python objects). If
> you need to mass inserts, using the ORM is not going to be the fastest
> way. That's fine -- Django's ORM isn't designed to ever be a 100%
> replacement for interacting directly with the database in all
> circumstances.
>
> For creating a single object or a small group, using the ORM is fine,
> since the extra overhead is negligible when compared to all the other
> time consumed in a request/response cycle. If you subsequently need to
> work with the objects as Python objects, using the ORM for creatinv even
> a large number (using manual transaction control) *might* be worthwhile,
> but I would time it if I was doing this. It might be better to do the
> inserts using raw SQL and then use a single queryset to pull back the
> results into Python, too.
>
> So there's no problem here. You're just using the ORM to do a task it
> isn't particularly designed for. It's not that common for a website to
> need to do 100's of inserts all at once, for example. Perfectly
> acceptable to use raw SQL when you need to do that.
>
> 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
-~--~~~~--~~--~--~---



new comments and ratings

2008-11-28 Thread [EMAIL PROTECTED]

I'm afraid my reality belies the blithe comment in the docs that the
removal of ratings should only affect World Online. For those of us
who *were* using ratings, is there some recommended way for bringing
ratings back?

I have django-voting, but what I need is the old comment-style 1-5
ratings on multiple categories.
--~--~-~--~~~---~--~~
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: Address Book Contact Importer in Python/Django?

2008-11-27 Thread [EMAIL PROTECTED]

Thanks guys, I've had a think about your security points Jarek. I
guess it's a tough decision to make... :-\

On Nov 27, 11:47 am, Brot <[EMAIL PROTECTED]> wrote:
> does this help
> Accessing your Gmail contact list with Python (http://www.holovaty.com/
> blog/archive/2004/06/20/0241)
>
> [EMAIL PROTECTED] schrieb:
>
> > Hi guys,
>
> > Does anybody know of a Python script or Django module that can handle
> > address book email importing? For instance, if I type my gmail email
> > and password it will then fetch all of the email addresses. I know of
> > plenty of paid PHP scripts around that allow gmail, hotmail, aol etc.
> > Is there an equivalent in Python?
>
> > Thanks,
>
> > Mike.
--~--~-~--~~~---~--~~
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 1.0 tutorial

2008-11-27 Thread [EMAIL PROTECTED]

checkout this

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

> I am trying to create a blog using django 1.0 and wan't to know how to
> us the forms engine of django 1.
> Is there a good tutorial which uses the advantage of the forms
> library.
>
> I checked the docs but the example provided is not clear.

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



Address Book Contact Importer in Python/Django?

2008-11-27 Thread [EMAIL PROTECTED]

Hi guys,

Does anybody know of a Python script or Django module that can handle
address book email importing? For instance, if I type my gmail email
and password it will then fetch all of the email addresses. I know of
plenty of paid PHP scripts around that allow gmail, hotmail, aol etc.
Is there an equivalent in Python?

Thanks,

Mike.
--~--~-~--~~~---~--~~
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: Caching and I18n

2008-11-25 Thread [EMAIL PROTECTED]

Hello Aloy,

I saw the great work you did on ticket #5691. Thanks a lot, I highly
appreciate that! We have to offer our first release with the bug, but
I hope to be able to include your patch or a workaround for the next
one and will give feedback once that's been done.

With regards,
Maik
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



path issue

2008-11-24 Thread [EMAIL PROTECTED]

Hey -
I'm coming from a c background into this - more or less a newbie to
the python/django environment.

That said - I have an issue with paths and mod_python that I can't
seem to resolve.

I have the following directory structure
django_project/
  __init.py__
  manage.py , etc 
  apps/
  __init.py__
  myapp/
__init.py__
views.py
models.py
templatetags/
   __init.py__, etc ...
templates/
   __init.py__, etc...

When I run the app using fastcgi there are no problems, and everything
works just fine
but when I run it with mod_python I get the following error:

global name 'apps' is not defined
the error references a line inside views.py
the import that its complaining about is
from django_project.apps.myapp.models import ModelOne, ModelTwo,
ModelThree

my httpd.conf looks like

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE django_project.settings
PythonPath "['/var/www/webapps/django_project','/var/www/lib/
python2.5'] + sys.path"
PythonOption django.root /django_project


I've tried a number of things, but nothing seems to be resolving the
issue.
Maybe someone else has run into this.

--~--~-~--~~~---~--~~
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: redirection 2 links back after signing up?

2008-11-23 Thread [EMAIL PROTECTED]

btw this requires that you use render_to_response with the 3rd
argument, context_instance=RequestContext(request)

see docs.
http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs

session docs
http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-http-sessions

On Nov 23, 9:51 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I just solved this issue. I did by using using sessions.
>
> I initialize this in a couple of views.
>
> request.session['last'] = request.get_full_path()
>
> If a user tries to do something restricted it requires them to login
> which I do the same exact way you do.
>
> After they login they get redirected to what is specified in next..
> fill out a form, yada yada yada.
> after success of that I then do this.
>
> return HttpResponseRedirect(request.session['last'])
>
> hope this helps.
>
> On Nov 5, 11:08 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > That is the problem I am trying to solve.
>
> > Basically, the restricted area isn't static. A user could be viewing
> > any number of dynamic pages protected by a sign in page.
>
> > If it were simply a static page, it would be trivial to do: return
> > HttpResponseRedirect("/static_page/")
>
> > The ?next= argument is only used by django's automatic sign-in code.
> > I'm not even sure how I could use it myself. Do you have any ideas
> > what I should try?
>
> > Basically:
>
> > 1) every potential page that has its access restricted must be able to
> > pass the current path along to the login page
> > 2) The login page needs to send along the same path to the
> > create_account page if it is clicked. If it is not clicked, then we
> > will return to the current page and no extra code is needed.
> > 3) The create account page can now return
> > HttpResponseRedirect(previousPath)
>
> > What is the best way to do this?
--~--~-~--~~~---~--~----~
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: redirection 2 links back after signing up?

2008-11-23 Thread [EMAIL PROTECTED]

I just solved this issue. I did by using using sessions.

I initialize this in a couple of views.

request.session['last'] = request.get_full_path()

If a user tries to do something restricted it requires them to login
which I do the same exact way you do.

After they login they get redirected to what is specified in next..
fill out a form, yada yada yada.
after success of that I then do this.

return HttpResponseRedirect(request.session['last'])

hope this helps.

On Nov 5, 11:08 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> That is the problem I am trying to solve.
>
> Basically, the restricted area isn't static. A user could be viewing
> any number of dynamic pages protected by a sign in page.
>
> If it were simply a static page, it would be trivial to do: return
> HttpResponseRedirect("/static_page/")
>
> The ?next= argument is only used by django's automatic sign-in code.
> I'm not even sure how I could use it myself. Do you have any ideas
> what I should try?
>
> Basically:
>
> 1) every potential page that has its access restricted must be able to
> pass the current path along to the login page
> 2) The login page needs to send along the same path to the
> create_account page if it is clicked. If it is not clicked, then we
> will return to the current page and no extra code is needed.
> 3) The create account page can now return
> HttpResponseRedirect(previousPath)
>
> What is the best way to do this?
--~--~-~--~~~---~--~~
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: help, ORM memory problems

2008-11-23 Thread [EMAIL PROTECTED]

Try doing Legacy.objects.all().iterator(), this isn't technically the
public API, but this grabs the results at a lower level, so it doesn't
get cached.

On Nov 23, 5:44 pm, derek73 <[EMAIL PROTECTED]> wrote:
> I have written a management script to migrate data from an existing
> site into our new Django-powered site. The script runs fine with one
> exception, memory consumption. A few of the tables I need to migrate
> have around 250,000 records, and it seems that the Django ORM caches
> each record in memory as it migrates each record.
>
> I have been able to work around it by only migrating about 50,000
> records at a time. By the time it reaches 50,000 records the python
> process has consumed about 2 GB of RAM. If I let the process end,
> python releases all that RAM, then I start a new management command
> with the next set of 50,000.
>
> It seems there's probably a better way to manage this memory problem
> but I'm a bit of a Python/Django newb. Any insight would be greatly
> appreciated. I'm running the migration script on my MacBookPro with
> 2GB of RAM and 30GB free HD at the moment.
>
> Here's an example of how I've set up my migration script. I cycle over
> the ids cause when I tried to do "for row in Legacy.objects.all():" it
> tried to swap out like 8GB of RAM then died.
>
> ids = [x[0] for x in Legacy.objects.order_by('time').values_list('id')
> [0:5]]
> for row_id in ids:
>   row = Legacy.objects.get(id=row_id)
>   new = ShinyNewObj()
>   new.stuff = row.oldstuff
>   new.save()
>
> And here's the error I get when it runs out of memory:
>
> -
>
> --> Importing #172000 id:172000 date:'2008-11-06 10:19:49'
> Python(4125) malloc: *** mmap(size=16777216) failed (error code=12)
> *** error: can't allocate region
>   File "manage.py", line 27, in 
>     execute_from_command_line()
>   File "/Library/Python/2.5/site-packages/django/core/management/
> __init__.py", line 331, in execute_from_command_line
>     utility.execute()
>   File "/Library/Python/2.5/site-packages/django/core/management/
> __init__.py", line 295, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/Library/Python/2.5/site-packages/django/core/management/
> base.py", line 77, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/Library/Python/2.5/site-packages/django/core/management/
> base.py", line 96, in execute
>     output = self.handle(*args, **options)
>   File "/Library/Python/2.5/site-packages/django/core/management/
> base.py", line 178, in handle
>     return self.handle_noargs(**options)
>   File "/Users/derek/projects/my_project/apps/legacy/management/
> commands/migrate_legacy.py", line 161, in handle_noargs
>     obj._save()
>   File "/Users/derek/projects/my_project/apps/ShinyNew/models.py",
> line 286, in _save
>     super(ShinyNew, self).save(**kwargs)
>   File "/Library/Python/2.5/site-packages/django/db/models/base.py",
> line 307, in save
>     self.save_base(force_insert=force_insert,
> force_update=force_update)
>   File "/Library/Python/2.5/site-packages/django/db/models/base.py",
> line 354, in save_base
>     manager.filter(pk=pk_val).extra(select={'a': 1}).values
> ('a').order_by())):
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 185, in __nonzero__
>     iter(self).next()
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 179, in _result_iter
>     self._fill_cache()
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 612, in _fill_cache
>     self._result_cache.append(self._iter.next())
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 653, in iterator
>     for row in self.query.results_iter():
>   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> query.py", line 206, in results_iter
>     for rows in self.execute_sql(MULTI):
>   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> query.py", line 1700, in execute_sql
>     cursor.execute(sql, params)
>   File "/Library/Python/2.5/site-packages/django/db/backends/util.py",
> line 19, in execute
>     return self.cursor.execute(sql, params)
>   File "/Library/Python/2.5/site-packages/django/db/backends/mysql/
> base.py", line 83, in execute
>     return self.cursor.execute(query, args)
>   File "build/bdist.macosx-10.5-i386/egg/MySQLdb/cursors.py", line
> 166, in execute
>   File "build/bdist.macosx-10.5-i386/egg/MySQLdb/connections.py", line
> 35, in defaulterrorhandler
> _mysql_exceptions.InterfaceError: (0, '')
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



UnicodeEncodeError using mysql as db

2008-11-23 Thread [EMAIL PROTECTED]

Hello,

I'm one of the developers of Rancho (www.getrancho.com)

One of our users reported a problem using mysql and unicode with we
haven't been able to solve.

Here is the traceback: http://dpaste.com/93163/

Any help is appreciated.

Best regards,

Luis
--~--~-~--~~~---~--~~
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: 'QuerySet' object has no attribute '_meta'

2008-11-21 Thread [EMAIL PROTECTED]

You can pass modelformset_factory a kwarg form which should just me
the form class you want to use(aka make a ModelForm with the changes
to the widgets).

Alex

On Nov 21, 7:25 pm, ayayalar <[EMAIL PROTECTED]> wrote:
> Karen,
>
> On this note, is it possible to customize the widget's for formsets as
> well?
>
> Thank you.
>
> On Nov 21, 3:23 pm, ayayalar <[EMAIL PROTECTED]> wrote:
>
> > Thanks Karen. That's exactly the case. Link you provided very helpful.
>
> > On Nov 21, 3:00 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > > On Fri, Nov 21, 2008 at 4:22 PM, ayayalar <[EMAIL PROTECTED]> wrote:
>
> > > > I am just simply trying to display all existing objects in a form
>
> > > > MODEL:
> > > > class Product(models.Model):
> > > >    name = models.CharField(max_length=30)
>
> > > >    def __unicode__(self):
> > > >        return self.name
>
> > > > VIEW
> > > > def product(request):
> > > >    product = Product.objects.all()
> > > >    form = ProductForm(instance=product)
> > > >    return render_to_response('index.html', {'form' : form})
>
> > > > Throws this error:
> > > > =
>
> > > > Environment:
>
> > > > Request Method: GET
> > > > Request URL:http://localhost:8000/product/
> > > > Django Version: 1.0.1 final
> > > > Python Version: 2.5.2
> > > > Installed Applications:
> > > > ['django.contrib.auth',
> > > >  'django.contrib.contenttypes',
> > > >  'django.contrib.sessions',
> > > >  'django.contrib.sites',
> > > >  'demo.home']
> > > > Installed Middleware:
> > > > ('django.middleware.common.CommonMiddleware',
> > > >  'django.contrib.sessions.middleware.SessionMiddleware',
> > > >  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> > > > Traceback:
> > > > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
> > > > get_response
> > > >  86.                 response = callback(request, *callback_args,
> > > > **callback_kwargs)
> > > > File "C:\Django\demo\..\demo\home\views.py" in product
> > > >  10.     form = ProductForm(instance=product)
> > > > File "C:\Python25\Lib\site-packages\django\forms\models.py" in
> > > > __init__
> > > >  216.             object_data = model_to_dict(instance, opts.fields,
> > > > opts.exclude)
> > > > File "C:\Python25\Lib\site-packages\django\forms\models.py" in
> > > > model_to_dict
> > > >  119.     opts = instance._meta
>
> > > > Exception Type: AttributeError at /product/
> > > > Exception Value: 'QuerySet' object has no attribute '_meta'
>
> > > > Any suggestions?
>
> > > You don't show us ProductForm but I can guess it is a ModelForm for
> > > Product.  A ModelForm is designed to display and let you edit one 
> > > individual
> > > object from the DB, not multiple.  Thus the 'instance' parameter to a 
> > > model
> > > form is supposed to be one single instance of a model, not a QuerySet.  A
> > > model formset might be closer to what you are looking for:
>
> > >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#id1
>
> > > Karen
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



New Django user: How do I return the server's IP address?

2008-11-21 Thread [EMAIL PROTECTED]

Where can I get the Host server's IP address?

request.META['SERVER_NAME'] simply returns localhost instead of
whatever my ip address is

Thanks.

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



change in admin template django/contrib/admin/templates/widget

2008-11-21 Thread [EMAIL PROTECTED]

hi all, i am using debian etch stable version 0.95

please i would like to know if there is a way to change admin, when 
displaying link "Currently" in models.BooleanField.
When i have images locally this can be done just by changing urls.py . 
But when i copy this file to another server during saving the model, and 
updated the value in db, it would be nice to have chance to check if the 
image is loaded on the new server via admin for this model. So i was 
thinking about changing django/contrib/admin/templates/widget/file.html 
just to change some values. But i did not succeed.

thank you very much for any idea
pavel

--~--~-~--~~~---~--~~
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: Creating formsets through AJAX

2008-11-20 Thread [EMAIL PROTECTED]

On 20 nov, 14:31, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On 20 nov, 06:54, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Wed, Nov 19, 2008 at 10:23 PM, [EMAIL PROTECTED]
>
> > <[EMAIL PROTECTED]> wrote:
>
> > > On 20 nov, 06:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> > >> On Wed, Nov 19, 2008 at 9:53 PM, [EMAIL PROTECTED]
>
> > >> <[EMAIL PROTECTED]> wrote:
>
> > >> > I use a fake queryset because it's the only way that I found to
> > >> > populate the formset (using a real queryset would lead to the same
> > >> > problem anyway), hence I wonder if there is a cleaner way to do what I
> > >> > want without reinventing modelforms, or using separate form classes
> > >> > for saving and creating my dynamic formsets.
>
> > >> I think from what I gather you are looking to create an "add"-only
> > >> model formset? If so take a look 
> > >> athttp://code.djangoproject.com/ticket/9538. I have written some
> > >> information on that ticket that may be of use to you.
>
> > > Yes I tried the approach you're talking about in the ticket:
>
> > > FormSet = modelformset_factory(SomeModel, extra=3)
>
> > > This creates 3 blank forms with INITIAL_FORMS=0, which is fine. But
> > > then how can I populate this formset with some initial data instead of
> > > the model's default values ?
>
> > Can you file a ticket about this? The fundamental issue here is that
> > formsets use initial data to populate the forms, but model formsets
> > make no distinction between initial data being passed in and initial
> > data it makes via the queryset. It sounds worth fixing.
>
> I think I misunderstood your first post, sorry. I tried to use
> formset_factory with my ModelForm based form :
>
> FormSet = formset_factory(SomeModelForm, extra=0)
> forms = FormSet(initial=[{"field": 1}, {"field": 2}, {"field": 3}])
>
> It works (I thought you _had_ to use modelformset_factory to create
> ModelForm formsets). But then again, I get INITIAL_FORMS=3 in the
> output. If I set extra to 3, I still get INITIAL_FORMS=3, and 3
> additional blank forms, there seems to be no way to populate the extra
> forms with initial data.
>
> So I think a new keyword argument is needed for formset_factory to
> solve this particular issue, perhaps extra_initial ?

Looking closer at the details, the 'id' field is missing when using
formset_factory, which prevents django from saving the formset (I
still use a modelformset_factory based formset on the form's target
view to save the models). Using modelformset_factory is what gives the
closest result to what I want, but something like extra_initial would
make the whole thing way less hackish.

I will try to write a patch and file a ticket about it.
--~--~-~--~~~---~--~~
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: Creating formsets through AJAX

2008-11-20 Thread [EMAIL PROTECTED]

On 20 nov, 06:54, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 10:23 PM, [EMAIL PROTECTED]
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > On 20 nov, 06:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> >> On Wed, Nov 19, 2008 at 9:53 PM, [EMAIL PROTECTED]
>
> >> <[EMAIL PROTECTED]> wrote:
>
> >> > I use a fake queryset because it's the only way that I found to
> >> > populate the formset (using a real queryset would lead to the same
> >> > problem anyway), hence I wonder if there is a cleaner way to do what I
> >> > want without reinventing modelforms, or using separate form classes
> >> > for saving and creating my dynamic formsets.
>
> >> I think from what I gather you are looking to create an "add"-only
> >> model formset? If so take a look 
> >> athttp://code.djangoproject.com/ticket/9538. I have written some
> >> information on that ticket that may be of use to you.
>
> > Yes I tried the approach you're talking about in the ticket:
>
> > FormSet = modelformset_factory(SomeModel, extra=3)
>
> > This creates 3 blank forms with INITIAL_FORMS=0, which is fine. But
> > then how can I populate this formset with some initial data instead of
> > the model's default values ?
>
> Can you file a ticket about this? The fundamental issue here is that
> formsets use initial data to populate the forms, but model formsets
> make no distinction between initial data being passed in and initial
> data it makes via the queryset. It sounds worth fixing.

I think I misunderstood your first post, sorry. I tried to use
formset_factory with my ModelForm based form :

FormSet = formset_factory(SomeModelForm, extra=0)
forms = FormSet(initial=[{"field": 1}, {"field": 2}, {"field": 3}])

It works (I thought you _had_ to use modelformset_factory to create
ModelForm formsets). But then again, I get INITIAL_FORMS=3 in the
output. If I set extra to 3, I still get INITIAL_FORMS=3, and 3
additional blank forms, there seems to be no way to populate the extra
forms with initial data.

So I think a new keyword argument is needed for formset_factory to
solve this particular issue, perhaps extra_initial ?
--~--~-~--~~~---~--~~
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 site within 7 hours (a day)

2008-11-20 Thread [EMAIL PROTECTED]

> I don't think there's a problem on whether it's appropriate for the
> group, but there's already Django Pluggables (http://djangoplugables.com/
> ) as a "django applications hotspot" so the project is a bit redundant
> isn't it?

Django pluggables is ok, but I can't get my applications listed on it
and I can't do releases of applications (version 1.0) of it etc. I was
toying with writing my own thing the other day, so more than happy to
see an alternative. Since I can submit to this application listing, I
welcome it.

Although the submit button at the top doesn't seem to 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-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: Creating formsets through AJAX

2008-11-19 Thread [EMAIL PROTECTED]



On 20 nov, 06:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 9:53 PM, [EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> wrote:
>
> > I use a fake queryset because it's the only way that I found to
> > populate the formset (using a real queryset would lead to the same
> > problem anyway), hence I wonder if there is a cleaner way to do what I
> > want without reinventing modelforms, or using separate form classes
> > for saving and creating my dynamic formsets.
>
> I think from what I gather you are looking to create an "add"-only
> model formset? If so take a look athttp://code.djangoproject.com/ticket/9538. 
> I have written some
> information on that ticket that may be of use to you.
>

Yes I tried the approach you're talking about in the ticket:

FormSet = modelformset_factory(SomeModel, extra=3)

This creates 3 blank forms with INITIAL_FORMS=0, which is fine. But
then how can I populate this formset with some initial data instead of
the model's default values ? As I said:

forms = FormSet(initial=[{"field": 1}, {"field": 2}, {"field": 3}])

Or even:

forms = FormSet(queryset=SomeModel.objects.none(), initial=[{"field":
1}, {"field": 2}, {"field": 3}])

Does not 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-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: Creating formsets through AJAX

2008-11-19 Thread [EMAIL PROTECTED]



On 20 nov, 05:33, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 9:14 PM, [EMAIL PROTECTED]
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > On 20 nov, 05:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> >> On Wed, Nov 19, 2008 at 8:59 PM, Brian Rosner <[EMAIL PROTECTED]> wrote:
> >> > On Wed, Nov 19, 2008 at 8:43 PM, Luper Rouch <[EMAIL PROTECTED]> wrote:
> >> >> For django to save the formset correctly when it is submitted, I have to
> >> >> manually set INITIAL_FORMS to 0 in javascript (because the objects are
> >> >> not really in the database).
>
> >> > It looks like you are trying to shove a square object through a round
> >> > hole. Why are you using a model formset when there is "real" queryset?
> >> > Model formsets are simply a thin layer over formsets. It sounds like
> >> > you need to those to cleanly write your code and not resort to hacking
> >> > a model formset to work without a real queryset.
>
> >> Ugh. That didn't read as well as I hoped :)
>
> >> I meant to ask, why are you using model formsets when there is no
> >> "real" queryset? You should just use formsets.
>
> > django/forms/models.py is 747 lines long, I would not call that a thin
> > layer :)
>
> That file is not just model formset code. In terms of what a model
> formset does, it is thin. It doesn't not change any behavior of a
> regular formset. Just provides the additional layer to hook up with
> models. I still consider that thin ;)
>
>
>
> > I use it because I want to write forms that save models, and avoid
> > duplicating my model structure in the form class. Is'nt it what
> > modelforms are meant for ?
>
> Then why are you not able to pass in a queryset? What data are you
> sending to the server to generate the formset? From the little
> explained code are they just primary keys?

[1, 2, 3] is just some example data, not primary keys (actually I'm
passing dictionaries, but I tried to keep the example code short). It
is used to populate the formset, which is then rendered, inserted in
the page via an AJAX call, and eventually submitted to another view to
save it to the database.

I use a fake queryset because it's the only way that I found to
populate the formset (using a real queryset would lead to the same
problem anyway), hence I wonder if there is a cleaner way to do what I
want without reinventing modelforms, or using separate form classes
for saving and creating my dynamic formsets.
--~--~-~--~~~---~--~~
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: Creating formsets through AJAX

2008-11-19 Thread [EMAIL PROTECTED]

On 20 nov, 05:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 8:59 PM, Brian Rosner <[EMAIL PROTECTED]> wrote:
> > On Wed, Nov 19, 2008 at 8:43 PM, Luper Rouch <[EMAIL PROTECTED]> wrote:
> >> For django to save the formset correctly when it is submitted, I have to
> >> manually set INITIAL_FORMS to 0 in javascript (because the objects are
> >> not really in the database).
>
> > It looks like you are trying to shove a square object through a round
> > hole. Why are you using a model formset when there is "real" queryset?
> > Model formsets are simply a thin layer over formsets. It sounds like
> > you need to those to cleanly write your code and not resort to hacking
> > a model formset to work without a real queryset.
>
> Ugh. That didn't read as well as I hoped :)
>
> I meant to ask, why are you using model formsets when there is no
> "real" queryset? You should just use formsets.
>

django/forms/models.py is 747 lines long, I would not call that a thin
layer :)

I use it because I want to write forms that save models, and avoid
duplicating my model structure in the form class. Is'nt it what
modelforms are meant for ?
--~--~-~--~~~---~--~~
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: serving static file via django

2008-11-18 Thread [EMAIL PROTECTED]

yes..its just a transparent gif...i'm thinking of writing my own view,
which will get the visitor data and then just call the static serve
method provided by django.
just dont know it its ok inproduction env though..

On Nov 19, 12:53 am, "David Zhou" <[EMAIL PROTECTED]> wrote:
> I was initially thinking that if you knew which pages you wanted to
> track, you could capture those requests via signals, rather than via
> requets to a file.
>
> But if it's an explicit requirement to track hits to that file, then
> that wouldn't work.
>
> Is the file a transparent gif that's solely used to track hits?
>
> Is there any reason you can't track your hits in views prior to
> template rendering?
>
>
>
> On Wed, Nov 19, 2008 at 12:34 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > david,
>
> > its a biz requirement for me to track what http requests are being
> > made to this file. used in generating internal metric reports. I guess
> > i'll have to dig into the django code to see how signals are used..do
> > you know of any example where the request_finished signal is used ?
>
> > thanks,
> > -p
>
> > On Nov 18, 10:23 pm, "David Zhou" <[EMAIL PROTECTED]> wrote:
> >> On Tue, Nov 18, 2008 at 9:40 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 
> >> wrote:
>
> >> > david,
>
> >> > can you illustrate how ? sorry -- havent worked with django signals
> >> > earlier
>
> >> I might be misunderstanding your need to track requests to that file,
> >> but if you're using it to track requests in Django in general, you may
> >> be able to do that by using a listening for a request finished signal,
> >> and doing something with it.
>
> >> What are you specifically trying to do by tracking which users
> >> requested the file?
>
> >> --
> >> ---
> >> David Zhou
> >> [EMAIL PROTECTED]
>
> --
> ---
> David Zhou
> [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: serving static file via django

2008-11-18 Thread [EMAIL PROTECTED]

david,

its a biz requirement for me to track what http requests are being
made to this file. used in generating internal metric reports. I guess
i'll have to dig into the django code to see how signals are used..do
you know of any example where the request_finished signal is used ?

thanks,
-p

On Nov 18, 10:23 pm, "David Zhou" <[EMAIL PROTECTED]> wrote:
> On Tue, Nov 18, 2008 at 9:40 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > david,
>
> > can you illustrate how ? sorry -- havent worked with django signals
> > earlier
>
> I might be misunderstanding your need to track requests to that file,
> but if you're using it to track requests in Django in general, you may
> be able to do that by using a listening for a request finished signal,
> and doing something with it.
>
> What are you specifically trying to do by tracking which users
> requested the file?
>
> --
> ---
> David Zhou
> [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: serving static file via django

2008-11-18 Thread [EMAIL PROTECTED]

david,

can you illustrate how ? sorry -- havent worked with django signals
earlier

thnx,
-p

On Nov 18, 7:06 pm, "David Zhou" <[EMAIL PROTECTED]> wrote:
> On Tue, Nov 18, 2008 at 6:22 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > my requirement is that I need to serve just one 10x10 gif file via
> > django -- so that i can track what users requested the file. can i use
> > the above view to serve this file ? what are the drawbacks of using
> > this view in a production env ?
>
> Have you considered using request/response signals?
>
> http://docs.djangoproject.com/en/dev/ref/signals/#module-django.core
>
> --
> ---
> David Zhou
> [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
-~--~~~~--~~--~--~---



serving static file via django

2008-11-18 Thread [EMAIL PROTECTED]

i know that django is not recommended to serve static content via
django and the web server handler should be used for it.

also, the following method to serve static content in development env,
but not recommended in a production env.

django.views.static.serve

http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs

my requirement is that I need to serve just one 10x10 gif file via
django -- so that i can track what users requested the file. can i use
the above view to serve this file ? what are the drawbacks of using
this view in a production env ?

thanks,
-pranav.
--~--~-~--~~~---~--~~
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: Multithreaded Dev Server

2008-11-16 Thread [EMAIL PROTECTED]

Having two instances of the dev server running does seem like another
easy way to do it, as it won't require installing anymore software.
--~--~-~--~~~---~--~~
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: Caching and I18n

2008-11-16 Thread [EMAIL PROTECTED]

Hello Ramiro,

thanks for your reply. According to the docs, the Locale and Session
middlewares should set the Vary-On headers accordingly, and indeed
they are:

Date: Sun, 16 Nov 2008 23:49:29 GMT
Server: WSGIServer/0.1 Python/2.5.2
Vary: Accept-Language, Cookie
Content-Type: text/html; charset=utf-8
Content-Language: de

200 OK

I'm lost. Maybe Beegee from the other thread found a solution in the
meantime.

On Nov 16, 10:33 pm, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> On Sun, Nov 16, 2008 at 10:51 AM, [EMAIL PROTECTED]
>
>
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > Hello everyone,
>
> > I'm trying to implement caching for my bilingual site. The problem is
> > that once I enable caching and I change the language (via the example
> > code 
> > inhttp://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-se...
> > ), the page does not change. The Content-Language header that the
> > browser receives is indeed changed accordingly, but apparently the
> > caching system is not aware of the change.
> > I've set up my middleware as follows:
>
> > MIDDLEWARE_CLASSES = (
> >    'django.middleware.cache.UpdateCacheMiddleware',
> >    'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
> > auth
> >    'django.contrib.auth.middleware.AuthenticationMiddleware',
> >    'django.middleware.locale.LocaleMiddleware',
> >    'django.middleware.common.CommonMiddleware',
> >    'django.middleware.cache.FetchFromCacheMiddleware',
> > )
>
> > I also tried per-site caching (disabling caching in the middleware),
> > but did get the same results, even when I specified vary_on_headers
> > ('Content-Language','Accept-Language').
>
> > I have found a snippet (http://www.djangosnippets.org/snippets/443/)
> > that might work, but I'm reluctant to use this hack and also rely on
> > the deprecated CacheMiddleware.
>
> > Any help and hints are appreciated!
>
> > Thanks,
> > Maik
>
> > PS. relevant settings.py excerpt:
> > CACHE_BACKEND = 'locmem:///'
> > CACHE_MIDDLEWARE_SECONDS = 300
> > CACHE_MIDDLEWARE_KEY_PREFIX = ''
> > CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
>
> The user's language preference might end being stored (and sent back) in
> the django language preferences cookie or the session-related cookie.
> So, to cover all the possible channels that preference could come in,
> you will also need to indicate 'cookie', in the Vary header:
>
> @vary_on_headers(''Accept-Language', 'Cookie')
>
> See the following posts for related discussions:
>
> http://groups.google.com/group/django-developers/browse_thread/thread...http://groups.google.com/group/django-users/browse_thread/thread/256f...
>
> Regards,
>
> --
>  Ramiro Morales
--~--~-~--~~~---~--~~
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: Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread [EMAIL PROTECTED]

Accidentally posted the first reply and you already beat me to my
actual reply, wow. The "not feeling right" part meant to imply that
the disadvantages I could see for both made me wonder if there wasn't
another (and better) option available, but based on your answer it
seems that won't happen anytime soon.


On Nov 16, 1:51 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi Malcolm,
> thanks for the fast reply.
>
> What is the downside of sticking this kind of information into a
> session, just that the session backend needs to carry this amount of
> information around and cookies have to be enabled for it to work? I
> otherwise would prefer it over (2) just for the cleaner URL.
>
> Thanks
> Stefan
>
> On Nov 16, 1:16 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Sun, 2008-11-16 at 12:58 +0100, Stefan Wallner wrote:
>
> > p,,,[
>
> > > My basic idea would be to use the same URL and view/template for  
> > > getting the directory listing and posting a file for uploading to it.  
> > > If a file is uploaded successfully the renamed file name and the users  
> > > that received the email should be listed in a notification part of the  
> > > template (i.e. ...) which confirms to the user  
> > > that everything is ok.
>
> > > Now I am stuck on how to best do this. POST/REDIRECT/GET does not seem  
> > > to fit here, since HttpResponseRedirect cannot pass any parameters to  
> > > a template and redirecting to the same URL does not make sense anyway.  
> > > What other pattern could/should I use?
>
> > I suspect you're actually asking the wrong question. The question isn't
> > "where should I redirect to?", but rather "how can I tell when loading
> > the file listing page, after a GET request, that some extra information
> > about the renamed file and notified people should be displayed?". It
> > doesn't matter what URL you actually retrieve after the file is
> > uploaded, that question still remains -- how to tell that you need to
> > display that information.
>
> > Once you've solved that problem, redirecting the the normal file listing
> > page is quite a natural place to go, since it shows the file listing
> > (plus this extra information sometimes), but that's really a side-issue.
>
> > You have at least a couple of choices:
>
> > (1) Use sessions and store the fact that a file was just uploaded (and
> > renamed) and the list of people notified in a key in the session. When
> > the user accesses the directory listing page using GET and if they have
> > that session key, display the extra information and then remove it from
> > the session (so it's displayed only once). Or possibly you want to keep
> > it in the session for a period of time or something. In any case, you
> > can use the session.
>
> > (2) The more HTTP/REST-like approach is to come up with a unique
> > identifier for the page that displays the newly uploaded information.
> > This identifier tells you (the webserver side of the code) that you need
> > to display the new filename and list of notified people. One way to do
> > this is to add a parameter to the GET request that is, say, the primary
> > key (or some other token) of the newly uploaded file. Then, when you are
> > processing that page, if the querystring contains that parameter, you
> > retrieve the new filename and the list of people who would have been
> > notified from the database.
>
> > The second way uses the fact that you can attach a querystring to a URL
> > and that's quite valid for an HTTP redirect. It's also probably not that
> > hard to implement, providing you can easily determine from the id of the
> > file who the recipients were. The slight drawback is that anybody who
> > knows that URL can view the same information. Maybe that's not a
> > problem. If it is, you can use access checking (e.g. the special display
> > information is only presented if the currently logged in user is the
> > person who uploaded the file with that id).
>
> > Thus the 'normal' view is, say, /foo/file_listing/ and the target after
> > an upload is, say, /foo/file_listing/?upload=123.
>
> > The first of these two choices is pretty fast to implement, but puts
> > information in the session, which you may or may not like doing. The
> > second is more "natural" in a way, but you have to do some work to
> > process the incoming optional querystring. It's still not particularly
> > hard, though.
>
> > 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
-~--~~~~--~~--~--~---



Caching and I18n

2008-11-16 Thread [EMAIL PROTECTED]

Hello everyone,

I'm trying to implement caching for my bilingual site. The problem is
that once I enable caching and I change the language (via the example
code in 
http://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-set-language-redirect-view
), the page does not change. The Content-Language header that the
browser receives is indeed changed accordingly, but apparently the
caching system is not aware of the change.
I've set up my middleware as follows:

MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
auth
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
)

I also tried per-site caching (disabling caching in the middleware),
but did get the same results, even when I specified vary_on_headers
('Content-Language','Accept-Language').

I have found a snippet (http://www.djangosnippets.org/snippets/443/)
that might work, but I'm reluctant to use this hack and also rely on
the deprecated CacheMiddleware.

Any help and hints are appreciated!

Thanks,
Maik

PS. relevant settings.py excerpt:
CACHE_BACKEND = 'locmem:///'
CACHE_MIDDLEWARE_SECONDS = 300
CACHE_MIDDLEWARE_KEY_PREFIX = ''
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread [EMAIL PROTECTED]

Hi Malcolm,
thanks for the fast reply.

What is the downside of sticking this kind of information into a
session, just that the session backend needs to carry this amount of
information around and cookies have to be enabled for it to work? I
otherwise would prefer it over (2) just for the cleaner URL.

Thanks
Stefan




On Nov 16, 1:16 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-11-16 at 12:58 +0100, Stefan Wallner wrote:
>
> p,,,[
>
> > My basic idea would be to use the same URL and view/template for  
> > getting the directory listing and posting a file for uploading to it.  
> > If a file is uploaded successfully the renamed file name and the users  
> > that received the email should be listed in a notification part of the  
> > template (i.e. ...) which confirms to the user  
> > that everything is ok.
>
> > Now I am stuck on how to best do this. POST/REDIRECT/GET does not seem  
> > to fit here, since HttpResponseRedirect cannot pass any parameters to  
> > a template and redirecting to the same URL does not make sense anyway.  
> > What other pattern could/should I use?
>
> I suspect you're actually asking the wrong question. The question isn't
> "where should I redirect to?", but rather "how can I tell when loading
> the file listing page, after a GET request, that some extra information
> about the renamed file and notified people should be displayed?". It
> doesn't matter what URL you actually retrieve after the file is
> uploaded, that question still remains -- how to tell that you need to
> display that information.
>
> Once you've solved that problem, redirecting the the normal file listing
> page is quite a natural place to go, since it shows the file listing
> (plus this extra information sometimes), but that's really a side-issue.
>
> You have at least a couple of choices:
>
> (1) Use sessions and store the fact that a file was just uploaded (and
> renamed) and the list of people notified in a key in the session. When
> the user accesses the directory listing page using GET and if they have
> that session key, display the extra information and then remove it from
> the session (so it's displayed only once). Or possibly you want to keep
> it in the session for a period of time or something. In any case, you
> can use the session.
>
> (2) The more HTTP/REST-like approach is to come up with a unique
> identifier for the page that displays the newly uploaded information.
> This identifier tells you (the webserver side of the code) that you need
> to display the new filename and list of notified people. One way to do
> this is to add a parameter to the GET request that is, say, the primary
> key (or some other token) of the newly uploaded file. Then, when you are
> processing that page, if the querystring contains that parameter, you
> retrieve the new filename and the list of people who would have been
> notified from the database.
>
> The second way uses the fact that you can attach a querystring to a URL
> and that's quite valid for an HTTP redirect. It's also probably not that
> hard to implement, providing you can easily determine from the id of the
> file who the recipients were. The slight drawback is that anybody who
> knows that URL can view the same information. Maybe that's not a
> problem. If it is, you can use access checking (e.g. the special display
> information is only presented if the currently logged in user is the
> person who uploaded the file with that id).
>
> Thus the 'normal' view is, say, /foo/file_listing/ and the target after
> an upload is, say, /foo/file_listing/?upload=123.
>
> The first of these two choices is pretty fast to implement, but puts
> information in the session, which you may or may not like doing. The
> second is more "natural" in a way, but you have to do some work to
> process the incoming optional querystring. It's still not particularly
> hard, though.
>
> 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: Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread [EMAIL PROTECTED]

Hi Malcolm,
thanks for the fast response. I had thought about both approaches, but
both didn't feel 100% right (more a gut feeling than anything).



On Nov 16, 1:16 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-11-16 at 12:58 +0100, Stefan Wallner wrote:
>
> p,,,[
>
> > My basic idea would be to use the same URL and view/template for  
> > getting the directory listing and posting a file for uploading to it.  
> > If a file is uploaded successfully the renamed file name and the users  
> > that received the email should be listed in a notification part of the  
> > template (i.e. ...) which confirms to the user  
> > that everything is ok.
>
> > Now I am stuck on how to best do this. POST/REDIRECT/GET does not seem  
> > to fit here, since HttpResponseRedirect cannot pass any parameters to  
> > a template and redirecting to the same URL does not make sense anyway.  
> > What other pattern could/should I use?
>
> I suspect you're actually asking the wrong question. The question isn't
> "where should I redirect to?", but rather "how can I tell when loading
> the file listing page, after a GET request, that some extra information
> about the renamed file and notified people should be displayed?". It
> doesn't matter what URL you actually retrieve after the file is
> uploaded, that question still remains -- how to tell that you need to
> display that information.
>
> Once you've solved that problem, redirecting the the normal file listing
> page is quite a natural place to go, since it shows the file listing
> (plus this extra information sometimes), but that's really a side-issue.
>
> You have at least a couple of choices:
>
> (1) Use sessions and store the fact that a file was just uploaded (and
> renamed) and the list of people notified in a key in the session. When
> the user accesses the directory listing page using GET and if they have
> that session key, display the extra information and then remove it from
> the session (so it's displayed only once). Or possibly you want to keep
> it in the session for a period of time or something. In any case, you
> can use the session.
>
> (2) The more HTTP/REST-like approach is to come up with a unique
> identifier for the page that displays the newly uploaded information.
> This identifier tells you (the webserver side of the code) that you need
> to display the new filename and list of notified people. One way to do
> this is to add a parameter to the GET request that is, say, the primary
> key (or some other token) of the newly uploaded file. Then, when you are
> processing that page, if the querystring contains that parameter, you
> retrieve the new filename and the list of people who would have been
> notified from the database.
>
> The second way uses the fact that you can attach a querystring to a URL
> and that's quite valid for an HTTP redirect. It's also probably not that
> hard to implement, providing you can easily determine from the id of the
> file who the recipients were. The slight drawback is that anybody who
> knows that URL can view the same information. Maybe that's not a
> problem. If it is, you can use access checking (e.g. the special display
> information is only presented if the currently logged in user is the
> person who uploaded the file with that id).
>
> Thus the 'normal' view is, say, /foo/file_listing/ and the target after
> an upload is, say, /foo/file_listing/?upload=123.
>
> The first of these two choices is pretty fast to implement, but puts
> information in the session, which you may or may not like doing. The
> second is more "natural" in a way, but you have to do some work to
> process the incoming optional querystring. It's still not particularly
> hard, though.
>
> 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: Multithreaded Dev Server

2008-11-15 Thread [EMAIL PROTECTED]

http://www.oebfare.com/blog/2008/nov/03/writing-custom-management-command/

The CherryPy WSGI server should make this really, you could probably
even deploy on it if you wanted.

On Nov 16, 1:15 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Nov 16, 4:40 pm, Chris <[EMAIL PROTECTED]> wrote:
>
> > I understand what you're saying. It's just unfortunate we're throwing
> > out the convenience of the dev server.
>
> > What's up withhttp://code.djangoproject.com/ticket/3357?Looks like
> > this idea isn't new.
>
> Using daemon mode of mod_wsgi can almost give you the convenience you
> want. The main issue with Apache is generally the need to restart
> Apache on all code changes. With mod_wsgi daemon mode, you only need
> touch the modification time of the WSGI script file after a set of
> code changes have been made and mod_wsgi will ensure application is
> reloaded. If you want, you can add your own monitor thread which looks
> for changed files and automatically triggers an application restart.
> See:
>
>  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
>
> Graham
>
> > Chris
>
> > On Nov 16, 12:30 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Sat, 2008-11-15 at 21:17 -0800, Chris wrote:
> > > > Do you mean easier in that runserver doesn't support multithreading at
> > > > all? Or easier in that it supports multi-threading, but it's difficult
> > > > to set up?
>
> > > The dev server is single-threaded by design. It wouldn't be impossible
> > > to make it multi-threaded with code changes, but it would be fiddly and
> > > in the past we've said we really aren't interested, since it adds a lot
> > > of maintenance burden. If you want multi-threaded behaviour, use a real
> > > web server.
>
> > > 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
-~--~~~~--~~--~--~---



Templates and method arguments for thumbnails

2008-11-15 Thread [EMAIL PROTECTED]

Hi,

>From the django documentation, it looks like it is not possible to
pass arguments to methods from the template HTML code.

For example:

class MyModel(Model):
  def foo(self):
return 'This works'

can be accessed by: {{ mymodel.foo }} in an HTML template.

What I am trying to do, however, is to access data based on arguments
for this method. This is my example scenario: I have several high
resolution photographs, and I want to be able to write some code that
displays thumbnails:

1) Check if a thumbnail exists, if it doesn't, create it
2) Return the URL for the given image file to be displayed on screen

e.g. {{ myimage.getThumbnail 200 }}

I was thinking of intercepting all method calls beginning with
getThumbnail, and extracting the width out of the method name, but
this seems kind of clumsy. The sizes for the thumbnails will always be
dynamic, and will not be fixed according the preconfigured sizes, so i
can't have a getThumbnailSmal()/Med()/Large() setup.

{{ myimage.getThumbnail_50/75/100/etc...}}

Is there a cleaner or better way to do this?

Thank you
--~--~-~--~~~---~--~~
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: TemplateDoesNotExist

2008-11-14 Thread [EMAIL PROTECTED]

I think the problem was a combination of an incorrect template
directory and forgetting to touch dispatch.fcgi, in any case, it seems
to be working  now.

Thanks for the help,

Jason

On Nov 13, 4:32 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-11-13 at 11:12 -0800, sergioh wrote:
>
> >  are you using fastcgi? it could be an error on your syspath?
>
> The filesystem path in TEMPLATE_DIRS has absolutely nothing to do with
> Python's import path. These are files that are loaded via os.open() and
> read(). They aren't Python files at all.
>
> 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: Book or documentation first

2008-11-13 Thread [EMAIL PROTECTED]

I'm just starting and I recommend the tutorial first. You can get it
done in an hour I think. Also, the book Practical Django Projects is
pretty good, if not totally up-to-date. But there is a website that
presents all changes you have to make to get it working with the
current version.
--~--~-~--~~~---~--~~
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: Improvement: documentation example for extra Manager methods

2008-11-13 Thread [EMAIL PROTECTED]

I found the origin on my error ('NoneType' object has no attribute
'_meta').
I used a wrong (old?) syntax for adding custom Manager to my Model:
ModelClass.objects = MyCustomManager()  # After Model and Manager
definitions

My custom Manager should have been attached in the model definition
(as found in the Manager documentation):
objects = MyCustomManager()  # And manager definition had to be moved
before the Model definition

Still, my initial message is valid: there is no standard example about
custom Manager method that returns a filtered queryset :-)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Improvement: documentation example for extra Manager methods

2008-11-13 Thread [EMAIL PROTECTED]

Hi,

I am building a custom Manager for adding extra methods that return
filtered querysets.
I believe this is a common case for custom Managers.

Digging into the documentation [1], the only example emphasises on the
ability to return anything from a Manager method. However, I miss a
standard example for methods that DO return a filtered queryset.

I am still struggling with my custom Manager method, which raises an
error in my project ('NoneType' object has no attribute '_meta'). Any
hint?
My custom Manager method is like this:
  def active(self):
return self.get_query_set().filter(status=STATUS_ACTIVE)


Based on your feedback, I could raise a ticket for updating the
documentation.
Thanks.

[1] 
http://docs.djangoproject.com/en/dev/topics/db/managers/#adding-extra-manager-methods
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Using FilteredSelectMultiple with Ajax

2008-11-13 Thread [EMAIL PROTECTED]

Hi guys,

I'm relatively new to django (coming from Zope) and I love it! This is
my first question.

Im using the FilteredSelectMultiple (from the admin application) in
one of my forms and it works like charm if I use with a "normal"
request. If I load the form with a AJAX request and inject the result
within my HTML I get the standard multi selection widget. I assume
that the widget is not initalized after the injection.

My question is: Is there a javascript function which I have to call
after I injecting the form into the HTML?

Thanks
L.

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

2008-11-12 Thread [EMAIL PROTECTED]

Sorry about the inconsistency but just to be clear, here is what I
have:

Dreamhost directory structure:

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

within this directory:
- index.html
- base.html

local directory structure:

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

within this directory:
- index.html
- base.html

There were two different posts, one referencing the directory
structure for the initial problem on Dreamhost and the test I did on
my local machine using the development server - which also returned
the same error.

On Nov 12, 10:29 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2008-11-12 at 22:12 -0800, [EMAIL PROTECTED] wrote:
> > The directory structure is:
>
> > /home/USERNAME/projects/django_templates/SITENAME/polls
> > - index.html
> > - base.html
>
> If the directory name is "/home/USERNAME/project/..", then why have you
> put "/django_projects/django_templates/polls/" as the setting value?
> There is no match there. The setting you have given in this thread says
> that there is a directory under the root called django_projects/, but it
> sounds like that isn't the case at all.
>
> 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: TemplateDoesNotExist

2008-11-12 Thread [EMAIL PROTECTED]

The directory structure is:

/home/USERNAME/projects/django_templates/SITENAME/polls
- index.html
- base.html

I'm sure it's my fault, I just don't see it.

On Nov 12, 6:10 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 12, 2008 at 1:39 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:
>
>
>
>
>
> > I tried this using the development server on my local machine and got
> > the same result:
>
> > Template-loader postmortem
>
> > Django tried loading these templates, in this order:
>
> >    * Using loader
> > django.template.loaders.filesystem.load_template_source:
> >          o /django_projects/django_templates/polls/index.html (File
> > does not exist)
> >    * Using loader
> > django.template.loaders.app_directories.load_template_source:
> >          o /Library/Frameworks/Python.framework/Versions/2.5/lib/
> > python2.5/site-packages/django/contrib/admin/templates/polls/
> > index.html (File does not exist)
>
> You are saying you do have a file named '
> /django_projects/django_templates/polls/index.html'?  You can cut-and-paste
> that value into a command prompt and cat the contents of the file?  Every
> time I have run into TemplateDoesNotExist I've been in error, not the
> template loader.  Perhaps you put the files directly in
> '/django_project/django_templates' instead of in a polls subdirectory
> there?  Or left the l off of html?
>
> Karen
--~--~-~--~~~---~--~~
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: TemplateDoesNotExist

2008-11-12 Thread [EMAIL PROTECTED]

I tried this using the development server on my local machine and got
the same result:

Template-loader postmortem

Django tried loading these templates, in this order:

* Using loader
django.template.loaders.filesystem.load_template_source:
  o /django_projects/django_templates/polls/index.html (File
does not exist)
* Using loader
django.template.loaders.app_directories.load_template_source:
  o /Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/contrib/admin/templates/polls/
index.html (File does not exist)

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

# URLS.PY
from django.conf.urls.defaults import *

urlpatterns = patterns('',
# Example:
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P\d+)/results/$',
'mysite.polls.views.results'),
(r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'),


# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),
)

# VIEWS.PY
from django.template import Context, loader
from mysite.polls.models import Poll
from django.http import HttpResponse

def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
t = loader.get_template('polls/index.html')
c = Context({
'latest_poll_list': latest_poll_list,
})
return HttpResponse(t.render(c))


I also tried another template and got the same error.


On Nov 11, 8:49 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-11-11 at 20:05 -0800, [EMAIL PROTECTED] wrote:
> > Hello,
>
> > I'm getting this error and the missing template IS in the template
> > directory defined in settings.py and views.py
>
> Everything looks correct visually, with one exception:
>
>
>
> > # SETTINGS.PY
> > TEMPLATE_DIRS = (
> >     # Put strings here, like "/home/html/django_templates" or "C:/www/
> > django/templates".
> >     # Always use forward slashes, even on Windows.
> >     # Don't forget to use absolute paths, not relative paths.
> >    '/home/projects/django_templates/SITENAME'
>
> If this is the only entry in TEMPLATE_DIRS, you will need to put a
> trailing comma there, since ("some_string") is not a tuple in Python and
> ("some_string",) is. That's a common error.
>
> You don't say how you're testing this. Does it only fail with a
> webserver like Apache (and works with the development server)? In that
> case, I'd suspect directory permissions.
>
> If it also fails with the development server, do other templates from
> the SITENAME/polls/ directory load correctly?
>
> 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: Performing an operation

2008-11-12 Thread [EMAIL PROTECTED]

Thanks for your help Daniel! I havent got hosting sorted yet so its
something Ill have to set up later.
I guess I can set up the custom command and do it manually for now.
Phil

On Nov 12, 5:29 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Nov 12, 5:02 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > Hi all,
> > Just building my first site with django and Ive hit my first snag that
> > I cant find in the documentation.
>
> > Just as an example scenario, suppose I have my model-
>
> > class User(models.Model):
> >     signup_date =  models.DateTimeField()
> >     full_user_date = models.DateTimeField()
> >     full_user = models.BooleanField()
>
> > I want to make it so that when we arrive at full_user_date django
> > flicks full_user over to 1 and sends the user an email.
>
> > I imagine I could do it in the views.py, but it would be dependant on
> > someone visiting the page. I think it would be more effecient to just
> > do a check once a day, thats all I need. How can i set it up so django
> > does a check on the database after a set time?
>
> > any ideas?
> > Phil
>
> You need some sort of job that runs periodically on the server. If
> you're using Linux (or a Mac), cron is ideal for this. (I think
> Windows has something like a Schedule Server for this job.)
>
> Just create a standalone script that imports the Django models just as
> you would do in a view. Perhaps the best way of doing this is to
> create a custom manage.py command - 
> seehttp://docs.djangoproject.com/en/dev/howto/custom-management-commands...
> for how this is done.
>
> You can then set cron to run manage.py your_command once a day to do
> the update.
> --
> 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: TemplateDoesNotExist

2008-11-12 Thread [EMAIL PROTECTED]

This is running on Dreamhost, who doesn't allow running independent
servers, so I am currently unable to test using the development
server. I'll set something up on my local machine and see what
happens.

Thanks,

Jason

On Nov 11, 8:49 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-11-11 at 20:05 -0800, [EMAIL PROTECTED] wrote:
> > Hello,
>
> > I'm getting this error and the missing template IS in the template
> > directory defined in settings.py and views.py
>
> Everything looks correct visually, with one exception:
>
>
>
> > # SETTINGS.PY
> > TEMPLATE_DIRS = (
> >     # Put strings here, like "/home/html/django_templates" or "C:/www/
> > django/templates".
> >     # Always use forward slashes, even on Windows.
> >     # Don't forget to use absolute paths, not relative paths.
> >    '/home/projects/django_templates/SITENAME'
>
> If this is the only entry in TEMPLATE_DIRS, you will need to put a
> trailing comma there, since ("some_string") is not a tuple in Python and
> ("some_string",) is. That's a common error.
>
> You don't say how you're testing this. Does it only fail with a
> webserver like Apache (and works with the development server)? In that
> case, I'd suspect directory permissions.
>
> If it also fails with the development server, do other templates from
> the SITENAME/polls/ directory load correctly?
>
> 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
-~--~~~~--~~--~--~---



Performing an operation

2008-11-12 Thread [EMAIL PROTECTED]

Hi all,
Just building my first site with django and Ive hit my first snag that
I cant find in the documentation.


Just as an example scenario, suppose I have my model-

class User(models.Model):
signup_date =  models.DateTimeField()
full_user_date = models.DateTimeField()
full_user = models.BooleanField()

I want to make it so that when we arrive at full_user_date django
flicks full_user over to 1 and sends the user an email.

I imagine I could do it in the views.py, but it would be dependant on
someone visiting the page. I think it would be more effecient to just
do a check once a day, thats all I need. How can i set it up so django
does a check on the database after a set time?

any ideas?
Phil

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



TemplateDoesNotExist

2008-11-11 Thread [EMAIL PROTECTED]

Hello,

I'm getting this error and the missing template IS in the template
directory defined in settings.py and views.py

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


# VIEWS.PY
from django.template import Context, loader
from SITENAME.polls.models import Poll
from django.http import HttpResponse

def index(request):
latest_poll_list = Poll.objects.all().order_by('-pubdate')[:5]
t = loader.get_template('polls/index.html')
c = Context({
'latest_poll_list': latest_poll_list,
})
return HttpResponse(t.render(c))



Thanks,

Jason
--~--~-~--~~~---~--~~
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: Sending mass, yet personalised email newsletters using Django

2008-11-11 Thread [EMAIL PROTECTED]

Hello Patrick,

On Nov 11, 1:53 am, "Patrick J. Anderson" <[EMAIL PROTECTED]>
wrote:
>
> Some of the main requirements are:
>
> * Personalised HTML/text messages
> * Manual delivery twice a week
> * Message logging/archiving
> * Amount of newsleter issues: ~50
> * Amount of subscribers: 500-5000

We (as company) has created 6 different versions of Newsletter for our
customers. They are
all commercial, but we plan to release some non-commercial version
too, as part of our e-commerce
solution, djWarehouse.

What about the Newsletter, I can explain the architecture for you, so
you would not fall into problems which had us to rewrite our
Newsletter 6 times until we get satisfied with results.


We have the following models:
 Newsletter (name, added, sent, status (NEW, READY, SCHEDULING,
SENDING, SENT)
 MessageSet (name, newsletter, category, status (same as in
newsletter))
 Message (messageset foreign key, marker_tag, subject, from name, from
email, format, message)
 MessageCopy(user, messageset, message)
 MessageResponse(message, url, count)

This newsletter is used on some of our sites, with thousands of
subscribers. (10-20).  The logick is the following:
customers are subscribed to some specific  categories on site. We have
choice to send general newsletter to all customers, or customize
messages by categories. MesageSet - a number of messages sent to
specific category[ies]. Every newsletter can contain a few message
sets. Why so complicated? Because we need to know what information is
more interesting to end users. Counting the results in MessageResponse
we find out how many customers clicked the links in one or another
newsletter, and know what customers are more interested in - this data
is used for next monthly newsletter from the site.

Now, the process of sending newsletter. That is one of the most
difficult parts of the process, since the SMTP protocol and message
daemons are not allowing to do many things, so we have to organize
things ourself. For example, since our sites have such a large users
base, Yahoo, Gmail, and specifically Hotmail were blocking our legal
newsletter every time, because from a few hundreds thousands
subscribers, a large part belongs to those online services (a few
thousands) and those services will automatically put you in "block
list" as soon as you try to send messages too quick.

That is why, we don't just send mails out via SMTP. The process of
sending is the following:
 1. When admin press "send" newsletter button, this only triggers the
process to save data to MesageCopy.
 2. An external program, run in 'daemon' mode, watches the table, and
maintains the list
of exeternal web services (Yahoo, MSN, etc). This daemon controls
that SMTP send out rate should
not exceed some specific amount for specific service.

So far, this architecture works out the best. We are using this 6th
version of improved newsletter for last 1.5 years, without any
problems.

I can not post the whole code here because the program is commercial,
but... some smaller  version will be released soon. Anyway, most of
customers need to only send mails to a few thousands customers, not a
few hundreds thousands, so some advanced functions are just not needed
for an average customer.

Hope that information is useful.

Best Regards.
Alex



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

2008-11-10 Thread [EMAIL PROTECTED]

It appears that the 500 error was a result of Dreamhost's process
watcher killing scripts. I'm still not sure where the problem is
originating from but coincidently I am now getting syntax errors from
django i.e., no 500 errors - at current time. Does anyone know why I
am getting a syntax error form this:

Exception Value:invalid syntax (urls.py, line 21)

from django.conf.urls.defaults import *

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

urlpatterns = patterns('',
(r'^$', 'SITENAME.polls.views.current_datetime'),
(r'^polls/$', 'SITENAME.polls.views.index'),
(r'^polls/(?P\d+)/$', 'SITENAME.polls.views.detail'),
(r'^polls/(?P\d+)/results/$',
'SITENAME.polls.views.results'),
(r'^polls/(?P\d+)/vote/$', 'SITENAME.polls.views.vote'),
)


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

# Uncomment the next line to enable the admin:
(r'^admin/(.*)', admin.site.root), # LINE 21
)


Thanks for all the help,

Jason
On Nov 7, 7:32 am, Blu3ness <[EMAIL PROTECTED]> wrote:
> 500 error will generate a error log in your ~/logs/ directory, do a
> little research on it, or maybe post it here :)
>
> On Nov 6, 1:58 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > I think I had the .htaccess and dispatch.fcgi  files in the wrong
> > place. I had them in the django generated mysite directory rather the
> > than the domain, but now when I go to mysite.com I get the 500
> > internal server error. This happened when I tried the Jeff Croft
> > setup:http://jeffcroft.com/blog/2006/may/11/django-dreamhost/which
> > is where I heard about the Gordon Tillman fix. Thanks for the help
> > thus far and any related to my new problem.
>
> > Jason
>
> > On Nov 6, 9:56 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > > I used the Gordon Tillman 
> > > setup:http://www.gordontillman.info/Development/DjangoDreamhost
> > > here are the dispatch.fcgi and .htaccess files:
>
> > > // dispatch.fcgi
>
> > > #!/usr/bin/env python2.4
> > > import sys, os
>
> > > # Add a custom Python path.
> > > sys.path.insert(0, "/home/USERNAME/projects/django/trunk")
> > > sys.path.insert(0, "/home/USERNAME/projects/flup/trunk")
> > > sys.path.insert(0, "/home/USERNAME/projects")
>
> > > //.htaccess
>
> > > # Set the DJANGO_SETTINGS_MODULE environment variable.
> > > os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
>
> > > from django.core.servers.fastcgi import runfastcgi
> > > runfastcgi(method="threaded", daemonize="false")
>
> > > AddHandler fastcgi-script .fcgi
> > > RewriteEngine On
> > > RewriteBase /
> > > RewriteRule ^(media/.*)$ - [L]
> > > RewriteRule ^(admin_media/.*)$ - [L]
> > > RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
> > > RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
>
> > > Here is my directory structure:
>
> > > home/USERNAME/
> > >    www.mysite.com/
> > >    www.anothersite.com/
> > >    www.yetanothersite.com/
> > >    projects/
> > >       django/
> > >       flup/
> > >       django_templates/
> > >       media/
> > >       mysite/
>
> > > On Nov 5, 5:56 pm, AndyB <[EMAIL PROTECTED]> wrote:
>
> > > >http://wiki.dreamhost.com/index.php/Django
>
> > > > Have you got the .htaccess, dispatch.fcgi etc all set up?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



using Etags or http response code 304 (not modified)

2008-11-10 Thread [EMAIL PROTECTED]

I've tried using the USE_ETAGS=true in my project settings and even
tried using the ConditionalGet Middleware. However, whenever an http
request is made to my page, it always seems to return a http code 200
along with the entire data.

how / what do I need to do so that a http 304 is issued if the data
hasnt been modified ?

do i need to do do anything within my view to issue the http 304 ?

thnx.
--~--~-~--~~~---~--~~
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: Browser access to manage.py / django command extensions

2008-11-10 Thread [EMAIL PROTECTED]

Maybe a button with a drop-down list for the commands he wants? Could
be part of the admin.

On Nov 10, 12:50 pm, Joe Murphy <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Boss wants browser access to a couple custom django command extensions
> -- wants it to be simple to administer for those who aren't
> comfortable on the command line.
>
> Any advice on how to approach this? I've searched google /
> djangosearch.com, and the django-users archive, and have come up with
> blanks.
>
> I understand the security risks in something like this, I also
> understand the job-security risks in not doing this.
>
> Thanks,
> Joe
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



has more than 1 ForeignKey to

2008-11-10 Thread [EMAIL PROTECTED]

Hi all,

I have a UserProfile connected to auth.models.User using

user = models.ForeignKey(User, unique=True)

Additionally, I'd like to connect users to each other with manager/
managed hierarchical relationships, whereby everyone has one manager
(except the big boss who has none):

manager = models.ForeignKey(User, blank=True,
related_name='employees_userprofile_manager')

My models fail to load with the exception:
 has more than 1
ForeignKey to 

This doesn't seem logical to me at all: the above is a perfectly fine
example of two foreign keys being meaningful. Why is this not possible
and what is the workaround, or rather, the proper way to do this?

I'm using Django 1.0.

Any help is much appreciated.

regards,
Klaas van Schelven

--~--~-~--~~~---~--~~
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.db.models.Q

2008-11-09 Thread [EMAIL PROTECTED]

>>> from django.db.models import Q

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/django/db/__init__.py", line
9, in 
if not settings.DATABASE_ENGINE:
  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 28, in __getattr__
self._import_settings()
  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 57, in _import_settings
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.


I have received this error. How Can i resolve it ?
I am newbie with django and python
byeee
--~--~-~--~~~---~--~~
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: How to order a list with a self-referential foreign key? (a category list)

2008-11-08 Thread [EMAIL PROTECTED]

I've found what I was looking for, and it turns out it's not simple at
all. Storing hierarchical information in a database is challenging and
there are several SQL techniques that can be applied to the problem.

There are a few good Django implementations out there, including
django-categories, django-mptt, and django-treebeard. I chose to use
some of the code from django-categories because it seemed the most
straightforward, though it hasn't been touched in a while and needed
some tweaks to get around backwards-incompatible changes with Django
signals.

I hope this helps point someone else in the right direction. I've got
it (mostly) working, and if anyone needs advice on doing it with their
own projects, feel free to send me a message.


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



How to order a list with a self-referential foreign key? (a category list)

2008-11-07 Thread [EMAIL PROTECTED]

I have a list of categories that allows you to set a parent/child
relationship such as:

  Financial
  Financial > Billing
  Financial > Billing > Collections
  Financial > Invoices

In the example above, "Financial" is a category, then "Billing" is a
category with "Financial" as the parent, etc.


I've got two problems I'm trying to solve:

1. Users shouldn't be able to set the parent object as itself

This can happen if save a category, then go back in and edit it. With
the way I'm returning the get_full_name() method, this causes a
recursion problem.

Is there a way to filter the current object out of the parent dropdown
in the admin? This should be pretty easy to do with logic outside of
the admin, but I'd like it to work properly inside the admin as well.
I was trying to find a way to use a pre or post-save hook to see if
the new value being saved for parent was equal to the object's ID and
causing a validation error, but couldn't quite nail it.

2. I'd like to group the subcategories by their parent categories all
the way down the hierarchy

I thought about trying to use the flattened hierarchy in a character
field and sorting by that (which worked) but if a parent category
changed, you have to go through and resave all the categories and
their flattened structures again to update them. That could work, but
it doesn't feel like the right approach.

I'm at a loss for ideas, does anyone have a clever solution for me?

Here's the model:

class Category(models.Model):
name = models.CharField(max_length=200)
parent = models.ForeignKey('self', null=True, blank=True)

def get_full_name(self):
if self.parent:
return "%s: %s" % (self.parent.get_full_name(), self.name)
else:
return self.name

def save(self, force_insert=False, force_update=False):
# Don't let people save itself as parent
if self.id and self.parent:
if self.id == self.parent.id:
return False
super(Category, self).save(force_insert, force_update)

def __unicode__(self):
return self.get_full_name()


--~--~-~--~~~---~--~~
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: Oracle Clob Field type

2008-11-07 Thread [EMAIL PROTECTED]

You're right -- there's no need to run syncdb.  All of this is a
learning exercise for me.
I'm just running the commands to see the output and behavior as I go
through the docs, with an eye for potential snags and "gotchas" that
might kill me later on.




On Nov 5, 9:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 5, 2008 at 5:54 PM, [EMAIL PROTECTED] <
>
>
>
> [EMAIL PROTECTED]> wrote:
>
> > Noob here...
>
> > I have an existing table with two Clob fields.  While defining the
> > model I use TextField as the filed type.
>
> > running  gives me back the error:
>
> > cx_Oracle.DatabaseError: ORA-01754: a table may contain only one
> > column of type LONG
>
> > Well, what I really want are clobs to begin with.  It sounds like what
> > I really want to do is subclass Field, but this is starting to turn in
> > to more trouble than it's worth...
>
> > This has to be something somebody's come across before.
>
> I've no experience with Oracle but -- you run syncdb to create your tables.
> If you already have the table, why are you running syncdb?
>
> Karen
--~--~-~--~~~---~--~~
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 Django

2008-11-06 Thread [EMAIL PROTECTED]

I think I had the .htaccess and dispatch.fcgi  files in the wrong
place. I had them in the django generated mysite directory rather the
than the domain, but now when I go to mysite.com I get the 500
internal server error. This happened when I tried the Jeff Croft
setup: http://jeffcroft.com/blog/2006/may/11/django-dreamhost/ which
is where I heard about the Gordon Tillman fix. Thanks for the help
thus far and any related to my new problem.

Jason

On Nov 6, 9:56 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I used the Gordon Tillman 
> setup:http://www.gordontillman.info/Development/DjangoDreamhost
> here are the dispatch.fcgi and .htaccess files:
>
> // dispatch.fcgi
>
> #!/usr/bin/env python2.4
> import sys, os
>
> # Add a custom Python path.
> sys.path.insert(0, "/home/USERNAME/projects/django/trunk")
> sys.path.insert(0, "/home/USERNAME/projects/flup/trunk")
> sys.path.insert(0, "/home/USERNAME/projects")
>
> //.htaccess
>
> # Set the DJANGO_SETTINGS_MODULE environment variable.
> os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
>
> from django.core.servers.fastcgi import runfastcgi
> runfastcgi(method="threaded", daemonize="false")
>
> AddHandler fastcgi-script .fcgi
> RewriteEngine On
> RewriteBase /
> RewriteRule ^(media/.*)$ - [L]
> RewriteRule ^(admin_media/.*)$ - [L]
> RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
> RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
>
> Here is my directory structure:
>
> home/USERNAME/
>    www.mysite.com/
>    www.anothersite.com/
>    www.yetanothersite.com/
>    projects/
>       django/
>       flup/
>       django_templates/
>       media/
>       mysite/
>
> On Nov 5, 5:56 pm, AndyB <[EMAIL PROTECTED]> wrote:
>
> >http://wiki.dreamhost.com/index.php/Django
>
> > Have you got the .htaccess, dispatch.fcgi etc all set up?
--~--~-~--~~----~---~--~~
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 Django

2008-11-06 Thread [EMAIL PROTECTED]

I used the Gordon Tillman setup: 
http://www.gordontillman.info/Development/DjangoDreamhost
here are the dispatch.fcgi and .htaccess files:

// dispatch.fcgi

#!/usr/bin/env python2.4
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home/USERNAME/projects/django/trunk")
sys.path.insert(0, "/home/USERNAME/projects/flup/trunk")
sys.path.insert(0, "/home/USERNAME/projects")

//.htaccess

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")


AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

Here is my directory structure:

home/USERNAME/
   www.mysite.com/
   www.anothersite.com/
   www.yetanothersite.com/
   projects/
  django/
  flup/
  django_templates/
  media/
  mysite/

On Nov 5, 5:56 pm, AndyB <[EMAIL PROTECTED]> wrote:
> http://wiki.dreamhost.com/index.php/Django
>
> Have you got the .htaccess, dispatch.fcgi etc all set up?
--~--~-~--~~~---~--~~
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: Installation of django in user account

2008-11-06 Thread [EMAIL PROTECTED]

No one?

On Nov 5, 6:18 pm, "Tim O'Toole" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I was wondering how feasile it is it to install Django in a user
> account without root access. I followed the instruction at:
>
> http://docs.djangoproject.com/en/dev/topics/install/#installing-devel...
>
> But I obviously cant  do the following without root access
>
> ln -s `pwd`/django-trunk/django SITE-PACKAGES-DIR/django
>
> Whilst I can set the PYTHONPATH, I can't then write to PythonPath in
> the Apache configuration file.
>
> I generally place my html/php files in a public_html directory in my
> local account, but I see that mod_python 3.1 is installed, However I
> fear the network is locked down too tightly for me to experiment with
> Django - anyone care to comment on 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
-~--~~~~--~~--~--~---



Django Using Multiple Databases in a Web Application

2008-11-06 Thread [EMAIL PROTECTED]

Hi, Django Users, Started on Django and enjoying this framework
immensley, Using the DjangoProject Documentation and the book The
Definitive Guide to Django Web Development Done Right,

I am starting a project but I want to use more that one sqlite
database. From the Docs\Book it appears that you can use only one. I
have read the following posts, but as a newbie I would appreciate a
bit of help.

http://groups.google.com/group/django-developers/browse_thread/thread/9f0353fe0682b73

Also the Django Multiple Database Branch “A How-To Guide”, this covers
legacy databases not your database in settings.py

If anyone can give me a step by step to create additional sqlite
databases that I want to refer to in a Django Application it would be
most appreciated.

Kind Regards

David Thomson
[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: Keeping track of online users

2008-11-05 Thread [EMAIL PROTECTED]



On Nov 3, 12:07 am, JoeJ <[EMAIL PROTECTED]> wrote:
> Are you looking for something like 'django-tracking' ??
>  http://code.google.com/p/django-tracking/
>
> I was just perusing this last night, for use on a site of mine.
>
> -- joe

excuse me for late... thank you very much :)




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



Oracle Clob Field type

2008-11-05 Thread [EMAIL PROTECTED]

Noob here...

I have an existing table with two Clob fields.  While defining the
model I use TextField as the filed type.

running  gives me back the error:

cx_Oracle.DatabaseError: ORA-01754: a table may contain only one
column of type LONG

Well, what I really want are clobs to begin with.  It sounds like what
I really want to do is subclass Field, but this is starting to turn in
to more trouble than it's worth...

This has to be something somebody's come across before.

--~--~-~--~~~---~--~~
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: redirection 2 links back after signing up?

2008-11-05 Thread [EMAIL PROTECTED]

That is the problem I am trying to solve.

Basically, the restricted area isn't static. A user could be viewing
any number of dynamic pages protected by a sign in page.

If it were simply a static page, it would be trivial to do: return
HttpResponseRedirect("/static_page/")

The ?next= argument is only used by django's automatic sign-in code.
I'm not even sure how I could use it myself. Do you have any ideas
what I should try?

Basically:

1) every potential page that has its access restricted must be able to
pass the current path along to the login page
2) The login page needs to send along the same path to the
create_account page if it is clicked. If it is not clicked, then we
will return to the current page and no extra code is needed.
3) The create account page can now return
HttpResponseRedirect(previousPath)

What is the best way to do this?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



redirection 2 links back after signing up?

2008-11-05 Thread [EMAIL PROTECTED]

Hello,

I have the following situation:

1) User goes to a restricted area and is offered a chance to login
(@login_required decorator used)
2) User logs in, and then is automatically returned to this page via ?
next={{ request.path }} in the HTML template

This works fine, after logging in the user is returned to the correct
page.

The problem is, if the user doesn't already have an account, I get
into this situation:

1) User goes to a restricted area and is offered a chance to login
(@login_required decorator used)
2) User doesn't have an account, so attempts to create one, and clicks
on the 'Create New Account link'. The problem is the link now looks
like: "/create_account/?next=/Sign_In/"
3) After creating the account, the user is redirected to the sign in
page, but _not the page they visted 2 steps back_

Is there an ideal way to fix this? Basically, if you click on 'create
an account' from the sign_in page, there should be some way to return
to the page you were at before being directed to the sign in page.



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

2008-11-04 Thread [EMAIL PROTECTED]

So, I added this to the urlpatterns var:

(r'^$', 'mysite.polls.views.current_datetime'),

...and this to views.py located in the polls directory

from django.http import HttpResponse
import datetime

def current_datetime(request):
now = datetime.datetime.now()
html = "It is now %s." % now
return HttpResponse(html)

When I open a browser and go to http://www.mysite.com I wind up in the
mysite.com directory on my Dreamhost server, rather than the url being
mapped to the django site located at /home/username/projects/mysite.

Thanks,

Jason


On Nov 3, 4:10 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I understand the mapping of urls.py but I guess I'm not clear on a few
> > things to begin with, like what is the equivalent to an index.html
> > page in django? I know that the system works off of a template system
> > like using "base.html" as the design skeleton for a site and extending
> > that system with calls to different views, but what happens when I
> > want to just request the index page for a django site? Let's say I
> > register and add a subdomain to my Dreamhost account say...
> > mysite.com, when I issue the startproject command as django-admin.py
> > startproject mysite is there some sort of connection between the two?
> > Do I scrap the Dreamhost generated directory "mysite.com" and the
> > actual command I should be issuing is django-admin.py startproject
> > mysite.COM? What is returned for an index page if there is no
> > ndex.html or index.php?
>
> Your site's root page is whatever is mapped to r"^$", the empty URL.
>
> It's the same for directories. If you *want* to map something on to
> .../something.html you can, but there is no need to. When a
> "directory-like URL" is passed by a browser the returned result is
> whatever is generated by the view the the URL is mapped to. Or a 404 if
> no such mapping can be found.
>
> regards
>  Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Where can I find the "What's new" in detail in django's doc 1.0?

2008-11-04 Thread [EMAIL PROTECTED]

Where can I find the "What's new" in detail in django's doc 1.0?
--~--~-~--~~~---~--~~
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: Forms Question

2008-11-03 Thread [EMAIL PROTECTED]

Yep, you need to do the if is_valid() stuff, but other than the save()
method it works like a normal form, more or less.

On Nov 3, 8:07 pm, Robocop <[EMAIL PROTECTED]> wrote:
> I tried that earlier but i failed terribly at syntax.  Should it be:
>
> f = ModelForm(request.POST)
> f.save()
>
> On Nov 3, 5:37 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>
> > On Nov 4, 2008, at 8:14 AM, Robocop wrote:
>
> > > I'm working with some rather long forms, and i've processed them in a
> > > pretty basic way.  I read in the post data for every field, then just
> > > create a new table entry using the form data.
>
> > > Something like:
> > > if request.method == 'POST':
> > >  if form.is_valid():
> > >    var_a = form.cleaned_data['var_a']
> > >    var_b = form.cleaned_data['var_b']
> > >    
> > >   var_z = form.cleaned_data['var_z']
> > >   new_model = Model( var_a = var_a, var_b = var_b, ... ,var_z =var_z)
> > >   new_model.save()
>
> > > Now that my forms are getting pretty long, i'm wondering if there is a
> > > faster way to do this.  Does anyone know of any tricks or shortcuts to
> > > just push a one to one mapping of my modelform to my model into a new
> > > table in my database?  As always, help is greatly appreciated.
>
> > If you're using a real modelform, just call save() on it:
>
> >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
--~--~-~--~~~---~--~~
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: Password Field Form

2008-11-02 Thread [EMAIL PROTECTED]

Hi Nick,
you can do this by passing the widget parameter to a CharField.

A little example:
password =
forms.CharField(label=_(u'Password'),widget=forms.PasswordInput(render_value=False))

Lukas

On Nov 2, 5:58 pm, nkulmati <[EMAIL PROTECTED]> wrote:
> How come this 
> page:http://docs.djangoproject.com/en/dev/ref/forms/fields/#module-django
> does not contain information about password fields?
>
> How do I create and use a password form field then?
>
> Clearly, django has support for password form fields, since they are
> used in the standard Create New User form provided in the library.
>
> Thanks!
> Nick.

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



Keeping track of online users

2008-11-01 Thread [EMAIL PROTECTED]


I have found some post of 2007 on this argument but maybe with django
1.0 something is changed.

how do you do that ?

thanks everyone :)
--~--~-~--~~~---~--~~
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: HttpRequest with chunked encoding is not buffered

2008-11-01 Thread [EMAIL PROTECTED]

I actually am seeing some input, but it is divided into several, well,
chunks. I guess it's the same problem as seeing no input - I'd say
you're right and chunked encoding is silently unsupported (it would be
nice if Django said something though).
However, could you please suggest any workaround? If mod_python does
not work, what should I use? (My goal is to be able to receive chunked
requests in some normal way in my django application).

On Nov 1, 10:28 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Nov 1, 10:40 am, "Tomáš Brambora" <[EMAIL PROTECTED]> wrote:
>
> > I have a standard Django installation without any changes in the
> > settings (except adding mysql db to the settings.py) and I'm sending
> > the message to localhost:8000, so there is no proxy or anything else
> > in the way. Still, the request body comes after me sending the
> > response...
>
> As I said in the other similar thread you created about this.
>
> If you are getting empty input on read, then you are using hosting
> mechanism that doesn't properly filter out chunked request content as
> not being supported and instead assumes that content length of
> request  was 0.
>
> In other words, chunked request content is not supported. Most hosting
> mechanisms will flag it as an error. The internal Django development
> server appears just to assume that content length on request is 0
> since Content-Length header wouldn't be set. Thus why you are seeing
> no input.
>
> Graham
>
>
>
> > On Fri, Oct 31, 2008 at 11:50 PM, Graham Dumpleton
>
> > <[EMAIL PROTECTED]> wrote:
>
> > > [EMAIL PROTECTED] wrote:
> > >> Hello,
> > >> I'm trying to receive a possibly large XML message via HttpRequest
> > >> (POST method) with chunked encoding. However, when I send a response,
> > >> I found out (using Wireshark) that the response is being sent before
> > >> the whole POST request body is available. I expected Django to be
> > >> buffering the chunks and that the request would be complete, but
> > >> that's apparently not happening...
>
> > >> I'm reading the body like this:
> > >> request.POST.values()[0]
>
> > >> (Which is probably a wrong way, but I don't know how to do it
> > >> otherwise.)
>
> > > What hosting mechanism are you using. Anything that uses WSGI (eg,
> > > mod_wsgi, fastcgi/flup) or mod_python will not work as neither WSGI
> > > specification or mod_python support chunked transfer encoding on
> > > request content. Certainly for mod_python and mod_wsgi, it should give
> > > an error back before even gets to Django saying that content length
> > > required to be set.
>
> > > Graham
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Installing an app in a sub-directory of another site (urls question)

2008-11-01 Thread [EMAIL PROTECTED]

Hi guys,

I installed my app on a subdir of another site (just for staging).

www.example.org/djangoapp

Now my urls keep pointing back to the root of the other site, breaking
navigation.

So for example if i POST some form to

www.example.org/djangoapp/subscribe/

and then from there issue an HttpResponseRedirect('/success/')
pretending to be redirected to

www.example.org/djangoapp/success/

i instead get redirected to

www.example.org/success/

What should i look into to fix this, without going through the code
and changing all my redirects just for staging?

Thanks,
Lorenzo
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



HttpRequest with chunked encoding is not buffered

2008-10-31 Thread [EMAIL PROTECTED]

Hello,
I'm trying to receive a possibly large XML message via HttpRequest
(POST method) with chunked encoding. However, when I send a response,
I found out (using Wireshark) that the response is being sent before
the whole POST request body is available. I expected Django to be
buffering the chunks and that the request would be complete, but
that's apparently not happening...

I'm reading the body like this:
request.POST.values()[0]

(Which is probably a wrong way, but I don't know how to do it
otherwise.)

Thank for any help.
Tomas

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



Response is sent before post body arrives

2008-10-31 Thread [EMAIL PROTECTED]

Hi,

I'm using chunked transfer encoding and i send a post http request to
my Django application. But when I try to read the post body, it's not
there (request.POST.keys() returns []). according to Wireshark, I send
the response and right after that comes the request body.
Do you know how to wait till the body arrives?
And why does Django not wait for it automatically?

Thanks
Tom

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



Using Django

2008-10-31 Thread [EMAIL PROTECTED]

Hello,

I'm new to Django and it's taken me a while to get things setup
correctly on Dreamhost. I've done the tutorials on my local machine
prior to setting things up on Dreamhost but it seems like I'm missing
instructions on how to actually use Django. Yes, I've read the "Using
Django" section of the website but I don't even know how/where my
pages should reside. If I request http://www.mysite.com, how do I
route that to my "projects" directory where the "mysite" directory
resides, a symbolic link? - which I tried but just returns a 403
error. I'm still used to the traditional "mysite.com" directory which
contains index.php, contact.php, etc., and I don't understand how the
directory structure for Django works. It seems like the tutorials just
show you how to start a project under test conditions and show off the
built-in admin tools, without really explaining how things are setup
for an actual website. Maybe this system is over my head...

Thanks,

Jason
--~--~-~--~~~---~--~~
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: Execute a java program

2008-10-31 Thread [EMAIL PROTECTED]



On Oct 31, 2:21 pm, varikin <[EMAIL PROTECTED]> wrote:
> On Oct 30, 5:12 am, "[EMAIL PROTECTED]"
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > Hi everyone I am newbie to django and I am italian so excuse me for my
> > english :P
> > I have to execute a java program very simple look something like this:
>
> > public class Book {
> >     public static void main(String[] args) {
>
> >          int year = 2008;
>
> >          List list =  Booklist.fetchbook(year);
> >          Iterator it = list.iterator();
>
> >          while (it.hasNext()) {
> >              Book book = (Book) it.next();
> >              System.out.println( book.getTitle()  + " " +
> > book.getAuthor() );
> >             }
>
> > } }
>
> > and I have to retrieve 2 strings ( book.getTitle() and
> > book.getAuthor() ) for use its in django application.
> > How Can I do that? Do I have to use JVM ? How ?
>
> > thanks :)
>
> Also, take a look at Jython which is Python written on top of the JVM
> so you can call Java libraries within Python. Django 1.0 works with
> Jython.


thanks I'll try subprocess and jython but I have heard that django
with jython is slow. Is it 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User.email

2008-10-31 Thread [EMAIL PROTECTED]



On Oct 31, 1:32 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> On Oct 31, 11:01 am, Daniel Roseman <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > On Oct 31, 9:51 am, "Alfredo Alessandrini" <[EMAIL PROTECTED]>
> > wrote:
>
> > > 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
>
> > Well, no, you can't do this in the way that you've tried above. I
> > suppose you could override the save method to populate the model with
> > the value of the email.
>
> > But why would you want to? You already have a link from your Player to
> > the associated User. So whenever you need the email, you just look in
> > the related object:
>
> > my_player.user.email
>
> > --
> > DR.
>
> User don't have a email field.
> Look here:http://www.djangobook.com/en/1.0/chapter12/#cn222
>
> for storing additional information for user :)


ops excuse me user have got a email field.
So I agree with Daniel
--~--~-~--~~~---~--~~
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.email

2008-10-31 Thread [EMAIL PROTECTED]



On Oct 31, 11:01 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Oct 31, 9:51 am, "Alfredo Alessandrini" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > 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
>
> Well, no, you can't do this in the way that you've tried above. I
> suppose you could override the save method to populate the model with
> the value of the email.
>
> But why would you want to? You already have a link from your Player to
> the associated User. So whenever you need the email, you just look in
> the related object:
>
> my_player.user.email
>
> --
> DR.


User don't have a email field.
Look here:
http://www.djangobook.com/en/1.0/chapter12/#cn222

for storing additional information for user :)
--~--~-~--~~~---~--~~
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: FileField doesn't repopulate after a ValidationError on another field

2008-10-30 Thread [EMAIL PROTECTED]

Ok, this sounds logical to me.

I guess the best way to handle this is to make the uploading process
require 2 separate submission pages, the first one for all the regular
input, and then have a second page just to upload the file.

Perhaps somebody has a better idea?

Thanks

On Oct 30, 5:42 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 30, 2008 at 10:52 AM, [EMAIL PROTECTED] <
>
>
>
> [EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I've having a problem with FileField and ImageField. Basically, I have
> > a form for uploading images:
>
> > Name: _a_  (throws ValidationError('This name is already taken. Choose
> > another'))
> > Notes: _test notes_
> > Filename:  _abc123.txt_
>
> > When I press SUBMIT, I get the form again, but it looks like this:
>
> > -This name is already taken. Choose another
> > Name: _a_
> > Notes: _test notes_
> > Filename:  _ (blank Not sure why)
>
> > The FileField is not repopulated for some reason, but the other fields
> > are.
>
> I believe this is a browser security measure.  The browser won't allow a
> server to pre-load a value into a File input, because that would mean a
> naive user could easily submit a form which uploads some key file from their
> machine to the server.  So for a File input the browser requires that the
> user actually go and select a file to upload.  (I do not know if there are
> any tricks one can play to get around this, I've never looked for one.)
>
> Karen
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



FileField doesn't repopulate after a ValidationError on another field

2008-10-30 Thread [EMAIL PROTECTED]

Hello,

I've having a problem with FileField and ImageField. Basically, I have
a form for uploading images:

Name: _a_  (throws ValidationError('This name is already taken. Choose
another'))
Notes: _test notes_
Filename:  _abc123.txt_

When I press SUBMIT, I get the form again, but it looks like this:

-This name is already taken. Choose another
Name: _a_
Notes: _test notes_
Filename:  _ (blank Not sure why)

The FileField is not repopulated for some reason, but the other fields
are.

Using django-1.0

I bind the data as specified at
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#topics-file-uploads:

form = UploadNewImageForm(request.POST, request.FILES)

My view function is identical to the one on the example page.
Everything else works, the file is properly uploaded and there are no
other problems. It is really just a user interface issue I would like
to fix because it is very annoying to have to repopulate the form
every time there is an input error, especially if there are many
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: content type

2008-10-30 Thread [EMAIL PROTECTED]

thank you redmonkey

that is exactly what i was looking for.
have a nice day

redmonkey wrote:
> You need to set a 'Content-Disposition' header.
>
> http://docs.djangoproject.com/en/dev/howto/outputting-pdf/?from=olddocs#complex-pdfs
>
> Look within the 'some_view' definition. You need to generate a
> HttpResponse object, set the response mimetype to the correct type of
> file you're serving, and then set the 'Content-Disposition' key to
> something like it says. Notice you can also set the filename if you
> need to.
>
> On Oct 30, 9:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>   
>> hi all i am using debian stable version 0.95
>>
>> and i would like know, how to tell django not to open some file types as
>> JPG, PNG or MP3 in browser after click and rather open a classic menu to
>> save the file.
>>
>> thank you very much pavel
>> 
> >
>   


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



Execute a java program

2008-10-30 Thread [EMAIL PROTECTED]

Hi everyone I am newbie to django and I am italian so excuse me for my
english :P
I have to execute a java program very simple look something like this:


public class Book {
public static void main(String[] args) {

 int year = 2008;

 List list =  Booklist.fetchbook(year);
 Iterator it = list.iterator();

 while (it.hasNext()) {
 Book book = (Book) it.next();
 System.out.println( book.getTitle()  + " " +
book.getAuthor() );
}

} }


and I have to retrieve 2 strings ( book.getTitle() and
book.getAuthor() ) for use its in django application.
How Can I do that? Do I have to use JVM ? How ?

thanks :)

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



Syndication Feed-Problem

2008-10-30 Thread [EMAIL PROTECTED]

Hi,
i hope any one can help me.
I want to generate a rss-feed.
The url ist http://localhost:8000/isf/info/.
All works fine but the title of an Item and the Description are still
the same!
How can i change the title of an feed item in the feed to the title
from the model
and the description of the feed item to the description from the
model.
I get only the String from the __unicode__(self): Method. An this
string represent
the title and the description, why ?

Please help me!



My urls.py config:
feeds = {
'rss': Rss2Feed,

}

urlpatterns = patterns('django.contrib.syndication.views',
url(r'^(?P.*)/$', 'feed', {'feed_dict': feeds},
name="fh_feeds",),
)

Thats my models.py class:

class Item(models.Model):
title = models.CharField(max_length=30)
banner = models.CharField(max_length=30, null=True)
description = models.TextField(null=True)
pub_date = models.DateTimeField(auto_now=True,
verbose_name="Public Date")
expire_date = models.DateTimeField(verbose_name="Expire Date")
author = models.ForeignKey(User, editable=False)

def authors_email(self):
return "%s"%(self.author.email)

def get_absolute_url(self):
return "%s/"%(self.id)

def __unicode__(self):
return self.title

class Meta:
ordering = ['-pub_date']

class Item_Category(models.Model):
item = models.ForeignKey(Item)
category = models.ForeignKey(Category)

def __unicode__(self):
return "%s"%self.item.id

And thats my feed.py class:

class Rss2Feed(Feed):
#thats my hard-coded title,link and description for my info feed
title = "Info"
link = "/info/"
description = "Info-Site"

# i want to show all items of my model with the slug info
def items(self):
listOfItems = []
itemToCategoryForInfo =
Item_Category.objects.select_related().filter(category__slug = "info")
for selectedItem in itemToCategoryForInfo:
listOfItems.append(selectedItem.item)
return listOfItems





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



content type

2008-10-30 Thread [EMAIL PROTECTED]

hi all i am using debian stable version 0.95

and i would like know, how to tell django not to open some file types as 
JPG, PNG or MP3 in browser after click and rather open a classic menu to 
save the file.

thank you very much pavel

--~--~-~--~~~---~--~~
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: Email notification on updates?

2008-10-29 Thread [EMAIL PROTECTED]

Thanks Brian. The Observer in notification doesn't help me (I'd rather
keep my existing observer). The more I look at it, the more
notification looks like a nice piece of work. I just don't know how
much I'll end up reworking it for my purposes.


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



Email notification on updates?

2008-10-29 Thread [EMAIL PROTECTED]

I have a very simple "watchlist" app which allows people to keep an
eye on their favorite bits of content on the site... forum topics,
cars, articles, etc. Not much to it--it simply stores the object and
who's watching it:

class Watch(models.Model):
subscriber = models.ForeignKey(User, verbose_name="Subscriber")
content_type = models.ForeignKey(ContentType)
content_object = generic.GenericForeignKey()
object_id = models.IntegerField('object ID')

I've had several requests for email notifications when a watched item
changes/is updated.
Initially I thought of django-notification, but I'm having trouble
getting it running. It appears in its current state of development it
requires on-site notifications (useless to me) and atomformat??? So
I'm not sure if that's the way to go, or if I should just maybe send a
signal on save from the model(s) they can watch, loop through the
Watch items that match, and fire off an email to each subscriber.

I'm concerned about scalability, too. Some of these watched items,
like forum topics, can see a lot of changes.

Advice?


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



  1   2   3   4   5   6   7   8   9   10   >