manytomany relations

2010-01-28 Thread CCC
hi,
I have two  models:user,group,and they are manytomany,
class User(model.Model):
 name = models.CharField(max_length=20)

class Group(models.Model):
 name = models.CharField(max_length=20)
 users = models.ManytoManyField(User)

now i want to get the  top ten users who have the groups
,thanks for advance!

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



Re: popup forms

2010-01-28 Thread andreas schmid
hi, yes it works perfectly :)

follow the steps on the turorial here

http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/

sometimes its not so clear where to put the code... if you have questions ill 
try to help you.

ill make a "more complete" tutorial on my blog soon. 


Bhaskar Gara wrote:
> Hi Andrew,  Do you have any luck on this. I need same functionality.
>
> On Nov 30 2009, 5:40 am, andreas schmid  wrote:
>   
>> Emily Rodgers wrote:
>>
>> 
>>> On Oct 13, 1:20 pm, andreas schmid  wrote:
>>>   
 thank you very much for pointing me to the right path!!
 ill try to understand the behaviour and report about my progress...
 
 Andrew Ingram wrote:
 
> I'm assuming you are doing this somewhere other than the admin, or in
> custom views, so I'll explain how the admin stuff works.
>   
> Basically, when you create thepopupwindowyou give it a name which
> can be used the uniquely identify the field that is using thepopup
> (some variant on the field id would be ideal). Your main page (not the
> popup) should also have a javascript function to be called after the
> new author is saved (in the case of django admin, this function is
> called dismissAddAnotherPopup and is in RelatedObjectLookup.js).
>   
> Now the clever part (which I had to hunt around for when I needed this
> functionality, you can find it around line 608 in
> django.contrib.admin.options.py), is that when you successfully save
> the new author, you return an HttpResponse that consists of nothing
> but a script tag that executes
> owner.yourFunctionName(window_name,new_object_id (in the case of the
> django admin this would be owner.dismissAddAnotherPopup), window_name
> is the unique identifier you passed in originally.
>   
> This causes the browser to execute the function in the ownerwindow
> (the one that created thepopup) with the parameters you specified -
> which includes the ID of the new object. Django's code also provides
> the representation string of the object so it can be added to the
> select box.
>   
> Then you just make your JS function close thepopupwith 
> window_name.close().
>   
> I may not have explained it that well, but the key parts are in
> RelatedObjectLookup.js and options.py (near line 608).
>   
> I hope this helps.
>   
> - Andrew Ingram
>   
> 2009/10/13 nabucosound :
>   
>> This is the default behaviour in Django Admin, dude...
>> 
>> On Oct 13, 9:43 am, andreas schmid  wrote:
>> 
>>> hi,
>>>   
>>> how can i achieve a behaviour like in the admin backend where i can add
>>> a related object through apopupwindowand have it selectable after i
>>> saved the related form?
>>>   
>>> for example:
>>> im copleting the form book and i have to select the author but it doesnt
>>> exist yet... so i click on the + (add) button and apopupwindowappears
>>> where i create the editor object, and i can select it in the book form
>>> right after i saved and closed thispopupwindow.
>>>   
>>> can somebody point me to the code?
>>>   
>>> thank you in advance...
>>>   
>>> You might find this 
>>> helpful:http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/
>>>   
>>> Em
>>>   
>> the tutorial is nice but i cant get it really working. the problem is
>> that thepopupopens but i get a:
>>
>> TypeError at /popadd/topics/
>>
>> 'str' object is not callable
>>
>> Request Method: GET
>> Request URL:http://127.0.0.1:8000/de/popadd/topics/?_popup=1
>> Exception Type: TypeError
>> Exception Value:
>>
>> 'str' object is not callable
>>
>> Exception Location:
>> /home/pepe/DEV/FSlabs/parts/django/django/core/handlers/base.py in
>> get_response, line 92
>>
>> my views.projects ProjectForm:
>>
>> class ProjectForm(ModelForm):
>> topics   = ModelMultipleChoiceField(Topic.objects,
>> required=False, widget=MultipleSelectWithPop)
>> technologies = ModelMultipleChoiceField(Technology.objects,
>> required=False, widget=MultipleSelectWithPop)
>> class Meta:
>> model = Project
>> exclude = ['author']
>>
>> my views.handlePopAdd.py :
>>
>> from django.utils.html import escape
>> from django.contrib.auth.decorators import login_required
>>
>> from myapp.views.technologies import TechnologyForm
>> from myapp.views.topics import TopicForm
>>
>> def handlePopAdd(request, addForm, field):
>> if request.method == "POST":
>> form = addForm(request.POST)
>> if form.is_valid():
>> try:
>> newObject = fo

Re: v1.2a change in ModelAdmin: save_model not called by add_view

2010-01-28 Thread Ian
Bug tracking system says it was fixed two weeks ago in trunk
http://code.djangoproject.com/changeset/12206
 - referenced by http://code.djangoproject.com/ticket/12696

-- 
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 can a Django project name not start with a numeric

2010-01-28 Thread James Bennett
On Fri, Jan 29, 2010 at 12:39 AM, Delacroy Systems
 wrote:
> Why can a Django project name not start with a numeric? I would like
> my project name to be 1time.

Reading a good Python tutorial may be a good idea, since Python (the
programming language) doesn't support identifiers beginning with
numeric characters:

http://docs.python.org/reference/lexical_analysis.html#identifiers


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



Why can a Django project name not start with a numeric

2010-01-28 Thread Delacroy Systems
Why can a Django project name not start with a numeric? I would like
my project name to be 1time.

Even when I hack the system and manually update the settings.py file
for the desired project name, I have problems when I do a migrate with
South.

-- 
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: read only django admin

2010-01-28 Thread Ian
Despite the pedantic admonishments offered by others, there are use
cases for readonly fields beyond primary keys.  Metadata or implicit
data that really shouldn't be changed isn't a "trust" issue, it's
semantically different that application domain data. Anyway, I found
this code has some issues but the idea sound, see if it helps
http://bitbucket.org/stephrdev/django-readonlywidget/

On Jan 28, 6:55 pm, zweb  wrote:
> Is it possible to have a read only django admin, ie user cannot add,
> delete or update. User can only view data.
>
> or may be one user can be view only and other user has add/delete /
> update as well in Django admin.
>
> 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-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 evolution issue

2010-01-28 Thread Delacroy Systems
Thanks alot, I've now started using South.

On Jan 29, 12:57 am, Shawn Milochik  wrote:
> The author of Django-evolution has stated (including at DjangoCon 2009) that 
> South is the best solution for this problem.
> Django-evolution is unsupported and not under active development (unless 
> someone has forked it and I'm unaware).
>
> http://south.aeracode.org/
> I'd be happy to help you get South working, if you end up needing help.
>
> 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.



v1.2a change in ModelAdmin: save_model not called by add_view

2010-01-28 Thread Ian
I have an hook in a v1.1.1 admin app that sets some default values
when adding an object - it works by overriding ModelAdmin.save_model

Well, I just tried it with v1.2a and it fails, it looks like the call
to save_model that preceded the calls to save_formset was removed.
Without save_model, is there a replacement hook available to populate
the model with data from the request before it's saved?

-- 
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: read only django admin

2010-01-28 Thread Mike Ramirez
On Thursday 28 January 2010 21:04:15 chefsmart wrote:
> >admin is not for ordinary users who you do not trust to mess up the data.
> 
> Whether you provide such functionality outside of the admin or inside
> it, you are using the same django.contrib.auth, so "trust" is not the
> reason why you cannot do what you want to do within
> django.contrib.admin. If the permissions system cannot be "trusted",
> then it shouldn't be part of the django release. In all likelihood,
> the original poster zweb can do what he/she wants to do without
> compromising the system.
> 
> Django developers wouldn't have relied on permissions in the admin
> section if it weren't solid enough.
> 

It's none of this, it's all design philosophies, everyone trying to exert 
their own

Alot of people think the admin section is for admins, not arbitrary data 
updates from users and provide generic crud views for users. Others think 
users and admin should be able to do everything within the admin panel becaue 
it's there. Some hardcore folks can say f**k the admin panel and build their 
own from scratch, others may just do direct db inserts using some db tool 
(like pgadmin3). 

How it's done is upto the developer in question. But expect answers that say 
"you're doing it wrong cause that's not how I do it." Because no one 
understands that my choice may not be your choice.

*remembers first time I asked about the admin panel in irc and someone tried 
to convince me the admin panel was for database administrators, not site 
admins.*

Mike

-- 
A lawyer named Strange was shopping for a tombstone.  After he had
made his selection, the stonecutter asked him what inscription he
would like on it.  "Here lies an honest man and a lawyer," responded the
lawyer.
"Sorry, but I can't do that," replied the stonecutter.  "In this
state, it's against the law to bury two people in the same grave.  However,
I could put ``here lies an honest lawyer'', if that would be okay."
"But that won't let people know who it is" protested the lawyer.
"Certainly will," retorted the stonecutter.  "people will read it
and exclaim, "That's Strange!"


signature.asc
Description: This is a digitally signed message part.


Re: Reg. Improving Django response time (i.e throughput)

2010-01-28 Thread Graham Dumpleton


On Jan 29, 3:57 pm, chefsmart  wrote:
> When you say "It is taking plenty of time to load Django initially",
> what exactly do you mean?

Good question, because depending on what hosting mechanism you are
using and how you configure it, Django itself can be lazily loaded on
first request, albeit that shouldn't take minutes. If however you are
silly enough to use Apache mod_python or mod_wsgi (embedded mode) and
first page issues lots of sub requests, all those may go to distinct
Apache processes and so every sub request will also incur startup
cost. For a complex page this may causes first page to load to take
some time.

So, question is for OP is whether you have determined for sure whether
this is a database issue or whether it is because of how you are
trying to host it.

Graham

> What does initially mean here? Are you
> trying to reverse engineer your db using Django's inspectdb?
>
> Regards.
>
> On Jan 29, 1:53 am, Saravanan  wrote:
>
>
>
> > I have Django installed in SUSE Linux with postgres. It is working
> > great. Kudos
> > I have an issue. I have total database structure containing more than
> > 100million rows. I have partitions and indexes. It is taking plenty of
> > time to load Django initially. I meant in minutes. I can take a coffee
> > break and a short workout schedule. Is there any ideas/links and other
> > resources to speed up the response time (Throughput)
> > For you information, I am looking at Cache and DB tunning. Any other
> > tricks with Django, anything you are familiar with it?

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



Re: read only django admin

2010-01-28 Thread chefsmart
>admin is not for ordinary users who you do not trust to mess up the data.

Whether you provide such functionality outside of the admin or inside
it, you are using the same django.contrib.auth, so "trust" is not the
reason why you cannot do what you want to do within
django.contrib.admin. If the permissions system cannot be "trusted",
then it shouldn't be part of the django release. In all likelihood,
the original poster zweb can do what he/she wants to do without
compromising the system.

Django developers wouldn't have relied on permissions in the admin
section if it weren't solid enough.

Regards.

On Jan 29, 9:38 am, Kenneth Gonsalves  wrote:
> On Friday 29 Jan 2010 10:01:15 am chefsmart wrote:
>
> > > The Django administrative interface is there to allow administrative
> > > users to administer data.
>
> > But yes, you can do what you want if you use the permissions system
> > together with the groups system correctly. That is, create groups and
> > then assign whatever permissions you need to those groups. Then create
> > users and assign your users to the groups you created earlier.
>
> but as already mentioned it goes against the basic philosophy behind the admin
> - admin is not for ordinary users who you do not trust to mess up the data.
> --
> regards
> Kenneth Gonsalves
> Senior Project Officer
> NRC-FOSShttp://nrcfosshelpline.in/web/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Reg. Improving Django response time (i.e throughput)

2010-01-28 Thread chefsmart
When you say "It is taking plenty of time to load Django initially",
what exactly do you mean? What does initially mean here? Are you
trying to reverse engineer your db using Django's inspectdb?

Regards.

On Jan 29, 1:53 am, Saravanan  wrote:
> I have Django installed in SUSE Linux with postgres. It is working
> great. Kudos
> I have an issue. I have total database structure containing more than
> 100million rows. I have partitions and indexes. It is taking plenty of
> time to load Django initially. I meant in minutes. I can take a coffee
> break and a short workout schedule. Is there any ideas/links and other
> resources to speed up the response time (Throughput)
> For you information, I am looking at Cache and DB tunning. Any other
> tricks with Django, anything you are familiar with it?

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



Re: read only django admin

2010-01-28 Thread Kenneth Gonsalves
On Friday 29 Jan 2010 10:01:15 am chefsmart wrote:
> > The Django administrative interface is there to allow administrative
> > users to administer data.
> 
> But yes, you can do what you want if you use the permissions system
> together with the groups system correctly. That is, create groups and
> then assign whatever permissions you need to those groups. Then create
> users and assign your users to the groups you created earlier.
> 

but as already mentioned it goes against the basic philosophy behind the admin 
- admin is not for ordinary users who you do not trust to mess up the data.
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

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

2010-01-28 Thread chefsmart
> The Django administrative interface is there to allow administrative
> users to administer data.

But yes, you can do what you want if you use the permissions system
together with the groups system correctly. That is, create groups and
then assign whatever permissions you need to those groups. Then create
users and assign your users to the groups you created earlier.

Regards.

On Jan 29, 8:03 am, James Bennett  wrote:
> On Thu, Jan 28, 2010 at 8:55 PM, zweb  wrote:
> > Is it possible to have a read only django admin, ie user cannot add,
> > delete or update. User can only view data.
>
> > or may be one user can be view only and other user has add/delete /
> > update as well in Django admin.
>
> The Django administrative interface is there to allow administrative
> users to administer data.
>
> If you'd like a non-administrative interface to allow
> non-administrative users to not administer data, you might want to
> look into generic views.
>
> --
> "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: programming error - looking for an integer and finding a dict

2010-01-28 Thread Kenneth Gonsalves
On Friday 29 Jan 2010 8:36:06 am Kenneth Gonsalves wrote:
> I have a model called Matchentry. It is this:
> 
> class Matchentry(models.Model):
> tournament = models.ForeignKey(Tournament,verbose_name=_("Tournament"))
> player = models.ForeignKey(Player,verbose_name=_("Player"))
> 
> class Meta:
> unique_together = ("tournament", "player")
> 
> def __unicode__(self):
> return u"%s: %s" %(self.player,self.tournament)
> 
> using ModelForm, I get this error:
> 
> ERROR:  invalid input syntax for integer: " u'csrfmiddlewaretoken': [u'8ba1dfc67c7bb739f8cf31e7566b3ef9'],
>  u'tournament':  [u'1'], u'save': [u'Save']}>"
> 

solved - stupid mistake, when overriding __init__ for the Matchentryform, put 
the variables in the wrong order.
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

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



programming error - looking for an integer and finding a dict

2010-01-28 Thread Kenneth Gonsalves
hi

I have a model called Matchentry. It is this:

class Matchentry(models.Model):
tournament = models.ForeignKey(Tournament,verbose_name=_("Tournament"))
player = models.ForeignKey(Player,verbose_name=_("Player"))

class Meta:
unique_together = ("tournament", "player")

def __unicode__(self):
return u"%s: %s" %(self.player,self.tournament)

using ModelForm, I get this error:

ERROR:  invalid input syntax for integer: ""

SELECT "web_matchentry"."id", "web_matchentry"."tournament_id", 
"web_matchentry"."player_id" FROM "web_matchentry" WHERE 
"web_matchentry"."tournament_id" = '' 
I cannot understand why it is not extracting the tournament_id. The full 
traceback is here:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/addmatchentry/1/
Django Version: 1.2 alpha 1 SVN-12288
Python Version: 2.6.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'memootygolf.web']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.6/django/core/handlers/base.py" in get_response
  101. response = callback(request, *callback_args, 
**callback_kwargs)
File "/usr/lib/python2.6/django/utils/decorators.py" in __call__
  36. return self.decorator(self.func)(*args, **kwargs)
File "/usr/lib/python2.6/django/contrib/auth/decorators.py" in _wrapped_view
  24. return view_func(request, *args, **kwargs)
File "/home/lawgon/memootygolf/../memootygolf/web/views.py" in addmatchentry
  599. form = Matchentryform(request.POST,instance=instance)
File "/home/lawgon/memootygolf/../memootygolf/web/views.py" in __init__
  575. for x in self.tr:
File "/usr/lib/python2.6/django/db/models/query.py" in _result_iter
  104. self._fill_cache()
File "/usr/lib/python2.6/django/db/models/query.py" in _fill_cache
  755. self._result_cache.append(self._iter.next())
File "/usr/lib/python2.6/django/db/models/query.py" in iterator
  267. for row in compiler.results_iter():
File "/usr/lib/python2.6/django/db/models/sql/compiler.py" in results_iter
  619. for rows in self.execute_sql(MULTI):
File "/usr/lib/python2.6/django/db/models/sql/compiler.py" in execute_sql
  674. cursor.execute(sql, params)
File "/usr/lib/python2.6/django/db/backends/util.py" in execute
  19. return self.cursor.execute(sql, params)
File "/usr/lib/python2.6/django/db/backends/postgresql/base.py" in execute
  53. return self.cursor.execute(smart_str(sql, self.charset), 
self.format_params(params))

Exception Type: ProgrammingError at /addmatchentry/1/
Exception Value: ERROR:  invalid input syntax for integer: ""

SELECT "web_matchentry"."id", "web_matchentry"."tournament_id", 
"web_matchentry"."player_id" FROM "web_matchentry" WHERE 
"web_matchentry"."tournament_id" = '' 


-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

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

2010-01-28 Thread James Bennett
On Thu, Jan 28, 2010 at 8:55 PM, zweb  wrote:
> Is it possible to have a read only django admin, ie user cannot add,
> delete or update. User can only view data.
>
> or may be one user can be view only and other user has add/delete /
> update as well in Django admin.

The Django administrative interface is there to allow administrative
users to administer data.

If you'd like a non-administrative interface to allow
non-administrative users to not administer data, you might want to
look into generic views.


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



read only django admin

2010-01-28 Thread zweb
Is it possible to have a read only django admin, ie user cannot add,
delete or update. User can only view data.

or may be one user can be view only and other user has add/delete /
update as well in Django admin.

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-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: Select *Latest* Grade Information for every Student

2010-01-28 Thread marsanyi
The joy of annotate().  In Django 1.1 and above:

result = Student.objects.annotate(latest = models.Max('grades__date'))

gives you the recordset, sans test_name.  Any advances on this?

On Jan 28, 1:57 pm, Michael Shepanski  wrote:
> Is it possible to code this scenario using the Django ORM?
>
> I have two tables:
>   STUDENT: id, name, address
>   GRADES: id, student_id, date, test_name, grade
>
> Each Student will have several entries in the Grades table. I am
> wondering if it is possible using Django's ORM to select all students
> along with their *latest* grade information. I basically want a result
> table that looks like the following, where date, test_name, and grade
> are for the latest result (by date).
>
> LATEST_GRADES: id, name, address, date, test_name, grade

-- 
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: popup forms

2010-01-28 Thread Bhaskar Gara
Hi Andrew,  Do you have any luck on this. I need same functionality.

On Nov 30 2009, 5:40 am, andreas schmid  wrote:
> Emily Rodgers wrote:
>
> > On Oct 13, 1:20 pm, andreas schmid  wrote:
>
> >> thank you very much for pointing me to the right path!!
> >> ill try to understand the behaviour and report about my progress...
>
> >> Andrew Ingram wrote:
>
> >>> I'm assuming you are doing this somewhere other than the admin, or in
> >>> custom views, so I'll explain how the admin stuff works.
>
> >>> Basically, when you create thepopupwindowyou give it a name which
> >>> can be used the uniquely identify the field that is using thepopup
> >>> (some variant on the field id would be ideal). Your main page (not the
> >>>popup) should also have a javascript function to be called after the
> >>> new author is saved (in the case of django admin, this function is
> >>> called dismissAddAnotherPopup and is in RelatedObjectLookup.js).
>
> >>> Now the clever part (which I had to hunt around for when I needed this
> >>> functionality, you can find it around line 608 in
> >>> django.contrib.admin.options.py), is that when you successfully save
> >>> the new author, you return an HttpResponse that consists of nothing
> >>> but a script tag that executes
> >>> owner.yourFunctionName(window_name,new_object_id (in the case of the
> >>> django admin this would be owner.dismissAddAnotherPopup), window_name
> >>> is the unique identifier you passed in originally.
>
> >>> This causes the browser to execute the function in the ownerwindow
> >>> (the one that created thepopup) with the parameters you specified -
> >>> which includes the ID of the new object. Django's code also provides
> >>> the representation string of the object so it can be added to the
> >>> select box.
>
> >>> Then you just make your JS function close thepopupwith 
> >>> window_name.close().
>
> >>> I may not have explained it that well, but the key parts are in
> >>> RelatedObjectLookup.js and options.py (near line 608).
>
> >>> I hope this helps.
>
> >>> - Andrew Ingram
>
> >>> 2009/10/13 nabucosound :
>
>  This is the default behaviour in Django Admin, dude...
>
>  On Oct 13, 9:43 am, andreas schmid  wrote:
>
> > hi,
>
> > how can i achieve a behaviour like in the admin backend where i can add
> > a related object through apopupwindowand have it selectable after i
> > saved the related form?
>
> > for example:
> > im copleting the form book and i have to select the author but it doesnt
> > exist yet... so i click on the + (add) button and apopupwindowappears
> > where i create the editor object, and i can select it in the book form
> > right after i saved and closed thispopupwindow.
>
> > can somebody point me to the code?
>
> > thank you in advance...
>
> > You might find this 
> > helpful:http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/
>
> > Em
>
> the tutorial is nice but i cant get it really working. the problem is
> that thepopupopens but i get a:
>
>     TypeError at /popadd/topics/
>
>     'str' object is not callable
>
>     Request Method:     GET
>     Request URL:    http://127.0.0.1:8000/de/popadd/topics/?_popup=1
>     Exception Type:     TypeError
>     Exception Value:    
>
>     'str' object is not callable
>
>     Exception Location:    
>     /home/pepe/DEV/FSlabs/parts/django/django/core/handlers/base.py in
>     get_response, line 92
>
> my views.projects ProjectForm:
>
>     class ProjectForm(ModelForm):
>         topics       = ModelMultipleChoiceField(Topic.objects,
>     required=False, widget=MultipleSelectWithPop)
>         technologies = ModelMultipleChoiceField(Technology.objects,
>     required=False, widget=MultipleSelectWithPop)
>         class Meta:
>             model = Project
>             exclude = ['author']
>
> my views.handlePopAdd.py :
>
>     from django.utils.html import escape
>     from django.contrib.auth.decorators import login_required
>
>     from myapp.views.technologies import TechnologyForm
>     from myapp.views.topics import TopicForm
>
>     def handlePopAdd(request, addForm, field):
>         if request.method == "POST":
>             form = addForm(request.POST)
>             if form.is_valid():
>                 try:
>                     newObject = form.save()
>                 except forms.ValidationError, error:
>                     newObject = None
>                 if newObject:
>                     return HttpResponse('     type="text/javascript">opener.dismissAddAnotherPopup(window, "%s",
>     "%s");' % \
>                         (escape(newObject._get_pk_val()),
>     escape(newObject)))
>
>         else:
>             form = addForm()
>
>         pageContext = {'form': form, 'field': field}
>         return render_to_response("add/popadd.html", pageContext)
>
>     @login_required
>     def newTopic(request):
>         return handlePopAdd(request, TopicForm, 'topics')
>
>     @login_required
>     def newTechnology(reques

Re: Select *Latest* Grade Information for every Student

2010-01-28 Thread David
In SQL, this would be (and I'm winging this right now so I might be
slightly off)

SELECT name, address, `date`, test_name, grade
FROM Student as stu
LEFT JOIN Grade ON stu.id = Grade.student_id
WHERE `date` >=
(SELECT max(`date`) FROM Grade WHERE student_id = stu.id)
ORDER BY name

Unless you have an extremely large amount of students you're filtering
on I'd use the following:

for s in Students.objects.order_by('name'):
grades = Grade.objects.filter(student_id=s.id).order_by('-date')[:
1]
if len(grades) > 0:
# use the grades object to print the latest grade
pass
else:
# there is no grade for this student
pass

I'd have to investigate whether the ORM will optimize this, but I
doubt it does (currently). It's possible there is a better way, but I
don't know of one without resorting to SQL.







On Jan 28, 1:57 pm, Michael Shepanski  wrote:
> Is it possible to code this scenario using the Django ORM?
>
> I have two tables:
>   STUDENT: id, name, address
>   GRADES: id, student_id, date, test_name, grade
>
> Each Student will have several entries in the Grades table. I am
> wondering if it is possible using Django's ORM to select all students
> along with their *latest* grade information. I basically want a result
> table that looks like the following, where date, test_name, and grade
> are for the latest result (by date).
>
> LATEST_GRADES: id, name, address, date, test_name, grade

-- 
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: Empty categories

2010-01-28 Thread phred78
Thank you Eugene, but it's still listing the empty categories :(

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

2010-01-28 Thread Shawn Milochik
Try typing 'python' (or the full path to your Python executable) before 
django-admin.py.

I'm guessing you're using Windows, and it's associating .py files with a text 
editor instead of the Python interpreter.

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.



Select *Latest* Grade Information for every Student

2010-01-28 Thread Michael Shepanski
Is it possible to code this scenario using the Django ORM?

I have two tables:
  STUDENT: id, name, address
  GRADES: id, student_id, date, test_name, grade

Each Student will have several entries in the Grades table. I am
wondering if it is possible using Django's ORM to select all students
along with their *latest* grade information. I basically want a result
table that looks like the following, where date, test_name, and grade
are for the latest result (by date).

LATEST_GRADES: id, name, address, date, test_name, grade

-- 
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: Brief tutorial to get a django dev server up.

2010-01-28 Thread Aly
Hello,
I've just instaled Django with this tutorial
http://i.justrealized.com/2008/04/08/how-to-install-python-and-django-in-windows-vista/.

My problem is when I execute django-admin.py startproject mysite , the
folder is not created, and the file django-admin.py is opened. What is
the problem?

I really need help, please.

Thanks in advance





On 11 ene, 22:54, spike  wrote:
> This is just a brief tutorial I wrote for myself without the intention
> of releasing, but I figure if I can help just 1 person get started,
> then why keep it to myself.
>
> Again, not to be passed off as anything more then notes I wrote one
> afternoon for my own understanding on a Windows machine.
>
> Hope this helps someone. Comments ARE welcome.
>
> ---
> When creating a project you’ll want to link it to a database. So
> we'll, install Python, then Django, then the database. Create the
> project, setup the database, then launch the development server. For
> ease we’ll go with SQLite.
>
> Django requires Python 2.3 or higher.
>
> Install Python. When the installation is complete, add Python to the
> system path so that it can be accessed from the command prompt. To do
> this access “Control Panel > System > Advanced > Environment
> Variables”. Select the “path” from the “System Variables” section and
> append the Python installation directory.
>
> Download and extract Django to the “C:\”. Then in the command prompt,
> “cd” to the extracted directory.
>
> To install Django run “(Django Directory) python setup.py install” or
> to manually install, copy the Django folder to the Lib > site-packages
> directory inside the Python directory.
>
> The last step to install, copydjango-admin.py from “(Django
> Directory) > django > bin” to either c:\ or the Python directory.
> After completed you will want to test the installation by running “c:
> \>pythondjango-admin.py --version”.
>
> Django supports many database systems like MySQL, PostgreSQL, and
> SQLite. Django has a database layer, which will interact with any
> supported & selected database.
>
> Python 2.5 or later comes with the SQLite module named, “sqlite3”.
> SQLite stores the database in a single file.
> To use MySQL you must install the MySQL driver, which is titled
> “MySQLdb”.
>
> Django comes with its own preconfigured webserver but does support
> Apache and Lighttpd.
>
> Now, to create a new project, run “django-admin.pystartproject
> (project title)”.
> This command will create a folder named after the project title you
> entered. Inside this folder will be 4 files: __init__.py, manage.py,
> settings.py and urls.py. The file functions are as follows:
> i.      __init__.py: This file tells python to treat this folder as a
> package.
> ii.     manage.py: This is the project admin file, similar todjango-admin.py. 
> So similar in fact they share the same code.
> iii.    settings.py: The main configuration file. Includes your database
> settings, site language and Django features as well as more advanced
> functions.
> iv.     urls.py: Configuration file. Maps the URLs with the Python
> functions that handle them.
>
> Open settings.py and set the database with “DATABASE_ENGINE”. For
> SQLite enter “sqlite3”.
>
> Next, name the database with “DATABASE_NAME”. Name it after your
> project with “db” at the end. Example: “bookmarksdb”. Now save your
> file.
>
> Almost done. Cd into the project directory then tell Django to create
> tables for the database with the command “python manage.py syncdb”.
>
> Create your Superuser account. This process will create the file
> titled after the database name. This file holds the application data.
>
> Now run the development server with “python manage.py runserver”. You
> can also change the default port from 8000 by appending your desired
> port to the command.
>
> Open your browser tohttp://127.0.0.1:8000/
>
> Done.
> ---

-- 
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 evolution issue

2010-01-28 Thread Shawn Milochik
The author of Django-evolution has stated (including at DjangoCon 2009) that 
South is the best solution for this problem.
Django-evolution is unsupported and not under active development (unless 
someone has forked it and I'm unaware).

http://south.aeracode.org/
I'd be happy to help you get South working, if you end up needing help.

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: Strange 301 error, please save me!!!

2010-01-28 Thread cootetom
Hello,

403 is a forbidden error. 301 is a resource moved error. In order to
serve your web site to multiple machines you really need to install
Apache. The development server is used for development and is pretty
unstable for multiple users. Have a read about installing Apache for a
local intranet, I assume it's a local network you're wanting here. If
you're after access over the internet then you need a dedicated server
or some kind of shared hosting for your site.

- Tom




On Jan 28, 9:23 am, james ahn  wrote:
> Hi there.
>
> Recently i just downloaded django, and try to learn how to use it..
>
> I belive that django is a good web framework!!!.
>
> Here is a my problem...
>
> i create a web site with django and google appengine on my local
> machine
>
> 1. copied web site to another machine, but it does not  work, just
> show 301 error
>
>  i installed python and simply copied whole directory to new machine.
>
>  running the web site has no problem, but when i try to open the web,
> python console shows
>
> "Info : root : "get http/1.1" 301 -
>
> what is wrong?
>
> 2. i want to let other users access to the web site which i am
> developing & running on my local machine.
>
> for example, on my machine, i open my web site like this "http://
> 192.168.0.2:8080"
>
> it work!!!, but when i try same thing on different machine,
>
> "http://192.168.0.2:8080";,
>
> http 403 error i got.
>
> please help me, i should solve this problem ASAP!!!
>
> thanks in advance
>
> James

-- 
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: I can't get Auth and Sites to show in my Admin Site

2010-01-28 Thread Gabe
Later I discovered also that the code was there in stubbed out version
of the urls.py file just the commented out code was a light gray color
that faded into the background.

Lesson learned is that when dealing with generated code, read all the
comments closely.

-- 
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: I can't get Auth and Sites to show in my Admin Site

2010-01-28 Thread Gabe
I researched further and found the answer to my question.

If your admin application does not show Auth and Sites and it's in
your INSTALLED_APPS tuple on your settings.py

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite2.blog',
'django.contrib.admin',
)

Make sure that your urls.py has the admin.autodiscover() declared
under the import statements.

And bingo all the apps that should show will show.

from django.conf.urls.defaults import *
from django.contrib import admin
from mysite2.blog.views import archive
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^mysite2/', include('mysite2.foo.urls')),

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

# Uncomment the next line to enable the admin:
 (r'^admin/', include(admin.site.urls)),
 (r'^$', archive),
)

-- 
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 evolution issue

2010-01-28 Thread Delacroy Systems
Hi,

I am struggling to understand why Django Evolution is throwing this -
so I don't know what to fix:

Traceback (most recent call last):
  File "manage.py", line 11, in  execute_manager(settings)
  File "c:\python25\Lib\site-packages\django\core\management
\__init__.py", line 362, in execute_manager utility.execute()
  File "c:\python25\Lib\site-packages\django\core\management
\__init__.py", line 303, in execute self.fetch_command
(subcommand).run_from_argv(self.argv)
  File "c:\python25\Lib\site-packages\django\core\management\base.py",
line 195, in run_from_argv  self.execute(*args, **options.__dict__)
  File "c:\python25\Lib\site-packages\django\core\management\base.py",
line 222, in execute output = self.handle(*args, **options)
  File "c:\python25\Lib\site-packages\django_evolution\management
\commands\evolve.py", line 87, in handle hinted_evolution =
diff.evolution()
  File "c:\python25\Lib\site-packages\django_evolution\diff.py", line
197, in evolution changed_attrs[prop] = current_field_sig.get(prop,
ATTRIBUTE_DEFAULTS[prop])
KeyError: 'field_type'

-- 
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: Reg. Improving Django response time (i.e throughput)

2010-01-28 Thread cootetom
This might be of interest to you 
http://codysoyland.com/2010/jan/17/evaluating-django-caching-options/




On Jan 28, 8:53 pm, Saravanan  wrote:
> I have Django installed in SUSE Linux with postgres. It is working
> great. Kudos
> I have an issue. I have total database structure containing more than
> 100million rows. I have partitions and indexes. It is taking plenty of
> time to load Django initially. I meant in minutes. I can take a coffee
> break and a short workout schedule. Is there any ideas/links and other
> resources to speed up the response time (Throughput)
> For you information, I am looking at Cache and DB tunning. Any other
> tricks with Django, anything you are familiar with it?

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



Re: Extend model choice in project

2010-01-28 Thread Delacroy Systems
I have the choices in a model. I want it this way so that the choices
can be managed from the admin console. I have this code in models.py.

class StatusChoices(models.Model):
choice = models.CharField(max_length=10)  #Actual value that
is saved
description = models.CharField(max_length=10) #Human readable
value. Options are Active/Inactive
value = models.IntegerField(max_length=6) #Field to allocate
weights to the values

class Meta:
   pass

def __unicode__(self):
   return self.choice

STATUS_CHOICES = (StatusChoices.objects.values_list('choice',
'description')) #Return a tuple of choices


On Jan 22, 5:09 pm, Daniel Roseman  wrote:
> On Jan 22, 2:33 pm, Thomas Guettler  wrote:
>
> > Hi,
>
> > in my app I have this:
>
> > class FooModel(models.Model):
> >     example=models.SmallIntegerField(choices=[(1, u'one'),
> >                                               (2, u'two'),
> >                                               ...]
>
> > I want to extend thechoicesat project level. Where
> > should I put the code?
>
> >   Thomas
>
> Perhaps put the choice list in settings.py, and import it from there
> in your models.py?
> --
> 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: Reg. Improving Django response time (i.e throughput)

2010-01-28 Thread Doug Blank
On Thu, Jan 28, 2010 at 3:53 PM, Saravanan wrote:

> I have Django installed in SUSE Linux with postgres. It is working
> great. Kudos
> I have an issue. I have total database structure containing more than
> 100million rows. I have partitions and indexes. It is taking plenty of
> time to load Django initially. I meant in minutes. I can take a coffee
> break and a short workout schedule. Is there any ideas/links and other
> resources to speed up the response time (Throughput)
> For you information, I am looking at Cache and DB tunning. Any other
> tricks with Django, anything you are familiar with it?
>

The first thing you should look at is what queries are being run. You might
be running too many queries, or it might be that you need to add some
indexes to your database. Try looking at django-toolbar. The fact that you
have 100 million rows shouldn't really matter.

-Doug


>
> --
> 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: Updating a user/profile model object

2010-01-28 Thread Jonathan Roberts
> You're posting your update to a different view from the one that
> initially displays the form. The usual way to do this is to have the
> form post back to the same view, but have an 'if request.POST' to
> branch the execution. The main forms documentation explains the
> standard flow.

Ah I did see that, but I was planning on having a number of forms on
the same page and wasn't sure it would work if I left it as is?
>
> The main problem, though, is that you're not passing the instance into
> the form when you instantiate on post, so as you say the form creates
> a new instance. You just need to get the profile (that's where it
> makes sense to use the same view for display and post) and pass it in
> just as you do in the other view:
>    form = OrganisationForm(request.POST, instance=organisation)

Great, that fixed it in my separate view, so thanks for the tip! I'll
give it some more thought as to whether or not to go back to having it
in a single view or not.

Again, many thanks :)

Jon

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



Reg. Improving Django response time (i.e throughput)

2010-01-28 Thread Saravanan
I have Django installed in SUSE Linux with postgres. It is working
great. Kudos
I have an issue. I have total database structure containing more than
100million rows. I have partitions and indexes. It is taking plenty of
time to load Django initially. I meant in minutes. I can take a coffee
break and a short workout schedule. Is there any ideas/links and other
resources to speed up the response time (Throughput)
For you information, I am looking at Cache and DB tunning. Any other
tricks with Django, anything you are familiar with it?

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



Re: Project based permissions - best way to implement?

2010-01-28 Thread Stodge
I thought there might be a way to store the site ID in request.session
and then hack its value into settings.SITE_ID, but that doesn't work.
I have to set SITE_ID = -1 in settings.py and this value is always
loaded by the Sites framework, my hacked value is ignore. It was worth
a try!

On Jan 28, 1:15 pm, Stodge  wrote:
> I'm prototyping ideas for a project management tool. It supports
> multiple projects per site, but I'm not sure how to define permissions
> on a per project basis. Currently I have:
>
> class Project(models.Model):
>
>         title = models.CharField(max_length=128)
>         description = models.TextField()
>         members = models.ManyToManyField(User, through='Membership')
>
>         class Meta:
>                         permissions = (
>                                 ("is_member", "Is a member"),
>                         )
>
> class Membership(models.Model):
>         user = models.ForeignKey(User)
>         project = models.ForeignKey(Project)
>         role = models.CharField(max_length=120)
>
> This is fine except I want to re-use Django's permissions. But I can't
> see how to do this as the permissions table is rebuilt when the DB is
> resyncedd so there's no guarantee that the ID of a particular
> permission is consistent. Or is this a non-issue? Any ideas on the
> best way to implement this?
>
> I also considered using the Sites feature, where a site is basically a
> project, but I want users to be able to creates projects via the web
> interface, so creating a new settings.py file isn't too realistic.
>
> Comments welcome. 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.



Defining the queryset admin pages use for ForeignKey or ManyToMany fields

2010-01-28 Thread Walt
It seems like this should be possible, and this is the closest,
simplest
solution I can find in the documentation:

class InvoiceAdmin(admin.ModelAdmin):

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "books":
kwargs["queryset"] = Book.objects.filter(sold=False)
return db_field.formfield(**kwargs)
return super(InvoiceAdmin, self).formfield_for_foreignkey
(db_field, request, **kwargs)

But this does not work at all. I need to do this in many places
for a number of different forms, so it would be nice to be able
to specify the queryset for ForeignKey fields in a form without
completely recreating the admin form pages.

Thanks!
Walt

-~

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



I can't get Auth and Sites to show in my Admin Site

2010-01-28 Thread Gabe
I'm reading "Python Web Develoment With Django" and I'm a total Django
Newbie, and a total Python Newbie but I've heard so many great things
about Django I had to try it.

I been following a long in the book.

I was able to get the Blog application in the book to show in the
Admin app web interface.

But I can't see Auth and Sites.

I generated the project: django-admin.py startproject 

Auth and Sites are in settings.py with no issues.

Something that the book did not tell me to do was in urls.py it didn't
tell me to import:

from django.contrib import admin

to get:  (r'^admin/', include(admin.site.urls)), to work.

But I did.

I checked my user in the database and is_superuser=1

Not sure where too look now.  Been searching on the web for a while
but no success in finding an answer as to why  Auth and Sites don't
show in the Admin app?

And how can I get them to show?

Any links/docs will be great.

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: Problem with Django webserver on HP

2010-01-28 Thread Kairam, Raj
Hi Karen,
 
Thanks for the quick reply.
It may be that my problems are due to some thing that happened at the
time of installing Django on my HP box.
After I issued the following command 
python setup.py install
Looked like it was going well but at the end I got these messages
running install_egg_info
error: invalid command 'install_egg_info'
Not knowing what to do, I continued on ..
 
Here is what I did and what I got ...
r...@m020cad2:/home/root/MyDjango/testproject> python manage.py
runserver 0.0
.0.0:8000
Validating models...
0 errors found
 
Django version 1.1.1, using settings 'testproject.settings'
Development server is running at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
I quit ... and saw the following..

Unhandled exception in thread started by 
Traceback (most recent call last):
  File
"/opt/ActivePython-2.6.4.8-hpux11.00-parisc/INSTALLDIR/lib/python2.6/sit
e-packages/django/core/management/commands/runserver.py", line 60, in
inner_run
run(addr, int(port), handler)
  File
"/opt/ActivePython-2.6.4.8-hpux11.00-parisc/INSTALLDIR/lib/python2.6/sit
e-packages/django/core/servers/basehttp.py", line 698, in run
httpd.serve_forever()
  File
"/opt/ActivePython-2.6.4.8-hpux11.00-parisc/INSTALLDIR/lib/python2.6/Soc
ketServer.py", line 224, in serve_forever
r, w, e = select.select([self], [], [], poll_interval)
select.error: (4, 'Interrupted system call')
 
It did not make any difference even when I used 127.0.0.1:8000
 
Please advise if the error while installing Django has anything to do
with me not being able to see the server not running properly.
 
Thanks
Raj   kair...@coned.com
 



From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of Karen Tracey
Sent: Thursday, January 28, 2010 1:34 PM
To: django-users@googlegroups.com
Subject: Re: Problem with Django webserver on HP


On Thu, Jan 28, 2010 at 1:12 PM, Kairam, Raj  wrote:


Core dump and nothing happening in the browser. 


Core dump is a Should Never Happen type of thing with Python, and likely
not due to any Django code, which is pure Python. 

An incompatible/broken C extension might cause it so my first thing to
check out would be whatever database adapter you are using -- what are
you using for a database? 

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.

-- 
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: Problem with Django webserver on HP

2010-01-28 Thread Karen Tracey
On Thu, Jan 28, 2010 at 1:12 PM, Kairam, Raj  wrote:

> Core dump and nothing happening in the browser.


Core dump is a Should Never Happen type of thing with Python, and likely not
due to any Django code, which is pure Python.

An incompatible/broken C extension might cause it so my first thing to check
out would be whatever database adapter you are using -- what are you using
for a database?

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: Problem with Django webserver on HP

2010-01-28 Thread Jorge Bastida
Note that the default IP address, 127.0.0.1, is not accessible from other
machines on your network. To make your development server viewable to other
machines on the network, use its own IP address (e.g. 192.168.2.1) or
0.0.0.0.

>From any other computer in your network the url will be server/yours ip.
http://server-ip:8000/


-- 
Benito Jorge Bastida
jo...@thecodefarm.com

thecodefarm SL
Av. Gasteiz 21, 1º Derecha
01008 Vitoria-Gasteiz
http://thecodefarm.com
Tel: (+34) 945 06 55 09

-- 
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: News about Geraldo Reports

2010-01-28 Thread Stodge
I can't visit your site from work anyway:

Reason/Raison:
The Websense category "Potentially Damaging Content" is filtered.


:P

On Jan 26, 3:42 am, Marinho Brandao  wrote:
> Hello people,
>
> I have good news :)
>
> I've done today the new website of Geraldo Reports [1].
>
> Geraldo is a tool to make business reports easy, that not necessarily
> will be PDF files. For a while it just supports PDF and TXT (for file
> and matrix printers), but in the future it will supports HTML, ODF,
> DOC, XLS, and whatever. It uses the power of ReportLab to make PDF
> files and uses also some things from its library.
>
> Geraldo doesn't competes with ReportLab, it is just more like Jasper
> or Crystal Reports, ok?
>
> The new website is more like a redesign of the old one, but we want to
> have cook book, code snippets and report templates repositories as
> soon as possible.
>
> We are near to announce the release 0.4 (maybe in 1 or 2 weeks), with
> the main features:
>
> - Caching
> - Additional fonts
> - Events system
> - "Native" charts (using ReportLab functions instead of third part libraries)
> - Cross reference tables
> - Bar codes
> - bugs fixes
>
> Most of these features are already available [2] on the git/svn
> repositories [3] and [4] and I'm using them on some projects.
>
> Another important information: I recently knew about a project named
> "django-reporting" [5], that makes summaries on the Admin (with no
> printing). It is a good tool but a customer mine would like print
> those summaries to PDF, so, I made some improvements on it to do it
> (and sent a patch). I'm trying to make contact the author to make this
> easier.
>
> The problem: Geraldo already had in their repositories a Django app to
> integrate Geraldo with Django's Admin.
>
> Solution: I probably will change the name of Geraldo's "reporting", do
> some newness I have on my machine, etc.
>
> But, to avoid confusion: django-reporting and Geraldo's "reporting"
> are separated things and have different goals.
>
> In the future, Geraldo will have the Reports Server, probably a
> pluggable app or a Tornado service (I'm not sure about that), to serve
> reports like a BI framework. It will get data from database connection
> (with SQL instructions) or NoSQL accessing or, at least, receive data
> as a webservice, and generate reports. The main goal is take easy the
> integration with other languages and take easy for end users. The
> ideas are in my mind, but will late a little.
>
> That's all. Help is very very welcome, whatever you can do to help.
>
> Best regards, speak soon :)
>
> [1]http://www.geraldoreports.org/
> [2]http://www.geraldoreports.org/docs/examples/index.html
> [3]http://www.geraldoreports.org/docs/examples/index.html
> [4]http://geraldo.svn.sourceforge.net/viewvc/geraldo/
> [5]http://code.google.com/p/django-reporting/
>
> --
> Marinho Brandão (José Mário)http://marinhobrandao.com/

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



Project based permissions - best way to implement?

2010-01-28 Thread Stodge
I'm prototyping ideas for a project management tool. It supports
multiple projects per site, but I'm not sure how to define permissions
on a per project basis. Currently I have:

class Project(models.Model):

title = models.CharField(max_length=128)
description = models.TextField()
members = models.ManyToManyField(User, through='Membership')

class Meta:
permissions = (
("is_member", "Is a member"),
)

class Membership(models.Model):
user = models.ForeignKey(User)
project = models.ForeignKey(Project)
role = models.CharField(max_length=120)


This is fine except I want to re-use Django's permissions. But I can't
see how to do this as the permissions table is rebuilt when the DB is
resyncedd so there's no guarantee that the ID of a particular
permission is consistent. Or is this a non-issue? Any ideas on the
best way to implement this?

I also considered using the Sites feature, where a site is basically a
project, but I want users to be able to creates projects via the web
interface, so creating a new settings.py file isn't too realistic.

Comments welcome. 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: Problem with Django webserver on HP

2010-01-28 Thread Kairam, Raj
Hi Jorge,
Thanks for the quick reply.
I did what you suggested.

r...@myhost:/home/root/MyDjango/testproject> python manage.py runserver 
0.0.0.0:8000
Validating models...
0 errors found

Django bersion 1.1.1, using settings 'testproject.settings'
Development server is running at http://0.0.0.0:8000/  
Quit the server with CONTROL-C.

Now, open Mozilla browser and enter http://0.0.0.0:8000/  
Facing the same problem. Core dump and nothing happening in the browser.
 
I noticed the following in the testproject directory.
-rw-rw-r--   1  root   sys  0   Jan 21  16:46  _init_.py
 
Please advise.
Rajkair...@coned.com





From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of Jorge Bastida
Sent: Thursday, January 28, 2010 12:38 PM
To: django-users@googlegroups.com
Subject: Re: Problem with Django webserver on HP


http://docs.djangoproject.com/en/dev/ref/django-admin/#runserver-port-or-ipaddr-port
 

Try with 
python manage.py runserver 0.0.0.0:8000


2010/1/28 rajk 



HP-UX B.11.00
Django-1.1.1

myhost:/home/root/MyPython> python
ActivePython 2.6.4.8 (ActiveState Software Inc.) based on
Python 2.6.4 (r264:75706, Nov 3 2009, 13:55:48) [C] on hp-ux11
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 1, 1, 'final', 0)
>>> exit()

r...@myhost:/home/root/MyDjango> cd testproject
r...@myhost:/home/root/MyDjango/testproject>ls
_init_.py  _init_.pyc  manage.py  settings.py  settings.pyc   urls.py
r...@myhost:/home/root/MyDjango/testproject> python manage.py
runserver
Validating models...
0 errors found

Django bersion 1.1.1, using settings 'testproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Now, open Mozilla browser and enter http://127.0.0.1:8000/

Here is the PROBLEM which some one from the user group can resolve for
me ..
Nothing happens in the browser
A core file is in the  r...@myhost:/home/root/MyDjango/testproject
directory

Please advise and help - Thanks,  kair...@coned.com

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






-- 
Benito Jorge Bastida
jo...@thecodefarm.com

thecodefarm SL
Av. Gasteiz 21, 1º Derecha
01008 Vitoria-Gasteiz
http://thecodefarm.com
Tel: (+34) 945 06 55 09


-- 
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: Empty categories

2010-01-28 Thread Eugene Wee
Hi,

On Thu, Jan 28, 2010 at 9:08 PM, phred78  wrote:
> The problem is that it will list ALL categories, whereas I only want
> it to show a list of categories with products associated with it. I've
> tried many combinations of .filter() and .exclude() but with no
> success.
> Can someone please point me in the right direction?

Perhaps you could try:

def products(request):
category_list = Category.objects.filter(product__isnull=False)
# ...

Regards,
Eugene Wee

-- 
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: False negatives on model validation of CharField with choices

2010-01-28 Thread Thomas B. Higgins
I've done some further checking, and see that this issue has two
parts. The first part is certainly a bug. Basically, selects with
optgroups are broken. Here's the ticket: 
http://code.djangoproject.com/ticket/12722.

The second part is that if, on a choice field, blank=False, the model
won't validate unless there is a selection, even if a default is
supplied. So, if the field has been disabled, there will be an error.
This is different from previous Django behavior, but probably doesn't
matter much to me, now that I know what is happening.

On Jan 27, 10:44 pm, "Thomas B. Higgins" 
wrote:
> I am writing to see if anyone thinks this is not a bug before creating
> a new ticket. I have an app that runs as expected on Django 1.1.1. It
> used to work on the development version, but a problem arose no later
> than 1.2 alpha 1 SVN-12271, and perhaps much earlier.
>
> Basically, the errors dictionary is wrong for every CharField with
> choices in the model. My custom validation continues to work, except
> when overridden by default validation. When my custom validation is
> commented out, the picture becomes clearer:
>
> 1)  An error "Value u"A325" is not a valid choice" is reported for a
> select field with no possibility of selecting a blank when any of the
> four available choices is selected. Elimination of the "blank" line is
> handled as described on 11/07/07 by semenov 
> athttp://code.djangoproject.com/ticket/4653
> using a combination of an explicit blank=False and a declared default
> value. This is baffling. I cannot conceive of a reason for an error in
> this case.
>
> 2) An error of "This field cannot be blank" is reported for fields
> with a default named in the model, such as:
>
> stiff_pl_grade    = models.CharField(max_length=8, choices=PL_grades,
> blank=False, default="A36",
>     help_text="Stiffener PL grade")
>
> It is my understanding that if a default is supplied, it should not be
> necessary to fill the field, even if blank=False.
>
> FloatFields with choices and IntegerFields with choices continue to
> behave as expected.
>
> It seems clear that when the is_valid() method is run on the form,
> something bad is happening to CharFields with choices, and this type
> of field only, and perfectly valid string selections or string
> defaults are being reported as invalid, probably by automatic model
> validation.
>
> My code works fine under version 1.1.1 and I see nothing in the
> development documentation to explain this odd new behavior.
>
> Any thoughts?

-- 
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: Form formatting

2010-01-28 Thread Rick Caudill
Sorry...  I forgot that font-weight has a normal and text-align would be
appropriate.   I didn't test and fix before I sent it  lol



On Thu, Jan 28, 2010 at 10:41 AM, Zeynel  wrote:

> This works:
>
> 
>   label {font-weight: normal;}
>   th {text-align: right;}
>
>
> On Jan 28, 11:32 am, Zeynel  wrote:
> > Thanks. I added the CSS to the template; but it is not working. What
> > am I doing wrong?
> >
> > 
> > 
> > Feedback
> > 
> >label {font-weight: none}
> >th {align: right}
> > 
> > 
> > 
> > {% include 'menu.html' %}
> >
> > 
> > 
> > {{ form.as_table }}
> > 
> > 
> > 
> >
> > 
> > 
> >
> > On Jan 28, 11:04 am, Rick Caudill  wrote:
> >
> >
> >
> > > Use CSS.
> >
> > > label {font-weight: none}
> > > th {align: left}
> >
> > > On Thu, Jan 28, 2010 at 9:53 AM, Zeynel  wrote:
> > > > Hello,
> >
> > > > How can I remove the bold in this formhttp://swimswith.com/feedback/
> > > > and fix the alignment?
> >
> > > > 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.
> >
> > > --
> > > Rick Caudill
>
> --
> 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.
>
>


-- 
Rick Caudill

-- 
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: Problem with Django webserver on HP

2010-01-28 Thread Jorge Bastida
http://docs.djangoproject.com/en/dev/ref/django-admin/#runserver-port-or-ipaddr-port

Try with
python manage.py runserver 0.0.0.0:8000


2010/1/28 rajk 

>
> HP-UX B.11.00
> Django-1.1.1
>
> myhost:/home/root/MyPython> python
> ActivePython 2.6.4.8 (ActiveState Software Inc.) based on
> Python 2.6.4 (r264:75706, Nov 3 2009, 13:55:48) [C] on hp-ux11
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import django
> >>> django.VERSION
> (1, 1, 1, 'final', 0)
> >>> exit()
>
> r...@myhost:/home/root/MyDjango> cd testproject
> r...@myhost:/home/root/MyDjango/testproject>ls
> _init_.py  _init_.pyc  manage.py  settings.py  settings.pyc   urls.py
> r...@myhost:/home/root/MyDjango/testproject> python manage.py
> runserver
> Validating models...
> 0 errors found
>
> Django bersion 1.1.1, using settings 'testproject.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CONTROL-C.
>
> Now, open Mozilla browser and enter http://127.0.0.1:8000/
>
> Here is the PROBLEM which some one from the user group can resolve for
> me ..
> Nothing happens in the browser
> A core file is in the  r...@myhost:/home/root/MyDjango/testproject
> directory
>
> Please advise and help - Thanks,  kair...@coned.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Benito Jorge Bastida
jo...@thecodefarm.com

thecodefarm SL
Av. Gasteiz 21, 1º Derecha
01008 Vitoria-Gasteiz
http://thecodefarm.com
Tel: (+34) 945 06 55 09

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



Problem with Django webserver on HP

2010-01-28 Thread rajk

HP-UX B.11.00
Django-1.1.1

myhost:/home/root/MyPython> python
ActivePython 2.6.4.8 (ActiveState Software Inc.) based on
Python 2.6.4 (r264:75706, Nov 3 2009, 13:55:48) [C] on hp-ux11
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 1, 1, 'final', 0)
>>> exit()

r...@myhost:/home/root/MyDjango> cd testproject
r...@myhost:/home/root/MyDjango/testproject>ls
_init_.py  _init_.pyc  manage.py  settings.py  settings.pyc   urls.py
r...@myhost:/home/root/MyDjango/testproject> python manage.py
runserver
Validating models...
0 errors found

Django bersion 1.1.1, using settings 'testproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Now, open Mozilla browser and enter http://127.0.0.1:8000/

Here is the PROBLEM which some one from the user group can resolve for
me ..
Nothing happens in the browser
A core file is in the  r...@myhost:/home/root/MyDjango/testproject
directory

Please advise and help - Thanks,  kair...@coned.com

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



Re: False negatives on model validation of CharField with choices

2010-01-28 Thread Karen Tracey
On Thu, Jan 28, 2010 at 1:44 AM, Thomas B. Higgins  wrote:

> It seems clear that when the is_valid() method is run on the form,
> something bad is happening to CharFields with choices, and this type
> of field only, and perfectly valid string selections or string
> defaults are being reported as invalid, probably by automatic model
> validation.
>
> My code works fine under version 1.1.1 and I see nothing in the
> development documentation to explain this odd new behavior.
>
> Any thoughts?
>


What you are describing is not ringing any bells and I cannot recreate
aything like what you are saying in some attempts to duplicate based on
the vague prose description.  Posting some of the actual code you are using
to define, create, and process the form you are talking about might help.

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: Form formatting

2010-01-28 Thread Zeynel
This works:


   label {font-weight: normal;}
   th {text-align: right;}


On Jan 28, 11:32 am, Zeynel  wrote:
> Thanks. I added the CSS to the template; but it is not working. What
> am I doing wrong?
>
> 
> 
>     Feedback
>     
>        label {font-weight: none}
>        th {align: right}
>     
> 
> 
> {% include 'menu.html' %}
>
>     
>         
>             {{ form.as_table }}
>         
>         
>     
>
> 
> 
>
> On Jan 28, 11:04 am, Rick Caudill  wrote:
>
>
>
> > Use CSS.
>
> > label {font-weight: none}
> > th {align: left}
>
> > On Thu, Jan 28, 2010 at 9:53 AM, Zeynel  wrote:
> > > Hello,
>
> > > How can I remove the bold in this formhttp://swimswith.com/feedback/
> > > and fix the alignment?
>
> > > 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 > >  groups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Rick Caudill

-- 
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: Form formatting

2010-01-28 Thread Zeynel
Thanks. I added the CSS to the template; but it is not working. What
am I doing wrong?



Feedback

   label {font-weight: none}
   th {align: right}



{% include 'menu.html' %}



{{ form.as_table }}







On Jan 28, 11:04 am, Rick Caudill  wrote:
> Use CSS.
>
> label {font-weight: none}
> th {align: left}
>
>
>
>
>
> On Thu, Jan 28, 2010 at 9:53 AM, Zeynel  wrote:
> > Hello,
>
> > How can I remove the bold in this formhttp://swimswith.com/feedback/
> > and fix the alignment?
>
> > 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 > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Rick Caudill

-- 
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: Form formatting

2010-01-28 Thread Rick Caudill
Use CSS.

label {font-weight: none}
th {align: left}


On Thu, Jan 28, 2010 at 9:53 AM, Zeynel  wrote:

> Hello,
>
> How can I remove the bold in this form http://swimswith.com/feedback/
> and fix the alignment?
>
> 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.
>
>


-- 
Rick Caudill

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



Form formatting

2010-01-28 Thread Zeynel
Hello,

How can I remove the bold in this form http://swimswith.com/feedback/
and fix the alignment?

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: Support for MS SQL Databases

2010-01-28 Thread Rick Caudill
Hi,

Doing a google search for 'django mssql' results in:
http://code.google.com/p/django-mssql/   Now as I see it this version does
not support 1.2 and I am not sure how reliably this works but it is worth a
shot


Rick Caudill

On Thu, Jan 28, 2010 at 1:25 AM, sridharpandu wrote:

> By any chance does Django support MSSQL DB's. I have a query from a
> prospective customer who would like to protect his current IT
> investments.
>
> Best regards
>
> Sridhar
>
> --
> 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.
>
>


-- 
Rick Caudill

-- 
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: ForeignKey query

2010-01-28 Thread Daniel Roseman
On Jan 28, 2:33 pm, Odd  wrote:
> I have two models, model1 and model2, where model1 has a ForeignKey
> reference to model2.
>
> Given a list of model1 objects, I need to determine which of these are
> used as a foreign key by a model2 object, and return that list. This
> is my current effort:
>
> returnList=[]
> for model1 in modelList:
>         model2List=model1.model2_set.distinct()
>         if len(model2List) !=0:
>             returnList.append(model1)
> return returnList
>
> There are quite many model2 objects in my database, so this approach
> is rather slow. I'm guessing there is a more clever way to solve my
> problem, but I'm quite new to both django and python. Can anybody
> please give me a hint of a better solution?
>
> Thanks!
>
> Odd-R.

Your code doesn't match the description. You originally say the model1
has a foreign key to model2 - I interpret that to mean that the
ForeignKey is defined on model1. However, your code references
model1.model2_set - which would imply that the FK is defined on
model2, pointing to model1. So, do you want the objects that are
pointed to by FKs from objects in the initial list, or the ones that
FKs in the initial list point to?

In any case, you want something along the lines of:

return_list = Model1.objects.filter(model2__in=model2_list)
--
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: 1.2 alpha, multiple databases, and raw SQL

2010-01-28 Thread Chris Curvey
>
> from django.db import connections
>
> cursor = connections['mydb'].cursor()
> cursor.execute('INSERT ')
>
> That is, the 'db.connection' object has been replaced with an index
> called 'db.connections', keyed by database alias. Each of those
> connections behaves as the single connection did in 1.1.
>
> The old 'db.connection' object has been retained for backwards
> compatibility, but it is assumed to be no more than an alias for:
>
> connections['default']
>
> I hope that clarifies things.
>
> Yours,
> Russ Magee %-)

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



ForeignKey query

2010-01-28 Thread Odd
I have two models, model1 and model2, where model1 has a ForeignKey
reference to model2.

Given a list of model1 objects, I need to determine which of these are
used as a foreign key by a model2 object, and return that list. This
is my current effort:

returnList=[]
for model1 in modelList:
model2List=model1.model2_set.distinct()
if len(model2List) !=0:
returnList.append(model1)
return returnList

There are quite many model2 objects in my database, so this approach
is rather slow. I'm guessing there is a more clever way to solve my
problem, but I'm quite new to both django and python. Can anybody
please give me a hint of a better solution?

Thanks!

Odd-R.

-- 
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: Display most popular video from each category

2010-01-28 Thread Daniel Roseman
On Jan 28, 2:18 pm, grimmus  wrote:
> Thanks for the reply. I am having some issues outputting the fields
> now though.
>
> It seems 4 objects are being returned alright but when i try and
> output a value it's blank.
>
> top_videos = {}
>
>     for i in xrange(1,6):
>         videos = Video.objects.filter(category=i).order_by('-
> hit_count')
>         if videos:
>             top_videos[i] = videos[0]
>
>     t = loader.get_template('home/display.html')
>     c = RequestContext(request,{
>         'top_videos': top_videos
>     })
>     return HttpResponse(t.render(c))
>
> and in my template:
>
> {% for video in top_videos %}
>    {{video.title}}
> {% endfor %}
>
> Any ideas what i am doing wrong ?

For some reason, Gabriel's solution defined top_videos as a
dictionary, so you would need to iterate through it as {% for
category_id, video in top_videos.items %}.

A better way would be to define it as a list:
top_videos = []
for i in xrange(1,6):
videos = Video.objects.filter(category=i).order_by('-
hit_count')
if videos:
top_videos.append(videos[0])

I must say, when I originally saw your post, I thought there must be
an even simpler solution that gets to the top video in each category
in a single query, using aggregation. But I've been unable to come up
with the correct way of doing it.
--
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: Display most popular video from each category

2010-01-28 Thread grimmus
Thanks for the reply. I am having some issues outputting the fields
now though.

It seems 4 objects are being returned alright but when i try and
output a value it's blank.

top_videos = {}

for i in xrange(1,6):
videos = Video.objects.filter(category=i).order_by('-
hit_count')
if videos:
top_videos[i] = videos[0]


t = loader.get_template('home/display.html')
c = RequestContext(request,{
'top_videos': top_videos
})
return HttpResponse(t.render(c))

and in my template:

{% for video in top_videos %}
   {{video.title}}
{% endfor %}

Any ideas what i am doing wrong ?

On Jan 27, 5:23 pm, Gabriel Reis  wrote:
> Hi,
>
> I would do something like this:
>
> top_videos = {}
> for i in xrange(1,6):
>     videos = Video.objects.filter(category=i).order_by('-hit_count')
>     if videos:
>         top_videos[i] = videos[0]
>
> Then, access the top videos via the top_videos dict.
>
> Cheers,
>
> Gabriel
>
> --
> Gabriel de Carvalho Nogueira Reis
> Software Developer
> +44 7907 823942
>
> On Wed, Jan 27, 2010 at 3:45 PM, grimmus  wrote:
> > Hi,
>
> > On the homepage of my site i display 1 main video and then the most
> > popular video from each of the 5 categories, which is determined by a
> > hit count.
>
> > Basically i need something like the following
>
> > tv_video = Video.objects.filter(category=1).order_by('-hit_count')
>
> > But i need an object returned that gets the most popular video (just
> > the first one) from each category (1-5)
>
> > Does someone have an idea of the most efficient way to achieve this ?
>
> > Thanks, hope i was clear.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-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: News about Geraldo Reports

2010-01-28 Thread derek
Sorry Marinho, but I have to agree with Nick.

In terms of design, take a look at 
http://www.webdesignfromscratch.com/web-design/current-style.php
for key examples and highlights for a professional looking web site.
It might be quite cool to have a 1920's art-deco theme/look-and-feel
on your site (but that's just me!).

In terms of content - here is a (quick) rewording of your
"blurbs" (whatever your final version, running them past a native-
English speaker will be really helpful):


What is Geraldo Reports?

Geraldo is an open-source reporting engine for Python or Django
applications. It uses the power of ReportLab to allow you to generate
simple or complex reports.

Why should I use it?

Reports are the lifeblood of modern business.  Delivering timely and
accessible content for all employees is essential.  A reporting engine
that runs on the web, harnessing both the corporate infrastructure and
the cloud, provides this core functionality.

Why the name "Geraldo"?

As with "Django", "Geraldo" is the name of a well-known jazz musician
- moreover calling it "Zambrota" would have rather weird!

***

Geraldo can be used in standalone desktop applications and web
applications. It is platform independent and works under Linux, Mac or
Windows.

Geraldo is licensed under LGPL 3.0.  You are free to download, copy,
distribute and modify without any payment, provided you respect the
terms of the license.

Geraldo ships with tons of examples; from simple "getting started" to
complex report layouts.

delete this -- ((You can find example codes using Geraldo Reports, you
can look in the package the directory 'test' and you will find dozens
of them. You can find examples also on examples documentation.))
and rather provide visible links (buttons/images) to graphic examples.

HTH
Derek

On Jan 28, 4:27 am, Nick Lo  wrote:
> Hi Marinho,
>
> > I have good news :)
>
> > I've done today the new website of Geraldo Reports [1].
>
> I hate to be one to say this as it looks like you've put a lot of work in, 
> but I much, much, much preferred the look of your old site. Mainly for one 
> reason: It was very easy to send clients to (I did) and know they'd be 
> impressed and immediately get an idea of what Geraldo does. This was largely 
> due to the large images of reports you used to have. I now would not send a 
> client to it as they'd be completely confused. Also it needs some work on the 
> wording for example:
>
> "Why should I know it?
> Reports are the eyes of business - specially for the chairmans - and theweb 
> is the obvious desination for all corporate softwares, like ERPs, CRMs, etc. 
> The cloud is here and there, so, make sense you should know a good reporting 
> engine to make your reports on the web, and on the cloud."
>
> The above has typos, needs some grammar changes as well as the overall 
> wording and message made clearer.
>
> > Geraldo is a tool to make business reports easy, that not necessarily
> > will be PDF files. For a while it just supports PDF and TXT (for file
> > and matrix printers), but in the future it will supports HTML, ODF,
> > DOC, XLS, and whatever. It uses the power of ReportLab to make PDF
> > files and uses also some things from its library.
>
> > Geraldo doesn't competes with ReportLab, it is just more like Jasper
> > or Crystal Reports, ok?
>
> You missed out a biggie: It makes them more easily too (depending on your 
> needs of course).
>
> > The new website is more like a redesign of the old one, but we want to
> > have cook book, code snippets and report templates repositories as
> > soon as possible.
>
> > We are near to announce the release 0.4 (maybe in 1 or 2 weeks), with
> > the main features:
>
> > - Caching
> > - Additional fonts
> > - Events system
> > - "Native" charts (using ReportLab functions instead of third part 
> > libraries)
> > - Cross reference tables
> > - Bar codes
> > - bugs fixes
>
> These are great new features to the site and to the engine.
>
> Thanks very much for all your time on this and I hope I don't come across as 
> negative about the new site. For us developers it really doesn't matter too 
> much as long as the site has the info we need BUT for us developers that want 
> to impress clients or bosses it matters a LOT. I don't think the new site is 
> appealing to clients or bosses and more to the point, I think it would just 
> completely confuse them.
>
> Cheers,
>
> Nick

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



Re: URL design - why the trailing slash?

2010-01-28 Thread kRON
Nope, no caveat there. You'r perfectly free to design your own URLs as
you like.

Ultimately, means you can also have a conflicting situation where you
decide you don't want to have a trailing `/` but you include URLs from
a 3p django application that do.

On Jan 28, 1:54 am, Brett Thomas  wrote:
> Most of the URLConf examples I run across use a trailing slash on all 
> URLs:www.example.com/profile/
>
> I'm not sure why, but I don't like this. I think it looks nicer 
> without:www.example.com/profile
>
> Are there any performance or security reasons to use the trailing slash in
> Django? Seems like there could be some quirk with regular expressions that
> I'm not thinking of...
>
> Thanks --
> Brett

-- 
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: static serve problem

2010-01-28 Thread Ozgur Yılmaz
Merhaba Ibrahim,

sanirim hata surada:

wrote:

> Hi,
> I've made what saying at
> http://superjared.com/entry/requiring-login-entire-django-powered-site/
> url. But i cant import to my css file which stay under /extend/
> directory. I have diffrent apps and I can import with that that css
> file. You can see below my url.py:
>
> from django.conf.urls.defaults import *
> from django.conf import settings
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
># Example:
># (r'^example/', include('example.foo.urls')),
>  (r'^myapp/$', 'example.myapp.views.index'),
># Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
># to INSTALLED_APPS to enable admin documentation:
># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
># Uncomment the next line to enable the admin:
>(r'^admin/', include(admin.site.urls)),
>(r'^extend/(?P.*)$', 'django.views.static.serve',
>{'document_root': '/home/ibrahim/example/extend'}),
>(r'^accounts/login/$', 'django.contrib.auth.views.login')
> )
>
>
> I can import with myapp that css file but no luck with accounts/login.
> I've already created the file under templates/registration/login.html
> and add the line:
>  media="screen" />
> What is the problem?
> 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.
>
>

-- 
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: static serve problem

2010-01-28 Thread Atamert Ölçgen
On Thursday 28 January 2010 13:26:37 H.Ibrahim YILMAZ wrote:
> (r'^extend/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/home/ibrahim/example/extend'}),
> (r'^accounts/login/$', 'django.contrib.auth.views.login')
> )
>
>  media="screen" />


Hi H. İbrahim,
I suspect it is looking for an "accounts/login/extent/login.css". I suggest 
you to use something like Live HTTP headers plugin (or something similar) to 
make sure the correct path is requested. (If this is a development server, 
just reading the console output would do)

Kind Regards,

-- 
Saygılarımla,
Atamert Ölçgen

 -+-
 --+
 +++

www.muhuk.com
mu...@jabber.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-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.



Strange 301 error, please save me!!!

2010-01-28 Thread james ahn
Hi there.

Recently i just downloaded django, and try to learn how to use it..

I belive that django is a good web framework!!!.


Here is a my problem...

i create a web site with django and google appengine on my local
machine

1. copied web site to another machine, but it does not  work, just
show 301 error

 i installed python and simply copied whole directory to new machine.

 running the web site has no problem, but when i try to open the web,
python console shows


"Info : root : "get http/1.1" 301 -

what is wrong?

2. i want to let other users access to the web site which i am
developing & running on my local machine.

for example, on my machine, i open my web site like this "http://
192.168.0.2:8080"

it work!!!, but when i try same thing on different machine,

"http://192.168.0.2:8080";,

http 403 error i got.


please help me, i should solve this problem ASAP!!!

thanks in advance


James

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



Empty categories

2010-01-28 Thread phred78
Hi,

I'm sorry if this question has been posted before, but I can't seem to
find the correct answer to my problem.

I'm trying to list product categories but I'd like to show only those
that have products associated with them. Some of them are empty and
should not be listed. I have something like this:

class Category(models.Model):
name = models.CharField()
(...)

class Product(models.Model):
name = models.CharField()
categories = models.ManyToManyField(Category)
(...)

And in my views.py file:

def products(request):
category_list = Category.objects.all()
(...)

The problem is that it will list ALL categories, whereas I only want
it to show a list of categories with products associated with it. I've
tried many combinations of .filter() and .exclude() but with no
success.
Can someone please point me in the right direction?

Thank you,

Frederico

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



static serve problem

2010-01-28 Thread H.Ibrahim YILMAZ
Hi,
I've made what saying at 
http://superjared.com/entry/requiring-login-entire-django-powered-site/
url. But i cant import to my css file which stay under /extend/
directory. I have diffrent apps and I can import with that that css
file. You can see below my url.py:

from django.conf.urls.defaults import *
from django.conf import settings

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

urlpatterns = patterns('',
# Example:
# (r'^example/', include('example.foo.urls')),
  (r'^myapp/$', 'example.myapp.views.index'),
# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
(r'^extend/(?P.*)$', 'django.views.static.serve',
{'document_root': '/home/ibrahim/example/extend'}),
(r'^accounts/login/$', 'django.contrib.auth.views.login')
)


I can import with myapp that css file but no luck with accounts/login.
I've already created the file under templates/registration/login.html
and add the line:

What is the problem?
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: URL design - why the trailing slash?

2010-01-28 Thread FxFocus
On Jan 28, 12:54 am, Brett Thomas  wrote:
> Most of the URLConf examples I run across use a trailing slash on all 
> URLs:www.example.com/profile/
>
> I'm not sure why, but I don't like this. I think it looks nicer 
> without:www.example.com/profile
>
> Are there any performance or security reasons to use the trailing slash in
> Django? Seems like there could be some quirk with regular expressions that
> I'm not thinking of...
>
> Thanks --
> Brett

You may find the *Common Middleware* documentation of interest in this
regard...

http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.common

regards,
Ed

-- 
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: Reasons why syncdb ignores an application?

2010-01-28 Thread phoebebright
OK Found it.

Used this

from autoslug.fields import AutoSlugField

and had one autoslug field.

Autoslug not on the pythonpath and syncdb failed silently.  Once I
took these out, normal service resumed.  Phew!

Phoebe.


On Jan 28, 9:56 am, phoebebright  wrote:
> It can see the app fine - the import views suggested above works fine,
> and if I put print statements in models.py, they are displayed when
> syncdb runs (4 times!).
>
> Checked all the folders for __init__ and all there.
>
> Am going to create a new app from scratch and put stuff in one small
> piece at a time.  Aghhh, don't you just love computers!
>
> Thanks for your suggestions, I'll keep them in a checklist for future
> reference.
>
> Phoebe
>
> On Jan 28, 12:46 am, mtnpaul  wrote:
>
>
>
> > In manage.py you could add
>
> > sys.path.insert(0, "/path/to/web")
>
> > Just before the  if __name__="__main__":   line
>
> > You will also need to handle this in your wsgi file for deployment.
>
> > Are you using "South"? If so, new tables for something you have
> > migrated will not be built by syncdb.
>
> > On Jan 27, 11:54 am, phoebebright  wrote:
>
> > > I cannot find the reason why syncdb will not create tables from a
> > > models.py.
>
> > > It is quite happy to create the auth tables and ones from an external
> > > app that is included in INSTALLED_APPS but it won't build the tables
> > > from my 'web' folder.
>
> > > I can put a print statement in the web.models.py and it appears.  It
> > > is clearly parsing all the models, because if I put a foreignkey to a
> > > model which doesn't exist, it complains until I fix the error, but it
> > > won't build the tables.  I do a syncdb and nothing happens and nothing
> > > is displayed.
>
> > > Have tried running it with verbosity 2 and this folder is never
> > > referred to.
>
> > > Have included 'from web.models import *' in urls.py and admin.py for
> > > luck.
>
> > > Have tried copying the web folder to another name and putting that
> > > name in the INSTALLED_APPS.
>
> > > The only other symptom is that if I do  'python manage.py sql web'  I
> > > get the error
> > > Error: App with label web could not be found. Are you sure your
> > > INSTALLED_APPS setting is correct?
>
> > > Here is my INSTALLED_APPS:
> > > INSTALLED_APPS = (
> > >     'django.contrib.auth',
> > >     'django.contrib.contenttypes',
> > >     'django.contrib.sessions',
> > >     'django.contrib.sites',
> > >     'django.contrib.admin',
> > >     'web',
> > >     'lifestream',
> > > )
>
> > > I have no idea what to try next!!

-- 
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: Sharing input control name with dynamic form

2010-01-28 Thread Daniel Roseman
On Jan 28, 9:04 am, Emiel van de Laar  wrote:
> Hi all,
>
> I've just run into something that I have no idea how to tackle.
> In creating a form with any number of checkboxes I would like
> to share the input control name amongst all the checkboxes.
>
> ~ % cat forms.py
> from django import forms
>
> class FooForm(forms.Form):
>     def __init__(self, *args, **kwargs):
>         super(FooForm, self).__init__(*args, **kwargs)
>
>         for field in ('foo', 'bar'):
>             self.fields[field] = forms.BooleanField()
>
> if __name__ == '__main__':
>     f = FooForm()
>     print(f)
>
> So instead of this output:
>
> ~ % python2.5 ./forms.py                                                      
>                                                                   -- INSERT --
> Foo: name="foo" id="id_foo" />
> Bar: name="bar" id="id_bar" />
> ...
>
> I would like to see:
>
> ~ % python2.5 ./forms.py                                                      
>                                                                   -- INSERT --
> Foo: name="foo" id="id_foo" />
> Bar: name="foo" id="id_bar" />
> ...
>
> Notice that the input name attribute needs to be the same for all the input 
> elements (checkboxes).
>
> I've looked through the code but it seems Django forms leans very heavily on 
> the name attribute being unique.
> For HTML checkboxes, however, this is a fairly common technique and the HTML 
> spec allows for it.
>
> Any help would be appreciated. :)
>
> Cheers!
>
>  - Emiel

The HTML you've posted won't work: the form will have no way of
distinguishing between foo and bar, since their HTML names are the
same. If you want multiple checkboxes with the same name, you need to
give them `value` attributes.

In any case, the way to do this in Django is with a
MultipleChoiceField and a CheckboxSelectMultiple widget.
--
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: Dealing with polyhierarchical data

2010-01-28 Thread Matthias Kestenholz
Hi

On Wed, Jan 27, 2010 at 11:29 PM, Olivier Guilyardi  wrote:
> Hi,
>
> I'm working with a polyhierarchical thesaurus, and trying to handle that in
> Django. By polyhierarchical, I mean : nodes can have both multiple parents and
> children.
>
> Actually, this is a geographical thesaurus, and yes a location can have 
> multiple
> parents (being across countries, etc..).
>
> I have read about the Nested set paradigm [1], and would love to use that, 
> maybe
> through django-mptt or django-treebeard. But unless someone shows me how, 
> nested
> sets aren't suitable for polyhierarchical data.
>
> Currently I have a simple recursive many-to-many mapping. This allows to
> establish the poly-relations, but is completely unusable for real use cases.
>
> For instance, I have a table of "items", with a "location" field which points 
> to
> a location in the thesaurus.
>
> Now I need to list all items which are located in a given country.
>
> I just can't filter by country, there's no such field in the items table. And 
> a
> location can be of any level of precision, such as country, region, city,
> village, etc..
>
> The nested set would be perfect for this, but apparently can't handle multiple
> parents.
>
> Do you see a fast and elegant way to handle this ?
>
> [1] http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
>

Maybe you could take a look at this project?
http://bitbucket.org/cmutel/django-directed-acyclic-graph/


Matthias

-- 
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: Reasons why syncdb ignores an application?

2010-01-28 Thread phoebebright
It can see the app fine - the import views suggested above works fine,
and if I put print statements in models.py, they are displayed when
syncdb runs (4 times!).

Checked all the folders for __init__ and all there.

Am going to create a new app from scratch and put stuff in one small
piece at a time.  Aghhh, don't you just love computers!

Thanks for your suggestions, I'll keep them in a checklist for future
reference.

Phoebe

On Jan 28, 12:46 am, mtnpaul  wrote:
> In manage.py you could add
>
> sys.path.insert(0, "/path/to/web")
>
> Just before the  if __name__="__main__":   line
>
> You will also need to handle this in your wsgi file for deployment.
>
> Are you using "South"? If so, new tables for something you have
> migrated will not be built by syncdb.
>
> On Jan 27, 11:54 am, phoebebright  wrote:
>
>
>
> > I cannot find the reason why syncdb will not create tables from a
> > models.py.
>
> > It is quite happy to create the auth tables and ones from an external
> > app that is included in INSTALLED_APPS but it won't build the tables
> > from my 'web' folder.
>
> > I can put a print statement in the web.models.py and it appears.  It
> > is clearly parsing all the models, because if I put a foreignkey to a
> > model which doesn't exist, it complains until I fix the error, but it
> > won't build the tables.  I do a syncdb and nothing happens and nothing
> > is displayed.
>
> > Have tried running it with verbosity 2 and this folder is never
> > referred to.
>
> > Have included 'from web.models import *' in urls.py and admin.py for
> > luck.
>
> > Have tried copying the web folder to another name and putting that
> > name in the INSTALLED_APPS.
>
> > The only other symptom is that if I do  'python manage.py sql web'  I
> > get the error
> > Error: App with label web could not be found. Are you sure your
> > INSTALLED_APPS setting is correct?
>
> > Here is my INSTALLED_APPS:
> > INSTALLED_APPS = (
> >     'django.contrib.auth',
> >     'django.contrib.contenttypes',
> >     'django.contrib.sessions',
> >     'django.contrib.sites',
> >     'django.contrib.admin',
> >     'web',
> >     'lifestream',
> > )
>
> > I have no idea what to try next!!

-- 
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: Python Graph

2010-01-28 Thread Daniel Hilton
On 27 January 2010 17:56, Bhaskar Gara  wrote:
> I am really stupid. After cut & Paste I need to double check what i
> pasted.
>
> Thank you very much Dan and sorry for wasting your time.
>
> Lesson learned.

I usually find all my mistakes are stupid ones. I actually find a
little comfort in this!

Good luck with Django - it's a great framework.
Cheers,
Dan

>
> On Jan 27, 11:16 am, Daniel Hilton  wrote:
>> 2010/1/27 Bhaskar Gara :
>>
>>
>>
>>
>>
>> > No luck.
>>
>> > url.py
>> > url(r'^member/score/compare/$', direct_to_template,
>> >            {'template': 'member_score_compare.html'},
>> > name='member_score_compare'),
>>
>> > view.py
>> > def prev_score(request):
>> >    template_name = 'member_score_compare.html'
>> >    graph = graphs.BarGraph('vBar')
>> >    graph.values = [380, 150, 260, 310, 430]
>> >    myGraph =  graph.create()
>> >    return render_to_response(template_name,
>> >                   { 'graph': myGraph },
>> >                    context_instance=RequestContext(request))
>>
>> > thank you
>> > Bhaskar
>>
>> In your example, the request will never touch your view function as
>> you're using the generic view to render straight to template.
>> Try placing this at the top of your urls.py:
>>
>> from YOUR_APP_NAME.views import view
>>
>> And then in your urls.py:
>>
>> url(r'^member/score/compare/$', view,
>>             {'template': 'member_score_compare.html'},
>>  name='member_score_compare'),
>>
>> Although you'll prob get an error on your view name. Have a look 
>> at:http://docs.djangoproject.com/en/1.1/topics/http/urls/#topics-http-urls
>>
>> HTH
>>
>> Dan
>>
>>
>>
>>
>>
>>
>>
>> > On Jan 27, 3:40 am, Daniel Hilton  wrote:
>> >> 2010/1/27 Bhaskar Gara :
>>
>> >> > Hi,
>>
>> >> >    I am very new to django.  I am trying to use this library for my
>> >> > graphs
>> >> >http://www.gerd-tentler.de/tools/pygraphs/?page=introduction
>>
>> >> > In my Views.py
>>
>> >> > prev_score(request):
>> >> >        graph = graphs.BarGraph('vBar')
>> >> >        graph.values = [380, 150, 260, 310, 430]
>> >> >        print graph.create()
>>
>> >> > In my Template  "score_compare.html"  in between the screen  I kept
>> >> > below code where it need to display the graph.
>>
>> >> >                {{ prev_score }}
>>
>> >> > It not erroring out,  but the graph is not displaying.  Please help.
>>
>> >> > Thank you
>> >> > Bhaskar
>>
>> >> Within a view function you can't print html out, you need to return
>> >> the output of the function.
>>
>> >> So, using your example, this should give you your graph:
>>
>> >> from django.template import loader, Context
>>
>> >> def prev_score(request):
>> >>     graph = graphs.BarGraph('vBar')
>> >>     graph.values = [380, 150, 260, 310, 430]
>> >>     myGraph =  graph.create()
>> >>     t = loader.get_template('my_template.html')
>> >>     c = Context({ 'graph': myGraph })
>> >>     return HttpResponse(t.render(c))
>>
>> >> Have a read through this part of the 
>> >> documentation:http://docs.djangoproject.com/en/1.1/topics/http/views/#topics-http-v...
>>
>> >> HTH
>> >> Dan
>>
>> >> > --
>> >> > 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.
>>
>> >> --
>> >> Dan Hilton
>> >> www.twitter.com/danhiltonwww.DanHilton.co.uk
>> >> - Hide quoted text -
>>
>> >> - Show quoted text -
>>
>> > --
>> > 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.
>>
>> --
>> Dan Hilton
>> www.twitter.com/danhiltonwww.DanHilton.co.uk
>> - Hide quoted text -
>>
>> - Show quoted text -- Hide quoted text -
>>
>> - Show quoted text -
>
> --
> 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.
>
>



-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.uk


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send ema

Re: Models, forms and inlineformset

2010-01-28 Thread andreas schmid
i forgot to add my edit view:

@login_required
def edit_projectidea(request, slug):
projectidea = get_object_or_404(Projectidea, slug=slug)
activity_formset = inlineformset_factory(Projectidea, Activity, extra=7)
form = ProjectideaForm(instance=projectidea)
formset = activity_formset(instance=projectidea)
if request.user.id != projectidea.author.id:
return HttpResponseForbidden()
if request.method == 'POST':
form = ProjectideaForm(request.POST, instance=projectidea)
formset = activity_formset(request.POST, instance=projectidea)
if form.is_valid() and formset.is_valid(): # All validation
rules pass
new_idea = form.save(commit=False)
new_idea.author = request.user
new_idea = form.save()
formset_models = formset.save(commit=False)
for f in formset_models:
f.projectidea = new_idea
f.save()
return HttpResponseRedirect(new_idea.get_absolute_url()) #
Redirect after POST
else:
form = ProjectideaForm(request.POST, instance=projectidea)
formset = activity_formset(request.POST, instance=projectidea)
return render_to_response('fslform/fslform.html',
  { 'form': form, 'formset': formset ,'add':
False },
  context_instance=RequestContext(request))


andreas schmid wrote:
> and your form works on edit too?
> i really cant understand why mine isnt...
>
> its giving me this MultiValueDictKeyError which i dont understand.
>
> Stefan Nitsche wrote:
>   
>> On Wed, Jan 27, 2010 at 14:04, andreas schmid > > wrote:
>>
>> is this an add or an edit form? or both?
>>
>> i have a similar inlineformset and i need to loop over the inline
>> objects to set the foreignkey to the parent object like:
>>
>>if form.is_valid() and formset.is_valid(): # All validation
>> rules pass
>>new_idea = form.save(commit=False)
>>new_idea.author = request.user
>>new_idea = form.save()
>>formset_models = formset.save(commit=False)
>>for f in formset_models:
>>f.idea = new_idea
>>f.save()
>>return
>> HttpResponseRedirect(new_idea.get_absolute_url())
>>
>>
>> im actually experiencing problems with the edit form where i can
>> get the
>> values displayed in the form if i want to edit but i get a
>>
>>Exception Type: MultiValueDictKeyError
>>Exception Value:
>>
>>Key 'activity_set-0-id' not found in > {u'activity_set-0-name': [u'a\xf6lskjdf\xf6sa'],
>> u'activity_set-0-type': [u'research']
>>
>> on save... any hints?
>>
>>
>> Stefan Nitsche wrote:
>> > On Mon, Jan 4, 2010 at 23:27, Stefan Nitsche > 
>> > >> wrote:
>> >
>> > Hi,
>> >
>> > to begin with I would like to declare that I'm still on the
>> > beginner end of the scale when it comes to Python and Django.
>> >
>> > I have an app which has two models:
>> >
>> > class Item(models.Model):
>> > title = models.CharField()
>> > description_markdown = models.TextField()
>> >
>> > class ItemImage(models.Model):
>> > item = models.ForeignKey(Item)
>> > image = models.ImageField(upload_to='tmp')
>> >
>> > What I want to do now is to create a page where users can submit
>> > an item and upload an image (or images) at the same time. I can
>> > create a form using ModelForm for the Item-model and I can
>> create
>> > a form for the ItemImage-model using inlineformset_factory, if I
>> > do this the submit page looks like it should. However it doesn't
>> > behave the way I want it to when saving, but to be honest I have
>> > no real idea of what I'm doing when it comes to the related
>> > model/form.
>> >
>> > If I understand it correctly when using inlineformset_factory I
>> > must give it an instance so that it can map the foreignkey,
>> > correct? So how do one go about and create a form where
>> people can
>> > add "item" and "itemimages" at the same time? I'm feeling totaly
>> > lost any pointers would be greatly appreciated.
>> >
>> > --
>> > Stefan Nitsche
>> > ste...@nitsche.se 
>> >
>> >
>> >
>> >
>> > Ok I'm totally lost here. I've created an edit function which works
>> > splendidly except for the inline-part, it displays alright but it
>> > isn't saved at all.
>> >
>> > My models look like this:
>> > 

Re: Models, forms and inlineformset

2010-01-28 Thread andreas schmid
and your form works on edit too?
i really cant understand why mine isnt...

its giving me this MultiValueDictKeyError which i dont understand.

Stefan Nitsche wrote:
> On Wed, Jan 27, 2010 at 14:04, andreas schmid  > wrote:
>
> is this an add or an edit form? or both?
>
> i have a similar inlineformset and i need to loop over the inline
> objects to set the foreignkey to the parent object like:
>
>if form.is_valid() and formset.is_valid(): # All validation
> rules pass
>new_idea = form.save(commit=False)
>new_idea.author = request.user
>new_idea = form.save()
>formset_models = formset.save(commit=False)
>for f in formset_models:
>f.idea = new_idea
>f.save()
>return
> HttpResponseRedirect(new_idea.get_absolute_url())
>
>
> im actually experiencing problems with the edit form where i can
> get the
> values displayed in the form if i want to edit but i get a
>
>Exception Type: MultiValueDictKeyError
>Exception Value:
>
>Key 'activity_set-0-id' not found in  {u'activity_set-0-name': [u'a\xf6lskjdf\xf6sa'],
> u'activity_set-0-type': [u'research']
>
> on save... any hints?
>
>
> Stefan Nitsche wrote:
> > On Mon, Jan 4, 2010 at 23:27, Stefan Nitsche  
> > >> wrote:
> >
> > Hi,
> >
> > to begin with I would like to declare that I'm still on the
> > beginner end of the scale when it comes to Python and Django.
> >
> > I have an app which has two models:
> >
> > class Item(models.Model):
> > title = models.CharField()
> > description_markdown = models.TextField()
> >
> > class ItemImage(models.Model):
> > item = models.ForeignKey(Item)
> > image = models.ImageField(upload_to='tmp')
> >
> > What I want to do now is to create a page where users can submit
> > an item and upload an image (or images) at the same time. I can
> > create a form using ModelForm for the Item-model and I can
> create
> > a form for the ItemImage-model using inlineformset_factory, if I
> > do this the submit page looks like it should. However it doesn't
> > behave the way I want it to when saving, but to be honest I have
> > no real idea of what I'm doing when it comes to the related
> > model/form.
> >
> > If I understand it correctly when using inlineformset_factory I
> > must give it an instance so that it can map the foreignkey,
> > correct? So how do one go about and create a form where
> people can
> > add "item" and "itemimages" at the same time? I'm feeling totaly
> > lost any pointers would be greatly appreciated.
> >
> > --
> > Stefan Nitsche
> > ste...@nitsche.se 
> >
> >
> >
> >
> > Ok I'm totally lost here. I've created an edit function which works
> > splendidly except for the inline-part, it displays alright but it
> > isn't saved at all.
> >
> > My models look like this:
> > ==
> >
> > class Recipe(models.Model):
> > author = models.ForeignKey(User)
> > name = models.CharField(max_length=255, verbose_name='Namn
> på rätten')
> > category = models.ForeignKey('Category',
> verbose_name='Kategori')
> > create_date = models.DateTimeField(auto_now_add=True)
> > servings = models.CharField(max_length=10,
> verbose_name='Portioner')
> > cooking_time = models.CharField(max_length=10,
> > verbose_name='Tillagningstid')
> > ingredients = models.TextField(verbose_name='Ingridienser')
> > instructions = models.TextField(verbose_name='Instruktioner')
> > oven_heat = models.CharField(max_length=10, null=True,
> blank=True,
> > verbose_name='Ugnsvärme')
> > serving_tips = models.TextField(null=True, blank=True,
> > verbose_name='Serveringsförslag')
> > tags = TagField(verbose_name='Taggar')
> > slug = models.SlugField()
> > published = models.NullBooleanField(default=1)
> >
> > class Image(models.Model):
> > recipe = models.ForeignKey(Recipe)
> > file = models.ImageField(upload_to=get_file_path)
> >
> > My view looks like this:
> > =
> > from django.shortcuts import render_to_response, get_object_or_404
> > from django.template import RequestContext
> > from django.http import HttpResponseRedirect
> > from nitsche.recipes.models import Category, Recipe, Image
> > from nitsche.reci

Sharing input control name with dynamic form

2010-01-28 Thread Emiel van de Laar
Hi all,

I've just run into something that I have no idea how to tackle.
In creating a form with any number of checkboxes I would like
to share the input control name amongst all the checkboxes.

~ % cat forms.py 
from django import forms

class FooForm(forms.Form):
def __init__(self, *args, **kwargs):
super(FooForm, self).__init__(*args, **kwargs)

for field in ('foo', 'bar'):
self.fields[field] = forms.BooleanField()

if __name__ == '__main__':
f = FooForm()
print(f)

So instead of this output:

~ % python2.5 ./forms.py
-- INSERT --
Foo:
Bar:
...

I would like to see:

~ % python2.5 ./forms.py
-- INSERT --
Foo:
Bar:
...

Notice that the input name attribute needs to be the same for all the input 
elements (checkboxes).

I've looked through the code but it seems Django forms leans very heavily on 
the name attribute being unique.
For HTML checkboxes, however, this is a fairly common technique and the HTML 
spec allows for it.

Any help would be appreciated. :)

Cheers!

 - Emiel

-- 
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: "Pro Django" book still up to date

2010-01-28 Thread FxFocus


On Jan 27, 11:51 pm, Russell Keith-Magee 
wrote:
> On Thu, Jan 28, 2010 at 6:23 AM, FxFocus  
> wrote:
> > On Jan 27, 4:55 pm, Achim Domma  wrote:
> >> Hi,
>
> >> I'm interested in buying the "Pro Django" book. I could not find any
> >> hint about what version it's written for. As it covers mostly
> >> internals and the ideas behind Django, it should not be outdated as
> >> quickly as other books. Has anybody read that book and can give some
> >> feedback about how useful it is for the current version of Django?
>
> >> cheers,
> >> Achim
>
> > You can download a free pdf version for evaluation here...
>
> >http://www.freebookspot.in/Books-Pro%20Django.htm
>
> > I don't know why it's free but I assume the site is legal as I got the
> > link from a respectable paper magazine article.
>
> I won't speak for Marty or APress, but I *severely* doubt that this is
> a legitimate site. A site with really bad page layout, sharing files
> on RapidShare, that passes PDFs through a link removal service doesn't
> say "legitimate" to me.
>
> Yours
> Russ Magee %-)

Did some research and seems your right...

http://www.guardian.co.uk/technology/askjack/2009/apr/16/copyright-ebooks

Interestingly I downloaded several django related ebooks and as a
result purchased two paper versions from Epress, The Definitive
Guide... and Practical Django Projects. I found the chance to preview
the digital versions before purchase a great help.

I wont be using the FreeBookSpot Service or similar in future but you
can still pay for digital versions direct from Apress. Digital version
is useful in addition to paper version as you have the ability to
search, cut & paste etc.

-- 
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: View doesn't return HttpResponse object

2010-01-28 Thread Ashok Prabhu
Thanks all. It finally worked. The was a minor issue with my browser.
It cached some previous page.

On Jan 28, 1:05 pm, Ashok Prabhu  wrote:
> Please find below the properly indented code. However pdb stack trace
> doesn't seem to be of much use in this case. In this code the view is
> working properly if the table name is NOT 'Master'. If the table name
> turns out to be 'Master' the value error is displayed.
>
> def dbout(request):
> try:
> filter_string= request.GET.get('filter_string', '')
> table_name=request.GET.get('table_name','')
> field_name=request.GET.get('field_name','')
> if table_name=='Master':
> if field_name=='hostid':
> results=eval(table_name).objects.filter
> (hostid__icontains=str(filter_string)).values()
> elif field_name=='plat_manu_name':
> results=eval(table_name).objects.filter
> (plat_manu_name__icontains=str(filter_string)).values()
> elif field_name=='hostname':
> results=eval(table_name).objects.filter
> (hostname__icontains=str(filter_string)).values()
> elif field_name=='mac':
> results=eval(table_name).objects.filter
> (mac__icontains=str(filter_string)).values()
> return HttpResponse(Template(open("/TCDB/
> masterout.html").read()).render(Context({'results':results})))
> else:
> if field_name=='hostid':
> results=eval(table_name).objects.filter
> (hostid__icontains=str(filter_string)).values()
> elif field_name=='hostname':
> results=eval(table_name).objects.filter
> (hostname__icontains=str(filter_string)).values()
> elif field_name=='date_entered':
> results=eval(table_name).objects.filter
> (date_entered__icontains=str(filter_string)).values()
> elif field_name=='sysfw_ver':
> results=eval(table_name).objects.filter
> (sysfw_ver__icontains=str(filter_string)).values()
> elif field_name=='sysfw_bld':
> results=eval(table_name).objects.filter
> (sysfw_bld__icontains=str(filter_string)).values()
> elif field_name=='os_ver':
> results=eval(table_name).objects.filter
> (os_ver__icontains=str(filter_string)).values()
> elif field_name=='os_bld':
> results=eval(table_name).objects.filter
> (os_bld__icontains=str(filter_string)).values()
> elif field_name=='sunvts_ver':
> results=eval(table_name).objects.filter
> (sunvts_ver__icontains=str(filter_string)).values()
> elif field_name=='sunvts_bld':
> results=eval(table_name).objects.filter
> (sunvts_bld__icontains=str(filter_string)).values()
> elif field_name=='test_info':
> results=eval(table_name).objects.filter
> (test_info__icontains=str(filter_string)).values()
> return HttpResponse(Template(open("/TCDB/
> configout.html").read()).render(Context({'results':results})))
>except:
> pass
>
> On Jan 27, 8:22 pm, Karen Tracey  wrote:
>
> > On Wed, Jan 27, 2010 at 10:02 AM, Malcolm Box  wrote:
> > > It was indented if you looked in the original message text - I suspect 
> > > your
> > > (and my) default email program is stripping leading spaces.
>
> > How odd.  Looking at it in Gmail one space has been removed from the front
> > of all lines that had more than one leading space. Looking at it on the
> > Google Groups page the indentation is legal (if extremely hard to see
> > properly) Python. Another email client I use also shows it correctly. I've
> > not noticed Gmail doing that before.
>
> > 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: View doesn't return HttpResponse object

2010-01-28 Thread Ashok Prabhu
Please find below the properly indented code. However pdb stack trace
doesn't seem to be of much use in this case. In this code the view is
working properly if the table name is NOT 'Master'. If the table name
turns out to be 'Master' the value error is displayed.

def dbout(request):
try:
filter_string= request.GET.get('filter_string', '')
table_name=request.GET.get('table_name','')
field_name=request.GET.get('field_name','')
if table_name=='Master':
if field_name=='hostid':
results=eval(table_name).objects.filter
(hostid__icontains=str(filter_string)).values()
elif field_name=='plat_manu_name':
results=eval(table_name).objects.filter
(plat_manu_name__icontains=str(filter_string)).values()
elif field_name=='hostname':
results=eval(table_name).objects.filter
(hostname__icontains=str(filter_string)).values()
elif field_name=='mac':
results=eval(table_name).objects.filter
(mac__icontains=str(filter_string)).values()
return HttpResponse(Template(open("/TCDB/
masterout.html").read()).render(Context({'results':results})))
else:
if field_name=='hostid':
results=eval(table_name).objects.filter
(hostid__icontains=str(filter_string)).values()
elif field_name=='hostname':
results=eval(table_name).objects.filter
(hostname__icontains=str(filter_string)).values()
elif field_name=='date_entered':
results=eval(table_name).objects.filter
(date_entered__icontains=str(filter_string)).values()
elif field_name=='sysfw_ver':
results=eval(table_name).objects.filter
(sysfw_ver__icontains=str(filter_string)).values()
elif field_name=='sysfw_bld':
results=eval(table_name).objects.filter
(sysfw_bld__icontains=str(filter_string)).values()
elif field_name=='os_ver':
results=eval(table_name).objects.filter
(os_ver__icontains=str(filter_string)).values()
elif field_name=='os_bld':
results=eval(table_name).objects.filter
(os_bld__icontains=str(filter_string)).values()
elif field_name=='sunvts_ver':
results=eval(table_name).objects.filter
(sunvts_ver__icontains=str(filter_string)).values()
elif field_name=='sunvts_bld':
results=eval(table_name).objects.filter
(sunvts_bld__icontains=str(filter_string)).values()
elif field_name=='test_info':
results=eval(table_name).objects.filter
(test_info__icontains=str(filter_string)).values()
return HttpResponse(Template(open("/TCDB/
configout.html").read()).render(Context({'results':results})))
   except:
pass


On Jan 27, 8:22 pm, Karen Tracey  wrote:
> On Wed, Jan 27, 2010 at 10:02 AM, Malcolm Box  wrote:
> > It was indented if you looked in the original message text - I suspect your
> > (and my) default email program is stripping leading spaces.
>
> How odd.  Looking at it in Gmail one space has been removed from the front
> of all lines that had more than one leading space. Looking at it on the
> Google Groups page the indentation is legal (if extremely hard to see
> properly) Python. Another email client I use also shows it correctly. I've
> not noticed Gmail doing that before.
>
> 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.