Re: Synchronising Database.

2007-07-18 Thread Kenneth Gonsalves


On 19-Jul-07, at 11:08 AM, Dmitriy Sodrianov wrote:

> How should the process of synchronisation be performed?
> To my mind only dropping table and recreating it should do the task.

for example:

http://www.djangosnippets.org/snippets/188/

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



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



Re: Synchronising Database.

2007-07-18 Thread James Bennett

On 7/19/07, Dmitriy Sodrianov <[EMAIL PROTECTED]> wrote:
> After typing manage.py syncdb again the table is not synchronised with
> the model despite the name of the command syncdb.

http://www.djangoproject.com/documentation/django-admin/#syncdb

> How should the process of synchronisation be performed?
> To my mind only dropping table and recreating it should do the task.

You'll want to look up the appropriate syntax for "ALTER TABLE" for
the database you're using.

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

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



Synchronising Database.

2007-07-18 Thread Dmitriy Sodrianov

Hi to all!

Imagine a situation when a Django model is installed into the database
with well-known command

manage.py syncdb

and then it is altered, let's say a new field is added to model.

After typing manage.py syncdb again the table is not synchronised with
the model despite the name of the command syncdb.

How should the process of synchronisation be performed?
To my mind only dropping table and recreating it should do the task.


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



django foreignkey

2007-07-18 Thread james_027

hi,

I have a model with a field models.ForeignKey(), with manage.py
validate I check if my code are right, then run manage.py syncdb. When
I was checking the tables generated I don't see any foreign key
created? Is there something wrong? where should I check?

I am using django 0.96, mysql 5 on winxp

Thanks
james


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



Re: Problem installing django on dreadhost

2007-07-18 Thread walterbyrd

I think I may have fixed it.  I did the following:

1) I had moved sqlite, but didn't change the link, so I fixed that.

2) In the settings.py, I entered a path to the database, but not the
actual database name, so I fixed that as well.

3) Then I re-ran the django-admin.py syncdb script

$ django-admin.py syncdb
Creating table auth_message
Creating table auth_group
Creating table auth_user
Creating table auth_permission
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have
any superusers defined.
Would you like to create one now? (yes/no): yes
Please enter either "yes" or "no": yes
Username (Leave blank to use 'username'):
E-mail address: [EMAIL PROTECTED]
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Message model
Installing index for auth.Permission model
Loading 'initial_data' fixtures...
No fixtures found.



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



Re: context processor question

2007-07-18 Thread james_027

Hi Jeremy,

I am a bit lost ... where do I apply that? Isn't that I just call the
variable name/dict key in the template?

Thanks
james

On Jul 19, 11:18 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote:
> ...
>
> > the commonly use data will automatically available, do I get it right?
>
> Yes.  Just keep in mind that you need to use RequestContext rather
> than Context in order for context processors to be applied.


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



Re: Blog engine

2007-07-18 Thread Kyle Fox

It's easy to write a "basic" blog in Django.  If that's all people
want, then great.  Something like that will work perfectly for the
majority of bloggers (who probably won't get that much readership
anyway)...

But all this talk about making a "full-featured" blog app in Django --
one that will really get noticed (and thus get django noticed): what
we need is a blog with *more features* that could actually begin to
compete with something like Wordpress**.

I mean stuff like Akismet, Flickr integration, delicious/magnolia
bookmarks, multi-author (with per-object permissions), importing from
Wordpress, statistics, easy web-based installation (NOT easy_install
but a wizard someone could follow, like the Wordpress install, lots of
customization, integration with pingback services, etc.

If that sounds like a lot, that's because it is.  To even be a blip on
the screen it will need this kind of stuff.  I also doubt the django-
admin will be sufficient for an application like this.

I know a lot of the stuff I've mentioned above has already been
hammered out by djangonauts -- I'm sure a snippet for almost every
feature has been posted on djangosnippets.org.  It's a matter of
bringing all those together into something that works out of the box,
rather than everyone patching together their own frankenstein.

** By the way, I know "competing with Wordpress" is nearly
impossible.  I'm just saying that to accomplish what it sounds like
people here are talking about, we need close to the same level of
functionality.


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



Re: Problem with multiple django versions on mod_python

2007-07-18 Thread Russell Keith-Magee

On 7/19/07, oggie rob <[EMAIL PROTECTED]> wrote:
>
> Please, if you've seen the same issue or have any helpful ideas to try
> to stop the error, let me know.

I think I've seen the same problem (or, at least, an analogous one).
Unfortunately, I can't provide much by way of helpful debug or
solution - the sysadmin that identified the problem for us isn't
around for me to ask him for more details.

As I recall, the problem was mod_python. Older versions of mod_python
had some sort of issue with caching python instances. As a result, if
you deployed two different versions of Django, the version of Django
that was provided to a given request was determined by the thread that
served the request. If the first request served by a thread used the
old version of Django, that was the version that was used for all
subsequent requests on that thread, regardless of the version that was
required to satisfy the request.

I believe we fixed the problem by updating mod_python, but I'm not
completely certain on that.

I know that this is all vague and ambiguous help - sorry I can't be
more specific.

Yours,
Russ Magee %-)

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



Problem with multiple django versions on mod_python

2007-07-18 Thread oggie rob

I've run into a problem that appears to be caused by multiple django
versions running on the same server. I have a preforked mod_python
installation and the problem I'm seeing is this: after using the trunk-
based application, I try to use the 0.91-based application and get a
500 error. The root of the SQL error is that variables aren't quoted
properly and it can't find a column name, which you can see if you
look at the SQL that is printed out. Here's an example of the error:
ERROR: column "activity" does not exist SELECT
"packages"."label","packages"."name" FROM "packages" WHERE
"packages"."label" = activity ORDER BY "packages"."name" ASC
Looking at the variables, the params list contains a unicode variable
- which I don't think will work okay in 0.91:
params [u'activity']

The error occurs only after I have visited the trunk-based
application. If I restart the server, I can use the 0.91-based
application continuously. Looking in log files I have seen that the
500 error occurs after somebody has used the trunk-based application,
plus the error has only showed up after I deployed the trunk-based
application in the last week or so. I thought this problem would be
avoided by using the PythonInterpreter option, but it hasn't worked so
far. Here are my Location directives from my testing server (which
also reproduces the problem):

SetHandler mod_python
PythonPath "['/opt/djangolibs/django_src','/djangoapps'] +
sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE sc_ca.settings
PythonInterpreter sc_ca
PythonDebug On
SSLRequireSSL



SetHandler mod_python
PythonPath "['/opt/djangolibs/django_trunk','/djangoapps'] +
sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE syb.noisy.settings
PythonInterpreter curriculum
PythonDebug On
SSLRequireSSL


The directories django_src is the 0.91 tree, django_trunk is obviously
trunk, and I don't have a link to either in site-packages. I've
removed *.pyc files in all the trees but this only delays the problem
until the files are regenerated.

Please, if you've seen the same issue or have any helpful ideas to try
to stop the error, let me know.
Thanks!
 -rob


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



Re: How to use request.GET??

2007-07-18 Thread Jeremy Dunck

On 7/18/07, Greg <[EMAIL PROTECTED]> wrote:
> Do I have to return a HttpResponse?

Yes.  It is an error for an HTTP Request not to be given a HTTP
response in return.

In the 'if "favorite_color"' branch of your example view, simple
"return response" just before the else: clause.

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



Re: context processor question

2007-07-18 Thread Jeremy Dunck

On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote:
...
> the commonly use data will automatically available, do I get it right?
>


Yes.  Just keep in mind that you need to use RequestContext rather
than Context in order for context processors to be applied.

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



Re: Django's User authentication

2007-07-18 Thread james_027

Thanks Jason for sharing this one.

cheers,
james

On Jul 18, 9:07 pm, [EMAIL PROTECTED] (Jason F. McBrayer) wrote:
> james_027 <[EMAIL PROTECTED]> writes:
> > what if I need additional fields or methods for my apps? Do i inherit
> > it or edit the user class?
>
> The standard approach is 
> here:http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model
>
> However, also have a look at this 
> approach:http://groups.google.com/group/django-developers/browse_thread/thread...
>
> It does require writing a context processor and a middleware, but they
> are very small and simple, and they greatly simplify the use of your
> user object in your views and templates.
>
> --
> +---+
> | Jason F. McBrayer[EMAIL PROTECTED]  |
> | If someone conquers a thousand times a thousand others in |
> | battle, and someone else conquers himself, the latter one |
> | is the greatest of all conquerors.  --- The Dhammapada|


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



Re: How to use request.GET??

2007-07-18 Thread Greg

Also, when I use 'http://example.com/url_to_set_colour_view/?
favorite_color=Blue' it gives me an error that says:

 'The view mysite.rugs.views.set_color didn't return an HttpResponse
object.'  Do I have to return a HttpResponse?  My view is shown
above...if the 'if' statement is true the view doesn't return
anything.

Thanks for any help


On Jul 18, 9:44 pm, Greg <[EMAIL PROTECTED]> wrote:
> I've seen other Django websites that use the ? mark at the end.  I've
> always wondered what the reason for that was.  So the only time the ?
> mark is used is to send form data?
>
> On Jul 18, 9:33 pm, "Nimrod A. Abing" <[EMAIL PROTECTED]> wrote:
>
> > On 7/19/07, SmileyChris <[EMAIL PROTECTED]> wrote:
>
> > > On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote:
> > > > I was wondering how do I send a 'favorite_color' GET parameter?  Do I
> > > > have to use a form to do this that sends data by GET or is there
> > > > another way to do it?
>
> > >http://example.com/url_to_set_colour_view/?favorite_color=Blue
>
> > Also be sure to URL encode any characters in the paramter that require
> > it. See section 2.2 of RFC1738.
>
> >http://www.ietf.org/rfc/rfc1738.txt
> > --
> > _nimrod_a_abing_
>
> >http://abing.gotdns.com/http://www.preownedcar.com/


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



Re: How to use request.GET??

2007-07-18 Thread Greg

I've seen other Django websites that use the ? mark at the end.  I've
always wondered what the reason for that was.  So the only time the ?
mark is used is to send form data?

On Jul 18, 9:33 pm, "Nimrod A. Abing" <[EMAIL PROTECTED]> wrote:
> On 7/19/07, SmileyChris <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote:
> > > I was wondering how do I send a 'favorite_color' GET parameter?  Do I
> > > have to use a form to do this that sends data by GET or is there
> > > another way to do it?
>
> >http://example.com/url_to_set_colour_view/?favorite_color=Blue
>
> Also be sure to URL encode any characters in the paramter that require
> it. See section 2.2 of RFC1738.
>
> http://www.ietf.org/rfc/rfc1738.txt
> --
> _nimrod_a_abing_
>
> http://abing.gotdns.com/http://www.preownedcar.com/


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



Re: Bulk data upload

2007-07-18 Thread Chris Moffitt
Also, this library is really simple to use to pull data out of excel.

http://www.lexicon.net/sjmachin/xlrd.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ip to location

2007-07-18 Thread Justin Bronn

Francesco,

MaxMind(R) produces commercial and free IP geolocation datasets.  As a
proof of concept I created GeoDjango-enabled models and import scripts
for their CSV files:

http://www.djangosnippets.org/snippets/327/
http://www.djangosnippets.org/snippets/328/

To create this code I had to patch Django since it lacks large integer
support; specifically, IP address queries require conversion to a long
integer.  I used Peter Nixon's latest patch to get BigIntegerField:
http://code.djangoproject.com/attachment/ticket/399/django-bigint-20070712.patch

I'm not sure about the utility of including it in GeoDjango.  The
large database size (3 million rows for LocationBlock), makes queries
slower -- however, there are much fewer CountryBlock rows.  I will try
out their C API and compare.  This may be useful for some research
purposes (e.g. how many IP allocations within a political boundary,
etc.).

Example:

>>> from geoip.models import LocationBlock, CountryBlock
>>> lb = LocationBlock.objects.ipquery('72.14.207.99')
>>> print unicode(lb.location)
Location 2633: United States - CA, Mountain View 94043
>>> print lb.location.point
POINT (-122.05740012 37.41919965)
>>> cb = CountryBlock.objects.ipquery('66.64.46.23')
>>> print unicode(cb.location)
United States: 66.60.64.0 to 66.70.70.109

-Justin


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



Re: Multiple URLconfs per app?

2007-07-18 Thread Collin Grady

You'll need two files.


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



Re: How to use request.GET??

2007-07-18 Thread Nimrod A. Abing

On 7/19/07, SmileyChris <[EMAIL PROTECTED]> wrote:
>
> On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote:
> > I was wondering how do I send a 'favorite_color' GET parameter?  Do I
> > have to use a form to do this that sends data by GET or is there
> > another way to do it?
>
> http://example.com/url_to_set_colour_view/?favorite_color=Blue

Also be sure to URL encode any characters in the paramter that require
it. See section 2.2 of RFC1738.

http://www.ietf.org/rfc/rfc1738.txt
-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.com/

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



Re: How to use request.GET??

2007-07-18 Thread SmileyChris

On Jul 19, 2:22 pm, Greg <[EMAIL PROTECTED]> wrote:
> I was wondering how do I send a 'favorite_color' GET parameter?  Do I
> have to use a form to do this that sends data by GET or is there
> another way to do it?

http://example.com/url_to_set_colour_view/?favorite_color=Blue


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



How to use request.GET??

2007-07-18 Thread Greg

Hello,
I have the following function

/

def set_color(request):
if "favorite_color" in request.GET:

# Create an HttpResponse object...
response = HttpResponse("Your favorite color is now %s" % \
request.GET["favorite_color"])

# ... and set a cookie on the response
response.set_cookie("favorite_color",
request.GET["favorite_color"])

else:
return HttpResponse("You didn't give a favorite color.")

/

I was wondering how do I send a 'favorite_color' GET parameter?  Do I
have to use a form to do this that sends data by GET or is there
another way to 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multiple URLconfs per app?

2007-07-18 Thread Nathaniel Whiteinge

I'm a little fuzzy on how Django imports additional app URLconfs. I've
got two parts of an app that are closely related to one another,
however I'd like to give them both root URLs.

myproject/urls.py::

urlpatterns = patterns('',
(r'^feature1/', include('myproject.apps.myapp.urls')),
(r'^feature2/', include('myproject.apps.myapp.urls')),
)

Is there a way to group the URLs in the app's urls.py so as to keep
them all in that one file? Or do I *have* to make seperate files (e.g.
feature1_urls.py, feature2_urls.py)?

myproject/urls.py::

urlpatterns = patterns('',
(r'^feature1/',
include('myproject.apps.myapp.urls.feature1')),
(r'^feature2/',
include('myproject.apps.myapp.urls.feature2')),
)

- whiteinge


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



Re: Is there any way to custom group models in the admin panel?

2007-07-18 Thread Sebastian Macias

I just opened a ticket for this.

http://code.djangoproject.com/ticket/4918

Sebastian Macias


On Jul 12, 6:37 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/12/07,SebastianMacias <[EMAIL PROTECTED]> wrote:
>
>
>
> > By default models are grouped by app. I really need to be able to
> > break down that grouping a little bit more. I will have an app with
> > probably 40-50 models and would like togroupthose logically instead
> > of having them all listed under my app name.
>
> This isn't possible at present. You can collect the fields on an
> individual model into groups, but there isn't currently a mechanism 
> togroupmodels other than by application.
>
> It is an interesting idea though. I would suggestion opening a ticket
> requesting this feature - we are currently rewriting the admin views
> to use newforms. This particular feature probably won't be a target
> for the initial release, but its worth documenting it to make sure we
> don't code ourselves into a corner.
>
> Yours,
> Russ Magee %-)


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



Re: Modifying Model Field Attributes on Run Time

2007-07-18 Thread Malcolm Tredinnick

On Wed, 2007-07-18 at 17:08 +, Sebastian Macias wrote:
> Is there anyway to modify model field attributes on run time.. What
> I'm trying to do is to build some logic that will decide whether a
> model that is related to other model should be edited or not inline in
> the admin.
> 
> Basically: "client = models.ForeignKey(Client, unique=True,
> edit_inline = True, core=True)" should be changed to client =
> models.ForeignKey(Client, unique=True, edit_inline = False) on run
> time.

It should be possible, if you're careful (entirely unsupported, though,
so if it breaks you get to keep both pieces). After a model class has
been parsed at import time, all the information about the Field classes
resides in the _meta attribute, which is an Options class from
django/db/models/options.py. The fields themselves are all subclasses of
Field, which is in django/db/models/fields/__init__.py. Both of those
files are fairly well documented in the comments, so it should be fairly
straightforward to read through the Field class (as a starting point) to
work out what you need to change.

Regards,
Malcolm

-- 
Quantum mechanics: the dreams stuff is made of. 
http://www.pointy-stick.com/blog/


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



Re: Accessing FK sets in model methods

2007-07-18 Thread Ben Ford
This error message is to do with a syntax error... It doesn't have anything
to do with django specifically. If you've cut and pasted verbatim, then you
need a colon ( : ) at the end of your if  > 0 line. This is what python
is flagging as an error as far as i can see.
Ben

On 18/07/07, Ilan <[EMAIL PROTECTED]> wrote:
>
>
> You're correct I did have a extra space, but the original problem was
> syntax error on the following line :
> if self.segment_set.count() > 0
> so my question is : can I acess to FK queryset as described in
> http://www.djangoproject.com/documentation/db-api/#Backward in a model
> method
>
> thanks
>
> On 18 יולי, 17:32, Tim Chase <[EMAIL PROTECTED]> wrote:
> > > Can someone point me to the problem?
> >
> > > class Base(models.Model):
> > > User = models.CharField(maxlength=200)
> > > Notes = models.CharField(maxlength=200) # free text
> >
> > >  def _first_date(self):
> > >""" Return the first date """
> > >  if self.segment_set.count() > 0
> > >  return(self.segment_set.order_by('create_date')
> > > [0].create_date)
> > >  first_date = property(_first_date)
> >
> > > class Segment(models.Model):
> > > base = models.ForeignKey(Base)
> > > create_date = models.DateTimeField(auto_now_add=True)
> > > update_date = models.DateTimeField(auto_now=True)
> > > Notes = models.CharField(maxlength=200) # free tex
> >
> > > #
> > > D:\Sites\mysite>python manage.py syncdb
> > > Error: Couldn't install apps, because there were errors in one or more
> > > models:
> > > mysite.traveler: invalid syntax (models.py, line 8)
> >
> > If you did a copy of your actual code, line #8 ("def
> > _first_date(self):") seems to have an extra space worth of
> > indentation from the User/Notes lines.
> >
> > Python would flag this as bogus, which in turn would likely
> > trigger an error in validation.
> >
> > -tim
>
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+628111880346

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



Modifying Model Field Attributes on Run Time

2007-07-18 Thread Sebastian Macias

Is there anyway to modify model field attributes on run time.. What
I'm trying to do is to build some logic that will decide whether a
model that is related to other model should be edited or not inline in
the admin.

Basically: "client = models.ForeignKey(Client, unique=True,
edit_inline = True, core=True)" should be changed to client =
models.ForeignKey(Client, unique=True, edit_inline = False) on run
time.


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



Cheetah-like comments [was: Re: template preprocessor ?]

2007-07-18 Thread olivier

Thank you James, it's really great to get such answers !

Template loaders is a handy feature, I made my own in minutes.
People interested can find it here :

http://www.djangosnippets.org/snippets/326/

Cheers,

Olivier



On 19 juil, 02:03, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 7/18/07, olivier <[EMAIL PROTECTED]> wrote:
>
> > I'm thinking about a very simple processor that would remove lines
> > beginning by ## (ala mako), because the Django comment syntax is sooo
> > verbose and tedious to type
>
> You'll probably want to implement it as a custom template loader[1];
> Django ships with a couple of different loaders which have different
> behaviors for locating templates, but there's no reason why you
> couldn't write one which implements whatever preprocessing you want; a
> template loader is simply a function which, given a template name and
> a list of directories to search, locates and returns the appropriate
> contents of a template file to be passed to the Template constructor.
>
> It'd be fairly easy to write one which, after loading the file,
> performs whatever preprocessing you like on the contents before
> handing them over (as a string); documentation on how to write
> template loaders is a little bit scarce right now, but the bundled
> loaders in django.template.loaders[2] provide helpful examples, and
> there's also a third-party loader by Jannis Leidel which pulls
> templates from a database[3] you might want to look at as an example
> of rolling your own.
>
> [1]http://www.djangoproject.com/documentation/templates_python/#loading-...
> [2]http://code.djangoproject.com/browser/django/trunk/django/template/lo...
> [3]http://code.google.com/p/django-databasetemplateloader/
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



Re: Accessing FK sets in model methods

2007-07-18 Thread Ilan

You're correct I did have a extra space, but the original problem was
syntax error on the following line :
if self.segment_set.count() > 0
so my question is : can I acess to FK queryset as described in
http://www.djangoproject.com/documentation/db-api/#Backward in a model
method

thanks

On 18 יולי, 17:32, Tim Chase <[EMAIL PROTECTED]> wrote:
> > Can someone point me to the problem?
>
> > class Base(models.Model):
> > User = models.CharField(maxlength=200)
> > Notes = models.CharField(maxlength=200) # free text
>
> >  def _first_date(self):
> >""" Return the first date """
> >  if self.segment_set.count() > 0
> >  return(self.segment_set.order_by('create_date')
> > [0].create_date)
> >  first_date = property(_first_date)
>
> > class Segment(models.Model):
> > base = models.ForeignKey(Base)
> > create_date = models.DateTimeField(auto_now_add=True)
> > update_date = models.DateTimeField(auto_now=True)
> > Notes = models.CharField(maxlength=200) # free tex
>
> > #
> > D:\Sites\mysite>python manage.py syncdb
> > Error: Couldn't install apps, because there were errors in one or more
> > models:
> > mysite.traveler: invalid syntax (models.py, line 8)
>
> If you did a copy of your actual code, line #8 ("def
> _first_date(self):") seems to have an extra space worth of
> indentation from the User/Notes lines.
>
> Python would flag this as bogus, which in turn would likely
> trigger an error in validation.
>
> -tim


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



How do I know if fastcgi is installed correctly? (using dreamhost)

2007-07-18 Thread walterbyrd

I am trying to follow jeff croft's tutorial for installing django on
dreamhost.

http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/

I am trying to "Install and configure FastCGI"

I followed the tutorial, I don't see where I did anything wrong.

One part that I don't quite understand:

---
Set up mod_rewrite
Apache's mod_rewrite module will pass all requests to your website
through dispatch.fcgi, and thus, into Django's URL dispatcher.


How I am I supposed to do that? Is that done when I do the pkill
python?

After the pkill python, the tutorial states:

---
All URLs on our subdomain should now be routed to Django. Feel free to
open up your browser and try it out for yourself.
---

So, I don't have to restart python? Also, what am I supposed to see,
if the setup was successful? I gave it a try and the server timed out.
Any idea what I did wrong?


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



Re: error accessing /admin/doc/views/

2007-07-18 Thread James Bennett

On 7/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I can access other pages in the doc area (ex: /admin/doc/filters/ or /
> admin/doc/tags/) but when I try to access the views documentation, I
> receive:

...snip...

>   SyntaxError at /admin/doc/views/
>   invalid syntax (views.py, line 39)
> """

Your best bet is to check your views to ensure that there are no
Python syntax errors, and your URLConf to ensure nothing's wrong in
there; if an error in one of those files causes problems building the
map of URLs to views or importing the views to get their
documentation, you'll see these sorts of errors.


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

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



Re: MySQL Clustering

2007-07-18 Thread James Bennett

On 7/18/07, Richard Leland <[EMAIL PROTECTED]> wrote:
> Trying to set up a connection from Django to a MySQL cluster. I've never
> done this before, so any guidance you could provide would be excellent.

Though I may be wrong, I was under the impression that the engine only
needs to be specified when creating the tables, so probably you'll
want to avoid using syncdb -- instead, pipe the output of 'manage.py
sql' for each of your apps into a file, add the requisite engine
declarations, and run that manually on the SQL node of the cluster.

After that, you should be able to have Django connect to the SQL node
just as it would connect to any other MySQL database, and (hopefully)
things will just work.


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

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



Re: Bulk data upload

2007-07-18 Thread Jacob Kaplan-Moss

On 7/18/07, Tim Chase <[EMAIL PROTECTED]> wrote:
> I dislike CSV because it takes extra overhead to
> synchronize the flavors of them (how are quotes quoted?  are
> values quoted? etc).

Psst! Check out Python's built-in ``csv`` module
(http://docs.python.org/lib/module-csv.html); it handles all that
nastiness for you.

Jacob

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



Re: template preprocessor ?

2007-07-18 Thread James Bennett

On 7/18/07, olivier <[EMAIL PROTECTED]> wrote:
> I'm thinking about a very simple processor that would remove lines
> beginning by ## (ala mako), because the Django comment syntax is sooo
> verbose and tedious to type

You'll probably want to implement it as a custom template loader[1];
Django ships with a couple of different loaders which have different
behaviors for locating templates, but there's no reason why you
couldn't write one which implements whatever preprocessing you want; a
template loader is simply a function which, given a template name and
a list of directories to search, locates and returns the appropriate
contents of a template file to be passed to the Template constructor.

It'd be fairly easy to write one which, after loading the file,
performs whatever preprocessing you like on the contents before
handing them over (as a string); documentation on how to write
template loaders is a little bit scarce right now, but the bundled
loaders in django.template.loaders[2] provide helpful examples, and
there's also a third-party loader by Jannis Leidel which pulls
templates from a database[3] you might want to look at as an example
of rolling your own.

[1] 
http://www.djangoproject.com/documentation/templates_python/#loading-templates
[2] http://code.djangoproject.com/browser/django/trunk/django/template/loaders
[3] http://code.google.com/p/django-databasetemplateloader/

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

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



Re: Problem when inserting into a table with a MySQL auto_increment primary key

2007-07-18 Thread Nis Jørgensen

AnaReis skrev:
> Hi all,
> I have a problem when inserting a register into this table that I'm
> working with.
> This table belongs to a MySQL database and the storage engine is
> MyISAM. The database that I'm using is a legacy database and I can't
> change it in any way.
> When I insert a register into the table it's MySQL who generates the
> primary key for me. Which means that I fill all the required table
> fields and leave the primary key field empty for MySQL to fill when I
> insert the record. The problem is, since the ".save()" method doesn't
> return any value there is no way for me to give any confirmation for
> the user if the register was inserted or not. 
Have you added the primary key to the model, like this:

my_legacy_id = AutoField()

If you do, I believe you will be able to read the value of the field
after calling .save().
 At least you can with the standard id field when using postgresql.

Nis

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



Re: Bulk data upload

2007-07-18 Thread Toby Dylan Hocking

> What about CSV?  You can export from Excel as CSV pretty easily and it's a 
> fairly easy format to parse in python...

Either that or tab-delimited text. I have a django app that does bulk data 
upload from the admin interface according to the following protocol.

1. Users make their bulk upload data tables in excel.

2. They log onto the Django admin site, where I have a special ExcelImport 
model set up --- it just has a TextField where the data goes.

3. They copy the entire table from excel and paste it in the TextField, 
then click Save.

4. I have a custom save() method for the ExcelImport class that processes 
the data and creates the related objects.

>
> Thanks,
>
> Dave
>
> -- 
> David Reynolds
> [EMAIL PROTECTED]
>
>

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



Re: Picture in admin

2007-07-18 Thread Kai Kuehne

Hi Naco

On 7/18/07, Naco <[EMAIL PROTECTED]> wrote:
>
> Does anybody know how to display thumnails in the admin interface?

Maybe this is what you want:
http://www.djangosnippets.org/snippets/239/

Greetings
Kai

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



Re: sessions - cookies in opera

2007-07-18 Thread Nis Jørgensen

Daniel Kontsek skrev:
> Hello
>
> I have a web application with 2 views. The first view checks if the
> session dictionary has a 'uid' key - if not it generates an random ID
> and puts it into request.session dict. The second view reads the uid
> from the session dict and creates a Project DB object with that uid.
> This works fine in all browsers (FF, Safari, IE), except Opera. Looks
> like Opera (Mac, 9.21.3678) doesn't accept the cookie with the session
> info. although cookies are on. Any idea why?
>   
Several possibilities come to mind:

- The cookies may be somehow violating the standard. Other browsers may
be more accepting of invalid data.
- When receiving a cookie received as part of a redirect, it may not be
immediately sent with the new request. It is not clear whether this is
allowed by the standard - which talks about cookies which the client has
"stored". Opera might not have stored the cookie at that point in time.
. Opera may be configured to not accept cookies, or be very strict in
what it accepts.
- Opera may be caching the page that is supposed to set the cookie. This
would probably not be happening consistently, though.

I think it would be a good idea to look at what actually goes on in the
HTTP communication - perhaps logging the two HttpRequests and
corresponding HttpResponses

/Nis


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



Re: Blog engine

2007-07-18 Thread Kai Kuehne
We don't need such an app (well, I don't need it).
If I want it, I write it in 20 minutes. :-)

Kai

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



Re: Menu implementation

2007-07-18 Thread Carl Karsten

Lic. José M. Rodriguez Bacallao wrote:
> Have anybody implemented a tree with django, for example, a menu?
> 

tree = ui or data structurer?  (guessing the answer is yes to both)

Carl K

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



model and cascading

2007-07-18 Thread tyman26

Is it possible to set a property in my model that will set update
cascade/delete to true when the tables are generated?  I know models
automatically do this anyways when you delete or update, but if I am
working directly with database information it doesn't work
consistently.   I know it's possible to simply alter  the table within
my database, but if I rebuild the tables with django then I have to
redo this every time.  Is this my only solution?


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



www.cerocom.com

2007-07-18 Thread Natalia

.. www.cerocom.com 
..

You will be able to ask yourself:

Is Internet a good investment for my company?
So that an investment would have to do I of this type?
Really is going to serve to me to have a Web site?
So that to be in Internet?

See some of the main advantages have a Web site:

· Increase the productivity and to generate more businesses with the
implementation of collaboration  rofe and integration maximizing the
value of Internet and networks IP.

· Offer solutions of Internet, integration and collaboration in
accordance with our clients, anyone is their size or trains, to
rofesional r to integrate their applications, to fortify their present
position in the market or to impel their growth, assuring
trustworthiness, discharge  rofesional qualification, and customized
service.

I invite it to cross the Web site and interiorice of the services
available.

www.cerocom.com

Contact:

Commercial direction:
Viamonte 783 Piso 3°
Capital Federal
(C1053ABO) Bs. As. Argentina

Tel/Fax: (54.11) 4322.1201

Celular: (54-9-11) (15) 5006.4384

Mail:  [EMAIL PROTECTED]

Web Site:  www.cerocom.com


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



Re: Picture in admin

2007-07-18 Thread Nathan Ostgard

Here's something on djangosnippets.org for displaying thumbnails in
the admin list:
http://www.djangosnippets.org/snippets/239/

Or do you mean on the page for editing a record?


Nathan Ostgard

On Jul 18, 2:11 pm, Naco <[EMAIL PROTECTED]> wrote:
> Does anybody know how to display thumnails in the admin interface?


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



MySQL Clustering

2007-07-18 Thread Richard Leland
Trying to set up a connection from Django to a MySQL cluster. I've never
done this before, so any guidance you could provide would be excellent.

I know that DATABASE_OPTIONS can be used in the settings.py file, just not
sure if that's the right course of action or even how to write this into the
DATABASE_OPTIONS dict. I know that any query on the DB needs to specify the
engine as NDBCLUSTER like so:

mysql> CREATE TABLE x (
-> id int(11) NOT NULL AUTO_INCREMENT,
-> c char(10) DEFAULT NULL,
-> PRIMARY KEY (id)
->   ) ENGINE=NDBCLUSTER DEFAULT CHARSET=utf8;

thanks in advance!

Rich

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



Re: Slug (w/o using SlugField) Problems

2007-07-18 Thread Forest Bond
On Wed, Jul 18, 2007 at 07:10:27PM -, John-Scott wrote:
> Next, change your urls.py like so:
> 
> (r'^characters/(?P\d+)[-\w]+/$', object_detail,
> dict(character_detail_dict)),
> 
> This should capture the '123' and discard '-bob-and-jane'. This is a
> fairly elegant solution that allows you to still have 'pretty' urls
> that are human readable and google friendly while completely
> sidestepping the complications of record retrieval based on reverse
> engineering slugs or bothering with a slug column, opting instead for
> the dead-simple and fast id lookup.


Don't we all agree that unique URLs with one-to-one relationships with unique
resources are a Good Thing?  I sure thought we did...

Multiple URLs corresponding to the same resource will actually dilute your
Google rank, anyway (if someone out in space uses the non-canonical version in a
link).

You could do a permanent redirect to the canonical version, I guess.

-Forest


signature.asc
Description: Digital signature


Re: Slug (w/o using SlugField) Problems

2007-07-18 Thread John-Scott

The option I want to implement, and which my be a suitable solution
for your situation, is to combine the object id with the slugified
version of the object name. Then in your urls.py, only capture the
object id and ignore the slug when retrieving the object (this gets
you past any issues with reversibility). So you'd end up with
something like:

def get_absolute_url(self):
return "/characters/%s/" % self.id + '-' + (slugify(self.name))

...in your model, resulting in a url like "/characters/123-bob-and-
jane". Your urls.py would need something like:
(r'^characters/(?P\d+)[-\w]+/$', object_detail, ...

This should capture the '123' of the slug and ignore the '-bob-and-
jane'. So you only use the slug for pretty urls aka human readable and
search engine friendly urls but still rely on the id value for quick
and painless database lookups.

My question is did you write your own 'slugify' method or is this
included in core somewhere and I just need the appropriate import
statement in my model files?

Cheers,
John-Scott


On Jul 6, 4:27 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> >> You might need to adopt a different approach to URL construction that is
> >> reversible (writing your own version of slugify, possibly?).
>
> > Thanks for the help Malcolm. Using Jeff Croft's "I'm not a programmer"
> > excuse, would it be too much trouble to request a small example of a
> > reversible slugify?
>
> Given that any general "slugify" method throws away information
> (case, spaces, punctuation, etc), there's no way to fabricate
> that information for reversal short of keeping the original and
> working backwards.
>
> However, you can use the urllib.quote() and urllib.unquote()
> functions instead, which may do the trick.
>
> You may have to modify the regexp in your urls.py to handle
> standard quoted characters rather than just "slug" chars.
>
> -tim


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



error accessing /admin/doc/views/

2007-07-18 Thread [EMAIL PROTECTED]

I can access other pages in the doc area (ex: /admin/doc/filters/ or /
admin/doc/tags/) but when I try to access the views documentation, I
receive:

"""
SyntaxError at /admin/doc/views/
invalid syntax (views.py, line 39)
Request Method: GET
Request URL:http://localhost:8000/admin/doc/views/
Exception Type: SyntaxError
Exception Value:invalid syntax (views.py, line 39)
Exception Location: C:\Python25\lib\site-packages\django\core
\urlresolvers.py in _get_callback, line 125


Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\lib\site-packages\django\contrib\admin\views
\decorators.py" in _checklogin
  55. return view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views\doc.py"
in view_index
  108. view_functions =
extract_views_from_urlpatterns(urlconf.urlpatterns)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views\doc.py"
in extract_views_from_urlpatterns
  341. views.extend(extract_views_from_urlpatterns(patterns, base +
p.regex.pattern))
File "C:\Python25\Lib\site-packages\django\contrib\admin\views\doc.py"
in extract_views_from_urlpatterns
  333. views.append((p._get_callback(), base + p.regex.pattern))
File "C:\Python25\lib\site-packages\django\core\urlresolvers.py" in
_get_callback
  125. self._callback = getattr(__import__(mod_name, {}, {}, ['']),
func_name)

  SyntaxError at /admin/doc/views/
  invalid syntax (views.py, line 39)
"""

I'm using .96, and Python 2.5 on windoze.

I see some posts about not being able to access the views because of a
decorator issue, but they don't seem related.


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



Re: Problem when inserting into a table with a MySQL auto_increment primary key

2007-07-18 Thread Collin Grady

If there's a problem, it will raise an exception, so you won't just
slide past invisibly.


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



Picture in admin

2007-07-18 Thread Naco

Does anybody know how to display thumnails in the admin interface?


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



Re: newforms and models unique=True validation

2007-07-18 Thread Nathan Ostgard

You want to create a BaseForm to specify in your form_for_model call.
You could do something like:

from django import newforms as forms

class MyBaseForm(forms.BaseForm):
  def clean_myfield(self):
if
MyModel.objects.filter(myfield=self.cleaned_data['myfield']).count():
  raise forms.ValidationError('some error message')

MyForm = forms.form_for_model(MyModel, form=MyBaseForm)


Nathan Ostgard

On Jul 18, 7:06 am, stereoit <[EMAIL PROTECTED]> wrote:
> Hi,
> I have model with field that has attribute unique set to True. I know
> newforms are not able to handle such a validation as this is DB
> related. However I read at newforms doc page that it is possible to
> provide method called clean_() that can do custom validation.
> My problem is that method is supposed to access the data via
> self.cleaned_date and I create form by using form_for_model hence I do
> not know how to write such a method.
>
> Can anyone point me to right direction or best practice? Handling this
> at form.save() seem not right to me.
>
> My idea was to create custom validation method that would try tu pull
> object from DB with  set to same as in
> cleaned_data['fieldname'] and if it exists it would raise
> ValidationError. But I have no clue how to do that at the moment.


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



Re: Slug (w/o using SlugField) Problems

2007-07-18 Thread John-Scott

Hello,

I'm using a solution I saw on a RoR blog (http://
blog.hasmanythrough.com/2006/7/7/more-on-naming-and-the-crud has a
summary of the technique) which should address the 'reversibility'
issue. Basically you just concatenate the object id with the slug of
the human readable name, but then just ignore everything but the
object id in your urlpatterns. First, you'd change your model like so:

def get_absolute_url(self):
return "/characters/%s/" % self.id + '-' + (slugify(self.name))

This will generate urls like "/characters/123-bob-and-jane".
Next, change your urls.py like so:

(r'^characters/(?P\d+)[-\w]+/$', object_detail,
dict(character_detail_dict)),

This should capture the '123' and discard '-bob-and-jane'. This is a
fairly elegant solution that allows you to still have 'pretty' urls
that are human readable and google friendly while completely
sidestepping the complications of record retrieval based on reverse
engineering slugs or bothering with a slug column, opting instead for
the dead-simple and fast id lookup.

Hope this helps.

Btw, I assume you're just importing the slugify method from
django.template.defaultfilters? This is what I did, rather than write
my own method.

Cheers,
John-Scott

(note: I tried writing this response a few hours ago, but it doesn't
appear to have posted correctly. If it magically appears, I'll remove
the duplicate post)


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



Re: Bulk data upload

2007-07-18 Thread Tim Chase

> left: bulk upload. I've thought of using xls (microsoft
> office's excel files) to make it easy on the client, because
> teaching them xml or yaml isn't the big deal. After thinking
> about it, finding a xls parser module for python might not be
> the problem, 

I second the idea of using a plain-text interchange format, 
whether CSV as David suggested, or (my preferred) tab-delimited 
format.  I dislike CSV because it takes extra overhead to 
synchronize the flavors of them (how are quotes quoted?  are 
values quoted? etc).  I find TAB format just less messy.

> but how could I take on product images? How can I
> bulk upload those? Ok, I can upload a tar or zip file and have
> it unpacked automatically, but how do I automagically assign
> the images with the product, having in mind that some might
> have 5 pics and others might have 2 or none.

Your idea of uploading a zip/tar archive is a good one.  One 
would need to go with naming conventions.  Images could be named 
of the format _.[jpg|gif] and then any 
corresponding items could be added to your ProductImages table. 
This assumes you have a  column in your upload file.

You might want to report on items in the image-archive that don't 
have a corresponding item in the upload file (or aren't already 
in the data...might be easier).

To augment Adam's suggestion, a lot of the code can be made 
shorter and more readable using Python's tuple-assignment, so 
rather than having hard-coded indicies such as "product.slug = 
raw_data[6]", you can do something like

  (in_id,
   manufacturer,
   vendor,
   dealer_price,
   dealer_price_updated,
   model,
   slug,
   description,
   package_contents,
   ...
   ) = raw_data

You can then use each of these parts for later assignment, or 
even directly assign them like

  (in_id,
   manufacturer,
   ...
   product.model,
   product.slug,
   product.description,
   ... ) = raw_data

This does assume a fixed column order, which would require some 
tweaks if the columns could be in an arbitrary order.  However, a 
little dictionary trickery can solve that.  I usually do this via

REQUIRED_COLUMNS = [
   'manufacturer',
   'slug',
   ...
   ]
for row_num, row in file(filename):
   row = row.rstrip('\n').split(DELIM)
   if row_num == 0:
 header_to_column = dict([
   (n, i) for (i,n)
   in enumerate(row)])
 header_set = set([h.lower() for h in row])
 for header in REQUIRED_COLUMNS:
   assert header in header_set, 'Missing column %s' % header
 continue
   # use header_to_column to map the desired column name
   # to its offset/index


-tim





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



Re: Menu implementation

2007-07-18 Thread Jonathan Buchanan

On 7/18/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote:
> Have anybody implemented a tree with django, for example, a menu?
>
> --
> Lic. José M. Rodriguez Bacallao
> Cupet

I've implemented a tree of comments in django-discussion:

http://django-discussion.googlecode.com/svn/trunk/models.py

It shouldn't be too hard to modify that for your own ends if it's
suitable - it uses Modified Preorder Tree Traversal as described here:

http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal

I've also *just about* finished my first hackety stab at a (non
database-backed) Section/Page menu system (where each section may
contain a number of pages) which takes into account which users should
be able to see which links - I'll probably put it on Django Snippets
once it's "working". I'd ideally like to go on to extract a generic
implementation of this functionality, but time is in short supply as
always! :)

Regards,
Jonathan.

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



Re: Unique=true

2007-07-18 Thread Nis Jørgensen

Nis Jørgensen skrev:
> [EMAIL PROTECTED] skrev:
>   
>> OK, fixed the above problem -- figured out that it was related to my
>> setting unique=True on a field. But that raises the larger question...
>>
>> I have a bit of data that may or may not exist... a identifier on the
>> user that not all users will have, but if they DO have it, it needs to
>> be unique to that user. Apparently, unique=True isn't what I want,
>> because the second user without it throws the above duplicate entry
>> error, so how do I handle that?
>>   
>> 
> I believe the behavior depends on your database backend. Postgresql does
> what you want.
>
> Postgresql is, AFAICT, complying with at least one of the SQL standards
> (but I don't have a copy of those)
>   
It seems mysql 5 works the same way as postgres - and it seems the error
message you quoted was from postgres.

It seems to me you do not have  null=True set for the Field. Thus blank
values are stored as empty strings, which unlike NULLS are equal to each
other.

/Nis




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



Re: Accessing FK sets in model methods

2007-07-18 Thread Tim Chase

> Can someone point me to the problem?
> 
> class Base(models.Model):
> User = models.CharField(maxlength=200)
> Notes = models.CharField(maxlength=200) # free text
> 
>  def _first_date(self):
>""" Return the first date """
>  if self.segment_set.count() > 0
>  return(self.segment_set.order_by('create_date')
> [0].create_date)
>  first_date = property(_first_date)
> 
> class Segment(models.Model):
> base = models.ForeignKey(Base)
> create_date = models.DateTimeField(auto_now_add=True)
> update_date = models.DateTimeField(auto_now=True)
> Notes = models.CharField(maxlength=200) # free tex
> 
> #
> D:\Sites\mysite>python manage.py syncdb
> Error: Couldn't install apps, because there were errors in one or more
> models:
> mysite.traveler: invalid syntax (models.py, line 8)

If you did a copy of your actual code, line #8 ("def 
_first_date(self):") seems to have an extra space worth of 
indentation from the User/Notes lines.

Python would flag this as bogus, which in turn would likely 
trigger an error in validation.

-tim



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



Re: Bulk data upload

2007-07-18 Thread Adam Fast
I won't attempt to tackle the image conundrum (because our old ecommerce
site is of the single-image variety, which makes it easy).

The other, though I can help you with.  My models yield four tables
(products, product_categories, product_site to tie it to a site, and
product_attributes).  I wrote in C# an exporter application from our old
system (.NET) and made it output pipe-delimited files in the format of my
models in django, whether that data was stored previously or not, just to
keep it clean and readable.  The C# app takes some information such as what
ID the next imported product will start with, and uses it to build rows and
save them.  This may help, it may not...but below is my
importprocess.pythat handles all of this, at least on the django side.
 It's not a perfect
implementation, because it was only used once - to move data over.  It runs
in the shell, but it could be wrapped in a view as well.  I've changed a few
names and such to protect who we are...we are not yet switched over to the
django site, several other projects have come up for me to work on.  I will
most certainly announce though once we do go live.

*importprocess.py

from project.products.models import Product, Manufacturer, Warranty,
Category, ProductAttribute, ProductAttributeChoice
from django.contrib.sites.models import Site

def import_products():
filename = "c:/import/products.txt"

file = open(filename)

while 1:
lines = file.readlines(10)
if not lines:
break
for line in lines:
raw_data = line.split('|')
product = Product()
#raw_data[0]
#id left alone, db will handle

#raw_data[1]
#manufacturer
prd_man_list = Manufacturer.objects.filter
(id__exact=raw_data[1])
if prd_man_list:
prd_man = prd_man_list[0]
product.manufacturer = prd_man

#raw_data[2]
#vendor
#not implemented previously, left out

#raw_data[3]
#dealer_price
#not implemented previously, left out

#raw_data[4]
#dealer_price_updated
#not implemented previously, left out

#raw_data[5]
#model
product.model = raw_data[5]

#raw_data[6]
#slug
product.slug = raw_data[6]

#raw_data[7]
#description
product.description = raw_data[7]

#raw_data[8]
#package_contents
#not implemented previously, left out

#raw_data[9]
#warranty
if raw_data[9] != '':
if int(raw_data[9]) > 0:
warranty_list = Warranty.objects.filter
(id__exact=raw_data[9])
if warranty_list:
warranty = warranty_list[0]
product.warranty = warranty
else:
warranty_list = Warranty.objects.filter(id__exact=15)
if warranty_list:
warranty = warranty_list[0]
product.warranty = warranty
else:
warranty_list = Warranty.objects.filter(id__exact=15)
if warranty_list:
warranty = warranty_list[0]
product.warranty = warranty

#raw_data[10]
#MAP
product.map = raw_data[10]

#raw_data[11]
#on_site_price
#not implemented previously, left out

#raw_data[12]
#in_cart_price
product.in_cart_price = raw_data[12]

#raw_data[13]
#released
#not implemented previously, left out

#raw_data[14]
#discontinued
#not implemented previously, left out

#raw_data[15]
#length
#not implemented previously, left out

#raw_data[16]
#width
#not implemented previously, left out

#raw_data[17]
#height
#not implemented previously, left out

#raw_data[18]
#weight
product.weight = raw_data[18]

#raw_data[19]
#shipping_weight
product.shipping_weight = raw_data[19]

#raw_data[20]
#shipping_length
product.shipping_length = raw_data[20]

#raw_data[21]
#shipping_width
product.shipping_width = raw_data[21]

#raw_data[22]
#shipping_height
product.shipping_height = raw_data[22]

#raw_data[23]
#shipping_flat_cost
#not implemented previously, left out

#raw_data[24]
#show_in_stock
product.show_in_stock = raw_data[24]

#raw_data[25]
#spec_pdf
product.spec_pdf = raw_data[25]

#raw_data[26]
#highlight_large
product.highlight_large = raw_data[26]

#raw_data[27]
#highlight_medium
product.highlight_medium = raw_data[27]

#raw_data[28]
#highlight_thumbnail
product.highlight_thumbnail = 

Accessing FK sets in model methods

2007-07-18 Thread Ilan

Hi,
My name is Ilan, and I kind of new working with Django.

I have a question about model methods.
I trying to write a model method which access ForeignKey FOO_set
functionality

Whoever it does not seems to pass the "syncdb" validation, because of
invalid syntax
Can someone point me to the problem?

#
from django.db import models
from django.contrib.auth.models import User

class Base(models.Model):
User = models.CharField(maxlength=200)
Notes = models.CharField(maxlength=200) # free text

 def _first_date(self):
   """ Return the first date """
 if self.segment_set.count() > 0
 return(self.segment_set.order_by('create_date')
[0].create_date)
 first_date = property(_first_date)

class Segment(models.Model):
base = models.ForeignKey(Base)
create_date = models.DateTimeField(auto_now_add=True)
update_date = models.DateTimeField(auto_now=True)
Notes = models.CharField(maxlength=200) # free tex

#
D:\Sites\mysite>python manage.py syncdb
Error: Couldn't install apps, because there were errors in one or more
models:
mysite.traveler: invalid syntax (models.py, line 8)


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



custom order_by?

2007-07-18 Thread Andrey Khavryuchenko

Folks,

In spirit of recent question regarding custom 'where'...  Is there a way to
put a custom ORDER BY into QuerySet?  I have an sql function that does all
the math on db side and would like to use it at order_by clause

I quickly skimmed _get_sql_clause and haven't found any way to incorporate
something like "ORDER BY calc_post_rating(id)".

Am I wrong or is the only way to have this to override/hack
_QuerySet._get_sql_clause?

TIA!

-- 
Andrey V Khavryuchenko
Django NewGate -  http://www.kds.com.ua/djiggit/
Development - http://www.kds.com.ua OR skype://akhavr

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



newforms and models unique=True validation

2007-07-18 Thread stereoit

Hi,
I have model with field that has attribute unique set to True. I know
newforms are not able to handle such a validation as this is DB
related. However I read at newforms doc page that it is possible to
provide method called clean_() that can do custom validation.
My problem is that method is supposed to access the data via
self.cleaned_date and I create form by using form_for_model hence I do
not know how to write such a method.

Can anyone point me to right direction or best practice? Handling this
at form.save() seem not right to me.

My idea was to create custom validation method that would try tu pull
object from DB with  set to same as in
cleaned_data['fieldname'] and if it exists it would raise
ValidationError. But I have no clue how to do that at the moment.


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



Re: Bulk data upload

2007-07-18 Thread David Reynolds


On 18 Jul 2007, at 12:00 pm, Chris Hoeppner wrote:


Hi there!

I've been working on an ecommerce solution. So far everything works  
like

it should. There's just one "nice to have" feature left: bulk upload.
I've thought of using xls (microsoft office's excel files) to make it
easy on the client, because teaching them xml or yaml isn't the big
deal. After thinking about it, finding a xls parser module for python
might not be the problem, but how could I take on product images? How
can I bulk upload those? Ok, I can upload a tar or zip file and  
have it

unpacked automatically, but how do I automagically assign the images
with the product, having in mind that some might have 5 pics and  
others

might have 2 or none.




What about CSV?  You can export from Excel as CSV pretty easily and  
it's a fairly easy format to parse in python...


Thanks,

Dave

--
David Reynolds
[EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature


Re: Django's User authentication

2007-07-18 Thread Jason F. McBrayer

james_027 <[EMAIL PROTECTED]> writes:

> what if I need additional fields or methods for my apps? Do i inherit
> it or edit the user class?

The standard approach is here:
http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model

However, also have a look at this approach:
http://groups.google.com/group/django-developers/browse_thread/thread/f62b05cae5e5f462/55889eafe381a09b?lnk=gst=multiple+profiles=1#55889eafe381a09b

It does require writing a context processor and a middleware, but they
are very small and simple, and they greatly simplify the use of your
user object in your views and templates.

-- 
+---+
| Jason F. McBrayer[EMAIL PROTECTED]  |
| If someone conquers a thousand times a thousand others in |
| battle, and someone else conquers himself, the latter one |
| is the greatest of all conquerors.  --- The Dhammapada|

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



Re: ANN: DMigrate - A Django Database Migration Tool

2007-07-18 Thread Noam Raphael

On 7/18/07, Ben Ford <[EMAIL PROTECTED]> wrote:
> Just out of interest have you explored using SQLAlchemy directly with the 
> django model..? I mean mapping the SA Table onto the django Model..? I had a 
> play with that a while back and it seems a very straightforward way of 
> achieving SA - django integration...
> Ben
>

No, I haven't tried it. In the script DMigrate creates, there are SA
classes which interact with the source database, and Django classes
which interact with the destination database. They don't touch one
another.

Noam

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



Special Django Presentation at PyAtl

2007-07-18 Thread [EMAIL PROTECTED]

Just an FYI,

For all of you folks in the Atlanta Area, we have a special Django
Presentation on Aug. 9th at Turner Studios by a leading Django
instructor from the Big Nerd Ranch.  Please see our meetup event for
more details:  http://python.meetup.com/46/calendar/5900658/


Thanks,

Noah


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



Special Django Presentation at PyAtl

2007-07-18 Thread [EMAIL PROTECTED]

Just an FYI,

For all of you folks in the Atlanta Area, we have a special Django
Presentation on Aug. 9th at Turner Studios by a leading Django
instructor from the Big Nerd Ranch.  Please see our meetup event for
more details:  http://python.meetup.com/46/calendar/5900658/


Thanks,

Noah


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



Re: ANN: DMigrate - A Django Database Migration Tool

2007-07-18 Thread Ben Ford
Just out of interest have you explored using SQLAlchemy directly with the
django model..? I mean mapping the SA Table onto the django Model..? I had a
play with that a while back and it seems a very straightforward way of
achieving SA - django integration...
Ben

On 18/07/07, Noam <[EMAIL PROTECTED]> wrote:
>
>
> On Jul 18, 4:47 am, "Ben Ford" <[EMAIL PROTECTED]> wrote:
> > > I haven't looked at the code, but I wonder about the dependency on
> > > multiple ORMs; the Django ORM cannot expose its own functionality on
> > > multiple databases at once...
> >
> > It can using the multiple-db-support branch (see ticket 4747 for a patch
> > bringing the branch up to date)...
>
> If it's merged into the trunk, there indeed will be no need to use
> SQLAlchemy. It will be very nice!
>
> > There's also a similar module (on
> > djangosnippets I think) which enables extraction/insertion of a database
> > into/from a list of python files. It's pretty good!!
>
> Thanks for the reference! You probably mean
> http://www.djangosnippets.org/snippets/167/
> . It's very nice. I still prefer my method, but I would like to hear
> what others think about it.
>
> (Ok, I'll say why I prefer my method. Pickle is complicated. You never
> know exactly what's in that pickle file. On the other hand, a script
> which copies data from one database into another is easy to understand
> and modify. It also doesn't require you to write plugins to modify
> classes - you just modify the script in a straightforward way. And
> still, I'm biased. I would like to hear what others think.)
>
> Noam
>
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+628111880346

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



edit_inline for a reflexive m2m_intermediary

2007-07-18 Thread Nicola Larosa

I'm following the m2m_intermediary pattern:

9. Many-to-many relationships via an intermediary table
http://www.djangoproject.com/documentation/models/m2m_intermediary/

However, I need associations, not between two different models, but between
pairs of instances of the *same* model, as discussed in this thread:

Friendship_type on symmetrical M2M
http://groups.google.com/group/django-users/browse_thread/thread/72afc8b5540dd75e/68688173a04a027d

Take this Person model:

class Person(models.Model):
first_name = models.CharField(maxlength = 100)
last_name = models.CharField(maxlength = 100)

and associate pairs of persons, while adding some data:

class Association(models.Model):
person = models.ForeignKey(Person, related_name='friend_of')
associate = models.ForeignKey(Person, related_name='friends')
some_data = models.IntegerField()

The admin interface for these models works correctly.

Now, to be able to add Associations while editing Persons, I add
edit_inline and core to Association fields.

If I add them to both ForeignKey fields:

class Association(models.Model):
person = models.ForeignKey(Person, related_name='friend_of',
core=True, edit_inline=models.TABULAR)
associate = models.ForeignKey(Person, related_name='friends',
core=True, edit_inline=models.TABULAR)
dummy = models.IntegerField()

I get this error:

Traceback (most recent call last):
File ".../django/template/__init__.py" in render_node
  754. result = node.render(context)
File ".../django/template/defaulttags.py" in render
  134. nodelist.append(node.render(context))
File ".../django/contrib/admin/templatetags/admin_modify.py" in render
  171. bound_related_object = relation.bind(
   context['form'], original, bound_related_object_class)
File ".../django/db/models/related.py" in bind
  129. return bound_related_object_class(self, field_mapping, original)
File ".../django/contrib/admin/templatetags/admin_modify.py" in __init__
  138. for (i,field_mapping) in self.field_mappings.items() ]
File ".../django/oldforms/__init__.py" in items
  264. self.fill()
File ".../django/oldforms/__init__.py" in fill
  283. field = self.parent_manipulator[full_field_name]
File ".../django/oldforms/__init__.py" in __getitem__
  28. raise KeyError, "Field %s not found\n%s" % (
  field_name, repr(self.fields))

  KeyError at /admin/person/add/
  'Field association.0.associate not found
  [FormField "first_name", FormField "last_name",
   FormField "association.0.id", FormField "association.0.person",
   FormField "association.0.dummy",
   FormField "association.1.id", FormField "association.1.person",
   FormField "association.1.dummy",
   FormField "association.2.id", FormField "association.2.person",
   FormField "association.2.dummy",
   FormField "association.0.id", FormField "association.0.person",
   FormField "association.0.dummy",
   FormField "association.1.id", FormField "association.1.person",
   FormField "association.1.dummy",
   FormField "association.2.id", FormField "association.2.person",
   FormField "association.2.dummy"]'

If I only add edit_inline and core to the first ForeignKey field:

class Association(models.Model):
person = models.ForeignKey(Person, related_name='friend_of',
core=True, edit_inline=models.TABULAR)
associate = models.ForeignKey(Person, related_name='friends')
dummy = models.IntegerField()

I get this other error:

Traceback (most recent call last):
File ".../django/template/__init__.py" in render_node
  754. result = node.render(context)
File ".../django/template/defaulttags.py" in render
  134. nodelist.append(node.render(context))
File ".../django/contrib/admin/templatetags/admin_modify.py" in render
  171. bound_related_object = relation.bind(
   context['form'], original, bound_related_object_class)
File ".../django/db/models/related.py" in bind
  129. return bound_related_object_class(self, field_mapping, original)

  TypeError at /admin/diet/person/add/
  'bool' object is not callable


What am I missing?


-- 
Nicola Larosa - http://www.tekNico.net/

The smart way to keep people passive and obedient is to strictly limit
the spectrum of acceptable opinion, but allow very lively debate within
that spectrum. -- Noam Chomsky, quoted by David Icke, February 2007



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



Re: Django's User authentication

2007-07-18 Thread james_027

what if I need additional fields or methods for my apps? Do i inherit
it or edit the user class?

Thanks
james

On Jul 18, 3:45 pm, Przemek Gawronski <[EMAIL PROTECTED]>
wrote:
> > is this use for the django admin features only? or I can use it for my
> > own app? if yes, do I make it suitable for my application?
>
> Sure you can, tak a look at:
>
> http://www.djangoproject.com/documentation/authentication/#how-to-log...
>
> Przemek
> --
> AIKIDO TANREN DOJO  -   Poland - Warsaw - Mokotow - Ursynow - Natolin
> info:http://www.tanren.pl/phone: +4850151 email: [EMAIL PROTECTED]


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



Bulk data upload

2007-07-18 Thread Chris Hoeppner
Hi there!

I've been working on an ecommerce solution. So far everything works like
it should. There's just one "nice to have" feature left: bulk upload.
I've thought of using xls (microsoft office's excel files) to make it
easy on the client, because teaching them xml or yaml isn't the big
deal. After thinking about it, finding a xls parser module for python
might not be the problem, but how could I take on product images? How
can I bulk upload those? Ok, I can upload a tar or zip file and have it
unpacked automatically, but how do I automagically assign the images
with the product, having in mind that some might have 5 pics and others
might have 2 or none.

Any ideas?



signature.asc
Description: OpenPGP digital signature


Re: inheriting models' fields, methods and managers

2007-07-18 Thread Malcolm Tredinnick

On Wed, 2007-07-18 at 09:48 +, omat wrote:
> Hi all,
> 
> Recently, it occurred to me that, defining some abstract models for
> some types of applications would make my code significantly DRYer, by
> eliminating duplication of common fields, model methods and manager
> methods.
> 
> Examples of common groups of applications are:
> 
> - Orthogonal applications, that is, applications that hold content
> related to other applications, such as tags.
> - Hierarchically categorized content
> - User contributed content
> 
> There had been some discussion on "model inheritance" on the
> developers' list about a year ago, but this is basically for content
> that is hierarchically related, such as "carnivores are subclass of
> animals" and would be defined as:
> 
> class Carnivore(Animal)
> 
> But what I want is a bit different (and simpler). For example, for
> hierarchical content, define a Node() base model class as follows:
> 
> class Node(models.Model):
> parent = models.ForeignKey('self')
> objects = NodeManager()
> 
> And a manager class as follows:
> 
> class NodeManager(models.Manager):
> def get_children(self, node):
> return self.filter(parent = node)
> 
> def get_neighbours(self, node):
> return self.filter(parent = node.parent).exclude(id = node.id)
> 
> Whenever a model holds hierarchical content, subclass Node(), like
> that:
> 
> class MenuItem(Node):
> title = models.CharField(maxlength=50)
> 
> 
> I only tested with the Ortho() model class which can be found in the
> thread I started yesterday, before the issues appeared to be more
> complicated than I thought:
> http://groups.google.com/group/django-users/browse_thread/thread/975d56dff34a8784
> 
> When 'syncdb'ed, it created a single table with the methods and fields
> from the base class included. With this approach, base class' fields
> and methods can be accessed with dot notation.
> 
>  But:
> - relations in the base class does not work, i.e. I cannot say "parent
> = models.ForeignKey('self')"
> - you cannot access the manager, but you can refer to the manager from
> within the subclass, so not a big issue
> - django goodies such as "get_object_or_404" fail with " Programming
> Error: relation "models_[basemodel]" does not exist", i.e. requires to
> have the table for the base class. But if you avoid using those
> goodies, and go with simple api methods, it works.
> - admin application frequently compşains with the same "Programming
> Error"
> 
> 
> Is there a way to achieve that kind of inheritance?

You can't do it at the moment, but it's one of the completion
requirements for model inheritance. It's exactly the abstract base class
scenario: all the parent model fields will be installed in the child as
though they were defined there. Parents will (possibly) never exist in
isolation. I say "possibly", because it's not clear at the moment if the
declaration that the parent class is abstract is a property of the
parent (a la C++) or the child.

So it's a "coming soon" feature.

Regards,
Malcolm

-- 
A clear conscience is usually the sign of a bad memory. 
http://www.pointy-stick.com/blog/


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



inheriting models' fields, methods and managers

2007-07-18 Thread omat

Hi all,

Recently, it occurred to me that, defining some abstract models for
some types of applications would make my code significantly DRYer, by
eliminating duplication of common fields, model methods and manager
methods.

Examples of common groups of applications are:

- Orthogonal applications, that is, applications that hold content
related to other applications, such as tags.
- Hierarchically categorized content
- User contributed content

There had been some discussion on "model inheritance" on the
developers' list about a year ago, but this is basically for content
that is hierarchically related, such as "carnivores are subclass of
animals" and would be defined as:

class Carnivore(Animal)

But what I want is a bit different (and simpler). For example, for
hierarchical content, define a Node() base model class as follows:

class Node(models.Model):
parent = models.ForeignKey('self')
objects = NodeManager()

And a manager class as follows:

class NodeManager(models.Manager):
def get_children(self, node):
return self.filter(parent = node)

def get_neighbours(self, node):
return self.filter(parent = node.parent).exclude(id = node.id)

Whenever a model holds hierarchical content, subclass Node(), like
that:

class MenuItem(Node):
title = models.CharField(maxlength=50)


I only tested with the Ortho() model class which can be found in the
thread I started yesterday, before the issues appeared to be more
complicated than I thought:
http://groups.google.com/group/django-users/browse_thread/thread/975d56dff34a8784

When 'syncdb'ed, it created a single table with the methods and fields
from the base class included. With this approach, base class' fields
and methods can be accessed with dot notation.

 But:
- relations in the base class does not work, i.e. I cannot say "parent
= models.ForeignKey('self')"
- you cannot access the manager, but you can refer to the manager from
within the subclass, so not a big issue
- django goodies such as "get_object_or_404" fail with " Programming
Error: relation "models_[basemodel]" does not exist", i.e. requires to
have the table for the base class. But if you avoid using those
goodies, and go with simple api methods, it works.
- admin application frequently compşains with the same "Programming
Error"


Is there a way to achieve that kind of inheritance?


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



Re: ANN: DMigrate - A Django Database Migration Tool

2007-07-18 Thread Noam

On Jul 18, 4:47 am, "Ben Ford" <[EMAIL PROTECTED]> wrote:
> > I haven't looked at the code, but I wonder about the dependency on
> > multiple ORMs; the Django ORM cannot expose its own functionality on
> > multiple databases at once...
>
> It can using the multiple-db-support branch (see ticket 4747 for a patch
> bringing the branch up to date)...

If it's merged into the trunk, there indeed will be no need to use
SQLAlchemy. It will be very nice!

> There's also a similar module (on
> djangosnippets I think) which enables extraction/insertion of a database
> into/from a list of python files. It's pretty good!!

Thanks for the reference! You probably mean 
http://www.djangosnippets.org/snippets/167/
. It's very nice. I still prefer my method, but I would like to hear
what others think about it.

(Ok, I'll say why I prefer my method. Pickle is complicated. You never
know exactly what's in that pickle file. On the other hand, a script
which copies data from one database into another is easy to understand
and modify. It also doesn't require you to write plugins to modify
classes - you just modify the script in a straightforward way. And
still, I'm biased. I would like to hear what others think.)

Noam


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



Problem when inserting into a table with a MySQL auto_increment primary key

2007-07-18 Thread AnaReis

Hi all,
I have a problem when inserting a register into this table that I'm
working with.
This table belongs to a MySQL database and the storage engine is
MyISAM. The database that I'm using is a legacy database and I can't
change it in any way.
When I insert a register into the table it's MySQL who generates the
primary key for me. Which means that I fill all the required table
fields and leave the primary key field empty for MySQL to fill when I
insert the record. The problem is, since the ".save()" method doesn't
return any value there is no way for me to give any confirmation for
the user if the register was inserted or not. The only way to check if
the new record was inserted is to go to the table and check if the
register is there or not.
Is there any way to go around this? I thought, since this is a MyISAM
table, I could get the last inserted record but I still have no
guaranty that the last record was the one inserted by the user since
there can be two equal lines in the table with the same information
but with a different primary key... How do I know if the last record
was inserted by the user (which means the insert was successful) or if
it was already there before and there was a problem with this last
insert?

Ana


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



Re: ANN: DMigrate - A Django Database Migration Tool

2007-07-18 Thread Noam

Thanks for your comment!

Relying on another ORM isn't technically necessary, but it seems to me
the easiest way - instead of issuing select statements, the generated
code looks like this:

for s in src.myapp.City.select():
d = dst.myapp.City()
d.id = s.id
d.name = s.name
d.save()

Using select statements, the code would have been much uglier, and
much harder to modify, I think.

Noam

On Jul 18, 4:36 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 7/17/07, Noam Raphael <[EMAIL PROTECTED]> wrote:
>
> > I would really like to hear what you think about it (especially if
> > it's good things...) Tell me!
>
> I haven't looked at the code, but I wonder about the dependency on
> multiple ORMs; the Django ORM cannot expose its own functionality on
> multiple databases at once, but this does not mean you cannot have
> connections open to multiple databases at once -- if you have the
> location and credentials for the second connection, you can simply
> drop down to the database adapter module, open a new connection
> independently of Django and use the standard Python DB API to execute
> any SQL you like.
>
> So unless you're relying heavily on ORM methods to access the data,
> instead of using simple SELECT statements, there's not any technical
> need to install another ORM package.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



Re: MEDIA_URL MEDIA_ROOT problem.

2007-07-18 Thread Dmitriy Sodrianov

Thanks to all for help.
With your suggestions and links I've found out how to serve static files
with Django.
Now everything works just fine!



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



Re: Blog engine

2007-07-18 Thread Kenneth Gonsalves


On 18-Jul-07, at 11:31 AM, James Bennett wrote:

> So I'm not necessarily convinced that there's a great need for a
> "standard" Django blog application; it would appease some folks, but I
> have a feeling that in the Django world a lot of people really would
> be happier, in the long run, writing their own app that does what they
> need

except for nesh's thumbnails, i have always found it quicker to roll  
my own things rather than spend time bolting on someone else's app to  
my app.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



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



Re: How to select objects referenced by another table ?

2007-07-18 Thread Jonathan Ballet

On 17 juil, 20:29, Tim Chase <[EMAIL PROTECTED]> wrote:
> Fortunately, Django's ORM lets you get at the underlying SQL via
> a call to .extra() where you can provide your own WHERE clause.
> This would look something like
>
>Article.objects.extra(where="""
>  app_article.id in (select article_id from app_photo)
>  """)
>
> You'd have to adjust for the various column-names and table-names
> accordingly.

Argl, I missed the 'extra' method in the documentation, 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django's User authentication

2007-07-18 Thread Przemek Gawronski

> is this use for the django admin features only? or I can use it for my
> own app? if yes, do I make it suitable for my application?

Sure you can, tak a look at:

http://www.djangoproject.com/documentation/authentication/#how-to-log-a-user-in

Przemek
-- 
AIKIDO TANREN DOJO  -   Poland - Warsaw - Mokotow - Ursynow - Natolin
info: http://www.tanren.pl/ phone: +4850151 email: [EMAIL PROTECTED]

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



Django's User authentication

2007-07-18 Thread james_027

hi,

is this use for the django admin features only? or I can use it for my
own app? if yes, do I make it suitable for my application?

Thanks
james


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



Re: session question

2007-07-18 Thread Russell Keith-Magee

On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> sorry for this stupid question ... does django's session only work
> when cookies are enabled?

Yes.

Yours,
Russ Magee %-)

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



Re: model managers of base classes

2007-07-18 Thread omat

Are you working on a specific application that uses model inheritance,
or testing the models I posted in the first message in this thread?
Also, previously, you've mentioned something that you will post to
another list. I didn't get that either.

I was using the model api. The error is:
Programming Error: relation "models_ortho" does not exist

Naturally, if you access a view function that has this error via http,
you will see Http500.


Thanks,
oMat



On 17 Temmuz, 19:58, Carl Karsten <[EMAIL PROTECTED]> wrote:
> Thanks - I think I bumped into that yesterday and got distracted trying to 
> setup
> a test on a win box (yay)
>
> I was getting a 500, you too right?
>
> Carl K
>
> omat wrote:
> > As I further test the pythonic inheritance for models, I figure out
> > that some django model magic does not work. For example, instead of
> > "get_object_or_404" you should do:
> > try:
> > object = ObjectClass.objects.get(pk=1)
> > except:
> > raise Http404
>
> > On 17 Temmuz, 18:01, omat <[EMAIL PROTECTED]> wrote:
> >> Sorry for the terminological confusion. The "model" is the
> >> django.db.models.Model() class, the "manager" is the
> >> django.db.models.Manager() class.
>
> >> Yes Nis, the behaviors you listed are the most important ones. It
> >> would be nice to have Meta, Admin, etc. inherited as well but, it is
> >> not a priority. I think, with that requirements, pure pythonic class
> >> inheritance is just fine. It gives a single table for each model,
> >> which sounds quite natural.
>
> >> For the side effect, as Carl has pointed out, as long as you don't put
> >> "ortho" in the settings.INSTALLED_APPS, it is not recognized by
> >> syncdb.
>
> >> Yours,
> >> oMat
>
> >> On 17 Temmuz, 17:14, Carl Karsten <[EMAIL PROTECTED]> wrote:
>
> >>> Nis Jørgensen wrote:
>  omat skrev:
> > Thanks for the pointer, Nis.
> > Model inheritance made my models so much DRYer that it will be hard to
> > give up, at least psychologically...
> > And, except for the managers, it worked just as I would expect, and
> > for the managers, it was easy to patch.
>  Just to make sure I understand, your expected behavior is
>  - Each model gets a db table which include fields from its ancestors
>  - Managers and (other) methods are inherited as if they were defined on
>  the subclass
>  - There is no common interface for subclasses of a model class.
>  Correct?
>  I would perhaps call this "class templating" rather than "subclassing",
>  but I can definitely see its usefulness.
> >>> I think the name problem stems from "model" not being well defined, or 
> >>> notr
> >>> properly used.  Is the model the class, the persistence implemented in 
> >>> the db,
> >>>   the shape of the data...?
> >>> I agree that what is bing described here is very different than some of 
> >>> the
> >>> other discussions that use the same terms.  which makes it very 
> >>> confusing.  (the
> >>> other discussions seem to focus around a separate table for each level of 
> >>> subclass.)
> >>> I am currently trying out what is discussed in this thread, and figured 
> >>> out the
> >>> same hack: db_table = 'message' - Some time this week I hope to have 
> >>> things
> >>> working well enough to post the whole app 
> >>> inhttp://groups.google.com/group/django-hotclub
>  Note that you get the probably undesired sideeffect of defining the
>  Ortho class as a model - which may cause some confusion if people use
>  syncdb and friends, and probably in other cases as well.
> >>> So far syncdb has not found my abstract class. I have it in a separate 
> >>> dir not
> >>> referenced by INSTALLED_APPS.  guessing that is the trick, but I am not 
> >>> 100%
> >>> sure how syncdb finds classes.
> >>> Carl K


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



Re: session question

2007-07-18 Thread Malcolm Tredinnick

On Wed, 2007-07-18 at 06:51 +, james_027 wrote:
> hi,
> 
> sorry for this stupid question ... does django's session only work
> when cookies are enabled?

That is correct. See
http://www.djangoproject.com/documentation/sessions/#session-ids-in-urls
for the documentation on this.

Regards,
Malcolm

-- 
No one is listening until you make a mistake. 
http://www.pointy-stick.com/blog/


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



Re: Logging in a newly created user

2007-07-18 Thread Jonathan Buchanan

LaundroMat wrote:
> Hi,
> 
> When running this, I get a "NoneType has no attribute
> is_authenticated()" error, and I cannot understand why:
> 
> 1 new_user = User.objects.create_user(username, "your.email",
> password)
> 2 new_user.is_active = False
> 3 new_user.save()
> 4 user = authenticate(username = new_user.username, password =
> new_user.password) # See http://code.djangoproject.org/ticket/2656
> 5 if user.is_authenticated():   # The error is produced here.
> login(request, user)
> 
> Why does authenticate() in line 4 return a None object instead of a
> user?
> 
> Thanks for your help,
> 
> Mathieu

"If the password is invalid, authenticate() returns None" [1]

The password field in the User model contains "...a hash of, and 
metadata about, the password. (Django doesn't store the raw password.)" [2]

So authenticate is returning None because you're trying to login with a 
hashed version of the password, not the raw version. Try this instead:

 user = authenticate(username=username, password=password)

Look at the second code example under [1] for an example of how to do this.

Jonathan.

[1] 
http://www.djangoproject.com/documentation/authentication/#how-to-log-a-user-in

[2] http://www.djangoproject.com/documentation/authentication/#fields

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



session question

2007-07-18 Thread james_027

hi,

sorry for this stupid question ... does django's session only work
when cookies are enabled?

Thanks


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



Logging in a newly created user

2007-07-18 Thread LaundroMat

Hi,

When running this, I get a "NoneType has no attribute
is_authenticated()" error, and I cannot understand why:

1 new_user = User.objects.create_user(username, "your.email",
password)
2 new_user.is_active = False
3 new_user.save()
4 user = authenticate(username = new_user.username, password =
new_user.password) # See http://code.djangoproject.org/ticket/2656
5 if user.is_authenticated():   # The error is produced here.
login(request, user)

Why does authenticate() in line 4 return a None object instead of a
user?

Thanks for your help,

Mathieu


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



Re: Blog engine

2007-07-18 Thread [EMAIL PROTECTED]

I wrote a blogging system for myself that can be had through
subversion at this url: http://svn.karmazilla.net/hobby_projects/Djogg

I'm still looking for a good place to deploy my own instance, though.
I've kinda given up getting it to work in dreamhost.




On Jul 18, 8:01 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 7/18/07, Paulo <[EMAIL PROTECTED]> wrote:
>
> > No to mention a good blog app that people can standardize on would be
> > a nice alternative to Wordpress[1] and Simplelog[2]. Having one would
> > definitely be helpful in the "spreading the word about Django"
> > department.
>
> I'm not entirely disinterested since I've been working on rewriting my
> own blogging application to be released open source, but...
>
> I think part of the reason that there isn't a "standard" blog
> application built on Django is simply the fact that it's so easy --
> it's quite literally a couple dozen lines of code to get a simple blog
> application. A model for entries and a URLConf which routes to generic
> views are all the Python you need to write, and then the generic views
> and bundled applications in django.conrtrib -- admin, auth and
> comments -- will do the rest. And if you want something more, it's
> generally easier to be writing your own custom code from the start so
> you can tailor things exactly how you want them.
>
> Rails doesn't offer those sorts of components (from what I know of the
> development team's choices, it's largely a philosophical matter, much
> as we don't offer tight integration of a JavaScript toolkit), which
> means that it's easier and more efficient for Rails users to
> standardize on and contribute code to a single application which can
> implement all the necessary bits.
>
> So I'm not necessarily convinced that there's a great need for a
> "standard" Django blog application; it would appease some folks, but I
> have a feeling that in the Django world a lot of people really would
> be happier, in the long run, writing their own app that does what they
> need (trying to encourage that is one reason why I keep spinning off
> bits of code from my blog into standalone applications -- when I do
> eventually finish my rewrite and release everything, I'd like people
> to be able to pick and choose the bits they want).
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



Re: How can I run syncdb task without loading any initial_data fixtures?

2007-07-18 Thread Manoj Govindan

>
> Is this comparison something you have done personally? If so, can you

Yes. I wrote the same application in Rails before I moved to Django (I
have always liked Python ;))
While the tests themselves are not *identical* there were about the
same number of them.

> provide any benchmarking details? (including SQL traces, if possible -
> it would be interesting to know if the problem is Django's code, or
> the SQL that is generated)
>

I don't have any supporting benchmark information, but I will try to
come up with some.

Regards,
Manoj


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



Re: Date Problem

2007-07-18 Thread James Bennett

On 7/18/07, Nash <[EMAIL PROTECTED]> wrote:
> I am running django pre-0.97 on a linux box. the date command on linux
> and in python datetime.now() both give me the correct times. However,
> in one of my models, there is a datetime attribute 'created_on' with
> default=datetime.now(). The default value going is is not the same as
> that of datetime.now() (its 10 hours or so behind). Any ideas? Much
> thanks for your help!

Remove the parentheses, so that it's "default=datetime.now".

The important thing here is to understand the difference between
passing the *return value* of a function to be a default, and between
passing *the function itself* to be a default. What you want is to
pass the function as the default, because Django will recognize a
function object and call it repeatedly as needed to get values. But
what you're doing, by using the parentheses, is calling
"datetime.now()" at the time the model class is defined, and passing
its return value at that single moment to be the default.


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

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



Re: Blog engine

2007-07-18 Thread James Bennett

On 7/18/07, Paulo <[EMAIL PROTECTED]> wrote:
> No to mention a good blog app that people can standardize on would be
> a nice alternative to Wordpress[1] and Simplelog[2]. Having one would
> definitely be helpful in the "spreading the word about Django"
> department.

I'm not entirely disinterested since I've been working on rewriting my
own blogging application to be released open source, but...

I think part of the reason that there isn't a "standard" blog
application built on Django is simply the fact that it's so easy --
it's quite literally a couple dozen lines of code to get a simple blog
application. A model for entries and a URLConf which routes to generic
views are all the Python you need to write, and then the generic views
and bundled applications in django.conrtrib -- admin, auth and
comments -- will do the rest. And if you want something more, it's
generally easier to be writing your own custom code from the start so
you can tailor things exactly how you want them.

Rails doesn't offer those sorts of components (from what I know of the
development team's choices, it's largely a philosophical matter, much
as we don't offer tight integration of a JavaScript toolkit), which
means that it's easier and more efficient for Rails users to
standardize on and contribute code to a single application which can
implement all the necessary bits.

So I'm not necessarily convinced that there's a great need for a
"standard" Django blog application; it would appease some folks, but I
have a feeling that in the Django world a lot of people really would
be happier, in the long run, writing their own app that does what they
need (trying to encourage that is one reason why I keep spinning off
bits of code from my blog into standalone applications -- when I do
eventually finish my rewrite and release everything, I'd like people
to be able to pick and choose the bits they want).


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

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



Using Threadlocals: Error binding parameter 5 - probably unsupported type.

2007-07-18 Thread Michael Lake

Hi all

I am using ThreadLocals from 
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser

I am getting this error on submitting the form:
InterfaceError at /erun/10/1/
Error binding parameter 5 - probably unsupported type.

This is my model:

class Data(models.Model):
 date_added  = models.DateTimeField('Date added', editable=False)
 date_changed= models.DateTimeField('Date changed', editable=False)
 who = models.CharField('Who', maxlength='100', editable=False)

 def save(self):
 if not self.id:
 self.date_added = datetime.datetime.today()

 self.date_changed = datetime.datetime.today()
 self.who = threadlocals.get_current_user()

 return super(Data, self).save()

The Django users groups turns up a few posts about threadlocals but I can see 
anything like the problem that I have here.

-- 
Mike




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