cannot store images into file system using Imageupload

2009-07-23 Thread guptha

hi friends
I 'm facing a wried behavior of Imageupload
In Models.py
class Market(...)
   title_name=models.CharField(max_length=125)
   photo1  = models.ImageField(upload_to= 'img/marketplace/%Y/%m/
%d', null=True, blank=True)

In views.py
def postyour_adds(request):
if request.method=='POST':
form=MarketplaceForm(request.POST,request.FILES)
if form.is_valid():
postdict=request.POST.copy()
newmarket=form.save()
.
 .

In forms.py
class MarketplaceForm(forms.Form):
title_name = forms.CharField(max_length=125)
photo1 = forms.ImageField(widget=forms.FileInput
(),required=False)
# I tried with another way in vain
#photo1 = forms.Field(widget=forms.FileInput(),required=False)
  def save(self):
new_market =Marketplace.objects.create
(title_name=self.cleaned_data['title_name'],
 
photo1=self.cleaned_data['photo1'],
   return new_market


In html file
{% block content %}
 Enter your choice

  
  {{ form.as_table }}
  
  
  
{% endblock %}

Issue is that image names are stored in Database but when i search in
my file system I could not find the image .
when i repeat the same in admin site i could see the file name with
the path i specified in Models.py and the actual image file is present
in the specified location .
I'm not sure why this wried behavior when i upload images from the
user page .Why is that the image is not constructed in my file system
Your solution is very much appreciated
thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cross-referencing design question

2009-07-23 Thread Matthias Kestenholz

Hey,

On Fri, Jul 24, 2009 at 6:46 AM, Mike Dewhirst wrote:
>
> I'm new to Django and want to express a self-referencing design
> feature to link clients in the same table with each other. Django is
> currently objecting to this. Could you please point me to
> documentation which will let me figure it out?
>

See here:


You can pass a string instead of the class itself it the model is not
defined already.


> This is my models.py in a play project using Django from svn rev ...
>
> - - - - - - - - - - -
> from django.db import models
>
> def when():
>    return datetime.now()
>
> class Client(models.Model):
>    """ base class for everyone/thing """
>    surname = models.CharField(max_length=48, blank=False)
>    client_type = models.CharField(max_length=24, blank=False)
>    def __unicode__(self):
>        return self.client_type + ": " + self.surname
>
> class Membership(models.Model):
>    """ cross (xr) referencing and linking clients """
>    client_x = models.ForeignKey(Client)
>    client_r = models.ForeignKey(Client)
>    def __unicode__(self):
>        return str(self.client_x + " : " + str(self.client_r)
>

Is this your complete Membership model? Or do you have additional
fields there? If you've only got these two foreign keys, it might be
better to use a many to many field that references the same model (
ManyToManyField('self') )

Plus, you should use unicode(), not str() inside __unicode__ -- str()
will bail if client_type or surname contains non-ASCII-chars.


Matthias



> - - - - - - - - - - -
>
>
> >
>



-- 
Matthias Kestenholz
Konzept & Programmierung

FEINHEIT GmbH
Dienerstrasse 15
CH-8004 Zü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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: view/form with fields from multiple models

2009-07-23 Thread Matthias Kestenholz

On Fri, Jul 24, 2009 at 5:32 AM, sico wrote:
>
> Hi,
>
> I want to be able to edit fields from several different models on the
> same form/view.
>
> The models are related one-to-one... can they be defined as "Inline"
> forms in the admin system??  The documentation doesn't make any
> mention of using inline forms for anything except parent child
> relations so I'm thinking this may cause issues.
>
> Whats the best way to handle this in a custom view?  Do I just simply
> define forms for each model, pass them in separately to be displayed
> in the template and then validate and save them individually on
> saving?  The fields would need to be clearly distinguishable to which
> model they belong using a prefix which is something that formsets use
> to distinguish themselves

Yes, you'd do it this way. Forms (and formsets too) take a prefix
argument which you can use to differentiate between the forms.

I think you do not want to validate and save them individually though
(I'm sorry if I did not understand you), you probably do not want to
save anything until all forms have passed validation:

if request.method == 'POST':
# initialize forms with request.POST and prefix
if form1.is_valid() and form2.is_valid() and form3.is_valid():
# save the data from the individual forms
else:
# 

return render_to_response('template.html', {'form1': form, 'form2':
form, 'form3': form})


> (I actually want to be able to edit multiple records of these in a
> grid, but need to be able to edit one first!)

Then you'll want to look into formsets, and use their prefix parameter
too to make sure that the field names of different formsets don't
clash.


Matthias

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



Re: Database connection closed after each request?

2009-07-23 Thread Glenn Maynard

On Thu, Jul 23, 2009 at 11:36 PM, James Bennett  wrote:
> Meanwhile, the codebase stays much simpler and avoids some pitfalls
> with potential resource and state leaks.

All pgpool2 does to reset the session to avoid all of these pitfalls
is issue "ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT".
There's nothing complex about that.  (With that added, the
TransactionMiddleware change I mentioned earlier isn't needed,
either.)

I see no need for a complex connection pooling service.  You're making
this sound much more complicated than it is, resulting in people
needing to use configurations much more complicated than necessary.

-- 
Glenn Maynard

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



cross-referencing design question

2009-07-23 Thread Mike Dewhirst

I'm new to Django and want to express a self-referencing design
feature to link clients in the same table with each other. Django is
currently objecting to this. Could you please point me to
documentation which will let me figure it out?

This is my models.py in a play project using Django from svn rev ...

- - - - - - - - - - -
from django.db import models

def when():
return datetime.now()

class Client(models.Model):
""" base class for everyone/thing """
surname = models.CharField(max_length=48, blank=False)
client_type = models.CharField(max_length=24, blank=False)
def __unicode__(self):
return self.client_type + ": " + self.surname

class Membership(models.Model):
""" cross (xr) referencing and linking clients """
client_x = models.ForeignKey(Client)
client_r = models.ForeignKey(Client)
def __unicode__(self):
return str(self.client_x + " : " + str(self.client_r)

- - - - - - - - - - -


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



Re: Customizing a manytomany admin box

2009-07-23 Thread knicholes

Oh, sweet, thanks!  I read that a few times before I posted but I
couldn't get the inlines to work--  I was using the model with the
large field, the manytomany field, with the raw_id_fields=...  I had
to use the INLINE model to display it.  Thanks again!

On Jul 23, 12:45 pm, Rajesh D  wrote:
> On Jul 22, 11:17 pm, knicholes  wrote:
>
> > Hey,
>
> > I used the admin to display a manytomany field (that had over 60,000
> > entries) and used raw_id_field = ('hugeDatabaseField').  This took
> > care of the problem, but I wanted to be able to sort my manytomany
> > field, so I added an intermediary class to handle the sort order.
> > Once I added the
>
> > whatever = models.ManyToManyField(Class,
> > through='OrderableIntermediaryClass')
>
> > the admin screen stopped displaying the manytomany field (I think a
> > selection field) all together.
>
> This behaviour and its solution are documented here:
>
> http://docs.djangoproject.com/en/dev//ref/contrib/admin/#working-with...
>
> -RD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Extending AdminSite

2009-07-23 Thread Dr.Hamza Mousa
Try those :

*Concept ,Ideas and Basics :*

http://www.theotherblog.com/Articles/2009/06/02/extending-the-django-admin-interface/

Tom explain the main concept .

*Slideshow ( reference ) :*and this slideshow is outstanding as well :

http://www.slideshare.net/lincolnloop/customizing-the-django-admin

*CSS and Template *: and This is how to extend the style and add your custom
extra css :

http://blog.montylounge.com/2009/jul/5/customizing-django-admin-branding/

*Doing more with the Django admin*

http://www.ibm.com/developerworks/opensource/library/os-django-admin/index.html

Also Django`s Docs are pretty cool , though no enough examples so you may
check some other projects as Django-CMS . to see what is done and how they
made it !

P.s : if you stuck at some point , don't worry shortly you'll get your way
out , its Django :)

Regards .

On Fri, Jul 24, 2009 at 2:14 AM, Jan-Herbert Damm  wrote:

>
> Hi,
>
> Daniel Roseman wrote:
> > > ... http://www.webmonkey.com/tutorial/...
>
> > This is a very misleading tutorial, and I wouldn't recommend it.
>
> > You could make this work, though. ...
> Not being the OP i still want to thank you for these hints, Daniel. Makes a
> beginner catch a glimpse ...
>
> Could you recommend a tutorial (in addition to the official one), that
> teaches
> more of these basics?
>
> jan
>
> >
>


-- 
Hamza E.e Mousa

www.neoxero.com
www.goomedic.com
www.medpeek.com
www.freewaydesign.com

http://www.twitter.com/hamzamusa
http://twitter.com/goomedic

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



Re: Database connection closed after each request?

2009-07-23 Thread James Bennett

On Thu, Jul 23, 2009 at 9:50 PM, Glenn Maynard wrote:
> In this case, that's a terrible-performance-by-default approach.
> (It's also not a default, but the only behavior, but I'll probably
> submit a patch to add a setting for this if I don't hit any major
> problems.)

Please do a bit more research and reflection on the topic before you
start submitting patches, because this isn't quite what you're making
it out to be.

In the case of a fairly low-traffic site, you're not going to notice
any real performance difference (since you're not doing enough traffic
for connection overhead to add up). In the case of a high-traffic
site, you almost certainly want some sort of connection-management
utility (like pgpool) regardless of what Django does, in which case it
becomes rather moot (since what you're doing is getting connection
handles from pgpool or something similar).

Meanwhile, the codebase stays much simpler and avoids some pitfalls
with potential resource and state leaks.

(and, in general, I don't believe that connection-management utilities
belong in an ORM; keeping them in a different part of the stack
drastically increases flexibility in precisely the cases where you
need it most)


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



view/form with fields from multiple models

2009-07-23 Thread sico

Hi,

I want to be able to edit fields from several different models on the
same form/view.

The models are related one-to-one... can they be defined as "Inline"
forms in the admin system??  The documentation doesn't make any
mention of using inline forms for anything except parent child
relations so I'm thinking this may cause issues.

Whats the best way to handle this in a custom view?  Do I just simply
define forms for each model, pass them in separately to be displayed
in the template and then validate and save them individually on
saving?  The fields would need to be clearly distinguishable to which
model they belong using a prefix which is something that formsets use
to distinguish themselves

so... what is the best way to allow editing of fields from multiple
one-to-one models at once.

thanks!
Simon

p.s.
(I actually want to be able to edit multiple records of these in a
grid, but need to be able to edit one first!)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database connection closed after each request?

2009-07-23 Thread Glenn Maynard

On Thu, Jul 23, 2009 at 10:02 PM, Carlos A. Carnero
Delgado wrote:
> On Thu, Jul 23, 2009 at 5:24 PM, Glenn Maynard wrote:
>> Why is each thread's database connection closed after each request?
>
> I believe that this is related to Django's shared-nothing-by-default approach.

In this case, that's a terrible-performance-by-default approach.
(It's also not a default, but the only behavior, but I'll probably
submit a patch to add a setting for this if I don't hit any major
problems.)

I can think of obscure cases where this would matter--if something
changes a per-connection setting, like changing the schema search
path, and doesn't put it back--but for most people this is just an
unnecessary chunk of overhead.  (I wonder if Postgres has a way to
quickly reset the connection state, without having to tear it down
completely.)

The only other change I've had to make so far is making
TransactionMiddleware always commit or rollback, not just on is_dirty,
so it doesn't leave read locks held after a request.  (Of course, that
sometimes adds an SQL COMMIT where there wasn't one before, but I'll
take a 500us per request overhead over 100ms in a heartbeat.)

-- 
Glenn Maynard

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



Re: forms with django and extjs 3.0.0

2009-07-23 Thread Russell Keith-Magee

On Thu, Jul 23, 2009 at 5:43 PM, Emily
Rodgers wrote:
>
> Hi all,
>
> I am currently working on some web apps that use django for the back
> end, and extjs for the front end (using JSON to pass data between the
> two).
>
> I am getting to the point where I am going to have to start doing some
> form integration. Has anyone done this lately (with the latest version
> of extjs)? If so, how did you go about it? I have looked on the web,
> but most of the extjs / modelform examples are using either an old
> version of django or an old version of extjs, both of which have
> undergone fairly backwards incompatible changes in recent revisions. I
> just thought that I would ask here before spending lots of time trying
> to figure it out from scratch.

I can't speak for ExtJS, but Django hasn't had any backwards
incompatible changes in almost a year - and the areas where you are
delving here (i.e., view and forms handling) have been stable for much
longer.

So - you shouldn't have any problems (from a Django point of view)
with any tutorial that is a year old.

I can't offer much advice than that, though. Firstly, I'm not that
familar with ExtJS; secondly, there isn't that much to explain.
 * You write a Django view.
 * That view serves a HTML page.
 * The HTML page contains some javascript.
 * The javascript makes a call on another Django view.
 * The second Django view serves JSON, or some other raw data format.
 * The javascript running on the first page uses that data to modify
in-situ the original page.

And boom, you have an AJAX website. To be sure, there is some
complexity in getting your Javascript working - but that complexity is
almost 100% a function of your JS toolkit of choice. From Django's
perspective, all you ever do is serve individual pages - either HTML
for human consumption, or JSON/some other format for automated
Javascript consumption.

Yours,
Russ Magee %-)

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



Re: Database connection closed after each request?

2009-07-23 Thread Carlos A. Carnero Delgado

Hi,

On Thu, Jul 23, 2009 at 5:24 PM, Glenn Maynard wrote:
> Why is each thread's database connection closed after each request?

I believe that this is related to Django's shared-nothing-by-default approach.

HTH,
Carlos.

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



Re: PostgreSQL Stored Procedure in ordinary Django query expression?

2009-07-23 Thread Russell Keith-Magee

On Thu, Jul 23, 2009 at 11:55 PM, Adam Seering wrote:
>
> Hey folks,
>        I have a PostgreSQL stored procedure that does some fairly complex
> logic to query/filter a particular table (though it ultimately does
> return rows straight from that table).  I'm trying to call this stored
> procedure from within Django, and execute additional filters/etc on the
> procedure:
>
> MyModel.do_my_stored_procedure('proc', args).filter(mymodelfk__foo=bar)
>
> (or the like.)  Anyone have any pointers on how to best do this?  Is
> there, by any chance, native support for this in Django 1.1 that I just
> haven't found yet?
>
>        There's an existing implementation that worked decently with Django 1.0
> (djangosnippets.org #272).  However, it works by generating a normal
> query through an ordinary QuerySet and doing string
> matching/substitution to insert the function call.  I'd like to do
> something a bit cleaner, but I don't yet understand Django's internals
> well enough to hack them this much...  Any ideas?

There isn't a simple "run stored procedure" entry point in the Django
ORM. That said, it may be possible to do what you want, depending on
exactly how you want to use the stored procedure.

For example, if your stored procedure is a column-modifying function,
you can use a custom field definition to mutate the SQL - if you
define the get_db_prep_value(), you can modify the way a column is
rendered in SQL. DateFields give an example of how this is done (since
they need to convert Python Dates to SQL dates).

There are also a bunch of tricks, of varying degrees of complexity,
that can be played by defining a custom models.Query or
models.sql.Query class. The Oracle backend and contrib.gis both use
this technique to expose Oracle-specific and GIS specific query
features. These are some pretty big and hairy blocks of code to wrap
your head around; if you want specifics, ask a specific question and
I'll try to help.

The first step would be to state the SQL that you want to run as an
end goal - once I've got a clear idea of what you want to spit out, I
might be able to point you at the right places to look for hints.

Also - keep in mind that in some cases, the best solution is just
"don't use the ORM". Django's ORM isn't designed to be homomorphic
with SQL - it's designed to make simple and common object queries
easy. We have specifically avoided adding obvious SQL-like features to
Django's ORM, because at the end of the day, we're not trying to
replace SQL - we're just trying to provide a convenient way to express
simple queries. It is fully expected that you will fall back to just
calling raw SQL for complex cases.

Yours,
Russ Magee %-)

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



Re: ImageField questions

2009-07-23 Thread Joshua Russo
On Thu, Jul 23, 2009 at 9:31 PM, Rusty Greer  wrote:

>
> how do i create a query on the size of an image?
>
> for example:
> class Image(models.Model):
>
>image = models.ImageField(upload_to=upload_to('images'), db_index=True)
>
>
> if i try something like:
>
>for image in Image.objects.filter(image__height_field__gte=100):
>  # do something
>
> i get the following error:
>
> django.core.exceptions.FieldError: Join on field 'image' not permitted.


The filters are translated into SQL for the database and the database
doesn't have a mechanism for reading the image properties. As far as the db
is concerned it's just another binary field. What I would recommend is to
create columns for extra information like height and width. Then you can
override your Image model's save method and extract information and save it
into the column automatically.

class Image(models.Model):
   image = models.ImageField(upload_to=upload_to('images'), db_index=True)
   height = models.IntegerField()
   width = models.IntegerField()

   def save(self, force_insert=False, force_update=False):
# The following is sudo code, I have no experience with image
objects
self.height = self.image.height
self.width = self.image.width
super(Image, self).save(force_insert, force_update) # Call the
"real" save() method.
*
*
*You can read more about models and all the cool stuff  you can do with them
here:
http://docs.djangoproject.com/en/dev/topics/db/models/#topics-db-models*

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



problem with forms, ForeignKey, get_or_create

2009-07-23 Thread Nail

Hello, developers!

Please help me with one problem. I spent 2 days attempting to solve
it. And now i have some solution, but i don't like it.

My application manages music tracks.
There is models: Artist, Album, Track.
Simply:

class Artist:
  name = CharField()

class Album:
  title = CharField()
  artist = ForeignKey(Artist)

class Track:
  title = CharField()
  album = ForeignKey(Album)
  artist = ForeignKey(Artist)

class FeaturedLink:
  artist = ForeignKey(Artist)
  track = ForeignKey(Track)
  text = CharField()

Some explanations: artist may have several tracks, and track may
belong to several artists - one primary and some featured (e.g. 50
cents feat. Justin). text field in FeaturedLink contains "feat.",
"remix by" etc.

User interface needs to be very simple. For example if user creates
some album, he enters name of artist(ajax name suggestion helps him),
title and presses save. If artist with this name doesn't exist, it
must be created.
This is not a problem. I create AlbumForm(ModelForm), with artist
field excluded, define custom char field artist_name. __init__
provides Initial data for artist_name from instance.artist.name. save
() method gets artist from existing or creates new
(Artist.objects.get_or_create(name=artist_name)) and fills
instance.artist.

Problem is in TrackForm. Primary artist is being filled in without
problems. But featuredlink_set uses InlineFormSet to be able to edit
any number of featured links in one form. Inline form set uses default
ModelForm instances for each model instance. So there will be
ChoiceField for artist field in FeaturedLink. But i need simple char
field with behavior as in album form. But i don't find a way to do
this. Changing a form for InlineFormSet doesn't help, formset never
calls save() method of form, it saves objects by oneself. Overriding
save method of inline form set is very complex. It handles to many
tasks.

And what a solution i found: create custom form field, that will
accept char data from request data and clean() it to artist id. But i
think this is not a true solution, because such field clean will
change database in validation stage.

Please, help.

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



Re: run django on multicore machine

2009-07-23 Thread Graham Dumpleton



On Jul 24, 8:53 am, James Matthews  wrote:
> Django depends more on the python interpreter. If it really matters
> recompile python to take advantage of your machine. I am sure you will see
> some nice improvements
>
> On Fri, Jul 24, 2009 at 12:08 AM, Some Guy  wrote:
>
> > Not sure about my answer but
> > I think it matters more that the webserver you are using can take
> > advantage of multicore (i.e. mod_python instances running in their own
> > thread.)
>
> > On Jul 23, 10:26 am, ihome  wrote:
> > > Has django been designed to take advantage of multicore machine? Is
> > > there a way to boost the performance of a django server on multicore
> > > machine? Any thoughts? Thanks.

Recompiling Python is not the answer. Use of a multi process web
server is the answer, but the comment about mod_python isn't strictly
accurate.

FWIW, read:

  http://blog.dscpl.com.au/2007/09/parallel-python-discussion-and-modwsgi.html
  http://blog.dscpl.com.au/2009/03/python-interpreter-is-not-created-for.html
  http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

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



Re: Extending AdminSite

2009-07-23 Thread Jan-Herbert Damm

Hi,

Daniel Roseman wrote:
> > ... http://www.webmonkey.com/tutorial/...

> This is a very misleading tutorial, and I wouldn't recommend it.
 
> You could make this work, though. ...
Not being the OP i still want to thank you for these hints, Daniel. Makes a
beginner catch a glimpse ... 

Could you recommend a tutorial (in addition to the official one), that teaches
more of these basics? 

jan

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



Re: run django on multicore machine

2009-07-23 Thread James Matthews
Django depends more on the python interpreter. If it really matters
recompile python to take advantage of your machine. I am sure you will see
some nice improvements

On Fri, Jul 24, 2009 at 12:08 AM, Some Guy  wrote:

>
> Not sure about my answer but
> I think it matters more that the webserver you are using can take
> advantage of multicore (i.e. mod_python instances running in their own
> thread.)
>
> On Jul 23, 10:26 am, ihome  wrote:
> > Has django been designed to take advantage of multicore machine? Is
> > there a way to boost the performance of a django server on multicore
> > machine? Any thoughts? Thanks.
> >
>


-- 
http://www.goldwatches.com

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



Re: replicating database changes from one postgres DB to another

2009-07-23 Thread Steve Howell


On Jul 21, 3:18 pm, Wayne Koorts  wrote:
> Hi Steve,
>
> > We have an application where we periodically import data from an
> > external vendor, and the process is mostly automated, but we need to
> > review the data before having it go live.
>
> > We were considering an option where we would run processes on another
> > database, do the manual validation, and then replicate the DB changes
> > to our production database (which would have the same schema).
>
> I do exactly this with one of my sites.  This is my scenario:
>
> 1.  Main database table gets updated automatically every night (this
> is a kind of data that can be automatically refreshed, but that should
> be beside the point for this discussion).  The data first goes into a
> pending table on my dev server, which is exactly the same as the main
> table, with "_pending" appended to the name.
> 2.  The data is then dumped to a file using "psql" and sent via FTP up
> to an equivalent pending table on the production server (via Python
> script in my dev environment).  There is a Python script set up on the
> server to monitor a specific folder for a specific dump file name at
> regular intervals, and if it finds it, imports it into the table also
> with "psql", then deletes the dump file.
> 3.  The data sits in the pending table on the production server until
> I approve it via an admin interface which I have set up Django.
> Basically there is a "DB Admin" area on the site which I have set up
> which shows me four chunks of the data at various points in the table,
> 100 at the start, 100 at 1/4 through, 100 at 3/4 through and then 100
> at the end.  It also shows me the total number of records so that I
> can do a quick visual integrity check.
> 4.  There are "approve" and "reject" buttons at the bottom of the
> approval page.  If I click "approve" it moves the current live table
> data into a backup table (the db admin area also has a restore
> function) and moves the pending data into the live table using a raw
> nested SQL SELECT statement via Django and then empties the pending
> table.  If I click "reject" it just empties the pending table.
>
> These same general steps can be adjusted to accomodate more tables
> etc. as per your requirements.
>

Wayne,

Thanks for your response.

The way that you are doing it was definitely an option we were
considering, but we have just enough tables that I think scaling up
the "pending_" methodology that you describe below would not
really be practical.

The overall process will be very similar, though.  We'll do the import
on some sort of staging database and have an application with approve/
reject buttons to validate the new data is quality for production.


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



ImageField questions

2009-07-23 Thread Rusty Greer

how do i create a query on the size of an image?

for example:
class Image(models.Model):

image = models.ImageField(upload_to=upload_to('images'), db_index=True)


if i try something like:

for image in Image.objects.filter(image__height_field__gte=100):
  # do something

i get the following error:

django.core.exceptions.FieldError: Join on field 'image' not permitted.


am i just missing something?

thanks.

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



Please help me design Model

2009-07-23 Thread urosh

Hi.

I want to create phone book. I want that this phone book list will be
ordered by number of dialing this number. I think of using two tables
one with phone numbers and one for phone dialing statistics (how many
times user dialed number). Each user has his own ordering rule based
on his user-name. I will populate this phonebook statistics with other
function regular running.

This is what I have so far.

class phonebook(models.Model):
person_company = models.CharField(blank=True,max_length=30)
address = models.CharField(blank=True,max_length=50)
e_mail = models.EmailField(blank=True,max_length=70)
number = models.CharField(unique=True,max_length=15)
dialed = models.ForeignKey('phonebook_stat')
def __unicode__(self):
return self.person_company

class phonebook_stat(models.Model):
username = models.CharField(max_length=30)
number = models.CharField(max_length=15)
dialed_times = models.IntegerField(max_length=10)
class Admin:
pass
in admin.py
class PhonebookAdmin(admin.ModelAdmin):
def queryset(self, request):
qs = super(PhonebookAdmin, self).queryset(request)
global caller_id
caller_id = str(request.user)
return qs
list_per_page = 20
search_fields = ('person_company','number')
list_display = ['person_company','number','address',]
fields = ('person_company','number','address','e_mail',)
#ordering = (order_common_used,)

THANK YOU in advance.

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



Re: Customizing context by opening up BoundField, is it ok?

2009-07-23 Thread Joshua Russo

On Jul 23, 12:41 am, Russell Keith-Magee 
wrote:
> The decision about splitting this into more than one view is
> approaching an 'inmates running the asylum' issue [1]. Work out what
> UI will work for your users. Then work out how to make that
> implementation work. Don't let the implementation drive the UI.
>
> [1]http://www.amazon.com/Inmates-Are-Running-Asylum/dp/0672316498

Oh ya, I bought the book too. :o) I think I have a tendency to find
myself in this trap.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Customizing context by opening up BoundField, is it ok?

2009-07-23 Thread Joshua Russo

On Jul 23, 12:41 am, Russell Keith-Magee 
wrote:
> This sounds like you are on the right track. My only other suggestion
> is that it might be worth looking into using FormSets to simplify the
> logic for displaying multiple Payment forms on the page.

Thanks for your input. Just to give you an update. I ended up not
using FormSets. They seem to be more geared toward a single save
button for the page and I wanted to force them to save each payment
individually. Tthe feedback is quick and it comes across as the line
just changing from editable to not. Though it was good to review the
FormSets.

I think I'm just about ready for testing. I just have a few for
strange bugs to work out, like why the errors output isn't being
wrapped in a ul tag. I think I can see the light. :o)

Thanks again for your 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: PostgreSQL Stored Procedure in ordinary Django query expression?

2009-07-23 Thread Glenn Maynard

On Thu, Jul 23, 2009 at 11:55 AM, Adam Seering wrote:
>        I have a PostgreSQL stored procedure that does some fairly complex
> logic to query/filter a particular table (though it ultimately does
> return rows straight from that table).  I'm trying to call this stored
> procedure from within Django, and execute additional filters/etc on the
> procedure:
>
> MyModel.do_my_stored_procedure('proc', args).filter(mymodelfk__foo=bar)
>
> (or the like.)  Anyone have any pointers on how to best do this?  Is
> there, by any chance, native support for this in Django 1.1 that I just
> haven't found yet?

I'd like to know this, too.  It'd be an excellent way to execute
complex SQL without having to drop out of the ORM entirely: hide the
logic in a function, giving it a simple interface that the ORM can
easily digest without knowing the details.

-- 
Glenn Maynard

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



Re: Extending AdminSite

2009-07-23 Thread Daniel Roseman

On Jul 23, 9:17 pm, James  wrote:
> Based some tutorials and code examples, I'm attempting to modify my
> admin page by adding "admin.py" in my project directory. However, the
> changes don't seem to make a lick of difference.
>
> This (http://www.webmonkey.com/tutorial/
> Install_Django_and_Build_Your_First_App#Check_your_head) implies that,
> by creating "admin.py" in the "djangoblog" directory (if the tutorial
> is followed verbatim) with the listed code, the "Auth" and "Sites"
> sections of the administration page would not show up. I also take
> that to mean, based on other documentation I've read, that these, and
> other models, can be rearranged in the admin interface as desired.
>
> However, I ran across this (http://docs.djangoproject.com/en/dev/ref/
> contrib/admin/#adminsite-objects) that makes me believe such ideas are
> in Django 1.1, rather than 1.0.2, which I am currently running. Is
> this correct?
>
> If the modification should be done in templates, let me know; I do
> think admin.py is the appropriate place for it, but I'm new to the
> community.
>
> Thank you,
>
> James

This is a very misleading tutorial, and I wouldn't recommend it.
However if you look at the bottom of the page you reference, it says
it was last updated last September - just at the time of the release
of Django 1.0. So nothing in it is intended only for version 1.1.

I don't know why they assume that putting a blank AdminSite in the
project folder would make other admin sections disappear (I presume
this i the bit that isn't making a 'lick of difference' - the code for
the blog app customisations seems correct). There's no reason why the
code as given would work at all, especially the completely pointless
empty subclassing of AdminSite.

You could make this work, though. The missing piece is linking up the /
admin/ url with the new AdminSite object. You'd need to do this in
your urls.py - at the top, add
from djangodblog.admin import site as mysite
and in the list of urls change 'admin.site.root' to 'mysite.root'.

However, this won't allow you to change the ordering of applications
on that page. This isn't easily customisable.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Database connection closed after each request?

2009-07-23 Thread Glenn Maynard

Why is each thread's database connection closed after each request?

Opening a database connection is expensive; it's taking 150ms.  Even
10ms would be far too much, for a request that otherwise takes only
30ms.  Django threads are reused in FastCGI, and database connections
are reusable; why do threads not reuse their database connections?

Disabling django.db.close_connection fixes this, bringing a trivial
request from 170ms to 35ms after the first.

150ms to localhost also seems grossly expensive, and I'm still
investigating that.  However, even if I bring it down to 10ms, that's
still spending 25% of the time for the request on something that
shouldn't be necessary at all.

-- 
Glenn Maynard

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



Re: urls.py import() usage?

2009-07-23 Thread Joshua Russo
On Thu, Jul 23, 2009 at 3:09 PM, Matthias Kestenholz <
matthias.kestenh...@gmail.com> wrote:
>
> Well, there is a big difference between the two. include() takes the
> python path to an URLconf file while the other form takes a view.
>
> You should read the documentation on this page if you haven't done this
> already:
> http://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-urls


Gotcha, Thanks. RTFM

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



Re: urls.py import() usage?

2009-07-23 Thread Joshua Russo
there should have been a comma after the word not.

On Thu, Jul 23, 2009 at 2:40 PM, Saketh wrote:

> Joshua, could you clarify what you mean by "not in the url pattern list?"
>
> Sincerely,
> Saketh
>
> --
> Saketh Bhamidipati
> Harvard College '11
> http://people.fas.harvard.edu/~svbhamid/
>
>
>
> On Thu, Jul 23, 2009 at 11:33 AM, Joshua Russo wrote:
>
>> On Thu, Jul 23, 2009 at 2:18 PM, Matthias Kestenholz <
>> matthias.kestenh...@gmail.com> wrote:
>>
>>>
>>> On Thu, Jul 23, 2009 at 4:51 PM, Joshua Russo
>>> wrote:
>>> >
>>> > Is there any difference between using import() versus not in the url
>>> > pattern list?
>>> >(r'^accounts/login/$', 'django.contrib.auth.views.login'),
>>> >(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>>
>>> Are you asking about import or include? Where would your imports be?
>>
>>
>> Sorry, I meant include.
>>
>>
>
> >
>

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



Re: run django on multicore machine

2009-07-23 Thread Some Guy

Not sure about my answer but
I think it matters more that the webserver you are using can take
advantage of multicore (i.e. mod_python instances running in their own
thread.)

On Jul 23, 10:26 am, ihome  wrote:
> Has django been designed to take advantage of multicore machine? Is
> there a way to boost the performance of a django server on multicore
> machine? Any thoughts? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Extending AdminSite

2009-07-23 Thread James

Based some tutorials and code examples, I'm attempting to modify my
admin page by adding "admin.py" in my project directory. However, the
changes don't seem to make a lick of difference.

This (http://www.webmonkey.com/tutorial/
Install_Django_and_Build_Your_First_App#Check_your_head) implies that,
by creating "admin.py" in the "djangoblog" directory (if the tutorial
is followed verbatim) with the listed code, the "Auth" and "Sites"
sections of the administration page would not show up. I also take
that to mean, based on other documentation I've read, that these, and
other models, can be rearranged in the admin interface as desired.

However, I ran across this (http://docs.djangoproject.com/en/dev/ref/
contrib/admin/#adminsite-objects) that makes me believe such ideas are
in Django 1.1, rather than 1.0.2, which I am currently running. Is
this correct?

If the modification should be done in templates, let me know; I do
think admin.py is the appropriate place for it, but I'm new to the
community.

Thank you,

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



Proxy meta ordering in admin

2009-07-23 Thread fgasperino

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

class MyProxy (MyModel):
  class Meta:
proxy = True
ordering = ["name"]

class MyAdmin (admin.ModelAdmin):
  pass

admin.site.register(MyProxy, MyAdmin)

The above example does not seem to honor the ordering field within the
admin pages (svn rev: 11298). If the ordering is placed into the
MyModel or MyAdmin, it works as expected.

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



Re: Customizing a manytomany admin box

2009-07-23 Thread Rajesh D



On Jul 22, 11:17 pm, knicholes  wrote:
> Hey,
>
> I used the admin to display a manytomany field (that had over 60,000
> entries) and used raw_id_field = ('hugeDatabaseField').  This took
> care of the problem, but I wanted to be able to sort my manytomany
> field, so I added an intermediary class to handle the sort order.
> Once I added the
>
> whatever = models.ManyToManyField(Class,
> through='OrderableIntermediaryClass')
>
> the admin screen stopped displaying the manytomany field (I think a
> selection field) all together.

This behaviour and its solution are documented here:

http://docs.djangoproject.com/en/dev//ref/contrib/admin/#working-with-many-to-many-intermediary-models

-RD

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



Re: How I run background processes

2009-07-23 Thread Rajesh D



On Jul 21, 9:10 am, Philippe Josse  wrote:
> Hi there,
>
> I would like to have your feedback on the way I am running daemon scripts
> for my Django/ Python app. I know this is definitely not the "one best way",
> but this is a solution I came up with that seemed simple to implement. (I am
> a real newbie!)
>
> My constraints:
>  - getting a few processs constantly repeating themselves
>  - getting an email notification if one of the process crashes
>
> I set up a cron job that is launching a "daemon manager" script every
> minute. This script is querying a PostGreSQL database to retrieve boolean
> values associated to the state of my background processes (running / not
> running).  If the database indicates the process is not running, then the
> cron script launches it.
>
> Boolean values are updated by each process when it starts and finishes.
> Currently, it seems to work fine - but my background processes are very
> quick to execute. When my user base will grow, they may last longer and it
> will be essential that background processes do not run concurrently.
>
> Would that solution work? I was worried by potential caching issues with the
> database that may prevent my cron script to retrieve the latest boolean
> value. Is there any real risk?

What happens if your process starts but crashes before it can tell the
DB that it has crashed/finished? Your monitor job will think the
process is still active.

Here's another way that doesn't involve the DB:

When your process starts, have it bind to a known TCP port using the
Python socket[1] library. If the bind call fails, it means an instance
of your process is still running so just exit out of the current
instance. If the bind call succeeds, assume that no other instance is
active so continue running the rest of the process. Even if your
process crashes without explicitly releasing the socket, the OS will
unbind it for you.

[1] http://docs.python.org/library/socket.html

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



Re: Django 1.0.2 ordering fireign keys

2009-07-23 Thread Rajesh D

> Lets say I have two models Street and House, related by a foreign key
> thus:
>
> class House(models.Model):
>     house_number =  models.CharField(max_length=16)
>     street = models.ForeignKey(Street)
>
> In the admin area, the Change House page displays a list widget by
> which to select the street.  I need them to be listed in alphabetical
> order.
>
> How should a newbie cause this to happen?

Add the appropriate 'ordering' Meta field to your Street model.

http://docs.djangoproject.com/en/dev//ref/models/options/#ordering

-RD

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



Re: mysql setting eror

2009-07-23 Thread Saketh
Looks like I learned something too. :)

Sincerely,
Saketh

On Thu, Jul 23, 2009 at 1:32 PM, Sonal Breed  wrote:

>
> Saketh,
> I got the problem, it was the quotes around username and localhost,
> The command for mysql should be
> GRANT ALL ON django_db.* TO sonal@'ocalhost IDENTIFIED BY
> 'sonal';
>
>
> http://www.webdevelopersnotes.com/tutorials/sql/mysql_primer_creating_a_database.php3
>
> Thanks,
> Sonal.
>
> On Jul 23, 10:03 am, Sonal Breed  wrote:
> > Hello saketh,
> > The name of the db is mygodb, i just happened to give the example of
> > Django_db in mysql console.
> > I am still getting the error. Does anybody know the solution to this??
> >
> > Any help will be really appreciated,
> > Sonal.
> >
> > On Jul 23, 9:47 am, Sonal Breed  wrote:
> >
> > > Yes , the name of the database is mygodb..
> >
> > > On Jul 23, 9:45 am, Saketh  wrote:
> >
> > > > You seem to be accessing 'mygodb' from your django config, for which
> > > > so...@localhost might not have permissions. Is this the case?
> >
> > > > Sincerely,
> > > > Saketh
> >
> > > > On Thu, Jul 23, 2009 at 12:42 PM, Sonal Breed 
> wrote:
> >
> > > > > Hi all,
> >
> > > > > I am migrating my project from sqlite3 to mysql.
> > > > > Installed mysql and mysqldb on  my machine and executed following:
> >
> > > > >  mysql -u root -p
> > > > > Enter password:
> > > > > Welcome to the MySQL monitor.  Commands end with ; or \g.
> > > > > Your MySQL connection id is 1
> > > > > Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)
> >
> > > > > Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
> >
> > > > > mysql> CREATE DATABASE django_db;
> > > > > Query OK, 1 row affected (0.01 sec)
> >
> > > > > mysql> GRANT ALL ON django_db.* TO 'sonal'@'localhost' IDENTIFIED
> BY
> > > > > 'sonal';
> > > > > Query OK, 0 rows affected (0.03 sec)
> >
> > > > > mysql> quit
> > > > > Bye
> >
> > > > > In settings.py
> > > > > DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
> > > > > 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
> > > > > DATABASE_NAME = 'mygodb' # Or path to database file if
> > > > > using sqlite3.
> > > > > DATABASE_USER = 'sonal ' # Not used with sqlite3.
> > > > > DATABASE_PASSWORD = 'sonal' # Not used with sqlite3.
> > > > > DATABASE_HOST = '' # Set to empty string for localhost.
> > > > > Not used with sqlite3.
> > > > > DATABASE_PORT = '' # Set to empty string for default.
> Not
> > > > > used with sqlite3.
> >
> > > > > user sonal is already created in mysql with password sonal.
> >
> > > > > And the error message is
> >
> > > > > /var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
> > > > > DeprecationWarning: the sets module is deprecated
> > > > >  from sets import ImmutableSet
> > > > > ...
> > > > > ...
> > > > > _mysql_exceptions.OperationalError: (1045, "Access denied for user
> > > > > 'sonal '@'localhost' (using password: YES)")
> >
> > > > > Thanks in advance,
> > > > > Sonal
> >
> >
> >
>

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



Re: mysql setting eror

2009-07-23 Thread Sonal Breed

Saketh,
I got the problem, it was the quotes around username and localhost,
The command for mysql should be
GRANT ALL ON django_db.* TO sonal@'ocalhost IDENTIFIED BY
'sonal';

http://www.webdevelopersnotes.com/tutorials/sql/mysql_primer_creating_a_database.php3

Thanks,
Sonal.

On Jul 23, 10:03 am, Sonal Breed  wrote:
> Hello saketh,
> The name of the db is mygodb, i just happened to give the example of
> Django_db in mysql console.
> I am still getting the error. Does anybody know the solution to this??
>
> Any help will be really appreciated,
> Sonal.
>
> On Jul 23, 9:47 am, Sonal Breed  wrote:
>
> > Yes , the name of the database is mygodb..
>
> > On Jul 23, 9:45 am, Saketh  wrote:
>
> > > You seem to be accessing 'mygodb' from your django config, for which
> > > so...@localhost might not have permissions. Is this the case?
>
> > > Sincerely,
> > > Saketh
>
> > > On Thu, Jul 23, 2009 at 12:42 PM, Sonal Breed  
> > > wrote:
>
> > > > Hi all,
>
> > > > I am migrating my project from sqlite3 to mysql.
> > > > Installed mysql and mysqldb on  my machine and executed following:
>
> > > >  mysql -u root -p
> > > > Enter password:
> > > > Welcome to the MySQL monitor.  Commands end with ; or \g.
> > > > Your MySQL connection id is 1
> > > > Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)
>
> > > > Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
>
> > > > mysql> CREATE DATABASE django_db;
> > > > Query OK, 1 row affected (0.01 sec)
>
> > > > mysql> GRANT ALL ON django_db.* TO 'sonal'@'localhost' IDENTIFIED BY
> > > > 'sonal';
> > > > Query OK, 0 rows affected (0.03 sec)
>
> > > > mysql> quit
> > > > Bye
>
> > > > In settings.py
> > > > DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2',
> > > > 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
> > > > DATABASE_NAME = 'mygodb'             # Or path to database file if
> > > > using sqlite3.
> > > > DATABASE_USER = 'sonal '             # Not used with sqlite3.
> > > > DATABASE_PASSWORD = 'sonal'         # Not used with sqlite3.
> > > > DATABASE_HOST = ''             # Set to empty string for localhost.
> > > > Not used with sqlite3.
> > > > DATABASE_PORT = ''             # Set to empty string for default. Not
> > > > used with sqlite3.
>
> > > > user sonal is already created in mysql with password sonal.
>
> > > > And the error message is
>
> > > > /var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
> > > > DeprecationWarning: the sets module is deprecated
> > > >  from sets import ImmutableSet
> > > > ...
> > > > ...
> > > > _mysql_exceptions.OperationalError: (1045, "Access denied for user
> > > > 'sonal '@'localhost' (using password: YES)")
>
> > > > Thanks in advance,
> > > > Sonal
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



run django on multicore machine

2009-07-23 Thread ihome

Has django been designed to take advantage of multicore machine? Is
there a way to boost the performance of a django server on multicore
machine? Any thoughts? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mysql setting eror

2009-07-23 Thread Sonal Breed

Hello saketh,
The name of the db is mygodb, i just happened to give the example of
Django_db in mysql console.
I am still getting the error. Does anybody know the solution to this??

Any help will be really appreciated,
Sonal.


On Jul 23, 9:47 am, Sonal Breed  wrote:
> Yes , the name of the database is mygodb..
>
> On Jul 23, 9:45 am, Saketh  wrote:
>
> > You seem to be accessing 'mygodb' from your django config, for which
> > so...@localhost might not have permissions. Is this the case?
>
> > Sincerely,
> > Saketh
>
> > On Thu, Jul 23, 2009 at 12:42 PM, Sonal Breed  wrote:
>
> > > Hi all,
>
> > > I am migrating my project from sqlite3 to mysql.
> > > Installed mysql and mysqldb on  my machine and executed following:
>
> > >  mysql -u root -p
> > > Enter password:
> > > Welcome to the MySQL monitor.  Commands end with ; or \g.
> > > Your MySQL connection id is 1
> > > Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)
>
> > > Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
>
> > > mysql> CREATE DATABASE django_db;
> > > Query OK, 1 row affected (0.01 sec)
>
> > > mysql> GRANT ALL ON django_db.* TO 'sonal'@'localhost' IDENTIFIED BY
> > > 'sonal';
> > > Query OK, 0 rows affected (0.03 sec)
>
> > > mysql> quit
> > > Bye
>
> > > In settings.py
> > > DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2',
> > > 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
> > > DATABASE_NAME = 'mygodb'             # Or path to database file if
> > > using sqlite3.
> > > DATABASE_USER = 'sonal '             # Not used with sqlite3.
> > > DATABASE_PASSWORD = 'sonal'         # Not used with sqlite3.
> > > DATABASE_HOST = ''             # Set to empty string for localhost.
> > > Not used with sqlite3.
> > > DATABASE_PORT = ''             # Set to empty string for default. Not
> > > used with sqlite3.
>
> > > user sonal is already created in mysql with password sonal.
>
> > > And the error message is
>
> > > /var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
> > > DeprecationWarning: the sets module is deprecated
> > >  from sets import ImmutableSet
> > > ...
> > > ...
> > > _mysql_exceptions.OperationalError: (1045, "Access denied for user
> > > 'sonal '@'localhost' (using password: YES)")
>
> > > Thanks in advance,
> > > Sonal
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mysql setting eror

2009-07-23 Thread Sonal Breed

Yes , the name of the database is mygodb..

On Jul 23, 9:45 am, Saketh  wrote:
> You seem to be accessing 'mygodb' from your django config, for which
> so...@localhost might not have permissions. Is this the case?
>
> Sincerely,
> Saketh
>
> On Thu, Jul 23, 2009 at 12:42 PM, Sonal Breed  wrote:
>
> > Hi all,
>
> > I am migrating my project from sqlite3 to mysql.
> > Installed mysql and mysqldb on  my machine and executed following:
>
> >  mysql -u root -p
> > Enter password:
> > Welcome to the MySQL monitor.  Commands end with ; or \g.
> > Your MySQL connection id is 1
> > Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)
>
> > Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
>
> > mysql> CREATE DATABASE django_db;
> > Query OK, 1 row affected (0.01 sec)
>
> > mysql> GRANT ALL ON django_db.* TO 'sonal'@'localhost' IDENTIFIED BY
> > 'sonal';
> > Query OK, 0 rows affected (0.03 sec)
>
> > mysql> quit
> > Bye
>
> > In settings.py
> > DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2',
> > 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
> > DATABASE_NAME = 'mygodb'             # Or path to database file if
> > using sqlite3.
> > DATABASE_USER = 'sonal '             # Not used with sqlite3.
> > DATABASE_PASSWORD = 'sonal'         # Not used with sqlite3.
> > DATABASE_HOST = ''             # Set to empty string for localhost.
> > Not used with sqlite3.
> > DATABASE_PORT = ''             # Set to empty string for default. Not
> > used with sqlite3.
>
> > user sonal is already created in mysql with password sonal.
>
> > And the error message is
>
> > /var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
> > DeprecationWarning: the sets module is deprecated
> >  from sets import ImmutableSet
> > ...
> > ...
> > _mysql_exceptions.OperationalError: (1045, "Access denied for user
> > 'sonal '@'localhost' (using password: YES)")
>
> > Thanks in advance,
> > Sonal
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mysql setting eror

2009-07-23 Thread Saketh
You seem to be accessing 'mygodb' from your django config, for which
so...@localhost might not have permissions. Is this the case?

Sincerely,
Saketh

On Thu, Jul 23, 2009 at 12:42 PM, Sonal Breed  wrote:

>
> Hi all,
>
> I am migrating my project from sqlite3 to mysql.
> Installed mysql and mysqldb on  my machine and executed following:
>
>  mysql -u root -p
> Enter password:
> Welcome to the MySQL monitor.  Commands end with ; or \g.
> Your MySQL connection id is 1
> Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)
>
> Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
>
> mysql> CREATE DATABASE django_db;
> Query OK, 1 row affected (0.01 sec)
>
> mysql> GRANT ALL ON django_db.* TO 'sonal'@'localhost' IDENTIFIED BY
> 'sonal';
> Query OK, 0 rows affected (0.03 sec)
>
> mysql> quit
> Bye
>
> In settings.py
> DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
> DATABASE_NAME = 'mygodb' # Or path to database file if
> using sqlite3.
> DATABASE_USER = 'sonal ' # Not used with sqlite3.
> DATABASE_PASSWORD = 'sonal' # Not used with sqlite3.
> DATABASE_HOST = '' # Set to empty string for localhost.
> Not used with sqlite3.
> DATABASE_PORT = '' # Set to empty string for default. Not
> used with sqlite3.
>
> user sonal is already created in mysql with password sonal.
>
> And the error message is
>
> /var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
> DeprecationWarning: the sets module is deprecated
>  from sets import ImmutableSet
> ...
> ...
> _mysql_exceptions.OperationalError: (1045, "Access denied for user
> 'sonal '@'localhost' (using password: YES)")
>
>
> Thanks in advance,
> Sonal
> >
>

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



mysql setting eror

2009-07-23 Thread Sonal Breed

Hi all,

I am migrating my project from sqlite3 to mysql.
Installed mysql and mysqldb on  my machine and executed following:

 mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE django_db;
Query OK, 1 row affected (0.01 sec)

mysql> GRANT ALL ON django_db.* TO 'sonal'@'localhost' IDENTIFIED BY
'sonal';
Query OK, 0 rows affected (0.03 sec)

mysql> quit
Bye

In settings.py
DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'mygodb' # Or path to database file if
using sqlite3.
DATABASE_USER = 'sonal ' # Not used with sqlite3.
DATABASE_PASSWORD = 'sonal' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

user sonal is already created in mysql with password sonal.

And the error message is

/var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
DeprecationWarning: the sets module is deprecated
  from sets import ImmutableSet
...
...
_mysql_exceptions.OperationalError: (1045, "Access denied for user
'sonal '@'localhost' (using password: YES)")


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



Re: urls.py import() usage?

2009-07-23 Thread Matthias Kestenholz

On Thu, Jul 23, 2009 at 5:33 PM, Joshua Russo wrote:
> On Thu, Jul 23, 2009 at 2:18 PM, Matthias Kestenholz
>  wrote:
>>
>> On Thu, Jul 23, 2009 at 4:51 PM, Joshua Russo
>> wrote:
>> >
>> > Is there any difference between using import() versus not in the url
>> > pattern list?
>> >    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>> >    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>> Are you asking about import or include? Where would your imports be?
>
>
> Sorry, I meant include.

Well, there is a big difference between the two. include() takes the
python path to an URLconf file while the other form takes a view.

You should read the documentation on this page if you haven't done this already:
http://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-urls


Matthias

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



PostgreSQL Stored Procedure in ordinary Django query expression?

2009-07-23 Thread Adam Seering

Hey folks,
I have a PostgreSQL stored procedure that does some fairly complex 
logic to query/filter a particular table (though it ultimately does 
return rows straight from that table).  I'm trying to call this stored 
procedure from within Django, and execute additional filters/etc on the 
procedure:

MyModel.do_my_stored_procedure('proc', args).filter(mymodelfk__foo=bar)

(or the like.)  Anyone have any pointers on how to best do this?  Is 
there, by any chance, native support for this in Django 1.1 that I just 
haven't found yet?

There's an existing implementation that worked decently with Django 1.0 
(djangosnippets.org #272).  However, it works by generating a normal 
query through an ordinary QuerySet and doing string 
matching/substitution to insert the function call.  I'd like to do 
something a bit cleaner, but I don't yet understand Django's internals 
well enough to hack them this much...  Any ideas?

Thanks,
Adam


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



Re: @login_required() dont work

2009-07-23 Thread Jonas Obrist

that should be

@login_required
def index(request):
...


as far as i know, pretty sure your () are the problem

Asinox wrote:
> Hi guys, im trying to use the login and logout functions of Django,
> but my @login_required() dont work, dont redirecto to the login form
> and show the view where the user need to be logged...
>
> VIEW
> from django.shortcuts import render_to_response, get_object_or_404,
> Http404
> from django.contrib.auth.decorators import login_required
> from diligencia.diligencias.models import UserProfile, Diligencia
>
> @login_required()
> def index(request):
> entradas = Diligencia.objects.all()
> return render_to_response('account/listar_deligencias.html',
> {'listar': entradas})
>
>
> SETTINGS
> LOGIN_REDIRECT_URL = '/accounts/profile/'
>
> LOGIN_URL = '/accounts/login/'
>
>
>
> What's wrong?
>
> Thanks
> >
>   


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



Re: urls.py import() usage?

2009-07-23 Thread Saketh
Joshua, could you clarify what you mean by "not in the url pattern list?"

Sincerely,
Saketh

--
Saketh Bhamidipati
Harvard College '11
http://people.fas.harvard.edu/~svbhamid/


On Thu, Jul 23, 2009 at 11:33 AM, Joshua Russo wrote:

> On Thu, Jul 23, 2009 at 2:18 PM, Matthias Kestenholz <
> matthias.kestenh...@gmail.com> wrote:
>
>>
>> On Thu, Jul 23, 2009 at 4:51 PM, Joshua Russo
>> wrote:
>> >
>> > Is there any difference between using import() versus not in the url
>> > pattern list?
>> >(r'^accounts/login/$', 'django.contrib.auth.views.login'),
>> >(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>> Are you asking about import or include? Where would your imports be?
>
>
> Sorry, I meant include.
> >
>

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



Re: urls.py import() usage?

2009-07-23 Thread Joshua Russo
On Thu, Jul 23, 2009 at 2:18 PM, Matthias Kestenholz <
matthias.kestenh...@gmail.com> wrote:

>
> On Thu, Jul 23, 2009 at 4:51 PM, Joshua Russo
> wrote:
> >
> > Is there any difference between using import() versus not in the url
> > pattern list?
> >(r'^accounts/login/$', 'django.contrib.auth.views.login'),
> >(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> Are you asking about import or include? Where would your imports be?


Sorry, I meant include.

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



@login_required() dont work

2009-07-23 Thread Asinox

Hi guys, im trying to use the login and logout functions of Django,
but my @login_required() dont work, dont redirecto to the login form
and show the view where the user need to be logged...

VIEW
from django.shortcuts import render_to_response, get_object_or_404,
Http404
from django.contrib.auth.decorators import login_required
from diligencia.diligencias.models import UserProfile, Diligencia

@login_required()
def index(request):
entradas = Diligencia.objects.all()
return render_to_response('account/listar_deligencias.html',
{'listar': entradas})


SETTINGS
LOGIN_REDIRECT_URL = '/accounts/profile/'

LOGIN_URL = '/accounts/login/'



What's wrong?

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



Re: urls.py import() usage?

2009-07-23 Thread Matthias Kestenholz

On Thu, Jul 23, 2009 at 4:51 PM, Joshua Russo wrote:
>
> Is there any difference between using import() versus not in the url
> pattern list?
>    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>    (r'^admin/doc/', include('django.contrib.admindocs.urls')),

Are you asking about import or include? Where would your imports be?


Matthias

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



Re: Slugs, why would you ever need to store one in the database?

2009-07-23 Thread Masklinn

On 23 Jul 2009, at 16:30 , nbv4 wrote:
> I'm looking into adding prettier URLs into my site with the help of
> slugs. I've never done something like this before, so I'm doing a lot
> of reading and am having trouble "getting" slugs. When creating URLs,
> couldn't you just do do something like "example.com/45/slug-goes-
> here"? Then have the view only use the 45 (the ID) to look up the blog
> entry (or whatever).

Yes you could.

> It seems that the way
> you're supposed to do it involves a seperate slug field that gets
> stored in the database. What is the point of this? I'm about to
> implement this the way I described above. Is there anything I'm
> missing?

Well I usually set the slug field as the pk (which removes the `id`  
field Django automatically adds to the table). That way I get  
`example.com/slug-goes-here` and the view only uses the slug to look  
up the item, not an artificial ID (naturally one can also consider the  
slug to be artificial: since it's a transformation on the name/title  
of the item/entry, one could use the name/title as a PK, though I  
don't think even Django 1.1's extensions to the ORM handle that kind  
of cases gracefully).


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



urls.py import() usage?

2009-07-23 Thread Joshua Russo

Is there any difference between using import() versus not in the url
pattern list?
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Slugs, why would you ever need to store one in the database?

2009-07-23 Thread Michael
On Thu, Jul 23, 2009 at 10:30 AM, nbv4  wrote:

>
> I'm looking into adding prettier URLs into my site with the help of
> slugs. I've never done something like this before, so I'm doing a lot
> of reading and am having trouble "getting" slugs. When creating URLs,
> couldn't you just do do something like "example.com/45/slug-goes-
> here"? Then have the view only use the 45 (the ID) to look up the blog
> entry (or whatever). Then it checks to see if the slug matches, if it
> does then carry on, if not, issue a redirect with the correct slug. It
> seems like to me this is the easiest way to go about this, but in my
> google searches, this is Not The Right Way (TM). It seems that the way
> you're supposed to do it involves a seperate slug field that gets
> stored in the database. What is the point of this? I'm about to
> implement this the way I described above. Is there anything I'm
> missing?
>

In general, some of us don't really care to expose the 45 part of that url.
It is often a lot simpler to have a slug stored in the db and have it be the
field that people use to look up entries. While I wouldn't say your way is
wrong, the slug and the ID are redundant; they are both referring to the
same thing. It helps SEO and humans to have short, concise and readable
uris, so when you look at my blog post /python-rocks-my-socks/ you know what
you are getting yourself into. Why put the extra ID there? You could also
compute the uri on the fly if you don't want to store the slug in the DB,
but that would require a lot of processing and essentially the same database
lookup (WHERE `slug` EXACT 'python-rocks-my-socks') or something worse
(WHERE `slug` IREGEX 'crazy regex processing'). It is easier to just store
the slug IMO.

>
> Also, is there some kind of "slugify" function build into django? I
> know theres the slugify template tag, but what about something not in
> that I can use in my models and views?


Filters are nothing more than functions in Django, so:
In [1]: from django.template.defaultfilters import slugify

In [2]: slugify('Python rocks my socks')
Out[2]: u'python-rocks-my-socks'

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



Re: Slugs, why would you ever need to store one in the database?

2009-07-23 Thread Shawn Milochik

My understanding of the slug field is that prettier URLs are the main  
point.

"Slug" is a newspaper-industry term, and since Django has its roots  
there, it's now a Django term.

Django does' in fact, contain a slugify function:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#slugify
You can import and use this in a view, not just in a template: from  
django.template.defaultfilters import slugify

Note that it does not enforce uniqueness; you'd have to do that  
yourself. We just append a number to the slug.
So, for example, if you already had john_smith as a slug, you'd end up  
with john_smith2.

We use unique slugs, and store them in the database. The main reason  
(I think) for storing it in the
database is the fact that you can easily retrieve a model instance  
using (slug = value) in the objects.get().

Having the ID and the slug both passed in the URL is redundant. We use  
one or the other. Your use case may
dictate a different approach, but it doesn't make sense to me to have  
two values in the URL, both of which should
be referring to the exact same record.

Shawn

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



Slugs, why would you ever need to store one in the database?

2009-07-23 Thread nbv4

I'm looking into adding prettier URLs into my site with the help of
slugs. I've never done something like this before, so I'm doing a lot
of reading and am having trouble "getting" slugs. When creating URLs,
couldn't you just do do something like "example.com/45/slug-goes-
here"? Then have the view only use the 45 (the ID) to look up the blog
entry (or whatever). Then it checks to see if the slug matches, if it
does then carry on, if not, issue a redirect with the correct slug. It
seems like to me this is the easiest way to go about this, but in my
google searches, this is Not The Right Way (TM). It seems that the way
you're supposed to do it involves a seperate slug field that gets
stored in the database. What is the point of this? I'm about to
implement this the way I described above. Is there anything I'm
missing?

Also, is there some kind of "slugify" function build into django? I
know theres the slugify template tag, but what about something not in
that I can use in my models and views?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Automatic updating of open-high-low-close data

2009-07-23 Thread Shawn Milochik

Why not just use the automatic "id" field as the primary key?



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



Re: passing variable to objects.get

2009-07-23 Thread Shawn Milochik

Do you know for certain that indata contains a value before you try  
the objects.get()?

If you are getting an error like "no value found," it sounds like you  
might not. If you're getting something like "no such object," then it  
would be a different problem.

Is the field "word" in your model a unique value? Also, does your  
regex match the value for indata? Maybe there are punctuation marks  
that don't match \w.

Also, once you've confirmed that indata contains a value, dump its  
type and value to the screen with the logging module or a print  
statement, and see if it looks like the kind of data your database  
should be expecting.

If you don't get it to work, please post sample values for "word" in  
the database and sample values for "indata," including a couple of URL  
strings.

Shawn

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



Re: pdb session and auto-reload: input problem

2009-07-23 Thread Tom Evans

On Thu, 2009-07-23 at 14:11 +0100, Jeremy Sule wrote:
> Hi everyone,
> 
> I use pdb a lot and just drop "import pdb; pdb.set_trace()" here and
> there in my code.
> Often I find I have to change my code and do the change in the source
> code and save it.
> 
> The auto reload feature of django then reloads the files and restarts
> the development server (nice).
> 
> The problem is that if I didn't close my pdb session by a continue,
> any input I'd make in the terminal would not appear:
> Any character I type is passed to the terminal but does not appear on
> the screen, even if I interrupt the django server. I have to close the
> terminal and restart everything.
> 
> Should I do something differently? (remembering to press "c" each time
> has proven too difficult so far)
> 
> Toutanc

If you are using a UNIX like shell, you can simply type 'reset' to reset
your terminal to a proper state. If you have a regular keyboard, 'reset
-e ^?' is probably correct. 

Tom



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



Re: recursive relationship : cannot save

2009-07-23 Thread Fleg

I reply to myself...
My mistake was a confusion between db_column and to_field so the
mistake was to put  db_column='id_schedule' in
 id_parent = models.ForeignKey("self",db_column='id_schedule')
because like that django will use the column id_schedule for
id_parent
Instead I have to use
 id_parent = models.ForeignKey
("Scheduler",db_column='id_parent',to_field='id_schedule')

F.

On 23 juil, 15:02, Fleg  wrote:
> Hi,
> I am using Django version 1.0.2 final with Python 2.5.2
> I have a model called Scheduler in which I have a colomn (called
> "parent_id") which define a recursive relationship.
> I defined it like this :
>
> class Scheduler(models.Model):
>         id_schedule = models.AutoField(primary_key=True)
>         id_parent = models.ForeignKey("self",db_column='id_schedule')
>         id_object_type = models.ForeignKey(ObjectTypes,
> db_column='id_object_type')
>         
>
> I create a new object with :
> action=Scheduler(id_schedule = None,id_parent_id=1,id_object_type_id =
> 2 ..
>
> My problem is that when I want to save the object (with action.save
> ()), it fails with the following error :
>
> ERROR:  null value in column
> "id_parent" violates not-null constraint
>
> INSERT INTO "scheduler" ("id_schedule", "id_object_type", 
>
> So the generated SQL query does not include the id_parent field !
> Why ?
> What am i doing wrong ?
> Thanks for your help
> F.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



pdb session and auto-reload: input problem

2009-07-23 Thread Jeremy Sule
Hi everyone,

I use pdb a lot and just drop "import pdb; pdb.set_trace()" here and there
in my code.
Often I find I have to change my code and do the change in the source code
and save it.

The auto reload feature of django then reloads the files and restarts the
development server (nice).

The problem is that if I didn't close my pdb session by a continue, any
input I'd make in the terminal would not appear:
Any character I type is passed to the terminal but does not appear on the
screen, even if I interrupt the django server. I have to close the terminal
and restart everything.

Should I do something differently? (remembering to press "c" each time has
proven too difficult so far)

Toutanc

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



recursive relationship : cannot save

2009-07-23 Thread Fleg

Hi,
I am using Django version 1.0.2 final with Python 2.5.2
I have a model called Scheduler in which I have a colomn (called
"parent_id") which define a recursive relationship.
I defined it like this :

class Scheduler(models.Model):
id_schedule = models.AutoField(primary_key=True)
id_parent = models.ForeignKey("self",db_column='id_schedule')
id_object_type = models.ForeignKey(ObjectTypes,
db_column='id_object_type')


I create a new object with :
action=Scheduler(id_schedule = None,id_parent_id=1,id_object_type_id =
2 ..

My problem is that when I want to save the object (with action.save
()), it fails with the following error :

ERROR:  null value in column
"id_parent" violates not-null constraint

INSERT INTO "scheduler" ("id_schedule", "id_object_type", 

So the generated SQL query does not include the id_parent field !
Why ?
What am i doing wrong ?
Thanks for your help
F.

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



Djang-admin : Display link to object info page instead of edit form , in records change list ?

2009-07-23 Thread Hamza

Hello ,

I am customizing Django-admin for an application am working on . so
far the customization is working file , added some views . but I am
wondering how to change the records link in change_list display to
display an info page instead of change form ?!

in this blog post :http://www.theotherblog.com/Articles/2009/06/02/
extending-the-django-admin-interface/ Tom said :

" You can add images or links in the listings view by defining a
function then adding my_func.allow_tags = True "


which i didn't fully understand !!

right now i have  profile function , which i need when i click on a
member in the records list i can display it ( or adding another button
called - Profile - ) , also how to add link for every member ( Edit :
redirect me to edit form for this member ) .

How i can achieve  that ?!

Regards





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



problem with Imageloading

2009-07-23 Thread guptha

My requirement is  ,user  uploaded  image has to be saved in Database
after a custom validation for size and has to display to user.
In models.py
class Marketplace(models.Model):
title_name=models.CharField(max_length=125)
photo1  = models.ImageField(upload_to= 'img/marketplace/%Y/%m/
%d', null=True, blank=True)
photo2  = models.ImageField(upload_to = 'img/marketplace/%Y/%m/
%d', null=True, blank=True)


In forms.py
   class MarketplaceForm(forms.Form):
   title_name = forms.CharField(max_length=125)
photo1 = forms.ImageField(required=False)
photo2 = forms.ImageField(required=False)


   def clean_photo1(self):
from django.core.files.images import
get_image_dimensions
logo = self.cleaned_data['photo1']
w, h = get_image_dimensions(logo)
if w > 150 or h > 150:
raise forms.ValidationError(u'That logo is
too big. Please resize it so that it is 32x32 pixels or less, although
150x150 pixels is optimal for display purposes.')
   return self.cleaned_data['photo1']


  def save(self):
new_market = Marketplace.objects.create
(title_name=self.cleaned_data['title_name'],
photo1=self.cleaned_data['photo1'],
photo2=self.cleaned_data['photo2'],
return new_market



In views.py

   def postyour_adds(request):
 if request.method=='POST':
 form=MarketplaceForm(request.POST)
 if form.is_valid():
 newmarket=form.save()
 return HttpResponseRedirect("/
thanksfor_post/")
   else:
   form = MarketplaceForm()
   return render_to_response("marketplace/
postyour_add.html", {'form': form})




In postyour_add.html



{% block content %}
 Enter your choice

  
  {{ form.as_p }}
  
  
{% endblock %}



The Error i am getting says photo1 and photo2 are None


Exception Type: TypeError
Exception Value: coercing to Unicode: need string or buffer,
NoneType found



Local vars shows no values is assigned to photo1 and photo2

Any solution please
Gjango


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



Re: No serial primary key and admin interface

2009-07-23 Thread Thomas Guettler

I am sorry for the noise: The slug primary key of the inline model
needs to be displayed. Now it works. Nevertheless silently ignoring
errors like admin does sometimes is bad.

Thomas Guettler schrieb:
> ... replying to myself
> 
> In django trunk this was fixed.
> http://code.djangoproject.com/ticket/10992
> 
> Still looking for a solution in 1_0_X. Unfortunately I don't get a stacktrace,
> but the inlines are just missing.
> 
> TEMPLATE_STRING_IF_INVALID does not get used.
> 
>   Thomas
> 
> 
> Thomas Guettler schrieb:
>> Hi,
>>
>> today I created a model with a slug field as primary key.
>> I discovered that it brings problems in the admin interface.
>>
>> 1. Inlines are not possible. The don't get displayed and if I submit I get 
>> "ManagementForm data is missing or has been
>> tampered with".
>>
>> Both ("parent" and inline) models have a slug field as primary key. Any 
>> change to get the
>> admin interface working?
>>
>> I use the django svn 1_0_X branch
>>
>>   Thomas
>>
> 

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



Re: reduce the amount of classes shown in the admin panel

2009-07-23 Thread rvandam

Oh no, how stupid of me. First i register the models in admin.py, and
then i ask how to get rid of them :/

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



Re: reduce the amount of classes shown in the admin panel

2009-07-23 Thread Kenneth Gonsalves

On Thursday 23 Jul 2009 4:45:29 pm rvandam wrote:
> I got a bit lost in the documentation.
>
> The Django admin panel (1.0.2) shows every model class from my app.I
> have 10 classes, and I want to reduce the classes shown to 2. I can
> modify the other classes because the use of ForeignKeys
>
> What is the best way to accomplish this?

do not register the unwanted models with admin
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: About Templates Readymade

2009-07-23 Thread Kenneth Gonsalves

On Thursday 23 Jul 2009 2:58:25 pm gopinath_g wrote:
> Hi friends,
> I am currently working on django .But i feel writing templates
> is a tough job for me because i am terrific at design. Can you provide
> me sources where can get the ready made templates for django
> especially.

I assume you mean you are terrible at design and not terrific. Templates are 
just css and html. So go to your favourite source for ready made templates and 
use them
-- 
regards
kg
http://lawgon.livejournal.com

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



reduce the amount of classes shown in the admin panel

2009-07-23 Thread rvandam

I got a bit lost in the documentation.

The Django admin panel (1.0.2) shows every model class from my app.I
have 10 classes, and I want to reduce the classes shown to 2. I can
modify the other classes because the use of ForeignKeys

What is the best way to accomplish this?

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



Automatic updating of open-high-low-close data

2009-07-23 Thread Stale

Hi all,

I have an app for storing historical data for stocks, which I
automatically fetch on a daily basis from Yahoo using the exellent
matplotlib. I have split this into two models, something like this:

class Stock(models.Model):
 ticker=models.CharField(max_length=30)
 name=models.CharField(max_length=255)

class Quote(models.Model):
 stock=models.ForeignKey(Stock)
 date=models.DateField()
 open=models.FloatField()
 ..

Quotes are naturally unique for dates so I would like to use the date-
field as a primary key. However, if I use the date-field as a primary
key only the quotes-values for the latest stock in my list of stocks
are kept - all others are over-written.

Would it be more appropriate to substitute the ForeignKey with a
ManyToMany-field and use a primary key for the date-field? Any other
suggestions?

Thanks for any pointers!

Stale

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



About Templates Readymade

2009-07-23 Thread gopinath_g

Hi friends,
I am currently working on django .But i feel writing templates
is a tough job for me because i am terrific at design. Can you provide
me sources where can get the ready made templates for django
especially.

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



Re: Django-admin {{ root_path }} problem !

2009-07-23 Thread Dr.Hamza Mousa
reinstall the django to the latest development version of the trunk solve
the issue , thank you



On Thu, Jul 23, 2009 at 10:39 AM, Dr.Hamza Mousa wrote:

> Thanks again Russell
>
> The admin templates i put in /templates/admin is working very well the css
> is extended and also customize the base template file ( still working thu )
> ( forget to say i already set the template dir in settings.py : sorry )  , i
> also registered the application .
>
> yes the admin working correctly and still working thu :)
>
> about old files of django RC 1.1 somewhere i think so cause this issue is
> not happening on Windows Django 1.1 !!!
>
> will check if reinstalling django will work !
>
> Thanks
>
>
>
>
> On Thu, Jul 23, 2009 at 10:22 AM, Russell Keith-Magee <
> freakboy3...@gmail.com> wrote:
>
>>
>> On Thu, Jul 23, 2009 at 2:30 PM, Dr.Hamza Mousa
>> wrote:
>> > Hi Russell
>> >
>> > The admin templates i copied into /templates/admin/ .
>> >
>> > The idea : i need to customize the admin for a project am working on .
>> >
>> > -details :
>> >
>> > installed django RC 1.1 , ubuntu linux 9.04 .
>> >
>> > so i ran :
>> >
>> > django-admin.py startproject emr_admin
>> >
>> > , python manage.py startapp emr
>> >
>> > defined my first model in the emr/models.py
>> >
>> > added the django.contrib.admin in emr_admin/settings.py
>> >
>> > then ran : python manage.py syncdb
>> >
>> > urls.py :
>> >
>> > -
>> > from django.contrib import admin
>> > admin.autodiscover()
>> >
>> > and in : urlpatterns  i added the admin urls
>> >
>> >
>> > (r'^admin/', include(ad
>> >
>> > min.site.urls)),
>> > 
>> >
>> >
>> >
>> >
>> > 
>> > Django admin Template files :
>> >
>> > to extend the admin css style i copied the admin template from the
>> django RC
>> > 1.1 to /templates/admin/ like base.html , base_site.html , index.html
>> ..
>> >
>> > so now they are in
>> >
>> > /templates/admin/
>>
>> I should point out that unless you make a modification to
>> TEMPLATE_DIRS in your settings file, copying the template files will
>> have no effect at all. From the point of view of these instructions,
>> copying the template files is a no op - the admin won't pay any
>> attention to the files in /templates.
>>
>> > 
>> >
>> > emr/admin.py :
>> >
>> > so it all runs so fine ,
>>
>> To clarify - Are you saying that at this point in the process, the
>> admin site URLs are displayed correctly?
>>
>> > register my app models in emr/admin.py
>>
>> I presume you have also put emr into INSTALLED_APPS at some point in
>> this process?
>>
>> > :
>> > from django.contrib import admin
>> > from django import forms
>> >
>> > from emr_admin.emr.models import *
>> >
>> > class PatientForm(forms.ModelForm):
>> > comment = forms.CharField(widget=forms.Textarea(attrs={'rows':4,
>> > 'cols':60}),label='Comment',help_text="")
>> > sex =
>> forms.CharField(widget=forms.RadioSelect(choices=SEX),label='Sex')
>> > smoking =
>> >
>> forms.CharField(widget=forms.RadioSelect(choices=SMOKING),label='Smoking')
>> > maritalstatus =
>> > forms.CharField(widget=forms.RadioSelect(choices=Marital_STATS))
>> >
>> >
>> >
>> > class PatientAdmin(admin.ModelAdmin):
>> >list_display = ( 'name', 'sex','maritalstatus', 'bdate','jobtitle')
>> >list_display_links = ( 'name', 'sex','maritalstatus',
>> 'bdate','jobtitle')
>> >search_fields = ('name', 'jobtitle')
>> >list_filter = ('jobtitle','sex')
>> >list_per_page = 25
>> >ordering = ['name']
>> >form = PatientForm
>> >
>> >
>> > admin.site.register(Patient , PatientAdmin)
>> >
>> >
>> >
>> > -
>> > everything working so fine at the admin side , however the only thing is
>> not
>> > working is the logout and change password , when i direct the url to the
>> > change password form and change my password , it redirect me to the
>> wrong
>> > url as well :
>> >
>> > http://localhost:8000/admin/password_change/admin/password_change/done/
>> >
>> >
>> > thats what happend so far :
>>
>> I don't experience any problems when I follow these instructions. I am
>> shown links to  /admin/password_change/ and /admin/logout/; I get
>> redirected to /admin/password_change/done/ when I change my password.
>>
>> The fact that your instructions don't include any reference to
>> changing TEMPLATE_DIRS leads me suspect that one of three things is
>> happening:
>>
>> 1) You're actually pointing at a different set of templates than you
>> think you are (and those templates are using the old linking scheme
>> for the logout and password change links)
>>
>> 2) You don't have a complete and correct checkout of Django v1.1 RC1
>>
>> 3) In addition to a complete and correct checkout of Django v1.1 RC1,
>> you have an older (pre v1.1 RC1) checkout somewhere, and it is this
>> checkout that is being used to provide admin templates.
>>
>> Could you please check the contents of the TEMPLATE_DIRS settings of
>> your project, and then check your PYTHONPATH very closely

forms with django and extjs 3.0.0

2009-07-23 Thread Emily Rodgers

Hi all,

I am currently working on some web apps that use django for the back
end, and extjs for the front end (using JSON to pass data between the
two).

I am getting to the point where I am going to have to start doing some
form integration. Has anyone done this lately (with the latest version
of extjs)? If so, how did you go about it? I have looked on the web,
but most of the extjs / modelform examples are using either an old
version of django or an old version of extjs, both of which have
undergone fairly backwards incompatible changes in recent revisions. I
just thought that I would ask here before spending lots of time trying
to figure it out from scratch.

I have been using django for a year or so, but I am fairly new to
extjs, and the oo style of coding javascript (more like java / C#), so
I am playing catch up, and any help or advice would be gratefully
received.

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



Re: No serial primary key and admin interface

2009-07-23 Thread Thomas Guettler

... replying to myself

In django trunk this was fixed.
http://code.djangoproject.com/ticket/10992

Still looking for a solution in 1_0_X. Unfortunately I don't get a stacktrace,
but the inlines are just missing.

TEMPLATE_STRING_IF_INVALID does not get used.

  Thomas


Thomas Guettler schrieb:
> Hi,
> 
> today I created a model with a slug field as primary key.
> I discovered that it brings problems in the admin interface.
> 
> 1. Inlines are not possible. The don't get displayed and if I submit I get 
> "ManagementForm data is missing or has been
> tampered with".
> 
> Both ("parent" and inline) models have a slug field as primary key. Any 
> change to get the
> admin interface working?
> 
> I use the django svn 1_0_X branch
> 
>   Thomas
> 

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



Re: Generating images.

2009-07-23 Thread Daniel Roseman

On Jul 23, 10:09 am, Goldy  wrote:
> Hi,
>
> I can generate a specific image using the following from the Django
> book.
>
> --- 
> ---
> from django.http import HttpResponse
>
> def my_image(request):
>     image_data = open("/path/to/my/image.png", "rb").read()
>     return HttpResponse(image_data, mimetype="image/png")
> --- 
> ---
>
> However, I would like the 'image.png' part to be dynamic. I would
> like the function to render an image from a field lets say called
> image from
> a model.
>
> Thanks in advance for your help.

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



No serial primary key and admin interface

2009-07-23 Thread Thomas Guettler

Hi,

today I created a model with a slug field as primary key.
I discovered that it brings problems in the admin interface.

1. Inlines are not possible. The don't get displayed and if I submit I get 
"ManagementForm data is missing or has been
tampered with".

Both ("parent" and inline) models have a slug field as primary key. Any change 
to get the
admin interface working?

I use the django svn 1_0_X branch

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



Generating images.

2009-07-23 Thread Goldy

Hi,

I can generate a specific image using the following from the Django
book.

--
from django.http import HttpResponse

def my_image(request):
image_data = open("/path/to/my/image.png", "rb").read()
return HttpResponse(image_data, mimetype="image/png")
--

However, I would like the 'image.png' part to be dynamic. I would
like the function to render an image from a field lets say called
image from
a model.

Thanks in advance for your help.

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



passing variable to objects.get

2009-07-23 Thread Boštjan Jerko

I have Django 1.0 and in views.py have following definition:

def vplayer(request,indata):
path_data=szj.objects.get(word=indata).file_path
context=RequestContext(request, {
"indata":path_data,
})
return render_to_response("vplayer.html",context)

The funny thing is that passing the value to it using

 (r'^szj/play/(?P\w+)/$', vplayer)

in url.py results in error (no value found). If I create a variable  
with the same text the element is found in the database.

Am I missing something since the values both look the same (and also  
have the same length)?

Regards,

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



how to decode url encoded by django.utils.http.urlquote which contain utf characters

2009-07-23 Thread virhilo

Hello
Diango have any build-in method to decode that url?
>>> from django.utils.http import urlquote_plus
>>> url = urlquote_plus('zażółć gęśłą jaźń')
>>> print url
za%C5%BC%C3%B3%C5%82%C4%87+g%C4%99%C5%9B%C5%82%C4%85+ja%C5%BA%C5%84

or this is the best way?
from urllib import unquote_plus
>>> print unicode(unquote_plus(str(url)), 'utf-8')
zażółć gęśłą jaźń

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



Re: Django-admin {{ root_path }} problem !

2009-07-23 Thread Dr.Hamza Mousa
Thanks again Russell

The admin templates i put in /templates/admin is working very well the css
is extended and also customize the base template file ( still working thu )
( forget to say i already set the template dir in settings.py : sorry )  , i
also registered the application .

yes the admin working correctly and still working thu :)

about old files of django RC 1.1 somewhere i think so cause this issue is
not happening on Windows Django 1.1 !!!

will check if reinstalling django will work !

Thanks



On Thu, Jul 23, 2009 at 10:22 AM, Russell Keith-Magee <
freakboy3...@gmail.com> wrote:

>
> On Thu, Jul 23, 2009 at 2:30 PM, Dr.Hamza Mousa
> wrote:
> > Hi Russell
> >
> > The admin templates i copied into /templates/admin/ .
> >
> > The idea : i need to customize the admin for a project am working on .
> >
> > -details :
> >
> > installed django RC 1.1 , ubuntu linux 9.04 .
> >
> > so i ran :
> >
> > django-admin.py startproject emr_admin
> >
> > , python manage.py startapp emr
> >
> > defined my first model in the emr/models.py
> >
> > added the django.contrib.admin in emr_admin/settings.py
> >
> > then ran : python manage.py syncdb
> >
> > urls.py :
> >
> > -
> > from django.contrib import admin
> > admin.autodiscover()
> >
> > and in : urlpatterns  i added the admin urls
> >
> >
> > (r'^admin/', include(ad
> >
> > min.site.urls)),
> > 
> >
> >
> >
> >
> > 
> > Django admin Template files :
> >
> > to extend the admin css style i copied the admin template from the django
> RC
> > 1.1 to /templates/admin/ like base.html , base_site.html , index.html
> ..
> >
> > so now they are in
> >
> > /templates/admin/
>
> I should point out that unless you make a modification to
> TEMPLATE_DIRS in your settings file, copying the template files will
> have no effect at all. From the point of view of these instructions,
> copying the template files is a no op - the admin won't pay any
> attention to the files in /templates.
>
> > 
> >
> > emr/admin.py :
> >
> > so it all runs so fine ,
>
> To clarify - Are you saying that at this point in the process, the
> admin site URLs are displayed correctly?
>
> > register my app models in emr/admin.py
>
> I presume you have also put emr into INSTALLED_APPS at some point in
> this process?
>
> > :
> > from django.contrib import admin
> > from django import forms
> >
> > from emr_admin.emr.models import *
> >
> > class PatientForm(forms.ModelForm):
> > comment = forms.CharField(widget=forms.Textarea(attrs={'rows':4,
> > 'cols':60}),label='Comment',help_text="")
> > sex =
> forms.CharField(widget=forms.RadioSelect(choices=SEX),label='Sex')
> > smoking =
> >
> forms.CharField(widget=forms.RadioSelect(choices=SMOKING),label='Smoking')
> > maritalstatus =
> > forms.CharField(widget=forms.RadioSelect(choices=Marital_STATS))
> >
> >
> >
> > class PatientAdmin(admin.ModelAdmin):
> >list_display = ( 'name', 'sex','maritalstatus', 'bdate','jobtitle')
> >list_display_links = ( 'name', 'sex','maritalstatus',
> 'bdate','jobtitle')
> >search_fields = ('name', 'jobtitle')
> >list_filter = ('jobtitle','sex')
> >list_per_page = 25
> >ordering = ['name']
> >form = PatientForm
> >
> >
> > admin.site.register(Patient , PatientAdmin)
> >
> >
> >
> > -
> > everything working so fine at the admin side , however the only thing is
> not
> > working is the logout and change password , when i direct the url to the
> > change password form and change my password , it redirect me to the wrong
> > url as well :
> >
> > http://localhost:8000/admin/password_change/admin/password_change/done/
> >
> >
> > thats what happend so far :
>
> I don't experience any problems when I follow these instructions. I am
> shown links to  /admin/password_change/ and /admin/logout/; I get
> redirected to /admin/password_change/done/ when I change my password.
>
> The fact that your instructions don't include any reference to
> changing TEMPLATE_DIRS leads me suspect that one of three things is
> happening:
>
> 1) You're actually pointing at a different set of templates than you
> think you are (and those templates are using the old linking scheme
> for the logout and password change links)
>
> 2) You don't have a complete and correct checkout of Django v1.1 RC1
>
> 3) In addition to a complete and correct checkout of Django v1.1 RC1,
> you have an older (pre v1.1 RC1) checkout somewhere, and it is this
> checkout that is being used to provide admin templates.
>
> Could you please check the contents of the TEMPLATE_DIRS settings of
> your project, and then check your PYTHONPATH very closely to see if
> any of these conditions are correct?
>
> Yours,
> Russ Magee %-)
>
> >
>


-- 
Hamza E.e Mousa

www.neoxero.com
www.goomedic.com
www.medpeek.com
www.freewaydesign.com

http://www.twitter.com/hamzamusa
http://twitter.com/goomedic

--~--~-~--~~~---~--~~
You received this message because you

Re: Django-admin {{ root_path }} problem !

2009-07-23 Thread Russell Keith-Magee

On Thu, Jul 23, 2009 at 2:30 PM, Dr.Hamza Mousa wrote:
> Hi Russell
>
> The admin templates i copied into /templates/admin/ .
>
> The idea : i need to customize the admin for a project am working on .
>
> -details :
>
> installed django RC 1.1 , ubuntu linux 9.04 .
>
> so i ran :
>
> django-admin.py startproject emr_admin
>
> , python manage.py startapp emr
>
> defined my first model in the emr/models.py
>
> added the django.contrib.admin in emr_admin/settings.py
>
> then ran : python manage.py syncdb
>
> urls.py :
>
> -
> from django.contrib import admin
> admin.autodiscover()
>
> and in : urlpatterns  i added the admin urls
>
>
> (r'^admin/', include(ad
>
> min.site.urls)),
> 
>
>
>
>
> 
> Django admin Template files :
>
> to extend the admin css style i copied the admin template from the django RC
> 1.1 to /templates/admin/ like base.html , base_site.html , index.html ..
>
> so now they are in
>
> /templates/admin/

I should point out that unless you make a modification to
TEMPLATE_DIRS in your settings file, copying the template files will
have no effect at all. From the point of view of these instructions,
copying the template files is a no op - the admin won't pay any
attention to the files in /templates.

> 
>
> emr/admin.py :
>
> so it all runs so fine ,

To clarify - Are you saying that at this point in the process, the
admin site URLs are displayed correctly?

> register my app models in emr/admin.py

I presume you have also put emr into INSTALLED_APPS at some point in
this process?

> :
> from django.contrib import admin
> from django import forms
>
> from emr_admin.emr.models import *
>
> class PatientForm(forms.ModelForm):
>     comment = forms.CharField(widget=forms.Textarea(attrs={'rows':4,
> 'cols':60}),label='Comment',help_text="")
>     sex = forms.CharField(widget=forms.RadioSelect(choices=SEX),label='Sex')
>     smoking =
> forms.CharField(widget=forms.RadioSelect(choices=SMOKING),label='Smoking')
>     maritalstatus =
> forms.CharField(widget=forms.RadioSelect(choices=Marital_STATS))
>
>
>
> class PatientAdmin(admin.ModelAdmin):
>    list_display = ( 'name', 'sex','maritalstatus', 'bdate','jobtitle')
>    list_display_links = ( 'name', 'sex','maritalstatus', 'bdate','jobtitle')
>    search_fields = ('name', 'jobtitle')
>    list_filter = ('jobtitle','sex')
>    list_per_page = 25
>    ordering = ['name']
>    form = PatientForm
>
>
> admin.site.register(Patient , PatientAdmin)
>
>
>
> -
> everything working so fine at the admin side , however the only thing is not
> working is the logout and change password , when i direct the url to the
> change password form and change my password , it redirect me to the wrong
> url as well :
>
> http://localhost:8000/admin/password_change/admin/password_change/done/
>
>
> thats what happend so far :

I don't experience any problems when I follow these instructions. I am
shown links to  /admin/password_change/ and /admin/logout/; I get
redirected to /admin/password_change/done/ when I change my password.

The fact that your instructions don't include any reference to
changing TEMPLATE_DIRS leads me suspect that one of three things is
happening:

1) You're actually pointing at a different set of templates than you
think you are (and those templates are using the old linking scheme
for the logout and password change links)

2) You don't have a complete and correct checkout of Django v1.1 RC1

3) In addition to a complete and correct checkout of Django v1.1 RC1,
you have an older (pre v1.1 RC1) checkout somewhere, and it is this
checkout that is being used to provide admin templates.

Could you please check the contents of the TEMPLATE_DIRS settings of
your project, and then check your PYTHONPATH very closely to see if
any of these conditions are correct?

Yours,
Russ Magee %-)

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