File/Folder permissions for deploying Django app

2010-05-18 Thread flyinglegs
Hello,

I know that Django code and templates are should not sit in the root
and the same path with Apache. Is there a recommendated location for
deploying the Django app? Also, what is the best practice in terms of
the user account and group the Django folder should use?

Let's say on the virtual machine (ubuntu), I am thinking of creating a
new folder, /var/django, and create a user and a group called django
who owns this folder. Is this good enough? Do I need to assign
permissions so that mod_wsgi can serve django to apache requests?

Thanks!
Yi

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



ModelForm always calls Model's clean method

2010-05-18 Thread ak37
Hi,

I just tried the new Model Validation feature in Django 1.2 and I
found out that ModelForm always calls the Model's clean method even
when the form validation has errors. This causes problems when the
model has a foreign key, and the value is validated in the clean
method. Consider this example:

class Flight(models.Model):
aircraft = models.ForeignKey(Aircraft)
departure = models.ForeignKey(Departure)
arrival = models.ForeignKey(Arrival)

def clean(self):
# There can never be flights departing and arriving to the
same place
if self.departure == self.arrival:
raise ValidationError("Departure is the same as Arrival")

class FligthForm(forms.ModelForm):
class Meta:
model = Flight

If the form is submitted with empty values, I will get a DoesNotExist
exception when trying to access the self.departure/self.arrival
attribute in the clean method. Is this by design? If it is then what
is the recommended practice to implement the Model's clean method?

Regards,
Rendy Anthony (ak37)

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



css files are not loading properly for admin screens

2010-05-18 Thread Lokesh
Hi,

CSS files are not loading when i try to access the admin screens.

Here are the settings.py config file details
MEDIA_ROOT = ''
MEDIA_URL = 'http://127.0.0.1:8000'
ADMIN_MEDIA_PREFIX = '/media/'

Could some one please provide me help on this.

Thanks a lot.

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



How create M2M through with out PK?

2010-05-18 Thread poison...@gmail.com
Models:

from django.db import models

class People(models.Model):
name = models.CharField(max_length=30)

class Meta:
db_table = 'libs_peoples'

class Content(models.Model):
title = models.CharField(max_length=30)
peoples = models.ManyToManyField(People, through='Type')

class Meta:
db_table = 'libs_contents'

class Type(models.Model):
people = models.ForeignKey(People)
content = models.ForeignKey(Content)
type = models.CharField(max_length=10)

class Meta:
db_table = 'libs_content_has_people'


Generated SQL:

BEGIN;
CREATE TABLE "libs_peoples" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(30) NOT NULL
)
;
CREATE TABLE "libs_contents" (
"id" integer NOT NULL PRIMARY KEY,
"title" varchar(30) NOT NULL
)
;
CREATE TABLE "libs_content_has_people" (
"id" integer NOT NULL PRIMARY KEY,
"people_id" integer NOT NULL REFERENCES "libs_peoples" ("id"),
"content_id" integer NOT NULL REFERENCES "libs_contents" ("id"),
"type" varchar(10) NOT NULL
)
;
COMMIT;

How remove PK from table "libs_content_has_people" and don't use 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to insert a tuple into ManyToMany Relations

2010-05-18 Thread Daemoneye



class People(forms.Form):
HoldComments=models.ManyToManyField('Comment')
class Comment(forms.Form):
CommentWord=models.CharField(max_length=1)
I've had these two tables, I'd want the people make a comment so I new  
p=comment(CommentWord=Comment)in the view

but how can I save this tuple p of the comment to the People.HoldComment?
I can do it in the admin.But how can I do this job by the Django sentense?


thanks for helping me

--
吾血之血啊

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



How to retrieve data from Wikimapia using its API?

2010-05-18 Thread ravi krishna
Hi,

I am a beginner with Django. Can someone tell me how to access the database
of Wikimapia using its API through Django.

-- 
Regards,
Rav!

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



Re: Custom Form in a ModelFormset_Factory?

2010-05-18 Thread Ian Lewis
I'm pretty sure that modelformset_factory is not documented.

2010/5/19 Michael Davis :
> Thanks! I found that by looking at the source shortly after I posted
> the question. I'm surprised I didn't stumble across that option in the
> documentation. Do you have a link to any documentation that indicates
> this (and other features) is an option?
>
> On May 18, 1:10 am, Ian Lewis  wrote:
>> Pass the form class to modelformset_factory() in the form argument.
>> The factory will then use the AuthorForm class as the base form class
>> when it creates the modelform class for the formset.
>>
>> modelFormset = modelformset_factory(Author, form=AuthorForm)
>>
>> On Tue, May 18, 2010 at 7:08 AM, Michael Davis
>>
>>
>>
>>  wrote:
>>
>> > I am new to Django and am trying to get a custom modelForm to work in
>> > a ModelFormset_factory. For example:
>>
>> > # in models.py
>> > class Author(models.Model):
>> >name = models.CharField()
>> >address = models.CharField()
>> >phone = models.CharField()
>>
>> > class AuthorForm(ModelForm):
>> >class Meta:
>> >model = Author
>>
>> > # in views.py
>> > def authorForm(request):
>> >modelFormset = modelformset_factory(Author)
>> >items = Author.objects.all()
>> >formsetInstance = modelFormset(queryset=items)
>> >return render_to_response('blah',locals())
>>
>> > The above code works fine, but I'd like to be able to tweak the
>> > default presentation of the AuthorForm and use that in the
>> > formset_factory. Is there any way to do that through the AuthorForm
>> > class above? If not is there another nearly easy way?
>>
>> > 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-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> ===
>> 株式会社ビープラウド  イアン・ルイス
>> 〒150-0021
>> 東京都渋谷区恵比寿西2-3-2 NSビル6階
>> email: ianmle...@beproud.jp
>> TEL:03-6416-9836
>> FAX:03-6416-9837http://www.beproud.jp/
>> ===
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group 
>> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
===
株式会社ビープラウド  イアン・ルイス
〒150-0021
東京都渋谷区恵比寿西2-3-2 NSビル6階
email: ianmle...@beproud.jp
TEL:03-6416-9836
FAX:03-6416-9837
http://www.beproud.jp/
===

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



"select for update" with models

2010-05-18 Thread Greg Pelly
Hi,

I'm new to Django -- looking to write a credit card transaction module and I
need the ability to perform a "SELECT FOR UPDATE" (mysql) so that an order
does not get processed by two different threads.

I see an open ticket for this here:
http://code.djangoproject.com/ticket/2705

Has anyone successfully used this code in a production environment?

Any workarounds that people can think of?

Greg

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



Re: ajax setup

2010-05-18 Thread Brian Neal
On May 18, 9:57 am, Matt W  wrote:
> Hello Everyone,
>
> I just started to use Django and I was wondering how I could setup
> javascipt (AJAX to be more specfic) in my djagno project in order to
> run a script. Here is the script code.
>
[snip]
>
> In specific I was wondering where I place the source code for the
> javascipt file along with what files I need to configure in the
> project folder. I'm very new to django so I don't really know how to
> even start this.
>

Django is a server-side framework, it doesn't require configuration
for client-side javascript, save for perhaps your MEDIA_URL. Your
script doesn't reference any local javascript files, but if you had
them, you'd probably want to put them in your media directory, say
media/js. Your templates would just reference them, perhaps using
{{ MEDIA_URL }} or just hard-coding a path to them. You are free to
sprinkle javascript 

Sync user objects with sympa mailinglist

2010-05-18 Thread Dexter
Hi,

I want to sync emailadresses in the django.contrib.auth User model, to a
sympa mailinglist subscriberlist.
I really don't have any experience with sympa. So I don't know how this
process usually goes,
but what I did found out, is that sympa documentation is lacking a bit.
I find the concepts they use really vague, but I guess its powerful as well.

Does anyone know how this is done?

Grtz, Dexter

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



Re: insert html in html

2010-05-18 Thread Brian Neal
On May 18, 2:00 pm, CrabbyPete  wrote:
> I want to insert a html calendar into an existing web page. What is
> the best way to insert html into a template that I have for the web
> page?

In what form do you have this calendar HTML? Do you compute it in a
view? Is it already in a file? If you have it in a view, then one way
to do it would be to pass it to a template and in the template:

My Calendar

{{ my_calendar_data|safe }}


You could make this a template tag, or {% include %} it, or put it in
your base template...

We'd need more information to help further.

Hope that helps.
BN

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



Re: send_mail not firing

2010-05-18 Thread Nick
Actually, I've fixed the problem with send_activation. If i go via the
form it still doesn't trigger the email.

On May 18, 5:19 pm, Nick  wrote:
> I get the same results.
>
> I dropped into the shell and tried it out
>
> >>> user = User(username="nick", email="t...@test.com")
> >>> send_activation(user)
>
> 1
>
> I think the 1 means that it passed but I don't get any emails sent
>
> On May 18, 5:08 pm, "ge...@aquarianhouse.com"
>
>
>
>  wrote:
> > what happens if you set fail_silently to True?
>
> > On May 19, 12:05 am, Nick  wrote:
>
> > > I am having an issue with an authentication app I am writing. The app
> > > saves the form appropriately but doesn't send the confirmation email.
> > > I am using the same email_host settings as with other application that
> > > send email messages but with no results. Here is the process.
>
> > > First a form processes the information:
>
> > > from django.contrib.auth.forms import UserCreationForm
> > > from django import forms
> > > from django.contrib.auth.models import User
> > > from activate import send_activation
>
> > > class RegisterForm(UserCreationForm):
> > >     email = forms.EmailField(label="E-Email")
>
> > >     class Meta:
> > >         model = User
> > >         fields = ("username", "email")
>
> > >     def clean_email(self):
> > >         email = self.cleaned_data["email"]
>
> > >         try:
> > >             User.objects.get(email=email)
> > >         except User.DoesNotExist:
> > >             return email
>
> > >         raise forms.ValidationError("A user with that email address
> > > already exists.")
>
> > >         def save(self):
> > >             user = super(RegisterForm, self).save(commit=False)
> > >             send_activation(user)
> > >             user.is_active = False
> > >             user.save()
>
> > > the activate.py file:
>
> > > from django.core.mail import send_mail
> > > from hashlib import md5
> > > from django.template import loader, Context
> > > from Obits.settings import BASE_URL as base_url
>
> > > def send_activation(user):
> > >     code = md5(user.username).hexdigest()
> > >     url = "%sactivate/?user=%s=%s" % (base_url, user.username,
> > > code)
> > >     template = loader.get_template('obits/eactivate.html')
> > >     context = ({
> > >          'username': user.username,
> > >          'url': url,
> > >      })
> > >     send_mail('Activate account at super site', 'this is a test',
> > > 'myem...@mydomain.com, [user.email], fail_silently=False)
>
> > > The form saves to the DB, it hits all of the conditions but fails to
> > > send an email. I can't get any error messages so I'm really at a loss.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: send_mail not firing

2010-05-18 Thread Nick
OK, it's all fixed. I updated the template rendering to actually use
Context, if you look at activate.py I just put "context = ({". That's
not helping anything out. I also added a default_host_email to the
settings file. I don't know if that was the problem, but I'm leaving
it in.

On May 18, 5:19 pm, Nick  wrote:
> I get the same results.
>
> I dropped into the shell and tried it out
>
> >>> user = User(username="nick", email="t...@test.com")
> >>> send_activation(user)
>
> 1
>
> I think the 1 means that it passed but I don't get any emails sent
>
> On May 18, 5:08 pm, "ge...@aquarianhouse.com"
>
>
>
>  wrote:
> > what happens if you set fail_silently to True?
>
> > On May 19, 12:05 am, Nick  wrote:
>
> > > I am having an issue with an authentication app I am writing. The app
> > > saves the form appropriately but doesn't send the confirmation email.
> > > I am using the same email_host settings as with other application that
> > > send email messages but with no results. Here is the process.
>
> > > First a form processes the information:
>
> > > from django.contrib.auth.forms import UserCreationForm
> > > from django import forms
> > > from django.contrib.auth.models import User
> > > from activate import send_activation
>
> > > class RegisterForm(UserCreationForm):
> > >     email = forms.EmailField(label="E-Email")
>
> > >     class Meta:
> > >         model = User
> > >         fields = ("username", "email")
>
> > >     def clean_email(self):
> > >         email = self.cleaned_data["email"]
>
> > >         try:
> > >             User.objects.get(email=email)
> > >         except User.DoesNotExist:
> > >             return email
>
> > >         raise forms.ValidationError("A user with that email address
> > > already exists.")
>
> > >         def save(self):
> > >             user = super(RegisterForm, self).save(commit=False)
> > >             send_activation(user)
> > >             user.is_active = False
> > >             user.save()
>
> > > the activate.py file:
>
> > > from django.core.mail import send_mail
> > > from hashlib import md5
> > > from django.template import loader, Context
> > > from Obits.settings import BASE_URL as base_url
>
> > > def send_activation(user):
> > >     code = md5(user.username).hexdigest()
> > >     url = "%sactivate/?user=%s=%s" % (base_url, user.username,
> > > code)
> > >     template = loader.get_template('obits/eactivate.html')
> > >     context = ({
> > >          'username': user.username,
> > >          'url': url,
> > >      })
> > >     send_mail('Activate account at super site', 'this is a test',
> > > 'myem...@mydomain.com, [user.email], fail_silently=False)
>
> > > The form saves to the DB, it hits all of the conditions but fails to
> > > send an email. I can't get any error messages so I'm really at a loss.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Invitation to connect on LinkedIn

2010-05-18 Thread Nitzan Brumer
LinkedIn
Nitzan Brumer requested to add you as a connection on LinkedIn:
--

David,

I'd like to add you to my professional network on LinkedIn.

- Nitzan

Accept invitation from Nitzan Brumer
http://www.linkedin.com/e/9FjGxeSxbe2CaYJw_BjdQigBBG4n6ACF_BMhl3N6oSq4/blk/I61244194_6/6lColZJrmZznQNdhjRQnOpBtn9QfmhBt71BoSd1p65Lr6lOfPpvd3ANd3gOcjp9bSVzqDdPi68VbP0Nc34Ve38NcP4LrCBxbOYWrSlI/EML_comm_afe/

View invitation from Nitzan Brumer
http://www.linkedin.com/e/9FjGxeSxbe2CaYJw_BjdQigBBG4n6ACF_BMhl3N6oSq4/blk/I61244194_6/dBYQej4Qd38NdAALqnpPbOYWrSlI/svi/
--

DID YOU KNOW you can be the first to know when a trusted member of your network 
changes jobs? With Network Updates on your LinkedIn home page, you'll be 
notified as members of your network change their current position. Be the first 
to know and reach out!
http://www.linkedin.com/

 
--
(c) 2010, LinkedIn Corporation

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



Re: reverse() with multiple possibilities: Is there a way to retrieve all?

2010-05-18 Thread Bill Freeman
Make one of the urls pass an argument using parentheses in the pattern.  Then
make that an option argument in the view function.  Reverse will return one if
you supply the argument, and the other if you don't.

But why not use named patterns and reverse by pattern name?

In either case you have to call reverse twice to get both, but it's an
unusual need
and I think that you're stuck doing some view coding here anyway.

On Tue, May 18, 2010 at 4:44 PM, Thomas Allen  wrote:
> If I have two URLs which resolve to the same view. Is there any way to
> get both? I rely on reverse() for some "active page" logic and the
> trouble is that it will only return a single URL, the first match it
> has encountered.
>
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: send_mail not firing

2010-05-18 Thread Nick
I get the same results.

I dropped into the shell and tried it out

>>> user = User(username="nick", email="t...@test.com")
>>> send_activation(user)
1

I think the 1 means that it passed but I don't get any emails sent

On May 18, 5:08 pm, "ge...@aquarianhouse.com"
 wrote:
> what happens if you set fail_silently to True?
>
> On May 19, 12:05 am, Nick  wrote:
>
>
>
> > I am having an issue with an authentication app I am writing. The app
> > saves the form appropriately but doesn't send the confirmation email.
> > I am using the same email_host settings as with other application that
> > send email messages but with no results. Here is the process.
>
> > First a form processes the information:
>
> > from django.contrib.auth.forms import UserCreationForm
> > from django import forms
> > from django.contrib.auth.models import User
> > from activate import send_activation
>
> > class RegisterForm(UserCreationForm):
> >     email = forms.EmailField(label="E-Email")
>
> >     class Meta:
> >         model = User
> >         fields = ("username", "email")
>
> >     def clean_email(self):
> >         email = self.cleaned_data["email"]
>
> >         try:
> >             User.objects.get(email=email)
> >         except User.DoesNotExist:
> >             return email
>
> >         raise forms.ValidationError("A user with that email address
> > already exists.")
>
> >         def save(self):
> >             user = super(RegisterForm, self).save(commit=False)
> >             send_activation(user)
> >             user.is_active = False
> >             user.save()
>
> > the activate.py file:
>
> > from django.core.mail import send_mail
> > from hashlib import md5
> > from django.template import loader, Context
> > from Obits.settings import BASE_URL as base_url
>
> > def send_activation(user):
> >     code = md5(user.username).hexdigest()
> >     url = "%sactivate/?user=%s=%s" % (base_url, user.username,
> > code)
> >     template = loader.get_template('obits/eactivate.html')
> >     context = ({
> >          'username': user.username,
> >          'url': url,
> >      })
> >     send_mail('Activate account at super site', 'this is a test',
> > 'myem...@mydomain.com, [user.email], fail_silently=False)
>
> > The form saves to the DB, it hits all of the conditions but fails to
> > send an email. I can't get any error messages so I'm really at a loss.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: send_mail not firing

2010-05-18 Thread Nick
I get the same result.

I dropped into the shell and ran this

>>> user = User(username="test", email="t...@test.com")
>>>send_activation(user)
1

I don't really know what that 1 means, though.

On May 18, 5:08 pm, "ge...@aquarianhouse.com"
 wrote:
> what happens if you set fail_silently to True?
>
> On May 19, 12:05 am, Nick  wrote:
>
>
>
> > I am having an issue with an authentication app I am writing. The app
> > saves the form appropriately but doesn't send the confirmation email.
> > I am using the same email_host settings as with other application that
> > send email messages but with no results. Here is the process.
>
> > First a form processes the information:
>
> > from django.contrib.auth.forms import UserCreationForm
> > from django import forms
> > from django.contrib.auth.models import User
> > from activate import send_activation
>
> > class RegisterForm(UserCreationForm):
> >     email = forms.EmailField(label="E-Email")
>
> >     class Meta:
> >         model = User
> >         fields = ("username", "email")
>
> >     def clean_email(self):
> >         email = self.cleaned_data["email"]
>
> >         try:
> >             User.objects.get(email=email)
> >         except User.DoesNotExist:
> >             return email
>
> >         raise forms.ValidationError("A user with that email address
> > already exists.")
>
> >         def save(self):
> >             user = super(RegisterForm, self).save(commit=False)
> >             send_activation(user)
> >             user.is_active = False
> >             user.save()
>
> > the activate.py file:
>
> > from django.core.mail import send_mail
> > from hashlib import md5
> > from django.template import loader, Context
> > from Obits.settings import BASE_URL as base_url
>
> > def send_activation(user):
> >     code = md5(user.username).hexdigest()
> >     url = "%sactivate/?user=%s=%s" % (base_url, user.username,
> > code)
> >     template = loader.get_template('obits/eactivate.html')
> >     context = ({
> >          'username': user.username,
> >          'url': url,
> >      })
> >     send_mail('Activate account at super site', 'this is a test',
> > 'myem...@mydomain.com, [user.email], fail_silently=False)
>
> > The form saves to the DB, it hits all of the conditions but fails to
> > send an email. I can't get any error messages so I'm really at a loss.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: send_mail not firing

2010-05-18 Thread ge...@aquarianhouse.com
what happens if you set fail_silently to True?

On May 19, 12:05 am, Nick  wrote:
> I am having an issue with an authentication app I am writing. The app
> saves the form appropriately but doesn't send the confirmation email.
> I am using the same email_host settings as with other application that
> send email messages but with no results. Here is the process.
>
> First a form processes the information:
>
> from django.contrib.auth.forms import UserCreationForm
> from django import forms
> from django.contrib.auth.models import User
> from activate import send_activation
>
> class RegisterForm(UserCreationForm):
>     email = forms.EmailField(label="E-Email")
>
>     class Meta:
>         model = User
>         fields = ("username", "email")
>
>     def clean_email(self):
>         email = self.cleaned_data["email"]
>
>         try:
>             User.objects.get(email=email)
>         except User.DoesNotExist:
>             return email
>
>         raise forms.ValidationError("A user with that email address
> already exists.")
>
>         def save(self):
>             user = super(RegisterForm, self).save(commit=False)
>             send_activation(user)
>             user.is_active = False
>             user.save()
>
> the activate.py file:
>
> from django.core.mail import send_mail
> from hashlib import md5
> from django.template import loader, Context
> from Obits.settings import BASE_URL as base_url
>
> def send_activation(user):
>     code = md5(user.username).hexdigest()
>     url = "%sactivate/?user=%s=%s" % (base_url, user.username,
> code)
>     template = loader.get_template('obits/eactivate.html')
>     context = ({
>          'username': user.username,
>          'url': url,
>      })
>     send_mail('Activate account at super site', 'this is a test',
> 'myem...@mydomain.com, [user.email], fail_silently=False)
>
> The form saves to the DB, it hits all of the conditions but fails to
> send an email. I can't get any error messages so I'm really at a loss.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



send_mail not firing

2010-05-18 Thread Nick
I am having an issue with an authentication app I am writing. The app
saves the form appropriately but doesn't send the confirmation email.
I am using the same email_host settings as with other application that
send email messages but with no results. Here is the process.

First a form processes the information:

from django.contrib.auth.forms import UserCreationForm
from django import forms
from django.contrib.auth.models import User
from activate import send_activation

class RegisterForm(UserCreationForm):
email = forms.EmailField(label="E-Email")

class Meta:
model = User
fields = ("username", "email")

def clean_email(self):
email = self.cleaned_data["email"]

try:
User.objects.get(email=email)
except User.DoesNotExist:
return email

raise forms.ValidationError("A user with that email address
already exists.")

def save(self):
user = super(RegisterForm, self).save(commit=False)
send_activation(user)
user.is_active = False
user.save()

the activate.py file:

from django.core.mail import send_mail
from hashlib import md5
from django.template import loader, Context
from Obits.settings import BASE_URL as base_url

def send_activation(user):
code = md5(user.username).hexdigest()
url = "%sactivate/?user=%s=%s" % (base_url, user.username,
code)
template = loader.get_template('obits/eactivate.html')
context = ({
 'username': user.username,
 'url': url,
 })
send_mail('Activate account at super site', 'this is a test',
'myem...@mydomain.com, [user.email], fail_silently=False)


The form saves to the DB, it hits all of the conditions but fails to
send an email. I can't get any error messages so I'm really at a loss.


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



Localized fields in modelforms/modeladmin

2010-05-18 Thread Dejan Noveski
Hi everybody,

Is there a way i can localize some of the form fields from the ModelForm
class or ModelAdmin class?

-- 
--
Dejan Noveski
Web Developer
dr.m...@gmail.com
Twitter: http://twitter.com/dekomote | LinkedIn:
http://mk.linkedin.com/in/dejannoveski

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



Re: Extend User

2010-05-18 Thread Alexandre González
I need some more info :)

I've get this: http://img138.imageshack.us/img138/200/descargan.png it's
pretty but need to change somethings...

   1. *I need that user be a EmailField unique. User is defined in auth.User
   so I don't know how change it.*
   2. In "User Profiles" I like to change the title, and delete "User
   Profile: #1" because it's a 1-1 relation between my create UserProfile and
   the auth.User

This is my code:

models.py

from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
BUSINESS_SIZE_CHOICES = (
('1', '1 to 10 employees'),
('11', '11 to 50 employees'),
('51', '51 to 250 employees'),
('251', '251 and above employees'),
)

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

#email = models.EmailField(unique=True, help_text='Unique email, you
can\'t reuse it in another profile.')
sector = models.CharField(max_length=100, help_text='Business sector of
activity.')
countries = models.CharField(max_length=100, help_text='Countries where
the business are.')
business_activity = models.CharField(max_length=100, help_text='Your
business principal activity.')
business_size = models.SmallIntegerField(choices=BUSINESS_SIZE_CHOICES,
help_text='Choose your aproximately business size.')
business_description = models.TextField(help_text='Little description
about your business, some as a "Elevator Pitch".')
ranking = models.CharField(max_length=50, help_text='Your ranking in the
business. Example: CEO, CKO...')
linkedin = models.CharField(max_length=50, help_text='Your linkedin
profile.')
twitter = models.CharField(max_length=50, help_text='Your twitter
profile.')
xing = models.CharField(max_length=50, help_text='Your xing profile.')

And this is my admin.py

from networking.lukkom.models import UserProfile
from django.contrib.auth.models import User
from django.contrib import admin

class UserProfileAdmin(admin.StackedInline):
model = UserProfile
fields = ['sector', 'countries', 'business_activity', 'business_size',
'business_description', 'ranking', ]

class UserAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['username', 'password']}),
('Advanced', {'fields': ['is_staff', 'is_active', 'is_superuser',
'last_login', 'date_joined'], 'classes': ['collapse']}),
]
inlines = [UserProfileAdmin]

admin.site.unregister(User)
admin.site.register(User, UserAdmin)


2010/5/18 Alexandre González 

> Perfect, thanks for your help!
>
>
> On Tue, May 18, 2010 at 14:03, zinckiwi  wrote:
>
>> On May 18, 7:57 am, Alexandre González  wrote:
>> > But don't you think that have attributes that I don't need is a
>> perfomance
>> > lost? I only ask, I'm learning django :)
>> >
>> > I go to see the documentation that you send me, thanks for your help.
>>
>> There will be a minuscule amount of overhead from the query for User
>> objects referring to fields you don't use, but I mean *really*
>> minuscule. Unmeasurable unless you are Twitter. Don't worry about it.
>>
>> Regards
>> Scott
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.com
>



-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



reverse() with multiple possibilities: Is there a way to retrieve all?

2010-05-18 Thread Thomas Allen
If I have two URLs which resolve to the same view. Is there any way to
get both? I rely on reverse() for some "active page" logic and the
trouble is that it will only return a single URL, the first match it
has encountered.

Thomas

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



Can you give me explanation for my

2010-05-18 Thread Hendra Kurniawan

Hi all,
Can you give me a bright explanation for Django Framework ? how can
Django being configure in cloud computing? it's support? can you give
me some link article for this ?

Thanks Before that..

Sincerely

Hendra

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



Re: admin media and template override ignored after switch to 1.2rc

2010-05-18 Thread C4m1l0
Hi, I've encountered the same problem.  When I look in the page source
the link point to the correct localization, but the CSS and images
aren't loaded, the layout is default. Could anyone help us? :)

Thanks!

On May 17, 8:37 am, naos  wrote:
> Well now I think that it might be related to virtualenv since I
> created new virtualenv with Django 1.1.1 and have the same result.
>
> On May 17, 12:44 pm, naos  wrote:
>
>
>
>
>
> > Hi All,
>
> > Today I tried to switch my project  from 1.0.4 to 1.2rc version and I
> > encountered problem withadminmediadefinitions andtemplate
> > override. It simply doesn't work :) JS,CSS files are not included in
> > the html and alltemplatecustomizations are not present, looks like
> > my custom templates are not loaded anymore.
>
> > Does anyone have similar problem? Any solutions?
>
> > Greetings,
> > Lukasz
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Error in form validation with choices

2010-05-18 Thread Jori
Thanks, you're correct. I don't know how I didn't notice but then
again it worked just fine with 1.1.1.

-Jori

On May 18, 11:03 pm, Daniel Roseman  wrote:
>
> It's an integer field, but the choices are all strings. The first
> value in each tuple should be an integer, to match the field.
> --
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Error in form validation with choices

2010-05-18 Thread Daniel Roseman
On May 18, 8:49 pm, Jori  wrote:
> Hi,
>
> I upgraded one of my projects to 1.2 today. I noticed that one of my
> model forms won't validate anymore:
>
> class Review(Entry):
>     RATING_VALUE_CHOICES = (
>         ('1', _('1. Overpriced')),
>         ('2', _('2. Prices above average')),
>         ('3', _('3. Average price range')),
>         ('4', _('4. Inexpensive')),
>         ('5', _('5. Excellent value')),
>     )
>
>     communication = models.IntegerField(max_length=1,
> choices=RATING_COMMUNICATION_CHOICES, verbose_name =
> _('communication'), help_text=_('i.e. customer service, order
> confirmations'))
>     ...
>
> And yes this is a child model inheriting model Entry (plain multi-
> table inheritance). The Entry model has also one IntegerField with
> choices and it works just fine. My form is created using ModelForm
> without any custom stuff and this also gives error under admin ("Value
> 2 is not a valid choice.").
>
> Anyone else having the same problem?
>
> -Jori
>

It's an integer field, but the choices are all strings. The first
value in each tuple should be an integer, to match the field.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Error in form validation with choices

2010-05-18 Thread Jori
Uups, copypasted the wrong choices list. The format is the same so
don't mind the variable name.

On May 18, 10:49 pm, Jori  wrote:
> Hi,
>
> I upgraded one of my projects to 1.2 today. I noticed that one of my
> model forms won't validate anymore:
>
> class Review(Entry):
>     RATING_VALUE_CHOICES = (
>         ('1', _('1. Overpriced')),
>         ('2', _('2. Prices above average')),
>         ('3', _('3. Average price range')),
>         ('4', _('4. Inexpensive')),
>         ('5', _('5. Excellent value')),
>     )
>
>     communication = models.IntegerField(max_length=1,
> choices=RATING_COMMUNICATION_CHOICES, verbose_name =
> _('communication'), help_text=_('i.e. customer service, order
> confirmations'))
>     ...
>
> And yes this is a child model inheriting model Entry (plain multi-
> table inheritance). The Entry model has also one IntegerField with
> choices and it works just fine. My form is created using ModelForm
> without any custom stuff and this also gives error under admin ("Value
> 2 is not a valid choice.").
>
> Anyone else having the same problem?
>
> -Jori
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Error in form validation with choices

2010-05-18 Thread Jori
Hi,

I upgraded one of my projects to 1.2 today. I noticed that one of my
model forms won't validate anymore:

class Review(Entry):
RATING_VALUE_CHOICES = (
('1', _('1. Overpriced')),
('2', _('2. Prices above average')),
('3', _('3. Average price range')),
('4', _('4. Inexpensive')),
('5', _('5. Excellent value')),
)

communication = models.IntegerField(max_length=1,
choices=RATING_COMMUNICATION_CHOICES, verbose_name =
_('communication'), help_text=_('i.e. customer service, order
confirmations'))
...

And yes this is a child model inheriting model Entry (plain multi-
table inheritance). The Entry model has also one IntegerField with
choices and it works just fine. My form is created using ModelForm
without any custom stuff and this also gives error under admin ("Value
2 is not a valid choice.").

Anyone else having the same problem?

-Jori

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



Proxy models and object instantiation

2010-05-18 Thread janedenone
Hi,

I'd like to use proxy models to define different properties for
different kinds of pages in my Django CMS. Which proxy model/class an
object belongs to is based on a certain field's value. Before querying
the database, my view cannot know which proxy model to use for
instantiation.

What is the preferred way to choose (and apply) the right proxy model
after retrieving the object?

- Jan

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



insert html in html

2010-05-18 Thread CrabbyPete
I want to insert a html calendar into an existing web page. What is
the best way to insert html into a template that I have for the web
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multi-table inheritance - knowing the child object from the parent

2010-05-18 Thread Jori
http://docs.djangoproject.com/en/1.2/topics/db/models/#id7

You can access sub-classes with place.restaurant and place.gardenstore
if the model has them.

I did something similar the other day but added an extra field to
parent class to indicate which type of a child model it had (1 for
Restaurant etc). I don't know if this is a proper way to handle the
situation but it works for me.

-Jori

On May 18, 7:11 pm, Lee Hinde  wrote:
> On Tue, May 18, 2010 at 4:27 AM, Jani Tiainen  wrote:
> > > Given the following:
>
> > > class Place(models.Model):
> > >     name = models.CharField(max_length=50)
> > >     address = models.CharField(max_length=80)
> > >     zip_code = models.CharField(max_length=15)
>
> > > class Restaurant(Place):
> > >     serves_hot_dogs = models.BooleanField()
> > >     serves_pizza = models.BooleanField()
>
> > > class GardenStore(Place):
> > >     sells_lady_bugs = models.BooleanField()
>
> > > and given a query on zip_code in Places, how would I know whether a
> > > Place is a Restaurant or a Garden Store?
>
> > You don't OOTB.
>
> > I asked same thing quite a while ago - you should be able to find my
> > thoughts
> > somewhere in this group archives.
>
> > Rationale behind this is that you're trying to achieve something pretty
> > much
> > impossible - inheritance in relational world.
>
> > Thing is that you can have you can really have both: Restaurant and
> > GardenStore instance to point to same place - so is that correct case or
> > not?
>
> > Note that "inheritance" is made so that you have relation from Restaurant
> > and
> > GardenStore tables to Place. There is no simple mechanism to prevent your
> > data
> > to have references from both "children" to point to "parent".
>
> > You can have property/method on your model that tries to determine which
> > one
> > is correct.
>
> > Or you can re-factor your models (which is usually less painful) so that
> > your
> > place, provided that it is unique (which actually in this case might not
> > be).
> > Add simple discriminator field to tell what type of child you must also
> > fetch
> > to make data complete.
>
>  Thanks Jani; I'd seen some of the older threads, with similar work arounds,
> but those discussions pre-dated recent advances. I'll look again for the
> thread you mention.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Installing 3rd party django applications on a shared environment

2010-05-18 Thread Tom Evans
On Tue, May 18, 2010 at 6:33 PM, Bill Freeman  wrote:
> Because the incantation is ". activate", not "./activate".  "." is a
> shell command
> a.k.a. source, which reads the file and executes it in the current shell.  It 
> is
> not a command to run as a sub-process.
>

As Bill says, . is the shortcut/original name of the 'source' command.
You want to run the contents of activate in the current shell (it sets
some environment variables).

I always type it as '. ./activate' out of habit :/

Cheers

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



Re: Cannot concatenate context list. Bizarre.

2010-05-18 Thread Thomas Allen
And the following ugly loop adds scripts as I hoped simple
concatenation would:

def render(self, context):
  for i in range(0, len(self.scripts)):
context['scripts'].insert(i, self.scripts[i])
  return ''

Thomas

On May 18, 2:31 pm, Thomas Allen  wrote:
> I would like to be able to allow any template file to add its own
> JavaScript. Seemed like an easy implementation:
>
> class AddScriptNode(Node):
>   def __init__(self, scripts=[]):
>     self.scripts = scripts
>
>   def render(self, context):
>     context['scripts'] = self.scripts + context['scripts']
>     return ''
>
> @register.tag
> def add_scripts(parser, token):
>   bits = list(token.split_contents())
>   if len(bits) > 1:
>     return AddScriptNode(bits[1:])
>   else:
>     return AddScriptNode()
>
> {% add_scripts moo moo-more nativelib pnc %}
>
> Note that I add the existing scripts to the end of the added scripts
> because templates seem to be evaluated bottom-to-top, meaning a simple
> extend() call would cause the sub-template scripts to be at the
> beginning of the list (no good).
>
> The trouble is that this code clobbers context['scripts'] each time
> render() is called. I have no idea why that is, because if I replace
> that line with:
>
> context['scripts'].extend(self.scripts)
>
> then the scripts are added to the end, and nothing is clobbered. The
> same goes for the equivalent:
>
> context['scripts'] += self.scripts
>
> This makes no sense to me. What's going on here?
>
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Cannot concatenate context list. Bizarre.

2010-05-18 Thread Thomas Allen
I would like to be able to allow any template file to add its own
JavaScript. Seemed like an easy implementation:

class AddScriptNode(Node):
  def __init__(self, scripts=[]):
self.scripts = scripts

  def render(self, context):
context['scripts'] = self.scripts + context['scripts']
return ''

@register.tag
def add_scripts(parser, token):
  bits = list(token.split_contents())
  if len(bits) > 1:
return AddScriptNode(bits[1:])
  else:
return AddScriptNode()

{% add_scripts moo moo-more nativelib pnc %}

Note that I add the existing scripts to the end of the added scripts
because templates seem to be evaluated bottom-to-top, meaning a simple
extend() call would cause the sub-template scripts to be at the
beginning of the list (no good).

The trouble is that this code clobbers context['scripts'] each time
render() is called. I have no idea why that is, because if I replace
that line with:

context['scripts'].extend(self.scripts)

then the scripts are added to the end, and nothing is clobbered. The
same goes for the equivalent:

context['scripts'] += self.scripts

This makes no sense to me. What's going on here?

Thomas

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



Re: No stylesheet in administration panel

2010-05-18 Thread Brian Neal
On May 18, 10:47 am, Carlo Trimarchi  wrote:
> Hi,
> I'm following the django tutorial to build the poll application. I'm
> working mostly on a remote server (using wsgi), but I'm also trying
> stuff on my local machine, just running the manage.py runserver
> command.
> I've just enabled the admin site and it works. But when I access the
> page on the server it just doesn't use any style. I mean, I don't see
> coloured boxes, no cool fonts or the correct layout. If I run the
> local version it is displayed correctly. I'm sure that the code is the
> same for both versions, since the local one is just the remote
> directory mounted through ssh.
>
> So, what can be the problem?
>
You need to configure Apache / mod_wsgi to serve the static files.
Here is a place to start:

http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/#howto-deployment-modwsgi

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



Re: No stylesheet in administration panel

2010-05-18 Thread Carlo Trimarchi
On 18 May 2010 17:25, ryan west  wrote:
> Just a django noob, but are you sure that the path for media is set
> correctly in your settings.py file?
>
> For instance, my media settings look like:
>
> MEDIA_ROOT = '/home/ryanisnan/ryanwest.info/public/media'
> MEDIA_URL = '/media/'
> ADMIN_MEDIA_PREFIX = '/media/'

Mh, I've never edited that variables, so, since it works on my machine
I think the problem should be somewhere else.

Unless I need to change them when I'm not running the Django server.

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



Re: No stylesheet in administration panel

2010-05-18 Thread Mitch Anderson
Depending on your ADMIN_MEDIA_PREFIX in settings.py (default is /media/)

your webserver should be configured to point to the django admin media
location...

I have this line in my apache config

Alias /media/ /usr/share/pyshared/django/contrib/admin/media/

-Mitch

On Tue, May 18, 2010 at 9:47 AM, Carlo Trimarchi wrote:

> Hi,
> I'm following the django tutorial to build the poll application. I'm
> working mostly on a remote server (using wsgi), but I'm also trying
> stuff on my local machine, just running the manage.py runserver
> command.
> I've just enabled the admin site and it works. But when I access the
> page on the server it just doesn't use any style. I mean, I don't see
> coloured boxes, no cool fonts or the correct layout. If I run the
> local version it is displayed correctly. I'm sure that the code is the
> same for both versions, since the local one is just the remote
> directory mounted through ssh.
>
> So, what can be the problem?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Missing Response

2010-05-18 Thread steve
Just wondering what happened to my response to:

  Record won't Insert, possibly due to not using built in 'ID'?

  It says Last Post by Steve, but the message is missing.

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



Re: Reflect changes made through Manager to model instances

2010-05-18 Thread Daniel Roseman
On May 18, 9:21 am, Alexei Selivanov 
wrote:
> Is it possible to reflect changes made through model's Manager to
> model instances? For example I have ProfileManager class like so:
>
> class ProfileManager(models.Manager):
>
>     def activate_profile(self, id, activation_key):
>         # do activation
>
> And I want changes made by this method be visible in Profile instances.

It's not really clear what your question is. Exactly what is
active_profile doing? Using my crystal ball, it seems that you are
passing an ID in, presumably of a Profile instance. So what are you
hoping to happen? Updating the database row corresponding to that ID?

It seems you are going about this the wrong way. activate_profile
should be a **model** method, not a Manager one. Then it would operate
on that instance directly.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Record won't Insert, possibly due to not using built in 'ID'?

2010-05-18 Thread steve
Hi,

  Are you wrapping the insert statement in a Try?  First, make sure
you're doing that.

  Also, add a parameter after "except Exception" like so:

try:
   instance = TableClassName.(field="a value",
user_id=request.user.id)
   instance.save()

except Exception, msg <--- add this
   print msg


The output of msg will tell you exactly what's going on.

(Make sure also you're including all of the fields that are "not
null", but I'm guessing that particular error would cause the full-
page development error output that Django gives you.)

Steve



On May 18, 8:37 am, beetlecube  wrote:
> ( Not sure what happened to the post, the subject appeared, but post
> content is missing)
> -
> Hi I am currently using 1.1:
>
> For the first time, I'm using a table without the built in
> autoincrement field. As we know, the way to tell Django -not- to use
> the "id" is to manually specify one of the fields as primary_key=True.
>
> Here is my table:
>
> class Rssitem(models.Model):
>     url_key = models.CharField(max_length=40, primary_key=True)
>     title = models.CharField(max_length=1024)
>     date_to_resend = models.DateTimeField()
>     user = models.ForeignKey(User)
>
> When I run the app and my View function is called - the one that
> inserts a record into the table - the insert never happens.
>
> I get no error while watching the console.   I know that the values to
> be inserted into the table, are being passed into the view, via my
> print statements.
>
> Would this be related to some other configuration I'm not taking care,
> due to me breaking the usual mold of not allowing Django to use the
> 'id' field?
>
> The postgresql schema:
>
> CREATE TABLE rssitem
> (
>   url_key character varying(40) NOT NULL,
>   title character varying(1024) NOT NULL,
>   date_to_resend timestamp with time zone NOT NULL,
>   user_id integer NOT NULL,
>   CONSTRAINT rssitem_pkey PRIMARY KEY (url_key),
>
>   CONSTRAINT rssitem_user_id_fkey FOREIGN KEY (user_id)
>       REFERENCES auth_user (id) MATCH SIMPLE
>       ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY
> DEFERRED
> )
> WITH (OIDS=FALSE);
> ALTER TABLE rssitem OWNER TO postgres;
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Installing 3rd party django applications on a shared environment

2010-05-18 Thread Bill Freeman
Because the incantation is ". activate", not "./activate".  "." is a
shell command
a.k.a. source, which reads the file and executes it in the current shell.  It is
not a command to run as a sub-process.

On Tue, May 18, 2010 at 1:15 PM, ryan west  wrote:
> Hey Tom,
>
> Any idea why ./activate would be failing "Permission Denied"?
>
> Ryan
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: No stylesheet in administration panel

2010-05-18 Thread ryan west
Just a django noob, but are you sure that the path for media is set
correctly in your settings.py file?

For instance, my media settings look like:

MEDIA_ROOT = '/home/ryanisnan/ryanwest.info/public/media'
MEDIA_URL = '/media/'
ADMIN_MEDIA_PREFIX = '/media/'

It could be that your MEDIA_ROOT are specified incorrectly, or
ADMIN_MEDIA_PREFIX is wrong too.You can also path to that folder
manually and check to see if the .css files are all installed
correctly.

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



Re: Installing 3rd party django applications on a shared environment

2010-05-18 Thread ryan west
Hey Tom,

Any idea why ./activate would be failing "Permission Denied"?

Ryan

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



Re: Multi-table inheritance - knowing the child object from the parent

2010-05-18 Thread Lee Hinde
On Tue, May 18, 2010 at 4:27 AM, Jani Tiainen  wrote:

> > Given the following:
> >
> > class Place(models.Model):
> > name = models.CharField(max_length=50)
> > address = models.CharField(max_length=80)
> > zip_code = models.CharField(max_length=15)
> >
> >
> > class Restaurant(Place):
> > serves_hot_dogs = models.BooleanField()
> > serves_pizza = models.BooleanField()
> >
> > class GardenStore(Place):
> > sells_lady_bugs = models.BooleanField()
> >
> >
> > and given a query on zip_code in Places, how would I know whether a
> > Place is a Restaurant or a Garden Store?
>
> You don't OOTB.
>
> I asked same thing quite a while ago - you should be able to find my
> thoughts
> somewhere in this group archives.
>
> Rationale behind this is that you're trying to achieve something pretty
> much
> impossible - inheritance in relational world.
>
> Thing is that you can have you can really have both: Restaurant and
> GardenStore instance to point to same place - so is that correct case or
> not?
>
> Note that "inheritance" is made so that you have relation from Restaurant
> and
> GardenStore tables to Place. There is no simple mechanism to prevent your
> data
> to have references from both "children" to point to "parent".
>
> You can have property/method on your model that tries to determine which
> one
> is correct.
>
> Or you can re-factor your models (which is usually less painful) so that
> your
> place, provided that it is unique (which actually in this case might not
> be).
> Add simple discriminator field to tell what type of child you must also
> fetch
> to make data complete.
>
>
>
 Thanks Jani; I'd seen some of the older threads, with similar work arounds,
but those discussions pre-dated recent advances. I'll look again for the
thread you mention.

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



Re: Installing 3rd party django applications on a shared environment

2010-05-18 Thread Tom Evans
On Tue, May 18, 2010 at 5:02 PM, Bill Freeman  wrote:
> I'll be that you can have a private site-packages directory, or whatever
> you want to call it, which you can add to sys.path.  You can manipulate
> sys.path in your manage.py, but if you don't need to override basic
> django stuff that is imported before settings.py is read, you could do
> the manipulation in settings.py.  You will want to insert it at/near the
> beginning of sys.path, so that if the system and you have versions
> of the same file, you will get yours.
>
> (I'm not sure what you need to do for mod_wsgi if you make the
> changes in manage.py.)
>
> Making easy_install or pip install to a private site-packages directory
> is possible, but I'll have to refer you to the documentation for that.
>

Well, you could mess around with that stuff manually yourself, or you
can use virtualenv, like the rest of the python world.

It's as easy as:

cd folder_above_my_project
virtualenv environ
. ./activate
pip install some_pkg # or easy_install (but pip is _much_ better)
python project/manage.py 

No messing with sys.path, no messing with launch scripts. To use it
with mod_wsgi, at its simplest you can set:
WSGIPythonHome /path/to/folder_above_my_project/environ

Theres much more you can do with mod_wsgi/virtualenv - more details:
http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

Cheers

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



Re: Custom Form in a ModelFormset_Factory?

2010-05-18 Thread Michael Davis
Thanks! I found that by looking at the source shortly after I posted
the question. I'm surprised I didn't stumble across that option in the
documentation. Do you have a link to any documentation that indicates
this (and other features) is an option?

On May 18, 1:10 am, Ian Lewis  wrote:
> Pass the form class to modelformset_factory() in the form argument.
> The factory will then use the AuthorForm class as the base form class
> when it creates the modelform class for the formset.
>
> modelFormset = modelformset_factory(Author, form=AuthorForm)
>
> On Tue, May 18, 2010 at 7:08 AM, Michael Davis
>
>
>
>  wrote:
>
> > I am new to Django and am trying to get a custom modelForm to work in
> > a ModelFormset_factory. For example:
>
> > # in models.py
> > class Author(models.Model):
> >name = models.CharField()
> >address = models.CharField()
> >phone = models.CharField()
>
> > class AuthorForm(ModelForm):
> >class Meta:
> >model = Author
>
> > # in views.py
> > def authorForm(request):
> >modelFormset = modelformset_factory(Author)
> >items = Author.objects.all()
> >formsetInstance = modelFormset(queryset=items)
> >return render_to_response('blah',locals())
>
> > The above code works fine, but I'd like to be able to tweak the
> > default presentation of the AuthorForm and use that in the
> > formset_factory. Is there any way to do that through the AuthorForm
> > class above? If not is there another nearly easy way?
>
> > 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> ===
> 株式会社ビープラウド  イアン・ルイス
> 〒150-0021
> 東京都渋谷区恵比寿西2-3-2 NSビル6階
> email: ianmle...@beproud.jp
> TEL:03-6416-9836
> FAX:03-6416-9837http://www.beproud.jp/
> ===
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Installing 3rd party django applications on a shared environment

2010-05-18 Thread ryan west
Thanks Tom,

I'll have a look at that.

Ryan

>
> Google for virtualenv.
>
> Cheers
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Installing 3rd party django applications on a shared environment

2010-05-18 Thread Bill Freeman
I'll be that you can have a private site-packages directory, or whatever
you want to call it, which you can add to sys.path.  You can manipulate
sys.path in your manage.py, but if you don't need to override basic
django stuff that is imported before settings.py is read, you could do
the manipulation in settings.py.  You will want to insert it at/near the
beginning of sys.path, so that if the system and you have versions
of the same file, you will get yours.

(I'm not sure what you need to do for mod_wsgi if you make the
changes in manage.py.)

Making easy_install or pip install to a private site-packages directory
is possible, but I'll have to refer you to the documentation for that.

On Tue, May 18, 2010 at 11:41 AM, ryan west  wrote:
> Disclaimer: This may be more of a python/shared hosting issue, but
> alas I'm posting here.
>
> Hey all,
>
> I'm currently just trying to install some 3rd party django apps so I
> can use them in my project.  I already have django up and running, I'm
> hosting on Dreamhost using passenger.  I don't have my own python
> installation, so I'm using dreamhost's shared.
>
> I have built a custom app, and project, and they work perfect, however
> I can't seem to install 3rd party apps (using the python setup.py
> install method).
>
> I have to use this method because I don't have acces to easy_install
> for example, because the shared /usr/ directory is off limits to me.
>
> python setup.py install fails because it doesn't see my custom install
> directory on the PYTHONPATH (obviously).  I've tried modifying the
> setup.py script to append the directory to the path before running,
> but still no success.
>
> Is there any way to do this?  It seems like overkill that I would have
> to have my own installation of python running just to get 3rd party
> apps to work, considering I can get mine going great.
>
> Thanks in advance!
>
> Ryan
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



No stylesheet in administration panel

2010-05-18 Thread Carlo Trimarchi
Hi,
I'm following the django tutorial to build the poll application. I'm
working mostly on a remote server (using wsgi), but I'm also trying
stuff on my local machine, just running the manage.py runserver
command.
I've just enabled the admin site and it works. But when I access the
page on the server it just doesn't use any style. I mean, I don't see
coloured boxes, no cool fonts or the correct layout. If I run the
local version it is displayed correctly. I'm sure that the code is the
same for both versions, since the local one is just the remote
directory mounted through ssh.

So, what can be the problem?

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



Re: Installing 3rd party django applications on a shared environment

2010-05-18 Thread Tom Evans
On Tue, May 18, 2010 at 4:41 PM, ryan west  wrote:
> Disclaimer: This may be more of a python/shared hosting issue, but
> alas I'm posting here.
>
> Hey all,
>
> I'm currently just trying to install some 3rd party django apps so I
> can use them in my project.  I already have django up and running, I'm
> hosting on Dreamhost using passenger.  I don't have my own python
> installation, so I'm using dreamhost's shared.
>
> I have built a custom app, and project, and they work perfect, however
> I can't seem to install 3rd party apps (using the python setup.py
> install method).
>
> I have to use this method because I don't have acces to easy_install
> for example, because the shared /usr/ directory is off limits to me.
>
> python setup.py install fails because it doesn't see my custom install
> directory on the PYTHONPATH (obviously).  I've tried modifying the
> setup.py script to append the directory to the path before running,
> but still no success.
>
> Is there any way to do this?  It seems like overkill that I would have
> to have my own installation of python running just to get 3rd party
> apps to work, considering I can get mine going great.
>
> Thanks in advance!
>
> Ryan
>

Google for virtualenv.

Cheers

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



Installing 3rd party django applications on a shared environment

2010-05-18 Thread ryan west
Disclaimer: This may be more of a python/shared hosting issue, but
alas I'm posting here.

Hey all,

I'm currently just trying to install some 3rd party django apps so I
can use them in my project.  I already have django up and running, I'm
hosting on Dreamhost using passenger.  I don't have my own python
installation, so I'm using dreamhost's shared.

I have built a custom app, and project, and they work perfect, however
I can't seem to install 3rd party apps (using the python setup.py
install method).

I have to use this method because I don't have acces to easy_install
for example, because the shared /usr/ directory is off limits to me.

python setup.py install fails because it doesn't see my custom install
directory on the PYTHONPATH (obviously).  I've tried modifying the
setup.py script to append the directory to the path before running,
but still no success.

Is there any way to do this?  It seems like overkill that I would have
to have my own installation of python running just to get 3rd party
apps to work, considering I can get mine going great.

Thanks in advance!

Ryan

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



Record won't Insert, possibly due to not using built in 'ID'?

2010-05-18 Thread beetlecube
( Not sure what happened to the post, the subject appeared, but post
content is missing)
-
Hi I am currently using 1.1:

For the first time, I'm using a table without the built in
autoincrement field. As we know, the way to tell Django -not- to use
the "id" is to manually specify one of the fields as primary_key=True.

Here is my table:

class Rssitem(models.Model):
url_key = models.CharField(max_length=40, primary_key=True)
title = models.CharField(max_length=1024)
date_to_resend = models.DateTimeField()
user = models.ForeignKey(User)


When I run the app and my View function is called - the one that
inserts a record into the table - the insert never happens.

I get no error while watching the console.   I know that the values to
be inserted into the table, are being passed into the view, via my
print statements.

Would this be related to some other configuration I'm not taking care,
due to me breaking the usual mold of not allowing Django to use the
'id' field?


The postgresql schema:

CREATE TABLE rssitem
(
  url_key character varying(40) NOT NULL,
  title character varying(1024) NOT NULL,
  date_to_resend timestamp with time zone NOT NULL,
  user_id integer NOT NULL,
  CONSTRAINT rssitem_pkey PRIMARY KEY (url_key),

  CONSTRAINT rssitem_user_id_fkey FOREIGN KEY (user_id)
  REFERENCES auth_user (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY
DEFERRED
)
WITH (OIDS=FALSE);
ALTER TABLE rssitem OWNER TO postgres;

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



Record won't Insert, possibly due to not using built in 'ID'?

2010-05-18 Thread beetlecube
Hi I am currently using 1.1:

For the first time, I'm using a table without the built in
autoincrement field. As we know, the way to tell Django -not- to use
the "id" is to manually specify one of the fields as
primary_key=True.

Here is my table:

class Rssitem(models.Model):
url_key = models.CharField(max_length=40, primary_key=True)
title = models.CharField(max_length=1024)
date_to_resend = models.DateTimeField()
user = models.ForeignKey(User)


When I run the app and my View function is called - the one that
inserts a record into the table - the insert never happens.

I get no error while watching the console.   I know that the values to
be inserted into the table, are being passed into the view, via my
print statements.

Would this be related to some other configuration I'm not taking care,
due to me breaking the usual mold of not allowing Django to use the
'id' field?


The postgresql schema:

CREATE TABLE rssitem
(
  url_key character varying(40) NOT NULL,
  title character varying(1024) NOT NULL,
  date_to_resend timestamp with time zone NOT NULL,
  user_id integer NOT NULL,
  CONSTRAINT rssitem_pkey PRIMARY KEY (url_key),

  CONSTRAINT rssitem_user_id_fkey FOREIGN KEY (user_id)
  REFERENCES auth_user (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY
DEFERRED
)
WITH (OIDS=FALSE);
ALTER TABLE rssitem OWNER TO postgres;

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



Re: Extend User

2010-05-18 Thread Alexandre González
Perfect, thanks for your help!

On Tue, May 18, 2010 at 14:03, zinckiwi  wrote:

> On May 18, 7:57 am, Alexandre González  wrote:
> > But don't you think that have attributes that I don't need is a
> perfomance
> > lost? I only ask, I'm learning django :)
> >
> > I go to see the documentation that you send me, thanks for your help.
>
> There will be a minuscule amount of overhead from the query for User
> objects referring to fields you don't use, but I mean *really*
> minuscule. Unmeasurable unless you are Twitter. Don't worry about it.
>
> Regards
> Scott
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Challenge with Annotate

2010-05-18 Thread Ian Lewis
Roland,

Shooting a bit in the dark but how about:

...
select = {
'days_in_stock': "'%s' - transactie_datum_inkomend + 1" %
(given_date.isoformat()),
'avg_days_instock': 'AVG(days_in_stock)',
})
...
qs.annotate(Count('manufacturer'))
...

Would that get you the group by and average field you were looking for?

If not it might be easier to just write what you want as custom SQL.

Ian

On Tue, May 18, 2010 at 10:51 PM, Roland van Laar  wrote:
> On 05/18/2010 03:43 PM, Ian Lewis wrote:
>> Roland,
>>
>> Instead of using annotate, could you just add the avg_days_instock
>> field as another key in the select argument to extra?
>>
>
> Well how would I do that?
> Since I want the avg_days_instock calculated on a 'group_by' basis.
> To me it seems that I need to do a Count and a avg_days_instock at the
> same time?
>
> Roland
>
>> Ian
>>
>> On Tue, May 18, 2010 at 9:03 PM, Roland van Laar  wrote:
>>
>>> Hello,
>>>
>>> Question: How do I calculate the Average of a calculated field.
>>>
>>> My (simplified) models.py:
>>>
>>> Manufacturer(models.Model):
>>>name = models.CharField(length=100)
>>>
>>> Product(models.Model):
>>>name = models.CharField(length=100)
>>>
>>> Items(models.Model):
>>>manufacturer = models.Foreignkey(Manufacturer)
>>>product = models.ForeignKey(Product)
>>>bought_date = models.DateField()
>>>sold_date = models.DateField(null=True, blank=True)
>>>
>>> On these models I want to calculate the number of days an item was in stock
>>> on a given date:
>>>
>>> qs = Items.objects.all().extra(select= \
>>>{'days_in_stock': "'%s' - transactie_datum_inkomend + 1" %
>>> (given_date.isoformat())})
>>>
>>> And then I want to know the average number of days all the items selected on
>>> manufacturer and product.
>>>
>>> qs.values('manufacturer', 'product)
>>> qs.annotate(Count('manufacturer'), avg_days_instock=Avg('days_in_stock'))
>>>
>>> The annotate fails because 'days_in_stock' is not a valid field:
>>> FieldError: Cannot resolve keyword 'days_in_stock' into field. Choices are:
>>> manufacturer, product, bought_date, sold_date
>>>
>>> How can I calculate the average of the days_in_stock?
>>>
>>> Thanks,
>>>
>>> Roland van Laar
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>>
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
===
株式会社ビープラウド  イアン・ルイス
〒150-0021
東京都渋谷区恵比寿西2-3-2 NSビル6階
email: ianmle...@beproud.jp
TEL:03-6416-9836
FAX:03-6416-9837
http://www.beproud.jp/
===

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



Custom Validation on Models

2010-05-18 Thread hovo
Hi,

I am new to django, and got some problems on models validation. I have
the following two models:

class A(models.Model):
   ...

class B(models.Model):
key_field = models.ForeignKey(A)
...
bool_field = models.BooleanField(default=False)

I want to add a validation rule in model B on this way:
for a special key_field there cannot be more than one entry with
bool_field=True

How can I have this?

Thanks,
Hovo

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



Inlines user permissions problem + view only permissions

2010-05-18 Thread Vali Lungu
Hello,

I'm not sure if this is a bug or I'm just missing something (although I have
already parsed the documentation about inlines), but:

Let's say I have a model A. Model A is an inline of model B. User U has full
access to model B, but only change permissions to model A (so, no add, nor
delete).

However, when editing model B, user U can still see the "Add another A" link
at the bottom, although U hasn't add permissions for that respective model.

What's wrong? Why does that link keep on showing? My logic says that if U
does not have permissions to add A, the link shouldn't appear anymore.

Also, ideally, I would like to give U only view rights to model A (so no
add, delete or change - only view), but I've read about that (strange, if
you ask me) philosophy according to which "If you don't trust U, just deny
him access to the admin area all together". Kind of a stupid doctrine.

Right now, I'm trying to simulate this 'view only permissions' by leaving U
with just change rights and set all fields as read only. But I think this is
kind of a stupid approach and may also cause problems like the permissions
thing above...

How does an average Django programmer like me achieve view-only permissions,
and most of all how should I get rid of the "Add another A" link at the
bottom of the admin edit form?

Thanks in advance!

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



Re: Challenge with Annotate

2010-05-18 Thread Roland van Laar
On 05/18/2010 03:43 PM, Ian Lewis wrote:
> Roland,
>
> Instead of using annotate, could you just add the avg_days_instock
> field as another key in the select argument to extra?
>   

Well how would I do that?
Since I want the avg_days_instock calculated on a 'group_by' basis.
To me it seems that I need to do a Count and a avg_days_instock at the
same time?

Roland

> Ian
>
> On Tue, May 18, 2010 at 9:03 PM, Roland van Laar  wrote:
>   
>> Hello,
>>
>> Question: How do I calculate the Average of a calculated field.
>>
>> My (simplified) models.py:
>>
>> Manufacturer(models.Model):
>>name = models.CharField(length=100)
>>
>> Product(models.Model):
>>name = models.CharField(length=100)
>>
>> Items(models.Model):
>>manufacturer = models.Foreignkey(Manufacturer)
>>product = models.ForeignKey(Product)
>>bought_date = models.DateField()
>>sold_date = models.DateField(null=True, blank=True)
>>
>> On these models I want to calculate the number of days an item was in stock
>> on a given date:
>>
>> qs = Items.objects.all().extra(select= \
>>{'days_in_stock': "'%s' - transactie_datum_inkomend + 1" %
>> (given_date.isoformat())})
>>
>> And then I want to know the average number of days all the items selected on
>> manufacturer and product.
>>
>> qs.values('manufacturer', 'product)
>> qs.annotate(Count('manufacturer'), avg_days_instock=Avg('days_in_stock'))
>>
>> The annotate fails because 'days_in_stock' is not a valid field:
>> FieldError: Cannot resolve keyword 'days_in_stock' into field. Choices are:
>> manufacturer, product, bought_date, sold_date
>>
>> How can I calculate the average of the days_in_stock?
>>
>> Thanks,
>>
>> Roland van Laar
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>> 
>
>
>   

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



Re: Challenge with Annotate

2010-05-18 Thread Ian Lewis
Roland,

Instead of using annotate, could you just add the avg_days_instock
field as another key in the select argument to extra?

Ian

On Tue, May 18, 2010 at 9:03 PM, Roland van Laar  wrote:
> Hello,
>
> Question: How do I calculate the Average of a calculated field.
>
> My (simplified) models.py:
>
> Manufacturer(models.Model):
>name = models.CharField(length=100)
>
> Product(models.Model):
>name = models.CharField(length=100)
>
> Items(models.Model):
>manufacturer = models.Foreignkey(Manufacturer)
>product = models.ForeignKey(Product)
>bought_date = models.DateField()
>sold_date = models.DateField(null=True, blank=True)
>
> On these models I want to calculate the number of days an item was in stock
> on a given date:
>
> qs = Items.objects.all().extra(select= \
>{'days_in_stock': "'%s' - transactie_datum_inkomend + 1" %
> (given_date.isoformat())})
>
> And then I want to know the average number of days all the items selected on
> manufacturer and product.
>
> qs.values('manufacturer', 'product)
> qs.annotate(Count('manufacturer'), avg_days_instock=Avg('days_in_stock'))
>
> The annotate fails because 'days_in_stock' is not a valid field:
> FieldError: Cannot resolve keyword 'days_in_stock' into field. Choices are:
> manufacturer, product, bought_date, sold_date
>
> How can I calculate the average of the days_in_stock?
>
> Thanks,
>
> Roland van Laar
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
===
株式会社ビープラウド  イアン・ルイス
〒150-0021
東京都渋谷区恵比寿西2-3-2 NSビル6階
email: ianmle...@beproud.jp
TEL:03-6416-9836
FAX:03-6416-9837
http://www.beproud.jp/
===

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



Re: Displaying dictionaries

2010-05-18 Thread derek
On May 18, 11:35 am, Tom Evans  wrote:
> On Tue, May 18, 2010 at 12:46 AM, Barry  wrote:
> > Hi--
>
> >  I want to dynamically display the contents of results (an array of
> > dictionaries with the same keys) as a table where the column headers
> > are a select group of keys in the variable result_col_titles and the
> > order of the columns is the same as the order of the keys in
> > result_col_titles. I imagine the template code would be something like
> > what is below but I don't know how to reference a dictionary item
> > value when the key value is in a variable and not hard-coded in the
> > template.
>
> >  This seems pretty basic but I didn't see it in the Definitive Guide
> > to Django.
>
> > Thanks
>
> > Barry
> > ===
> >      
> >        
> >          {% for title in result_col_titles %}
> >            
> >               {{ title }}
> >            
> >          {% endfor %}
> >        
> >        {% for dictionary in result %}
> >          
> >            {% for title in result_col_titles %}
> >              
> >                 {{ dictionary.title }}
> >                 {{ dictionary.{{title}} }}
> >              
> >            {% endfor %}
> >          
> >        {% endfor %}
> >      
>
> It's considered 'poor form' by django devs - too much work in the
> template. If you want the data in that order, arrange it so in the
> view.
>
> If you don't agree, add this 5 line template tag:
>
>   from django import template
>   register = template.Library()
>
>   @register.filter
>   def dict_get(hash, key):
>     return hash[key]
>
> It should go in /templatetags/dict_get.py
>
> You can then do:
>
> {% load dict_get %}
>
> {% for dict in list_of_dicts %}
> 
> {% for title in titles %}
>   {{ dict|dict_get:title }}
> {% endfor %}
> 
> {% endfor %}
>
> Cheers
>
> Tom

Having _just_ struggled for a week with this and finally discovering a
link here:
http://www.bhphp.com/blog4.php/2009/08/17/django-templates-and-dictionaries
that saved my sanity, I curious as to why this is considered "too much
work".  All the data in Django seems to be passed around via
dictionaries (or, rather, if you do any kind of interim processing on
it in the view logic, it ends up in lists of dictionaries) , so it
would seem logical to allow sorting by dictionary keys.

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



Re: pass related_name-s into Model.objects.create()?

2010-05-18 Thread Phlip
> > But what about 'ForeignKey's? May we pass their 'remote_name's in with
> > the kwargs?
>
> Foreign Keys - yes. Reverse Foreign Keys - no.

Point: All kwargs takes is the fields on this object.

> In the case of a foreign key, just pass in the object instance that
> you want your object to be related to (e.g., when creating a Question
> object, you can pass in the Poll that the question belongs to).
>
> > If not, what's some clean way to construct everything all at once?
>
> Depends on what you mean by "at once".

I want to take out the objects.create, and create everything in
memory. So the many-to-ones - the foreign keys - go in the kwargs.

  o = Model(field=x, foreigner=Foreigner())
  o.manys = [ Item(), Item(), Item() ]

Now everything hangs in memory like it would in the database if we
created all of it.

Then I want o.save() to blast it all into the database.

> If you're trying to assign a list of related objects, that isn't a
> single operation either - what you're actually doing is setting a
> foreign key value on multiple related objects.

No prob - I will just create the Item() things with a foreign key to
their parent, and leave the syntactic sugar.

Then I will call save() on everything from top to bottom, so all the
pks populate correctly.

> However, all of these are just wrappers around multiple underlying
> database calls. The changes won't happen "at once" unless you start
> getting involved with transactions etc.

I prematurely optimize so infrequently I forgot some people use it to
mean "in one database call". I just meant in one big humongous
statement. No prob.

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



Reflect changes made through Manager to model instances

2010-05-18 Thread Alexei Selivanov
Is it possible to reflect changes made through model's Manager to
model instances? For example I have ProfileManager class like so:

class ProfileManager(models.Manager):

def activate_profile(self, id, activation_key):
# do activation


And I want changes made by this method be visible in Profile instances.

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



Challenge with Annotate

2010-05-18 Thread Roland van Laar

Hello,

Question: How do I calculate the Average of a calculated field.

My (simplified) models.py:

Manufacturer(models.Model):
name = models.CharField(length=100)

Product(models.Model):
name = models.CharField(length=100)

Items(models.Model):
manufacturer = models.Foreignkey(Manufacturer)
product = models.ForeignKey(Product)
bought_date = models.DateField()
sold_date = models.DateField(null=True, blank=True)

On these models I want to calculate the number of days an item was in stock
on a given date:

qs = Items.objects.all().extra(select= \
{'days_in_stock': "'%s' - transactie_datum_inkomend + 1" % 
(given_date.isoformat())})


And then I want to know the average number of days all the items 
selected on manufacturer and product.


qs.values('manufacturer', 'product)
qs.annotate(Count('manufacturer'), avg_days_instock=Avg('days_in_stock'))

The annotate fails because 'days_in_stock' is not a valid field:
FieldError: Cannot resolve keyword 'days_in_stock' into field. Choices 
are: manufacturer, product, bought_date, sold_date


How can I calculate the average of the days_in_stock?

Thanks,

Roland van Laar



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



Re: Extend User

2010-05-18 Thread zinckiwi
On May 18, 7:57 am, Alexandre González  wrote:
> But don't you think that have attributes that I don't need is a perfomance
> lost? I only ask, I'm learning django :)
>
> I go to see the documentation that you send me, thanks for your help.

There will be a minuscule amount of overhead from the query for User
objects referring to fields you don't use, but I mean *really*
minuscule. Unmeasurable unless you are Twitter. Don't worry about it.

Regards
Scott

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



Re: Extend User

2010-05-18 Thread Alexandre González
But don't you think that have attributes that I don't need is a perfomance
lost? I only ask, I'm learning django :)

I go to see the documentation that you send me, thanks for your help.

On Tue, May 18, 2010 at 13:38, Ian Lewis  wrote:

> If you don't need the name, surname etc. then don't use them. They are
> optional fields. You can also implement a custom form or view when the
> user registers that can make sure the email has not been previously
> registered.
>
> If you need to add additional fields then you should create a custom
> profile model and set the model in AUTH_PROFILE_MODULE. That will
> allow you to get the information from the user via the get_profile()
> method.
>
> See: http://docs.djangoproject.com/en/dev/topics/auth/#auth-profiles
>
> 2010/5/18 Alexandre González :
> > Hi everybody!
> > I need a User model with normal attributes inherit from models.User, but
> I
> > need some differences:
> >
> > I dont' need name, surname and another attributes
> > I need that email are unique between different Users
> >
> > Can I inherit and use most of models.User? Or I need to create a new
> class
> > and don't benefit from Auth module?
> > Thanks!
> > Álex González
> > --
> > Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx,
> .ppt
> > and/or .pptx
> > http://mirblu.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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
>
>
>
> --
> ===
> 株式会社ビープラウド  イアン・ルイス
> 〒150-0021
> 東京都渋谷区恵比寿西2-3-2 NSビル6階
> email: ianmle...@beproud.jp
> TEL:03-6416-9836
> FAX:03-6416-9837
> http://www.beproud.jp/
> ===
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ANN: Django 1.1.2 and Django 1.2 released

2010-05-18 Thread zinckiwi


On May 18, 12:39 am, rahul jain  wrote:
> Awesome job...but I discovered just one problem. Select all missing from
> admin panel. So now i cannot select all the objects if i want to from admin
> panel. It was fine on django 1.1. Its not fine on django 1.2 nor in the
> development versions.

Works fine for me RJ -- you're talking about the list of objects for a
given model, yes?

Regards
Scott

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



Re: pass related_name-s into Model.objects.create()?

2010-05-18 Thread Russell Keith-Magee
On Tue, May 18, 2010 at 12:45 PM, Phlip  wrote:
> Djangoists:
>
> The documentation for Model.objects.create(**kwargs) does not define
> kwargs. It just sez "kwargs".
>
> I think all of our experiences would bear out "kwargs" may at least be
> the model's fields.

Correct.

> But what about 'ForeignKey's? May we pass their 'remote_name's in with
> the kwargs?

Foreign Keys - yes. Reverse Foreign Keys - no.

In the case of a foreign key, just pass in the object instance that
you want your object to be related to (e.g., when creating a Question
object, you can pass in the Poll that the question belongs to).

> If not, what's some clean way to construct everything all at once?

Depends on what you mean by "at once". As soon as you're dealing with
foreign keys, you're dealing with more than one database operation -
at the very least, you'll need to create or find the related objects.

If you're trying to assign a list of related objects, that isn't a
single operation either - what you're actually doing is setting a
foreign key value on multiple related objects. Django doesn't provide
a single wrapper call to create *and* assign reverse foreign key
relations, but if you really want one, it won't be too hard to write.

However, all of these are just wrappers around multiple underlying
database calls. The changes won't happen "at once" unless you start
getting involved with transactions etc.

Yours,
Russ Magee %-)

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



Re: Extend User

2010-05-18 Thread Ian Lewis
If you don't need the name, surname etc. then don't use them. They are
optional fields. You can also implement a custom form or view when the
user registers that can make sure the email has not been previously
registered.

If you need to add additional fields then you should create a custom
profile model and set the model in AUTH_PROFILE_MODULE. That will
allow you to get the information from the user via the get_profile()
method.

See: http://docs.djangoproject.com/en/dev/topics/auth/#auth-profiles

2010/5/18 Alexandre González :
> Hi everybody!
> I need a User model with normal attributes inherit from models.User, but I
> need some differences:
>
> I dont' need name, surname and another attributes
> I need that email are unique between different Users
>
> Can I inherit and use most of models.User? Or I need to create a new class
> and don't benefit from Auth module?
> Thanks!
> Álex González
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
===
株式会社ビープラウド  イアン・ルイス
〒150-0021
東京都渋谷区恵比寿西2-3-2 NSビル6階
email: ianmle...@beproud.jp
TEL:03-6416-9836
FAX:03-6416-9837
http://www.beproud.jp/
===

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



Re: Module loading error in django trunk.

2010-05-18 Thread Russell Keith-Magee
On Tue, May 18, 2010 at 6:12 PM, ben  wrote:
> Hi All,
>
> After a recent svn update to my copy of Django/trunk I’ve been getting
> a persistent error relating to module loading (see below). I am able
> to create the same error from many but not all views/requests.
>
> Interesting, when I run my code against a slightly older version of
> Django trunk (at Rev. 13079) I don’t get these errors.

> Is this a bug, or have I missed some backwards incompatible change?

It's certainly possible you've found a bug. The module that is raising
errors was subject to a number of changes in the last days of 1.2
preparation, and while we've added lots of tests to make sure module
loading works as expected, it's possible we've missed some edge cases.

There is one thing that is a little suspicious. Your stack track
contains the following at the end:

File "/django/utils/module_loading.py", line 12, in
module_has_submodule
   # zipimport.zipimporter.find_module is documented to take

This indicates that there is some confusion over exactly what code is
running. Line 12 of module_loading.py in 1.2-final is a call to
find_module, not a comment about zipimport. The first step in
debugging this will be to purge all your .pyc files in case some
timestamp problems are causing some stale code to execute.

If you still see the problem, the next thing we need to know is
exactly what is being imported, from where -- and most importantly --
by what. Assuming the line numbers in the stack trace are correct, the
block of code that you are tripping over is a walk through
sys.meta_path, which suggests that you are using a custom module
loader of some kind. We're going to need lots of details on exactly
what your stack is doing - how you are storing modules, how they are
being loaded, any special cases you may have, etc.

The stack trace you've given us looks like it's been cut from a
standard Django 500 page; if this is the case, it would be helpful to
have all the local stack information from the last stack frame -- all
the local variables, as well as anything you can furnish about
sys.path and sys.meta_path. Ideally, this will lead to a simple test
case where you can give us the exact conditions under which the
problem arises.

Yours,
Russ Magee %-)

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



Re: Multi-table inheritance - knowing the child object from the parent

2010-05-18 Thread Jani Tiainen
> Given the following:
> 
> class Place(models.Model):
> name = models.CharField(max_length=50)
> address = models.CharField(max_length=80)
> zip_code = models.CharField(max_length=15)
> 
> 
> class Restaurant(Place):
> serves_hot_dogs = models.BooleanField()
> serves_pizza = models.BooleanField()
> 
> class GardenStore(Place):
> sells_lady_bugs = models.BooleanField()
> 
> 
> and given a query on zip_code in Places, how would I know whether a
> Place is a Restaurant or a Garden Store?

You don't OOTB.

I asked same thing quite a while ago - you should be able to find my thoughts 
somewhere in this group archives.

Rationale behind this is that you're trying to achieve something pretty much 
impossible - inheritance in relational world. 

Thing is that you can have you can really have both: Restaurant and 
GardenStore instance to point to same place - so is that correct case or not?

Note that "inheritance" is made so that you have relation from Restaurant and 
GardenStore tables to Place. There is no simple mechanism to prevent your data 
to have references from both "children" to point to "parent".

You can have property/method on your model that tries to determine which one 
is correct.

Or you can re-factor your models (which is usually less painful) so that your 
place, provided that it is unique (which actually in this case might not be). 
Add simple discriminator field to tell what type of child you must also fetch 
to make data complete.

-- 

Jani Tiainen

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



Extend User

2010-05-18 Thread Alexandre González
Hi everybody!

I need a User model with normal attributes inherit from models.User, but I
need some differences:

   - I dont' need name, surname and another attributes
   - I need that email are unique between different Users

Can I inherit and use most of models.User? Or I need to create a new class
and don't benefit from Auth module?

Thanks!
Álex González

-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Error was: cannot import name validators

2010-05-18 Thread Ian Lewis
validators is a module that was added in Django 1.2.

You probably have the wrong version of Django installed or are using
Django 1.1 with a django application that requires Django 1.2.

On Tue, May 18, 2010 at 6:01 PM, Pankaj Singh
 wrote:
> pan...@pankaj-laptop:~/django_projects/pankaj$ python
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 from django.core import validators
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: cannot import name validators

>
> Validators is really missing .. don't know how to install .. help needed
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
===
株式会社ビープラウド  イアン・ルイス
〒150-0021
東京都渋谷区恵比寿西2-3-2 NSビル6階
email: ianmle...@beproud.jp
TEL:03-6416-9836
FAX:03-6416-9837
http://www.beproud.jp/
===

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



Module loading error in django trunk.

2010-05-18 Thread ben
Hi All,

After a recent svn update to my copy of Django/trunk I’ve been getting
a persistent error relating to module loading (see below). I am able
to create the same error from many but not all views/requests.

Interesting, when I run my code against a slightly older version of
Django trunk (at Rev. 13079) I don’t get these errors.

Is this a bug, or have I missed some backwards incompatible change?
I’ve searched around and came up with nothing? Any insights or
suggestions much appreciated.

kindly,
Ben.


Example Error:

TypeError at /admin/auth/user/1787/

find_module() takes exactly 3 arguments (2 given)

Request Method: GET
Request URL:http://0.0.0.0/admin/auth/user/1787/
Django Version: 1.2.1 pre-alpha SVN-13291
Exception Type: TypeError
Exception Value:

find_module() takes exactly 3 arguments (2 given)

Exception Location: / django/utils/module_loading.py in
module_has_submodule, line 12

Python Executable: /

Python Version: 2.6.4

Python Path:['/new-mos', '/new-mos/django', '/new-mos/contrib', '/
usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg', '/
usr/local/lib/python2.6/site-packages/Genshi-0.5.1-py2.6-freebsd-6.3-
RELEASE-p1-i386.egg', '/usr/local/lib/python2.6/site-packages/
pytz-2009l-py2.6.egg', '/usr/local/lib/python2.6/site-packages/
Jinja2-2.1.1-py2.6-freebsd-6.3-RELEASE-p1-i386.egg', '/usr/local/lib/
python2.6/site-packages/Pygments-1.0-py2.6.egg', '/usr/local/lib/
python2.6/site-packages/flup-1.0.2-py2.6.egg', '/usr/local/lib/
python2.6/site-packages/Sphinx-0.6.3-py2.6.egg', '/usr/local/lib/
python2.6/site-packages/PyAMF-0.5-py2.6-freebsd-6.3-RELEASE-p1-
i386.egg', '/usr/local/lib/python2.6/site-packages/Markdown-2.0.1-
py2.6.egg', '/usr/local/lib/python2.6/site-packages/
python_memcached-1.44-py2.6.egg', '/usr/local/lib/python2.6/site-
packages/Trac-0.11.5-py2.6.egg', '/usr/local/lib/python2.6/site-
packages/paramiko-1.7.6-py2.6.egg', '/usr/local/lib/python2.6/site-
packages/pycrypto-2.0.1-py2.6-freebsd-6.3-RELEASE-p1-i386.egg', '/usr/
local/lib/python26.zip', '/usr/local/lib/python2.6', '/usr/local/lib/
python2.6/plat-freebsd6', '/usr/local/lib/python2.6/lib-tk', '/usr/
local/lib/python2.6/lib-old', '/usr/local/lib/python2.6/lib-dynload',
'/usr/local/lib/python2.6/site-packages', '/usr/local/lib/python2.6/
site-packages/PIL', '/usr/local/lib/python2.6/site-packages/
pythonutils', '/new-mos/contrib/satchmo/apps']


An Example Traceback:

Traceback (most recent call last):

  File "/django/core/handlers/base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/new_mos/views.py", line 24, in index
return render_to_response('index.html',
context_instance=Context(request, data))

  File "/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs),
**httpresponse_kwargs)

  File "/django/template/loader.py", line 181, in render_to_string
t = get_template(template_name)

  File "/django/template/loader.py", line 160, in get_template
template = get_template_from_string(template, origin,
template_name)

  File "/django/template/loader.py", line 168, in
get_template_from_string
return Template(source, origin, name)

  File "/django/template/__init__.py", line 158, in __init__
self.nodelist = compile_string(template_string, origin)

  File "/django/template/__init__.py", line 186, in compile_string
return parser.parse()

  File "/django/template/__init__.py", line 282, in parse
compiled_result = compile_func(self, token)

  File "/django/template/loader_tags.py", line 197, in do_extends
nodelist = parser.parse()

  File "/django/template/__init__.py", line 282, in parse
compiled_result = compile_func(self, token)

  File "/django/template/defaulttags.py", line 917, in load
try:

  File "/django/template/__init__.py", line 1040, in get_library
lib = import_library(taglib_module)

  File "/django/template/__init__.py", line 992, in import_library
if not module_has_submodule(app_module, taglib):

  File "/django/utils/module_loading.py", line 12, in
module_has_submodule
# zipimport.zipimporter.find_module is documented to take

TypeError: find_module() takes exactly 3 arguments (2 given)

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



Re: Displaying dictionaries

2010-05-18 Thread Tom Evans
On Tue, May 18, 2010 at 12:46 AM, Barry  wrote:
> Hi--
>
>  I want to dynamically display the contents of results (an array of
> dictionaries with the same keys) as a table where the column headers
> are a select group of keys in the variable result_col_titles and the
> order of the columns is the same as the order of the keys in
> result_col_titles. I imagine the template code would be something like
> what is below but I don't know how to reference a dictionary item
> value when the key value is in a variable and not hard-coded in the
> template.
>
>  This seems pretty basic but I didn't see it in the Definitive Guide
> to Django.
>
> Thanks
>
> Barry
> ===
>      
>        
>          {% for title in result_col_titles %}
>            
>               {{ title }}
>            
>          {% endfor %}
>        
>        {% for dictionary in result %}
>          
>            {% for title in result_col_titles %}
>              
>                 {{ dictionary.title }}
>                 {{ dictionary.{{title}} }}
>              
>            {% endfor %}
>          
>        {% endfor %}
>      
>

It's considered 'poor form' by django devs - too much work in the
template. If you want the data in that order, arrange it so in the
view.

If you don't agree, add this 5 line template tag:

  from django import template
  register = template.Library()

  @register.filter
  def dict_get(hash, key):
return hash[key]

It should go in /templatetags/dict_get.py

You can then do:

{% load dict_get %}

{% for dict in list_of_dicts %}

{% for title in titles %}
  {{ dict|dict_get:title }}
{% endfor %}

{% endfor %}


Cheers

Tom
Hope that helps.

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



Re: Custom Model Fields

2010-05-18 Thread Nuno Maltez
Hi,

I think what you're trying to accomplish is more or less what
django-tagging [http://code.google.com/p/django-tagging/] does, so I
suggest looking at its source code.

HTH,
Nuno

On Sun, May 9, 2010 at 11:24 PM, Nick Taylor
 wrote:
> Hi all,
>
> I want to create my own "field" type for a model, this essentially
> will be a relationship to another model via a generic link model
> (using GenericForeignKey etc).
>
> As en example I basically want to do the following in models.py:
>
> class Pizza(models.Model):
>   toppings = IngredientsField()
>
> Which can then be reused in another app sandwiches/models.py as:
>
> class Sandwich(models.Model)
>   filling = IngredientsField()
>
> Where I use a IngredientsField() field type which then controls the
> links as a separate set of models Ingredients and IngredientItems.
>
> Now I have created in fields.py:
>
> class IngredientsField(CharField):
>    def __init__(self, *args, **kwargs):
>    ..
>
> However I get an "Unknown column 'pizza_pizza.toppings' in 'field
> list'" error - BUT I don't want to add it as a column in toppings as I
> want it to be linked via the link table/model IngredientItems.
> Eventually what I want to achieve is while using the admin system for
> certain models that you manage there will be a text box where you can
> enter ingredients into a TextField in the admin comma delimited
> "Cheese, Ham" and then the model take care of the rest.
>
> Hopefully I'm pretty close, any ideas anyone?
>
> Thanks in advance,
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Error was: cannot import name validators

2010-05-18 Thread Pankaj Singh
pan...@pankaj-laptop:~/django_projects/pankaj$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core import validators

Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name validators
>>>

*Validators is really missing .. don't know how to install .. help needed*

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



Re: Restarting the server while working on dreamhost.

2010-05-18 Thread Pietro Speroni
Thanks for trying,
that didn't help.
What I actually needed to do was to
pkill python

I am writing it here in case someone later have a similar problem and
searches for this.

Pietro

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



Custom Django Admin translations

2010-05-18 Thread Ivan Mincik
Hi,
I would like to ask, what is the best way to change some of the
translation messages in Django Admin to custom ones. Is there any good
way, how to override system translations of Admin in some projects
where I need it ?

Thanks
Ivan

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



Re: Custom Form in a ModelFormset_Factory?

2010-05-18 Thread Ian Lewis
Pass the form class to modelformset_factory() in the form argument.
The factory will then use the AuthorForm class as the base form class
when it creates the modelform class for the formset.

modelFormset = modelformset_factory(Author, form=AuthorForm)

On Tue, May 18, 2010 at 7:08 AM, Michael Davis
 wrote:
>
> I am new to Django and am trying to get a custom modelForm to work in
> a ModelFormset_factory. For example:
>
> # in models.py
> class Author(models.Model):
>name = models.CharField()
>address = models.CharField()
>phone = models.CharField()
>
> class AuthorForm(ModelForm):
>class Meta:
>model = Author
>
> # in views.py
> def authorForm(request):
>modelFormset = modelformset_factory(Author)
>items = Author.objects.all()
>formsetInstance = modelFormset(queryset=items)
>return render_to_response('blah',locals())
>
> The above code works fine, but I'd like to be able to tweak the
> default presentation of the AuthorForm and use that in the
> formset_factory. Is there any way to do that through the AuthorForm
> class above? If not is there another nearly easy way?
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
===
株式会社ビープラウド  イアン・ルイス
〒150-0021
東京都渋谷区恵比寿西2-3-2 NSビル6階
email: ianmle...@beproud.jp
TEL:03-6416-9836
FAX:03-6416-9837
http://www.beproud.jp/
===

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