custom django-admin commands naming convention

2011-03-08 Thread Marwan Al-Sabbagh
Hi,
  I need to cron a few jobs for my django app to run daily. I went through
the docs on "Writing custom django-admin commands" and thats the direction
I'm planning to go to run these jobs. Our company has a number of teams
developing different apps and I didn't want the naming of the commands to be
a mess. Are there any recommendations for naming conventions of the
commands. Is it common for example to call the command appname_command to
make it clear which app is implementing which command. Any advice/experience
is welcome.

thanks,
Marwan

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



dependend fields

2011-03-08 Thread Szabo, Patrick (LNG-VIE)
Hi, 

 

I want to make the choices of a dropdown menu dependend on what is
chosen from another field. 

One field is a normal Textfield and the other one is created by the
model.

 

What is the best and easiest way of doing that ?!

 

Kind regards

 


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 





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



Re: Bug in Django admin?

2011-03-08 Thread Martin Tiršel

Hello,

On Mon, 07 Mar 2011 22:12:14 +0100, Michael Radziej   
wrote:



Ahoj Martin,

On Mon, 07 Mar 2011 12:49:32 +0100, Martin Tiršel   
wrote:

When I use filter in Django admin (that produces URL
.../admin/appname/booltest/?completed__exact=False), I get results which
are with completed=True. This is the SQL query generated by Django
admin:


It's the wrong URL, you should use

.../admin/appname/booltest/?completed__exact=False



It is the same link, I don't see a difference :)


(or has this changed since 1.1?)

Is there really a link somewhere in the admin to the "...=False" link,
or did you try to guess it?




This link is called after I click on `no` in filter category `By  
completed`.



Kind regards

Michael



Regards,
Martin

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



Admin list delete and model delete() method

2011-03-08 Thread galago
Hi, I have defined delete() method in my model. I use it to clear cache and 
delete thumbs. When I delete an element in admin, in it's details (edit 
mode) cache is cleared and all thumbs are deleted.
But, when i want to delete several elements at once - checking checkboxes on 
the elements list - elements are deleted, but cahce and 
thumbnails aren't deleted, so my model delete method isn't made:/

How can I fix it?

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



Re: When do we stop using Django admin?

2011-03-08 Thread Michael Radziej
On Mon, 7 Mar 2011 21:49:45 -0800 (PST), ajaishankar  
wrote:
> I do know we can tweak the admin to restrict querysets etc. and also
> override admin templates - but is admin preferable in this situation?
> 
> Or is it better to treat all this as a front end web app, and start
> work on fresh pages.

The admin pages usually are a compromise for a user interface. They have
to be very generic and as such are usually not the best fit. I usually
stay away from them when they need more than trivial customization. It's more 
open
to changes (and you don't get big eyes from your customer because
changing this little detail needs so much additional effort). The admin
pages are also very simple to implement as views.

Anyway, your mileage may vary, and it all depends on the
circumstances. If leaving admin pages means writing hundreds of views,
or if the admin pages really fit the user interaction in your
application, it might make sense to stay with them.

As a rule of thumb: When understanding the customization is harder than
writing a view, there's probably not much sense in using the admin.


Hope that helps

Michael

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



Re: SQL generated for ManyToManyField is incorrect with Django 1.2.1

2011-03-08 Thread Gergely
Ok, it is clear now.
SQLite unfortunatelly does not support "ALTER TABLE ADD CONSTRAINT"
command.
So the "REFERENCES" clause is not possible if the referenced table is
missing, there is no alter, and of course django will not re-arrange
my definition order.
The same applies to many-to-many relations.
At least it creates an index on the foreign key column, so query will
be faster just the constraint is missing.
I think django does the maximum it can with sqlite :)

Since I am just learning django I can live without constraints and
later I will use some "more complete" db, no frustration anymore :)

Thanks again for the informations, I hope it was usefull not just for
me.

Best regards,
Gergely

On márc. 7, 13:43, Gergely  wrote:
> Thanks a lot Tom!
>
> Now I see that not the "REFERENCES" is missing but the "ALTER" at the
> end of the script.
> And of course the reason is clear, you are right.
>
> I will test it with the latest django and sqlite and report the result
> here.
>
> Regards,
> Gergely
>
> On márc. 7, 13:33, Tom Evans  wrote:
>
>
>
>
>
>
>
> > On Mon, Mar 7, 2011 at 12:04 PM, Tom Evans  wrote:
> > > If so, then there is no difference in the SQL generated - why would there 
> > > be?
>
> > > Cheers
>
> > > Tom
>
> > Oh, I'm waay wrong:
>
> > class Series(models.Model):
> >   pass
> > class Episode(models.Model):
> >   series = models.ForeignKey('Series')
>
> > =>
>
> > BEGIN;
> > CREATE TABLE "app_series" (
> >     "id" serial NOT NULL PRIMARY KEY
> > )
> > ;
> > CREATE TABLE "app_episode" (
> >     "id" serial NOT NULL PRIMARY KEY,
> >     "series_id" integer NOT NULL REFERENCES "app_series" ("id")
> > DEFERRABLE INITIALLY DEFERRED
> > )
> > ;
> > CREATE INDEX "app_episode_series_id" ON "app_episode" ("series_id");
> > COMMIT;
>
> > where as:
>
> > class Episode(models.Model):
> >   series = models.ForeignKey('Series')
> > class Series(models.Model):
> >   pass
>
> > =>
>
> > BEGIN;
> > CREATE TABLE "app_episode" (
> >     "id" serial NOT NULL PRIMARY KEY,
> >     "series_id" integer NOT NULL
> > )
> > ;
> > CREATE TABLE "app_series" (
> >     "id" serial NOT NULL PRIMARY KEY
> > )
> > ;
> > ALTER TABLE "app_episode" ADD CONSTRAINT "series_id_refs_id_61c5b6e4"
> > FOREIGN KEY ("series_id") REFERENCES "app_series" ("id") DEFERRABLE
> > INITIALLY DEFERRED;
> > CREATE INDEX "app_episode_series_id" ON "app_episode" ("series_id");
> > COMMIT;
>
> > Django 1.2.5, using postgres_psycopg2 backend.
>
> > I can understand why it does this. The table it references needs to
> > exist before Django can create a reference to it. By declaring it in
> > one order leads Django to assume that the table does not exist yet,
> > and to defer the creation of the reference constraint pointing to it.
>
> > To have both situations producing the same SQL would require Django to
> > understand and re-order the table creation queries, and that isn't
> > necessary or worthwhile - the order that the developer chose is used
> > instead.
>
> > 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to aggreate in html django

2011-03-08 Thread Tom Evans
On Tue, Mar 8, 2011 at 1:23 AM, sushanth Reddy  wrote:
> Hi Tom,
>
> Can you please  add few lines of code example,
> to make code more efficient?sorry for troubling.
>

Currently you query the DB to generate a list of users, and then for
each user you query the DB once for each date in the date range to
find out their expenses. If you have 100 users, and a 60 day reporting
period, your view will do 6000 queries to display the page. For this
sort of situation, you should be using 2 queries.

users = Profiles.objects.filter(...)
rp_begin = ... # start of reporting period
rp_end = ... # end of reporting period
expenses_data = Dataset.objects.filter(user__in=users,
date__gt=rp_begin, date__lt=rp_end).order_by('user',
'date').values_list('user_id', 'date', 'expense')

This will give you a list of values. You can either iterate through
this building up the HTML in your view (bad), or you can then
pre-process it a little bit into a format that would work nicely in a
template, and output it that way.

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



Re: Bug in Django admin?

2011-03-08 Thread Michael Radziej
Hi Martin!

> > It's the wrong URL, you should use
> >
> > .../admin/appname/booltest/?completed__exact=False
> >
> 
> It is the same link, I don't see a difference :)

Args--you're right. Stupid fingers :-)

I meant

.../admin/appname/booltest/?completed__exact=0

Does it work that way for you with 0 instead of False?


> This link is called after I click on `no` in filter category `By  
> completed`.

Hmm. I see a 0 here. I don't know the reason for the difference, I
checked it on a django 1.1 system. I vaguely remember a change.

What database and which version of Django are you using?


Kind regards

Michael

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



Re: Admin list delete and model delete() method

2011-03-08 Thread Michal Petrucha
> Hi, I have defined delete() method in my model. I use it to clear cache and 
> delete thumbs. When I delete an element in admin, in it's details (edit 
> mode) cache is cleared and all thumbs are deleted.
> But, when i want to delete several elements at once - checking checkboxes on 
> the elements list - elements are deleted, but cahce and 
> thumbnails aren't deleted, so my model delete method isn't made:/
> 
> How can I fix it?

When deleting batches of elements using whole querysets (which is what
I believe happens here), the delete() method isn't called for each
element, instead a more direct SQL query is issued to delete all
matching objects at once.

If you want to circumvent this, I recommend reading through
http://docs.djangoproject.com/en/1.2/topics/db/queries/#deleting-objects

Michal Petrucha


signature.asc
Description: Digital signature


Re: Admin list delete and model delete() method

2011-03-08 Thread galago
So if I'll define delete_model in admin - it will work?

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



PLEASE HELP ME IN ADDING A CATEGORY IN THE ADMIN SITE

2011-03-08 Thread pankaj sharma
same as categories i have to add affiliation to every college.
so i added

class Affiliation(models.Model):
title = models.CharField(max_length=100)

def __unicode__(self):
return self.title

to models.py


and  added one more field to class of colleges

class College(models.Model):
   name = models.CharField(max_length=250)
   category = models.ForeignKey(Category)
   city = models.ForeignKey(City)
   affiliation = models.ForeignKey(Affiliation)### i added
this line to college class in models .py

now i changed my admin.py to this:



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

class CollegeAdmin(admin.ModelAdmin):
list_display = ('name','category', 'city', 'affiliation')
list_filter = ['category', 'city']
search_fields = ['name', 'city']


class CityAdmin(admin.ModelAdmin):
list_display = ('title', 'state')
list_filter = ['state']
search_fields = ['title',]

admin.site.register(College, CollegeAdmin)
admin.site.register(City, CityAdmin)
admin.site.register(State)
admin.site.register(Category)
admin.site.register(Affiliation)


 but when i use syncdb command it shows no fixtures found

and when i click on college in admin site  then it show me error like
this


OperationalError at /admin/college/college/
(1054, "Unknown column 'college_college.affiliation_id' in 'field
list'")




now what to do? do i have to edit some more codes?

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



Re: PLEASE HELP ME IN ADDING A CATEGORY IN THE ADMIN SITE

2011-03-08 Thread Brian Bouterse
please don't shout

On Tue, Mar 8, 2011 at 12:34 AM, pankaj sharma
wrote:

> same as categories i have to add affiliation to every college.
> so i added
>
> class Affiliation(models.Model):
>title = models.CharField(max_length=100)
>
>def __unicode__(self):
>return self.title
>
> to models.py
>
>
> and  added one more field to class of colleges
>
> class College(models.Model):
>   name = models.CharField(max_length=250)
>   category = models.ForeignKey(Category)
>   city = models.ForeignKey(City)
>   affiliation = models.ForeignKey(Affiliation)### i added
> this line to college class in models .py
>
> now i changed my admin.py to this:
>
>
>
> from django.contrib import admin
> from college.models import *
>
> class CollegeAdmin(admin.ModelAdmin):
>list_display = ('name','category', 'city', 'affiliation')
>list_filter = ['category', 'city']
>search_fields = ['name', 'city']
>
>
> class CityAdmin(admin.ModelAdmin):
>list_display = ('title', 'state')
>list_filter = ['state']
>search_fields = ['title',]
>
> admin.site.register(College, CollegeAdmin)
> admin.site.register(City, CityAdmin)
> admin.site.register(State)
> admin.site.register(Category)
> admin.site.register(Affiliation)
>
>
>  but when i use syncdb command it shows no fixtures found
>
> and when i click on college in admin site  then it show me error like
> this
>
>
> OperationalError at /admin/college/college/
> (1054, "Unknown column 'college_college.affiliation_id' in 'field
> list'")
>
>
>
>
> now what to do? do i have to edit some more codes?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Brian Bouterse
ITng Services

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



Re: PLEASE HELP ME IN ADDING A CATEGORY IN THE ADMIN SITE

2011-03-08 Thread Kenneth Gonsalves
On Mon, 2011-03-07 at 21:34 -0800, pankaj sharma wrote:
> and when i click on college in admin site  then it show me error like
> this 

when changing fields within a model, you have to manually change the
database table. Syncdb will not do it.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: PLEASE HELP ME IN ADDING A CATEGORY IN THE ADMIN SITE

2011-03-08 Thread Anoop Thomas Mathew
Pankaj,

If there is no relevant data in the db, remove it, create a new db and try
syncdb.
That'll work.

regards,
atm
___
Life is short, Live it hard.




On 8 March 2011 18:00, Kenneth Gonsalves  wrote:

> On Mon, 2011-03-07 at 21:34 -0800, pankaj sharma wrote:
> > and when i click on college in admin site  then it show me error like
> > this
>
> when changing fields within a model, you have to manually change the
> database table. Syncdb will not do it.
> --
> regards
> KG
> http://lawgon.livejournal.com
> Coimbatore LUG rox
> http://ilugcbe.techstud.org/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: date_heiarchy not working

2011-03-08 Thread Karen Tracey
On Mon, Mar 7, 2011 at 4:52 PM, Bobby Roberts  wrote:

> i've got this in my admin model:
>  date_heiarchy='ShipDate'
>
> Shipdate is a DateField.  The Date Heiarchy plugin is not showing on
> my admin list view... has that been depricated in django 1.2+?
>

No, it's not be deprecated. If that's a cut-and-paste from your file the
problem is the attribute is spelled date_hierarchy, not date_heiarchy.
You've also given ShipDate two different capitalizations and it will need to
be specified with one that matches the field definition.

Karen
-- 
http://tracey.org/kmt/

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



Why does Django Fail on Date Field?

2011-03-08 Thread octopusgrabbus
Here is the table:

class CsRemove(models.Model):
action = models.CharField(max_length=3, db_column='Action') #
Field name made lowercase.
endpointid = models.IntegerField(primary_key=True,
db_column='EndpointId') # Field name made lowercase.
devicetype = models.IntegerField(primary_key=True,
db_column='DeviceType') # Field name made lowercase.
channelnumber = models.IntegerField(primary_key=True,
db_column='ChannelNumber') # Field name made lowercase.
actiondate = models.DateField(primary_key=True,
db_column='ActionDate') # Field name made lowercase.
class Meta:
db_table = u'cs_remove'

I can use MySQL Query browser and insert successfully. Django cannot.
I can easily roll some MySQL code to do this, but would prefer to do
it the Django way.

What am I missing?

Thanks.

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



Re: Why does Django Fail on Date Field?

2011-03-08 Thread Jirka Vejrazka
Well, we're missing the bit where you tell us what error are you
getting. I don't know about others, but my crystal ball is a bit dusty
these days.

The models.py snippet you posted is obvious result of inspectdb
output, which *may* need some manual tweaking. But it's difficult for
us to guess as we don't know your database and we don't know what
exactly is wrong (except for "Django fails").

If you add more details, someone might be able to help you

My 2 cents

   Jirka

On Tue, Mar 8, 2011 at 14:08, octopusgrabbus  wrote:
> Here is the table:
>
> class CsRemove(models.Model):
>    action = models.CharField(max_length=3, db_column='Action') #
> Field name made lowercase.
>    endpointid = models.IntegerField(primary_key=True,
> db_column='EndpointId') # Field name made lowercase.
>    devicetype = models.IntegerField(primary_key=True,
> db_column='DeviceType') # Field name made lowercase.
>    channelnumber = models.IntegerField(primary_key=True,
> db_column='ChannelNumber') # Field name made lowercase.
>    actiondate = models.DateField(primary_key=True,
> db_column='ActionDate') # Field name made lowercase.
>    class Meta:
>        db_table = u'cs_remove'
>
> I can use MySQL Query browser and insert successfully. Django cannot.
> I can easily roll some MySQL code to do this, but would prefer to do
> it the Django way.
>
> What am I missing?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



csrf_exempt decorator and class based views

2011-03-08 Thread Christo Buschek
Hello.

I came across a problem that I don't fully understand. I try to
implement a view where I want to turn csrf protection off. My view is
implemented as a class based view, eg:

class BaseHandler(object):
"""Base class to provide method lookup per HTTP method."""
def __call__(self, request, **kwargs):
self.request = request
try:
callback = getattr(self, "do_%s" % request.method)
except AttributeError:
 allowed_methods = [m.lstrip("do_") for m in dir(self) if
m.startswith("do_")]
 return HttpResponseNotAllowed(allowed_methods)
return callback(**kwargs)

class SpecificHandler(BaseHandler):
"""Implement the HTTP methods."""
def do_POST(self, **kwargs):
pass

If I want to use the @csrf_exempt on the class method 'do_POST', it
doesn't get recognised. It is only accepted if I wrap the whole class
inside the decorator, eg:

# This doesn't work
class SpecificHandler(BaseHandler):
@csrf_exempt
def do_POST(self, **kwargs):
pass

# This works
@csrf_exempt
class SpecificHandler(BaseHandler):
def do_POST(self, **kwargs):
pass

But I wonder if that is the right way to do because than all class
methods are excepted from the csrf protection.

1) Why is the decorator not wrapping the class method (more a python
question I guess)?
2) Is there any other way how I could turn off the csrf protection for
this single class method?

Any enlightenment is very much appreciated.

cheers
Christo

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



Re: Cycle & Include tags

2011-03-08 Thread Russell Keith-Magee
On Tue, Mar 8, 2011 at 11:29 AM, Brian Neal  wrote:
> I'm using a recent checkout of Django trunk.
>
> If I have a template "test.html" which is this:
>
> {{ rowcolors }}
>
> the only way I could make cycle and include behave together is to do
> this:
>
> {% for obj in page.object_list %}
> 
> {% include 'test.html' %}
> {% endfor %}
>
> I thought that perhaps the new "silent" keyword would eliminate the
> need to HTML comment out the cycle tag:
>
> {% for obj in page.object_list %}
> {% cycle 'odd' 'even' as rowcolors silent %}
> {% include 'test.html' %}
> {% endfor %}
>
> However, the very first time through the for loop, rowcolors is not
> set in the included template. It works on subsequent cycles though.
>
> Is there a way to make this work without having to HTML comment out
> the cycle tag output? Admittedly it's a minor annoyance.

It looks like you may have discovered a problem with the silent flag
as designed. The use you present is exactly what the silent flag was
designed to address; but it appears that it doesn't actually hit that
use case.

I've just opened #15570 to track this problem, and since this is a new
feature (which will require a backwards incompatible change to fix),
it is a blocker for 1.3 final. The fix will be to make silent *always*
put the value into context, but not render a value. This is the usage
that your second sample suggests as appropriate usage.

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



Re: csrf_exempt decorator and class based views

2011-03-08 Thread Casey S. Greene

Have you seen this yet:

http://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-class-based-views

I think it answers your question.

Hope this helps,
Casey

On 03/08/2011 08:19 AM, Christo Buschek wrote:

Hello.

I came across a problem that I don't fully understand. I try to
implement a view where I want to turn csrf protection off. My view is
implemented as a class based view, eg:

class BaseHandler(object):
 """Base class to provide method lookup per HTTP method."""
 def __call__(self, request, **kwargs):
 self.request = request
 try:
 callback = getattr(self, "do_%s" % request.method)
 except AttributeError:
  allowed_methods = [m.lstrip("do_") for m in dir(self) if
m.startswith("do_")]
  return HttpResponseNotAllowed(allowed_methods)
 return callback(**kwargs)

class SpecificHandler(BaseHandler):
 """Implement the HTTP methods."""
 def do_POST(self, **kwargs):
 pass

If I want to use the @csrf_exempt on the class method 'do_POST', it
doesn't get recognised. It is only accepted if I wrap the whole class
inside the decorator, eg:

# This doesn't work
class SpecificHandler(BaseHandler):
 @csrf_exempt
 def do_POST(self, **kwargs):
 pass

# This works
@csrf_exempt
class SpecificHandler(BaseHandler):
 def do_POST(self, **kwargs):
 pass

But I wonder if that is the right way to do because than all class
methods are excepted from the csrf protection.

1) Why is the decorator not wrapping the class method (more a python
question I guess)?
2) Is there any other way how I could turn off the csrf protection for
this single class method?

Any enlightenment is very much appreciated.

cheers
Christo



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



Re: Cycle & Include tags

2011-03-08 Thread Russell Keith-Magee
On Tue, Mar 8, 2011 at 9:29 PM, Russell Keith-Magee
 wrote:
> On Tue, Mar 8, 2011 at 11:29 AM, Brian Neal  wrote:
>> I'm using a recent checkout of Django trunk.
>>
>> If I have a template "test.html" which is this:
>>
>> {{ rowcolors }}
>>
>> the only way I could make cycle and include behave together is to do
>> this:
>>
>> {% for obj in page.object_list %}
>> 
>> {% include 'test.html' %}
>> {% endfor %}
>>
>> I thought that perhaps the new "silent" keyword would eliminate the
>> need to HTML comment out the cycle tag:
>>
>> {% for obj in page.object_list %}
>> {% cycle 'odd' 'even' as rowcolors silent %}
>> {% include 'test.html' %}
>> {% endfor %}
>>
>> However, the very first time through the for loop, rowcolors is not
>> set in the included template. It works on subsequent cycles though.
>>
>> Is there a way to make this work without having to HTML comment out
>> the cycle tag output? Admittedly it's a minor annoyance.
>
> It looks like you may have discovered a problem with the silent flag
> as designed. The use you present is exactly what the silent flag was
> designed to address; but it appears that it doesn't actually hit that
> use case.
>
> I've just opened #15570 to track this problem, and since this is a new
> feature (which will require a backwards incompatible change to fix),
> it is a blocker for 1.3 final. The fix will be to make silent *always*
> put the value into context, but not render a value. This is the usage
> that your second sample suggests as appropriate usage.

... and, FYI: Fixed in r15773.

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



Re: dependend fields

2011-03-08 Thread urukay
one way is to use Ajax call to get choices for dropdown menu.

R.

On 8. Mar., 09:42 h., "Szabo, Patrick \(LNG-VIE\)"
 wrote:
> Hi,
>
> I want to make the choices of a dropdown menu dependend on what is
> chosen from another field.
>
> One field is a normal Textfield and the other one is created by the
> model.
>
> What is the best and easiest way of doing that ?!
>
> Kind regards
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Patrick Szabo
>  XSLT Developer
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: +43 (1) 534 52 - 1573
> Fax: +43 (1) 534 52 - 146

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



Django Dynamic Fixture

2011-03-08 Thread Paulo Cheque
To whom make automated tests in Django must have realized that using
fixtures (static data) is a terrible idea. There are a list of lots of
tools that help working with fixtures (djangopackages.com/grids/g/
fixtures), but I am just showing a new one, Django Dynamic Fixture
(code.google.com/p/django-dynamic-fixture) I think is the simplest and
most complete.

abs
Paulo
pythonsmalltalk.blogspot.com

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



Re: Multiple database queries

2011-03-08 Thread VidJa Hunter
I totally agree with the one database solution, which would be my choice, if
there were no legal issues attached to the different datasets.

On Mon, Mar 7, 2011 at 10:49 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Hey Vidja,
>
> May I ask why so many database instances are required? In my experience, if
> you get to the point where you really need this many, it's usually better to
> use a solution like Sphinx Search Engine, then employ your database as a
> heavy key/value store (with the bare necessary unique compound keys).
>
> We have a database with around 19 million rows (500,000 now added each
> day), which comes to around 20gb in the data lib folder. Now we push around
> 170 queries per second average (consisting of simple ID lookups), on a
> single quad core server with 8gb RAM. All the lookup queries take place
> inside Sphinx Search.
>
> This may not be appropriate for what you need, and does add some
> complexity, but I would certainly encourage you to explore this option if
> performance is what you need, without having to throw more and more hardware
> into it.
>
> Cal
>
>
>
> On Mon, Mar 7, 2011 at 9:41 PM, Vidja  wrote:
>
>> Hi all,
>>
>> does anyone have experience with querying against multiple databases
>> and performance issues? My plan is to query against 15-200  instances
>> of a database (Postgres on a 8 core 32 GB machine, each db about 200
>> mb) , all with the same schema (an thus model file), but with
>> different data.
>> Are there serious performance bottlenecks to be expected?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: current recommendations for using email as username

2011-03-08 Thread Bill Freeman
We've even had problems (converting people's old site accounts) with
non-email usernames exceeding 30 characters.

On Sat, Mar 5, 2011 at 12:49 AM, creecode  wrote:
> It would be grand if the max_length was upped.
>
> On Mar 4, 7:51 pm, Shawn Milochik  wrote:
>
>> > Email addresses have been allowed since version 1.2 <
>> >http://docs.djangoproject.com/en/1.2/topics/auth/#api-reference>.
>> > Have you found place in 1.2.x where an email address doesn't work?
>>
>> The problem here is that the username is still limited to 30
>> characters. So plenty of e-mail addresses won't work.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: weird ifnotequal issue

2011-03-08 Thread Bill Freeman
That's a weird field name.  I could see there being a corner case.

If it were me, I'd stick a breakpoint in the ifequal implementation, possibly,
if you have a lot of other ifequal tags to get past conditioned (normal
python if statement) on having gotten "." in the arguments.  Then you
can see what's really happening.

On Sun, Mar 6, 2011 at 11:30 PM, Bobby Roberts  wrote:
> fieldname does in fact equal "-" so why is the TR still showing?
>
>  {% ifnotequal mymodel.fieldname"-"%}
>  
>    Flagged Reason
>    {{mymodel.fieldname}}
>  
> {%endifnotequal%}
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Payment Gateways

2011-03-08 Thread Bill Freeman
On Mon, Mar 7, 2011 at 6:03 AM, CLIFFORD ILKAY
 wrote:
> You can use whatever you like as long as it has an API and documentation.
> We've used SecurePay (an Australian one), InternetSecure, BeanStream,
> Authorize.net, and others that I can't remember right now. They all have
> their pros and cons. A quick checklist of what to look for:
>
> * API
>
> * Documentation - very important
>
> * Test environment, a.k.a. sandbox - very important. Some have great
> restrictions on what you can do in that environment so pay attention to the
> details.
>
> * Which currencies will they process?
>
> * Which credit cards and which other payment methods will they accept?
>
> * Fees - the pricing is all over the place and like anything, volume will
> get you discounts.

And I can't resist recommending solutions that don't require your to touch
the credit card number.  If you never had it, you can't be responsible for
compromising it.

Bill

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



Re: celery tasks and circular imports

2011-03-08 Thread Bill Freeman
The (major part of the work of) import is NOT done every time through.  On
subsequent passes, the import statement merely looks up the module in
sys.modules.  This is only slightly more of a performance hit than a direct
dictionary look up (depending on how much the compiler inlines when it
sees an import statement) - that is, it's not worth worrying about.

It is often possible to refactor code so that these techniques aren't necessary,
for example, breaking one module, A, into A1 and A2 modules, where A1
has no code that depends on B, but does have what B needs from A (so
both A2 and B import A1).  But this often obfuscates the code.  Readable
code is always a priority for me.

Bill

On Mon, Mar 7, 2011 at 9:55 AM, Brian Bouterse  wrote:
> I too "protect" code from being interpreted at import time by putting import
> statements directly in the tasks that need them.  I don't think there is
> anything wrong with this approach the from a Python perspective other than
> possibly these:
> * imports are parsed at runtime and thus an import occurs for each time the
> code is run    <=== performance problem
> * import errors aren't discovered until runtime
> I too am looking for a better way to do this.
> Brian
> On Mon, Mar 7, 2011 at 8:25 AM, Shawn Milochik  wrote:
>>
>> If there's a "correct" way to do this I'd love to hear it also.
>>
>> At present I do the model imports in tasks.py within the task that
>> requires the model. This is because in my models.py I import tasks
>> from tasks.py.
>>
>> 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-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Brian Bouterse
> ITng Services
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: which statements are right?

2011-03-08 Thread Bill Freeman
I'll take a shot.

On Mon, Mar 7, 2011 at 11:43 AM, yongzhen zhang <4...@live.cn> wrote:
> Hi,
> When i am doing some exercises, i found some questions are very to
> understand, Could you tell me which sentiences are correct?
> 1. Models convert data from relational database form to objects and
> vice versa.

Somewhat true.  Models define the data you want to persist in the
database.  In cahoots with the database back end code, they thus
specify one or more tables per model (mostly one, but an occasional
auxiliary table is sometimes used), and what the columns of the table(s)
are, both as to data types and column names.  It is the database
back end code (shared by all models) that knows how to convert
between database representation of data and the python objects you
find in fields of *instances* of the model class.

> 2. Django model has to be written for a specific relation database

False.  settings.py specifies which database (and database back end)
you are using, and, generally speaking, the same model will work
unmodified with, for example, sqlite and postresql.  Some databases,
however, have their quirks, and may restrict your model coding, but
obeying those restrictions won't (in general) prevent the model from
working with one of the more "regular" databases.  (Database back
ends for some of the less usual databases may have some warts
of their own.)

> 3. Foreignkey are used to refer to elements in the other databases

False.  Foreign keys reference rows in other tables or the same
table in the same database.  I think that some of the more recent
work allows references to rows in tables in another database, but
this is an uncommon need (single database projects are still the
norm for most of us).

> about the views:
>
> 4. they interpret user input contained in the HTTP requests

The can interpret user input, in the form of GET and/or POST
parameters, but many views do not.  Mostly a view is code
that decides what to return to the user (what he views).  They
may or may not use user input for this decision.

> 5. they create the user interface

Not, in general, by themselves.  If you consider the url path
design to be part of the user interface (as I do), then the
url resolver and it's urls.py modules is involved.  And while
a view can return a response without using templates, that
is unusual (other than for the return or errors or non-HTML
content).

> 6. they access the models

They can access model data (instances of models), but they
don't have to.  It's perfectly reasonable to have a view that,
for example, gives you information about the site and tells
you the current time.  But when database data needed to
generate the response, then, yes, they obtain model
instances to access that data (similarly, if they need to
store something in the database).

> about the templates:
>
> 7. Templates can specify any HTTP Headers for the response

False.  HTTP headers are set in the view.  A normal template
does not affect them (except by having an error exception).
While it would be possible for a view to use the return value
of some special template when it sets response headers, this
is not common practice.  Headers are though of a more in the
programmer's province than in the presentation designer's.

> The last thing is that why  django has a mechanism to protects against
> calling methods from template that have side effects is a good idea?

Templates are supposed to be about presentation, that is, how
the response looks.  Logic generally belongs elsewhere, though
the distinction is hard to draw, leading to "if" and "for" constructs
in templates.  Most logic is better expressed in python than in the
template language.  Expressing complex logic in the template
language is torturous.  In serious projects template coding is often
handled by separate people, whose expertise is visual design and
how to get things to look right in IE6, but who are not necessarily
programmers.  This separation is accepted by many (most?) as
modern good practice, even if the programmer and template
designer are the same person (you should be in different frames
of mind for the two tasks).  That being said, django does not
prevent your template from having side effects.  You just need
the cooperation of your view and/or models and/or write a template
tag or filter.

Bill

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



Re: How to get next and previous element in a forloop in the template

2011-03-08 Thread Bill Freeman
Apart from writing your own for tag, you could, for instance, supply
a generator (or equivalent) on your model, or passed in by your
view, that returns 3 tuples of (this, prev, next), or perhaps easier
to read in the template, toy objects having this, prev, and next
attributes (or properties).

On Mon, Mar 7, 2011 at 3:43 PM, Ariel  wrote:
> Could you give some idea ???
> I am sorry about the previous message I had not finished.
> Any help is appreciated.
> Regards.
>
> On Mon, Mar 7, 2011 at 3:39 PM, Ariel  wrote:
>>
>> Hi everybody:
>>
>> I would want to know in the django template tags how to get the next and
>> the previous element when I am iterating in the forloop, I haven't found
>> something similar, for instance I would want something like this:
>> {% for element in list_elements %}
>> {{forloop.get_prev_element.title}}
>> {{forloop.get_next_element.title}}
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Treebeard Question

2011-03-08 Thread Tyler Brock
Answer:

I was depending on Django's auto_now feature to give me appropriate datetime
which apparently isn't available until save.

Changed root addition to this and it works like a charm:

now = created=datetime.datetime.now()

Interaction.add_root(page=page, content=content, user=user,
interaction_node=tag, created=now)

-Tyler

On Mon, Mar 7, 2011 at 12:50 PM, Tyler Brock  wrote:

> Hey guys,
>
> Was wondering if you could help me figure this out...
>
> I've got a class in a model that implements MP_Node from treebeard:
> http://dpaste.com/481579/
>
> When I tag something and send the tag request to the API I want to
> create a new tag interaction (root node) as defined in the following
> handler.
>
> Piston handler: http://dpaste.com/481577/
>
> The idea is, when no parent node is passed in that I want to create a
> new tree for possible interactions that happen on that first tag. A
> first tag is a new tree of interactions here. (the parent passing in
> part isn't implemented yet so everything is a new tree at the moment)
>
> Why is it that the first tag goes ok and subsequent tags are met with
> the following error: http://dpaste.com/481583/
>
> Can you only add one root? I've checked the arguments I've passed in
> and none are defined as None and each have an id.
>
> I've been looking at the examples and it seems like you can have many
> roots. I would like to have a new root (tree) for each first tag on a
> given page for a given piece of content.
>
> Please let me know. Thanks in advance!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Why does Django Fail on Date Field?

2011-03-08 Thread octopusgrabbus
Sorry. The error is Exception Type:
ValidationError
Exception Value:
[u'Enter a valid date in -MM-DD format.']

I have printed out for myself to prove that my date is in this format.

On Mar 8, 8:24 am, Jirka Vejrazka  wrote:
> Well, we're missing the bit where you tell us what error are you
> getting. I don't know about others, but my crystal ball is a bit dusty
> these days.
>
> The models.py snippet you posted is obvious result of inspectdb
> output, which *may* need some manual tweaking. But it's difficult for
> us to guess as we don't know your database and we don't know what
> exactly is wrong (except for "Django fails").
>
> If you add more details, someone might be able to help you
>
> My 2 cents
>
>    Jirka
>
> On Tue, Mar 8, 2011 at 14:08, octopusgrabbus  
> wrote:
> > Here is the table:
>
> > class CsRemove(models.Model):
> >    action = models.CharField(max_length=3, db_column='Action') #
> > Field name made lowercase.
> >    endpointid = models.IntegerField(primary_key=True,
> > db_column='EndpointId') # Field name made lowercase.
> >    devicetype = models.IntegerField(primary_key=True,
> > db_column='DeviceType') # Field name made lowercase.
> >    channelnumber = models.IntegerField(primary_key=True,
> > db_column='ChannelNumber') # Field name made lowercase.
> >    actiondate = models.DateField(primary_key=True,
> > db_column='ActionDate') # Field name made lowercase.
> >    class Meta:
> >        db_table = u'cs_remove'
>
> > I can use MySQL Query browser and insert successfully. Django cannot.
> > I can easily roll some MySQL code to do this, but would prefer to do
> > it the Django way.
>
> > What am I missing?
>
> > Thanks.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django inlines with custom form ignores excluded fields?

2011-03-08 Thread Marc Aymerich
HI,
I want to use a custom form for one of my admin inlines, but
unfortunatly I'm not able to exclude some fields. Seems that
GenericStackedInline ignores whatever I put on ModelForm.Meta.exclude.
Is this a normal behaviour? or it's a bug?

My test classes:

class Mon(ModelForm):
class Meta:
 model = Monitoring
 exclude = ('monitor','limit','current',)

class GenericMonitoringInline(generic.GenericStackedInline):
 model = Monitoring
 form = Mon


Thanks!
-- 
Marc

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



Django and an indirect access to the database tables (over stored procedures calls for data retrieval and modification)

2011-03-08 Thread Vazir
Hello!
I'm looking for a way to be using Django as an MVC framework, for a
very complex database, so
there is no way (and no need) of giving a Django models with direct
access to a DB structure (all business logic is already bult in to the
DB), all DB interaction must be done via the stored procedures calls.
I'm looking for any examples on implementation of the Django models
with indirect access to a DB data. There is doc of using raw() methods
in Django documentation, but it's not clear how updates will be done
than. Will be grateful for any links or suggestions how to do that!

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



Re: Django and an indirect access to the database tables (over stored procedures calls for data retrieval and modification)

2011-03-08 Thread Michael Radziej
On Tue, 8 Mar 2011 10:11:57 -0800 (PST), Vazir  wrote:
> there is no way (and no need) of giving a Django models with direct
> access to a DB structure (all business logic is already bult in to the
> DB), all DB interaction must be done via the stored procedures calls.

Well, you have to call your stored procedures in a way that depends on
your stored procedures. There is no django support for this, it's all
do-it-yourself. 

It's probably best to ignore all the model stuff in django. Django loses
a lot of features in such a setting, unfortunately.

Take a look at the python DB API, and do everything with that.

http://www.python.org/dev/peps/pep-0249/


Kind regards

Michael

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



Re: current recommendations for using email as username

2011-03-08 Thread Andy
Is the 30 characters limit enforced by the database or by Django?

If the limit is set by the database, would altering the DB schema
work?

On Mar 4, 10:51 pm, Shawn Milochik  wrote:
> > Email addresses have been allowed since version 1.2 <
> >http://docs.djangoproject.com/en/1.2/topics/auth/#api-reference>.
> > Have you found place in 1.2.x where an email address doesn't work?
>
> > Toodle-lo..
> > creecode
>
> The problem here is that the username is still limited to 30
> characters. So plenty of e-mail addresses won't work.

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



Re: current recommendations for using email as username

2011-03-08 Thread william ratcliff
If you look through the code in the django admin, then the limit is set in
the database schema.

On Tue, Mar 8, 2011 at 3:05 PM, Andy  wrote:

> Is the 30 characters limit enforced by the database or by Django?
>
> If the limit is set by the database, would altering the DB schema
> work?
>
> On Mar 4, 10:51 pm, Shawn Milochik  wrote:
> > > Email addresses have been allowed since version 1.2 <
> > >http://docs.djangoproject.com/en/1.2/topics/auth/#api-reference>.
> > > Have you found place in 1.2.x where an email address doesn't work?
> >
> > > Toodle-lo..
> > > creecode
> >
> > The problem here is that the username is still limited to 30
> > characters. So plenty of e-mail addresses won't work.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Making a dashboard for the admin

2011-03-08 Thread Thomas Weholt
I thinking about making a dashboard for the admin, replace the page
you get to by default with something more relevant for my project, but
I don`t want to overwrite the index.html in the django-code, but the
django docs says the index.html file cannot be overriden in project
template dirs. How do I do this the correct way without messing with
django source?

Thanks in advance.

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

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



Re: custom django-admin commands naming convention

2011-03-08 Thread creecode
Hello Marwan,

I don't know if it's common but for my needs it's a must!  :-)  I have
several apps with custom management commands and I've taken to naming
the commands like...

my_app_name_my_custom_management_command_name.py

If find it easier to read the command name if I separate each word
with an underscore.  The names are fairly long but I'm not typing them
into the terminal all that much.  Mostly called from cron or pulled up
through my bash history.

Toodle-looo..
creecode

On Mar 8, 12:02 am, Marwan Al-Sabbagh 
wrote:

> Our company has a number of teams
> developing different apps and I didn't want the naming of the commands to be
> a mess. Are there any recommendations for naming conventions of the
> commands. Is it common for example to call the command appname_command to
> make it clear which app is implementing which command. Any advice/experience
> is welcome.

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



Re: current recommendations for using email as username

2011-03-08 Thread Brian Craft
On Tue, Mar 8, 2011 at 12:53 PM, william ratcliff
 wrote:
> If you look through the code in the django admin, then the limit is set in
> the database schema.

I've read elsewhere that it's also in all the auth form validations,
so you have to subclass all of them. I haven't actually investigated
this myself.

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



Re: current recommendations for using email as username

2011-03-08 Thread william ratcliff
It is in the forms.

On Tue, Mar 8, 2011 at 4:26 PM, Brian Craft wrote:

> On Tue, Mar 8, 2011 at 12:53 PM, william ratcliff
>  wrote:
> > If you look through the code in the django admin, then the limit is set
> in
> > the database schema.
>
> I've read elsewhere that it's also in all the auth form validations,
> so you have to subclass all of them. I haven't actually investigated
> this myself.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Satchmo Error - Invalid block tag: 'thumbnail', expected 'else' or 'endif'

2011-03-08 Thread anvydigital
I ran into this issue also with the latest version of satchmo and sorl-
thumbnail.  According to the sorl-thumbnail documentation, the tag
needs to be closed like so:

{% thumbnail item.image "100x100" crop="center" as im %}

{% endthumbnail %}

It is quite likely you are (as am I) using code that expects an older
version of sorl-thumbnail.
http://thumbnail.sorl.net/examples.html

Options are possibly: use an older version of sorl-thumbnail, or
update templates.

On Feb 25, 3:43 pm, Bobby Roberts  wrote:
> anyone have any other ideas?
>
> On Feb 22, 5:02 pm, Bobby Roberts  wrote:
>
>
>
>
>
>
>
> > Hey Daniel -
>
> > we've got {% load thumbnail%} at the top of the template (a standard
> > satchmo template anyway)... running version 3.2.5 for sorl.
>
> > On Feb 22, 4:25 pm, Daniel Roseman  wrote:
>
> > > On Tuesday, February 22, 2011 6:22:16 PM UTC, Bobby Roberts wrote:
>
> > > > Hi group.  I've posted this in the satchmo group but am posting here
> > > > as well in hopes of getting some help.
>
> > > > This error is caused by this code:
>
> > > > {% if product.main_image %}
> > > >               
> > > >               {% thumbnail product.main_image.picture 85x85 as image
> > > > %}
> > > >                > > > src="{{ image }}" width="{{ image.width }}"
> > > > height="{{ image.height }}" />
> > > >               
> > > > {% endif %}
>
> > > > it makes use of sorl thumbnail to resize images on the fly i believe.
> > > > We can import sorl thumbnail into python from command line just fine.
>
> > > > If anyone uses satchmo for their ecommerce store have you run into
> > > > this error?  How did you resolve.  Please help and thank you in
> > > > advance.
>
> > > You haven't loaded the template tag library that defines the thumbnail 
> > > tag.
>
> > >     {% load thumbnail_tags %}
>
> > > or whatever.
> > > --
> > > DR.

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



Re: Making a dashboard for the admin

2011-03-08 Thread olarcheveque
You should have a look at django-admin-tools (http://pypi.python.org/
pypi/django-admin-tools).
It provides dashboard + toolbar features.

On 8 mar, 16:00, Thomas Weholt  wrote:
> I thinking about making a dashboard for the admin, replace the page
> you get to by default with something more relevant for my project, but
> I don`t want to overwrite the index.html in the django-code, but the
> django docs says the index.html file cannot be overriden in project
> template dirs. How do I do this the correct way without messing with
> django source?
>
> Thanks in advance.
>
> --
> Mvh/Best regards,
> Thomas Weholthttp://www.weholt.org

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



Customizing how the elements are listed in admin change_list.html

2011-03-08 Thread Thomas Weholt
My app handles photos and the admin shows these photos in a table-like
manner as shown in attachment.

but I want to show it as google does when you search for images; a
bunch of photos spread across the page, like here:

http://www.google.no/images?q=django+pony

but still inside the admin and hopefully by extending django by
editing change_list.html for my model. I guess the code is somehow
being generated here somewhere :

 {% if cl.formset %}
{{ cl.formset.management_form }}
  {% endif %}

  {% block result_list %}
  {% if action_form and actions_on_top and
cl.full_result_count %}{% admin_actions %}{% endif %}
  {% result_list cl %}
  {% if action_form and actions_on_bottom and
cl.full_result_count %}{% admin_actions %}{% endif %}
  {% endblock %}

that`s from the change_list.html. But I`m not sure if I can access the
result queryset in the template somehow and add my own template code
to accomplish what I`m after.

Any hint or thoughts on how to do this would be great, and I apologize
in advance for adding the attachment.

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

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

<>

[OFFTOPIC] TUNO: small django app for programmed dents/tweets

2011-03-08 Thread Efrain Juvenal Valles Pulgar
Regards,


I write because I posted an app in django which we used in the office
to play with the twitter api's, we added identi.ca publications and
now we bring it to a web app using the power of django. This app is
not ready for production but can put it to work in 10 steps.

This web application is ideal for status updates that are informative
and scheduled. In fact it is the only thing that works for now. I
invite you to join the development of what would be a web app for
publications neglected all social networks. This is writen
primordially to have an app that is transparent in it's publishing of
status updates in the cloud and have it  as free and opensource
software

I do not guarantee it works 100% all the time for now, not a nice and
safe code, but that's where we are headed. I've been using since
November and is pretty much on time with publications. now if there is
a Json error from time to time with identi.ca. only make sure  that
you don't post the same thing twice in less than 5 minutes).

all is well detailed in the git repository to prepare for this app. I
will have a Bzr branch  also keep a repository for those of us who do
use it daily but I have not posted it yet.

Please do check out and have fun with TUNO

http://gitorious.org/tuno/tuno

initial meeting development in freenode # tuno friday 11 March, 17:30
UTC

Please consider helping out. It need all the hands we can get to make
it look, feel and perform rock solid

A hug to everyone

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



Re: PLEASE HELP ME IN ADDING A CATEGORY IN THE ADMIN SITE

2011-03-08 Thread ronny
Ignore the rest of these guys, and go here:

http://south.aeracode.org/docs/tutorial/part1.html#tutorial-part-1

It's called django-south, all the cool kids are using it.

Enjoy.  :D

-ron

On Mar 8, 7:34 am, pankaj sharma  wrote:
> same as categories i have to add affiliation to every college.
> so i added
>
> class Affiliation(models.Model):
>     title = models.CharField(max_length=100)
>
>     def __unicode__(self):
>         return self.title
>
> to models.py
>
> and  added one more field to class of colleges
>
> class College(models.Model):
>    name = models.CharField(max_length=250)
>    category = models.ForeignKey(Category)
>    city = models.ForeignKey(City)
>    affiliation = models.ForeignKey(Affiliation)            ### i added
> this line to college class in models .py
>
> now i changed my admin.py to this:
>
> from django.contrib import admin
> from college.models import *
>
> class CollegeAdmin(admin.ModelAdmin):
>     list_display = ('name','category', 'city', 'affiliation')
>     list_filter = ['category', 'city']
>     search_fields = ['name', 'city']
>
> class CityAdmin(admin.ModelAdmin):
>     list_display = ('title', 'state')
>     list_filter = ['state']
>     search_fields = ['title',]
>
> admin.site.register(College, CollegeAdmin)
> admin.site.register(City, CityAdmin)
> admin.site.register(State)
> admin.site.register(Category)
> admin.site.register(Affiliation)
>
>  but when i use syncdb command it shows no fixtures found
>
> and when i click on college in admin site  then it show me error like
> this
>
> OperationalError at /admin/college/college/
> (1054, "Unknown column 'college_college.affiliation_id' in 'field
> list'")
>
> now what to do? do i have to edit some more codes?

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



Re: Payment Gateways

2011-03-08 Thread CLIFFORD ILKAY

On 03/08/2011 09:59 AM, Bill Freeman wrote:

And I can't resist recommending solutions that don't require your to touch
the credit card number.  If you never had it, you can't be responsible for
compromising it.


That is true. Most of the payment processors have some sort of hosted 
form solution for that. However, there are significant limitations in 
those hosted form solutions that may make them unsuitable in some 
situations. For instance, we ran into one such limitation recently on a 
project where the processor apparently doesn't provide any sort of 
"success" or "failure" notification for zero dollar transactions. Why 
would you want a zero dollar transaction you might be wondering? Our 
client was running a promotion where some initial period was free after 
which the normal recurring fees would kick in. Normally, there is an 
initial fee and recurring fees. Upon success or failure on the normal 
initial fee, we'd get a callback to a view function from the payment 
gateway which we'd need to complete the transaction. Completion of the 
transaction consists of listing the product and updating the user's 
dashboard with the transaction date and the expiry date for the listing. 
With the zero dollar transaction, we never got a callback due so we 
could do none of those things. We had to manually list the products and 
update the user's dashboard for the successful transactions in that 
scenario.


To avoid creating a situation in the future where there would have to be 
tedious and error-prone manual processing, we recommended to the client 
that they don't offer "free initial period" promotions but instead 
charge some nominal amount, even if it's one cent. "All listings one 
cent" doesn't have quite the same impact as "Free listings" even though 
for all intents and purposes, it's the same thing. We've discovered many 
other limitations like that, small and large, that really makes the case 
for API-level integration, in which case you'd have to go through a PCI 
compliance audit. By the way, we've been through it multiple times. For 
the most part, it's perfunctory.

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



Re: Payment Gateways

2011-03-08 Thread David Zhou
I use Braintree, and it's been great.

-- dz



On Tue, Mar 8, 2011 at 4:40 PM, CLIFFORD ILKAY
 wrote:
> On 03/08/2011 09:59 AM, Bill Freeman wrote:
>>
>> And I can't resist recommending solutions that don't require your to touch
>> the credit card number.  If you never had it, you can't be responsible for
>> compromising it.
>
> That is true. Most of the payment processors have some sort of hosted form
> solution for that. However, there are significant limitations in those
> hosted form solutions that may make them unsuitable in some situations. For
> instance, we ran into one such limitation recently on a project where the
> processor apparently doesn't provide any sort of "success" or "failure"
> notification for zero dollar transactions. Why would you want a zero dollar
> transaction you might be wondering? Our client was running a promotion where
> some initial period was free after which the normal recurring fees would
> kick in. Normally, there is an initial fee and recurring fees. Upon success
> or failure on the normal initial fee, we'd get a callback to a view function
> from the payment gateway which we'd need to complete the transaction.
> Completion of the transaction consists of listing the product and updating
> the user's dashboard with the transaction date and the expiry date for the
> listing. With the zero dollar transaction, we never got a callback due so we
> could do none of those things. We had to manually list the products and
> update the user's dashboard for the successful transactions in that
> scenario.
>
> To avoid creating a situation in the future where there would have to be
> tedious and error-prone manual processing, we recommended to the client that
> they don't offer "free initial period" promotions but instead charge some
> nominal amount, even if it's one cent. "All listings one cent" doesn't have
> quite the same impact as "Free listings" even though for all intents and
> purposes, it's the same thing. We've discovered many other limitations like
> that, small and large, that really makes the case for API-level integration,
> in which case you'd have to go through a PCI compliance audit. By the way,
> we've been through it multiple times. For the most part, it's perfunctory.
> --
> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Django and an indirect access to the database tables (over stored procedures calls for data retrieval and modification)

2011-03-08 Thread Vazir
Thanks Michael!
Probably I must be more specific. I mean, can I use all the Django
modeling stuff (since it's cool in forms and etc), but rewrite the
way, models interacts with DB - how they retrieve and update data from/
to DB? There is some examples via raw() for data selects, but nothing
about data updates. Any suggestions?

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



Re: custom django-admin commands naming convention

2011-03-08 Thread Marwan Al-Sabbagh
cool thanks,

Marwan

On Wed, Mar 9, 2011 at 12:14 AM, creecode  wrote:

> Hello Marwan,
>
> I don't know if it's common but for my needs it's a must!  :-)  I have
> several apps with custom management commands and I've taken to naming
> the commands like...
>
> my_app_name_my_custom_management_command_name.py
>
> If find it easier to read the command name if I separate each word
> with an underscore.  The names are fairly long but I'm not typing them
> into the terminal all that much.  Mostly called from cron or pulled up
> through my bash history.
>
> Toodle-looo..
> creecode
>
> On Mar 8, 12:02 am, Marwan Al-Sabbagh 
> wrote:
>
> > Our company has a number of teams
> > developing different apps and I didn't want the naming of the commands to
> be
> > a mess. Are there any recommendations for naming conventions of the
> > commands. Is it common for example to call the command appname_command to
> > make it clear which app is implementing which command. Any
> advice/experience
> > is welcome.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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