Re: model name ending with an 's'

2009-07-17 Thread Earl Lapus
On Sat, Jul 18, 2009 at 1:54 PM, Alex Gaynor  wrote:

>
>
> You can provide verbose name, and verbose name plural to control that:
> http://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name
>
> Alex
>
>
It works! Thanks a lot!

-- 
There are seven words in this sentence.

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



runserver at the same ip address and port number doesn't report error

2009-07-17 Thread fyaqq

I tried to start the development server with the same ip address and
port number twice.
I supposed to see the second one fail with an error message like port
number already in use.
But I didn't see it and there is no error message.

Can someone tell me what's the reason behind this?

Thanks a lot.

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



looking for developer who can help..

2009-07-17 Thread AE

Hello,

I have posted the message at the pinax users group without any luck
thought I will have better luck here. I would like to integrate pinax
with the apps listed below. End result will be open source and hosted
in github, here are the apps :

http://github.com/CrowdSense/django-subscription/tree/master
http://github.com/CrowdSense/django-prepaid/tree/master
http://github.com/CrowdSense/django-muaccounts/tree/master

The goal is to provide hosted community If you are seriously
interested Your cost should reflect the fact that end result is open
source. please contact me privately, you do need to be able to start
within a week. Look forward to hear from you

Anton.

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



Re: model name ending with an 's'

2009-07-17 Thread Alex Gaynor

On Sat, Jul 18, 2009 at 12:52 AM, Earl Lapus wrote:
> hi,
>
> I have a model named 'Services'. I added it to the admin page and an extra
> 's' was appended to the name (see attached file).
> I grep'd through my project directory and I'm pretty sure that there are no
> text that matches 'Servicess'.
> So, is django the one altering the model name? If so, is there a way to
> override it?
>
> thanks.
>
> --
> There are seven words in this sentence.
>
> >
>

You can provide verbose name, and verbose name plural to control that:
http://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



model name ending with an 's'

2009-07-17 Thread Earl Lapus
hi,

I have a model named 'Services'. I added it to the admin page and an extra
's' was appended to the name (see attached file).
I grep'd through my project directory and I'm pretty sure that there are no
text that matches 'Servicess'.
So, is django the one altering the model name? If so, is there a way to
override it?

thanks.

-- 
There are seven words in this sentence.

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

<>

Re: Decouple URLs and get_absolute_url issue

2009-07-17 Thread grant neale
Answering myself.

I knew it was something pathetic and I found it:

This is what I was doing wrong
(r'^weblog/'$, include('coltrane.urls.entries')),

This is what I should have been doing right
(r'^weblog/', include('coltrane.urls.entries')),

The dollar sign cuts of anything that I was including in the "entries"  
file.

Hope that may help some other bastd like me.

Grant


On 17 Jul 2009, at 11:13, grant neale wrote:

>
> Hi,
>
> I'm going through James Bennet's Practical Django projects.
>
> When I de-couple the urls to "urls folder" + "url category"  I
> get_absolute_url doesn't work.
> If I put the urls back into the main urls.py file get_absolute_urls
> works again.
>
> I must be missing something very basic, but I'm pretty much stuck.
>
> Thoughts ?
>
> Grant
>
>
>
> >


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



Re: Graphing (Pie Chart, Bar Graphs, Line Plots, etc) in Django?

2009-07-17 Thread Shawn Milochik

"Beginning Python Visualization" was recently published to fit exactly  
this need. (No disclaimer -- I have no association with the book other  
than having purchased it.)



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



Re: looking for a clean, easy way to force user to change password on first login

2009-07-17 Thread Shawn Milochik

This isn't ideal, but it should work (or prompt someone to propose  
something better).

Add a one-to-one table for the user, with a field containing the  
initial password (encrypted, of course, so it looks like the password  
in the auth_user table).

When the user logs in, have the login page check to see if the  
passwords match. If they do, redirect to the password change page  
instead of the normal redirect page.



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



Re: Current user in model.save() context

2009-07-17 Thread Shawn Milochik

I think you still have to pass the user, but you can tell if the item  
is modified or new by whether its id has a value. If it's brand new  
and has never been saved, then it won't have one.

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



Re: how to alter (add/del cols) the tables from the existing models

2009-07-17 Thread Shawn Milochik

Look at south or evolution. I use south, personally. It does exactly  
this very easily.

http://south.aeracode.org/wiki/Tutorial1

To add a column to the database with south, you add it to the model,  
then:

./manage.py startmigration appname migration_name --add-field  
model.field

So, if your app was named awesome, and you added field thumb to model  
Hand, it would look like this:

./manage.py startmigration awesome added_thumb --add-field Hand.thumb

then:

./manage.py migrate

Of course, check out the tutorial.

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



Re: Limiting administration based on user settings

2009-07-17 Thread Shawn Milochik


On Jul 17, 2009, at 8:08 AM, Rune Bromer wrote:

>
> Hello.
>
> For a small webshop I have the following models: Product, Category,
> Country and UserProfile. Each user have a country set with a FK, and
> should only be allowed to see content in the administration assigned
> to the same Country. The Product and Category have FKs to the Country
> model so I can ensure this by writing a "formfield_for_foreignkey" on
> the ModelAdmin. So far so good, as I can also filter the admin list
> view by overwriting the queryset() model on the ModelAdmin.
>
> The problem now is that I can assign several categories to each
> Product. But I only want to allow people to see the Categories for the
> same Country as the product. How is that possible. Apparently the
> options for the m2m field is not filtered by the queryset and I can't
> see there is a formfield_for_manytomanyfield?

There is probably a way to do this if you dig deep enough into the  
Django code, but the admin wasn't meant for this. According to the  
second edition of "The Definitive Guide," the admin was meant to be an  
easier-to-use and less-powerful replacement for the command-line  
interface to your database. If you are developing in an environment  
where the content creators are trusted to have this kind of access,  
then it's an added convenience.

Creating forms and modelforms is simple, and have the added benefit of  
being much easier to control layout.

Your views could get the request.user.country and use that as an  
automatic filter.

Shawn

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



Re: Non-editable (but visible) fields in admin?

2009-07-17 Thread Shawn Milochik


On Jul 16, 2009, at 11:11 PM, Rubens Altimari wrote:

>
> Hello,
>
> Is there a way to show model fields in admin, but prevent them from
> being edited? Using 'editable=False' in the model won't do, since then
> the field simply is not displayed.
>
> Also, on a related topic: is there a simple way to allow the user to
> set a certain field when *creating* a new record, but then "lock" the
> field from further changes? Similar to the previous question, only I
> wanted to allow the field to be set when creating the record.
>
> Thanks in advance,
> Rubens
>

The short answer to part one is "yes," because you can customize  
everything in Django. However, I don't know if it's trivial to modify  
the admin in that way, and that's really not the kind of thing the  
admin was intended for. You should probably just make a form for this  
functionality. It would take about a minute, and the view wouldn't  
take much longer.

For the second part, certainly. Just override the save function of the  
model. If the object already has a primary key, then don't save those  
fields. There may be a more elegant way to check whether it's already  
been saved than checking the instance.id, so maybe someone else will  
chime in.

Shawn



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



Re: Accessing Meta properties and a templating question.

2009-07-17 Thread Beetle B.

Russell Keith-Magee wrote:
> > 1. In the Python code, how can I access various Meta properties of a
> > model (e.g. verbose_name, etc). At the moment, I do it via
> > model._meta.verbose_name, but I always get chills down my spine when I
> > access properties beginning with a single underscore. Is there a
> > "proper" way?
>
> Yes - you pass the data you want in the context as a normal context variable.

I must have been unclear: The two questions are unrelated. I want to
know how to access the verbose_name for a model within the Python
code, not the template.

I have a function that takes in a model, and I want to get that
model's verbose_name (or plural, or some other Meta property). Is
there a way to do this other than model._meta.verbose_name?

> > 2. Can someone explain the rationale behind not allowing access to
> > properties of objects that begin with double underscores in the
> > template? It worked in 1.02, but with SVN I can't access anything like
> > object.__class__. I'm merely curious as to why this was restricted. In
> > one or two cases, life was easier for me when I could do it.
>
> To the best of my knowledge, you have _never_ been able to access
> 'protected and private' attributes(i.e., attributes starting with _)
> in a template. Are you certain you were able to do this in the past?

Yes. In fact, I only discovered that this was a problem when I
switched to the subversion from 1.02 recently and had the site fail to
work. It has been working fine on Webfaction's 1.02 for more than a
month with me accessing a protected variable (double underscore, I
believe).

Hmm...Tried it for another object, and it isn't working as well with
1.02. I'm 100% sure it worked for something else I was doing - but I
don't want to go through the trouble of duplicating it because I
changed quite a bit of the system to get it working with subversion
and it's probably not worth the bother. Probably an obscure bug.

> If this is true, it would be a major backwards incompatibility, and
> one that we will need to fix. However, I'm not aware of any changes
> that have been made to the template system since v1.0 was released -
> certainly none that would make this change.

Oh what the heck. Looked through my logs and managed to duplicate:

You're right, stuff like {{ object.__str__ }} doesn't work in either.
However, in 1.02, the following works:

{% ifequal object.__str__  some_string %}
Look ma! It works!
{% endifequal %}

whereas I get an exception in subversion. I don't know if that's just
for ifequal or whether it'll occur with {% if %} and others, as well.

(And I don't recall whether the match actually worked or not - but
that's another story).

Since it fails under SVN, I'm assuming it was caught and fixed. I
haven't looked at the Incompatibility list to see if it's there.

Anyway, though, what's the rationale for not allowing double
underscored properties? I know single underscores are considered poor
practice, but I don't recall that accessing the double underscore
properties as being discouraged. After all, people do it all the time
in Python, and I'm sure Django's source makes heavy use of it...


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



Re: question about the DEBUG setting

2009-07-17 Thread Shawn Milochik

And as a brief aside, I've found it helpful to have a  
local_settings.py, which lives outside version control.

If you put your database stuff and DEBUG flag there, you never have to  
fix it when you move to production.

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



Re: Accessing Form Data in Form Object

2009-07-17 Thread Shawn Milochik

Try using form.data.initial to get the text only.

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



Re: Generating forms question.

2009-07-17 Thread Shawn Milochik

On Jul 16, 2009, at 5:16 AM, Viacheslav Chumushuk wrote:
> 
> class Book(models.Model):
>author = models.ForeignKey(Author)
>title = models.CharField(max_length=100)
>
> All that I need is edit some book by primary key.


Just make a forms.ModelForm for your Book model. The class Meta will  
contain 'model = Book.' You don't need any of that inline stuff to  
edit a single instance.

Briefly (assuming your ModelForm is named BookForm):

In your view, you will make an instance of your ModelForm:

book_form = BookForm()

Then do the typical render_to_response bit.

You will also have an if request.POST in your view. If that's hit,  
then you will declare your form like this:

book_form = BookForm(request.POST) #if you're not doing a  
request.POST.copy(), which you probably should.

Then: if book_form.is_valid(), you save it. If not, you let it fall  
out of that if statement into your render_to_response part.

Make sure that if the form doesn't validate, you're not doing the  
"bare" book_form = BookForm() and overwriting your bound version. The  
bare version could be above the if, or in an else clause.

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



Re: Graphing (Pie Chart, Bar Graphs, Line Plots, etc) in Django?

2009-07-17 Thread Justin Lilly

It would also be worth pointing out Jacob's django-googlecharts
template tags. I've used them before and they work solidly, as long
as google charts are what you need.

http://github.com/jacobian/django-googlecharts/tree/master

 -justin

On Thu, 16 Jul 2009, Keith Pettit wrote:

> What is the best way to create Pie Charts, Bar Graphs, Line Plots, etc?
> I've only seen two Django graph type modules but they seem dead.
> 
> Are they any Python modules or other type of graphing apps that would work
> well with Django?
> 
> Thanks,
> 
> -- 
> Keith Pettit
> 
> > 

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



Re: Expert System

2009-07-17 Thread Carlos Eduardo Sotelo Pinto

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Joshua Russo escribió:
> I second that. In my experience they are inherently very context
> specific, with very unique databases and code bases. With that said, you
> can definitely develop an expert system using django. It's more about
> the algorithms you produce than the environment you produce them in. 

I was thinkin about using the powerful of django for dabase admin and templates 
for web and make the
algorithms on python modules... after that call them as a simple module... my 
question is about a
maden job about it.

thanks

> 
> 
> On Fri, Jul 17, 2009 at 11:22 PM, Joshua Partogi
> mailto:joshua.part...@gmail.com>> wrote:
> 
> What kind of expert system do you want to know. I think expert
> system is a very broad topic.
> 
> 
> On Sat, Jul 18, 2009 at 10:05 AM, Carlos Eduardo Sotelo Pinto
> mailto:csot...@aqpglug.org.pe>> wrote:
> 
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Hi peolple
> 
> some one knows somthing about works about expert system maden on
> python with django
> 
> thanks a lot
> 
> 
> -- 
> http://blog.scrum8.com
> http://twitter.com/scrum8
> 
> 
> 
> 
> 
> > 


- --
 . ''`. Carlos Eduardo Sotelo Pinto ( KrLoS )  ,= ,-_-. =.
: :'  : Free and OpenSource Software Developer((_/)o o(\_))
`. `'`  GNULinux Registered User #379182   `-'(. .)`-'
  `-GNULinux Registered Machine #277661\_/
GNULinux Arequipa Users Group||Debian Arequipa Users Group
- --
pgp.rediris.es 0xF8554F6B
GPG FP:697E FAB8 8E83 1D60 BBFB 2264 9E3D 5761 F855 4F6B
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkphN0MACgkQnj1XYfhVT2t9VgCgtkTLwB3RFmURdSq/YrlhrPBL
ujsAn0koJSoLvP5Of+QmSFFD0++SfOhK
=juXY
-END PGP SIGNATURE-

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



Re: Accessing Meta properties and a templating question.

2009-07-17 Thread Russell Keith-Magee

On Fri, Jul 17, 2009 at 9:53 PM, Beetle B. wrote:
>
> Hi,
>
> 1. In the Python code, how can I access various Meta properties of a
> model (e.g. verbose_name, etc). At the moment, I do it via
> model._meta.verbose_name, but I always get chills down my spine when I
> access properties beginning with a single underscore. Is there a
> "proper" way?

Yes - you pass the data you want in the context as a normal context variable.

> 2. Can someone explain the rationale behind not allowing access to
> properties of objects that begin with double underscores in the
> template? It worked in 1.02, but with SVN I can't access anything like
> object.__class__. I'm merely curious as to why this was restricted. In
> one or two cases, life was easier for me when I could do it.

To the best of my knowledge, you have _never_ been able to access
'protected and private' attributes(i.e., attributes starting with _)
in a template. Are you certain you were able to do this in the past?

If this is true, it would be a major backwards incompatibility, and
one that we will need to fix. However, I'm not aware of any changes
that have been made to the template system since v1.0 was released -
certainly none that would make this change.

Can you provide specifics of the Django versions that you believe
allowed this behaviour, and the earliest version in which you are
aware that it was removed?

Yours
Russ Magee %-)

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



Re: syncdb doesn't updated database after adding null=True to an IntegerField

2009-07-17 Thread Shawn Milochik
> 
> Apart from django-evolution, also take a look at http://south.aeracode.org/


I second that -- I use South and it's really handy. I couldn't get  
Evolution to work (maybe I didn't wait long enough ^_^), but South  
does everything I need. The nice thing about it is that it's easily  
reversible or completely removable if you need to dump it -- just  
delete one database table and remove it from installed_apps.

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



Re: pre-fetch one-to-many and many-to-many relationships

2009-07-17 Thread Russell Keith-Magee

On Fri, Jul 17, 2009 at 11:06 PM, Miriam wrote:
>
> There currently is no way in Django to pre-fetch one-to-many and/or
> many-to-many relationships, right?

Correct.

> There's select_related, which will pre-fetch FK or one-to-one, which
> is great, but not sufficient.
>
> Suppose I am fetching a list of Blog posts and I want to pre-fetch the
> Comments for each of these posts? There's no way to do that in
> Django.
>
> I was looking through the tickets at code.djangoproject.com and I
> didn't see anything about this.
>
> Does anyone know if this feature is planned for sometime down the
> road? Anyone have a work-around or a patch or anything. This is
> supremely irritating.

You're not the first to suggest the idea. There are two (well, three)
obstacles that are standing in the way of this idea:

Firstly - What's the interface to this? Is it just an extension of the
capabilities of select_related? If so - how does the proposed
interface map to SQL? In particular, what happens to the results in A
that are duplicated when you do a select_related() onto B?

Second - How do we constrain the performance implications? For
example, if a table with just 3 rows does a select_related() on a
table that contains 1 rows, how do you prevent an query
accidentally bringing the system to it's knees?

Third - someone needs to actually write the code. However, this is a
non-issue until the first two are resolved.

The reason select_related() has been implemented for the N-1 case, but
not the 1-N case is that the answer to the first two questions is
easy. Since the relationship has cardinality 1, all you're doing is
extending the result line. There's no need to worry about handling of
repeated results; performance problems are limited to concerns of the
depth that select_related will traverse.

If you have any particularly inspired answers to these questions for
the 1-N case, feel free to let us know. We're always interested in
making Django better.

Yours,
Russ Magee %-)

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



Re: Flushing the cache during testing

2009-07-17 Thread Russell Keith-Magee

On Sat, Jul 18, 2009 at 6:21 AM, Andrew Fong wrote:
>
> I'm playing around with some low-level caching of model instances.
> During testing, it's necessary for me to flush out the cache so cached
> whatnot from one test doesn't pollute another.
>
> To my knowledge, Django's currently doesn't offer support for
> resetting the cache after each testcase in the same way it does for
> the test database (via the custom testcase class).
>
> The options I'm looking at:
>> Manually (re)starting a separate cache process
>> Adding a prefix to my cache keys and changing them for each test case
>
> Ideally, I'd just like to flush the cache but after poking around in
> Django's caching code, I haven't seen any explicit support for
> flushing. Does anyone have any ideas?

You're correct that there isn't any explicit support for cache
flushing in the Django cache API. However, you can manually flush the
cache - the technique just depends on the cache backend you are using.
In most cases, you will be able to fall back to the capabilities of
the underlying cache implementation. For example, to flush memcache,
you can use the capabilities of the underlying cache object:

from django.core.cache import cache
cache._cache.flush_all()

If you're using locmem, you can just reset the dictionary in the cache object:

from django.core.cache import cache
self._cache = {}

Analogous solutions will exist for the other backends.

Another possibility is to use the dummy cache for testing - that is,
use the cache backend that doesn't actually cache. This will ensure
that you don't get any caching effects in your code. Of course, this
doesn't help if you're actually trying to test the caching behaviour.

However, your original point is valid. Caching is one of those things
that needs to be reset for testing purposes. It makes sense for
Django's cache backend to expose a flushing capability, and Django's
TestCase should be using these facilities. Please open a ticket to
make sure this idea isn't lost. If you take a swing at a patch (and
tests), I'll see about getting it into trunk in the v1.2 timeframe.

Yours,
Russ Magee %-)

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



Re: RequestContext current_app keyword argument

2009-07-17 Thread Russell Keith-Magee

On Sat, Jul 18, 2009 at 7:27 AM, Vasil
Vangelovski wrote:
>
> Looking at the code for the ModelAdmin class in
> django.contrib.admin.options I've come accross this:
> context_instance = template.RequestContext(request,
> current_app=self.admin_site.name)
> in a few places. What is this current_app argument?

http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context

> When I try to init a RequestContext with the current_app argument from
> my code it fails saying that the __init__ method doesn't accept such
> kwarg. What am I missing here?

The current_app argument was added as part of the fix for reversing
admin URLs. The argument is definitely available to both Context and
RequestContext. If your code is raising errors when you pass
current_app='xxx' to RequestContext, then your Django checkout isn't
completely up to date.

To confirm - line 100 of django/template/context.py is the definition
of RequestContext. It should read:

def __init__(self, request, dict=None, processors=None, current_app=None):
Context.__init__(self, dict, current_app=current_app)

Yours,
Russ Magee %-)

>
> >
>

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



Re: Expert System

2009-07-17 Thread Joshua Russo
I second that. In my experience they are inherently very context specific,
with very unique databases and code bases. With that said, you
can definitely develop an expert system using django. It's more about
the algorithms you produce than the environment you produce them in.

On Fri, Jul 17, 2009 at 11:22 PM, Joshua Partogi
wrote:

> What kind of expert system do you want to know. I think expert system is a
> very broad topic.
>
> On Sat, Jul 18, 2009 at 10:05 AM, Carlos Eduardo Sotelo Pinto <
> csot...@aqpglug.org.pe> wrote:
>
>>
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>>
>> Hi peolple
>>
>> some one knows somthing about works about expert system maden on python
>> with django
>>
>> thanks a lot
>>
>
> --
> http://blog.scrum8.com
> http://twitter.com/scrum8
>
>
> >
>

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



Re: Expert System

2009-07-17 Thread Joshua Partogi
What kind of expert system do you want to know. I think expert system is a
very broad topic.

On Sat, Jul 18, 2009 at 10:05 AM, Carlos Eduardo Sotelo Pinto <
csot...@aqpglug.org.pe> wrote:

>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi peolple
>
> some one knows somthing about works about expert system maden on python
> with django
>
> thanks a lot
>

-- 
http://blog.scrum8.com
http://twitter.com/scrum8

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



Expert System

2009-07-17 Thread Carlos Eduardo Sotelo Pinto

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi peolple

some one knows somthing about works about expert system maden on python with 
django

thanks a lot


- --
 . ''`. Carlos Eduardo Sotelo Pinto ( KrLoS )  ,= ,-_-. =.
: :'  : Free and OpenSource Software Developer((_/)o o(\_))
`. `'`  GNULinux Registered User #379182   `-'(. .)`-'
  `-GNULinux Registered Machine #277661\_/
GNULinux Arequipa Users Group||Debian Arequipa Users Group
- --
pgp.rediris.es 0xF8554F6B
GPG FP:697E FAB8 8E83 1D60 BBFB 2264 9E3D 5761 F855 4F6B
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkphEbEACgkQnj1XYfhVT2sC1gCglnsLe6qwRwChs9M2VTXWvaaM
tGkAn3e9rNCl+a8LOaEYT+FC5cWOV36s
=g4Z3
-END PGP SIGNATURE-

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



RequestContext current_app keyword argument

2009-07-17 Thread Vasil Vangelovski

Looking at the code for the ModelAdmin class in
django.contrib.admin.options I've come accross this:
context_instance = template.RequestContext(request,
current_app=self.admin_site.name)
in a few places. What is this current_app argument?
When I try to init a RequestContext with the current_app argument from
my code it fails saying that the __init__ method doesn't accept such
kwarg. What am I missing here?

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



How can I do per-connection initialization using connection_created?

2009-07-17 Thread gthank

It's not clear to me how I can execute a statement on the newly
created connection when the sender is the wrapper class, not the
connection I want to initialize. I reopened 
http://code.djangoproject.com/ticket/6064
since the final implementation doesn't seem to address the original
problem, but was told this is a better place.

The reason I am trying to do this is so I can implement multitenancy
using a schema-per-client solution in Postgres. If there is a better
way to do that than initializing each connection a request creates,
I'd be glad to look into that.

Thanks,

Hank

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



looking for a clean, easy way to force user to change password on first login

2009-07-17 Thread pjv

i am working on a project where i need to create a number of users
(standard django User objects who will login to the site using the
vanilla django auth framework) along with random passwords (rather
than allowing the users to sign up and supply their own passwords).
after the site launches, staff will email each user their username and
the generated random password and a link to the site.

ideally, the random password would be a one-time password and when the
user logs in, they would be automatically redirected to the change
password page and required to pick a new password.

i've thought about creating a special link to put into the email that
would hit a view that redirected to the change password view rather
than the usual home page after login, but that seems a little kludgy
and also easy to get around since the user might not use the link from
the email.

i've done a fair amount of googling and struck out. i don't want to
reinvent the wheel here, or write a bunch of code if i don't have to.
anyone have any ideas or pointers to prior art?

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



Flushing the cache during testing

2009-07-17 Thread Andrew Fong

I'm playing around with some low-level caching of model instances.
During testing, it's necessary for me to flush out the cache so cached
whatnot from one test doesn't pollute another.

To my knowledge, Django's currently doesn't offer support for
resetting the cache after each testcase in the same way it does for
the test database (via the custom testcase class).

The options I'm looking at:
> Manually (re)starting a separate cache process
> Adding a prefix to my cache keys and changing them for each test case

Ideally, I'd just like to flush the cache but after poking around in
Django's caching code, I haven't seen any explicit support for
flushing. Does anyone have any ideas?

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



Re: Django charset problem

2009-07-17 Thread Andrew Fong

Try fetching the data via Django's shell. What do you get then?

Also, how did you configure MySQL to work with UTF-8? Did you modify
your my.cnf file so UTF-8 is the default? Or did you change your
database's settings manually? Or something else?

-- Andrew

On Jul 17, 5:33 pm, Larry  wrote:
> Hi,
>
> I have a database with messages stored and utf-8 encoded. The messages
> look OK in the database, i.e, when I am in MySQL client the messages
> with special characters (e.g., Korean) are correctly displayed.
> However, in the web page, the special characters become
> irrecognizable, like this
>
> ã‚°ãƒ¼ã‚°ãƒ«ã ®æœ€æ–°ã ®ãƒ‡ãƒ¼ã‚¿ã‚»ãƒ³ã‚¿ãƒ¼ã ¯é žå¸¸è­˜ã ªã »ã ©é
> €²åŒ–㠗㠦㠄る ï¼  Blog on Publickey
>
> I read the django documentation it says django handles the coding
> automatically, but apparently this is not the case. Could anyone tell
> me what could wrong, is it the problem of the database of the django
> setting or other problem?
>
> Any help would be appreciated. Thanks in advance.
> -Larry
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django charset problem

2009-07-17 Thread Larry
Hi,

I have a database with messages stored and utf-8 encoded. The messages
look OK in the database, i.e, when I am in MySQL client the messages
with special characters (e.g., Korean) are correctly displayed.
However, in the web page, the special characters become
irrecognizable, like this

ã‚°ãƒ¼ã‚°ãƒ«ã ®æœ€æ–°ã ®ãƒ‡ãƒ¼ã‚¿ã‚»ãƒ³ã‚¿ãƒ¼ã ¯é žå¸¸è­˜ã ªã »ã ©é
€²åŒ–㠗㠦㠄る ï¼  Blog on Publickey

I read the django documentation it says django handles the coding
automatically, but apparently this is not the case. Could anyone tell
me what could wrong, is it the problem of the database of the django
setting or other problem?

Any help would be appreciated. Thanks in advance.
-Larry

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



Re: A question about reverse url lookups for admin site in svn version

2009-07-17 Thread Vasil Vangelovski

Yeah, I was confused mostly about the stuff with the colon because I
didn't pay much attention when reading about namespaced urls the new
docs.

Thanks

On Fri, Jul 17, 2009 at 10:49 PM, Michael wrote:
> On Fri, Jul 17, 2009 at 4:27 PM, Vasil Vangelovski 
> wrote:
>>
>> Sorry, it was probably my missunderstanding of some details in the
>> docs. I changed the initialization of my admin site so it doesn't have
>> a name and what I was trying to do works now. But anyway, if my admin
>> site was initialized like so site = MyAdminSite('admin') what code is
>> supposed to give me the url for it's index page?
>>
>> On Fri, Jul 17, 2009 at 9:48 PM, Vasil
>> Vangelovski wrote:
>> > Yes it does work, I've tried this with a brand new project in the same
>> > virtualenv. Reverese resolution of urls for the AdminSite in
>> > django.contrib.admin does work with the latest trunk revision.
>> > Here's simplest situation where I'm having a problem:
>> >
>> > I have an app called admin in my project which contains some
>> > templatetags and a subcalss of AdminSite, you can see the relevant
>> > code in this dpaste:
>> > http://dpaste.com/68309/
>> > The shell interaction is here:
>> > http://dpaste.com/68303/
>> > Note in my installed apps I have both my admin application and the
>> > admin app from django.contrib.
>> > The same shell interaction would work without a problem if I try it in
>> > another project where I use just django.contrib.admin.sites.AdminSite
>> > Note that changing the url regex for the admin from empty to
>> > r'^admin/' doesn't change anything, it's like that because the django
>> > project
>> > is just an admin site for a larger project done in Java/Flex.
>> > Thanks.
>
> Try reverse('admin:index ')
> The colon is the new namespaces that were just added to the django
> urlresolvers. Pretty exciting, huh?
> FYI the admin uses 'admin' as the default app instance. I am not sure what
> this will do if you have two apps that are named the same and try to
> reverse. It might just be unpredictable as to which URL is going to be
> returned or might throw an error. I am not sure. You might want to change
> that to something else.
> Hope that helps,
> Michael
> >
>

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



Re: Graphing (Pie Chart, Bar Graphs, Line Plots, etc) in Django?

2009-07-17 Thread Javier Guerra

don't forget Flot:  http://code.google.com/p/flot/   why do it in the
server when you can use your user's machine?

-- 
Javier

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



Re: Overriding admin forms

2009-07-17 Thread greatlemer

On Jul 17, 3:06 pm, cornjuliox  wrote:
> Hi everyone. I'm new to Django, learning things mostly through trial
> and error, but this time I can't seem to figure out what went wrong. I
> overrode the admin change_form.html for my model so that I could add a
> Javascript RTE that I found, but not only does the text area look
> broken (it's split in two, on separate lines), the slug field no
> longer prepopulates (it did before I changed things). The RTE works as
> expected, though. I'm not sure what I'm supposed to be pasting in
> order to get an accurate diagnosis, so here's everything I think is
> relevant.

> This is the model in question:
> class Entry(models.Model):
>     # ALL TITLES MUST BE UNIQUE! The slug is gonna give me problems if
> it isn't.
>     title = models.CharField(max_length=250, unique=True)
>     slug = models.SlugField(
>         help_text="This field will be filled in automatically based on
> the title field.\
>                   You don't need to fill this in. Honest."
>     )
>     subject = models.CharField(max_length=140)
>     category = models.ManyToManyField(Category)
>     author = models.ForeignKey(User)
>     dateTime = models.DateTimeField(default=datetime.datetime.now)
>     content = models.TextField()
>     content_html = models.TextField()
>
>     class Meta:
>         ordering = ['-dateTime']
>         verbose_name_plural = "Entries"
>
>     def __unicode__(self):
>         return self.title
>
>     def get_aboslute_url(self):
>         return "/%s/%s" % (self.dateTime.strftime("%Y/%b/%d").lower
> (),self.slug)
>
>     def save(self):
>         html_data = markdown.markdown(self.content)
>         super(Entry, self).save()
>
> This is the modeladmin for the model:
> class EntryAdmin(admin.ModelAdmin):
>     fields = ('title', 'subject', 'slug', 'dateTime', 'category',
> 'content',)
>     prepopulated_fields = {'slug' : ('title',)}
>     date_hierarchy = 'dateTime'
>     list_filter = ('dateTime',)
>
>     def save_model(self, request, object, form, change):
>         if not change:
>             object.author = request.user
>         object.save()
>
> And this is the new form:
> {% extends "admin/change_form.html" %}
> {% block form_top %}
>         A customized entry form.
> {% endblock %}
>
> {% block extrahead %}
>         http://js.nicedit.com/nicEdit-latest.js"; type="text/
> javascript">
>         bkLib.onDomLoaded
> (nicEditors.allTextAreas);
> {% endblock %}
>
> I placed this file in my templates dir, in the /admin/(my_app)/Entry
> folder. Any help would be greatly appreciated, because I'm really
> stuck on this one.

I'm not sure if this will help but try adding {{ block.super}}
somewhere in your {% block extrahead %} section as it sounds like you
may have inadvertantly stopped some JavaScript from loading.

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



Re: A question about reverse url lookups for admin site in svn version

2009-07-17 Thread Michael
On Fri, Jul 17, 2009 at 4:27 PM, Vasil Vangelovski
wrote:

>
> Sorry, it was probably my missunderstanding of some details in the
> docs. I changed the initialization of my admin site so it doesn't have
> a name and what I was trying to do works now. But anyway, if my admin
> site was initialized like so site = MyAdminSite('admin') what code is
> supposed to give me the url for it's index page?
>
> On Fri, Jul 17, 2009 at 9:48 PM, Vasil
> Vangelovski wrote:
> > Yes it does work, I've tried this with a brand new project in the same
> > virtualenv. Reverese resolution of urls for the AdminSite in
> > django.contrib.admin does work with the latest trunk revision.
> > Here's simplest situation where I'm having a problem:
> >
> > I have an app called admin in my project which contains some
> > templatetags and a subcalss of AdminSite, you can see the relevant
> > code in this dpaste:
> > http://dpaste.com/68309/
> > The shell interaction is here:
> > http://dpaste.com/68303/
> > Note in my installed apps I have both my admin application and the
> > admin app from django.contrib.
> > The same shell interaction would work without a problem if I try it in
> > another project where I use just django.contrib.admin.sites.AdminSite
> > Note that changing the url regex for the admin from empty to
> > r'^admin/' doesn't change anything, it's like that because the django
> > project
> > is just an admin site for a larger project done in Java/Flex.
> > Thanks.
>

Try reverse('admin:index ')

The colon is the new namespaces that were just added to the django
urlresolvers. Pretty exciting, huh?

FYI the admin uses 'admin' as the default app instance. I am not sure what
this will do if you have two apps that are named the same and try to
reverse. It might just be unpredictable as to which URL is going to be
returned or might throw an error. I am not sure. You might want to change
that to something else.

Hope that helps,

Michael

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



Re: How to implement a custom field (or relation) which supports List of Strings

2009-07-17 Thread Sam Tregar
On Fri, Jul 17, 2009 at 3:23 PM, Dudley Fox  wrote:

>
> Should I have posted this to the developer's list? I ask because I
> have received no responses yet. Not even a "...you shouldn't do that."
> :)


I can help you with that - you shouldn't do that.   Instead you should
create a new model for friends and link users to friends with a one-to-many
relation.  Each friend can have a single character field for their name,
which will give you a list of strings (friends) attached to each user.

Does that make sense?

-sam

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



Re: A question about reverse url lookups for admin site in svn version

2009-07-17 Thread Vasil Vangelovski

Sorry, it was probably my missunderstanding of some details in the
docs. I changed the initialization of my admin site so it doesn't have
a name and what I was trying to do works now. But anyway, if my admin
site was initialized like so site = MyAdminSite('admin') what code is
supposed to give me the url for it's index page?

On Fri, Jul 17, 2009 at 9:48 PM, Vasil
Vangelovski wrote:
> Yes it does work, I've tried this with a brand new project in the same
> virtualenv. Reverese resolution of urls for the AdminSite in
> django.contrib.admin does work with the latest trunk revision.
> Here's simplest situation where I'm having a problem:
>
> I have an app called admin in my project which contains some
> templatetags and a subcalss of AdminSite, you can see the relevant
> code in this dpaste:
> http://dpaste.com/68309/
> The shell interaction is here:
> http://dpaste.com/68303/
> Note in my installed apps I have both my admin application and the
> admin app from django.contrib.
> The same shell interaction would work without a problem if I try it in
> another project where I use just django.contrib.admin.sites.AdminSite
> Note that changing the url regex for the admin from empty to
> r'^admin/' doesn't change anything, it's like that because the django
> project
> is just an admin site for a larger project done in Java/Flex.
> Thanks.
>
>
> On Fri, Jul 17, 2009 at 4:46 PM, Michael wrote:
>> On Fri, Jul 17, 2009 at 10:28 AM, Vasil Vangelovski 
>> wrote:
>>>
>>> I'm using svn trunk version of django (rev. #11263). In my project I
>>> have only one admin site registered in the urlconf. This admin site is
>>> a subcalss of django.contrib.admin.sites.AdminSite and is instantiated
>>> with the name 'admin'. I'm trying to use reverse url lookups for the
>>> admin site as described in the docs:
>>> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#admin-reverse-urls
>>> But it doesn't work, I always get a NoReverseMatch exception.
>>> Can someone confirm that reverse url lookups for admin sites work as
>>> described in the docs with the latest trunk revision?
>>
>> I can confirm they work, but they were only checked in less than 48 hours
>> ago, so I would first double check and make sure you have the newest version
>> of the django svn. If you are all updated and it still doesn't work, posting
>> your admin site, model admin and where the urlreversing is happening, we can
>> help you.
>> Also, sometimes you can get a more helpful error message from the shell. The
>> reverse() function that you can use is available in
>> django.core.urlresolvers.
>> Let us know how it is going,
>> Michael
>> >>
>>
>

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



GeoDjango Job Posting

2009-07-17 Thread modelmike

Extend a Django Web site currently on PostgreSQL by adding GeoDjango
mapping features.  The application tracks large whale rescues and is
based out of the U.S. National Marine Fisheries Service office in
Gloucester, Massachusetts.

You can email me for more information or contact the contracting
company:

http://www.integratedstatistics.com/Database.htm


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



Re: A question about reverse url lookups for admin site in svn version

2009-07-17 Thread Vasil Vangelovski

Yes it does work, I've tried this with a brand new project in the same
virtualenv. Reverese resolution of urls for the AdminSite in
django.contrib.admin does work with the latest trunk revision.
Here's simplest situation where I'm having a problem:

I have an app called admin in my project which contains some
templatetags and a subcalss of AdminSite, you can see the relevant
code in this dpaste:
http://dpaste.com/68309/
The shell interaction is here:
http://dpaste.com/68303/
Note in my installed apps I have both my admin application and the
admin app from django.contrib.
The same shell interaction would work without a problem if I try it in
another project where I use just django.contrib.admin.sites.AdminSite
Note that changing the url regex for the admin from empty to
r'^admin/' doesn't change anything, it's like that because the django
project
is just an admin site for a larger project done in Java/Flex.
Thanks.


On Fri, Jul 17, 2009 at 4:46 PM, Michael wrote:
> On Fri, Jul 17, 2009 at 10:28 AM, Vasil Vangelovski 
> wrote:
>>
>> I'm using svn trunk version of django (rev. #11263). In my project I
>> have only one admin site registered in the urlconf. This admin site is
>> a subcalss of django.contrib.admin.sites.AdminSite and is instantiated
>> with the name 'admin'. I'm trying to use reverse url lookups for the
>> admin site as described in the docs:
>> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#admin-reverse-urls
>> But it doesn't work, I always get a NoReverseMatch exception.
>> Can someone confirm that reverse url lookups for admin sites work as
>> described in the docs with the latest trunk revision?
>
> I can confirm they work, but they were only checked in less than 48 hours
> ago, so I would first double check and make sure you have the newest version
> of the django svn. If you are all updated and it still doesn't work, posting
> your admin site, model admin and where the urlreversing is happening, we can
> help you.
> Also, sometimes you can get a more helpful error message from the shell. The
> reverse() function that you can use is available in
> django.core.urlresolvers.
> Let us know how it is going,
> Michael
> >
>

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



Re: How to implement a custom field (or relation) which supports List of Strings

2009-07-17 Thread Dudley Fox

Should I have posted this to the developer's list? I ask because I
have received no responses yet. Not even a "...you shouldn't do that."
:)

Sincerely,
Dudley

On Wed, Jul 15, 2009 at 11:38 AM, Dudley Fox wrote:
> I want to create a new type of field for django models that is
> basically a ListOfStrings. So in your model code you would have the
> following:
>
> models.py:
>
>   from django.db import models
>
>   class ListOfStringsField(???):
>   ???
>
>   class myDjangoModelClass():
>   myName = models.CharField(max_length=64)
>   myFriends = ListOfStringsField() #
>
> other.py:
>
>   myclass = myDjangoModelClass()
>   myclass.myName = "bob"
>   myclass.myFriends = ["me", "myself", "and I"]
>
>   myclass.save()
>
>   id = myclass.id
>
>   loadedmyclass = myDjangoModelClass.objects.filter(id__exact=id)
>
>   myFriendsList = loadedclass.myFriends
>   # myFriendsList is a list and should equal ["me", "myself", "and I"]
>
>
> My first attempt at this looks like the following, and appears to work
> as I expect:
> ==
> class ListValueDescriptor(object):
>
>   def __init__(self, lvd_parent, lvd_model_name, lvd_value_type,
> lvd_unique, **kwargs):
>  """
> This descriptor object acts like a django field, but it will accept
> a list of values, instead a single value.
> For example:
># define our model
>class Person(models.Model):
>   name = models.CharField(max_length=120)
>   friends = ListValueDescriptor("Person", "Friend",
> "CharField", True, max_length=120)
>
># Later in the code we can do this
>p = Person("John")
>p.save() # we have to have an id
>p.friends = ["Jerry", "Jimmy", "Jamail"]
>...
>p = Person.objects.get(name="John")
>friends = p.friends
># and now friends is a list.
> lvd_parent - The name of our parent class
> lvd_model_name - The name of our new model
> lvd_value_type - The value type of the value in our new model
>This has to be the name of one of the valid django
>model field types such as 'CharField', 'FloatField',
>or a valid custom field name.
> lvd_unique - Set this to true if you want the values in the list to
> be unique in the table they are stored in. For
> example if you are storing a list of strings and
> the strings are always "foo", "bar", and "baz", your
> data table would only have those three strings listed in
> it in the database.
> kwargs - These are passed to the value field.
>  """
>  self.related_set_name = lvd_model_name.lower() + "_set"
>  self.model_name = lvd_model_name
>  self.parent = lvd_parent
>  self.unique = lvd_unique
>
>  # only set this to true if they have not already set it.
>  # this helps speed up the searchs when unique is true.
>  kwargs['db_index'] = kwargs.get('db_index', True)
>
>  filter = ["lvd_parent", "lvd_model_name", "lvd_value_type", "lvd_unique"]
>
>  evalStr = """class %s (models.Model):\n""" % (self.model_name)
>  evalStr += """value = models.%s(""" % (lvd_value_type)
>  evalStr += self._params_from_kwargs(filter, **kwargs)
>  evalStr += ")\n"
>  if self.unique:
> evalStr += """parent = models.ManyToManyField('%s')\n"""
> % (self.parent)
>  else:
> evalStr += """parent = models.ForeignKey('%s')\n""" % 
> (self.parent)
>  evalStr += "\n"
>  evalStr += """self.innerClass = %s\n""" % (self.model_name)
>
>  print evalStr
>
>  exec (evalStr) # build the inner class
>
>   def __get__(self, instance, owner):
>  value_set = instance.__getattribute__(self.related_set_name)
>  l = []
>  for x in value_set.all():
> l.append(x.value)
>
>  return l
>
>   def __set__(self, instance, values):
>  value_set = instance.__getattribute__(self.related_set_name)
>  for x in values:
> value_set.add(self._get_or_create_value(x))
>
>   def __delete__(self, instance):
>  pass # I should probably try and do something here.
>
>
>   def _get_or_create_value(self, x):
>  if self.unique:
> # Try and find an existing value
> try:
>return self.innerClass.objects.get(value=x)
> except django.core.exceptions.ObjectDoesNotExist:
>pass
>
>  v = self.innerClass(value=x)
>  v.save() # we have to save to create the id.
>  return v
>
>   def _params_from_kwargs(self, filter, **kwargs):
>  """Given a dictionary of arguments, build a string which
>  represents it as a parameter list, and filter out any
>  keywords in filter."""
>  params = ""
>  for key in kwargs:
> if key not in filter:
>value = kwargs[key]
>

Re: accessing multiple dbs?

2009-07-17 Thread Richard E. Cooke

Thanks for the replies!

Happily I have managed to avoid the issue.  We will just make one
Django site per database.  Using a web page to post all the different
sites, thus making it "look" like its accessing multiple dbs..

Cheap shot I know, but I'm very lazy.

Plus I figure by the time I really get forced to deal with this issue,
GSOC will have helped out enough it won't be "hard" or tricky
anymore

By the way,when I was evaluating different packages to choose I was
torn between Django and TurboGears2.  It was the fact Django has GSOC
working on the multi-DB issue that made me choose it.


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



Re: about a web site

2009-07-17 Thread Diego Eduardo Ahumada - SICO S.I. S.A.

2009/7/17 Michael :
> On Fri, Jul 17, 2009 at 1:30 PM, Lic. José M. Rodriguez Bacallao
>  wrote:
>>
>> anyone?
>>
>>
>> On 7/17/09, Lic. José M. Rodriguez Bacallao  wrote:
>> > hi folks, it's be a long time without writing to the list but now I'm
>> > back with a simple question, I need to know how much can cost to make
>> > a site like this:
>> >
>> > --
>> > Lic. José M. Rodriguez Bacallao
>> > Centro de Biofisica Medica
>> > -
>> > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
>> > mismo.
>> >
>

Hi! Why you ask? What's your plan? That someone build a site for you,
or build it for someone and want to know how much you can earn?

Diego

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



Re: File Upload : Memory consumption

2009-07-17 Thread Alvin

has anyone had luck getting past this?

I am using a recent 1.1 beta release have checked the folder
permissions and set the FILE_UPLOAD_TEMP_DIR all 777

code is at http://pastebin.com/m4332fdb2

On Jun 24, 2:06 pm, alecs  wrote:
> If to be honest I can't google this posts ... Most of the links are
> for patches or for old django versions :(
> Don't know, maybe I should try to setFILE_UPLOAD_MAX_MEMORY_SIZE, but
> I didn't change it , so the default value is 2.5Mb ...
>
> On Jun 24, 2:54 pm, John M  wrote:
>
>
>
> > I've seen quite a few posts on this, and I think it's documented as
> > well.
>
> > As I recall, there is a certain way of doing large uploads, search the
> > docs and the forum and I'm sure you'll find it.
>
> > On Jun 24, 3:20 am, alecs  wrote:
>
> > > Hi! I'm trying to upload a large file (700Mb) and something wrong with
> > > django happens: First it starts caching enormously (4Gb of ram are
> > > used), than it starts to purge caches and starts swapping (1Gb of swap
> > > is used).
> > > Have you ever faced with such a thing ? Django 1.02, mod_wsgi + Apache
> > > 2.2
> > > Thanks :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: about a web site

2009-07-17 Thread Michael
On Fri, Jul 17, 2009 at 1:30 PM, Lic. José M. Rodriguez Bacallao <
jmr...@gmail.com> wrote:

>
> anyone?
>
>
> On 7/17/09, Lic. José M. Rodriguez Bacallao  wrote:
> > hi folks, it's be a long time without writing to the list but now I'm
> > back with a simple question, I need to know how much can cost to make
> > a site like this:
> >
> > --
> > Lic. José M. Rodriguez Bacallao
> > Centro de Biofisica Medica
> > -
> > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
> > mismo.
> >


Well I'll build it for you for $15 million.

Maybe a lot, maybe a little. Depends on the developers the traffic,
licenses you might need. This isn't the right place to ask a question
like this. We take months to write up a detailed proposal of costs.
Given that everyone here is volunteer and working on the same thing, I
doubt they are going to build a business plan for you.

We can help with specifics, but given that Django itself is free (as
in beer) costs are up to you.

Michael

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



Re: about a web site

2009-07-17 Thread Lic . José M . Rodriguez Bacallao

anyone?


On 7/17/09, Lic. José M. Rodriguez Bacallao  wrote:
> hi folks, it's be a long time without writing to the list but now I'm
> back with a simple question, I need to know how much can cost to make
> a site like this:  www.juegon.com
>
> --
> Lic. José M. Rodriguez Bacallao
> Centro de Biofisica Medica
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
> mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
>


-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

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



Howto add button to certain field

2009-07-17 Thread zayatzz

Hello

I have this form with username and other user information. Since user
needs to set his own username and it has to be unique, i was going to
add some button to the form that does some ajax magic and checks if
the username is already in use.

What i wanted to know is that if there is some way to add this buttong
right next to the username field through the way how the form itself
is set up - (widget?). I know that i can of course ditch this :
{% for field in aform %}
{{ field.label_tag }}
{{ field }}
{% endfor %}

And write all that markup without for loop and just add the button
after usename field. What i wanted to know was if it can be done
differently?

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



Re: Reading data from database tied to another Django project?

2009-07-17 Thread Benjamin Kreeger

Thanks for your help, Ian. Two awesome solutions; I'll try and check
'em out today if I get the chance.

Ben

On Jul 15, 1:26 pm, Ian Clelland  wrote:
> On Jul 14, 8:23 am,BenjaminKreeger 
> wrote:
>
> > I was using PostgreSQL at first, but then I found information about
> > reading data across databases only with MySQL, so I'm using MySQL for
> > the time being.
>
> > Now, I don't have a database set for P1 yet because it's just
> > displaying reStructuredText files; if I were to set up that site to
> > access P2's database (in P1's settings.py file), would I be able to
> > (eek) do raw SQL to get the data to display the way I want? Or would
> > there be an easier way to do that WITHOUT raw SQL, and WITHOUT
> > duplicating that model declared on P2?
>
> I didn't realise that P1 didn't have a database at all -- if that's
> the case, then you can just use the credentials from P2 (the
> DATABASE_* lines from settings.py) in P1's settings. You can define
> the same models -- it's as simple as installing the same apps that P2
> uses, there should be no duplication of code, and you'll have access
> to all of the P2 data from P1.
>
> If P1 needs its own database, however, (and you're using MySQL, and
> your databases are on the same server), then you can use this patch to
> django/db/backends/mysql/base.py (this is based on the 1.0.x branch;
> other branches should be similar)
>
> ===
> --- django/db/backends/mysql/base.py    (revision 10742)
> +++ django/db/backends/mysql/base.py    (working copy)
> @@ -143,7 +143,7 @@
>      def quote_name(self, name):
>          if name.startswith("`") and name.endswith("`"):
>              return name # Quoting once is enough.
> -        return "`%s`" % name
> +        return ".".join(["`%s`" % name_part for name_part in
> name.split(".")])
>
>      def random_function_sql(self):
>          return 'RAND()'
>
> That will let you define, in your P1 models, a complete table name
> like this:
>
> class Example(models.Model):
>     ... fields ...
>
>     class Meta:
>         db_table = 'p2_database.table_name'
>
> And mysql will get the data from the right database. No raw SQL
> required.
>
> Ian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: never_cache doesn't work for login page

2009-07-17 Thread Michael
On Fri, Jul 17, 2009 at 11:19 AM, Ronghui Yu  wrote:

>
>
> Michael 写道:
>
> 2009/7/17 Ronghui Yu 
>
>> Hi, All,
>>
>> I have a project that have CsrfMiddleware enable, all forms work fine, but
>> the login form doesn't, for all browsers(IE,Chrome,Firefox,Safari).
>> Most of the time, it throws 403, which is thrown by CsrfMiddleware. That's
>> because the browser cache the login page, so each time the login page is
>> opened, the csrfmiddlearetoken value doesn't get update. If the browser
>> cache is cleaned before opening the login page, then it works fine. But this
>> is not what I expect.
>>
>> When look into django.contrib.auth.views, the login view is decorated by
>> never_cache, but actually it doesn't work for me. I have no idea what's
>> wrong with it. Has anybody ever encounted this situation? Or could anybody
>> give me some hints?
>>
>> Thanks in advance.
>>
>> --
>> Ronghui Yu 
>>
>
> I have encountered this, but it isn't a problem with the admin, it is a
> problem with the browser. These pages are stored for offline use and then
> when the user goes to the page, they don't get a new token. You can see here
> [1] and here [2] where the views are cached. You can look at your browser
> and see that the headers are right as well. You should see something along
> these lines in the headers: Cache-Control max-age=0
>
>  1]
> http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L324
> 2]
> http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L188
>
>  I haven't been able to figure out how to fix this behavior in the
> browser, but the user only needs to refresh a few times to break that
> cache.
>
>  I would love to hear if anyone else has figured something out to fix
> this.
>
>  Also if you are using the 1.1 branch, make sure you update svn there was
> a recent fix put in for caching of all pages[3], but otherwise, the best I
> can tell, this is a browser issue, and not something Django can easily fix.
>
>  3] http://code.djangoproject.com/ticket/11416
>
>  I hope that helps,
>
>  Michael
>
>
>  Thanks Michael.
>
> Look into the apache log, I see that when the login page is accessed again,
> it returns 304, then the subsequent submit returns 403.
>
> 116.22.69.90 - - [17/Jul/2009:23:12:06 +0800] "GET /accounts/login/
> HTTP/1.0" 304
> 116.22.69.90 - - [17/Jul/2009:23:12:17 +0800] "POST /accounts/login/
> HTTP/1.0" 403 159
>
> I guess there are some tags that apache or mod_python omits. But I am not
> sure. I will do more research soon.
>
> --
> Ronghui Yu 
>

Hmm, interesting, What do your HTTP headers look like?

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



Re: never_cache doesn't work for login page

2009-07-17 Thread Ronghui Yu


Michael ??:
> 2009/7/17 Ronghui Yu mailto:stone...@gmail.com>>
>
> Hi, All,
>
> I have a project that have CsrfMiddleware enable, all forms work
> fine, but the login form doesn't, for all
> browsers(IE,Chrome,Firefox,Safari).
> Most of the time, it throws 403, which is thrown by
> CsrfMiddleware. That's because the browser cache the login page,
> so each time the login page is opened, the csrfmiddlearetoken
> value doesn't get update. If the browser cache is cleaned before
> opening the login page, then it works fine. But this is not what I
> expect.
>
> When look into django.contrib.auth.views, the login view is
> decorated by never_cache, but actually it doesn't work for me. I
> have no idea what's wrong with it. Has anybody ever encounted this
> situation? Or could anybody give me some hints?
>
> Thanks in advance.
>
> -- 
> Ronghui Yu 
>
>
> I have encountered this, but it isn't a problem with the admin, it is 
> a problem with the browser. These pages are stored for offline use and 
> then when the user goes to the page, they don't get a new token. You 
> can see here [1] and here [2] where the views are cached. You can look 
> at your browser and see that the headers are right as well. You should 
> see something along these lines in the headers: Cache-Control max-age=0
>
> 1] 
> http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L324
> 2] 
> http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L188
>
> I haven't been able to figure out how to fix this behavior in the 
> browser, but the user only needs to refresh a few times to break that 
> cache. 
>
> I would love to hear if anyone else has figured something out to fix 
> this. 
>
> Also if you are using the 1.1 branch, make sure you update svn there 
> was a recent fix put in for caching of all pages[3], but otherwise, 
> the best I can tell, this is a browser issue, and not something Django 
> can easily fix. 
>
> 3] http://code.djangoproject.com/ticket/11416
>
> I hope that helps,
>
> Michael
>
>
Thanks Michael.

Look into the apache log, I see that when the login page is accessed 
again, it returns 304, then the subsequent submit returns 403.

116.22.69.90 - - [17/Jul/2009:23:12:06 +0800] "GET /accounts/login/ 
HTTP/1.0" 304
116.22.69.90 - - [17/Jul/2009:23:12:17 +0800] "POST /accounts/login/ 
HTTP/1.0" 403 159

I guess there are some tags that apache or mod_python omits. But I am 
not sure. I will do more research soon.

-- 
Ronghui Yu 

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



pre-fetch one-to-many and many-to-many relationships

2009-07-17 Thread Miriam

There currently is no way in Django to pre-fetch one-to-many and/or
many-to-many relationships, right?

There's select_related, which will pre-fetch FK or one-to-one, which
is great, but not sufficient.

Suppose I am fetching a list of Blog posts and I want to pre-fetch the
Comments for each of these posts? There's no way to do that in
Django.

I was looking through the tickets at code.djangoproject.com and I
didn't see anything about this.

Does anyone know if this feature is planned for sometime down the
road? Anyone have a work-around or a patch or anything. This is
supremely irritating.

Miriam

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



ForeignKey model attribute value in save() method

2009-07-17 Thread onoxo

how can i access ForeignKey model attribute value in save() or
__unicode__ method?
some hint will help.

here is my model.py:

class PhotoSetPhotoItem(models.Model):
photo_item = models.ForeignKey('Photo', related_name='photoitem')
slug = models.SlugField(blank = True, null = True)

def __unicode__(self):
# > BELOW IS THE PROBLEMATIC PART
return str(self.photo_set)+str(self.photo_item)+str
(self.photo_item.img)

def save(self, force_insert=False, force_update=False):
if self.photo_item != None:
# > BELOW IS THE PROBLEMATIC PART
self.slug = str(self.photo_set)+str(self.photo_item)+str
(self.photo_item.img)
super(PhotoSetPhotoItem, self).save(force_insert,
force_update)


class Photo(models.Model):
title_hr = models.CharField('(hr)', max_length=255)
slug = models.SlugField()
img = FileBrowseField(max_length=200, initial_directory="", ...)

def __unicode__(self):
return self.title_hr

def getImg(self):
return self.img




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



Re: A question about reverse url lookups for admin site in svn version

2009-07-17 Thread Michael
On Fri, Jul 17, 2009 at 10:28 AM, Vasil Vangelovski
wrote:

>
> I'm using svn trunk version of django (rev. #11263). In my project I
> have only one admin site registered in the urlconf. This admin site is
> a subcalss of django.contrib.admin.sites.AdminSite and is instantiated
> with the name 'admin'. I'm trying to use reverse url lookups for the
> admin site as described in the docs:
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#admin-reverse-urls
> But it doesn't work, I always get a NoReverseMatch exception.
> Can someone confirm that reverse url lookups for admin sites work as
> described in the docs with the latest trunk revision?
>

I can confirm they work, but they were only checked in less than 48 hours
ago, so I would first double check and make sure you have the newest version
of the django svn. If you are all updated and it still doesn't work, posting
your admin site, model admin and where the urlreversing is happening, we can
help you.

Also, sometimes you can get a more helpful error message from the shell. The
reverse() function that you can use is available in
django.core.urlresolvers.

Let us know how it is going,

Michael

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



Re: never_cache doesn't work for login page

2009-07-17 Thread Michael
2009/7/17 Ronghui Yu 

>  Hi, All,
>
> I have a project that have CsrfMiddleware enable, all forms work fine, but
> the login form doesn't, for all browsers(IE,Chrome,Firefox,Safari).
> Most of the time, it throws 403, which is thrown by CsrfMiddleware. That's
> because the browser cache the login page, so each time the login page is
> opened, the csrfmiddlearetoken value doesn't get update. If the browser
> cache is cleaned before opening the login page, then it works fine. But this
> is not what I expect.
>
> When look into django.contrib.auth.views, the login view is decorated by
> never_cache, but actually it doesn't work for me. I have no idea what's
> wrong with it. Has anybody ever encounted this situation? Or could anybody
> give me some hints?
>
> Thanks in advance.
>
> --
> Ronghui Yu 
>

I have encountered this, but it isn't a problem with the admin, it is a
problem with the browser. These pages are stored for offline use and then
when the user goes to the page, they don't get a new token. You can see here
[1] and here [2] where the views are cached. You can look at your browser
and see that the headers are right as well. You should see something along
these lines in the headers: Cache-Control max-age=0

1]
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L324
2]
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L188

I haven't been able to figure out how to fix this behavior in the browser,
but the user only needs to refresh a few times to break that cache.

I would love to hear if anyone else has figured something out to fix this.

Also if you are using the 1.1 branch, make sure you update svn there was a
recent fix put in for caching of all pages[3], but otherwise, the best I can
tell, this is a browser issue, and not something Django can easily fix.

3] http://code.djangoproject.com/ticket/11416

I hope that helps,

Michael

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



A question about reverse url lookups for admin site in svn version

2009-07-17 Thread Vasil Vangelovski

I'm using svn trunk version of django (rev. #11263). In my project I
have only one admin site registered in the urlconf. This admin site is
a subcalss of django.contrib.admin.sites.AdminSite and is instantiated
with the name 'admin'. I'm trying to use reverse url lookups for the
admin site as described in the docs:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#admin-reverse-urls
But it doesn't work, I always get a NoReverseMatch exception.
Can someone confirm that reverse url lookups for admin sites work as
described in the docs with the latest trunk revision?

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



Re: Current user in model.save() context

2009-07-17 Thread Bartłomiej Górny

Phil wrote:
> Hi Josh,
> 
> unfortunately it seems that there is no way to do so. As you've
> noticed that correctly you can use request (request.user) in any place
> but model save.

Yes, I bumped into the same problem and came to the same conclusion. No
way. Unless you hack out something along the lines of
translation.activate/get_language - using a global dictionary and 
current thread. It works, but is hardly in line with Django spirit.

I think it is a design decision, to keep MVC structure clean. Though it 
might be arguable if it would really seriously breach the MVC principle. 
Maybe it is worthwhile.

Bartek

> 
> most likely that will be view:
> 
> ---
> if form.is_valid():
> newObj = form.save(commit=False)
> newObj.user = request.user
> newObj.save()
> ---
> 
> Cheers,
> Phil
> 
> On Jul 17, 7:19 am, Joshua Russo  wrote:
>> I think I might be overlooking something simple here. I have a set of
>> 4 fields in almost every table (user create & modified and date create
>> & modified). The date (datetime) is easy with auto_now and
>> auto_now_add options.
>>
>> The user has been much trickier. I can't figure out how (if possible)
>> to get access to the current user information in the context of a
>> model. The work around that I've implemented is a method that takes
>> the model, user id, and a boolean indicating modification or new. I
>> then use this in location where I still have a request object (and
>> thus request.user.id) like my views or save_model() of the admin form.
>>
>> Is this as good as I can do, or can I access the current user (or
>> request object) from within the model?
>>
>> Thanks
>> Josh
> > 



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



never_cache doesn't work for login page

2009-07-17 Thread Ronghui Yu
Hi, All,

I have a project that have CsrfMiddleware enable, all forms work fine,
but the login form doesn't, for all browsers(IE,Chrome,Firefox,Safari).
Most of the time, it throws 403, which is thrown by CsrfMiddleware.
That's because the browser cache the login page, so each time the login
page is opened, the csrfmiddlearetoken value doesn't get update. If the
browser cache is cleaned before opening the login page, then it works
fine. But this is not what I expect.

When look into django.contrib.auth.views, the login view is decorated by
never_cache, but actually it doesn't work for me. I have no idea what's
wrong with it. Has anybody ever encounted this situation? Or could
anybody give me some hints?

Thanks in advance.

-- 
Ronghui Yu 

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



Re: how to alter (add/del cols) the tables from the existing models

2009-07-17 Thread Diego Eduardo Ahumada - SICO S.I. S.A.

2009/7/17 Lokesh :
>
> Hi,
>
> Initially the table created with the following code
> Class user_privileges(models.Model):
>    user_id = models.ForeignKey(User)
>    is_deleted= models.CharField(null=False, blank=False,
> max_length=1)
>    is_email_active = models.CharField(null=False, blank=False,
> max_length=1)
>
> Now I would like to add the one more column to the "user_privileges"
> model
>    is_phone_active = models.CharField(null=False, blank=False,
> max_length=1)
>
> The changes are not taken place when I do the "manage.py syncdb" after
> adding the new column into the model.
>

Remember that "manage.py syncdb" only check if the table exits/not
exits, it doesn't check structures. So if all the model is in the
server, syncdb simply do nothing.

> Please guide me how do I modify the models after the initial creation.
>
> I am not supposed to drop the "user_privileges" table because this is
> linked to other tables as foreign key.
>
> Thanks in advance.
> --~--~-~--~~~---~--~~

I'm pretty new in Django, but i think that you need to make that
change manually in the database server, i mean: change the model
(adding the field) and change the structure of the table (adding the
field with the same characteristics).

Another option is to backup your data, drop all the tables, do
"manage.py syncdb" and recover the backup.

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



Overriding admin forms

2009-07-17 Thread cornjuliox

Hi everyone. I'm new to Django, learning things mostly through trial
and error, but this time I can't seem to figure out what went wrong. I
overrode the admin change_form.html for my model so that I could add a
Javascript RTE that I found, but not only does the text area look
broken (it's split in two, on separate lines), the slug field no
longer prepopulates (it did before I changed things). The RTE works as
expected, though. I'm not sure what I'm supposed to be pasting in
order to get an accurate diagnosis, so here's everything I think is
relevant.

This is the model in question:
class Entry(models.Model):
# ALL TITLES MUST BE UNIQUE! The slug is gonna give me problems if
it isn't.
title = models.CharField(max_length=250, unique=True)
slug = models.SlugField(
help_text="This field will be filled in automatically based on
the title field.\
  You don't need to fill this in. Honest."
)
subject = models.CharField(max_length=140)
category = models.ManyToManyField(Category)
author = models.ForeignKey(User)
dateTime = models.DateTimeField(default=datetime.datetime.now)
content = models.TextField()
content_html = models.TextField()

class Meta:
ordering = ['-dateTime']
verbose_name_plural = "Entries"

def __unicode__(self):
return self.title

def get_aboslute_url(self):
return "/%s/%s" % (self.dateTime.strftime("%Y/%b/%d").lower
(),self.slug)

def save(self):
html_data = markdown.markdown(self.content)
super(Entry, self).save()

This is the modeladmin for the model:
class EntryAdmin(admin.ModelAdmin):
fields = ('title', 'subject', 'slug', 'dateTime', 'category',
'content',)
prepopulated_fields = {'slug' : ('title',)}
date_hierarchy = 'dateTime'
list_filter = ('dateTime',)

def save_model(self, request, object, form, change):
if not change:
object.author = request.user
object.save()


And this is the new form:
{% extends "admin/change_form.html" %}
{% block form_top %}
A customized entry form.
{% endblock %}

{% block extrahead %}
http://js.nicedit.com/nicEdit-latest.js"; type="text/
javascript">
bkLib.onDomLoaded
(nicEditors.allTextAreas);
{% endblock %}

I placed this file in my templates dir, in the /admin/(my_app)/Entry
folder. Any help would be greatly appreciated, because I'm really
stuck on this one.

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



how to alter (add/del cols) the tables from the existing models

2009-07-17 Thread Lokesh

Hi,

Initially the table created with the following code
Class user_privileges(models.Model):
user_id = models.ForeignKey(User)
is_deleted= models.CharField(null=False, blank=False,
max_length=1)
is_email_active = models.CharField(null=False, blank=False,
max_length=1)

Now I would like to add the one more column to the "user_privileges"
model
is_phone_active = models.CharField(null=False, blank=False,
max_length=1)

The changes are not taken place when I do the "manage.py syncdb" after
adding the new column into the model.

Please guide me how do I modify the models after the initial creation.

I am not supposed to drop the "user_privileges" table because this is
linked to other tables as foreign key.

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



Accessing Meta properties and a templating question.

2009-07-17 Thread Beetle B.

Hi,

1. In the Python code, how can I access various Meta properties of a
model (e.g. verbose_name, etc). At the moment, I do it via
model._meta.verbose_name, but I always get chills down my spine when I
access properties beginning with a single underscore. Is there a
"proper" way?

2. Can someone explain the rationale behind not allowing access to
properties of objects that begin with double underscores in the
template? It worked in 1.02, but with SVN I can't access anything like
object.__class__. I'm merely curious as to why this was restricted. In
one or two cases, life was easier for me when I could do it.

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



Re: How redirect lightweight webserver messages?

2009-07-17 Thread Andrea Della Pietra
Yes and also on windows. I use tee in order to have print on stdout and also
on a log file. The problem is that I don't see django web server messages on

log file (I see only my logging messages). Maybe I've found the problem
checking
Django source. Server log message are send to stderr (stdout is set as a
file handler)
but tee logs only stdout.
Tnx anyway,
Andrew

2009/7/17 Luke Seelenbinder 

>
> That would depend on the OS you use.
>
> If you use linux:  "python manage.py runserver >> example.log"
> That will save the output in a file, instead of showing it on screen,
> allowing you to have another webserver serve it.
>
> Luke
>
> On Jul 17, 6:38 am, Andrew  wrote:
> > Hi,
> > I run Django light web server with command line "python manage.py
> > runserver".
> > I must redirect to another stream web server output messages, the ones
> > like "[17/Jul/2009 12:35:58] "GET /home/foo/ HTTP/1.1" 200 1061".
> > Any help?
> >
> > Tnx,
> > Andrew
> >
>

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



Using AVG

2009-07-17 Thread The Danny Bos

Heya,

If I wanted to get the Average of all ratings (in a Rating table) for
a single record.
Would I use something like this:

ratings_avg = Rating.objects.aggregate(Avg('rating'))

And where does this live? In models.py or views.py and how is it
called.
I've been reading a lot about it, but some things seem implied which
I'm having trouble wrapping my head around.

Thanks,

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



Re: How redirect lightweight webserver messages?

2009-07-17 Thread Luke Seelenbinder

That would depend on the OS you use.

If you use linux:  "python manage.py runserver >> example.log"
That will save the output in a file, instead of showing it on screen,
allowing you to have another webserver serve it.

Luke

On Jul 17, 6:38 am, Andrew  wrote:
> Hi,
> I run Django light web server with command line "python manage.py
> runserver".
> I must redirect to another stream web server output messages, the ones
> like "[17/Jul/2009 12:35:58] "GET /home/foo/ HTTP/1.1" 200 1061".
> Any help?
>
> Tnx,
> Andrew
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



about a web site

2009-07-17 Thread Lic . José M . Rodriguez Bacallao

hi folks, it's be a long time without writing to the list but now I'm
back with a simple question, I need to know how much can cost to make
a site like this:  www.juegon.com

-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

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



Amazon Product Advertising API

2009-07-17 Thread Luke Seelenbinder

I'm working on a django project right now that uses the Amazon Product
Advertising API. I was using pyaws, but it is quite outdated and won't
be useful for the changes coming in the next month.

My first question is whether you know of any other python library for
it.
Second question, is there anybody willing to help me develop a new
python abstraction for the api.

I'm going to get started today with a new python api, if there is
anybody willing to help, drop me an email (lukeqsee at gmail), or just
reply to this message.

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



Re: raw_id_fields, get atribute name and number, how to?

2009-07-17 Thread onoxo

to make it simple, i have this in models.py

class Photo(models.Model):
title_hr = models.CharField('(hr)', max_length=255)
title_en = models.CharField('(en)', max_length=255)
img = FileBrowseField(max_length=200, initial_directory="",...)

class PhotoSetPhotoItem(models.Model):
order = models.IntegerField(blank = True, null = True)
photo_item = models.ForeignKey('Photo', related_name='photoitem')
photo_item_name = str(photo_item.img)

how can i relate to 'img' attribute of 'Photo' class in
'PhotoSetPhotoItem' class?

why is this not working?
photo_item_name = str(photo_item.img)

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



Doctests for custom template tags

2009-07-17 Thread A Khodyrev

  Hello

I'm writing a library of helper classes/functions to ease creation of
custom template tags. So a natural doctest (or an example in the
documentation) goes like this: define a compiler function and Node
class with my helpers, register them with a tag library, define a
bunch of template strings with these tags, then render these templates
and check whether the output is ok. However, there is a problem. For
this to work, I need to somehow tell my templates where to find the
tags. I can not use the {% load %} tag (because the tags being tested
are not in a module), so I need to somehow tell the Template object
where to look. I looked through django.template and there seems to be
no way to do that (libraries are added to the template's Parser object
which is deeply incapsulated).

So, my question is: how do people test such things?

--
Alexander Khodyrev

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



Limiting administration based on user settings

2009-07-17 Thread Rune Bromer

Hello.

For a small webshop I have the following models: Product, Category,
Country and UserProfile. Each user have a country set with a FK, and
should only be allowed to see content in the administration assigned
to the same Country. The Product and Category have FKs to the Country
model so I can ensure this by writing a "formfield_for_foreignkey" on
the ModelAdmin. So far so good, as I can also filter the admin list
view by overwriting the queryset() model on the ModelAdmin.

The problem now is that I can assign several categories to each
Product. But I only want to allow people to see the Categories for the
same Country as the product. How is that possible. Apparently the
options for the m2m field is not filtered by the queryset and I can't
see there is a formfield_for_manytomanyfield?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Accessor for field clashes with related field

2009-07-17 Thread Ramiro Morales

On Fri, Jul 17, 2009 at 6:55 AM, Oleg Oltar wrote:

> I want to create an object that contains 2 links to users. For example
>
> class GameClaim(models.Model):
>     target = models.ForeignKey(User)
>     claimer = models.ForeignKey(User)
>     isAccepted = models.BooleanField()
>
> but I am getting an error when running server:
>
> Accessor for field 'target' clashes with related field 'User.gameclaim_set'.
> Add a related_name argument to the definition for 'target'.
> Accessor for field 'claimer' clashes with related field
> 'User.gameclaim_set'. Add a related_name argument to the definition for
> 'claimer'.
>
> Please explain why I am getting the error and how to fix it?

When you create a relationship from model A (GameClaim) to model B
(User), Django automatically adds to model B isntances Python attribute
(the ' accessors'  above) that allow you to in case you have one B instance,
to get all the A instances related to it (in your example, using the claimer FK,
it would allow you to, starting from an given user, obtain all the
games she/he claimed).

The name of such an accessor is, by default, determined by a simple
rule: the A name lowercased and suffixed with '_set' (gameclaim_set).

The problem in your case is a typical one and the model validation error
messages you are getting are pointing you in the right direction: you have
two FKs between A and B and then the default names for the accessors
Django is trying to add clash.

Is In those cases when the related_name parameter of the ForeignKey
field is useful because it allows you to override the default accessor
name 'gameclaim_set'.

Read the relevant documentation for more details:

http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey
http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects

HTH.

-- 
Ramiro Morales
http://rmorales.net

PyCon 2009 Argentina - Vie 4 y Sab 5 Septiembre
Buenos Aires, Argentina
http://ar.pycon.org/2009/about/

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



How redirect lightweight webserver messages?

2009-07-17 Thread Andrew

Hi,
I run Django light web server with command line "python manage.py
runserver".
I must redirect to another stream web server output messages, the ones
like "[17/Jul/2009 12:35:58] "GET /home/foo/ HTTP/1.1" 200 1061".
Any help?

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



Accessor for field clashes with related field

2009-07-17 Thread Oleg Oltar
Hi!


I want to create an object that contains 2 links to users. For example

class GameClaim(models.Model):
target = models.ForeignKey(User)
claimer = models.ForeignKey(User)
isAccepted = models.BooleanField()

but I am getting an error when running server:

Accessor for field 'target' clashes with related field 'User.gameclaim_set'.
Add a related_name argument to the definition for 'target'.
Accessor for field 'claimer' clashes with related field
'User.gameclaim_set'. Add a related_name argument to the definition for
'claimer'.

Please explain why I am getting the error and how to fix it?

Thanks,
Oleg

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



Decouple URLs and get_absolute_url issue

2009-07-17 Thread grant neale

Hi,

I'm going through James Bennet's Practical Django projects.

When I de-couple the urls to "urls folder" + "url category"  I  
get_absolute_url doesn't work.
If I put the urls back into the main urls.py file get_absolute_urls  
works again.

I must be missing something very basic, but I'm pretty much stuck.

Thoughts ?

Grant



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



[ANN] django-nav 0.1

2009-07-17 Thread Dj Gilcrease

Examples and code can be found at http://code.google.com/p/django-nav/


Goals:
Create a extensible, non intrusive, fast system for generation
navigation groupings.


Reason:
While there are several systems already out there for crating
navigation menus, tabs, etc, they all (That I have found) fail at one
or more of my goals.

I want to create a system that any django app can use so that it's
default navigation appears or disappears in an existing site based
only on having the application in INSTALLED_APPS or not.


Implementation:
To meet the goal of non intrusive, and auto adding/removing the
navigation groupings I looked to djangos own admin autodiscover
feature and implemented a similar system that looks though all of your
sites INSTALLED_APPS to see if they have a nav.py file, if they do it
processes it.

... Further implementation details on the site



Over the weekend I plan on adding example nav.py files for many common
applications to help new users and future developers get a jump start
on their own sites and apps

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



Re: Cached forms when changing language- Is this a bug?

2009-07-17 Thread Matthias Kestenholz

Hi,

On Fri, Jul 17, 2009 at 9:14 AM, Adrián Ribao wrote:
>
> Hello everybody,
>
> I have an multi language site with a form in the home. If I change the
> language of the site everything changes but the form takes a few
> minutes before I see it in the right language.
>
> If I reload the server the form is visualized ok, but this is not the
> right behaviour.
>
> The code of the form is somethin like:
> from django.utils.translation import ugettext as _

You need ugettext_lazy instead of ugettext when declaring forms:
from django.utils.translation import ugettext_lazy as _

Read about it here:
http://docs.djangoproject.com/en/dev/topics/i18n/#lazy-translation


Matthias

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



Re: How do you unit test forms

2009-07-17 Thread Rodrigue

Hi Joshua,

whenever I override some of the Form methods, I make sure I have tests
that cover the code I wrote. In particular, when I override the save()
method on a ModelForm, I make sure that
  - the Model save() gets called from the Form save() if the form is
valid
  - my Form save() returns the object (a classic oversight for me).

I also try to make sure required fields are indeed required, and that
validation does validate/fail as expected.

I also like having good unit tests for my forms because then my view
unit tests can stop at the form level. What I mean is that if a view
uses a form, I can just test that
the correct type of form is instantiated and passed into the template
context, and that if I feed valid data to the view, the form save() is
called. This checks that the view makes correct use of the form, and I
trust the form to behave, because it has its own tests.

Rodrigue


On Jul 17, 3:57 am, Russell Keith-Magee 
wrote:
> On Fri, Jul 17, 2009 at 9:56 AM, Joshua Partogi 
> wrote:
> > Hi Russ,
>
> > To expand this question. Do we use unittest for testing forms? Because from
> > what I see in the code, doctest only tests your model. CMIIW.
>
> I shall. I don't know where you got that idea. :-)
>
> doctests are just a way of expressing tests. It has no inherent
> strengths, weaknesses or ties to model testing. It's just a way of
> testing based on a mock shell - i.e., "If I run X at the python
> prompt, I expect to see Y". You can do this with models, with forms,
> or anything else that can be invoked as a Python command.
>
> You can also use unittest to do exactly the same thing. The assertion
> facilities for unit tests are a little easier to use (since it isn't
> just based on string checking), but fundamentally, a unittest is just
> a way to bundle a series of commands whose output can then be asserted
> for validity.
>
> Django's TestCase provides a few extra helpful bits for web app
> testing - such as a built in test client, fixture loading, etc - but
> that's only because it's easier to subclass unittest.TestCase than it
> is to subclass the doctest framework.
>
> In short, use whatever you find convenient. Both doctest and unittest
> are valid and useful testing frameworks. In my experience, doctests
> are usually easier to write initially, but unittests prove more useful
> in the long term - but that's entirely subjective. YMMV.
>
> Yours
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Cached forms when changing language- Is this a bug?

2009-07-17 Thread Adrián Ribao

Hello everybody,

I have an multi language site with a form in the home. If I change the
language of the site everything changes but the form takes a few
minutes before I see it in the right language.

If I reload the server the form is visualized ok, but this is not the
right behaviour.

The code of the form is somethin like:
from django.utils.translation import ugettext as _
class RuedaForm(forms.Form):
puntuacion_hogar = forms.ChoiceField(label=_(u'Value'), choices=
[('', '')] + [(i, i) for i in range(11)], help_text=_(u'help text'),
required=False)

I've noticed that if you change a form in the fly, the changes don't
appear in the site inmediatly, For example when I hidde form fields
depending of the permissions of the users.

We are really worried with the behaviour of the forms when changing
the language, something is wrong with it.

You can have a look at: http://autocoaching.info/

We really need help with this issue.

Thank you very much,

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



Re: How do you unit test forms

2009-07-17 Thread Joshua Russo

On Jul 16, 11:11 pm, Russell Keith-Magee 
wrote:
> On Thu, Jul 16, 2009 at 10:46 PM, Joshua Russo wrote:
>
> > I want to test my forms but I'm not sure the best way to go about it.
> > It seems like it might be similar to views but I can't find much
> > discussion of form testing in any of the discussions about unit
> > testing.
>
> > Any suggestions are much appreciated.
>
> Well, a Form is just a class with a bunch of member functions - in
> your views you instantiate instances of the form and give it data,
> call is_valid() to validate and clean data.
>
> So a test is exactly that. Instantiate your form, give it some sample
> data, and assert that the data has either thrown an error (i.e., that
> is_valid() == False and form.errors is populated), or that
> form.cleaned_data contains the right output.
>
> Keep in mind that you don't need to test the core behaviour - Django's
> test suite will check that a simple integer field will reject
> character input, etc. All you need to test is your own local
> extensions, like clean_* methods.
>
> Yours
> Russ Magee %-)

Thanks. I'm guess I need to take a closer look at the forms
functionality. I don't think I'm using it properly. This is my first
Django project and I guess I don't always know enough of what I'm
asking about to ask a full question.

Thanks for the input.

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



Getting a dynamic model form

2009-07-17 Thread ~Young Devil

I've a generic model to save the user preference with a key and value
However the view would change depending upon the key.

Example,
key : newsletter
view : radio button, yes and no

key : template type
value: drop down box [blue, white, brown]


Is anything like this possible in Django, I am kinda new to this
framework I did google it but couldn't get a good solution.

Thanks in Advance.

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



building directory path with user table

2009-07-17 Thread neri...@gmail.com

Hello,

I'm trying to build a photo upload path which corresponds to the
selected user i.e., when the user is selected from the drop down the
username gets appended to the file upload path dynamically. If you
have any ideas I would like to hear them:

class Listing(models.Model):
user = models.ForeignKey(User, unique=True)
user_directory_path = os.path.join(settings.MEDIA_ROOT, 'listings',
user)
user_directory = models.FilePathField(path=user_directory_path,
recursive=True)
photo = models.ImageField(upload_to=user_directory)
name = models.CharField(max_length=50)
order = models.ForeignKey('Order')

def __unicode__(self):
return self.name

I keep getting this error:

AttributeError: 'ForeignKey' object has no attribute 'startswith'

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