Re: Timestamped comment field

2008-06-19 Thread M.Ganesh

Chris H. wrote:
> On Jun 19, 12:53 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
>   
>> Hi Chris,
>>
>> May be you can try this model :
>> ...
>> 
>
> While I could store each comment off as an instance of a Comments
> model, I don't really have a need to do so.  I'm wanting to have the
> comments stored as a TextField on the main object since there's no
> need to reference them individually.
>
> I suppose I could also create an Abstract Base Class for this,
> something like CommentableItemBase that would have the functionality
> defined there to keep it DRY.
>   
Sorry Chris, I am not able to understand what you mean.

1. Do you mean, you will have one big TextField per object and keep 
appending the comments about that object to the end of that TextField? 
How big will be your TextField then and how many comments you expect per 
object?

2. Are you talking about creating an abstract class similar to the model 
I showed? Go ahead and do it. In fact that was an abstract class in my 
code, and I changed it to a normal class before sending to avoid distraction

HTH

Ganesh


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



Re: createsuperuser error

2008-06-19 Thread jurian

I see now that this error doen not occur on an older version of the
'newforms-admin' branch, so I assume that something was broken with a
recent update.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



createsuperuser error

2008-06-19 Thread jurian

I'm getting the following error message when I try to run syncdb:

Error: Unknown command: 'createsuperuser'

All the tables are created, but as soon as it enter 'yes' to create
the super user the error appears.

I've got no clue as to what might be causing the problem.

I'm using the latest 'newforms-admin' from SVN.

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



Re: Looping through a specific number of times with a for loop

2008-06-19 Thread Catalyst



On Jun 19, 11:54 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> >   For example at the template level...
>
> >     {% for news in latest_news_list last 10 %}
>
> >   I'm hoping this would grab the latest 10 objects in the
> > latest_news_list. Does anyone know the best way to do this, or have
> > some examples set up I could read over?
>
> Looks like you want the slice filter[1]:
>
> {{ for news in latest_news_list|slice:":10" }}
>
> or
>
> {{ for news in latest_news_list|slice:"-10:" }}
>
> assuming latest_news_list is sorted by date.
>
> -tim
>
> [1]http://www.djangoproject.com/documentation/templates/#slice

 Thank you for the very fast reply. This worked great!

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



Re: Thanks!!!!!!!!!!!!!!!!!

2008-06-19 Thread Juan Hernandez
me 2 :D

On Fri, Jun 20, 2008 at 10:42 PM, k0001 <[EMAIL PROTECTED]> wrote:

>
> Can I jump into the "THANKS" bandwagon?
>
> Thanks. =)
>
> On Thu, Jun 19, 2008 at 11:41 PM, Gene Campbell <[EMAIL PROTECTED]>
> wrote:
> >
> > Just wanted to "THANKS" for an absolutely awesome web dev
> framework.
> >
> > >
> >
>
> >
>

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



user profile is not getting saved in admin

2008-06-19 Thread Gene Campbell
I have looked through the docs and search the group and web.  Seems other's
are asking the question, but I haven't seen an answer yet.

class UserProfile(models.Model):
country = models.ForeignKey(Country, core=True)
user = models.ForeignKey(User, unique=True, edit_inline=models.TABULAR,
core=True)

When I save a User in the Admin page, the country (from this UserProfile) is
not getting saved.

The list of Countries are shown in the menu, there are no errors, but the DB
table userprofile is empty, and when I come back to the User admin page, no
country is selected.

Seems that the save is getting dropped on the floor.

I have

  AUTH_PROFILE_MODULE = 'app.userprofile'

set.  The system doesn't throw any errors.  Just doesn't save.

I saw a post suggesting subclassing User and overriding saving to save my
profile  But, I can't find this recommended in the docs.  The documented way
to  do this is has nothing to do with subclassing

Please clarify.

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



Automatic Update of template

2008-06-19 Thread [EMAIL PROTECTED]

Hi,

I am writing a web based chat client in Django framework. When ever I
receive a message, I get that in a python function which is in the
same file as my views. Can I directly pass this data to the template
(by using response_to_render ) to update the template? Could someone
suggest a way to automatically update messages in the site from python
code.

Thanks,
Priyank


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



Re: Thanks!!!!!!!!!!!!!!!!!

2008-06-19 Thread k0001

Can I jump into the "THANKS" bandwagon?

Thanks. =)

On Thu, Jun 19, 2008 at 11:41 PM, Gene Campbell <[EMAIL PROTECTED]> wrote:
>
> Just wanted to "THANKS" for an absolutely awesome web dev 
> framework.
>
> >
>

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



Re: Models advice

2008-06-19 Thread [EMAIL PROTECTED]

I haven't looked through it fully, however you don't need to create
the primary keys, they are automatically created.

On Jun 19, 8:38 pm, joshuajonah <[EMAIL PROTECTED]> wrote:
> I am making a database of advertisers, product categories, products
> (advertiser+product category), retailers, and retailers stock
> (retailer + products)
>
> Here is my diagram of the topology:http://www.joshuajonah.com/database.png
>
> Here's my models.py:http://dpaste.com/57676/
>
> Do you see any problems before i sync this? can you think of any
> better way of structuring this? there will be a LOT of records. Thanx
> guys.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Thanks!!!!!!!!!!!!!!!!!

2008-06-19 Thread Gene Campbell

Just wanted to "THANKS" for an absolutely awesome web dev framework.

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



Re: get_models

2008-06-19 Thread James Bennett

On Thu, Jun 19, 2008 at 9:11 PM, Russell Keith-Magee
<[EMAIL PROTECTED]> wrote:
> This is just one of those areas that we haven't got around to
> documenting yet. It doesn't mean we don't want to document this
> feature - it just means other things have taken priority. We're always
> open to contributions, though. If you want to write up some
> documentation based on what you have just learned, feel free to
> volunteer.

Also, there were a few long-running tickets related to model loading,
so at the time it didn't make sense to document an API that might have
to change when those tickets were fixed. It turned out that the
model-loading API could stay backwards-compatible (which was a good
thing), so now if someone wants a good task for a sprint they should
look into documenting it.


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

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



Re: get_models

2008-06-19 Thread James Bennett

On Thu, Jun 19, 2008 at 8:01 PM, Marty Alchin <[EMAIL PROTECTED]> wrote:
> In fact, I'm confident enough that they're not going anywhere that I'm
> in the process of documenting them on dead trees.

I already beat you to it, at least partially (got some uses of
get_model() in my book).


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



Re: get_models

2008-06-19 Thread Russell Keith-Magee

On Fri, Jun 20, 2008 at 9:59 AM, Beetle B. <[EMAIL PROTECTED]> wrote:
>
> Thanks for all the replies.
>
> Wonder why they didn't add it to the documentation...seems like a
> useful function.

I'm one of "Them", and the answer is simple - we've been busy, and
documentation doesn't write itself. Writing documentation takes time.
Writing good documentation takes longer. We also have to patch bugs,
answer user and developer questions, and other pieces of
administrivia. Occasionally, I find eating to be an enjoyable
activity, so I have to work at a day job to pay for food.

This is just one of those areas that we haven't got around to
documenting yet. It doesn't mean we don't want to document this
feature - it just means other things have taken priority. We're always
open to contributions, though. If you want to write up some
documentation based on what you have just learned, feel free to
volunteer.

Yours,
Russ Magee %-)

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



Re: get_models

2008-06-19 Thread Beetle B.


Thanks for all the replies.

Wonder why they didn't add it to the documentation...seems like a
useful function.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Models advice

2008-06-19 Thread joshuajonah

I am making a database of advertisers, product categories, products
(advertiser+product category), retailers, and retailers stock
(retailer + products)

Here is my diagram of the topology: http://www.joshuajonah.com/database.png

Here's my models.py: http://dpaste.com/57676/

Do you see any problems before i sync this? can you think of any
better way of structuring this? there will be a LOT of records. Thanx
guys.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: get_models

2008-06-19 Thread Marty Alchin

On Thu, Jun 19, 2008 at 8:29 PM, James Bennett <[EMAIL PROTECTED]> wrote:
> If these functions were to change, Django itself would need to undergo
> not-insignificant refactoring. And since such a refactoring is not on
> the table, they're not going to change.

*SPOILER ALERT*

In fact, I'm confident enough that they're not going anywhere that I'm
in the process of documenting them on dead trees.

-Gul

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



URL templatetag with URL naming not working

2008-06-19 Thread kimus

Hi,

URL templatetag with URL naming not working for me.

application urls.py

urlpatterns = patterns('',
(r'^feeds/', include('blocks.apps.aggregator.urls')),
)

aggregator urls.py

urlpatterns = patterns('',
url(r'^(?P\d+)/$', 'blocks.apps.aggregator.views.feed_list',
name="feed-detail"),
)

template html

{{ item.id }}


the URL templatetag doesn't return nothing.


Any help will be appreciated.

thank you


kimus

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



Re: get_models

2008-06-19 Thread James Bennett

On Thu, Jun 19, 2008 at 7:02 PM, Russell Keith-Magee
<[EMAIL PROTECTED]> wrote:
> Short version:

See also long version: http://www.b-list.org/weblog/2007/nov/03/working-models/

If these functions were to change, Django itself would need to undergo
not-insignificant refactoring. And since such a refactoring is not on
the table, they're not going to change.

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



Re: Initializing a form.

2008-06-19 Thread Nathaniel Whiteinge

On Jun 19, 4:36 pm, Adi <[EMAIL PROTECTED]> wrote:
> In order to set up the initial values on a couple of fields of my
> form, I need to pass in a couple of model objects to my ModelForm's
> init method.

Try this::

class YourForm(forms.ModelForm):
class Meta:
...

def __init__(self, *args, **kwargs):
# pop() your custom keyword args before calling super()
self.modelobj1 = kwargs.pop('modelobj1', None)
self.modelobj2 = kwargs.pop('modelobj2', None)
super(YourForm, self).__init__(*args, **kwargs)

# Call like this:
modelobj1 = SomeModel.objects.get(id=1)
modelobj2 = SomeModel.objects.get(id=2)
form = YourForm(modelobj1=modelobj1, modelobj2=modelobj2)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: get_models

2008-06-19 Thread Russell Keith-Magee

On Fri, Jun 20, 2008 at 7:06 AM, Beetle B. <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I needed a way to get a list of all models in a Django project.
>
> I was told in IRC that I can use get_models from django.db.models.
>
> I'm not sure this is documented in the docs. Is it "safe" to use (as
> in this method and its behavior is not expected to change in the
> future)?

I'm pretty sure those functions are not documented, which is
unfortunate, because they are quite useful. They are quite safe, quite
supported, and unlikely to be changed or deprecated any time soon.

Short version:

>>> from django.db.models import get_model, get_models, get_apps

>>> get_apps()
[... list of application modules ]

>>> a = get_app('my_app')
>>> print a


>>> get_models(a)
[... list of model classes ...]

>>> get_model('myapp','Author')


Yours,
Russ Magee %-)

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



Re: Why PostgreSQL?

2008-06-19 Thread Russell Keith-Magee

On Fri, Jun 20, 2008 at 4:11 AM, AmanKow <[EMAIL PROTECTED]> wrote:
>
>> Already logged:http://code.djangoproject.com/ticket/3615
>
> I took a look at that ticket, and there was a comment at the end
> pointing to a mysql function that checks for constraint violations...
>
> http://forge.mysql.com/tools/tool.php?id=11
>
> Way too mysql guruish for me, but it looks interesting...

Yes - I added that link last night. Ticket #3615 came up in a separate
discussion yesterday, and someone suggested that script as a possible
solution. If someone wants to go to the effort of integrating that
script (and the license allows) I'd be happy to commit such a fix.

Yours
Russ Magee %-)

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



Re: Some Django unit tests fail...

2008-06-19 Thread Russell Keith-Magee

On Fri, Jun 20, 2008 at 1:07 AM, Peter Melvyn <[EMAIL PROTECTED]> wrote:
>
> On 6/19/08, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> Yes, it is the intention. If Django requires test database with
> charset UTF8, IMHO it should create it using related clause. as well
> as proper engine should be choosen if we care about reference
> integrity, e.g.
>
> SET storage_engine=InnoDB;
> CREATE DATABASE xxx
>  DEFAULT CHARACTER SET utf8
>  COLLATE utf8_xxx_ci;
>
>
> Should I create a ticket ;-)

I won't ever say no to a ticket. Make a proposal, and we will see if
it floats :-)

Yours
Russ Magee %-)

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



Displaying a select field only when more than one choice is available

2008-06-19 Thread Fabien
Hello,

I'm trying to extend the Select widget to only display the field if
more than one choice is available. How can I check the available
choices in the __init__() when I'm extending the SelectWidget :

class OptionalSelect(forms.Select):
def __init__(self, attrs=None, choices=()):
super(OptionalSelect, self).__init__(attrs)
self.choices = list(choices)
if len(list(self.choices)) <= 2:
self.is_hidden = True

But choices don't seems to be populated by the ModelChoiceField.

I'll take any help.

-- 
Fabien SCHWOB
_
Derrière chaque bogue, il y a un développeur, un homme qui s'est trompé.
(Bon, OK, parfois ils s'y mettent à plusieurs).

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



get_models

2008-06-19 Thread Beetle B.

Hi,

I needed a way to get a list of all models in a Django project.

I was told in IRC that I can use get_models from django.db.models.

I'm not sure this is documented in the docs. Is it "safe" to use (as
in this method and its behavior is not expected to change in the
future)?

Thanks.

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



Re: Confused by ImportError: cannot import name models

2008-06-19 Thread Karen Tracey
On Thu, Jun 19, 2008 at 5:37 PM, Tim <[EMAIL PROTECTED]> wrote:

>
> Hi all -
>
> This is my first post to the group; I am a new Django user and am very
> enthusiastic about working with the framework. However, I am having
> trouble with one thing in particular. I am trying to set up Review
> Board, a Django project supporting code reviews, and am having
> problems with the server (both the development server and Apache)
> crashing, completely silently with no output even when the development
> server is being run with --traceback. I am running under Windows XP,
> which I realize is unknown territory to a certain extent. In any case,
> to try to get at least some sense of what was going on, I set
> DJANGO_SETTINGS_MODULE and tried to run the offending view on the
> command line (which I'm not sure makes sense anyway). I get the
> following traceback, but I'm not sure if it's the real deal or a red
> herring - if this were causing the crashes, it seems that the
> traceback would be captured by one or both of the servers. Any ideas
> about how to fix it would be greatly appreciated! Or if I'm barking up
> the wrong tree altogether, that would be good to learn, too.
>

Trying to run the views module from a command prompt is probably not very
useful, it is simply not designed to be run that way and isn't going to
work.

To debug the kind of problem you are having I would either run the
development server under a debugger and step through the code to see where
things go south, or add print statements to try to get a feel for what is
going on.

If you do not feel like you know enough about Django or the Django app you
are trying to use to do that, I'd step back and start with stepping through
something simple (like the tutorial code) under a debugger in order to get a
basic understanding of the framework first.

As an aside,  though I primarily use Linux, I do have a Windows box where I
have tested out various problems people have reported.  It's not like Django
on Windows is completely unheard of.  I've never seen anything like what you
are describing though.

Karen

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



Re: error on manipulator fields

2008-06-19 Thread Karen Tracey
On Thu, Jun 19, 2008 at 6:21 PM, TiNo <[EMAIL PROTECTED]> wrote:

> Hi,
>
> (Django version 0.97-pre-SVN-7633)
>
> I am trying to use a custom modelfield. When I try to ad an entry in
> the admin, i get:
>
> ---
> TypeError at /admin/klanten/klant/add/
> __init__() got an unexpected keyword argument 'is_required'
>
> Traceback:
> File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> site-packages/django/core/handlers/base.py" in get_response
>  82. response = callback(request, *callback_args,
> **callback_kwargs)
> File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> site-packages/django/contrib/admin/views/decorators.py" in _checklogin
>  62. return view_func(request, *args, **kwargs)
> File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> site-packages/django/views/decorators/cache.py" in _wrapped_view_func
>  44. response = view_func(request, *args, **kwargs)
> File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> site-packages/django/contrib/admin/views/main.py" in add_stage
>  253. manipulator = model.AddManipulator()
> File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> site-packages/django/db/models/manipulators.py" in __init__
>  70.
> self.fields.extend(f.get_manipulator_fields(self.opts, self,
> self.change))
> File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> site-packages/django/db/models/fields/__init__.py" in
> get_manipulator_fields
>  352. return [man(field_name=field_names[i], **params) for i,
> man in enumerate(field_objs)]
>
> Exception Type: TypeError at /admin/klanten/klant/add/
> Exception Value: __init__() got an unexpected keyword argument
> 'is_require
> -
>
> the modelfield is defined as:
>
>
> -
> from django.db.models import *
> from django.contrib.localflavor.nl import forms as nlforms
> from django.core import validators
> from django.newforms.fields import EMPTY_VALUES
> from django.utils.encoding import smart_unicode
> from django import oldforms
> import re
>
> phone_re = re.compile('^\+?\d+$')
>
> class NLPhoneNumberField(Field):
>
>def get_internal_type(self):
>return "CharField"
>
>def db_type(self):
>return "char(16)"
>
>def to_python(self, value):
>if field_data in EMPTY_VALUES:
>return u''
>
>phone_nr = re.sub('[\-\s\(\)]', '', value)
>
>if not phone_re.search(p):
>raise validation.ValidationError('Ongeldig telefoon
> nummer. Voer (evt. +) 10 cijfers in.')
>
>if len(phone_nr) == 12:
>if phone_nr[:3] == '+31':
>phone_nr = phone_nr[3:]
>else:
>return phone_nr
>elif len(phone_nr) != 10:
>raise validation.ValidationError('Ongeldig telefoon
> nummer. Voer (evt. +) 10 cijfers in.')
>
>if phone_nr[0] == '6':
>return '06 ' + phone_nr[1:]
>else:
>return '%s %s' % (phone_nr[:3],phone_nr[3:])
>
>def get_manipulator_field_objs(self):
>return [nlforms.NLPhoneNumberField]
>
>def formfield(self, **kwargs):
>defaults = {'form_class': nlforms.NLPhoneNumberField,
> 'max_length':16}
>defaults.update(kwargs)
>return super(NLPhoneNumberField, self).formfield(**defaults)
> 
>
> The field is then used in a model without any arguments.
>
> The problem disappears when I change:
> 
>def get_manipulator_field_objs(self):
>return [nlforms.NLPhoneNumberField]
> 
> to:
> 
>def get_manipulator_field_objs(self):
>return [oldforms.TextField]
> 
>

What is nlforms.NLPhoneNumberField?  It sounds like it is a custom
newforms-type form field to go with your model field?  But
get_manipulator_field_objs is an oldforms-type thing and isn't going to work
when handed a newforms custom field.

Have you considered trying the newforms-admin branch?  There admin will be
using newforms instead of oldforms so you won't have to get the oldforms
stuff working for your custom model field, just newforms.

Karen

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

Initializing a form.

2008-06-19 Thread Adi

In order to set up the initial values on a couple of fields of my
form, I need to pass in a couple of model objects to my ModelForm's
init method. What is the right way to write the __init__ method so
that it works both when I initialize it with form data and without
form data.

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



error on manipulator fields

2008-06-19 Thread TiNo

Hi,

(Django version 0.97-pre-SVN-7633)

I am trying to use a custom modelfield. When I try to ad an entry in
the admin, i get:

---
TypeError at /admin/klanten/klant/add/
__init__() got an unexpected keyword argument 'is_required'

Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/core/handlers/base.py" in get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/contrib/admin/views/decorators.py" in _checklogin
  62. return view_func(request, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/contrib/admin/views/main.py" in add_stage
  253. manipulator = model.AddManipulator()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/db/models/manipulators.py" in __init__
  70.
self.fields.extend(f.get_manipulator_fields(self.opts, self,
self.change))
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/db/models/fields/__init__.py" in
get_manipulator_fields
  352. return [man(field_name=field_names[i], **params) for i,
man in enumerate(field_objs)]

Exception Type: TypeError at /admin/klanten/klant/add/
Exception Value: __init__() got an unexpected keyword argument
'is_require
-

the modelfield is defined as:

-
from django.db.models import *
from django.contrib.localflavor.nl import forms as nlforms
from django.core import validators
from django.newforms.fields import EMPTY_VALUES
from django.utils.encoding import smart_unicode
from django import oldforms
import re

phone_re = re.compile('^\+?\d+$')

class NLPhoneNumberField(Field):

def get_internal_type(self):
return "CharField"

def db_type(self):
return "char(16)"

def to_python(self, value):
if field_data in EMPTY_VALUES:
return u''

phone_nr = re.sub('[\-\s\(\)]', '', value)

if not phone_re.search(p):
raise validation.ValidationError('Ongeldig telefoon
nummer. Voer (evt. +) 10 cijfers in.')

if len(phone_nr) == 12:
if phone_nr[:3] == '+31':
phone_nr = phone_nr[3:]
else:
return phone_nr
elif len(phone_nr) != 10:
raise validation.ValidationError('Ongeldig telefoon
nummer. Voer (evt. +) 10 cijfers in.')

if phone_nr[0] == '6':
return '06 ' + phone_nr[1:]
else:
return '%s %s' % (phone_nr[:3],phone_nr[3:])

def get_manipulator_field_objs(self):
return [nlforms.NLPhoneNumberField]

def formfield(self, **kwargs):
defaults = {'form_class': nlforms.NLPhoneNumberField,
'max_length':16}
defaults.update(kwargs)
return super(NLPhoneNumberField, self).formfield(**defaults)


The field is then used in a model without any arguments.

The problem disappears when I change:

def get_manipulator_field_objs(self):
return [nlforms.NLPhoneNumberField]

to:

def get_manipulator_field_objs(self):
return [oldforms.TextField]



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



Confused by ImportError: cannot import name models

2008-06-19 Thread Tim

Hi all -

This is my first post to the group; I am a new Django user and am very
enthusiastic about working with the framework. However, I am having
trouble with one thing in particular. I am trying to set up Review
Board, a Django project supporting code reviews, and am having
problems with the server (both the development server and Apache)
crashing, completely silently with no output even when the development
server is being run with --traceback. I am running under Windows XP,
which I realize is unknown territory to a certain extent. In any case,
to try to get at least some sense of what was going on, I set
DJANGO_SETTINGS_MODULE and tried to run the offending view on the
command line (which I'm not sure makes sense anyway). I get the
following traceback, but I'm not sure if it's the real deal or a red
herring - if this were causing the crashes, it seems that the
traceback would be captured by one or both of the servers. Any ideas
about how to fix it would be greatly appreciated! Or if I'm barking up
the wrong tree altogether, that would be good to learn, too.

Thanks -

Traceback (most recent call last):
  File "C:\reviewboard\reviews\views.py", line 4, in 
from django.contrib.auth.models import User
  File "C:\progra~1\Python25\Lib\site-packages\django\contrib\auth
\models.py", line 4, in 
from django.db import models
  File "C:\progra~1\Python25\Lib\site-packages\django\db\models
\__init__.py", line 6, in 
from django.db.models.query import Q
  File "C:\progra~1\Python25\Lib\site-packages\django\db\models
\query.py", line 5, in 
from django.db.models.fields import DateField, FieldDoesNotExist
  File "C:\progra~1\Python25\Lib\site-packages\django\db\models\fields
\__init__.
py", line 16, in 
from django import oldforms
  File "C:\progra~1\Python25\Lib\site-packages\django\oldforms
\__init__.py", line 3, in 
from django.utils.html import escape
  File "C:\progra~1\Python25\Lib\site-packages\django\utils\html.py",
line 9, in 
from django.utils.http import urlquote
  File "C:\progra~1\Python25\Lib\site-packages\django\utils\http.py",
line 2, in 
from email.Utils import formatdate
  File "C:\reviewboard\reviews\email.py", line 4, in 
from django.contrib.sites.models import Site
  File "C:\progra~1\Python25\Lib\site-packages\django\contrib\sites
\models.py",
line 1, in 
from django.db import models
ImportError: cannot import name models

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



Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-19 Thread Nathaniel Whiteinge

On Jun 19, 3:45 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
>                 if self.instance.state == 'processing':
>                     queryset = queryset.exclude(state='new')

The above lines aren't quite right ``self.instance`` is an instance of
your ``SomeModel`` and presuming there is a foreign key to
``YourStateModel`` it should look something like this instead::

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



Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-19 Thread Nathaniel Whiteinge

On Jun 19, 3:23 pm, Huuuze <[EMAIL PROTECTED]> wrote:
> In this example, what if you wanted to selectively remove a value from
> the choice list.

For that you'll have to move the field declaration into the form's
__init__ method::

class SomeForm(forms.ModelForm):
class Meta:
model = SomeModel

def __init__(self, *args, **kwargs):
super(SomeForm, self).__init__(*args, **kwargs)

# Get the base queryset
queryset = YourStateModel.objects.all()

# Don't forget to pass the instance keyword
# when instantiating your form
if self.instance:
# selectively modify or filter the queryset as needed
if self.instance.state == 'processing':
queryset = queryset.exclude(state='new')

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



Re: Connection.has no attribute ping -- after recompiling modpython

2008-06-19 Thread l5x

On Jun 19, 8:22 pm, l5x <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Request Method:         GET
> Request URL:    https://age86.internetdsl.tpnet.pl/
> Exception Type:         AttributeError
> Exception Value:        'Connection' object has no attribute 'ping'
> Exception Location:     /usr/django/django/db/backends/mysql/base.py in
> _valid_connection, line 162
> Python Executable:      /usr/bin/python
> Python Version:         2.5.0
>
> Traceback:
> File "/usr/django/django/core/handlers/base.py" in get_response
>   82.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/usr/django/django/contrib/auth/decorators.py" in __call__
>   66.         if self.test_func(request.user):
> File "/usr/django/django/contrib/auth/middleware.py" in __get__
>   5.             request._cached_user = get_user(request)
> File "/usr/django/django/contrib/auth/__init__.py" in get_user
>   83.         user = backend.get_user(user_id) or AnonymousUser()
> File "/usr/django/django/contrib/auth/backends.py" in get_user
>   68.             return User.objects.get(pk=user_id)
> File "/usr/django/django/db/models/manager.py" in get
>   82.         return self.get_query_set().get(*args, **kwargs)
> File "/usr/django/django/db/models/query.py" in get
>   192.         num = len(clone)
> File "/usr/django/django/db/models/query.py" in __len__
>   53.                 self._result_cache = list(self.iterator())
> File "/usr/django/django/db/models/query.py" in iterator
>   162.         for row in self.query.results_iter():
> File "/usr/django/django/db/models/sql/query.py" in results_iter
>   200.         for rows in self.execute_sql(MULTI):
> File "/usr/django/django/db/models/sql/query.py" in execute_sql
>   1473.         cursor = self.connection.cursor()
> File "/usr/django/django/db/backends/__init__.py" in cursor
>   33.         cursor = self._cursor(settings)
> File "/usr/django/django/db/backends/mysql/base.py" in _cursor
>   170.         if not self._valid_connection():
> File "/usr/django/django/db/backends/mysql/base.py" in
> _valid_connection
>   162.                 self.connection.ping()
>
> It occured after I had recompiled mod_python 3.3.1 on Apache2.2.3 with
> Python2.5 instead of Python2.4.
>
> I can import MySQLdb using both Python2.5 and Python2.4.
>
> With Python2.4 I could perform 'syncdb' but now it is: Connection
> object has no attribute 'get_server_info'.
>
> My distro is Debian Etch 4.0 Stable. Django is the newest SVN.
>
> Does anybody know how to fix it?

If anybody is interested - it works fine with PostgreSQL (psycopg2)
and SQLite3. No luck with MySQL 5 (MySQLdb).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: eclipse + pydev + auto complete

2008-06-19 Thread Huuuze

You're off by one.  The value added to the PYTHONPATH (note, not
system path) should be:

/Library/Python/2.5/site-packages/

That will trigger the auto-complete for django classes.  One warning:
auto-completion for Model.objects is broken.  PyDev will flag that as
an error -- the author of PyDev is aware of the bug and I'm hoping
we'll see a fix in an upcoming release.


On Jun 19, 11:15 am, tom <[EMAIL PROTECTED]> wrote:
> hi,
>
> I wasn't able to find some information on this list about auto
> completion with eclipse. I managed to get auto completion for my
> projects, but not for django stuff. What I want to have for example
> is, when I enter models. that i get a list of available models, or
> forms. That's it. I have added /Library/Python/2.5/site-packages/
> django to the system path.
>
> Many thanks for your help!
>
> P.s: I use Mac OS X
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-19 Thread Huuuze

In this example, what if you wanted to selectively remove a value from
the choice list.  For example, let's say the list contained New, In
Process, and Closed.  When an item is "In Process", it cannot revert
back to "New".  As such, "New" should not be displayed amongst the
choices if "In Process" has been selected.

I realize I could eliminate the value using JavaScript on the front-
end, but is there a way to bake that logic into the form Model?

On Jun 7, 7:20 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
> On Jun 7, 4:18 pm, Berco Beute <[EMAIL PROTECTED]> wrote:
>
> > Quite a lot of work for something so simple
>
> I agree that overriding default widgets is currently too much work.
> But here's a slightly shorter version that works in exactly the same
> way as your example::
>
>     class SomeForm(forms.ModelForm):
>         class Meta:
>             model = SomeModel
>
>         car = forms.ModelChoiceField(Car.objects.all(),
>                 empty_label=None)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



hashed primary keys

2008-06-19 Thread phillc

Is there anyway to make the primary key of a model a hash of some
sort?
some of these primary keys will be public facing, and i'd rather them
not be counting up sequentially.

in my current implementation, i have left the primary key alone and
have made a unique field that creates a hash and checks for its
existance.

just wondering if there is a simpler way to do it.
(it would remove the redundant two unique identifiers, and reduce
inserts by one (or more) queries that check to see if it already
exists or not.)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ModelForm Question

2008-06-19 Thread Adi

Lets say I have a model:

class Foo(models.Model):
  name = models.charField()
 age = models.IntegerField ()

Then I create a form like this:

class FooForm (ModelForm):
salutation =
forms.ChoiceField(choices=common.SALUTATION_CHOICES,
label="Salutation")

   class Meta:
 model: Foo

I see that the form's cleaned_data does not contain an a key for
salutation. Why is this.. Is this because it is a model form? How do i
get the data entered for Saluation?



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



Re: Why PostgreSQL?

2008-06-19 Thread AmanKow

> Already logged:http://code.djangoproject.com/ticket/3615

I took a look at that ticket, and there was a comment at the end
pointing to a mysql function that checks for constraint violations...

http://forge.mysql.com/tools/tool.php?id=11

Way too mysql guruish for me, but it looks interesting...

If it could be modified in some way to return a list of useful errors
(empty list if no errors) it could be used with a modification of the
patch to provide verification and commit or failure with rollback and
meaningful errors for managed transactions... in other words, it would
eliminate the entire issue of no deferment of constraint checks for
mysql users.

It still wouldn't be ideal, and might impose a significant penalty to
run, but it could make loaddata work as expected in mysql.

On Jun 19, 12:45 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Thu, Jun 19, 2008 at 12:01 PM, AmanKow <[EMAIL PROTECTED]> wrote:
>
> > On Jun 18, 8:48 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> > wrote:
>
> > If I came off sounding accusatory, please forgive me,
> > it was not my intent.
>
> No problems. In the spirit of reconciliation, I didn't intend to be
> harsh either - I just wanted remove any doubt that MySQL is a first
> class citizen from the point of view of the Django core developers.
>
> >> If someone (cough cough... hint hint) were to submit a patch to
> >> implement table ordering on serialized output, I'd have no problem
> >> committing such a patch.
>
> > Hmm hint taken.  I'll start to look at it in my "spare time"...
> > maybe things will cool down at work in a month or two (seriously, I'm
> > swamped right now).  In the mean time, should I submit a ticket?
>
> Already logged:http://code.djangoproject.com/ticket/3615
>
> There's a patch already on that ticket, and it works, but the solution
> provided isn't ideal. The problem with the patch is that when foreign
> key checks are turned on again, there is not validation of data
> inserted when they were off. It's more of a workaround than a
> solution.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Nested Dictionaries in Django Templates

2008-06-19 Thread phillc

you are implementing logic into the templates, which django templating
attempts to prevent.

On Jun 17, 12:27 pm, Keybo <[EMAIL PROTECTED]> wrote:
> Hello,
>        I have a question regarding displaying information in django
> templates. I would like to display a nested dictionary(Hash) in the
> templates. However the only problem is that the values in the
> dictionary are either strings or other dictionaries. If there a way of
> knowing the type of value in the template ?
> For eg:
>         for key_value in dictionary.items:
>              if key_value.1 isTYPE String:
>                do something
>              if key_value.1 isTYPE Dictionary:
>                do something else
>
> Thanks in advance,
> Lezan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: model inheritance and admin (qs-rf & nf-a)

2008-06-19 Thread felix


I second that.  I've just spent the day quite happily refactoring my
app to use nifty model inheritance ... and the admin doesn't work.
whoops.

I think this should be stated in the docs for sure.



On Jun 2, 4:44 pm, ekellner <[EMAIL PROTECTED]> wrote:

> Is newforms-admin any closer to being merged?  This group's archives
> says that it's quite stable and has been for some time, but I don't
> have the impression that the merge is going to be easy or soon.
>
> > It does seem to me that the doc should mention that Admin doesn't currently
> > supportmodelinheritance(care to open a ticket/provide a patch?).
>
> (Done, #7349.  I didn't realize that the web docs were synthesized
> from .txt in source)
>
> Elizabeth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Title: Once again, subclassing User, UserProfile, Multiple User types...

2008-06-19 Thread phillc

"You have to add a User, then add a Student, and then
make sure that you get the right User attached to the student" or,
"Well you don't see the Student's first name and last name, in the
Student listing because those are really attributes of the User.""

could have your save method automatically create the associations.

On Jun 18, 9:58 am, radioflyer <[EMAIL PROTECTED]> wrote:
> On Jun 16, 8:10 pm, Etienne Robillard <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > On Mon, 16 Jun 2008 11:58:48 -0700 (PDT)
>
> > radioflyer <[EMAIL PROTECTED]> wrote:
>
> > > I've spent quite a lot of time reading through information about
> > > extending Django's User model. I've read the arguments about
> > > inheritance vs. user profiles. I've seen some posts in this forum
> > > where the examples even used some of the same model scenarios that I'm
> > > working with. Yet still...I need some help.
>
> > > When I started organizing the data structures for my project, I began
> > > by setting up some of the relationships I knew I would need. I didn't
> > > start with the user authentication issue. Three of the models
> > > (Student, Teacher, Parent) emerged as being a type of user. The
> > > profiles of each of these users are becoming unique enough that one
> > > 'UserProfile' definition does not seem sufficient.
>
> > > User type models:
>
> > > class Student(models.Model):
> > >    parents         = models.ManyToManyField('Parent')
> > >    teachers        = models.ManyToManyField('Teacher')
> > >    sections        = models.ManyToManyField('Section')
> > >    homeroom        = models.ForeignKey('Teacher',
> > > related_name='homeroom_students')
> > >    first_name      = models.CharField()
> > >    last_name       = models.CharField()
> > >    class_year      = models.CharField()
>
> > > class Teacher(models.Model):
> > >    sections        = models.ManyToManyField('Section')
> > >    first_name      = models.CharField()
> > >    last_name       = models.CharField()
>
> > > class Parent(models.Model):
> > >    first_name      = models.CharField()
> > >    last_name       = models.CharField()
>
> > > Other models:
>
> > > class Course(models.Model):
>
> > > class Section(models.Model):
>
> > > class Task(models.Model):
>
> > > It turns out, after trying various suggestions made by others, that
> > > the most important factor is "Make it look right in the admin
> > > interface." I don't want to start out a demo for a client by saying,
> > > "Well there's this Student, User, UserProfile, thing that you have to
> > > get used to" or, "You have to add a User, then add a Student, and then
> > > make sure that you get the right User attached to the student" or,
> > > "Well you don't see the Student's first name and last name, in the
> > > Student listing because those are really attributes of the User."
>
> > > Subclassing. Yes it's a problem if I want to use the same User/Student
> > > over in my After School Sports application.
>
> > > User Profiles.
> > > How do you have more than one? And how do you do it without making a
> > > mess of the Admin interface?
> > > How about a UserProfile with one field, 'user_type' that Parent,
> > > Teacher, Student could have a foreign key relationship to? That's
> > > starting to look messy too.
>
> > > Roles?
>
> > > So. What would James Bennett and Malcolm Trednick do? And how would
> > > they do it? :-)
>
> > > This seems like problem deserving of a Django design pattern. I need
> > > the help of someone smarter than I.
>
> > > Regards,
> > > Dan J.
>
> > > PS. Sometimes a Teacher is a Parent. But, one thing at a time. ;-)
>
> > Hi,
>
> > I think a good design pattern you could try adopting
> > is to name your profiles classes with a ending "Profile"
> > suffix.
>
> > For instance, rename a profile class for Teachers could be
> > named TeacherProfile, and so on.
>
> > That way I think its easier to remember which profiles belong
> > to. Also, you could also define your own ``get_profile`` function:
>
> > In example:
>
> > >>> get_profile = lambda cls,pk: cls._default_manager.get(user__id=pk)
> > >>> profile_data = get_profile(StudentProfile, obj.id)
>
> > Assuming that a 'user' field exists for each profile models.
>
> > To recap:
>
> > 1. Name all profile classes/models with a common suffix
> > 2. Define your own get_profile somewhere in case User.get_profile is not 
> > appropriate for you
> > 3. Forget about multi-table inheritance since its not stable yet -- Focus 
> > on raw admin functionality first :)
>
> > Hope this helps!
>
> > Etienne
>
> Etienne, Thanks for your reply. I'm working on my users with your
> approach now.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-

Re: little problem with the django template language

2008-06-19 Thread phillc

yes they are strings,
yes in python if you do

if item1:
pass

it will evaluate the string as a true/false depending on existance.

however, comparing two strings for equality... checks if they are
equal.

{% if item1 %}
{% if item2 %}
blah
{% endif %}
{% endif %}


On Jun 19, 1:50 pm, mark <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am stuck, please help.
>
> This is what I am trying to do:
>
> {% ifequal item1 item2 %}
>     ...do what I want
>
> item1 = '/test/something/'
> item2 = '/test/somethingelse/'
>
> or
>
> item1 = '/test/'
> tem2 = '/test/simething'
>
> both should evaluate to true and execute the if block.
>
> I experimented with 'item|slice[:]' but I could not find out how to
> determin the position (index) of the second '/'.
>
> Please note I am a beginner in Django and I should probably know how
> to solve this but obviously I do not :-((
>
> Best Regards,
> Mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Url tag issues

2008-06-19 Thread phillc

use of named urls will probably make that a ton easier

On Jun 19, 11:45 am, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have been hitting a brick wall so many times now on this that it is
> starting to hurt!! Please help if you can...
>
> I have an index page, and I want my function for it (in views.py) to take a
> number of parameters to decide what to display, but I can't figure out how
> to do it.
>
> The kinds of options I want to give it are things like, pkid of the thing I
> want to select (for more details), a filter to apply to the list of things
> shown on the index page, the name of the attribute I want to sort the index
> table by.
>
> The problems I am hitting are mainly to do with the {% url
> app.views.function keyword=optval %} tags to generate urls for my link bar.
>
> The combinations or parameters I want to use are:
>
> id
> id + filter
> filter
> and sort_by (alone, or with any of the above combinations)
>
> I have managed to write a regex to understand these options and my views
> function does what I want, but with that regex, the {% url blah thing %}
> just doesn't work at all. Do I need to just write loads of separate regexes
> (for different combinations!)?
>
> The regex that works (reading urls), but doesn't generate urls is something
> along the lines of:
>
> r'^co(|(?P\d*)/)(|/filter/(?P\w*)/)(|sort/(?P\w*)/)$
> '
>
> The kinds of url tag things I have been using are:
>
> {% url myapp.views.index id=3 %}
> {% url myapp.views.index filter_by="comp" %}
> {% url myapp.views.index filter_by="comp",sort_by="date" %}
>
> But they just evaluate to an empty string :(
>
> The problem is the option thing. Am I just being lazy / stupid?
>
> Em
>
> Information Security Analyst, ARM Ltd,
> 110 Fulbourn Road, Cambridge CB1 9NJ, UK
> Tel: +44 (0) 1223 406 365
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Implementing a new idea

2008-06-19 Thread phillc

models.Model.save(self)


super(ProjectModification, self).save()

On Jun 19, 1:41 pm, Adam Fraser <[EMAIL PROTECTED]> wrote:
> Signalling worked out for me but it turned out to be more complex than
> it needed to be.  Here are some references in case anyone is looking:
>
> http://www.chrisdpratt.com/2008/02/16/signals-in-django-stuff-thats-n...http://code.djangoproject.com/wiki/Signals
>
> In the end, I simply resolved to override the save() method of my
> Project class like so:
>
>     def save(self):
>         record_project_modification()
>         models.Model.save(self)
>
> ..here's the function that saves my new ProjectModification object:
>
>     def record_project_modification(self):
>         pmod = ProjectModification()
>         pmod.user_id = 21
>         pmod.project = self
>         pmod.date = datetime.date.today()
>         pmod.change_field = "test"
>         pmod.change_from =  "test"
>         pmod.change_to = "test"
>         pmod.save(pmod)
>
> ...I would have used the method mentioned in my first ref. above, but
> it turns out I couldn't have models importing signals while signals
> imported models.  Otherwise it would have made more sense for me to
> use signaling for scalability and elegance.
>
> -adam
>
> On Jun 18, 11:35 am, Adam Fraser <[EMAIL PROTECTED]> wrote:
>
> > I didn't, but you can bet I will now.  Thanks for the lead!
> > -Adam
>
> > On Jun 17, 4:22 pm, Dan <[EMAIL PROTECTED]> wrote:
>
> > > Did you take a look at Django Signals? You can intercept pre-save and
> > > post-save objects with them. You can use that to grab the data you
> > > want and fill your ProjectModification object. I don't know if there
> > > is a way you could tell if it was done in the admin or not though...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



new forms admin is there an equiv to unique_for_date

2008-06-19 Thread Norman Harman

This is what I'm talking about 
http://www.djangoproject.com/documentation/model-api/#unique-for-date

Searching internets can not find any answer.

Thanks,
-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun!  Check out Austin360.com for all the entertainment
info you need to live it up in the big city!

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



Re: Looping through a specific number of times with a for loop

2008-06-19 Thread Tim Chase

>   For example at the template level...
> 
> {% for news in latest_news_list last 10 %}
> 
>   I'm hoping this would grab the latest 10 objects in the
> latest_news_list. Does anyone know the best way to do this, or have
> some examples set up I could read over?

Looks like you want the slice filter[1]:

{{ for news in latest_news_list|slice:":10" }}

or

{{ for news in latest_news_list|slice:"-10:" }}

assuming latest_news_list is sorted by date.

-tim

[1]
http://www.djangoproject.com/documentation/templates/#slice







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



Re: little problem with the django template language

2008-06-19 Thread roj

Hi,

If you are trying to compare url string then use
request.path
which will give you URL and split by "/"

is that work for you?

Cheers!
Roj
Django Debugging Resource
http://django.freelancernepal.com


On Jun 19, 6:50 pm, mark <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am stuck, please help.
>
> This is what I am trying to do:
>
> {% ifequal item1 item2 %}
> ...do what I want
>
> item1 = '/test/something/'
> item2 = '/test/somethingelse/'
>
> or
>
> item1 = '/test/'
> tem2 = '/test/simething'
>
> both should evaluate to true and execute the if block.
>
> I experimented with 'item|slice[:]' but I could not find out how to
> determin the position (index) of the second '/'.
>
> Please note I am a beginner in Django and I should probably know how
> to solve this but obviously I do not :-((
>
> Best Regards,
> Mark

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



Looping through a specific number of times with a for loop

2008-06-19 Thread Catalyst


  I was trying to figure out the best way to loop through a specific
number of objects in a for loop.

  For example at the template level...

{% for news in latest_news_list last 10 %}

  I'm hoping this would grab the latest 10 objects in the
latest_news_list. Does anyone know the best way to do this, or have
some examples set up I could read over?

  Thanks for your help.

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



Connection.has no attribute ping -- after recompiling modpython

2008-06-19 Thread l5x

Hello,

Request Method: GET
Request URL:https://age86.internetdsl.tpnet.pl/
Exception Type: AttributeError
Exception Value:'Connection' object has no attribute 'ping'
Exception Location: /usr/django/django/db/backends/mysql/base.py in
_valid_connection, line 162
Python Executable:  /usr/bin/python
Python Version: 2.5.0

Traceback:
File "/usr/django/django/core/handlers/base.py" in get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/django/django/contrib/auth/decorators.py" in __call__
  66. if self.test_func(request.user):
File "/usr/django/django/contrib/auth/middleware.py" in __get__
  5. request._cached_user = get_user(request)
File "/usr/django/django/contrib/auth/__init__.py" in get_user
  83. user = backend.get_user(user_id) or AnonymousUser()
File "/usr/django/django/contrib/auth/backends.py" in get_user
  68. return User.objects.get(pk=user_id)
File "/usr/django/django/db/models/manager.py" in get
  82. return self.get_query_set().get(*args, **kwargs)
File "/usr/django/django/db/models/query.py" in get
  192. num = len(clone)
File "/usr/django/django/db/models/query.py" in __len__
  53. self._result_cache = list(self.iterator())
File "/usr/django/django/db/models/query.py" in iterator
  162. for row in self.query.results_iter():
File "/usr/django/django/db/models/sql/query.py" in results_iter
  200. for rows in self.execute_sql(MULTI):
File "/usr/django/django/db/models/sql/query.py" in execute_sql
  1473. cursor = self.connection.cursor()
File "/usr/django/django/db/backends/__init__.py" in cursor
  33. cursor = self._cursor(settings)
File "/usr/django/django/db/backends/mysql/base.py" in _cursor
  170. if not self._valid_connection():
File "/usr/django/django/db/backends/mysql/base.py" in
_valid_connection
  162. self.connection.ping()

It occured after I had recompiled mod_python 3.3.1 on Apache2.2.3 with
Python2.5 instead of Python2.4.

I can import MySQLdb using both Python2.5 and Python2.4.

With Python2.4 I could perform 'syncdb' but now it is: Connection
object has no attribute 'get_server_info'.

My distro is Debian Etch 4.0 Stable. Django is the newest SVN.

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



little problem with the django template language

2008-06-19 Thread mark

Hi,

I am stuck, please help.

This is what I am trying to do:

{% ifequal item1 item2 %}
...do what I want

item1 = '/test/something/'
item2 = '/test/somethingelse/'

or

item1 = '/test/'
tem2 = '/test/simething'

both should evaluate to true and execute the if block.

I experimented with 'item|slice[:]' but I could not find out how to
determin the position (index) of the second '/'.

Please note I am a beginner in Django and I should probably know how
to solve this but obviously I do not :-((


Best Regards,
Mark


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



Re: Implementing a new idea

2008-06-19 Thread Adam Fraser

Signalling worked out for me but it turned out to be more complex than
it needed to be.  Here are some references in case anyone is looking:

http://www.chrisdpratt.com/2008/02/16/signals-in-django-stuff-thats-not-documented-well/
http://code.djangoproject.com/wiki/Signals

In the end, I simply resolved to override the save() method of my
Project class like so:

def save(self):
record_project_modification()
models.Model.save(self)

..here's the function that saves my new ProjectModification object:

def record_project_modification(self):
pmod = ProjectModification()
pmod.user_id = 21
pmod.project = self
pmod.date = datetime.date.today()
pmod.change_field = "test"
pmod.change_from =  "test"
pmod.change_to = "test"
pmod.save(pmod)

...I would have used the method mentioned in my first ref. above, but
it turns out I couldn't have models importing signals while signals
imported models.  Otherwise it would have made more sense for me to
use signaling for scalability and elegance.

-adam

On Jun 18, 11:35 am, Adam Fraser <[EMAIL PROTECTED]> wrote:
> I didn't, but you can bet I will now.  Thanks for the lead!
> -Adam
>
> On Jun 17, 4:22 pm, Dan <[EMAIL PROTECTED]> wrote:
>
> > Did you take a look at Django Signals? You can intercept pre-save and
> > post-save objects with them. You can use that to grab the data you
> > want and fill your ProjectModification object. I don't know if there
> > is a way you could tell if it was done in the admin or not though...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Display image in django admin

2008-06-19 Thread Brian Rosner


On Jun 19, 2008, at 11:34 AM, Leon Yeh | New Avenue.net wrote:
>
>   def thumbnail(self):
>   return "" % (self.photo)

After the function add thumbnail.allow_tags = True.

Brian Rosner
http://oebfare.com




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



Display image in django admin

2008-06-19 Thread Leon Yeh | New Avenue.net

Hi All,

I have a small django admin site that I need to display image into the 
object list.

The photo currently contained the path to image. When got to the page of 
django admin escape the html output.

How can I make it so I can output raw html to the django admin ?

class News(models.Model):
title = models.CharField(max_length=100)
content = models.TextField(blank=True,)
link = models.CharField(max_length=300)
photo = models.CharField(max_length=300,  blank=True,)

def thumbnail(self):
return "" % (self.photo)

class Admin:
list_display = ('title','content', 'thumbnail')




Thanks,

Leon Yeh
New Avenue Systems Inc.

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



Re: Some Django unit tests fail...

2008-06-19 Thread Peter Melvyn

On 6/19/08, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:

> The only obvious thing I can glean from your stack traces is a
>  possible language problem - the last stack trace is complaining of a
>  collation mix, which suggests that your MySQL install isn't using utf8
>  all the time.

Yes, it is the intention. If Django requires test database with
charset UTF8, IMHO it should create it using related clause. as well
as proper engine should be choosen if we care about reference
integrity, e.g.

SET storage_engine=InnoDB;
CREATE DATABASE xxx
  DEFAULT CHARACTER SET utf8
  COLLATE utf8_xxx_ci;


Should I create a ticket ;-)

Peter

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



Re: Timestamped comment field

2008-06-19 Thread Chris H.

On Jun 19, 12:53 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
> Hi Chris,
>
> May be you can try this model :
> ...

While I could store each comment off as an instance of a Comments
model, I don't really have a need to do so.  I'm wanting to have the
comments stored as a TextField on the main object since there's no
need to reference them individually.

I suppose I could also create an Abstract Base Class for this,
something like CommentableItemBase that would have the functionality
defined there to keep it DRY.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django having a foreign key from a field in one database to another

2008-06-19 Thread Jeff

so I am using the Multiple Database Branch of django and currently
have a an app that uses several databases.

one problem I have encountered is that i have a foreign key from a
field in one database to a field in another.

the error I get is
Database1.Table1: 'Table1' is configured to use connection 'Database1'
but has relation with 'Table2', which is configured to use connection
'Database2'

is there a way to define the connection within the foreign key
definition

for my models file for Database 1 I have:

from Database2.models import Table2
class Table1(models.Model):
id = models.AutoField(primary_key=True)
brand = models.ForeignKey(Table2, db_column='brand')
class Meta:
db_table = 'Table1'

your help is much appreciated.

-Jeff


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



django blog which uses staticgenerator?

2008-06-19 Thread lgr888999

There are a shitload of blogging apps for django, i know.
But is there any which supports StaticGenerator that you are aware off?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Select field not generating with form_for_instance?

2008-06-19 Thread Huuuze

Got it worked out using ModelForms.  Version 0.96.2 didn't include any
of these slick features.

For what its worth, I don't believe it would've ever worked using
v0.96.2.

On Jun 19, 11:01 am, Huuuze <[EMAIL PROTECTED]> wrote:
> On Jun 18, 7:32 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Wed, Jun 18, 2008 at 4:53 PM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > > I have the following model:
>
> > > class Publishers(models.Model):
> > >  books = models.CharField(maxlength=1, choices=BOOKS)
>
> > > BOOKS is a tuple:
> > > BOOKS = ( ('1', 'Book A'), ('2', 'Book B') )
>
> > > When I use form_for_instance(Publishers) to generate my template's
> > > HTML based upon the Publisher model, the books field is a standard
> > >  field rather than a  field.
>
> > You aren't actually passing the Publishers model to form_for_instance, are
> > you?  
>
> No.  I'm passing in an object.
>
> > That wouldn't work, you must be passing a Publishers model instance?
> > Or are you using form_for_model?
>
> I'm definitely using form_for_instance.
>
> > Is this a bug in Django or am I missing something?  If its th latter,
>
> > > how can I get the desired effect using my model (I realize I could
> > > create a custom form by coding a PublisherForm(forms.Form) -- trying
> > > to stay DRY).  From my perspective, it seems reasonable to expect the
> > > HTML to be a  field when a "choices" attribute is added to the
> > > model definition.
>
> > I just tried this with a similar model and a recent trunk checkout and
> > form_for_instance generated a select input for the field with choices, as
> > you would expect, so something is going awry with what you are doing.  I
> > can't really guess what, though, based on the information you provided.
>
> > What version of Django are you using?  
>
> I'm using Django 0.96.2.  Which version did you use in your tests?
>
> > Is there a reason you are using the
> > older form_for_ methods instead of the newer (and preferred) ModelForms?
>
> Can you elaborate on ModelForms?  I'm relying solely on Django taking
> my model and generating the HTML.  From what I can tell, using
> ModelForms would require me to repeat my code by creating a new class
> that defines the structure of the form.  Again, I'd prefer to stay DRY
> (don't repeat yourself), but if Django won't play nice, I'll be left
> with no choice.
>
>
>
> > Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Url tag issues

2008-06-19 Thread Emily Rodgers

Hi,

I have been hitting a brick wall so many times now on this that it is
starting to hurt!! Please help if you can...

I have an index page, and I want my function for it (in views.py) to take a
number of parameters to decide what to display, but I can't figure out how
to do it.

The kinds of options I want to give it are things like, pkid of the thing I
want to select (for more details), a filter to apply to the list of things
shown on the index page, the name of the attribute I want to sort the index
table by.

The problems I am hitting are mainly to do with the {% url
app.views.function keyword=optval %} tags to generate urls for my link bar.

The combinations or parameters I want to use are:

id
id + filter
filter
and sort_by (alone, or with any of the above combinations)

I have managed to write a regex to understand these options and my views
function does what I want, but with that regex, the {% url blah thing %}
just doesn't work at all. Do I need to just write loads of separate regexes
(for different combinations!)?

The regex that works (reading urls), but doesn't generate urls is something
along the lines of:

r'^co(|(?P\d*)/)(|/filter/(?P\w*)/)(|sort/(?P\w*)/)$
'

The kinds of url tag things I have been using are:

{% url myapp.views.index id=3 %}
{% url myapp.views.index filter_by="comp" %}
{% url myapp.views.index filter_by="comp",sort_by="date" %}

But they just evaluate to an empty string :(

The problem is the option thing. Am I just being lazy / stupid?

Em

Information Security Analyst, ARM Ltd,
110 Fulbourn Road, Cambridge CB1 9NJ, UK
Tel: +44 (0) 1223 406 365 



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



eclipse + pydev + auto complete

2008-06-19 Thread tom

hi,

I wasn't able to find some information on this list about auto
completion with eclipse. I managed to get auto completion for my
projects, but not for django stuff. What I want to have for example
is, when I enter models. that i get a list of available models, or
forms. That's it. I have added /Library/Python/2.5/site-packages/
django to the system path.

Many thanks for your help!

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



Own threaded management command causes UnboundLocalError at different runs/places

2008-06-19 Thread sector119

Hi ALL!

Can I use threaded management commands? I write simple data import
command from manage.py. This command use threadpool and I sometimes
get UnboundLocalError on some variables (they differ) that they
referenced before assignment.. Why It can be so?

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



Re: Select field not generating with form_for_instance?

2008-06-19 Thread Huuuze

One additional note: Can you post the code you used to get it working?

On Jun 18, 7:32 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 18, 2008 at 4:53 PM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I have the following model:
>
> > class Publishers(models.Model):
> >  books = models.CharField(maxlength=1, choices=BOOKS)
>
> > BOOKS is a tuple:
> > BOOKS = ( ('1', 'Book A'), ('2', 'Book B') )
>
> > When I use form_for_instance(Publishers) to generate my template's
> > HTML based upon the Publisher model, the books field is a standard
> >  field rather than a  field.
>
> You aren't actually passing the Publishers model to form_for_instance, are
> you?  That wouldn't work, you must be passing a Publishers model instance?
> Or are you using form_for_model?
>
> Is this a bug in Django or am I missing something?  If its th latter,
>
> > how can I get the desired effect using my model (I realize I could
> > create a custom form by coding a PublisherForm(forms.Form) -- trying
> > to stay DRY).  From my perspective, it seems reasonable to expect the
> > HTML to be a  field when a "choices" attribute is added to the
> > model definition.
>
> I just tried this with a similar model and a recent trunk checkout and
> form_for_instance generated a select input for the field with choices, as
> you would expect, so something is going awry with what you are doing.  I
> can't really guess what, though, based on the information you provided.
>
> What version of Django are you using?  Is there a reason you are using the
> older form_for_ methods instead of the newer (and preferred) ModelForms?
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Select field not generating with form_for_instance?

2008-06-19 Thread Huuuze



On Jun 18, 7:32 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 18, 2008 at 4:53 PM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I have the following model:
>
> > class Publishers(models.Model):
> >  books = models.CharField(maxlength=1, choices=BOOKS)
>
> > BOOKS is a tuple:
> > BOOKS = ( ('1', 'Book A'), ('2', 'Book B') )
>
> > When I use form_for_instance(Publishers) to generate my template's
> > HTML based upon the Publisher model, the books field is a standard
> >  field rather than a  field.
>
> You aren't actually passing the Publishers model to form_for_instance, are
> you?  

No.  I'm passing in an object.

> That wouldn't work, you must be passing a Publishers model instance?
> Or are you using form_for_model?
>

I'm definitely using form_for_instance.

> Is this a bug in Django or am I missing something?  If its th latter,
>
> > how can I get the desired effect using my model (I realize I could
> > create a custom form by coding a PublisherForm(forms.Form) -- trying
> > to stay DRY).  From my perspective, it seems reasonable to expect the
> > HTML to be a  field when a "choices" attribute is added to the
> > model definition.
>
> I just tried this with a similar model and a recent trunk checkout and
> form_for_instance generated a select input for the field with choices, as
> you would expect, so something is going awry with what you are doing.  I
> can't really guess what, though, based on the information you provided.
>
> What version of Django are you using?  

I'm using Django 0.96.2.  Which version did you use in your tests?

> Is there a reason you are using the
> older form_for_ methods instead of the newer (and preferred) ModelForms?

Can you elaborate on ModelForms?  I'm relying solely on Django taking
my model and generating the HTML.  From what I can tell, using
ModelForms would require me to repeat my code by creating a new class
that defines the structure of the form.  Again, I'd prefer to stay DRY
(don't repeat yourself), but if Django won't play nice, I'll be left
with no choice.

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



Re: ManyToMany Field - is an object in their or not.

2008-06-19 Thread phillc

either way, the database is hit to check that. so if your goal is to
minimize, getting true and false instead of the record has no
advantage. just check if there is something returned.

On Jun 19, 10:14 am, timc3 <[EMAIL PROTECTED]> wrote:
> I have a situation where I want a true or false to whether an object
> is in a manytomany.
>
> For instance, I have my users, and have created (separate to the
> standard django groups) a groups table called GroupsOfUser with a
> relationships defined as:
>
> group_members = models.ManyToManyField(User, verbose_name="group
> members", related_name="groupofumembers")
>
> I know that I can do something like this:
>
> instance = get_object_or_404(GroupsOfUser, id=form["groupid"])
> auth_user = request.user
>
> ismember = auth_user.groupofumembers.filter(id = instance.id)
>
> And this would bring back ismember either populated with a
> GroupsOfUser object, but all I want is a true or false to whether they
> are in this group already. Is there an easy way of doing this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Quick way to find list objects close to the current date?

2008-06-19 Thread Norman Harman

mw wrote:
> Hello,
> 
> 
> I was thinking about ways to list some objects that are close to the
> current date.  I could do this using datetime and just subtract the
> two dates, but this seems like something that has probably been done
> before.  It seems like there would be a more Django way of doing it
> than me doing it manually.

http://www.djangoproject.com/documentation/db-api/#range

-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun!  Check out Austin360.com for all the entertainment
info you need to live it up in the big city!

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



Re: Is it bad to use GET parameters for model entities management in my views?

2008-06-19 Thread Doug Van Horn

I would say first that there's more than one way to skin this cat.  So
if what you're doing works for your team and your users, stick with
it.

Regarding RESTful URLs, my understanding is that the URL is the noun
and the request method is the verb.  E.g.,

http://example.com/somepage/ is your thing (the noun), and you can
GET, POST, PUT, and DELETE that thing via the HTTP protocol.

Since browsers only support GET and POST, you end up having to deal
with PUT and DELETE in another way.  You can make it a part of the url
(http://example.com/somepage/delete/), or you can make it a query
parameter to the URL (http://example.com/somepage/?action=DELETE).  No
right way, necessarily, but I prefer the first as it's more 'user/
human' friendly then the second.  Either way, that request should be a
POST as it changes data on the server.

Typically in Django, you'll see http://example.com/somepage/ coded to
display a resource when it's accessed via GET, and edited/changed when
accessed via POST.  Ideally, you should only be changing data server
side with POSTs, as GETs should be idempotent (they don't change data)
according to the HTTP spec.

Like you said, you can be as religious about this as you want, but at
the end of the day, getting something functional to the user is all
that really matters (many of them don't even look at the URLs).


doug.

On Jun 18, 10:31 pm, Vasiliy Gladkov <[EMAIL PROTECTED]> wrote:
> urls.py for my application looks like this:
>
> urlpatterns = patterns('ms.masterstroy.views',
>         (r'^(?P[^/]+)$', 'page'),
>         ...
> )
>
> As i want to allow site editor to edit pages in convenient way without
> built-in django admin, i use request.GET parameters like "http://
> localhost:8000/somepage?action=edit" and than process it in my
> views.py like this:
>
> def page(request, title):
>   page = Page.objects.get(url_name=title)
>   ...
>   if 'action' in request.GET:
>     action = request.GET['action']
>     if action == 'delete':
>       target_name = request.GET.get('target', '')
>       target_page = get_object_or_404(Page, url_name=target_name)
>       target_page.delete()
>       return http.HttpResponseRedirect('/')
>     if action == 'edit':
>        and so on...
>
> A lot of people from russian django group (http://groups.google.com/
> group/django-russian/browse_thread/thread/678e725e12ccca46 - russian
> language) told me that it's very bad decision as im losing some
> important django advantages.
>
> What they talking about? I have no idea. I have clear and simple urls
> and my urls is much closer to REST princeiples then django admin site
> with all this "http://localhost:8000/admin/my_cms/page/4/delete/"; wich
> is not REST at all. Btw, REST is kind of religion so you can follow it
> or you can not. I just dont want to have large trees of url-patterns
> in my urls.py and move all actions with my model in one view with a
> couple of "if action == ...: elseif action ==..."
>
> And i still can use url reversing in my templates like "{% url page
> 'pagename' %}?action=edit"
>
> So, what is the problem?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: bug in Django Evolution (was "Why PostgreSQL?")

2008-06-19 Thread bruno desthuilliers



On 19 juin, 03:32, Tim Chase <[EMAIL PROTECTED]> wrote:
> > Django Evolution is a slightly different beast - Django Evolution
> > isn't part of the core Django project, and if you read the FAQ, I
> > don't make the claim that MySQL is equally supported under Django
> > Evolution - in fact, I clearly state that MySQL is a work in progress,
> > simply due to my personal priorities. I have also said on many
> > occasions that I would like to fix this situation, but I am only one
> > man, and I only have so much time to give.
>
> Hmm...that would explain the bug I'm getting in Evolution:
>
> Traceback (most recent call last):
>File "testevolution.py", line 42, in exercise:
> OutOfRussMageeError:  Insufficient Russ Magee's; please
> contribute patches and try again.
>

MouarfAHAHAHAHAHA !-)

Just brillant !

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



Re: django-notification management.py not creating notice types.

2008-06-19 Thread Rajesh Dhawan



On Jun 19, 10:08 am, timc3 <[EMAIL PROTECTED]> wrote:
> > Renaming models to notification here is not a good idea (see below for
> > the reason)
>
> > > def create_notice_types(app, created_models, verbosity, **kwargs):
>
> > 
>
> > > dispatcher.connect(create_notice_types,
> > > signal=signals.post_syncdb, sender=notification)
>
> > The sender here must be the app name 'notification'. However, your
> > above import clobbers notification to take on the value of
> > notification.models. The net effect is that your callback function
> > create_notice_types is never called.
>
> > So, after you fix your import above and make sure sender=notification
> > refers to the notification app (i.e. import notification), do the
> > following:
>
> > manage.py reset notification
>
> > Hopefully, that will do the right thing. If it doesn't, try dropping
> > the notification app's tables from your DB, and run syncdb again.
>
> > -Rajesh D
>
> Well that's what the documentation is saying to 
> do,http://code.google.com/p/django-notification/wiki/IntegratingNotifica...
> .

I don't know that application but the signal mechanism is a Django
feature not a django-notification one. The sender=notication.models
that you have there is not going to get called.

Put a debug print statement inside create_notice_types() to verify for
yourself whether it's getting called when you run syncdb.

Then, for a second test, remove that sender parameter:

dispatcher.connect(create_notice_types, signal=signals.post_syncdb)

and try syncdb again.

In all cases, be sure to drop the notification_* tables from your DB
before running a syncdb.



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



Re: Some Django unit tests fail...

2008-06-19 Thread Russell Keith-Magee

On Thu, Jun 19, 2008 at 10:08 PM, Ramiro Morales <[EMAIL PROTECTED]> wrote:
>
> I've found this same problem last week both on a Linux system and on a
> Windows one.
> The common factor was they were systems where the 'stack' has had just
> been installed
> Python 2.4 and Python 2.5 respectively). Installing the right
> setuptools version solved the
> problems.
>
> Maybe a note about this dependency of that particular Django test
> suite component could
> be added to the "Unit tests" section of the "Contributing to Django"  
> document?.

I'm happy to add the note. Open a ticket with some draft text, bump it
to ready-for-checkin and I'll commit it when I get a chance.

Yours,
Russ Magee %-)

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



ManyToMany Field - is an object in their or not.

2008-06-19 Thread timc3

I have a situation where I want a true or false to whether an object
is in a manytomany.

For instance, I have my users, and have created (separate to the
standard django groups) a groups table called GroupsOfUser with a
relationships defined as:

group_members = models.ManyToManyField(User, verbose_name="group
members", related_name="groupofumembers")

I know that I can do something like this:

instance = get_object_or_404(GroupsOfUser, id=form["groupid"])
auth_user = request.user

ismember = auth_user.groupofumembers.filter(id = instance.id)

And this would bring back ismember either populated with a
GroupsOfUser object, but all I want is a true or false to whether they
are in this group already. Is there an easy way of doing this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: From ASP to Django

2008-06-19 Thread PFL

I had to make a similar argument at my job.  You are going to have to
convince
people who are rightly skeptical, wont appreciate the all the core
technological arguments,
and really only care about time and cost.

So, make a business case, not a technical case. Focus on:

1) tangible business benefits
2) reduce risk

On the benefits side,  I'd take your "speed of development" argument
and
think of specific features that you could add to help their business:
- better user experience, better data collection and analysis, etc
- can you factor out some licensed software costs (SQLServer, etc)
- does the current site support foreign language -- will  they need
that?
- what about hosting? In general I think you could make the case that
hosting
  Django and an opensource platform is easier than ASP

On the risk side, you need to convince them that your 2-week estimate
is valid;
you should provide them with some supporting material that breaks down
the
2 weeks into specific tasks so that they will have more confidence in
it.

They also are probably skeptical about Django's traction. I'd visit
Django Sites (http://www.djangosites.org/) and get a list of retailers
that
use Django to show them they would not be the first to do so.

Also, go to a big job board (HotJobs, Craigslist, etc) and do a search
in your location
jobs listing "Django".  That really helped at my job when my VP saw
how many job listings
were posted because he felt like it was an active market and that he
would be able
to find Django experience in the future.

good luck

On Jun 19, 6:02 am, gnijholt <[EMAIL PROTECTED]> wrote:
> Ok I need some thoughts on the following. For a client, we need to
> redesign their website. The back-end was coded a couple of years ago
> in classic ASP. It's fairly complex, with a webshop, uploading and
> parsing of excel files with new collections of clothing, and stuff
> like that. It took people about six months to build it back then.
>
> Personally, I think now is the moment to also revamp the back-end, but
> I'm having trouble to explain the reasons to non-tech people (bosses
> and the client). I reckon I could build most of the back-end within a
> week or two in Django. The problem is that neither the client nor the
> boss care about the technology, as long as it works. They will not pay
> for an upgrade of the back-end to newer technology, unless I can back
> up this decision with valid points. So why should they switch to
> something like Django? I can come up with technological points, such
> as maintainability (less LoC), speed of development in the future...
>
> Thanks

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



Re: django-notification management.py not creating notice types.

2008-06-19 Thread timc3

> Renaming models to notification here is not a good idea (see below for
> the reason)
>
> >     def create_notice_types(app, created_models, verbosity, **kwargs):
>
> 
>
> >     dispatcher.connect(create_notice_types,
> > signal=signals.post_syncdb, sender=notification)
>
> The sender here must be the app name 'notification'. However, your
> above import clobbers notification to take on the value of
> notification.models. The net effect is that your callback function
> create_notice_types is never called.
>
> So, after you fix your import above and make sure sender=notification
> refers to the notification app (i.e. import notification), do the
> following:
>
> manage.py reset notification
>
> Hopefully, that will do the right thing. If it doesn't, try dropping
> the notification app's tables from your DB, and run syncdb again.
>
> -Rajesh D

Well that's what the documentation is saying to do,
http://code.google.com/p/django-notification/wiki/IntegratingNotification
.

I tried:

import notification

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



Re: Some Django unit tests fail...

2008-06-19 Thread Ramiro Morales

On Thu, Jun 19, 2008 at 10:27 AM, Peter Melvyn <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I wanted to make sure that all unit tests will pass after #3030 fix
> and run Django unit tests on trunk updated to r7703 on Windows, Python
> 2.4 and MySQL 5.0.37.
>
> But I found that some test failes:
>
> 1. If I've run all tests, I get error:
>
> Traceback (most recent call last):
>  File "C:\Python24\Lib\site-packages\django-trunk\tests\runtests.py",
> line 183, in ?
>django_tests(int(options.verbosity), options.interactive, args)
>  File "C:\Python24\Lib\site-packages\django-trunk\tests\runtests.py",
> line 153, in django_tests
>failures = run_tests(test_labels, verbosity=verbosity,
> interactive=interactive, extra_tests=extra_tests)
>  File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
> line 136, in run_tests
>suite.addTest(build_suite(app))
>  File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
> line 59, in build_suite
>test_module = get_tests(app_module)
>  File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
> line 17, in get_tests
>test_module = __import__('.'.join(app_path + [TEST_MODULE]), {},
> {}, TEST_MODULE)
>  File 
> "C:\Python24\Lib\site-packages\django-trunk\tests\regressiontests\templates\tests.py",
> line 23, in ?
>from loaders import *
>  File 
> "C:\Python24\Lib\site-packages\django-trunk\tests\regressiontests\templates\loaders.py",
> line 13, in ?
>import pkg_resources
> ImportError: No module named pkg_resources
>

AFAICT the failing test is the one trying to execise the Python egg
template loader.

I've found this same problem last week both on a Linux system and on a
Windows one.
The common factor was they were systems where the 'stack' has had just
been installed
Python 2.4 and Python 2.5 respectively). Installing the right
setuptools version solved the
problems.

Maybe a note about this dependency of that particular Django test
suite component could
be added to the "Unit tests" section of the "Contributing to Django"  document?.

Regards,

-- 
 Ramiro Morales

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



Re: From ASP to Django

2008-06-19 Thread Tim Chase

> boss care about the technology, as long as it works. They will
> not pay for an upgrade of the back-end to newer technology,
> unless I can back up this decision with valid points. So why
> should they switch to something like Django? I can come up
> with technological points, such as maintainability (less LoC),
> speed of development in the future...

Some features I've found:

I find I'm leagues more productive in Python than C-like 
languages (C/C++/C#/Java) as Python is easier to read & write 
than the C-like's

I also understand that classic ASP has been sent out to pasture, 
and MS is offering little support (if any) for it now. 
Python+Django, you've got all the code for all the pieces, and 
the Django devs have made a fairly solid commitment to being 
Python2.3 compat.

Python has a lot of batteries-included libraries for free, that 
often in MS development you have to pay for.

Django URLs are beautiful, ASP URLs are pretty ugly (or at least 
Django makes it easy to make beautiful URLs, but you can make 'em 
ugly if you want; conversely, I understand it's possible to make 
beautiful ASP URLs, but it takes server configuration to do so). 
  This is also advantageous for SEO if that sort of thing matters 
in your case.

Django makes it easy to build RESTful applications, which makes 
it easy to integrate with other apps.  ASP has this crazy 
post-back madness that I regularly find myself sparring against 
when I want to integrate with other apps.

ASP really requires every developer to have a copy of Visual 
Studio (it's possible to develop without, but it's a painful 
experience); Django is happy with a text-editor (so you can use 
edlin, ed, cat, vi, vim, emacs, pico, nano, joe, Wing IDE, 
Eclipse, Textmate, TextPad, Notepad++, Notepad, whatever) 
Programmers using their preferred editor are happier and more 
productive.  I find this is also helpful when using 
version-control, as diff'ing text Django files produces 
meaningful results, whereas diff'ing VS's binary project files is 
100% unhelpful to me.

Django runs on a Linux/BSD box, so you can save your license of 
Windows Server or whatever you're running it on, and use a free OS.

I posted a similar comparison on comp.lang.python back in November:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/ffb00f1a5837fec5/221f7b7a3319cde4#221f7b7a3319cde4

in case you want to see other elements that struck me between 
them from my experience.

-tim





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



Re: Some Django unit tests fail...

2008-06-19 Thread Russell Keith-Magee

On Thu, Jun 19, 2008 at 9:27 PM, Peter Melvyn <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I wanted to make sure that all unit tests will pass after #3030 fix
> and run Django unit tests on trunk updated to r7703 on Windows, Python
> 2.4 and MySQL 5.0.37.

I'm not seeing any failures at the moment; the buildbot:

http://buildbot.djangoproject.com/

concurs (for trunk, anyway).

> Is there anything I've missed that Django unit tests do not pass on my
> installation?

The only obvious thing I can glean from your stack traces is a
possible language problem - the last stack trace is complaining of a
collation mix, which suggests that your MySQL install isn't using utf8
all the time.

Yours
Russ Magee %-)

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



Some Django unit tests fail...

2008-06-19 Thread Peter Melvyn

Hi all,

I wanted to make sure that all unit tests will pass after #3030 fix
and run Django unit tests on trunk updated to r7703 on Windows, Python
2.4 and MySQL 5.0.37.

But I found that some test failes:

1. If I've run all tests, I get error:

Traceback (most recent call last):
  File "C:\Python24\Lib\site-packages\django-trunk\tests\runtests.py",
line 183, in ?
django_tests(int(options.verbosity), options.interactive, args)
  File "C:\Python24\Lib\site-packages\django-trunk\tests\runtests.py",
line 153, in django_tests
failures = run_tests(test_labels, verbosity=verbosity,
interactive=interactive, extra_tests=extra_tests)
  File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
line 136, in run_tests
suite.addTest(build_suite(app))
  File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
line 59, in build_suite
test_module = get_tests(app_module)
  File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
line 17, in get_tests
test_module = __import__('.'.join(app_path + [TEST_MODULE]), {},
{}, TEST_MODULE)
  File 
"C:\Python24\Lib\site-packages\django-trunk\tests\regressiontests\templates\tests.py",
line 23, in ?
from loaders import *
  File 
"C:\Python24\Lib\site-packages\django-trunk\tests\regressiontests\templates\loaders.py",
line 13, in ?
import pkg_resources
ImportError: No module named pkg_resources


2. If I've run single tests, I get error in some particular tests as well, e.g.

FAIL: Doctest: modeltests.basic.models.__test__.API_TESTS
--
...
Failed example:
Article.objects.get(pk=a.id).headline
Expected:
u'\u6797\u539f \u3081\u3050\u307f'
Got:
u'Article 12'

###

FAIL: Doctest: modeltests.custom_pk.models.__test__.API_TESTS
--

File 
"C:\Python24\Lib\site-packages\django-trunk\tests\modeltests\custom_pk\models.py",
line ?, in modeltests.custom_pk.models.__test__.API_TESTS
Failed example:
emp.save()
Exception raised:
Traceback (most recent call last):
  File "C:\Python24\Lib\site-packages\django-trunk\django\test\_doctest.py",
line 1267, in __run
compileflags, 1) in test.globs
  File "", line 1, in ?
emp.save()
  File 
"C:\Python24\Lib\site-packages\django-trunk\django\db\models\base.py",
line 272, in save
self.save_base()
  File 
"C:\Python24\Lib\site-packages\django-trunk\django\db\models\base.py",
line 313, in save_base
if manager.filter(pk=pk_val).extra(select={'a':
1}).values('a').order_by():
  File 
"C:\Python24\Lib\site-packages\django-trunk\django\db\models\query.py",
line 84, in __nonzero__
iter(self).next()
  File 
"C:\Python24\Lib\site-packages\django-trunk\django\db\models\query.py",
line 78, in _result_iter
self._fill_cache()
  File 
"C:\Python24\Lib\site-packages\django-trunk\django\db\models\query.py",
line 494, in _fill_cache
self._result_cache.append(self._iter.next())
  File 
"C:\Python24\Lib\site-packages\django-trunk\django\db\models\query.py",
line 520, in iterator
for row in self.query.results_iter():
  File 
"C:\Python24\Lib\site-packages\django-trunk\django\db\models\sql\query.py",
line 200, in results_iter
for rows in self.execute_sql(MULTI):
  File 
"C:\Python24\Lib\site-packages\django-trunk\django\db\models\sql\query.py",
line 1474, in execute_sql
cursor.execute(sql, params)
  File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line
166, in execute
self.errorhandler(self, exc, value)
  File "C:\Python24\Lib\site-packages\MySQLdb\connections.py",
line 35, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1267, "Illegal mix of collations
(latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for
operation '='")

etc...

###

Is there anything I've missed that Django unit tests do not pass on my
installation?


Thx, Peter

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



Re: From ASP to Django

2008-06-19 Thread Dan

Microsoft ditched classic ASP.

"It's unsupported" usually carries some weigth as an argument with bosses.

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



Re: From ASP to Django

2008-06-19 Thread Shane Emmons
ASP will cost more. Windows Servers are more expensive, not to mention the
developer studio costs. What database backend are they using? If it is MS
SQL then there is another large cost that could be removed by using Postgre
or MySQL. Then just slip it to them that Google uses Python, not Microsoft
products.

On Thu, Jun 19, 2008 at 9:02 AM, gnijholt <[EMAIL PROTECTED]> wrote:

>
> Ok I need some thoughts on the following. For a client, we need to
> redesign their website. The back-end was coded a couple of years ago
> in classic ASP. It's fairly complex, with a webshop, uploading and
> parsing of excel files with new collections of clothing, and stuff
> like that. It took people about six months to build it back then.
>
> Personally, I think now is the moment to also revamp the back-end, but
> I'm having trouble to explain the reasons to non-tech people (bosses
> and the client). I reckon I could build most of the back-end within a
> week or two in Django. The problem is that neither the client nor the
> boss care about the technology, as long as it works. They will not pay
> for an upgrade of the back-end to newer technology, unless I can back
> up this decision with valid points. So why should they switch to
> something like Django? I can come up with technological points, such
> as maintainability (less LoC), speed of development in the future...
>
> Thanks
> >
>


-- 
Shane Emmons

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



From ASP to Django

2008-06-19 Thread gnijholt

Ok I need some thoughts on the following. For a client, we need to
redesign their website. The back-end was coded a couple of years ago
in classic ASP. It's fairly complex, with a webshop, uploading and
parsing of excel files with new collections of clothing, and stuff
like that. It took people about six months to build it back then.

Personally, I think now is the moment to also revamp the back-end, but
I'm having trouble to explain the reasons to non-tech people (bosses
and the client). I reckon I could build most of the back-end within a
week or two in Django. The problem is that neither the client nor the
boss care about the technology, as long as it works. They will not pay
for an upgrade of the back-end to newer technology, unless I can back
up this decision with valid points. So why should they switch to
something like Django? I can come up with technological points, such
as maintainability (less LoC), speed of development in the future...

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



Re: Is it bad to use GET parameters for model entities management in my views?

2008-06-19 Thread Vasiliy Gladkov



On 19 июн, 17:42, Bradley Wright <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On Jun 19, 4:31 am, Vasiliy Gladkov <[EMAIL PROTECTED]> wrote:
>
> > As i want to allow site editor to edit pages in convenient way without
> > built-in django admin, i use request.GET parameters like "http://
> > localhost:8000/somepage?action=edit"
>
> Like inline editing (Flickr-style), right?

Yes, that's exactly what im doing.

> > A lot of people from russian django group (http://groups.google.com/
> > group/django-russian/browse_thread/thread/678e725e12ccca46 - russian
> > language) told me that it's very bad decision as im losing some
> > important django advantages.
>
> I would guess the advantages are the robust and secure admin interface
> that comes packaged in django.contrib.admin, but as long as you're
> decorating your edit/delete/whatever views with logjn security I don't
> really see the problem either.

All of this actions permited for editors - company staff - only. For
persons who passed login procedure and who has turned on "is_staff"
flag in django.contrib.auth.

> Ryan Tomayko has done something similar (assuming we're talking about
> the same thing):
>
> http://tomayko.com/writings/administrative-debris

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



Re: How can I convert .py file to .pyc file.

2008-06-19 Thread Sudhir Porwal





jitesh wrote:

  Sorry for my noviceness.
Is it possible to handover an application to my client without giving
the source code because I don't want to open the source code OR is
there any way to convert .py file to .pyc or .exe file.
Any help is appreciated.



  

In python, the
compiled byte code may be decompiled easily.
you may opt for obfuscation  of code (to make your code hard to read
for your client).

you may try http://www.lysator.liu.se/~astrand/projects/pyobfuscate/


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





Re: How can I convert .py file to .pyc file.

2008-06-19 Thread Daniel Hepper

> Try py2exe www.py2exe.org
Besides being Windows only, Py2Exe just bundles your byte code with an
interpreter in a convenient package. The byte code can still be
extracted and decompiled. It just raises the bar.

FWIW, I think if you use an interpreted language, you just have to live
with the fact that your source code is more or less accessible.

Regards,
Daniel


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



Re: How can I convert .py file to .pyc file.

2008-06-19 Thread Daniel Hepper

Python source code (.py) is automatically compiled to byte code (.pyc)
when you import a module.

More info here:
http://effbot.org/zone/python-compile.htm

However, it seems that pyc files can still be decompiled, google for
"uncompile pyc" for more info.
 
HTH,
Daniel

Am Donnerstag, den 19.06.2008, 03:03 -0700 schrieb jitesh:
> Sorry for my noviceness.
> Is it possible to handover an application to my client without giving
> the source code because I don't want to open the source code OR is
> there any way to convert .py file to .pyc or .exe file.
> Any help is appreciated.
> 
> > 


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



Re: How can I convert .py file to .pyc file.

2008-06-19 Thread Alex Gusarov

Try py2exe www.py2exe.org

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



How can I convert .py file to .pyc file.

2008-06-19 Thread jitesh

Sorry for my noviceness.
Is it possible to handover an application to my client without giving
the source code because I don't want to open the source code OR is
there any way to convert .py file to .pyc or .exe file.
Any help is appreciated.

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



CSS retrieval

2008-06-19 Thread Aldo Bergamini

Dear list,

I have a question that I could not solve by 'list archival peeking'.  
Although I got a couple of messages hinting at the same problem I  
have, I did not find one pointing to the solution.

It's about Firefox and it's access to the basic css files for Django.  
If I a access my Django application on my local development machine  
both Safari and Firefox apply the css files to the view templates.

So I get the nice Django color scheme, from the login to my  
application 'views'. So far so good.

As I am creating a somewhat complex tool that accesses data on  
databases that are hosted on the private lan, while I can have a few  
sample data sets on my laptop, I need to have a still non production  
setup accessing some more Postgres databases; this setup is such that  
can be accessed through an Apache reverse proxy setup, actually still  
pointing to a simple Django debug server; I use this a second test  
environment.

I have setup the related Apache reverse proxying; the point that  
puzzles me is that on Safari (MacOSX) I get the HTML pages along with  
their CSS files, whereas Firefox,  afaik still on MacOSX, does not  
display the 'graphic' CSS attributes of the page elements.

The same setup on the localhost config on my laptop (directly talking  
to the Django server with no proxying) works well on both browsers.

I had even some accesses from Windows with XP on the external server:  
CSS files are passed along from the Django server to the browser via  
Apache.

So what is wrong with the Apache proxying setup, so that apparently  
only FireFox has problems getting CSS files?

BTW: in the messages I found in the archives there were hints about  
the trace that the HTTP request causes on the console, when getting  
(or failing to get) a CSS file. Neither on the localhost setup or on  
the Apache server do I ever see a request for a CSS file (whatever  
browser I am using to do my little tests).

Thanks for any pointer to an explanation/solution.

Best regards,
Aldo


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



Re: django-registration with my custom user profile

2008-06-19 Thread pihentagy

You didn't provide the 'dob' parameter.

On Jun 13, 12:02 pm, Chr1s <[EMAIL PROTECTED]> wrote:
> Hi thanks for your replay,
> It is the second situation, I re-write the form.py like this
>
> class RegistrationForm(forms.Form):
>    (other stuff  )
> def save(self, profile_callback=None):
>
>         new_user =
> RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],
>
> password=self.cleaned_data['password1'],
>
> email=self.cleaned_data['email'],
>
> nickname = self.cleaned_data['nickname'],
>
> country = self.cleaned_data['country'],
>
> province = self.cleaned_data['province'],
>
> city = self.cleaned_data['city'],
>
> gender = self.cleaned_data['gender'],
>
> phone = self.cleaned_data['phone'],
>
> bio = self.cleaned_data['bio'],
>
> profile_callback=profile_callback)
>         return new_user
>
> and then I changed the models.py in this way.
>
> def create_inactive_user(self, username, password,
> email,dob,nickname,country,province,
>                              city,gender,phone,bio,send_email=True,
> profile_callback=None):
>         new_user =
> User.objects.create_user(username,last_name,first_name, email,
> password)
>         new_user.is_active = False
>         new_user.save()
>
>         registration_profile = self.create_profile(new_user)
>         userdetail =
> UserDetail(new_user,nickname,dob,country,province,city,gender,phone,bio)
>         userdetail.save()
>         if profile_callback is not None:
>             profile_callback(user=new_user)
>
> but the browser throw the error like this
>
> TypeError at /veryuser/register/
> create_inactive_user() takes at least 12 non-keyword arguments (4
> given)
>
> thanks
>
> On Jun 13, 5:17 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> > 2008/6/13 Chr1s <[EMAIL PROTECTED]>:
>
> > > But still I don't know how to implement this, anyone could give me a
> > > simple example? thanks very much
>
> > This feature is intended for a situation where each of the following is 
> > true:
>
> > 1. You have a custom user-profile model.
> > 2. The user-profile model has been written in such a way that an
> > instance can be created using nothing but default values (e.g., with
> > no input whatsoever from the user).
>
> > If that is the case, simply write a function which can create an
> > instance using nothing but default values, and pass that as the
> > argument.
>
> > If that is not the case, you will either need to write a more complex
> > custom form (to handle any additional information you want to collect)
> > or create the profile in a separate step (e.g., using
> > django-profiles).
>
> > --
> > "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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newbie: Filter an inclusion tag

2008-06-19 Thread pihentagy

Thanks! Saved my day :)

On Jun 17, 2:32 am, Ned Batchelder <[EMAIL PROTECTED]> wrote:
> I think this will work:
>
>     {% filter truncatewords:10 %}
>     {% i18n_attr auction 'description' LANGUAGE_CODE %}
>     {% endfilter %}
>
> --Ned.http://nedbatchelder.com

> pihentagy wrote:
> > Hi all!
>
> > I have an inclusion tag:
> > {% i18n_attr auction 'description' LANGUAGE_CODE %}
>
> > I don't know how can I filter it with truncatewords.
>
> > {% i18n_attr auction 'description' LANGUAGE_CODE|truncatewords:10 %}
> > doesn't work.
>
> > Any ideas?
>
> > thanks
>
> --
> Ned Batchelder,http://nedbatchelder.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trouble querying across relationships

2008-06-19 Thread Arien

On Wed, Jun 18, 2008 at 11:21 PM, Austin Govella
<[EMAIL PROTECTED]> wrote:
> I'm pulling all events for a city:
>
> events = Event.objects.filter(city=city)
>
> Each event can have a set of attractions like food, dancing, drama,
> djs, live music, art, etc.
>
> How do I query the list of attractions for events in that city? (Query
> all attractions that are tied to events in that city)

You're looking for "lookups that span relationships":
http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships

In this case, you want something like "filter the attractions in such
a way that the name of the city of the related event is ... and
eliminate duplicates in the resulting list":

  attractions = Attraction.objects.filter(event__city__name='...').distinct()

The details depend on your exact models, but that's the idea.


Arien

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



Re: Is it bad to use GET parameters for model entities management in my views?

2008-06-19 Thread Bradley Wright

Hi,

On Jun 19, 4:31 am, Vasiliy Gladkov <[EMAIL PROTECTED]> wrote:

> As i want to allow site editor to edit pages in convenient way without
> built-in django admin, i use request.GET parameters like "http://
> localhost:8000/somepage?action=edit"

Like inline editing (Flickr-style), right?

> A lot of people from russian django group (http://groups.google.com/
> group/django-russian/browse_thread/thread/678e725e12ccca46 - russian
> language) told me that it's very bad decision as im losing some
> important django advantages.

I would guess the advantages are the robust and secure admin interface
that comes packaged in django.contrib.admin, but as long as you're
decorating your edit/delete/whatever views with logjn security I don't
really see the problem either.

Ryan Tomayko has done something similar (assuming we're talking about
the same thing):

http://tomayko.com/writings/administrative-debris

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



Re: Django HTML Editor

2008-06-19 Thread Gene Campbell

I just wrote that I use jEdit and although it's not great, I don't
care.  But, now after reading this thread, I'm starting to care.  I'm
learning python and django at the same time, and having some handy
"code intelligence" would be nice - linking method usages to defs and
code completion.  I don't know if jEdit can do this with Python, I've
tried to get sidekick and the various py pluggins going, and honestly
if they just don't work or are supposed to work, but I don't have time
to sort it out.  I probably have the syntax highlighting setup wrong,
or it's buggy.

Anyway, I'm looking at Komodo.  When you know a language really well,
code completion isn't as important, but when you're learning it's
awesome.  It keeps you from making those context switches to a book or
online reference.

I'll likely miss some of the editing features of jEdit like vertical
selections.   It really is the best editor I've ever used, and
probably ever will use.  (Though I really bummed that I have to use
Java 1.4 just to get middle mouse pasting to work from Xwindows to a
jEdit buffers.)

I wish the perfect editor/IDE would materialize!!!

gene


On Thu, Jun 19, 2008 at 3:57 PM, Tai <[EMAIL PROTECTED]> wrote:
>
> I've been using jEdit for years as well.
>
> O. Rutherford has created Django and Djagno+HTML modes available on
> his personal site.  The status says that they are not committed, and
> that he has split the original Django mode.
>
> http://www.rutherfurd.net/jedit/modes/index.html#django
>
> Cheers,
>
> Tai
>
> On Jun 15, 2:23 am, "Gene Campbell" <[EMAIL PROTECTED]> wrote:
>> jEdit - I've used it for years; it is good but not great for django.
>> But, it's just a killer editor, I don't care.
>>
>>
>>
>> On Sun, Jun 15, 2008 at 3:42 AM, mario <[EMAIL PROTECTED]> wrote:
>>
>> > Hi,
>>
>> > Have you tried using TinyMCE. It works and is compatible with Django
>> > Templates including bundled templates such as flatpages, etc.
>> > The URL ishttp://tinymce.moxiecode.com/?id=powered_by_tinymce_mini.
>> > Also check out Bill De Hora web site,
>> >http://www.dehora.net/journal/2006/05/using_tinymce_in_djangos_admin.
>> > It has excellent examples how to integate TinyMCE with Django.
>>
>> > I personally use it in my web site. Good luck!
>>
>> > Sincerely yours,
>>
>> > Mario
>>
>> > On Jun 14, 2:06 am, Ngu Soon Hui <[EMAIL PROTECTED]> wrote:
>> >> I want a free HTML editor that is compatible with Django template's
>> >> syntax. I just want to edit my Django power application's HTML faster.
>> >> When I say compatible, I mean that the editor shouldn't screw up all
>> >> the Django template's tags and variables.
>>
>> >> I used some HTML editors out there, but they are not compatible with
>> >> Django template in that they don't recognize the tags. I am not sure
>> >> whether there are any HTML editor that can do this job.
>>
>> --
>> Picante Solutions Limited
>> e: [EMAIL PROTECTED]
>> w: 06 757 9488
>
> >
>



-- 
Picante Solutions Limited
e: [EMAIL PROTECTED]
w: 06 757 9488

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