AttributeError: 'QuerySet' object has no attribute 'remove'

2010-03-10 Thread Hugh Zhang
Hi there, i have occured an error bellow with django 1.1:
*Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'QuerySet' object has no attribute 'remove'*
The whole code about this error is:

*>>> b = Blog.objects.get(id=1)
>>> e = Entry.objects.get(id=234)
>>> b.entry_set.remove(e)*

So, what's the problem with me? I need your help, thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 make django use a different python interpreter located at some random location.

2010-03-10 Thread Abhinov
Hi All,

How to make my django use a different python interpreter located at
some random location ?
Any help will be of great help.

Regards,
Abhinov

-- 
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: Database redesign for "user" table

2010-03-10 Thread derek
On Mar 8, 6:00 pm, Daniel Roseman  wrote:
> On Mar 8, 3:01 pm, Derek  wrote:
>
> > I am working with a legacy database and would appreciate some advice.
>
> > I have an existing "user" table, with some fields that overlap with the
> > design of Django's "user" table, and some fields that are "extra" to it.  I
> > understand that I can use Django's "user" table and extend it to include
> > these extra fields.
>
> > However, the problem lies with the user's "id" field.  In the legacy
> > database, this id appears in numerous tables (to identify the person who
> > last edited the record) but is a short character string, NOT an
> > auto-increment numeric value.  I am wondering what is the best/possible
> > approach in order to use all the features of Django admin without any code
> > changes.  I assume I will need to convert all the existing users into the
> > Django user table, but then do I:
>
> > a. leave the id field in the other tables "as is"?  In which case, is it
> > possible to somehow adapt Django's numeric id field to become alpha-numeric?
>
> > b. carry-out a mass update and convert all existing user id's in all tables
> > to the Django numeric format?
>
> > I think (b) might be better in the long run (although I am partial to the
> > idea of "human readable" id string when browsing the raw data), but I would
> > welcome other opinions (or options).
>
> > Thanks
> > Derek
>
> A Django ForeignKey field doesn't have to point at the related table's
> id column - you can use the 'to_field' attribute of the ForeignKey to
> point it at a different field. So I would suggest keeping your non-
> numeric key as (eg) 'legacy_key', and in your related models use:
>      user = ForeignKey(UserProfile, to_field='legacy_key').
>
> Would that work?
> --
> DR.

Thank you. That is an excellent suggestion. I will try it out.

Derek

-- 
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: ModelAdmin

2010-03-10 Thread Praveen
I know i can not directly register a form but i do not have any model
for Email. i just have plain form *forms.Form*
is there any other way to register Form with admin.
Thanks

On Mar 11, 3:03 am, Beres Botond  wrote:
> You cannot directly register a form with admin, you should be
> registering models
>
> from myapps.forms import MyModelForm
> from myapps.models import MyModel
>
> class MyModelAdmin(admin.ModelAdmin):
>      form = MyModelForm
>
> admin.site.register(MyModel, EmailAdmin)
>
> Also the form should be a ModelForm for that model.
>
> from django.forms import ModelForm
>
> # Create the form class.
> class MyModelForm(ModelForm):
>      class Meta:
>          model = MyModel
>
> Read the docs thoroughly, 
> especially:http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelformhttp://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-a...
>
> On Mar 10, 10:28 pm, Praveen  wrote:
>
> > Hi
> > I have one form in forms.py
>
> > class EmailForm(forms.Form):
> >     recipient = forms.CharField(max_length=14, min_length=12,
> > widget=forms.TextInput(attrs=require))
> >     message = forms.CharField(max_length=140, min_length=1,
> > widget=forms.Textarea(attrs={'cols': 30, 'rows': 5}))
>
> > and my site url is
> > admin.autodiscover()
> > urlpatterns = patterns('',  (r'^admin/(.*)',
> > include(admin.site.urls)),)
>
> > now i want it to be shown on admin interface
>
> > I tried so far
> > First attempt
>
> > from myapps.forms import EmailForm
> > class EmailAdmin(admin.ModelAdmin):
> >      form = EmailForm
> > did not work Exception Value:
> > 'DeclarativeFieldsMetaclass' object is not iterable
>
> > Second attempt
> > and now i 
> > followedhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
> > but could not get help
>
> > class EmailAdmin(admin.ModelAdmin):
> >     def my_view(self,request):
> >         return admin_my_view(request,self)
>
> >     def get_urls(self):
> >         urls = super(SmsAdmin, self).get_urls()
> >         my_urls = patterns('',(r'^my_view/
> > $',self.admin_site.admin_view(self.my_view)))
> >         return my_urls + urls
>
> > def admin_my_view(request, model_admin):
> >     opts = model_admin.model._meta
> >     admin_site = model_admin.admin_site
> >     has_perm = request.user.has_perm(opts.app_label \
> >     + '.' + opts.get_change_permission())
> >     context = {'admin_site': admin_site.name,
> >     'title': "My Custom View",
> >     'opts': opts,
> >     'root_path': '/%s' % admin_site.root_path,
> >     'app_label': opts.app_label,
> >     'has_change_permission': has_perm}
> >     template = 'admin/demo_app/admin_my_view.html'
> >     return render_to_response(template,
> > context,context_instance=RequestContext(request))
> > admin.site.register(EmailForm,EmailAdmin)
>
> > and when i run server and type on browserhttp://localhost:8000/admin
> > and hit enter button
>
> > Exception Value:
> > 'DeclarativeFieldsMetaclass' object is not iterable
>
> > and second time just after first time when i again enter then it show
> > me the admin page but i can't see my EmailAdmin in admin intercae..
>
> > Just help me or suggest me any link.
>
> > Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: ModelAdmin

2010-03-10 Thread Praveen


On Mar 11, 3:03 am, Beres Botond  wrote:
> You cannot directly register a form with admin, you should be
> registering models
I know i can not directly register a form but i do not have any model
for Email. i just have plain form *forms.Form*
is there any other way to register Form with admin.
Thanks
>
> from myapps.forms import MyModelForm
> from myapps.models import MyModel
>
> class MyModelAdmin(admin.ModelAdmin):
>      form = MyModelForm
>
> admin.site.register(MyModel, EmailAdmin)
>
> Also the form should be a ModelForm for that model.
>
> from django.forms import ModelForm
>
> # Create the form class.
> class MyModelForm(ModelForm):
>      class Meta:
>          model = MyModel
>
> Read the docs thoroughly, 
> especially:http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelformhttp://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-a...
>
> On Mar 10, 10:28 pm, Praveen  wrote:
>
> > Hi
> > I have one form in forms.py
>
> > class EmailForm(forms.Form):
> >     recipient = forms.CharField(max_length=14, min_length=12,
> > widget=forms.TextInput(attrs=require))
> >     message = forms.CharField(max_length=140, min_length=1,
> > widget=forms.Textarea(attrs={'cols': 30, 'rows': 5}))
>
> > and my site url is
> > admin.autodiscover()
> > urlpatterns = patterns('',  (r'^admin/(.*)',
> > include(admin.site.urls)),)
>
> > now i want it to be shown on admin interface
>
> > I tried so far
> > First attempt
>
> > from myapps.forms import EmailForm
> > class EmailAdmin(admin.ModelAdmin):
> >      form = EmailForm
> > did not work Exception Value:
> > 'DeclarativeFieldsMetaclass' object is not iterable
>
> > Second attempt
> > and now i 
> > followedhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
> > but could not get help
>
> > class EmailAdmin(admin.ModelAdmin):
> >     def my_view(self,request):
> >         return admin_my_view(request,self)
>
> >     def get_urls(self):
> >         urls = super(SmsAdmin, self).get_urls()
> >         my_urls = patterns('',(r'^my_view/
> > $',self.admin_site.admin_view(self.my_view)))
> >         return my_urls + urls
>
> > def admin_my_view(request, model_admin):
> >     opts = model_admin.model._meta
> >     admin_site = model_admin.admin_site
> >     has_perm = request.user.has_perm(opts.app_label \
> >     + '.' + opts.get_change_permission())
> >     context = {'admin_site': admin_site.name,
> >     'title': "My Custom View",
> >     'opts': opts,
> >     'root_path': '/%s' % admin_site.root_path,
> >     'app_label': opts.app_label,
> >     'has_change_permission': has_perm}
> >     template = 'admin/demo_app/admin_my_view.html'
> >     return render_to_response(template,
> > context,context_instance=RequestContext(request))
> > admin.site.register(EmailForm,EmailAdmin)
>
> > and when i run server and type on browserhttp://localhost:8000/admin
> > and hit enter button
>
> > Exception Value:
> > 'DeclarativeFieldsMetaclass' object is not iterable
>
> > and second time just after first time when i again enter then it show
> > me the admin page but i can't see my EmailAdmin in admin intercae..
>
> > Just help me or suggest me any link.
>
> > Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



Validating a specific model field

2010-03-10 Thread Julien Phalip
Hi,

It's the first time I'm playing with model validation, and I'm a bit
stuck with something. I couldn't find any help on this mailinglist or
in the doc, but if there is please let me know where :)

Basically I'd like to validate a model field in the context of its
instance. First I assumed it would work like with form validation, so
I did:

class Title(models.Model):
is_video = models.BooleanField(...)
aspect_ratio = models.CharField(...)
...

clean_aspect_ratio(self, value):
if self.is_video is True and value == '':
raise ValidationError('The aspect ratio is required for
video titles.')

But this doesn't work. The 'clean_aspect_ratio' method is never
called. I could use validators, but from there I can't have access to
the model instance and therefore I can't access the 'is_video'
attribute. It sort of works with the 'clean' method:

class Title(models.Model):
...

clean(self):
if self.is_video and value == '':
raise ValidationError('The aspect ratio is required for
video titles.')

However, this error is not attached specifically to the 'aspect_ratio'
attribute, therefore the error is displayed at the top of the admin
form rather than next to the aspect_ratio form field.

Is there a way to achieve the same type of specific validation like
with forms?

Many thanks,

Julien

-- 
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: Filtering by another object's ManyToMany properties

2010-03-10 Thread Laereom
Hey, thanks.  EXACTLY what I needed.

On Mar 10, 3:03 pm, Daniel Roseman  wrote:
> On Mar 10, 10:38 pm, Laereom  wrote:
>
>
>
>
>
> > I have two models, we'll call them 'Question' and 'Search'.
>
> > Search has a many to many field called 'questions' which contain,
> > naturally, a set of questions.
>
> > I want to retrieve a Question which is associated with a particular
> > Search through that many to many field.
>
> > It seemed straightforward -- I wrote something like this:
>
> > search = Search.objects.get(myCriteria)
> > question = Question.objects.filter(id=search.questions.id)
>
> > However, I'm getting an AttributeError:
>
> > 'ManyRelatedManager' object has no attribute 'id'
>
> > Any advice?
>
> You've used a ManyToMany field, so there isn't a "particular question"
> associated with a Search - there are Many, hence the name. So which of
> the many questions are you hoping to get?
>
> You can get *all* of them by simply doing:
>
>     search.questions.all()
>
> which returns a queryset, ie a list-like object containing several
> questions. See the documentation 
> here:http://docs.djangoproject.com/en/1.1/ref/models/relations/
> --
> 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: templates?

2010-03-10 Thread lalla
Hello jirka,
i could not get through the error. But when i run python manage.py
shell..
and do the same.i aint getting any errors.
what should i put in PYTHONPATH? to make it run through only
python.How to configure the things manually.

Thanx in advance
On Mar 11, 2:41 am, Jirka Vejrazka  wrote:
> > DJANGO_SETTINGS_MODULE=C:/django/Django-1.1.1/djangotest/mysite/settings
>
> Oops - I take it back (it's been a long day).
>
> You need to supply Python path, i.e just "mysite.settings" if you
> PYTHONPATH is already set to
> PYTHONPATH=C:\django\Django-1.1.1\djangotest  and mysite is a
> directory there.
>
>   Sorry about that
>
>    Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: need help in multi db

2010-03-10 Thread lakshmi silaja
thanks for ur suggestion jirka

On Thu, Mar 11, 2010 at 3:01 AM, Jirka Vejrazka wrote:

> Hi Silaja,
>
>  first, I'm going to guess that no one will be able to solve your
> problem. There are multiple reasons for it:
>
>  - Multiple database support is in Django 1.2. You insist on using it
> on Django 1.1, without mentioning why you can't upgrade (the upgrade
> would make sense for any reader not knowing the context that only you
> currently do know)
>  - the code written by Eric F. is an interesting hack for older
> versions of Django, but not too many people have probably used it, so
> there would be little experience with that. However, there is a
> problem:
>  - * you have not specified what your problem was when you tried it *
> So, even people willing to spend their time helping you could not do
> it as they would not know how far you have gotten implementing it and
> what actually stopped you from succeeding.
>  - you mentioned "i.e some of rows in some "x" table in one database
> and some of rows in "x" table in other database. i want to select
> which database used to add/retrieve the rows dynamically". This is
> quite complex and even the code from Eric's site will not help you
> much. If you make it working, it will lay the foundations, but you'd
> still be quite far from reaching your goal.
>
>  I'm afraid that you need to give us more detail and the actual
> context before you can expect better answer than "upgrade to Django
> 1.2".
>
>  Cheers
>
>Jirka
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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: /admin/auth/user/ trouble after doing the tutorial

2010-03-10 Thread John Griessen

John Griessen wrote:
http://127.0.0.1:8080/admin/auth/group/ shows zero groups.  is that a 
problem?


I tried adding a group with many permissions and rights and it just resulted in
an error message:   "Table 'django_server.auth_group_permissions' doesn't exist"

Should I be logging into mysql to check some things, or starting from scratch?

John

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



/admin/auth/user/ trouble after doing the tutorial

2010-03-10 Thread John Griessen

I have gone through the tutorials and get an error when using the admin UI
about users and authorizations.
Exception Value:

(1146, "Table 'django_server.auth_user_groups' doesn't exist")

I found this
"Note that the default settings.py file created by django-admin.py startproject includes 'django.contrib.auth' and 
'django.contrib.contenttypes' in INSTALLED_APPS for convenience. If your INSTALLED_APPS already contains these apps, feel free to 
run manage.py syncdb again"


and did a
manage.py syncdb
but no change...

the django app made by doing the tutorial functions, it saves poll votes in the 
database
and they persist from login to login to the admin site   as I have it set up
on my local machine:
http://127.0.0.1:8080/admin/auth/

http://127.0.0.1:8080/admin/auth/group/ shows zero groups.  is that a problem?

Seems related to not being able to delete a user and getting the error:

"Table 'django_server.auth_user_groups' doesn't exist"

Clues?

Thanks,

John


--
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: 1.1.2

2010-03-10 Thread brad
Thanks both. We'll use the 1.1 branch head then



On Mar 11, 4:22 pm, James Bennett  wrote:
> On Wed, Mar 10, 2010 at 9:16 PM, brad  wrote:
> > When can we expect a release of 1.1.2? Specifically I'm hoping to get
> > a test bug fixed -http://code.djangoproject.com/ticket/12720
>
> Barring unforeseen circumstances, a 1.1.2 release will probably
> accompany the release of Django 1.2.
>
> In the meantime, it's quite possible -- and at my day job we do this
> with no ill effects -- to simply run off the head of the 1.1.X release
> branch, periodically updating as needed. Since the release branches
> *only* receive bugfixes and security updates, this is usually an easy
> way to get fixes without waiting for point releases to be issued out
> of it.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."

-- 
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: 1.1.2

2010-03-10 Thread James Bennett
On Wed, Mar 10, 2010 at 9:16 PM, brad  wrote:
> When can we expect a release of 1.1.2? Specifically I'm hoping to get
> a test bug fixed - http://code.djangoproject.com/ticket/12720

Barring unforeseen circumstances, a 1.1.2 release will probably
accompany the release of Django 1.2.

In the meantime, it's quite possible -- and at my day job we do this
with no ill effects -- to simply run off the head of the 1.1.X release
branch, periodically updating as needed. Since the release branches
*only* receive bugfixes and security updates, this is usually an easy
way to get fixes without waiting for point releases to be issued out
of it.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

-- 
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: 1.1.2

2010-03-10 Thread Russell Keith-Magee
On Thu, Mar 11, 2010 at 11:16 AM, brad  wrote:
> Hi all
>
> When can we expect a release of 1.1.2? Specifically I'm hoping to get
> a test bug fixed - http://code.djangoproject.com/ticket/12720

The most likely scenario is that we will cut 1.1.2 at the same time we
cut 1.2-final. The exact date depends on progress through the 1.2
ticket list, but current estimates are around 3 weeks.

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.



1.1.2

2010-03-10 Thread brad
Hi all

When can we expect a release of 1.1.2? Specifically I'm hoping to get
a test bug fixed - http://code.djangoproject.com/ticket/12720


Thanks
Brad

-- 
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 Queryset one Paginator

2010-03-10 Thread felix

post the code that chains them together

probably the problem is that paginator needs to slice the query set,
and the chain you have isn't capable of doing that.

either write a fancier chain that can count the length of both queries
and then figure out how it has to slice them

or do it in the view : figure out where the break is (all in the
first, some of both, all in the second ?) and slice each then chain
those



On Mar 9, 8:33 pm, Mat  wrote:
> I was wondering if there is a way to put multiple querysets into one
> paginator. Currently I have my querysets being chained together with
> itertools. But i am unable to put the chained querysets into the
> paginator. Does any one know how I can combine multiple paginators
> into one or multiple querysets into one big queryset not a chain of
> querysets?
>
> thanks
> mat

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



def reload(model): model.__dict__ = model.__class__.objects.get(pk=model.pk).__dict__ ; return model

2010-03-10 Thread Phlip
Djangoists:

If I have a Frob model object, and I need it to reload itself out of
the database (for example it's dirty and the DB is clean), I want
reload(frob) -style convenience.

This time, the sample code's so short it's in the Subject line.

But is it healthy? Does Python support (or fail to prevent) assigning
a .__dict__ like that?

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand

-- 
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_mass_mail()

2010-03-10 Thread CLIFFORD ILKAY

On 03/10/2010 06:22 PM, onoxo wrote:

hi!

I know about Mailman but i have to send unique mail to each user, kind
of confirmation with system generated url.



--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

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



Django query with related models

2010-03-10 Thread aurphir
For the below models:

class Customer(models.Model):
id = models.IntegerField(primary_key=True)

class OrderA(models.Model):
name = models.CharField(max_length=20)
foo = models.FloatField()
customer = models.ForeignKey(Customer)
type = models.IntegerField()

class OrderB(models.Model):
name = models.CharField(max_length=20)
customer = models.ForeignKey(Customer)
type = models.IntegerField()

I want to grab all the Customer objects with their related OrderA and
OrderB objects in one go for a condition (where type in OrderA and
OrderB equals 1)

-- 
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: hi help regarding sharding

2010-03-10 Thread David
Chiranjeevi,

You might try looking at Django's multidb support if you are using
Django 1.2. I don't want to say it has built-in sharding support, but
it will probably make life easier.

http://docs.djangoproject.com/en/dev/topics/db/multi-db/#an-example

In general, you'll probably be writing a custom router to direct your
traffic.

-David

On Mar 10, 2:41 am, chiranjeevi muttoju
 wrote:
> Hi,
> i want to use *Sharding* concept in for my project. i requirement is, i have
> one user model, and i want to save users by selecting the random databases.
> ie. i have two tables db1 and db2, in both databases i have user table.
> based on the userid i want to select the database in which that user object
> should be persist. if any one know please help me. if any doubts about my
> requirement plz reply me, i'll tell.
> --
> Thanks & Regards,
> Chiranjeevi.Muttoju

-- 
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_mass_mail()

2010-03-10 Thread felix

I have a site that sends 40k in a day.

take a look at http://code.google.com/p/django-mailer/

I'm using that, though I've now modified it and not had a chance to
release my version.

mails are put into a queue and the queue is fed by a background daemon
loop

I've added html support and actually I don't render out each mail at
send time.
I render one message, then I have various placeholders which can be
replaced at send time for the individual.

there is absolutely no way you can emails to more than 50 users while
the sender waits for the view to return

there will be errors

there will be bounces



On Mar 11, 12:24 am, onoxo  wrote:
> @CLIFFORD ILKAY
> how did you handle so much mails?
>
> On Mar 11, 12:22 am, onoxo  wrote:
>
>
>
> > hi!
>
> > I know about Mailman but i have to send unique mail to each user, kind
> > of confirmation with system generated url.
>
> > On Mar 11, 12:16 am, CLIFFORD ILKAY 
> > wrote:
>
> > > On 03/10/2010 02:19 PM, onoxo wrote:
>
> > > > how much mails can i send with send_mass_mail()
> > > > i have like 7000 users and i have send mail to all of them.
>
> > > I've done large mailshots before. It's not fun if you don't have some
> > > method of bounce handling because even if you have a very clean list,
> > > with a list that large, you're bound to get the usual array of soft and
> > > hard bounces. Creating an announcement only mailing list in Mailman is
> > > quite easy. If you do that, your Django app only has to send an email to
> > > one address, the announcement only list's address. Then, you have a
> > > mature body of code to handle bounces, unsubscribes (if you wish), etc.
> > > Mailman is written in Python so it's easy to incorporate with your code
> > > at a lower level, if you need that.
> > > --
> > > Regards,
>
> > > Clifford Ilkay
> > > Dinamis
> > > 1419-3266 Yonge St.
> > > Toronto, ON
> > > Canada  M4N 3P6
>
> > > 
> > > +1 416-410-3326

-- 
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_mass_mail()

2010-03-10 Thread onoxo
@CLIFFORD ILKAY
how did you handle so much mails?

On Mar 11, 12:22 am, onoxo  wrote:
> hi!
>
> I know about Mailman but i have to send unique mail to each user, kind
> of confirmation with system generated url.
>
> On Mar 11, 12:16 am, CLIFFORD ILKAY 
> wrote:
>
>
>
> > On 03/10/2010 02:19 PM, onoxo wrote:
>
> > > how much mails can i send with send_mass_mail()
> > > i have like 7000 users and i have send mail to all of them.
>
> > I've done large mailshots before. It's not fun if you don't have some
> > method of bounce handling because even if you have a very clean list,
> > with a list that large, you're bound to get the usual array of soft and
> > hard bounces. Creating an announcement only mailing list in Mailman is
> > quite easy. If you do that, your Django app only has to send an email to
> > one address, the announcement only list's address. Then, you have a
> > mature body of code to handle bounces, unsubscribes (if you wish), etc.
> > Mailman is written in Python so it's easy to incorporate with your code
> > at a lower level, if you need that.
> > --
> > Regards,
>
> > Clifford Ilkay
> > Dinamis
> > 1419-3266 Yonge St.
> > Toronto, ON
> > Canada  M4N 3P6
>
> > 
> > +1 416-410-3326

-- 
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_mass_mail()

2010-03-10 Thread onoxo
hi!

I know about Mailman but i have to send unique mail to each user, kind
of confirmation with system generated url.

On Mar 11, 12:16 am, CLIFFORD ILKAY 
wrote:
> On 03/10/2010 02:19 PM, onoxo wrote:
>
> > how much mails can i send with send_mass_mail()
> > i have like 7000 users and i have send mail to all of them.
>
> I've done large mailshots before. It's not fun if you don't have some
> method of bounce handling because even if you have a very clean list,
> with a list that large, you're bound to get the usual array of soft and
> hard bounces. Creating an announcement only mailing list in Mailman is
> quite easy. If you do that, your Django app only has to send an email to
> one address, the announcement only list's address. Then, you have a
> mature body of code to handle bounces, unsubscribes (if you wish), etc.
> Mailman is written in Python so it's easy to incorporate with your code
> at a lower level, if you need that.
> --
> Regards,
>
> Clifford Ilkay
> Dinamis
> 1419-3266 Yonge St.
> Toronto, ON
> Canada  M4N 3P6
>
> 
> +1 416-410-3326

-- 
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_mass_mail()

2010-03-10 Thread CLIFFORD ILKAY

On 03/10/2010 02:19 PM, onoxo wrote:

how much mails can i send with send_mass_mail()
i have like 7000 users and i have send mail to all of them.


I've done large mailshots before. It's not fun if you don't have some 
method of bounce handling because even if you have a very clean list, 
with a list that large, you're bound to get the usual array of soft and 
hard bounces. Creating an announcement only mailing list in Mailman is 
quite easy. If you do that, your Django app only has to send an email to 
one address, the announcement only list's address. Then, you have a 
mature body of code to handle bounces, unsubscribes (if you wish), etc. 
Mailman is written in Python so it's easy to incorporate with your code 
at a lower level, if you need that.

--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

--
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: Thread safe language switching?

2010-03-10 Thread Jens Rantil
Hi Michal,

I'm not sure, but I would write the verbose names manually for each
field, wrapping each string inside a ugettext(...) function call like
so:
class Poll(models.Model):
  ...
  field = models.CharField(ugettext("My verbose name"), max_length=40)
  ...

Thay way I could just use the normal './manage.py makemessages' to
extract the translatable strings.

Regards,
Jens

On Mar 8, 2:28 pm, Plovarna  wrote:
> Hello,
> I just developing my first aplication with internationalization. I need to 
> get all verbose_name values of the model for each language defined in 
> settings.LANGUAGES. I do it by this code defined inside model method :
>
>    current_lang = get_language()
>    names = {}
>    for lang in settings.LANGUAGES:
>        activate(lang[0])
>        class_name = unicode(self.__class__._meta.verbose_name)
>        names.append(class_name)
>        deactivate()
>    activate(current_lang)
>
> My question is: Is this approach thread safe? Is there any other way how to 
> get verbose_name of the model for each defined language?
>
> Thank you for any advice
> Michal

-- 
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: ValueError, The view django_bookmarks.bookmarks.views.user_page didn't return an HttpResponse object.

2010-03-10 Thread Daniel Roseman
On Mar 8, 4:24 pm, Naveen Reddy  wrote:

> def user_page(request, username):
>     try:
>         user = User.objects.get(username=username)
>     except:
>             raise Http404('Requested user not found.')
>         bookmarks = user.bookmark_set.all()
>         template = get_template('user_page.html')
>         variables = Context({
>         'username': username,
>         'bookmarks': bookmarks
>     })

No, everything from bookmarks onwards must be at the same level as
'try' and 'except'.

Honestly, you need to read a Python tutorial. Indentation is
significant in Python, and you won't get very far without
understanding that.
--
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: send_mass_mail()

2010-03-10 Thread onoxo
thanks!
i'm talking with people from webfaction about smtp limit, i'll post
result...


On Mar 10, 9:04 pm, Jirka Vejrazka  wrote:
> > how much mails can i send with send_mass_mail()
> > i have like 7000 users and i have send mail to all of them.
>
> Hi,
>
>   I have never used it myself, but a quick glance at the source code
> does not show any reason why this would not work. However, keep two
> things in mind:
>
>   - the emails are first all constructed in memory, which could be a
> bit of a problem if the email body is large
>   - the SMTP server must be able to handle 7000 emails in one go
>
>   Hope this helps a bit
>
>     Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Filtering by another object's ManyToMany properties

2010-03-10 Thread Daniel Roseman
On Mar 10, 10:38 pm, Laereom  wrote:
> I have two models, we'll call them 'Question' and 'Search'.
>
> Search has a many to many field called 'questions' which contain,
> naturally, a set of questions.
>
> I want to retrieve a Question which is associated with a particular
> Search through that many to many field.
>
> It seemed straightforward -- I wrote something like this:
>
> search = Search.objects.get(myCriteria)
> question = Question.objects.filter(id=search.questions.id)
>
> However, I'm getting an AttributeError:
>
> 'ManyRelatedManager' object has no attribute 'id'
>
> Any advice?

You've used a ManyToMany field, so there isn't a "particular question"
associated with a Search - there are Many, hence the name. So which of
the many questions are you hoping to get?

You can get *all* of them by simply doing:

search.questions.all()

which returns a queryset, ie a list-like object containing several
questions. See the documentation here:
http://docs.djangoproject.com/en/1.1/ref/models/relations/
--
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: How to use pre-built HTML forms in Django

2010-03-10 Thread esatterwh...@wi.rr.com
I would build a form using the forms library - subclass forms.Form and
let django do the validation for you and return the errors.

Once you have that bit in place, you can add your javascript
enhancements and logic ontop of it.

if need js funcionality for specific fields that Django doesn't
supply, you create acustom field widget to do that part. This would be
the easiest way.

It looks like by all of your posts you are trying to build a django
application with out any django!

On Mar 9, 11:26 am, MMRUser  wrote:
> So as per your knowledge can u suggest a proper way of getting data
> from a form but not as mentioned inhttp://www.djangobook.com/en/2.0/chapter07/
> that way is too rusty.
>
> Thanks.
>
> On Mar 9, 7:28 pm, rebus_  wrote:
>
> > On 9 March 2010 15:22, MMRUser  wrote:
>
> > > The problem I's having is that my HTML form depends upon lot of
> > > external resources like javascript validation libraries and lots of
> > > css on fields (and some may differ from each other), and I think that
> > > I don't need to use re-usable templates because I just want to design
> > > a one simple form so there's only one HTML file.Do you think that is
> > > it ok to just ignore the Django's template system and get along with
> > > the normal way.
>
> > > On Mar 9, 2:32 pm, rebus_  wrote:
> > >> On 9 March 2010 05:54, MMRUser  wrote:
>
> > >> > Thanks another doubt,what about the css mappings class="field text
> > >> > medium" do they also need to include in the class definition in
> > >> > Django.
>
> > >> > On Mar 9, 9:21 am, rebus_  wrote:
> > >> >> On 9 March 2010 05:04, MMRUser  wrote:
>
> > >> >> > I have an pre-built HTML form (means I design the HTML form
> > >> >> > separately) and I need to reuse it with Django form class
> > >> >> > (django.forms), So how do I incorporate my HTML form with Django 
> > >> >> > form
> > >> >> > class. for example
>
> > >> >> > HTML:
>
> > >> >> > 
> > >> >> >  
> > >> >> >  Username
> > >> >> >  *
> > >> >> >  
> > >> >> >  
> > >> >> >  
> > >> >> >  
> > >> >> > 
>
> > >> >> > How do I map this HTML in to Django form definition, I know that it
> > >> >> > can be done by modifying Django form fields according to this HTML.
> > >> >> > But I guess it's a time consuming approach,so I would like to know
> > >> >> > that is there any easy and time saving solutions for this issue.
>
> > >> >> > Thanks.
>
> > >> >> > --
> > >> >> > You received this message because you are subscribed to the Google 
> > >> >> > Groups "Django users" group.
> > >> >> > To post to this group, send email to django-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.
>
> > >> >> Well usually you first create a form in django and use its instance to
> > >> >> generate the HTML.
>
> > >> >> You can also write the HTML by yourself and all you need to be careful
> > >> >> of is that name and id attributes of you inputs and input type are
> > >> >> same as in the class you define.
>
> > >> >> Your HTML corresponds to:
>
> > >> >> class MyForm(forms.Form):
> > >> >>    Field11 = forms.CharField(label="Username",  max_length=255)
>
> > >> >> I highly recommend to first setup a form class then write HTML and
> > >> >> making form fields have more sensible names then Field11.
>
> > >> >> Also i suggest these links as further reading:
>
> > >> >>http://docs.djangoproject.com/en/dev/topics/forms/http://docs.djangop...
>
> > >> > --
> > >> > 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.
>
> > >> No, CSS classes are not defined in form class (as far as i know).
>
> > >> I would suggest using reusable form templates [1] and putting the CSS
> > >> classes on field wrappers for example.
>
> > >> This is what you are interested in:
>
> > >>http://docs.djangoproject.com/en/dev/topics/forms/#reusable-form-temp..
>
> > >> Which ever approach you decide to use is valid, but writing a bunch of
> > >> your own HTML for forms takes more time but is also more customisable,
> > >> on the other hand using shortcut methods such as "as_p" [1] or
> > >> "as_table" [2] is faster but you have less control over the outputted
> > >> HTML.
>
> > >> [1]http://docs.djangoproject.com/en/dev/ref/forms/api/#as-p
> > >> [2]http://docs.djangoproject.com/en/dev/ref/forms/api/#as-table
>
> > > --
> > > You received this message because 

Re: Filtering by another object's ManyToMany properties

2010-03-10 Thread Nick
try search__questions.id

the __ spans the many to many relationship

On Mar 10, 4:38 pm, Laereom  wrote:
> I have two models, we'll call them 'Question' and 'Search'.
>
> Search has a many to many field called 'questions' which contain,
> naturally, a set of questions.
>
> I want to retrieve a Question which is associated with a particular
> Search through that many to many field.
>
> It seemed straightforward -- I wrote something like this:
>
> search = Search.objects.get(myCriteria)
> question = Question.objects.filter(id=search.questions.id)
>
> However, I'm getting an AttributeError:
>
> 'ManyRelatedManager' object has no attribute 'id'
>
> Any advice?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: overriding saving fails in loop

2010-03-10 Thread Ali Rıza Keleş
El mié, 10-03-2010 a las 17:28 -0500, Shawn Milochik escribió:
> I think you missed my point, or I explained it badly.
> 
> 1. In makeOrder, change i.save() to i.save(reorder = False).
> 
> 2. Change the save function to something like the following
> (untested):
> 
> def save(self, *args, **kwargs):
> 
> do_ordering = kwargs.pop('reorder', True)
>   
> super(Subject, self).save(*args, **kwargs)
> 
> if do_ordering:
> self.makeOrder()
> 
> 
> This way, the makeOrder function will be called every time an instance
> is saved, *except* what that save was called from the makeOrder
> function. This is exactly what you're asking for.
> 
> Shawn
> 

Hımm.. That's the point. Perfecto.. 
Gracias Shawn.. 

I am learning... 

Thanks.. 

--
Ali Rıza


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



Filtering by another object's ManyToMany properties

2010-03-10 Thread Laereom
I have two models, we'll call them 'Question' and 'Search'.

Search has a many to many field called 'questions' which contain,
naturally, a set of questions.

I want to retrieve a Question which is associated with a particular
Search through that many to many field.

It seemed straightforward -- I wrote something like this:

search = Search.objects.get(myCriteria)
question = Question.objects.filter(id=search.questions.id)

However, I'm getting an AttributeError:

'ManyRelatedManager' object has no attribute 'id'

Any advice?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: if statement with url

2010-03-10 Thread Nick
Just pop this into your template:

{% url Path.to.a.view.for.this.template as the_url %}
# you are importing a view's url structure right here and then storing
it as "the_url". Since you're not looking for anything dynamic we can
end that definition here (more here 
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url)
then
{% ifequal the_url "/the/url/to/check" %} pretty self explanatory
this is the result if that is true
{% endifequal %}

It might be a good idea to check this before adding any conditional
statement:


{% url Path.to.a.view.for.this.template as the_url %}
{{ the_url }} should output the relative URL (django calls relative
paths absolute paths for some reason)





On Mar 10, 3:42 pm, HARRY POTTRER  wrote:
> maybe try request.path?
>
> On Mar 10, 1:51 pm, Daxal  wrote:
>
> > Hey,
>
> > I wanted to use a if statement with a url like ...
>
> > if you are on "/cm/add/"
> > ..
> > endif
> > .
> > option 1:
> > I was wondering if anyone knows how to code that statement. if can
> > compare string variables like {% ifequal somevariable url %} where
> > "url" can be hard coded like "/cm/add" and somevariable would have to
> > store the url which i think is too complex.
>
> > option 2:
> > some if statement that directly compares the url like {% if {url} == "/
> > cm/add/" %}
>
> > any thoughts and ideas guys?
>
> > Thank you for all your replies. :)

-- 
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: why is __exact filter really doing an inexact match?

2010-03-10 Thread Margie Roginski
Ah yes - I am using mysql.  Thanks for that pointer.

Margie

On Mar 10, 1:34 pm, Karen Tracey  wrote:
> Are you using MySQL? See the note about MySQL here:
>
> http://docs.djangoproject.com/en/dev/ref/models/querysets/#exact
>
> Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: overriding saving fails in loop

2010-03-10 Thread Shawn Milochik
I think you missed my point, or I explained it badly.

1. In makeOrder, change i.save() to i.save(reorder = False).

2. Change the save function to something like the following (untested):

def save(self, *args, **kwargs):

do_ordering = kwargs.pop('reorder', True)

super(Subject, self).save(*args, **kwargs)

if do_ordering:
self.makeOrder()


This way, the makeOrder function will be called every time an instance is 
saved, *except* what that save was called from the makeOrder function. This is 
exactly what you're asking for.

Shawn

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



SNIPPET: assert_model_changes(record, 'field', 41, 42, lambda: money_line())

2010-03-10 Thread Phlip
Djangoids:

This is from Cuker's fork of django-test-extensions:

def assert_model_changes(self, mod, item, frum, too, lamb):
source = open(lamb.func_code.co_filename, 'r').readlines()
[lamb.func_code.co_firstlineno - 1]
source = source.replace('lambda:', '').strip()
model  = str(mod.__class__).replace("'>", '').split('.')[-1]

should = '%s.%s should equal `%s` before your activation line,
`%s`' % \
  (model, item, frum, source)

self.assertEqual(frum, mod.__dict__[item], should)
lamb()
mod = mod.__class__.objects.get(pk=mod.pk)

should = '%s.%s should equal `%s` after your activation line, `
%s`' % \
  (model, item, too, source)

self.assertEqual(too, mod.__dict__[item], should)
return mod

You call it like this:

self.assert_model_changes( blog, 'post_count', 41, 42, lambda:
blog.write_one_post('yack yack yack') )

The assertion covers the common situation where we assert a member
value before and after a method call, to check that it changed (or
that it did _not_ change!).

If the assertion fails, it prints out a complete diagnostic, including
the money line - "blog.write_one_post('yack yack yack')", the type of
the blog model ("Blog"), the attribute checked ("post_count"), the
expected value, AND whether the assertion failed before or after the
money line.

(The "money line" is jargon for the "Activate" line in the Assemble
Activate Assert pattern. It's the production-code target of the test
case.)

One little question - how can we cleanly upgrade this to eval() a
string instead of serve an attribute?

self.assert_model_changes( blog, 'post.count()', 41, 42,
lambda:
blog.write_one_post('yack yack yack') )

The code shows how to .reload() in Django, because (unless I'm wrong),
Django models don't have a method to reload themselves from their data
stores.

Another little question: If anyone can suggest a code cleanup, I'm
there!

--
  Phlip

-- 
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: overriding saving fails in loop

2010-03-10 Thread Ali Rıza Keleş
El mié, 10-03-2010 a las 15:37 -0500, Shawn Milochik escribió:
> Every time you save(), you call makeOrder(). Every time you run
> makeOrder(), you call save(). You've introduced an infinite loop.
> Well, infinite until Python decides enough is enough.
> 
Yes right.

But I need to reorder them all after each saving. If I try to reorder
while saving, It starts a new saving, ... and so on.. that means
infinitive loop.


> One simple possibility is to add an optional argument with a default
> of True to the save() override that determines whether to makeOrder().
> Just ensure that when makeOrder() calls save() that it sets that to
> False.
sorry. I couldn't do anything. makeOrder calls save for each item. 

an example:
let them be first states of records. 

nameorder
-
a   10
b   20
c   30
d   40
e   50

for example when I changed 'c' to 45, because I want to insert 'c'
between 'd' and 'e' 

First of all c would be set to 45,

nameorder
-
a   10
b   20
c   45
d   40
e   50

after reordering them 10 intervals, 'd' would be set 30 and 'c' would be
set 40. So now 'c' is between 'd' and 'e' as I expected.

nameorder
--
a   10
b   20
c   40
d   30
e   50



How can I do this?

Thanks. 

--
Ali 

> Shawn
> 
> 

> Hi all,
> 
> I want to override saving of one of my models.
> After saving any record, I am trying to reorder them all.  
> 
> class Subject(models.Model):
> slug = models.SlugField(db_index=True, unique=True)
> name = models.CharField(max_length="120")
> order = models.CharField(blank = True, max_length="3")
> 
> class Meta:
> ordering = ['order']
> 
> def __unicode__(self):
> return u'%s' % (self.name)
> 
> def __str__(self):
> return self.__unicode__()
> 
> def save(self, *args, **kwargs):
> super(Subject, self).save(*args, **kwargs)
> self.makeOrder()
> 
> def makeOrder(self):
> t = 10
> for i in Subject.objects.all().order_by('order'):
> i.order = t
> i.save()
> t += 10
> 
> 
> But here, It fails in a loop and give "maximum recursion depth
> exceeded"
> error.
> 
> How can I do? 

-- 
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: Generic create_update with inline many-to-many

2010-03-10 Thread Beres Botond
Please copy and paste here the Model definitions for Recept,
ingredient and 'verhouding' (I'm assuming this is explicitly defined,
given the non-standard name)

On Mar 10, 11:07 am, Marout  wrote:
> Hi there,
>
> I'm relatively new tio django and I can't get to grips with my many-to-many
> relations.
>
> Idea:
>
> I have a cooking Recept which has a many-to-many relation to it's
> ingredients.
> Recept has:
> -ID
> -Name
> -preparation text
> -resulting amount (numeric)
> -resulting amount (unit of measurement => relation to measurement table)
>
> The many-to-many relation is defined in the table 'verhouding'.
>
> This verhouding table contains keys for recept and ingredient.
> Also it contains additional columns for
> -amount (numeric)
> -amount (unit of measurement => relation to a measurement table)
> -following order of addition
>
> I try to create 2 web pages:
> -first you enter a recept name. Django checks if it exists.
> The nexpt page is either empty (recept was non-existent) or has the data
> from the requested recept, ready for modification.
>
> How do I accomplish this?
> because every time I try, the pk of recept seems lost which causes django to
> fail.
>
> Regards,
> marout

-- 
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: ModelAdmin

2010-03-10 Thread Beres Botond
You cannot directly register a form with admin, you should be
registering models

from myapps.forms import MyModelForm
from myapps.models import MyModel

class MyModelAdmin(admin.ModelAdmin):
 form = MyModelForm

admin.site.register(MyModel, EmailAdmin)

Also the form should be a ModelForm for that model.

from django.forms import ModelForm

# Create the form class.
class MyModelForm(ModelForm):
 class Meta:
 model = MyModel

Read the docs thoroughly, especially:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelform
http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-admin


On Mar 10, 10:28 pm, Praveen  wrote:
> Hi
> I have one form in forms.py
>
> class EmailForm(forms.Form):
>     recipient = forms.CharField(max_length=14, min_length=12,
> widget=forms.TextInput(attrs=require))
>     message = forms.CharField(max_length=140, min_length=1,
> widget=forms.Textarea(attrs={'cols': 30, 'rows': 5}))
>
> and my site url is
> admin.autodiscover()
> urlpatterns = patterns('',  (r'^admin/(.*)',
> include(admin.site.urls)),)
>
> now i want it to be shown on admin interface
>
> I tried so far
> First attempt
>
> from myapps.forms import EmailForm
> class EmailAdmin(admin.ModelAdmin):
>      form = EmailForm
> did not work Exception Value:
> 'DeclarativeFieldsMetaclass' object is not iterable
>
> Second attempt
> and now i 
> followedhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
> but could not get help
>
> class EmailAdmin(admin.ModelAdmin):
>     def my_view(self,request):
>         return admin_my_view(request,self)
>
>     def get_urls(self):
>         urls = super(SmsAdmin, self).get_urls()
>         my_urls = patterns('',(r'^my_view/
> $',self.admin_site.admin_view(self.my_view)))
>         return my_urls + urls
>
> def admin_my_view(request, model_admin):
>     opts = model_admin.model._meta
>     admin_site = model_admin.admin_site
>     has_perm = request.user.has_perm(opts.app_label \
>     + '.' + opts.get_change_permission())
>     context = {'admin_site': admin_site.name,
>     'title': "My Custom View",
>     'opts': opts,
>     'root_path': '/%s' % admin_site.root_path,
>     'app_label': opts.app_label,
>     'has_change_permission': has_perm}
>     template = 'admin/demo_app/admin_my_view.html'
>     return render_to_response(template,
> context,context_instance=RequestContext(request))
> admin.site.register(EmailForm,EmailAdmin)
>
> and when i run server and type on browserhttp://localhost:8000/admin
> and hit enter button
>
> Exception Value:
> 'DeclarativeFieldsMetaclass' object is not iterable
>
> and second time just after first time when i again enter then it show
> me the admin page but i can't see my EmailAdmin in admin intercae..
>
> Just help me or suggest me any link.
>
> Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: overriding saving fails in loop

2010-03-10 Thread Beres Botond
Or more specifically, why exactly do you want to reorder them all at
every Subject .save()? And what exactly do you use the values in
'order' field for?

On Mar 10, 11:46 pm, Beres Botond  wrote:
> Even if we ignore the infinite loop, selecting and updating every
> single instance of Subject at every save() of a Subject, is horribly
> wrong and inefficient on many levels.
>
> Exactly what kind of functionality/logic were you trying to implement?
>
> On Mar 10, 10:32 pm, Ali Rıza Keleş  wrote:
>
> > Hi all,
>
> > I want to override saving of one of my models.
> > After saving any record, I am trying to reorder them all.  
>
> > class Subject(models.Model):
> >     slug = models.SlugField(db_index=True, unique=True)
> >     name = models.CharField(max_length="120")
> >     order = models.CharField(blank = True, max_length="3")
>
> >     class Meta:
> >         ordering = ['order']
>
> >     def __unicode__(self):
> >         return u'%s' % (self.name)
>
> >     def __str__(self):
> >         return self.__unicode__()
>
> >     def save(self, *args, **kwargs):
> >         super(Subject, self).save(*args, **kwargs)
> >         self.makeOrder()
>
> >     def makeOrder(self):
> >         t = 10
> >         for i in Subject.objects.all().order_by('order'):
> >             i.order = t
> >             i.save()
> >             t += 10
>
> > But here, It fails in a loop and give "maximum recursion depth exceeded"
> > error.
>
> > How can I do?
>
> > Thanks..
>
> > --
> > Ali

-- 
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: overriding saving fails in loop

2010-03-10 Thread Beres Botond
Even if we ignore the infinite loop, selecting and updating every
single instance of Subject at every save() of a Subject, is horribly
wrong and inefficient on many levels.

Exactly what kind of functionality/logic were you trying to implement?

On Mar 10, 10:32 pm, Ali Rıza Keleş  wrote:
> Hi all,
>
> I want to override saving of one of my models.
> After saving any record, I am trying to reorder them all.  
>
> class Subject(models.Model):
>     slug = models.SlugField(db_index=True, unique=True)
>     name = models.CharField(max_length="120")
>     order = models.CharField(blank = True, max_length="3")
>
>     class Meta:
>         ordering = ['order']
>
>     def __unicode__(self):
>         return u'%s' % (self.name)
>
>     def __str__(self):
>         return self.__unicode__()
>
>     def save(self, *args, **kwargs):
>         super(Subject, self).save(*args, **kwargs)
>         self.makeOrder()
>
>     def makeOrder(self):
>         t = 10
>         for i in Subject.objects.all().order_by('order'):
>             i.order = t
>             i.save()
>             t += 10
>
> But here, It fails in a loop and give "maximum recursion depth exceeded"
> error.
>
> How can I do?
>
> Thanks..
>
> --
> Ali

-- 
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: if statement with url

2010-03-10 Thread HARRY POTTRER
maybe try request.path?

On Mar 10, 1:51 pm, Daxal  wrote:
> Hey,
>
> I wanted to use a if statement with a url like ...
>
> if you are on "/cm/add/"
> ..
> endif
> .
> option 1:
> I was wondering if anyone knows how to code that statement. if can
> compare string variables like {% ifequal somevariable url %} where
> "url" can be hard coded like "/cm/add" and somevariable would have to
> store the url which i think is too complex.
>
> option 2:
> some if statement that directly compares the url like {% if {url} == "/
> cm/add/" %}
>
> any thoughts and ideas guys?
>
> Thank you for all your replies. :)

-- 
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: templates?

2010-03-10 Thread Jirka Vejrazka
> DJANGO_SETTINGS_MODULE=C:/django/Django-1.1.1/djangotest/mysite/settings

Oops - I take it back (it's been a long day).

You need to supply Python path, i.e just "mysite.settings" if you
PYTHONPATH is already set to
PYTHONPATH=C:\django\Django-1.1.1\djangotest  and mysite is a
directory there.

  Sorry about that

   Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: templates?

2010-03-10 Thread Jirka Vejrazka
Hi Nadeesh,

  you need to use forward slashes, even on Windows (or
double-backslashes). So, changing to:

DJANGO_SETTINGS_MODULE=C:/django/Django-1.1.1/djangotest/mysite/settings

  might solve your problem, assuming everything else is OK.

  Cheers

Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: why is __exact filter really doing an inexact match?

2010-03-10 Thread Karen Tracey
Are you using MySQL? See the note about MySQL here:

http://docs.djangoproject.com/en/dev/ref/models/querysets/#exact

Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: why is __exact filter really doing an inexact match?

2010-03-10 Thread Shawn Milochik
What database are you using?

Shawn

-- 
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: need help in multi db

2010-03-10 Thread Jirka Vejrazka
Hi Silaja,

  first, I'm going to guess that no one will be able to solve your
problem. There are multiple reasons for it:

 - Multiple database support is in Django 1.2. You insist on using it
on Django 1.1, without mentioning why you can't upgrade (the upgrade
would make sense for any reader not knowing the context that only you
currently do know)
 - the code written by Eric F. is an interesting hack for older
versions of Django, but not too many people have probably used it, so
there would be little experience with that. However, there is a
problem:
 - * you have not specified what your problem was when you tried it *
So, even people willing to spend their time helping you could not do
it as they would not know how far you have gotten implementing it and
what actually stopped you from succeeding.
 - you mentioned "i.e some of rows in some "x" table in one database
and some of rows in "x" table in other database. i want to select
which database used to add/retrieve the rows dynamically". This is
quite complex and even the code from Eric's site will not help you
much. If you make it working, it will lay the foundations, but you'd
still be quite far from reaching your goal.

  I'm afraid that you need to give us more detail and the actual
context before you can expect better answer than "upgrade to Django
1.2".

  Cheers

Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



why is __exact filter really doing an inexact match?

2010-03-10 Thread Margie Roginski
When I do a filter like this

 Task.objects.filter(name__exact="test")

I seem to be getting an inexact match.  IE, I get tasks whose name is
"test" as well as tasks whose name is "Test".  Same thing if I do:

Task.objects.filter(name="test")

For example:

(Pdb) for t in Task.objects.filter(name__exact="test"): print t.name

Test
test
test


I don't have any special managers and I see this both in my own model
and doing a filter using the Auth model, ie:

User.objects.get(email="margie.rogin...@gmail.com").email

gives me:
u'margie.rogin...@gmail.com'

I thought this is supposed to be a case sensitive operation - am I
missing something here?  I'm running with the 1.1 final release.

Thanks,
Margie Roginski

-- 
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: ifequal issue

2010-03-10 Thread wolle
Hi Tom,

really cool idea, but it does not work...


-- Bitte Berufsgruppe wählen 
--
{% for item in berufe %}
{{item.name}}
{% endfor %}


does not select any option...

Any more hints?

On Mar 10, 5:13 pm, Tom Evans  wrote:
> On Wed, Mar 10, 2010 at 3:37 PM, Bill Freeman  wrote:
> > That would be my guess.  I presume that item.id is an int, so it's
> > likely that you're passing berufe_id as a string.  All the stuff that
> > comes from the GET or POST attributes or request, and any
> > arguments garnered by the url pattern are strings.  If you're not
> > converting it yourself, berufe_id will be a string, and:
>
> >  >>> 1 == '1'
> >  False
> >  >>>
>
> > Do you have a view function, or are you fitting this into a generic
> > view somehow?
>
> > Too bad that there doesn't seem to be a filter to invoke the int 
> > constructor,
> > or a string method that does it.  You could add a method to your model
> > that returns id as a string, then
>
> >   ...{% ifequal item.id_as_string berufe_id %}...
>
> {% ifequal item.id|stringformat:"s" berufe_id %}
>
> 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: Testing if a file has changed while saving the class

2010-03-10 Thread Beres Botond
Just a quick idea off the top of my head before going to bed :)

def save(self, *args, **kwargs):
super(MyModel, self).save(*args, **kwargs) # Call the "real"
save() method.
timestamp = os.path.getmtime(self.my_image_field.path)
if datetime.datetime.now() - timestamp < VERY_SMALL_DELTA:
process_image(self.my_image_field.path)


On Mar 9, 10:15 am, Xavier Ordoquy  wrote:
> Hi,
>
> I have a class with an image field.
> Every time the image is changed, I need to resize the image to several 
> formats.
> At the moment, I do that every time the class which contains the image is 
> saved.
> However, I'd like to improve that a bit and only resize whenever the image 
> has changed.
>
> Is there any way to do that easily with Django 1.1 ?
>
> Regards,
> Xavier.

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



templates?

2010-03-10 Thread Nadeesh Kumar
I've setup an environmental variable
DJANGO_SETTINGs_MODULE=C:\django\Django-1.1.1\djangotest\mysite\settings
and PYTHONPATH=C:\django\Django-1.1.1\djangotest
I also edited the registry key value for PYTHONPATH
I've got these errors.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\ammulu>python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from django import template
>>> t = template.Template('My name is {{ name }}.')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\Lib\site-packages\django\template\__init__.py", line
166, i
 __init__
if settings.TEMPLATE_DEBUG and origin is None:
  File "C:\Python25\Lib\site-packages\django\utils\functional.py", line 269,
in
__getattr__
self._setup()
  File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line 40, in
_se
up
self._wrapped = Settings(settings_module)
  File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line 75, in
__i
it__
raise ImportError, "Could not import settings '%s' (Is it on sys.path?
Does
it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings
'C:\django\Django-1.1.1\djangotest\mysit
\settings' (Is it on sys.path? Does it have syntax errors?): No module named
C:
django\Django-1.1.1\djangotest\mysite\settings

please help!
thanx in advance
-- 
Lalla
Have a Good time!!!

-- 
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: overriding saving fails in loop

2010-03-10 Thread Shawn Milochik
Every time you save(), you call makeOrder(). Every time you run makeOrder(), 
you call save(). You've introduced an infinite loop. Well, infinite until 
Python decides enough is enough.

One simple possibility is to add an optional argument with a default of True to 
the save() override that determines whether to makeOrder(). Just ensure that 
when makeOrder() calls save() that it sets that to False.

Shawn


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



overriding saving fails in loop

2010-03-10 Thread Ali Rıza Keleş
Hi all,

I want to override saving of one of my models.
After saving any record, I am trying to reorder them all.  

class Subject(models.Model):
slug = models.SlugField(db_index=True, unique=True)
name = models.CharField(max_length="120")
order = models.CharField(blank = True, max_length="3")

class Meta:
ordering = ['order']

def __unicode__(self):
return u'%s' % (self.name)

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

def save(self, *args, **kwargs):
super(Subject, self).save(*args, **kwargs)
self.makeOrder()

def makeOrder(self):
t = 10
for i in Subject.objects.all().order_by('order'):
i.order = t
i.save()
t += 10


But here, It fails in a loop and give "maximum recursion depth exceeded"
error.

How can I do? 

Thanks..

--
Ali


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



ModelAdmin

2010-03-10 Thread Praveen
Hi
I have one form in forms.py

class EmailForm(forms.Form):
recipient = forms.CharField(max_length=14, min_length=12,
widget=forms.TextInput(attrs=require))
message = forms.CharField(max_length=140, min_length=1,
widget=forms.Textarea(attrs={'cols': 30, 'rows': 5}))

and my site url is
admin.autodiscover()
urlpatterns = patterns('',  (r'^admin/(.*)',
include(admin.site.urls)),)

now i want it to be shown on admin interface

I tried so far
First attempt

from myapps.forms import EmailForm
class EmailAdmin(admin.ModelAdmin):
 form = EmailForm
did not work Exception Value:
'DeclarativeFieldsMetaclass' object is not iterable

Second attempt
and now i followed 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_urls
but could not get help

class EmailAdmin(admin.ModelAdmin):
def my_view(self,request):
return admin_my_view(request,self)

def get_urls(self):
urls = super(SmsAdmin, self).get_urls()
my_urls = patterns('',(r'^my_view/
$',self.admin_site.admin_view(self.my_view)))
return my_urls + urls

def admin_my_view(request, model_admin):
opts = model_admin.model._meta
admin_site = model_admin.admin_site
has_perm = request.user.has_perm(opts.app_label \
+ '.' + opts.get_change_permission())
context = {'admin_site': admin_site.name,
'title': "My Custom View",
'opts': opts,
'root_path': '/%s' % admin_site.root_path,
'app_label': opts.app_label,
'has_change_permission': has_perm}
template = 'admin/demo_app/admin_my_view.html'
return render_to_response(template,
context,context_instance=RequestContext(request))
admin.site.register(EmailForm,EmailAdmin)

and when i run server and type on browser http://localhost:8000/admin
and hit enter button

Exception Value:
'DeclarativeFieldsMetaclass' object is not iterable

and second time just after first time when i again enter then it show
me the admin page but i can't see my EmailAdmin in admin intercae..

Just help me or suggest me any link.

Thanks



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



unique_together - related Model field.

2010-03-10 Thread Daniel S
#models.py
class Item(models.Model):
parte = models.ForeignKey('Parte')
cantidad = models.PositiveIntegerField()

class Parte(models.Model):
num_parte = models.CharField(max_length=14, primary_key=True)
descripcion = models.CharField(max_length=40, blank=True)

class Item_Carrito(models.Model):
item = models.ForeignKey('Item')
carrito = models.ForeignKey('Carrito')
class Meta:
unique_together = ('carrito', 'item')

class Carrito(models.Model):
cliente = models.ForeignKey('Cliente', unique=True)

I have the restriction that the same part (Parte) cannot be related
more than once with a "Carrito" instance.

I think that could easily be solved using:

class Meta:
   unique_together=('carrito', 'item.parte')

In the Item_Carrito Model.

However, I can't use 'item.parte' as django gives me an error that I'm
referring to a field that doesnt' exist.

Is there a way I can use a field of another object in unique_together?

Thank you,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: ModelForm+datepicker

2010-03-10 Thread Shawn Milochik
The widget has nothing to do with the model. It needs to be specified in your 
forms.Form or forms.ModelForm.

Remember that the model is all about the database table and the form is all 
about the HTML form.

Shawn

-- 
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: ModelForm+datepicker

2010-03-10 Thread H . İbrahim Yılmaz
Hi,
I've already checked that and i got nothing :) I did in my model.py that:

from django.forms.extras.widgets import SelectDateWidget
date = forms.DateField(widget=SelectDateWidget())
But did not see the datepicker :S I got name error (forms) blabla? Is
there any complete reference for "how to integrate datepicker in to
template?". Or anybody can give me any example? How it works?
Regards.

2010/3/10 Shawn Milochik :
> Here you go:
>
> http://docs.djangoproject.com/en/1.1/ref/forms/widgets/
>
>
> (Try searching http://docs.djangoproject.com/ before Google. It's really a 
> great reference.)
>
> Shawn
>
> --
> 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.
>
>



-- 
http://www.arkeoloji.web.tr

-- 
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_mass_mail()

2010-03-10 Thread Jirka Vejrazka
> how much mails can i send with send_mass_mail()
> i have like 7000 users and i have send mail to all of them.

Hi,

  I have never used it myself, but a quick glance at the source code
does not show any reason why this would not work. However, keep two
things in mind:

  - the emails are first all constructed in memory, which could be a
bit of a problem if the email body is large
  - the SMTP server must be able to handle 7000 emails in one go

  Hope this helps a bit

Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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_mass_mail()

2010-03-10 Thread onoxo
how much mails can i send with send_mass_mail()
i have like 7000 users and i have send mail to all of them.

thanks,
vedran

-- 
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: need help in multi db

2010-03-10 Thread lakshmi silaja
Hi avinash thanks for ur reply.. i want that in Django1.1.1
as specified in this link
http://www.eflorenzano.com/blog/tag/multiple-databases/ i think  there is
one way to get multiple  db concept in django 1.1.1. but i cont able to get
the right way to do. if u know please reply. thank u.

On Thu, Mar 11, 2010 at 12:27 AM, Avinash Prasad wrote:

> Hi silaja,
> The best place to get a clear idea is to go to
> http://www.djangoproject.com and look for its documentation under multiple
> databases section.
> The support for multiple databases is there only in django's latest
> version.
> In settings.py file
> the DATABASES dictionary now has multiple keys where each key points to a
> particular database. For example,
> DATABASES = {'sqlite_db': { 'ENGINE': 'sqlite3', 'NAME' :' sqlite',
> 'HOSTNAME': , 'PORT':, }} here the key sqlite_db would be the database to
> which you would point to. Similarly you could also add other database with
> their appropriate names, and other configuartions pointed by an appropriate
> key.
> At view level fro saving the data,
> data = User.objects.using('sqlite_db').save() use the using() method to
> tell django where you want to save the entry.
> Similar rules apply for while retrieving data.
>
> Hope this helps.
> Do not forget to look into the API.
> Happy coding!!
>
> Avinash
>
>
> On Wed, Mar 10, 2010 at 11:34 PM, lakshmi silaja  > wrote:
>
>> Hi,
>> i'm silaja, in my django project i want to work with multiple
>> database. i'm new to django. if any one know about multiple databases
>> concept please reply me. even u have any links regarding this concept
>> please reply.
>> thank you.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-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.
>

-- 
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: need help in multi db

2010-03-10 Thread Avinash Prasad
Hi silaja,
The best place to get a clear idea is to go to
http://www.djangoproject.comand look for its documentation under
multiple databases section.
The support for multiple databases is there only in django's latest version.
In settings.py file
the DATABASES dictionary now has multiple keys where each key points to a
particular database. For example,
DATABASES = {'sqlite_db': { 'ENGINE': 'sqlite3', 'NAME' :' sqlite',
'HOSTNAME': , 'PORT':, }} here the key sqlite_db would be the database to
which you would point to. Similarly you could also add other database with
their appropriate names, and other configuartions pointed by an appropriate
key.
At view level fro saving the data,
data = User.objects.using('sqlite_db').save() use the using() method to tell
django where you want to save the entry.
Similar rules apply for while retrieving data.

Hope this helps.
Do not forget to look into the API.
Happy coding!!

Avinash


On Wed, Mar 10, 2010 at 11:34 PM, lakshmi silaja
wrote:

> Hi,
> i'm silaja, in my django project i want to work with multiple
> database. i'm new to django. if any one know about multiple databases
> concept please reply me. even u have any links regarding this concept
> please reply.
> thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.



if statement with url

2010-03-10 Thread Daxal
Hey,

I wanted to use a if statement with a url like ...

if you are on "/cm/add/"
..
endif
.
option 1:
I was wondering if anyone knows how to code that statement. if can
compare string variables like {% ifequal somevariable url %} where
"url" can be hard coded like "/cm/add" and somevariable would have to
store the url which i think is too complex.

option 2:
some if statement that directly compares the url like {% if {url} == "/
cm/add/" %}

any thoughts and ideas guys?

Thank you for all your replies. :)

-- 
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: need help in multi db

2010-03-10 Thread lakshmi silaja
hi swawn, thanks for ur reply. i tried in django2.1. but i want that in
Django 1.1.1. i tried as shown in this url.
http://www.eflorenzano.com/blog/tag/multiple-databases/
but i dont want to do like that. i want to seperate tables. i.e some of rows
in some "x" table in one database and some of rows in "x" table in other
database. i want to select which database used to add/retrieve the rows
dynamically. I think u got mu requirement. if u know how to do please reply
me. if u want any info please ask me. thank u.

On Wed, Mar 10, 2010 at 11:50 PM, Shawn Milochik  wrote:

> Go to google.com.
>
> Search for this:  multi-database support in django
>
> You will find that the first result is from a page on
> code.djangoproject.com which directly discusses this and links to the
> usage documentation. Note that this feature is currently in beta, and will
> be officially released as part of Django 1.2.
>
> In the future, when you have a Django question:
>
> Step 1: Go to http://docs.djangoproject.com/ and search.
> Step 2: Go to google.com and search (if step 1 doesn't help you).
> Step 3 (or later): Write to this group explaining what you tried and ask
> your question.
>
> Sincerely,
> Shawn
>
> --
> 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.



entering text+images into a textfield

2010-03-10 Thread HARRY POTTRER
I have a project where I'm taking a bunch of articles originally
written for a on a tripod page, and putting them into a database so
they can be served up by django.

Right now I have it all set up and working, but theres one problem. A
lot of these articles are very image heave. Each one has an average of
about 10 images.

I'm thinking of creating an app which acts, in part, as a modified
text widget in the admin. There will be a text box just like how there
is now, plus there will also be above it, another widget where you can
drag and drop images. When you save the model instance, it will save
those images into a directory named according to the slug of the
instance, or by the primary key, or maybe even the natural key.

Each image will be given a number based on the order of it being
uploaded. In the text box, where you want the images to be placed, you
enter something like  and the {1} will be replaced with
the url for that image.

Before I get started on this, does something similar to this exist? I
don't want to reinvent the wheel or anything...

-- 
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: tutorial --> deploy snag

2010-03-10 Thread John Griessen

John Griessen wrote:


Next, I'm looking for why in my settings.py

TEMPLATE_DIRS = (
"/home/john/djangotemplates"
)

is not being used.


I found the trouble and fixed already --

That above wasn't a good descr. of the symptom:

/home/john/djangotemplates  is not on the python path, but is inthe settings.py 
file as above.

Django tried loading these templates, in this order:

* Using loader django.template.loaders.filesystem.load_template_source:
  o /home/john/djangotemplates/polls/poll_list.html (File does not 
exist)


where I can
ls -l

-rw-rw-r-- 1 john john 191 2010-03-07 18:55 
/home/john/djangotemplates/polls/poll_list.html

why is the loader stopped?

chmod o+x djangotemplates
j...@toolbench:~$ chmod o+x djangotemplates/polls/

fixed that.

John

--
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: need help in multi db

2010-03-10 Thread Shawn Milochik
Go to google.com.

Search for this:  multi-database support in django

You will find that the first result is from a page on code.djangoproject.com 
which directly discusses this and links to the usage documentation. Note that 
this feature is currently in beta, and will be officially released as part of 
Django 1.2.

In the future, when you have a Django question:

Step 1: Go to http://docs.djangoproject.com/ and search.
Step 2: Go to google.com and search (if step 1 doesn't help you).
Step 3 (or later): Write to this group explaining what you tried and ask your 
question.

Sincerely,
Shawn

-- 
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: tutorial --> deploy snag

2010-03-10 Thread Daniel Roseman
On Mar 10, 6:11 pm, John Griessen  wrote:
> Joakim Hove wrote:
> >> What have I left out of this Virtualhost configuration?
> >    Alias /media/ "/usr/local/django/django/contrib/admin/media/"
> > HTH - Joakim
>
> Thanks Joakim,
>
> I found the corresponding place on my debian system and got admin templates.
>
> Next, I'm looking for why in my settings.py
>
> TEMPLATE_DIRS = (
> "/home/john/djangotemplates"
> )
>
> is not being used.
>
> Clues?
>
> John

You're confusing templates with assets. Templates are the HTML files
which are parsed by Django and determine what markup goes on a page.
Assets are the CSS and image files which go alongside. Django doesn't
serve assets, so you'll need to configure Apache to serve them
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: dotted path name requirements for WSGI os.environ['DJANGO_SETTINGS_MODULE'] =

2010-03-10 Thread John Griessen

Daniel Roseman wrote:

On Mar 10, 3:44 pm, John Griessen  wrote:


Is this line OK?

os.environ['DJANGO_SETTINGS_MODULE'] = 'industromatic.com.settings'



The DJANGO_SETTINGS_MODULE setting is a Python module, so it must be a
valid Python path. "industromatic.com" is already not a valid Python
name, so there's no point calling a folder within a Python project by
that name. 


That's what I thought.  Thanks for confirming and I'll be using folders like
industromatic_com

John

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



need help in multi db

2010-03-10 Thread lakshmi silaja
Hi,
i'm silaja, in my django project i want to work with multiple
database. i'm new to django. if any one know about multiple databases
concept please reply me. even u have any links regarding this concept
please reply.
thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: tutorial --> deploy snag

2010-03-10 Thread John Griessen

Joakim Hove wrote:

What have I left out of this Virtualhost configuration?




   Alias /media/ "/usr/local/django/django/contrib/admin/media/"



HTH - Joakim


Thanks Joakim,

I found the corresponding place on my debian system and got admin templates.

Next, I'm looking for why in my settings.py

TEMPLATE_DIRS = (
"/home/john/djangotemplates"
)

is not being used.

Clues?

John

--
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: dotted path name requirements for WSGI os.environ['DJANGO_SETTINGS_MODULE'] =

2010-03-10 Thread Daniel Roseman
On Mar 10, 3:44 pm, John Griessen  wrote:
> I am serving up sites named after their domains with .com in the name
> but when I saw the os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
> specified in tutorials it seemed like putting a .com might be interpreted 
> wrong.
>
> Can the WSGI file os.environ['DJANGO_SETTINGS_MODULE'] =
> deal with a directory name like industromatic.com?
>
> Is this line OK?
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'industromatic.com.settings'
>
> Thanks,
>
> John

The DJANGO_SETTINGS_MODULE setting is a Python module, so it must be a
valid Python path. "industromatic.com" is already not a valid Python
name, so there's no point calling a folder within a Python project by
that name. The *containing* folder can be called that, but in that
case you'd need to be adding 'industromatic.com' to the Pythonpath and
just having DJANGO_SETTINGS_MODULE to 'settings'.
--
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: ModelForm+datepicker

2010-03-10 Thread Shawn Milochik
Here you go:

http://docs.djangoproject.com/en/1.1/ref/forms/widgets/


(Try searching http://docs.djangoproject.com/ before Google. It's really a 
great reference.)

Shawn

-- 
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: django+modelform+Foreignkey

2010-03-10 Thread H . İbrahim Yılmaz
Thanks! "It Works!" ;)
2010/3/7 Kev Dwyer :
> On Sat, 06 Mar 2010 23:39:59 +0200, Arkeoloji.web.tr wrote:
>
>> Hi all,
>> I have some ModelForms.. This ModelForms based some ForeignKey included
>> models. When i want to create a ModelForm I got these ForeignKey fields
>> something like (in a dropdown menu) "BlaBla object". But i want to get
>> in that dropdown menus something like "Linus Torvalds". I mean how can I
>> show in that fields that Models name area or adress area?
>> I made my ModelForm like that :
>>
>> class Author(models.Model):
>>     name = models.ForeignKey(User)
>>     status = models.CharField(max_length=30)
>>
>>
>> class AuthorForm(ModelForm):
>>         class Meta:
>>         model = Author
>>         exclude = ("status",)
>>
>> --
>> http://www.arkeoloji.web.tr
>
> Hello,
>
> Try giving your models a __unicode__ method, so that you can
> manage how they are displayed.
>
> For example:
>
> class Author(models.Model):
>    name = models.ForeignKey(User)
>    status = models.CharField(max_length=30)
>
>    def __unicode__(self):
>        return self.name
>
> Cheers,
>
> Kev
>
> --
> 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.
>
>



-- 
http://www.arkeoloji.web.tr

-- 
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+datepicker

2010-03-10 Thread H . İbrahim Yılmaz
Hi I have some ModelForm. I want to use in my templates (or views not
sure cause i am a newbie) date selector. I search about that in google
but there is not very clear information. Some of thems were for old
old versions of dango.
Regards...

-- 
http://www.arkeoloji.web.tr

-- 
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: tutorial --> deploy snag

2010-03-10 Thread Joakim Hove

> What have I left out of this Virtualhost configuration?


Warning: This is a the very limit of my understanding of Django; but I
have the following
section in my apache configuration file; I see you have already
aliased media to point somewhere
else.

   Alias /media/ "/usr/local/django/django/contrib/admin/media/"
   
  Order allow,deny
  Options Indexes
  Allow from all
  IndexOptions FancyIndexing
   

HTH - Joakim

-- 
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: making query using filter()

2010-03-10 Thread Nick
Sounds like what you want is something like:

MyCategories = Category.objects.exclude(name!='mycateogry')

only problem is, django doesn't support the != operator so you're
going to have to go with a query object:

add this to your view

from django.db.models import Q (importing the Q object
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects,
here's another good article on Q objects 
http://www.djangozen.com/blog/the-power-of-q)

mycategory=Category.objects.exclude(~Q(name='mycategoy') (the ~Q is
equivalent to "this query DOES NOT EQUAL)



I don't have a model like this set up anywhere so I don't know if this
will properly filter those results with both 'mycategory' and other
categories as well.

On Mar 10, 6:24 am, rebus_  wrote:
> On 10 March 2010 12:06, jimgardener  wrote:
>
>
>
> > Hi
> > I need to make a query as follows
> > Select all entries where categories=mycategory
>
> > In the db there are entries and categories as follows
> > Category.objects.all() -->[ , > hiscategory>,]
>
> > MyEntry.objects.all() --> [  , > [u'mycategory',u'hiscategory' ]>, ]
>
> > I tried like this
> > mycategory=Category.objects.get(name='mycategory')
> > MyEntry.objects.filter(categories=mycategory)
>
> > But this returns entries where the categories field contains
> > 'mycategory' and 'hiscategory' also.
> > How do I mention to retrieve only 'mycategory'.
>
> > I went through the Queryset docs ..but couldn't figure it out...
> > Any help would be appreciated
> > thanks
> > jim
>
> > p.s:
>
> > My models are
> > class MyEntry(models.Model):
> >    categories=models.ManyToManyField(Category)
>
> > class Category(models.Model):
> >    name=models.CharField(unique=True,max_length=50)
>
> > --
> > 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.
>
> [  , 
>
> Well that's what it is supposed to do, both Entry objects have
> relation to "mycategory".

-- 
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: django-test-coverage gcc error

2010-03-10 Thread Karen Tracey
On Wed, Mar 10, 2010 at 11:13 AM, filias  wrote:

> I am trying to use a test coverage tool for django.
>
> I tried http://pypi.python.org/pypi/django-test-coverage/0.1. First
> with easy_install and after with setup.py install and I get the
> following error stack:
>
> Searching for django-test-coverage
> Best match: django-test-coverage 0.1
> Processing django_test_coverage-0.1-py2.6.egg
> django-test-coverage 0.1 is already the active version in easy-
> install.pth
>
> Using /usr/local/lib/python2.6/dist-packages/django_test_coverage-0.1-
> py2.6.egg
> Processing dependencies for django-test-coverage
> Searching for coverage
> Reading http://pypi.python.org/simple/coverage/
> Reading http://nedbatchelder.com/code/modules/coverage.html
> Reading http://nedbatchelder.com/code/coverage
> Best match: coverage 3.3.1
> Downloading
> http://pypi.python.org/packages/source/c/coverage/coverage-3.3.1.tar.gz#md5=6f5a25ce06baad03ab293990f3a98bb7
> Processing coverage-3.3.1.tar.gz
> Running coverage-3.3.1/setup.py -q bdist_egg --dist-dir /tmp/
> easy_install-nzgKke/coverage-3.3.1/egg-dist-tmp-JgaYFe
> no previously-included directories found matching 'test'
> coverage/tracer.c:3:20: error: Python.h: No such file or directory
>
[snip remainder]

You don't have installed whatever package you need on your system to build
Python C extensions. What type of system is this?

Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: ifequal issue

2010-03-10 Thread Bill Freeman
On Wed, Mar 10, 2010 at 11:13 AM, Tom Evans  wrote:
> {% ifequal item.id|stringformat:"s" berufe_id %}


Cool.  I spend my filter investigation time looking for one that would
convert berufe_id
to an int (no joy).

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



django-test-coverage gcc error

2010-03-10 Thread filias
I am trying to use a test coverage tool for django.

I tried http://pypi.python.org/pypi/django-test-coverage/0.1. First
with easy_install and after with setup.py install and I get the
following error stack:

Searching for django-test-coverage
Best match: django-test-coverage 0.1
Processing django_test_coverage-0.1-py2.6.egg
django-test-coverage 0.1 is already the active version in easy-
install.pth

Using /usr/local/lib/python2.6/dist-packages/django_test_coverage-0.1-
py2.6.egg
Processing dependencies for django-test-coverage
Searching for coverage
Reading http://pypi.python.org/simple/coverage/
Reading http://nedbatchelder.com/code/modules/coverage.html
Reading http://nedbatchelder.com/code/coverage
Best match: coverage 3.3.1
Downloading 
http://pypi.python.org/packages/source/c/coverage/coverage-3.3.1.tar.gz#md5=6f5a25ce06baad03ab293990f3a98bb7
Processing coverage-3.3.1.tar.gz
Running coverage-3.3.1/setup.py -q bdist_egg --dist-dir /tmp/
easy_install-nzgKke/coverage-3.3.1/egg-dist-tmp-JgaYFe
no previously-included directories found matching 'test'
coverage/tracer.c:3:20: error: Python.h: No such file or directory
coverage/tracer.c:4:71: error: compile.h: No such file or directory
coverage/tracer.c:5:43: error: eval.h: No such file or directory
coverage/tracer.c:6:26: error: structmember.h: No such file or
directory
coverage/tracer.c:7:25: error: frameobject.h: No such file or
directory
coverage/tracer.c:49: error: expected specifier-qualifier-list before
‘PyObject’
coverage/tracer.c:56: error: expected specifier-qualifier-list before
‘PyObject_HEAD’
coverage/tracer.c:115: error: expected declaration specifiers or ‘...’
before ‘PyObject’
coverage/tracer.c:115: error: expected declaration specifiers or ‘...’
before ‘PyObject’
coverage/tracer.c: In function ‘Tracer_init’:
coverage/tracer.c:129: error: ‘Tracer’ has no member named
‘should_trace’
coverage/tracer.c:129: error: ‘NULL’ undeclared (first use in this
function)
coverage/tracer.c:129: error: (Each undeclared identifier is reported
only once
coverage/tracer.c:129: error: for each function it appears in.)
coverage/tracer.c:130: error: ‘Tracer’ has no member named ‘data’
coverage/tracer.c:131: error: ‘Tracer’ has no member named
‘should_trace_cache’
coverage/tracer.c:132: error: ‘Tracer’ has no member named ‘arcs’
coverage/tracer.c:134: error: ‘Tracer’ has no member named ‘started’
coverage/tracer.c:135: error: ‘Tracer’ has no member named
‘tracing_arcs’
coverage/tracer.c:137: error: ‘Tracer’ has no member named ‘depth’
coverage/tracer.c:138: error: ‘Tracer’ has no member named
‘data_stack’
coverage/tracer.c:138: warning: implicit declaration of function
‘PyMem_Malloc’
coverage/tracer.c:139: error: ‘Tracer’ has no member named
‘data_stack’
coverage/tracer.c:141: warning: implicit declaration of function
‘PyErr_NoMemory’
coverage/tracer.c:144: error: ‘Tracer’ has no member named
‘data_stack_alloc’
coverage/tracer.c:146: error: ‘Tracer’ has no member named
‘cur_file_data’
coverage/tracer.c:147: error: ‘Tracer’ has no member named ‘last_line’
coverage/tracer.c:149: error: ‘Tracer’ has no member named
‘last_exc_back’
coverage/tracer.c: In function ‘Tracer_dealloc’:
coverage/tracer.c:157: error: ‘Tracer’ has no member named ‘started’
coverage/tracer.c:158: warning: implicit declaration of function
‘PyEval_SetTrace’
coverage/tracer.c:158: error: ‘NULL’ undeclared (first use in this
function)
coverage/tracer.c:161: warning: implicit declaration of function
‘Py_XDECREF’
coverage/tracer.c:161: error: ‘Tracer’ has no member named
‘should_trace’
coverage/tracer.c:162: error: ‘Tracer’ has no member named ‘data’
coverage/tracer.c:163: error: ‘Tracer’ has no member named
‘should_trace_cache’
coverage/tracer.c:165: warning: implicit declaration of function
‘PyMem_Free’
coverage/tracer.c:165: error: ‘Tracer’ has no member named
‘data_stack’
coverage/tracer.c:167: error: ‘PyObject’ undeclared (first use in this
function)
coverage/tracer.c:167: error: expected expression before ‘)’ token
coverage/tracer.c:167: error: expected ‘)’ before ‘self’
coverage/tracer.c: In function ‘Tracer_record_pair’:
coverage/tracer.c:224: error: ‘PyObject’ undeclared (first use in this
function)
coverage/tracer.c:224: error: ‘t’ undeclared (first use in this
function)
coverage/tracer.c:224: warning: implicit declaration of function
‘PyTuple_New’
coverage/tracer.c:225: error: ‘NULL’ undeclared (first use in this
function)
coverage/tracer.c:226: warning: implicit declaration of function
‘PyTuple_SET_ITEM’
coverage/tracer.c:226: warning: implicit declaration of function
‘PyInt_FromLong’
coverage/tracer.c:228: warning: implicit declaration of function
‘PyDict_SetItem’
coverage/tracer.c:228: error: ‘Tracer’ has no member named
‘cur_file_data’
coverage/tracer.c:228: error: ‘Py_None’ undeclared (first use in this
function)
coverage/tracer.c:232: warning: implicit declaration of function
‘Py_DECREF’
coverage/tracer.c: At top level:
coverage/tracer.c:245: error: expected declaration specifiers or 

Re: ifequal issue

2010-03-10 Thread Tom Evans
On Wed, Mar 10, 2010 at 3:37 PM, Bill Freeman  wrote:
> That would be my guess.  I presume that item.id is an int, so it's
> likely that you're passing berufe_id as a string.  All the stuff that
> comes from the GET or POST attributes or request, and any
> arguments garnered by the url pattern are strings.  If you're not
> converting it yourself, berufe_id will be a string, and:
>
>  >>> 1 == '1'
>  False
>  >>>
>
> Do you have a view function, or are you fitting this into a generic
> view somehow?
>
> Too bad that there doesn't seem to be a filter to invoke the int constructor,
> or a string method that does it.  You could add a method to your model
> that returns id as a string, then
>
>   ...{% ifequal item.id_as_string berufe_id %}...
>

{% ifequal item.id|stringformat:"s" berufe_id %}

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: How can I manually use RelatedFieldWidgetWrapper around a custom widget?

2010-03-10 Thread justind
Hello,

I have this working now, but it seems so convoluted I know it must be
backwards or just plain dumb. I hope someone comes along and shows me
how easy this is.

First, I add the admin_site to the form field of my ModelAdmin object

class ResourceAdmin(admin.ModelAdmin):
form = EasyResourceAdminForm
def __init__(self, model, admin_site):
self.form.admin_site = admin_site
... # etc

Then in my ModelForm I manually create the relation and wrap the
widget. Like so...

class EasyResourceAdminForm(forms.ModelForm):
files =
forms.ModelMultipleChoiceField(queryset=File.objects.all(),
widget=MyWidget, required=False)

def __init__(self, *args, **kwargs):
super(EasyResourceAdminForm, self).__init__(*args, **kwargs)
# RelatedFieldWidgetWrapper wants a widget to wrap, a
relationship, and an admin site.
# The widget is easy. I build the relationship manually and
use the admin_site I added when the
# ModelAdmin was created.
rel = ManyToOneRel(self.instance.files.model, 'id')
self.fields['files'].widget =
admin.widgets.RelatedFieldWidgetWrapper(self.fields['files'].widget,
rel, self.admin_site)
self.fields['files'].queryset =
File.objects.filter(resource=self.instance.pk)
self.fields['files'].empty_label = None



On Mar 9, 4:25 pm, justind  wrote:
> Hello,
>
> I've created a custom widget to replace the many to many widget found
> in the admin. Its working well, but I lose the "add" button when I use
> it. I see that the functionality is added by wrapping the widget in
> the RelatedFieldWidgetWrapper, but I can't figure out how to implement
> it. Essentially, my problem is the same as the user Julien who wrote
> to this group in 2007 under the subject "Popup 'add another' and
> custom widget in newforms-admin". (Actually I'm having the secondary
> problem he lists too, where form is still spitting back Validation
> errors even though the model specifies that this field is blank=True
> null=True)
>
> I noticed this solution 
> here:http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/,
> but it seems like using the built in RelatedFieldWidgetWrapper would
> be the way to go to avoid any unexpected problems.
>
> My Form code looks like this:
>
> class EasyResourceAdminForm(forms.ModelForm):
>     files =
> forms.ModelMultipleChoiceField(queryset=File.objects.none(),
> widget=MySelect)
>
>     def __init__(self, *args, **kwargs):
>         super(EasyResourceAdminForm, self).__init__(*args, **kwargs)
>         self.fields['files'].queryset =
> File.objects.filter(resource=self.instance.pk)
>
>     class Meta:
>         model = Resource
>
> My AdminForm starts like this...
>
> class ResourceAdmin(admin.ModelAdmin):
>     form = EasyResourceAdminForm
>
> MySelect is a subclass of SelectMultiple and implements custom render
> and render_options fields.
>
> I tried watching the execution from PDB in a few places, but I get
> lost quickly.
>
> Any ideas?
>
> Thanks,
> Justin

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



dotted path name requirements for WSGI os.environ['DJANGO_SETTINGS_MODULE'] =

2010-03-10 Thread John Griessen

I am serving up sites named after their domains with .com in the name
but when I saw the os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
specified in tutorials it seemed like putting a .com might be interpreted wrong.

Can the WSGI file os.environ['DJANGO_SETTINGS_MODULE'] =
deal with a directory name like industromatic.com?

Is this line OK?

os.environ['DJANGO_SETTINGS_MODULE'] = 'industromatic.com.settings'

Thanks,

John

--
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: tutorial --> deploy snag

2010-03-10 Thread John Griessen

Joakim Hove wrote:

Hello,

I __think__ you must add the path industtromatic_com in your wsgi
settings file,
i.e. something like:

import sys
sys.path.append( "/home/john/WEBprojects/industromatic_com" )


Yes, adding the dir above project and project dir to the sys.path let
apache2 function to serve the tutorial code.

It is without any backgrounds or formatting though.
I guess I need to link to or copy some static files used in the tutorial:

/var/log/apache2/error.log messages:
File does not exist: /home/john/WEBprojects/industromatic_com/media/js
File does not exist: /home/john/WEBprojects/industromatic_com/media/css

I'll look at the docs for templates and maybe run the devel
server and look at the page source it generates for clues about admin page 
templates.

What have I left out of this Virtualhost configuration?


ServerAdmin webmas...@industromatic.com
ServerName industromatic.com
ServerAlias www.industromatic.com
WSGIScriptAlias / 
/home/john/WEBprojects/industromatic_com/industromatic_com.wsgi
DocumentRoot /var/www/industromatic.com
Alias /media/ /home/john/WEBprojects/industromatic_com/media/


Options FollowSymLinks  Indexes MultiViews


Order allow,deny
Allow from all


Order allow,deny
Allow from all




Thanks,

John

--
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: ifequal issue

2010-03-10 Thread Bill Freeman
That would be my guess.  I presume that item.id is an int, so it's
likely that you're passing berufe_id as a string.  All the stuff that
comes from the GET or POST attributes or request, and any
arguments garnered by the url pattern are strings.  If you're not
converting it yourself, berufe_id will be a string, and:

  >>> 1 == '1'
  False
  >>>

Do you have a view function, or are you fitting this into a generic
view somehow?

Too bad that there doesn't seem to be a filter to invoke the int constructor,
or a string method that does it.  You could add a method to your model
that returns id as a string, then

   ...{% ifequal item.id_as_string berufe_id %}...


On Wed, Mar 10, 2010 at 10:23 AM, wolle  wrote:
> Already tried this several times. Here is a result of your code
>
> item.id = 1 with berufe_id = 1
> item.id = 2 with berufe_id = 1
>
> Not sure if this a type (int vs. string) error?
>
> On Mar 10, 4:18 pm, Bill Freeman  wrote:
>> Try adding code to render the values that you are trying to compare,
>> so that you can see in what way they are not equal.  They it will
>> probably become obvious in what way the conversion through the
>> GET or POST data and view isn't quite what you want.  E.g.; before
>> the select:
>>
>> berufe_id: {{ berufe_id }}
>> {% for item in berufe %}{{ item.id }}{% endfor %}
>>
>> On Wed, Mar 10, 2010 at 8:01 AM, wolle  wrote:
>> > Hi everybody,
>>
>> > I have a question on the ifequal template tag.
>>
>> > I have an HTML select where people can filter the database entries. On
>> > change of the selection I reload the page (new URL) and filter the
>> > results. I append the selected value from the option to the request
>> > (as berufe_id) and want to pre-select the chosen option with the
>> > following code:
>>
>> > 
>> >                                -- Please select 
>> > --
>> >                                {% for item in berufe %}
>> >                                        > > ifequal item.id berufe_id %}
>> > selected{% endifequal %}>{{item.name}}
>> >                                {% endfor %}
>> >                        
>>
>> > Somehow the equal check does not work. item.id is the id of the Object
>> > iterator and berufe_id the selected value from the last selection...
>> > {% ifequal item.id "2" %}selected{% endifequal %} seems to work
>> > though...
>>
>> > Who can help me with this?
>>
>> > Thanks
>> > Wolle
>>
>> > --
>> > 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.
>
>

-- 
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: ifequal issue

2010-03-10 Thread wolle
Already tried this several times. Here is a result of your code

item.id = 1 with berufe_id = 1
item.id = 2 with berufe_id = 1

Not sure if this a type (int vs. string) error?

On Mar 10, 4:18 pm, Bill Freeman  wrote:
> Try adding code to render the values that you are trying to compare,
> so that you can see in what way they are not equal.  They it will
> probably become obvious in what way the conversion through the
> GET or POST data and view isn't quite what you want.  E.g.; before
> the select:
>
> berufe_id: {{ berufe_id }}
> {% for item in berufe %}{{ item.id }}{% endfor %}
>
> On Wed, Mar 10, 2010 at 8:01 AM, wolle  wrote:
> > Hi everybody,
>
> > I have a question on the ifequal template tag.
>
> > I have an HTML select where people can filter the database entries. On
> > change of the selection I reload the page (new URL) and filter the
> > results. I append the selected value from the option to the request
> > (as berufe_id) and want to pre-select the chosen option with the
> > following code:
>
> > 
> >                                -- Please select 
> > --
> >                                {% for item in berufe %}
> >                                         > ifequal item.id berufe_id %}
> > selected{% endifequal %}>{{item.name}}
> >                                {% endfor %}
> >                        
>
> > Somehow the equal check does not work. item.id is the id of the Object
> > iterator and berufe_id the selected value from the last selection...
> > {% ifequal item.id "2" %}selected{% endifequal %} seems to work
> > though...
>
> > Who can help me with this?
>
> > Thanks
> > Wolle
>
> > --
> > 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: ifequal issue

2010-03-10 Thread Bill Freeman
Try adding code to render the values that you are trying to compare,
so that you can see in what way they are not equal.  They it will
probably become obvious in what way the conversion through the
GET or POST data and view isn't quite what you want.  E.g.; before
the select:

berufe_id: {{ berufe_id }}
{% for item in berufe %}{{ item.id }}{% endfor %}

On Wed, Mar 10, 2010 at 8:01 AM, wolle  wrote:
> Hi everybody,
>
> I have a question on the ifequal template tag.
>
> I have an HTML select where people can filter the database entries. On
> change of the selection I reload the page (new URL) and filter the
> results. I append the selected value from the option to the request
> (as berufe_id) and want to pre-select the chosen option with the
> following code:
>
> 
>                                -- Please select --
>                                {% for item in berufe %}
>                                         item.id berufe_id %}
> selected{% endifequal %}>{{item.name}}
>                                {% endfor %}
>                        
>
> Somehow the equal check does not work. item.id is the id of the Object
> iterator and berufe_id the selected value from the last selection...
> {% ifequal item.id "2" %}selected{% endifequal %} seems to work
> though...
>
> Who can help me with this?
>
> Thanks
> Wolle
>
> --
> 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: Django editor for Debian

2010-03-10 Thread Shawn Milochik
I did a little looking into this, and it seems like SPE (Stani's Python Editor) 
is the best pick for Ubuntu. It has been around for years and has remained 
popular. It's also specifically designed (obviously) for Python.

Shawn

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



ifequal issue

2010-03-10 Thread wolle
Hi everybody,

I have a question on the ifequal template tag.

I have an HTML select where people can filter the database entries. On
change of the selection I reload the page (new URL) and filter the
results. I append the selected value from the option to the request
(as berufe_id) and want to pre-select the chosen option with the
following code:


-- Please select --
{% for item in berufe %}
{{item.name}}
{% endfor %}


Somehow the equal check does not work. item.id is the id of the Object
iterator and berufe_id the selected value from the last selection...
{% ifequal item.id "2" %}selected{% endifequal %} seems to work
though...

Who can help me with this?

Thanks
Wolle

-- 
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: Django editor for Debian

2010-03-10 Thread Abdel Bolaños Martí­nez

Can i suggest you?

Eclipse + Aptana + Pydev

In the company i work for, our developer team has acquired very good results



Paul Menzel wrote:

Dear Nicolae,


Am Dienstag, den 15.12.2009, 23:58 -0800 schrieb NMarcu:
  

   Can you tell me a good Django editor for Debian? Something more
pretty then default text editor. Something to can edit templates also.



what did you end up with?


Thanks,

Paul
  



--- 
Este mensaje fue revisado por Kaspersky Mail Gateway en el servidor imx2.etecsa.cu

Visite nuestros sitios: , 
  
--- 
Este mensaje fue revisado por Kaspersky Mail Gateway en el servidor 
imx2.etecsa.cu
Visite nuestros sitios: , 
<>-- 
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: Django editor for Debian

2010-03-10 Thread Paul Menzel
Dear Nicolae,


Am Dienstag, den 15.12.2009, 23:58 -0800 schrieb NMarcu:
>Can you tell me a good Django editor for Debian? Something more
> pretty then default text editor. Something to can edit templates also.

what did you end up with?


Thanks,

Paul


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Re: Not able to view the admin page through the browser

2010-03-10 Thread Newbie
Found the problem missed to specify the admin entry in INSTALLED_APPS
variable in the settings.py file

Thanks for the help.



On Mar 9, 8:01 pm, Shawn Milochik  wrote:
> Something is broken in your code. If you set DEBUG = True, you'll find
> out what. But since it's False, it is hiding that information for
> security reasons. It tries to display an error page to the browser,
> and it expects a template to exist called 500.html to show to your
> poor, out-of-luck user.
>
> If you set up the ADMINS tuple in settings.py properly it should also
> e-mail you the detailed error information.
>
> Shawn

-- 
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: Not able to view the admin page through the browser

2010-03-10 Thread Newbie
Set the Debug=True and got the error as
TemplateDoesNotExist at /admin/


What is the reason?



On Mar 9, 8:01 pm, Shawn Milochik  wrote:
> Something is broken in your code. If you set DEBUG = True, you'll find
> out what. But since it's False, it is hiding that information for
> security reasons. It tries to display an error page to the browser,
> and it expects a template to exist called 500.html to show to your
> poor, out-of-luck user.
>
> If you set up the ADMINS tuple in settings.py properly it should also
> e-mail you the detailed error information.
>
> Shawn

-- 
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: circular import in two models.py

2010-03-10 Thread rebus_
On 10 March 2010 11:31, Viktor  wrote:
> Hi,
>
> I have two django applications, an issue tracker where an Issue is
> related to a Partner
> and a Partner model where partners can be grouped, etc
> I would like to add an issue to every group to provide an easy
> messaging for groups, so I don't have to write the message sending
> logic again
>
> could someone give me some ideas how can I cross-connect the two apps,
> but save them as seemingly separate?
> by seemingly separate I mean that I can change the Partner models by
> simply writing
>
>    from app.models import Partner1 as Parner
>
> instead of
>
>    from app.models import Partner2 as Parner
>
> in the messaging app
>
> thanks,
> Viktor
>
> --
> 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.
>
>

Instead of giving a class try giving a string in format 'myapp.MyModelName'.

class Foo(models.Model):
  bar = models.ForeignKey('myapp.MyModelName')

-- 
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: making query using filter()

2010-03-10 Thread rebus_
On 10 March 2010 12:06, jimgardener  wrote:
> Hi
> I need to make a query as follows
> Select all entries where categories=mycategory
>
> In the db there are entries and categories as follows
> Category.objects.all() -->[ , hiscategory>,]
>
> MyEntry.objects.all() --> [  , [u'mycategory',u'hiscategory' ]>, ]
>
>
> I tried like this
> mycategory=Category.objects.get(name='mycategory')
> MyEntry.objects.filter(categories=mycategory)
>
> But this returns entries where the categories field contains
> 'mycategory' and 'hiscategory' also.
> How do I mention to retrieve only 'mycategory'.
>
> I went through the Queryset docs ..but couldn't figure it out...
> Any help would be appreciated
> thanks
> jim
>
>
> p.s:
>
>
> My models are
> class MyEntry(models.Model):
>    categories=models.ManyToManyField(Category)
>
>
> class Category(models.Model):
>    name=models.CharField(unique=True,max_length=50)
>
> --
> 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.
>
>

[  , 

Well that's what it is supposed to do, both Entry objects have
relation to "mycategory".

-- 
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: Newbie question: upgrade to python 2.6: cannot (re)connect to Django?

2010-03-10 Thread BobAalsma
YES!
Thank you very much.

Amazing how simple things can be blocking if the context is
missing ;-)

Regards,
Bob

On Mar 10, 11:12 am, Jirka Vejrazka  wrote:
> Hi Bob,
>
> > MacPro1:Downloads$ ls
> > Django-1.1.1.tar
>
>   You have not unpacked the Django archive. You need to run:
> $ tar xf Django-1.1.1.tar
>
>   It will create a subdirectory (named "Django-1.1.1" probably), then
> you need to move to that subdirectory
>
> $ cd Django-1.1.1
>
>  and then run the
> $ python setup.py install
>
>   Regards
>
>     Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



making query using filter()

2010-03-10 Thread jimgardener
Hi
I need to make a query as follows
Select all entries where categories=mycategory

In the db there are entries and categories as follows
Category.objects.all() -->[ ,,]

MyEntry.objects.all() --> [  ,, ]


I tried like this
mycategory=Category.objects.get(name='mycategory')
MyEntry.objects.filter(categories=mycategory)

But this returns entries where the categories field contains
'mycategory' and 'hiscategory' also.
How do I mention to retrieve only 'mycategory'.

I went through the Queryset docs ..but couldn't figure it out...
Any help would be appreciated
thanks
jim


p.s:


My models are
class MyEntry(models.Model):
categories=models.ManyToManyField(Category)


class Category(models.Model):
name=models.CharField(unique=True,max_length=50)

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



hi help regarding sharding

2010-03-10 Thread chiranjeevi muttoju
Hi,
i want to use *Sharding* concept in for my project. i requirement is, i have
one user model, and i want to save users by selecting the random databases.
ie. i have two tables db1 and db2, in both databases i have user table.
based on the userid i want to select the database in which that user object
should be persist. if any one know please help me. if any doubts about my
requirement plz reply me, i'll tell.
-- 
Thanks & Regards,
Chiranjeevi.Muttoju

-- 
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: is it uses the memcache..?

2010-03-10 Thread chiranjeevi muttoju
ok janusz thanks for ur reply.

On Wed, Mar 10, 2010 at 3:56 PM, Janusz Harkot wrote:

> Django documentation is very clear in this matter.
>
> All standard cache functions/decorators are using cache backend
> specified in the settings,
> defaults to local memory, with an option to use memcache.
>
> J.
>
> --
> 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.
>
>


-- 
Thanks & Regards,
Chiranjeevi.Muttoju

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



circular import in two models.py

2010-03-10 Thread Viktor
Hi,

I have two django applications, an issue tracker where an Issue is
related to a Partner
and a Partner model where partners can be grouped, etc
I would like to add an issue to every group to provide an easy
messaging for groups, so I don't have to write the message sending
logic again

could someone give me some ideas how can I cross-connect the two apps,
but save them as seemingly separate?
by seemingly separate I mean that I can change the Partner models by
simply writing

from app.models import Partner1 as Parner

instead of

from app.models import Partner2 as Parner

in the messaging app

thanks,
Viktor

-- 
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: is it uses the memcache..?

2010-03-10 Thread Janusz Harkot
Django documentation is very clear in this matter.

All standard cache functions/decorators are using cache backend
specified in the settings,
defaults to local memory, with an option to use memcache.

J.

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



  1   2   >