Re: Work in memory instead of BD, how to?

2011-08-18 Thread Kejun He
May be you can try database long connection.

On Fri, Aug 19, 2011 at 10:44 AM, Andre Terra  wrote:

> I think a better solution would be to use a store rather than cache
> (protip: redis) and, if the calculations are lengthy, write a
> 'publish' function that writes them to the store and let the user
> choose when to see the changes in the results appear on the website.
>
> Additionally, add a 'modified since last publish' flag that is
> switched on with post_save and off with publish().
>
> And of course, use celery for running the calculations in the
> background. Here, redis doubles (or triples!) as the result and broker
> backends (see the celery docs for more info on that).
>
>
> Cheers,
> AT
>
> On 8/18/11, Felipe Arruda  wrote:
> > Humm, I see, the second case I could make out of it somehow(just have
> > some doubts in 2.5: How am I supposed to do this?)
> > The first one I could't see how I'm not going to lose the changes,
> > done in cache.
> > My biggest problem is in altering some value in some models, since
> > this operation will be done many times, and I can't do if not by
> > this(so that the client infos wont be any different from the DB), and
> > for what I understand from this solution I would work if my operations
> > where simple retrieving data from the server and doing some
> > calculation, but will lose the informations in cache(substituting it
> > from the DB. I want it to be otherwise).
> >
> > And about the django-celery: Never heard about it, but now I'm going
> > to use it(but for other purposes, and other projects too). Thanks for
> > the tip!
> >
> > Another thing. I thought of doing something like this:
> > Use MemCache, and the second ideia presented, put like a very long
> > time, and run a parallel task(using celery? or maybe some thing in
> > django-extensions that integrate with cron), so that from time to
> > time(a more reasonable time then the timeout from the cache) it will
> > get every info from cache and save it in the DB.
> > This way, in the worst case, every 10 minutes the system would have a
> > small halt to save things(or could make a more complex way to save
> > each register in different times).
> > What do you thing about it? To much POG, or is in the right track?
> >
> > On Aug 18, 3:57 pm, Doug Ballance  wrote:
> >> You probably don't want to cache changes.  Or if you do, it would be
> >> better done elsewhere (like a caching raid controller/w battery on
> >> your database machine).  The usual cache patterns I've seen are:
> >>
> >> 1) Fetch from database
> >> 2) Store in cache with a reasonable timeout to that changes are
> >> reflected as the cache expires
> >> 3) Look in cache, if found return that.  If not goto step (1)
> >>
> >> or
> >>
> >> 1) Fetch from database
> >> 2) Store in cache with a -long- timeout
> >> 2.5) Track changes to cached objects and update the stored information
> >> if it changes.
> >> 3) Look in cache, if found return it.  if not goto step(1)
> >>
> >> since the changes won't be reflected as rapidly due to the long
> >> timeout, you can configure the post_save/post_delete/etc signals to
> >> automatically update the cached value every time a change is made to
> >> one of that models instances.  This is what the django-cache-utils app
> >> is doing for you.  The trick is that the more complicated your use,
> >> the more complex the cache invalidation is going to have to be.
> >>
> >> Another possiblity is that caching may be the wrong solution to your
> >> problem. If for example a web request need to do so a bunch of
> >> expensive operations, but does not need to do them interactively with
> >> your user, a solution like django-celery may be better.  With celery
> >> the job gets scheduled for execution outside of the web request-
> >> response system (possibly even on another machine) and gives you a job
> >> id.  This allows the user to get on with things, leaving the work to
> >> be done behind the scenes.  If the user needs to know the results or
> >> state of the job  you can use ajax or refreshing to check back using
> >> the id to retreive the results when the job completes.
> >
> > --
> > You received this message because you are subscribed to the Google 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.
> >
> >
>
> --
> Sent from my mobile device
>
> --
> You received this message because you are subscribed to the Google 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
> 

Django admin site and DEBUG flag.

2011-08-18 Thread KC LEE
When I set DEBUG flag true, Django admin site works fine.

But when I change it to false, it throws me the page not found in
Django admin site (except main page of admin site, Groups page, and
Users page)

Anyone 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: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread Andre Terra
You can't map python processes to users. It's simply not how it works.


This is the web on the 21st century, rethink your concepts instead of
trying to fit them on to a completely different paradigm.

Change is good. Embrace it.


Cheers,
AT

On 8/18/11, michael kapelko  wrote:
> I think about 50 users, but Django for each sounds too much.
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google 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: Work in memory instead of BD, how to?

2011-08-18 Thread Andre Terra
I think a better solution would be to use a store rather than cache
(protip: redis) and, if the calculations are lengthy, write a
'publish' function that writes them to the store and let the user
choose when to see the changes in the results appear on the website.

Additionally, add a 'modified since last publish' flag that is
switched on with post_save and off with publish().

And of course, use celery for running the calculations in the
background. Here, redis doubles (or triples!) as the result and broker
backends (see the celery docs for more info on that).


Cheers,
AT

On 8/18/11, Felipe Arruda  wrote:
> Humm, I see, the second case I could make out of it somehow(just have
> some doubts in 2.5: How am I supposed to do this?)
> The first one I could't see how I'm not going to lose the changes,
> done in cache.
> My biggest problem is in altering some value in some models, since
> this operation will be done many times, and I can't do if not by
> this(so that the client infos wont be any different from the DB), and
> for what I understand from this solution I would work if my operations
> where simple retrieving data from the server and doing some
> calculation, but will lose the informations in cache(substituting it
> from the DB. I want it to be otherwise).
>
> And about the django-celery: Never heard about it, but now I'm going
> to use it(but for other purposes, and other projects too). Thanks for
> the tip!
>
> Another thing. I thought of doing something like this:
> Use MemCache, and the second ideia presented, put like a very long
> time, and run a parallel task(using celery? or maybe some thing in
> django-extensions that integrate with cron), so that from time to
> time(a more reasonable time then the timeout from the cache) it will
> get every info from cache and save it in the DB.
> This way, in the worst case, every 10 minutes the system would have a
> small halt to save things(or could make a more complex way to save
> each register in different times).
> What do you thing about it? To much POG, or is in the right track?
>
> On Aug 18, 3:57 pm, Doug Ballance  wrote:
>> You probably don't want to cache changes.  Or if you do, it would be
>> better done elsewhere (like a caching raid controller/w battery on
>> your database machine).  The usual cache patterns I've seen are:
>>
>> 1) Fetch from database
>> 2) Store in cache with a reasonable timeout to that changes are
>> reflected as the cache expires
>> 3) Look in cache, if found return that.  If not goto step (1)
>>
>> or
>>
>> 1) Fetch from database
>> 2) Store in cache with a -long- timeout
>> 2.5) Track changes to cached objects and update the stored information
>> if it changes.
>> 3) Look in cache, if found return it.  if not goto step(1)
>>
>> since the changes won't be reflected as rapidly due to the long
>> timeout, you can configure the post_save/post_delete/etc signals to
>> automatically update the cached value every time a change is made to
>> one of that models instances.  This is what the django-cache-utils app
>> is doing for you.  The trick is that the more complicated your use,
>> the more complex the cache invalidation is going to have to be.
>>
>> Another possiblity is that caching may be the wrong solution to your
>> problem. If for example a web request need to do so a bunch of
>> expensive operations, but does not need to do them interactively with
>> your user, a solution like django-celery may be better.  With celery
>> the job gets scheduled for execution outside of the web request-
>> response system (possibly even on another machine) and gives you a job
>> id.  This allows the user to get on with things, leaving the work to
>> be done behind the scenes.  If the user needs to know the results or
>> state of the job  you can use ajax or refreshing to check back using
>> the id to retreive the results when the job completes.
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google 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: Best approach to handling different types of Users

2011-08-18 Thread Andre Terra
Until you install some third party app that accesses
User.objects.all() and then suddenly nothing works as it's supposed
to.

You can access the User object from its related UserProfile instance
and do everything you say from there instead of breaking the
convention. Nobody's stopping you from writing an abstract
BaseUserProfile model with an FK to User and custom UserProfile
subclasses. I just don't see any advantages in going down that path.

Because how will you access every user if you ever need to? What if
someone gets promoted? How will you separate view from model logic?
Are you going to rewrite forms for every user class? That's probably
going to be hard to maintain.


FWIW, profiles are the canonical solution. They are also the only
elegant solution, at least until the app loading branch lands on
trunk, which should then allow you to register a different class as
User. But that won't happen any time soon..


Cheers,
AT

On 8/18/11, Matt Schinckel  wrote:
> Lately, I have been looking at using subclasses of auth.User as a way of
> segmenting users.
>
> This appears (to me, at this stage, anyway) to have several advantages over
> using the UserProfile approach.
>
> * You can have extra attributes on the subclass. For instance, one set of
> users belong to a Company, and I can do this FK relation from the subclass.
> Similarly, I can have a date_of_birth field that is attached to the user,
> rather than the UserProfile. From a performance perspective, this doesn't
> make a lick of difference, as a subclass of a concrete class still has a
> join anyway.
> * You can easily have different user classes appear differently in the
> admin.
> * You can have different relationships between particular User types and
> other objects. For instance, a Staff user may 'work_at' a Location, but an
> 'AreaManager' may have a 'manages' relationship to an Area. You can still do
> this with auth.User, but every user will have every relationship.
>
> The biggest helper for this was to have an authentication backend that
> automatically selects the subclass, so that you no longer get a User object
> in request.user, but whatever you want.
>
> A drawback is that you can't easily change the field types: email, which I
> use for authentication, needs to be unique. You can handle this with
> validation checking on forms, but that requires you to remember to build
> this into your forms. The other way is to monkey-patch the User class
> directly, and manually fix the database to not allow duplicates on the email
> column.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Y6qCTdPzU9sJ.
> 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.
>
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google 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 view and add related objects on both sides of an m2m field in admin

2011-08-18 Thread br
It seems that by definition, an M2M field is basically symettrical, at
least underneath.  However,  I'm having trouble figuring out how to
access and set M2M fields in the Django Admin via the Model that
doesn't declare the M2M.

Here is the example I've been working with to try to figure it out:

class Movie(models.Model):
name = models.CharField(max_length=50)

class Actor(models.Model):
name = models.CharField(max_length=50)
movie_set = models.ManyToManyField(Movie)

admin.site.register(Movie)
admin.site.register(Actor)


I can set the Movies for the Actor, but I'd like to be able to do
both: set Movies for Actor, or set Actors for Movie.  Is this readily
doable in Django Admin?  I tried using an Inline, but it wanted a
ForeignKey not an M2M.

-- 
You received this message because you are subscribed to the Google 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: problem with a graph image in template

2011-08-18 Thread smartaz
Hi, thank you for your response
It seems that there is an error when I asked for help in google
translation
i have
a form
 two views: plot(request) who return an httpresponse and
showgraph(request) who return a template (affichage.html)
  call the function plot(request)
in my views and return an httpresponse with this url (r $' ^plot/
image.png ', 'plot ') the response is  just an html file where python
write the image. This works when i call directly the function
plot(request) and ask to return an httpresponse.
The 500 error is when I try to go through show_graph function to
display the response in a template ( with url (r $' ^show_graph/image.png ', 'show_graph
') : in this template I put just a link to the image, as explained in
the documentation for Django
I think the error is in image.png GET, a python syntax error but I can
not think where (I do not know how to retrieve the trace of a 500
error in django, I installed django debug toolbar) it seems that
python can not write the file with the image ..the content type? ..I
don't understand, .this second view works when i ask an httpresponse
instead of the template
At this time i can run everything  by saving the image on the server
disk but it is not an option in production,  would require that all
things be done in memory in an HttpResponse

Thanks

On 18 août, 22:16, Reinout van Rees  wrote:
> On 17-08-11 21:32, smartaz wrote:
>
> > if I call this view for an url: (r $' ^plot / image.png ', 'contact ')
> > which comes from a form where I put
> >  > "Post">  {% csrf_token %}
> > the graph is correctly displayed as picture in a page html
> > http: // 127.0.0.1:8000 / graphs / contact / image.png
>
> That url doesn't seem to match the url you gave above. That makes it
> hard to guess what goes wrong.
>
> > If I pass by another view to show picture in a template Django,
> > I have an Internal Server Error 500 systematically
>
> So: what is the error? Getting an error 500 can mean anything from "disk
> full" to "python syntax error".
>
> Perhaps there's a difference that your first example is a POST to that
> image? And  means a GET request?
>
> > by putting in the
> > template a simple tag  in the template
>
> That src attribute again doesn't seem to match your original url.
>
> Reinout
>
> --
> Reinout van Rees                    http://reinout.vanrees.org/
> rein...@vanrees.org            http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul 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: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread michael kapelko
I think about 50 users, but Django for each sounds too much.

-- 
You received this message because you are subscribed to the Google 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: Best approach to handling different types of Users

2011-08-18 Thread Matt Schinckel
Lately, I have been looking at using subclasses of auth.User as a way of 
segmenting users.

This appears (to me, at this stage, anyway) to have several advantages over 
using the UserProfile approach.

* You can have extra attributes on the subclass. For instance, one set of 
users belong to a Company, and I can do this FK relation from the subclass. 
Similarly, I can have a date_of_birth field that is attached to the user, 
rather than the UserProfile. From a performance perspective, this doesn't 
make a lick of difference, as a subclass of a concrete class still has a 
join anyway.
* You can easily have different user classes appear differently in the 
admin.
* You can have different relationships between particular User types and 
other objects. For instance, a Staff user may 'work_at' a Location, but an 
'AreaManager' may have a 'manages' relationship to an Area. You can still do 
this with auth.User, but every user will have every relationship.

The biggest helper for this was to have an authentication backend that 
automatically selects the subclass, so that you no longer get a User object 
in request.user, but whatever you want.

A drawback is that you can't easily change the field types: email, which I 
use for authentication, needs to be unique. You can handle this with 
validation checking on forms, but that requires you to remember to build 
this into your forms. The other way is to monkey-patch the User class 
directly, and manually fix the database to not allow duplicates on the email 
column.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Y6qCTdPzU9sJ.
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 Not Populating AutoField

2011-08-18 Thread Shawn Milochik
As defined your id field doesn't differ from Django's default. Just get 
rid of your custom id field.



--
You received this message because you are subscribed to the Google 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: models.py datetimefield mysql datetime problem

2011-08-18 Thread furiston
ok guys, no need any help, i have solved it. it was all about altering
the database with manage.py sql ... i did the procedure from
beginning, it automatically solved.

thanks


On Aug 19, 2:51 am, furiston  wrote:
> i could not recognize the problem when i add a datetimefield to my
> model i can't get that model on admin page.
> i use mysql. without datetimefield it works. but when comes to add
> datetimefield to the model it stucks i get that error message. (ok. i
> didn't create 500.html, but i will :))
>
> Traceback (most recent call last):
>
>   File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py",
> line 279, in run
>     self.result = application(self.environ, self.start_response)
>
>   File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py",
> line 651, in __call__
>     return self.application(environ, start_response)
>
>   File "/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py",
> line 241, in __call__
>     response = self.get_response(request)
>
>   File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
> line 134, in get_response
>     return self.handle_uncaught_exception(request, resolver, exc_info)
>
>   File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
> line 166, in handle_uncaught_exception
>     return callback(request, **param_dict)
>
>   File "/usr/lib/pymodules/python2.6/django/views/defaults.py", line
> 23, in server_error
>     t = loader.get_template(template_name) # You need to create a
> 500.html template.
>
>   File "/usr/lib/pymodules/python2.6/django/template/loader.py", line
> 81, in get_template
>     source, origin = find_template_source(template_name)
>
>   File "/usr/lib/pymodules/python2.6/django/template/loader.py", line
> 74, in find_template_source
>     raise TemplateDoesNotExist, name
>
> TemplateDoesNotExist: 500.html

-- 
You received this message because you are subscribed to the Google 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: Anyone use mod_security with Django?

2011-08-18 Thread Reinout van Rees

On 18-08-11 22:42, Shawn Milochik wrote:

This was actually discussed in a talk by Adam Baldwin at DjangoCon 2010:
http://www.ngenuity-is.com/blog/2010/sep/10/pony-pwning-djangocon-2010/


Ah, that's useful!


I don't believe it's a good idea at all to disregard something like
mod_security just because we're using Django, because mod_security isn't
limited to duplicating what Django protects against by default.


You're probably right. I don't know the full range of what mod_security 
protects against.


My reaction was more the other side of the coin: don't feel secure 
"just" because you put mod_security in front if you don't fully know 
what that protects against and what actually needs protecting in Django.
Otherwise you're just installing mod_security because it protects 
against crsf and because that sounds secure even though Django protects 
against that just fine ;-)




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul 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.



Django Not Populating AutoField

2011-08-18 Thread Lee Hughes
In my model I have

id = models.AutoField(primary_key=True)

but upon saving a new record I get

null value in column "id" violates not-null constraint

I suspect this may be caused by my overriding save_model in admin.py to
populate timestamp fields:

  def save_model(self, request, obj, form, change):
if change:
  obj.updated_by = request.user.username
else:
  obj.created_by = request.user.username
obj.save()

Any ideas on how to restore the AutoField functionality?

Thanks-

-- 
Lee

-- 
You received this message because you are subscribed to the Google 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.



models.py datetimefield mysql datetime problem

2011-08-18 Thread furiston
i could not recognize the problem when i add a datetimefield to my
model i can't get that model on admin page.
i use mysql. without datetimefield it works. but when comes to add
datetimefield to the model it stucks i get that error message. (ok. i
didn't create 500.html, but i will :))

Traceback (most recent call last):

  File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py",
line 279, in run
self.result = application(self.environ, self.start_response)

  File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py",
line 651, in __call__
return self.application(environ, start_response)

  File "/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py",
line 241, in __call__
response = self.get_response(request)

  File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
line 134, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)

  File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
line 166, in handle_uncaught_exception
return callback(request, **param_dict)

  File "/usr/lib/pymodules/python2.6/django/views/defaults.py", line
23, in server_error
t = loader.get_template(template_name) # You need to create a
500.html template.

  File "/usr/lib/pymodules/python2.6/django/template/loader.py", line
81, in get_template
source, origin = find_template_source(template_name)

  File "/usr/lib/pymodules/python2.6/django/template/loader.py", line
74, in find_template_source
raise TemplateDoesNotExist, name

TemplateDoesNotExist: 500.html

-- 
You received this message because you are subscribed to the Google 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: Work in memory instead of BD, how to?

2011-08-18 Thread Felipe Arruda
Humm, I see, the second case I could make out of it somehow(just have
some doubts in 2.5: How am I supposed to do this?)
The first one I could't see how I'm not going to lose the changes,
done in cache.
My biggest problem is in altering some value in some models, since
this operation will be done many times, and I can't do if not by
this(so that the client infos wont be any different from the DB), and
for what I understand from this solution I would work if my operations
where simple retrieving data from the server and doing some
calculation, but will lose the informations in cache(substituting it
from the DB. I want it to be otherwise).

And about the django-celery: Never heard about it, but now I'm going
to use it(but for other purposes, and other projects too). Thanks for
the tip!

Another thing. I thought of doing something like this:
Use MemCache, and the second ideia presented, put like a very long
time, and run a parallel task(using celery? or maybe some thing in
django-extensions that integrate with cron), so that from time to
time(a more reasonable time then the timeout from the cache) it will
get every info from cache and save it in the DB.
This way, in the worst case, every 10 minutes the system would have a
small halt to save things(or could make a more complex way to save
each register in different times).
What do you thing about it? To much POG, or is in the right track?

On Aug 18, 3:57 pm, Doug Ballance  wrote:
> You probably don't want to cache changes.  Or if you do, it would be
> better done elsewhere (like a caching raid controller/w battery on
> your database machine).  The usual cache patterns I've seen are:
>
> 1) Fetch from database
> 2) Store in cache with a reasonable timeout to that changes are
> reflected as the cache expires
> 3) Look in cache, if found return that.  If not goto step (1)
>
> or
>
> 1) Fetch from database
> 2) Store in cache with a -long- timeout
> 2.5) Track changes to cached objects and update the stored information
> if it changes.
> 3) Look in cache, if found return it.  if not goto step(1)
>
> since the changes won't be reflected as rapidly due to the long
> timeout, you can configure the post_save/post_delete/etc signals to
> automatically update the cached value every time a change is made to
> one of that models instances.  This is what the django-cache-utils app
> is doing for you.  The trick is that the more complicated your use,
> the more complex the cache invalidation is going to have to be.
>
> Another possiblity is that caching may be the wrong solution to your
> problem. If for example a web request need to do so a bunch of
> expensive operations, but does not need to do them interactively with
> your user, a solution like django-celery may be better.  With celery
> the job gets scheduled for execution outside of the web request-
> response system (possibly even on another machine) and gives you a job
> id.  This allows the user to get on with things, leaving the work to
> be done behind the scenes.  If the user needs to know the results or
> state of the job  you can use ajax or refreshing to check back using
> the id to retreive the results when the job completes.

-- 
You received this message because you are subscribed to the Google 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 display an AutoField primary key on Admin change list and edit form?

2011-08-18 Thread Lee Hughes
My existing database schema has a primary key field named "id" in every
table. I want to have Django Admin automatically populate this field and
display it in read-only mode in both the change list and edit form.

Because the field name is "id", I understand that this will automatically be
included in the model: id = models.AutoField(primary_key=True)

Including "id" in the ModelAdmin list_display makes it appear on the change
list, but trying to force it to display on the edit form by including it in
the ModelAdmin "fields" property produces this error on the edit form:

'MyModelAdmin.fields' refers to field 'id' that is missing from the form


So, how do I add it to the form?

Thanks for any help or ideas.
-- 
Lee

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



Re: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread Gelonida N
How many different users are connected at the same time?

Would it be feasable to start one django prcoess for each connected user?


On 08/18/2011 11:55 AM, michael kapelko wrote:
> I think I have to emulate Delphi app with a server process, and make
> Django interact with the process. The process can login to DB
> directly. That's not so easy, but I guess that's the only option here
> - move Delphi app from client machine to server one.
> 


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



Re: Best way to show/hide the logout link in a template?

2011-08-18 Thread Andre Lopes
Thanks Kev,

It was exactly what I needed.

Regards,


On Thu, Aug 18, 2011 at 10:45 PM, Kev Dwyer  wrote:
> Andre Lopes wrote:
>
>> Hi,
>>
>> I am new to Django... I have made a logout link, but now I am in doubt
>> on which the best way to show/hide this template tag:
>>
>> [code]
>> Logout
>> [/code]
>>
>> Which is the best way of show/hide this link?
>>
>> Sorry if it is a basic question.
>>
>>
>> Best Regards,
>>
>
> I use
>
> {% if user.is_authenticated %}
>
> to condition my logout link's appearance.
>
> See https://docs.djangoproject.com/en/1.3/topics/auth/#authentication-data-
> in-templates
>
> Cheers,
>
> Kev
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: Best way to show/hide the logout link in a template?

2011-08-18 Thread Kev Dwyer
Andre Lopes wrote:

> Hi,
> 
> I am new to Django... I have made a logout link, but now I am in doubt
> on which the best way to show/hide this template tag:
> 
> [code]
> Logout
> [/code]
> 
> Which is the best way of show/hide this link?
> 
> Sorry if it is a basic question.
> 
> 
> Best Regards,
> 

I use

{% if user.is_authenticated %}

to condition my logout link's appearance.

See https://docs.djangoproject.com/en/1.3/topics/auth/#authentication-data-
in-templates

Cheers,

Kev

-- 
You received this message because you are subscribed to the Google 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 Relation in django-taggit

2011-08-18 Thread Eyad Al-Sibai
 I have created the following TagBase and each category can have
subcategory... Will this work? How can I override its add function in the
TaggableManager?

 class Category(TagBase):


parent = models.ForeignKey('self', blank=True, null=True,


   related_name='child')


description = models.TextField(blank=True, help_text="Optional")


class Meta:


verbose_name = _('Category')


verbose_name_plural = _('Categories')

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



Best way to show/hide the logout link in a template?

2011-08-18 Thread Andre Lopes
Hi,

I am new to Django... I have made a logout link, but now I am in doubt
on which the best way to show/hide this template tag:

[code]
Logout
[/code]

Which is the best way of show/hide this link?

Sorry if it is a basic question.


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



Django reloader fails to watch all the project files

2011-08-18 Thread rwman
Hi. I bumped into a problem with djnago autoreloader (using standard 
runserver command) recently - when i update my views.py file it does not 
reload the server automatically. (while it does, if i update my project's 
settings.py file)
Looking at the code (django/utils/autoreload.py) - i discovered, that it 
watches sys.modules list(dict, actually). And after some debugging i found, 
that my app's views.py never gets into this list.
i am no expert in python, and will appreciate any help in finding answers.
Can anyone please tell me, 
- is it a bug? (or no - updating views.py should not trigger autoreload?)
- how 'settings.py' appeared in the sys.modules?(what code makes it get in 
there) and why 'some_app.views.py' does not?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/SXecMqFIiQYJ.
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: Anyone use mod_security with Django?

2011-08-18 Thread Shawn Milochik

This was actually discussed in a talk by Adam Baldwin at DjangoCon 2010:
http://www.ngenuity-is.com/blog/2010/sep/10/pony-pwning-djangocon-2010/

I don't believe it's a good idea at all to disregard something like 
mod_security just because we're using Django, because mod_security isn't 
limited to duplicating what Django protects against by default.


Also, never assume that anything is secure just because it uses Django, 
because any developer can easily make a mistake or do something due to 
inexperience which can negate any of Django's protections.


--
You received this message because you are subscribed to the Google 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: Anyone use mod_security with Django?

2011-08-18 Thread Reinout van Rees

On 18-08-11 18:35, KC LEE wrote:

  Hi,

  I am running a website built with Django.

  For security, I am going to install mod_security on my web server.

  Anyone use mod_security with Django? Is mod_security useful?

  I heard that Django can defend many attacks (like csrf, XSS, SQL
Injection... and so on...)


The way django is build prevents those common attacks. You won't need 
protection against sql injection, for instance, as it is simply not a 
problem with django.


mod_security looks like something that needs both care and knowledge to 
set up properly. So you yourself will need to gain knowledge on what 
mod_security actually does and how to configure it.


Personally, I've never heard of anyone using it for Django and I'd be 
surprised if it is needed.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul 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: How to change the schma of database using python manage.py syncdb?

2011-08-18 Thread Shawn Milochik

On 08/18/2011 04:22 PM, Mike Seidle wrote:


When I started with Django, I ran into the same issue... seemed kind of silly
that we had this amazing framework that did so much but it had no way to
really alter tables...   Enter South. South works pretty well, but if you roll
your own ModelFields it can be tricky as you have to write your own
migrations.




Why do you have to write your own migrations? South handles non-standard 
fields just fine with its add_introspection_rules check.


--
You received this message because you are subscribed to the Google 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: 'dict' object has no attribute 'META'

2011-08-18 Thread Reinout van Rees

On 18-08-11 17:44, MikeKJ wrote:

'dict' object has no attribute 'META'

...

 ▶ Local vars
 /var/www/django/eco/django/core/context_processors.py in debug
 if settings.DEBUG and request.META.get('REMOTE_ADDR') in
settings.INTERNAL_IPS: ...


Apparently the request is now a 'dict' object instead of a real django 
request object.


Do you have some middleware or so that does something to the request? 
Does your view modify the request, inadvertently modifying it into a dict?


Just brainstorming about possible causes :-)



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul 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: How to change the schma of database using python manage.py syncdb?

2011-08-18 Thread Mike Seidle
On Thursday, August 18, 2011 12:03:00 pm smith jack wrote:
> at last, i use command  python manage.py syncdb
> 
> but was suprised to find that the schema of url table in the database
> is not changed
> 
> so is there any method to change the shcema of table using django command?

When I started with Django, I ran into the same issue... seemed kind of silly 
that we had this amazing framework that did so much but it had no way to 
really alter tables...   Enter South. South works pretty well, but if you roll 
your own ModelFields it can be tricky as you have to write your own 
migrations.  

-- 
You received this message because you are subscribed to the Google 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: problem with a grph image in template

2011-08-18 Thread Reinout van Rees

On 17-08-11 21:32, smartaz wrote:


if I call this view for an url: (r $' ^plot / image.png ', 'contact ')
which comes from a form where I put
  {% csrf_token %}
the graph is correctly displayed as picture in a page html
http: // 127.0.0.1:8000 / graphs / contact / image.png


That url doesn't seem to match the url you gave above. That makes it 
hard to guess what goes wrong.



If I pass by another view to show picture in a template Django,
I have an Internal Server Error 500 systematically


So: what is the error? Getting an error 500 can mean anything from "disk 
full" to "python syntax error".


Perhaps there's a difference that your first example is a POST to that 
image? And  means a GET request?



by putting in the
template a simple tag  in the template


That src attribute again doesn't seem to match your original url.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul 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: 'dict' object has no attribute 'META'

2011-08-18 Thread Daniel Roseman
On Thursday, 18 August 2011 16:44:51 UTC+1, MikeKJ wrote:
>
>
> I have this old site that was originally pre magic and got ported up 0.96
> where it still is and now have to make some alterations, this is a clone
> site to do something different but the same BUT on getting to the
> subsubcategory level (sorry my naming conventions back then really sucked) 
> I
> am getting, which is weird because the code is the same as the original 
> site
> that is working down to subsub level UH?
>
> 'dict' object has no attribute 'META'
>
> Exception Location: /var/www/django/eco/django/core/context_processors.py
> in debug, line 34
>
>
> Traceback
>
> Traceback Switch to copy-and-paste view
>
> /var/www/django/eco/django/core/handlers/base.py in get_response
> response = callback(request, *callback_args, **callback_kwargs) ...
> ▶ Local vars
> /var/www/django/project/kitchens_bathrooms/views.py in subsub_cat
> return render_to_response('kitchens_bathrooms/subsub.html',
>
> RequestContext({'products':products,'banner':current_subsub_cat.get_banner(),
> 'resource': current_subsub_cat.get_resource(), 'sub_cats': master_sub_cats,
>
> 'sub_cat':current_sub_cat,'masters':masters,'master':current_master,'subsub_cats':master_subsub_cats,
> 'subsub_cat':current_subsub_cat,'urlswitch':
> urlswitch,'brand_link':brand_link, 'brand_id':brand_id})) ...
> ▶ Local vars
> /var/www/django/eco/django/template/context.py in __init__
> self.update(processor(request)) ...
> ▶ Local vars
> /var/www/django/eco/django/core/context_processors.py in debug
> if settings.DEBUG and request.META.get('REMOTE_ADDR') in
> settings.INTERNAL_IPS: ...
> ▶ Local vars 
>
> There is no GET or POST data 
> HTTP_REFERER 
> '
> http://domain/kitchens_bathrooms/water-saving-taps/water-saving-basin-taps/
> '
> PATH_INFO 
>
> '/kitchens_bathrooms/water-saving-taps/water-saving-basin-taps/mono-basin-taps/'
>
> Anyone have any ideas please because I am just going round in ever
> decreasing circles??
>
> Yeah I know port it to latest version and sort out the naming and also dont
> use slug to navigate the urls but you all know how it is
>

The first parameter to RequestContext should always be the request, not the 
context dict. I don't think that has ever been different - see for example 
the class as of four years ago:
https://code.djangoproject.com/browser/django/trunk/django/template/context.py?rev=6975#L96
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/nJoI-aDaAy4J.
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: Anyone use mod_security with Django?

2011-08-18 Thread vikas ruhil
I am also looking for the same HELP ANYONE?

On Thu, Aug 18, 2011 at 10:05 PM, KC LEE  wrote:

>  Hi,
>
>  I am running a website built with Django.
>
>  For security, I am going to install mod_security on my web server.
>
>  Anyone use mod_security with Django? Is mod_security useful?
>
>  I heard that Django can defend many attacks (like csrf, XSS, SQL
> Injection... and so on...)
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: Work in memory instead of BD, how to?

2011-08-18 Thread Doug Ballance
You probably don't want to cache changes.  Or if you do, it would be
better done elsewhere (like a caching raid controller/w battery on
your database machine).  The usual cache patterns I've seen are:

1) Fetch from database
2) Store in cache with a reasonable timeout to that changes are
reflected as the cache expires
3) Look in cache, if found return that.  If not goto step (1)

or

1) Fetch from database
2) Store in cache with a -long- timeout
2.5) Track changes to cached objects and update the stored information
if it changes.
3) Look in cache, if found return it.  if not goto step(1)

since the changes won't be reflected as rapidly due to the long
timeout, you can configure the post_save/post_delete/etc signals to
automatically update the cached value every time a change is made to
one of that models instances.  This is what the django-cache-utils app
is doing for you.  The trick is that the more complicated your use,
the more complex the cache invalidation is going to have to be.

Another possiblity is that caching may be the wrong solution to your
problem. If for example a web request need to do so a bunch of
expensive operations, but does not need to do them interactively with
your user, a solution like django-celery may be better.  With celery
the job gets scheduled for execution outside of the web request-
response system (possibly even on another machine) and gives you a job
id.  This allows the user to get on with things, leaving the work to
be done behind the scenes.  If the user needs to know the results or
state of the job  you can use ajax or refreshing to check back using
the id to retreive the results when the job completes.

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



Re: How to change the schma of database using python manage.py syncdb?

2011-08-18 Thread Shawn Milochik
As was mentioned previously, South is the best solution in Django at 
this time.


south.aeracode.org

The docs are good, there's a Google Group you can join, and plenty of 
people on this list use it all the time and can help with it.


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: Work in memory instead of BD, how to?

2011-08-18 Thread Felipe Arruda
Ok, so I've read this topics(and also the django-cache-utils, although
I didn't understand this one much).
So I can serialize the objects and save them in cache, ok, but, when
the cache timesout I'll lose the data that was changed and saved in
the cache, isn't it?
Is there a way to to this in the cache? To tell him that when about to
delete by timeout, instead should update the DB? Or I need to create
my own cache?

On 18 ago, 11:36, Andre Terra  wrote:
> You can use the cache framework for pretty much anything you want, including
> saving serialized results of calculations, querysets and whatnot.
>
> Please 
> read:https://docs.djangoproject.com/en/dev/topics/cache/https://docs.djangoproject.com/en/dev/topics/cache/#the-low-level-cac...https://docs.djangoproject.com/en/dev/topics/serialization/
>
> And check out django-cache-utils, a third party app which spares you from
> reinventing the wheel:http://bitbucket.org/kmike/django-cache-utils/
>
> Cheers,
> AT
>
> On Thu, Aug 18, 2011 at 10:22 AM, Felipe Arruda <
>
>
>
>
>
>
>
> felipe.arruda.pon...@gmail.com> wrote:
> > Hi there, I was doing some project recently and faced a problem of
> > performance.
> > I need to be able to do a lot of access to some information on the DB,
> > almost all the time, and doing so seams to be taking too long.
>
> > Is it possible do do something like this:
> > Get the infos from the BD and put them in memory, then when I save() a
> > model or get()/filter() it will get from the memory.
> > And from time to time, the memory will update this info in the DB.
>
> > If this is possible, then how should I do it?
>
> > Using the Cache Framework? Ins't this one just for static files?
> > Thanks for the 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.

-- 
You received this message because you are subscribed to the Google 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.



Anyone use mod_security with Django?

2011-08-18 Thread KC LEE
 Hi,

 I am running a website built with Django.

 For security, I am going to install mod_security on my web server.

 Anyone use mod_security with Django? Is mod_security useful?

 I heard that Django can defend many attacks (like csrf, XSS, SQL
Injection... and so on...)

-- 
You received this message because you are subscribed to the Google 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: GenericIPAddressField validation error not translated

2011-08-18 Thread Andre Terra
https://docs.djangoproject.com/en/dev/internals/contributing/translations/

On Thu, Aug 18, 2011 at 12:28 PM, Federico Capoano  wrote:

> How can I contribute?
>
>
> On Aug 13, 6:50 am, Karen Tracey  wrote:
> > On Thu, Aug 11, 2011 at 2:58 PM, Federico Capoano
> > wrote:
> >
> > > Hi all,
> >
> > > i'm using the new GenericIPAddressField and validation errors are not
> > > translated to the language of my project.
> >
> > > Pheraps this field hasn't been internationalized yet?
> >
> > Correct. Updating translations are done as part of the release process.
> If
> > you're pulling new code out of the repo, it won't have translations.
> >
> > Karen
> > --http://tracey.org/kmt/
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: Getting and modifying url parameters in template: howto?

2011-08-18 Thread Andre Terra
Assuming I understood what you're trying to do, why not write a template tag
(more specifically, an inclusion tag)?


Cheers,
AT

On Thu, Aug 18, 2011 at 11:47 AM, samuele.mattiuzzo wrote:

> I'm not using haystack, since is strictly model-related. My solr
> instance isnt' bound to any model (since i don't use any backend DB to
> store my data)
>
> i need something like get_full_path or get_absolute_url, but not
> modell-related in this case...
>
>
>
> On 18 Ago, 16:37, Andre Terra  wrote:
> > Searching with Django =http://haystacksearch.org/
> >
> > Behold the power of pluggable apps.
> >
> > Cheers,
> > AT
> >
> > On Thu, Aug 18, 2011 at 11:34 AM, samuele.mattiuzzo  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi!
> > > I'm stuck with a problem... more confused than stuck, actually.
> >
> > > I have a search engine i'm working on, and we're using GET method to
> > > perform searches. In the listing page, i have my search results on the
> > > left and some filters on the right, something like google's filter.
> >
> > > my filters are all blabla
> >
> > > what i need to do, and i don't know how, is:
> >
> > > 1 - get url parameters
> > > 2 - for each filter modify the correct parameter
> >
> > > example:
> >
> > >www.mysite.com/?name=apple=now=male
> >
> > > for "name" filters:
> >
> > > new_val
> >
> > > i don't know what to look for, maybe the {{ url }} tag can help me,
> > > but i don't know how to get_and_modify a specific param :(
> >
> > > can anybody help me? 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.
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

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



Re: How to change the schma of database using python manage.py syncdb?

2011-08-18 Thread MikeKJ

Another alternative would be to access mysql from a shell and add the column
to the relevant table

mysql>> alter table x add column hits int(11) null;  for example




thinke365 wrote:
> 
> for example at first i have a model named url, the code is as follows:
> 
> class url(models.Model):
>  link=models.URLField(unique=True)
> 
> then i change this class as follows:
> 
> class url(models.Model):
>  link=models.URLField(unique=True)
>  hits=models.IntegerField()
> 
> at last, i use command  python manage.py syncdb
> 
> but was suprised to find that the schema of url table in the database
> is not changed
> 
> so is there any method to change the shcema of table using django command?
> 
> -- 
> You received this message because you are subscribed to the Google 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 this message in context: 
http://old.nabble.com/How-to-change-the-schma-of-database-using-python-manage.py-syncdb--tp32288667p32288737.html
Sent from the django-users mailing list archive at Nabble.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: RPC for python functions in a Django project

2011-08-18 Thread David
I'm the developer of rpc4django. The package does support SMD
generation and it makes it available in the system.describe() method
by default. However, JSONRPC is not nearly as well defined as XMLRPC
and nobody seems to agree exactly how an SMD should look let alone
what SMD even stands for. I tried to stick fairly close to the draft
specs, but it's somewhat of a moving target.



On Aug 18, 7:34 am, Muhammad Choudry 
wrote:
> Thanks!  This module didn't come across in my search.
>
> I just skimmed through the files and it seems as if the module doesn't
> support automatic SMD generation.  Is this true?
>
> On Aug 17, 5:43 pm, Gelonida N  wrote:
>
>
>
>
>
>
>
> > Hi Muhammad,
>
> > On 08/17/2011 08:18 PM, MuhammadChoudrywrote:
>
> > >  I've
> > > found that JSON-RPC is a good way to go for this, as there is
> > > typically built in support for this in javascript in addition to the
> > > numerous additional benefits.
>
> > > I've seen several ways to do this:
> > > 1) Create a unique URI for each function that you would like to
> > > access:
> > >https://code.djangoproject.com/wiki/JSONRPCServerMiddleware
> > > 2) Create one point of access, and pass the method name in the JSON
> > > package.  In this particular example an SMD is automatically
> > > generated.
> > >https://code.djangoproject.com/wiki/Jsonrpc
>
> > > The issue with (1) is that if there are many functions to be accessed,
> > > then there will be many URI's that will be used.  This does not seem
> > > like an elegant solution.  The issue with (2) is that I need to
> > > compare functions against a list of all functions.  Again this is not
> > > an elegant solution either.
>
> > > Is there no way that we can take the advantages of (1) and (2) to
> > > create an interface such that:
> > >  - Only one URI is used as a point of access
> > >  - Functions are called directly (without having to be compared
> > > against a list of functions)
>
> > > ?
>
> > Did you look at rpc4django.
>
> > The way it works roughly:
> > - you add rpc4django to the installed apps
> > - in urls.py you create one uri for the rpc calls
> > - you simply decorate all functions, that should be available via RPC.
>
> > By default the function will be available as xmlrpc and jsonrpc function.
>
> > For more details:http://packages.python.org/rpc4django/setup.html

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



Re: How to change the schma of database using python manage.py syncdb?

2011-08-18 Thread delegbede
What I do is remove the database and them run the syncdb command again. 

Some people might recommend migrations using South. 

Regards. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: smith jack 
Sender: django-users@googlegroups.com
Date: Fri, 19 Aug 2011 00:03:00 
To: 
Reply-To: django-users@googlegroups.com
Subject: How to change the schma of database using python manage.py syncdb?

for example at first i have a model named url, the code is as follows:

class url(models.Model):
 link=models.URLField(unique=True)

then i change this class as follows:

class url(models.Model):
 link=models.URLField(unique=True)
 hits=models.IntegerField()

at last, i use command  python manage.py syncdb

but was suprised to find that the schema of url table in the database
is not changed

so is there any method to change the shcema of table using django command?

-- 
You received this message because you are subscribed to the Google 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.

-- 
You received this message because you are subscribed to the Google 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 change the schma of database using python manage.py syncdb?

2011-08-18 Thread smith jack
for example at first i have a model named url, the code is as follows:

class url(models.Model):
 link=models.URLField(unique=True)

then i change this class as follows:

class url(models.Model):
 link=models.URLField(unique=True)
 hits=models.IntegerField()

at last, i use command  python manage.py syncdb

but was suprised to find that the schema of url table in the database
is not changed

so is there any method to change the shcema of table using django command?

-- 
You received this message because you are subscribed to the Google 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.



'dict' object has no attribute 'META'

2011-08-18 Thread MikeKJ

I have this old site that was originally pre magic and got ported up 0.96
where it still is and now have to make some alterations, this is a clone
site to do something different but the same BUT on getting to the
subsubcategory level (sorry my naming conventions back then really sucked) I
am getting, which is weird because the code is the same as the original site
that is working down to subsub level UH?

'dict' object has no attribute 'META'

Exception Location: /var/www/django/eco/django/core/context_processors.py
in debug, line 34


Traceback

Traceback Switch to copy-and-paste view

/var/www/django/eco/django/core/handlers/base.py in get_response
response = callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/var/www/django/project/kitchens_bathrooms/views.py in subsub_cat
return render_to_response('kitchens_bathrooms/subsub.html',
RequestContext({'products':products,'banner':current_subsub_cat.get_banner(),
'resource': current_subsub_cat.get_resource(), 'sub_cats': master_sub_cats,
'sub_cat':current_sub_cat,'masters':masters,'master':current_master,'subsub_cats':master_subsub_cats,
'subsub_cat':current_subsub_cat,'urlswitch':
urlswitch,'brand_link':brand_link, 'brand_id':brand_id})) ...
▶ Local vars
/var/www/django/eco/django/template/context.py in __init__
self.update(processor(request)) ...
▶ Local vars
/var/www/django/eco/django/core/context_processors.py in debug
if settings.DEBUG and request.META.get('REMOTE_ADDR') in
settings.INTERNAL_IPS: ...
▶ Local vars 

There is no GET or POST data 
HTTP_REFERER
'http://domain/kitchens_bathrooms/water-saving-taps/water-saving-basin-taps/'
PATH_INFO   
'/kitchens_bathrooms/water-saving-taps/water-saving-basin-taps/mono-basin-taps/'

Anyone have any ideas please because I am just going round in ever
decreasing circles??

Yeah I know port it to latest version and sort out the naming and also dont
use slug to navigate the urls but you all know how it is


-- 
View this message in context: 
http://old.nabble.com/%27dict%27-object-has-no-attribute-%27META%27-tp32288508p32288508.html
Sent from the django-users mailing list archive at Nabble.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: GenericIPAddressField validation error not translated

2011-08-18 Thread Federico Capoano
How can I contribute?


On Aug 13, 6:50 am, Karen Tracey  wrote:
> On Thu, Aug 11, 2011 at 2:58 PM, Federico Capoano
> wrote:
>
> > Hi all,
>
> > i'm using the new GenericIPAddressField and validation errors are not
> > translated to the language of my project.
>
> > Pheraps this field hasn't been internationalized yet?
>
> Correct. Updating translations are done as part of the release process. If
> you're pulling new code out of the repo, it won't have translations.
>
> Karen
> --http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google 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: Getting and modifying url parameters in template: howto?

2011-08-18 Thread samuele.mattiuzzo
I'm not using haystack, since is strictly model-related. My solr
instance isnt' bound to any model (since i don't use any backend DB to
store my data)

i need something like get_full_path or get_absolute_url, but not
modell-related in this case...



On 18 Ago, 16:37, Andre Terra  wrote:
> Searching with Django =http://haystacksearch.org/
>
> Behold the power of pluggable apps.
>
> Cheers,
> AT
>
> On Thu, Aug 18, 2011 at 11:34 AM, samuele.mattiuzzo wrote:
>
>
>
>
>
>
>
> > Hi!
> > I'm stuck with a problem... more confused than stuck, actually.
>
> > I have a search engine i'm working on, and we're using GET method to
> > perform searches. In the listing page, i have my search results on the
> > left and some filters on the right, something like google's filter.
>
> > my filters are all blabla
>
> > what i need to do, and i don't know how, is:
>
> > 1 - get url parameters
> > 2 - for each filter modify the correct parameter
>
> > example:
>
> >www.mysite.com/?name=apple=now=male
>
> > for "name" filters:
>
> > new_val
>
> > i don't know what to look for, maybe the {{ url }} tag can help me,
> > but i don't know how to get_and_modify a specific param :(
>
> > can anybody help me? 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.

-- 
You received this message because you are subscribed to the Google 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: Getting and modifying url parameters in template: howto?

2011-08-18 Thread Andre Terra
Searching with Django = http://haystacksearch.org/

Behold the power of pluggable apps.


Cheers,
AT

On Thu, Aug 18, 2011 at 11:34 AM, samuele.mattiuzzo wrote:

> Hi!
> I'm stuck with a problem... more confused than stuck, actually.
>
> I have a search engine i'm working on, and we're using GET method to
> perform searches. In the listing page, i have my search results on the
> left and some filters on the right, something like google's filter.
>
> my filters are all blabla
>
> what i need to do, and i don't know how, is:
>
> 1 - get url parameters
> 2 - for each filter modify the correct parameter
>
> example:
>
> www.mysite.com/?name=apple=now=male
>
> for "name" filters:
>
> new_val
>
> i don't know what to look for, maybe the {{ url }} tag can help me,
> but i don't know how to get_and_modify a specific param :(
>
> can anybody help me? 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: Work in memory instead of BD, how to?

2011-08-18 Thread Andre Terra
You can use the cache framework for pretty much anything you want, including
saving serialized results of calculations, querysets and whatnot.

Please read:
https://docs.djangoproject.com/en/dev/topics/cache/
https://docs.djangoproject.com/en/dev/topics/cache/#the-low-level-cache-api
https://docs.djangoproject.com/en/dev/topics/serialization/


And check out django-cache-utils, a third party app which spares you from
reinventing the wheel:
http://bitbucket.org/kmike/django-cache-utils/



Cheers,
AT


On Thu, Aug 18, 2011 at 10:22 AM, Felipe Arruda <
felipe.arruda.pon...@gmail.com> wrote:

> Hi there, I was doing some project recently and faced a problem of
> performance.
> I need to be able to do a lot of access to some information on the DB,
> almost all the time, and doing so seams to be taking too long.
>
> Is it possible do do something like this:
> Get the infos from the BD and put them in memory, then when I save() a
> model or get()/filter() it will get from the memory.
> And from time to time, the memory will update this info in the DB.
>
> If this is possible, then how should I do it?
>
> Using the Cache Framework? Ins't this one just for static files?
> Thanks for the 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.
>
>

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



Getting and modifying url parameters in template: howto?

2011-08-18 Thread samuele.mattiuzzo
Hi!
I'm stuck with a problem... more confused than stuck, actually.

I have a search engine i'm working on, and we're using GET method to
perform searches. In the listing page, i have my search results on the
left and some filters on the right, something like google's filter.

my filters are all blabla

what i need to do, and i don't know how, is:

1 - get url parameters
2 - for each filter modify the correct parameter

example:

www.mysite.com/?name=apple=now=male

for "name" filters:

new_val

i don't know what to look for, maybe the {{ url }} tag can help me,
but i don't know how to get_and_modify a specific param :(

can anybody help me? 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: RPC for python functions in a Django project

2011-08-18 Thread Muhammad Choudry
Thanks!  This module didn't come across in my search.

I just skimmed through the files and it seems as if the module doesn't
support automatic SMD generation.  Is this true?

On Aug 17, 5:43 pm, Gelonida N  wrote:
> Hi Muhammad,
>
> On 08/17/2011 08:18 PM, MuhammadChoudrywrote:
>
>
>
>
>
>
>
> >  I've
> > found that JSON-RPC is a good way to go for this, as there is
> > typically built in support for this in javascript in addition to the
> > numerous additional benefits.
>
> > I've seen several ways to do this:
> > 1) Create a unique URI for each function that you would like to
> > access:
> >https://code.djangoproject.com/wiki/JSONRPCServerMiddleware
> > 2) Create one point of access, and pass the method name in the JSON
> > package.  In this particular example an SMD is automatically
> > generated.
> >https://code.djangoproject.com/wiki/Jsonrpc
>
> > The issue with (1) is that if there are many functions to be accessed,
> > then there will be many URI's that will be used.  This does not seem
> > like an elegant solution.  The issue with (2) is that I need to
> > compare functions against a list of all functions.  Again this is not
> > an elegant solution either.
>
> > Is there no way that we can take the advantages of (1) and (2) to
> > create an interface such that:
> >  - Only one URI is used as a point of access
> >  - Functions are called directly (without having to be compared
> > against a list of functions)
>
> > ?
>
> Did you look at rpc4django.
>
> The way it works roughly:
> - you add rpc4django to the installed apps
> - in urls.py you create one uri for the rpc calls
> - you simply decorate all functions, that should be available via RPC.
>
> By default the function will be available as xmlrpc and jsonrpc function.
>
> For more details:http://packages.python.org/rpc4django/setup.html

-- 
You received this message because you are subscribed to the Google 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: m2m assignments lost when saving in admin but not shell

2011-08-18 Thread Shawn Milochik

On 08/18/2011 09:24 AM, Andre Terra wrote:

Your instance is probably not yet saved to the database, so the
m2m-related objects don't know which instance to connect to. There's
problem something wrong in your save() method. I often use "assert
False, some_var" to check if at some point the variable is already set
or not.



This is definitely not the case, because these are always records that 
already exist, if I'm editing them in the admin.


--
You received this message because you are subscribed to the Google 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: help error in form usage

2011-08-18 Thread Derek
The Django Book is a useful general introduction; but now more than 2
years old.  In a framework like Django, which is under constant
development, such old information gets out-of-date very fast.  Tom
correctly pointed you to the docs; and that is really the best place
to work from now that you are doing specific development.

On Aug 16, 6:02 pm, Phang Mulianto  wrote:
> Oh i see..
>
> i read the manual, the django book, no such information about that..
> oh my..better update the manual there..
>
> thanks for your quick explanation then, i think not a good way to manualy
> assign a dictionarry to the form, not like in the documentation / book of
> django. now i get it.
>
> Thanks
>
> Mulianto
>
> On Tue, Aug 16, 2011 at 11:58 PM, Tom Evans wrote:
>
>
>
>
>
>
>
> > Your form is not a model form, and so you cannot pass instance=post.
> > Since it is just a regular form, you should pass a dictionary of
> > values, with the keys of the dictionary being the names of the fields.
>
> > If the form is representing a model, you should be using a model form.
>
> >https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/
>
> > Cheers
>
> > Tom
>
> > On Tue, Aug 16, 2011 at 4:47 PM, Phang Mulianto 
> > wrote:
>
> > > hi anyone can help me...
>
> > > On Mon, Aug 15, 2011 at 12:39 PM, Phang Mulianto 
> > wrote:
>
> > >> Hi Daniel,
>
> > >> i change it to instance, but still got other errors :
>
> > >> def myadmin_change_post(request,
> > template_name='blog/admin/change_post.html'):
> > >>     try:
> > >>         id= request.GET.get('id','4')
> > >>     except ValueError:
> > >>         id=1
> > >>     #post = get_object_or_404(Post,pk=id)
> > >>     post = Post.objects.get(pk=id)
> > >>     form = AdminPostForm(instance=post)
> > >>     return render_to_response(template_name,locals(),context_instance =
> > RequestContext(request) )
>
> > >> the form :
>
> > >> class AdminPostForm(forms.Form):
>
> > >>     cat_choices = [('private','private')]
>
> > >>     title =
> > forms.CharField(widget=forms.TextInput(attrs={'size':'20','value':'','class 
> > ':''}),label='Title')
> > >>     content=
> > forms.CharField(widget=forms.Textarea(attrs={'cols':'40','rows':'5'}),label 
> > ='Content')
> > >>     slug =
> > forms.CharField(widget=forms.TextInput(attrs={'size':'20','class':''}),labe 
> > l='Slug')
> > >>     is_publish = forms.BooleanField(label='Publish')
> > >>     categories = forms.ChoiceField(choices=cat_choices)
> > >>     created_at =
> > forms.DateTimeField(widget=forms.DateTimeInput(),label='Created at')
> > >>     modified_at =
> > forms.DateTimeField(widget=forms.DateTimeInput(),label='Modified at')
>
> > >> any clue where the error migh be..
>
> > >> TypeError at /article/change/
>
> > >> __init__() got an unexpected keyword argument 'instance'
>
> > >> Request Method: GET
> > >> Request URL:http://127.0.0.1:8000/article/change/?id=2
> > >> Django Version: 1.3
> > >> Exception Type: TypeError
> > >> Exception Value:
>
> > >> __init__() got an unexpected keyword argument 'instance'
>
> > >> Exception Location:
> > C:\Users\mulianto\workspace\myblog\src\myblog\..\myblog\article\views.py in
> > myadmin_change_post, line 132
> > >> Python Executable: c:\python27\python.exe
> > >> Python Version: 2.7.2
> > >> Python Path:
>
> > >> ['C:\\Users\\mulianto\\workspace\\myblog\\src\\myblog',
> > >>  'c:\\python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
> > >>  'c:\\python27\\lib\\site-packages\\simplejson-2.1.6-py2.7.egg',
>
> > >>  'c:\\python27\\lib\\site-packages\\pyasn1-0.0.13-py2.7.egg',
> > >>  'c:\\python27\\lib\\site-packages\\pymongo-1.11-py2.7-win32.egg',
> > >>  'c:\\python27\\lib\\site-packages\\mongoengine-0.4-py2.7.egg',
>
> > >>  'C:\\Windows\\system32\\python27.zip',
> > >>  'c:\\python27\\DLLs',
> > >>  'c:\\python27\\lib',
> > >>  'c:\\python27\\lib\\plat-win',
> > >>  'c:\\python27\\lib\\lib-tk',
> > >>  'c:\\python27',
>
> > >>  'c:\\python27\\lib\\site-packages',
>
> > >>  'c:\\python27\\lib\\site-packages\\PIL']
>
> > >> Server time: Mon, 15 Aug 2011 12:32:23 +0800
>
> > >> Traceback Switch to copy-and-paste view
>
> > >> c:\python27\lib\site-packages\django\core\handlers\base.py in
> > get_response
>
> > >>                     for middleware_method in self._view_middleware:
>
> > >>                         response = middleware_method(request, callback,
> > callback_args, callback_kwargs)
>
> > >>                         if response:
>
> > >>                             break
>
> > >>                 if response is None:
>
> > >>                     try:
>
> > >>                         response = callback(request, *callback_args,
> > **callback_kwargs)
>
> > >> ...
>
> > >>                     except Exception, e:
>
> > >>                         # If the view raised an exception, run it
> > through exception
>
> > >>                         # middleware, and if the exception middleware
> > 

Work in memory instead of BD, how to?

2011-08-18 Thread Felipe Arruda
Hi there, I was doing some project recently and faced a problem of
performance.
I need to be able to do a lot of access to some information on the DB,
almost all the time, and doing so seams to be taking too long.

Is it possible do do something like this:
Get the infos from the BD and put them in memory, then when I save() a
model or get()/filter() it will get from the memory.
And from time to time, the memory will update this info in the DB.

If this is possible, then how should I do it?

Using the Cache Framework? Ins't this one just for static files?
Thanks for the 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: m2m assignments lost when saving in admin but not shell

2011-08-18 Thread Andre Terra
Your instance is probably not yet saved to the database, so the m2m-related
objects don't know which instance to connect to. There's problem something
wrong in your save() method. I often use "assert False, some_var" to check
if at some point the variable is already set or not.

And I get the same problem as you so many times that forms have become the
thing I hate the most about Django, even though my lack of knowledge is the
one to be blamed, not the framework.


Cheers,
AT

On Thu, Aug 18, 2011 at 5:48 AM, Tom Evans  wrote:

> On Thu, Aug 18, 2011 at 4:44 AM, Shawn Milochik 
> wrote:
> > I have some code that modifies related items when a model is saved. I've
> > tried this by both using a post_save signal and by putting the code
> directly
> > in a save() override.
> >
> > When I save an instance in the Django admin, it never works.
> > When I save an instance in ./manage.py shell it always works.
> >
> > Why would this be?
> >
> > For instance, if my code (in the save override) is this:
> >
> >self.some_m2m_field.clear()
> >self.some_m2m_field.add(this_thing)
> >
> > Then if I go into the admin and save the instance, this_thing is not
> > attached to the instance. But if I do a .save() in the shell and check it
> > has been assigned.
> >
> > I assume I'm missing something fundamental about this.
> >
> > Thanks,
> > Shawn
>
> I've never encountered this Shawn, but the primary difference between
> those two is that saving in the admin will go through a ModelForm.
> Does the admin site use frm.save(commit=False) and then run
> frm.save_m2m()? frm.save_m2m() would definitely be run after both an
> overwritten save() and a post_save hook.
>
> Worth a thought.
>
> Cheers
>
> 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: Best approach to handling different types of Users

2011-08-18 Thread Andre Terra
Do create a UserProfile with an FK to user, but add an FK to Group as well.
This way you can take advantage of the existing Permissions application
which would allow/deny users access to various parts of your application.

Just make sure your views take those permissions into consideration!


Cheers,
AT

On Thu, Aug 18, 2011 at 8:56 AM, Cameron  wrote:

> Hi, I'm wondering if anyone can help shed some light on the best
> approach is too creating different Users. I'm trying to make a online
> shop, that features two types of Users, "Customers" and "Merchants".
> The power of each Users vary greatly, Customers can buy items from
> Merchants and Merchants can (as you would expect) list new products,
> edit them. Merchants required additional information compared to
> Customers (such as Address, Contact Info, Payment details).
>
> Now hows the best way to handle this? I've read that subclassing the
> User class is bad (I'm not entirely sure why though). Most examples
> try to extend the User class, with a UserProfile class with a OneToOne
> relationship to the User class (like this http://pastebin.com/GQVLrVTx).
> Is it better to extend that to a UserProfileMerchant and
> UserProfileCustomer, or have a single UserProfile, and have a boolean
> field to indicate if the account is a Merchant? (both examples in the
> following - http://pastebin.com/F8ZenCa1)
>
> Any advice on the matter would be greatly appreciated!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Best approach to handling different types of Users

2011-08-18 Thread dfolland
Try using "Groups" that is part of the Django user authentication.

https://docs.djangoproject.com/en/dev/topics/auth/



On Aug 18, 6:56 am, Cameron  wrote:
> Hi, I'm wondering if anyone can help shed some light on the best
> approach is too creating different Users. I'm trying to make a online
> shop, that features two types of Users, "Customers" and "Merchants".
> The power of each Users vary greatly, Customers can buy items from
> Merchants and Merchants can (as you would expect) list new products,
> edit them. Merchants required additional information compared to
> Customers (such as Address, Contact Info, Payment details).
>
> Now hows the best way to handle this? I've read that subclassing the
> User class is bad (I'm not entirely sure why though). Most examples
> try to extend the User class, with a UserProfile class with a OneToOne
> relationship to the User class (like thishttp://pastebin.com/GQVLrVTx).
> Is it better to extend that to a UserProfileMerchant and
> UserProfileCustomer, or have a single UserProfile, and have a boolean
> field to indicate if the account is a Merchant? (both examples in the
> following -http://pastebin.com/F8ZenCa1)
>
> Any advice on the matter would be greatly appreciated!

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



Best approach to handling different types of Users

2011-08-18 Thread Cameron
Hi, I'm wondering if anyone can help shed some light on the best
approach is too creating different Users. I'm trying to make a online
shop, that features two types of Users, "Customers" and "Merchants".
The power of each Users vary greatly, Customers can buy items from
Merchants and Merchants can (as you would expect) list new products,
edit them. Merchants required additional information compared to
Customers (such as Address, Contact Info, Payment details).

Now hows the best way to handle this? I've read that subclassing the
User class is bad (I'm not entirely sure why though). Most examples
try to extend the User class, with a UserProfile class with a OneToOne
relationship to the User class (like this http://pastebin.com/GQVLrVTx).
Is it better to extend that to a UserProfileMerchant and
UserProfileCustomer, or have a single UserProfile, and have a boolean
field to indicate if the account is a Merchant? (both examples in the
following - http://pastebin.com/F8ZenCa1)

Any advice on the matter would be greatly appreciated!

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



Re: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread Fabrizio Mancini
On 18 August 2011 11:55, michael kapelko  wrote:

> I think I have to emulate Delphi app with a server process, and make
> Django interact with the process. The process can login to DB
> directly. That's not so easy, but I guess that's the only option here
> - move Delphi app from client machine to server one.
>

If you only want to authenticate users against the database you can write
your own auth backend.
The docs for these is here
https://docs.djangoproject.com/en/1.3/topics/auth/#writing-an-authentication-backend
HTH
Fabrizio

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



Re: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread michael kapelko
I think I have to emulate Delphi app with a server process, and make
Django interact with the process. The process can login to DB
directly. That's not so easy, but I guess that's the only option here
- move Delphi app from client machine to server one.

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



Re: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread bruno desthuilliers
On 18 août, 08:15, Jirka Vejrazka  wrote:
> I can't see how you could change Django easily. You could experiment
> with creating settings dynamically and closing DB connection just
> before user logs in (Django can open it again when it needs it) to use
> your "dynamic" DB connection,

The connections are per-process IIRC, so it wouldn't work in a
multithreaded configuration.

@OP: I don't know if what you want is even possible with Django, but
if it is it will very probably require some fairly advanced hacking
involving a custom db backend and some tricks with routers.

-- 
You received this message because you are subscribed to the Google 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: m2m assignments lost when saving in admin but not shell

2011-08-18 Thread Tom Evans
On Thu, Aug 18, 2011 at 4:44 AM, Shawn Milochik  wrote:
> I have some code that modifies related items when a model is saved. I've
> tried this by both using a post_save signal and by putting the code directly
> in a save() override.
>
> When I save an instance in the Django admin, it never works.
> When I save an instance in ./manage.py shell it always works.
>
> Why would this be?
>
> For instance, if my code (in the save override) is this:
>
>    self.some_m2m_field.clear()
>    self.some_m2m_field.add(this_thing)
>
> Then if I go into the admin and save the instance, this_thing is not
> attached to the instance. But if I do a .save() in the shell and check it
> has been assigned.
>
> I assume I'm missing something fundamental about this.
>
> Thanks,
> Shawn

I've never encountered this Shawn, but the primary difference between
those two is that saving in the admin will go through a ModelForm.
Does the admin site use frm.save(commit=False) and then run
frm.save_m2m()? frm.save_m2m() would definitely be run after both an
overwritten save() and a post_save hook.

Worth a thought.

Cheers

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: How to load data from local static path in templates (security error)

2011-08-18 Thread Tom Evans
On Wed, Aug 17, 2011 at 8:39 PM, Daniel Roseman  wrote:
> On Wednesday, 17 August 2011 19:00:13 UTC+1, Adam Zedan wrote:
>>
>> Hi it seems I cant access data from local static paths such as
>> c:\\somefolder\somefile.gif in my templates when I enter the url
>> the code for my template is simplified to something like this
>>
>> 
>> 
>>     
>>         
>>         Demo
>>     
>>     
>>     
>>     
>> 
>>
>> The title change to Demo. which shows that the page has loaded but
>> I get the error in firefox saying:
>> Security Error: Content at http://127.0.0.1:8000/db/ may not load or link
>> to file:///c://bender.gif
>
>
> No, you can't do that. Why would you want to? Your users aren't going to
> have that file on their machines, so what's the point of referencing a local
> file path?
> You serve the content through your webserver, with an http:// protocol. In
> development, you can do this through Django's development server:
> https://docs.djangoproject.com/en/1.3/howto/static-files/
> --
> DR.
>

The OP clearly doesn't understand why though, see his other thread on
this topic.

Your browser is a careful beast. It won't allow a webpage loaded from
the internet zone to load things from the local zone, as That Would Be
Bad. When you 'double click' the file and 'it works', what is actually
happening is that the webpage is loaded from the local zone, and so
access is allowed.

Also, Django is a web app. This means that most users who use your
site will not be using it from your desktop, so they would not be able
to access files on your local machine. Therefore, you need to provide
a way to serve these files over HTTP, so that other users can access
them. See the link in Daniel's reply on how to do this.

Cheers

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: Performance of process_template_response for corporate branding

2011-08-18 Thread Nathan Hoad
To answer my own question;

I performed some tests with the Apache benchmarking tool. I performed
5000 requests over 10 threads to a local server running lighttpd with
FastCGI, multiple passes over a few hours, with my middleware disabled
for one pass and disabled for another.

The passes were both on par, as I was hoping/expecting they would be.
The average difference was something like 2 seconds, with the enabled
middleware being the faster one usually. Obviously this means nothing,
and they're both on par and there's nothing to worry about.

On Aug 18, 1:11 pm, Nathan Hoad  wrote:
> I have a project at the moment that requires a lot of corporate
> branding as well as internationalisation/translations etc. Basically
> the way the system currently works is that it performs the
> translations, then applies branding for specific distributors.
>
> Now we're developing a web-based front end using Django, and of course
> the same rules still apply. I have a solution at the moment that uses
> a very minimalist middleware, which is called after the translations
> are performed, using the process_template_response method.
>
> Of course, it's working all fine, but I'm wondering about the
> performance hit from what's essentially 10-20 of str.replace()
> methods? The alternative is to create my own wrapper for Django's
> translation package, but after looking at the code I'm not big on that
> idea.
>
> If anyone has any alternative solutions, don't hesitate to share!

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



Re: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread Kejun He
hi,

I had a same problem as you before, and I spent much of time on it, but
could not get it goal.

And the DATAVASES in settings.py is loaded when the server running.

If you can let the project reload the settings, you may resolve the problem.

Or you can use MySQLdb to do it.

Sometimes we can use  using(db) to choice which connection is needed.
but the connections must be defined before your app start.

On Thu, Aug 18, 2011 at 2:15 PM, Jirka Vejrazka wrote:

> > I.e. I want to set up database connection after Django app has started
> > *when I want it*.
> > Is there a way to do it?
>
> No. At least not easily. Django is a web framework and is expected to
> run on a web/application server with a single-user connection to a
> target database. That's typical for web applications.
>
> What you have now it a typical "thick" client, running on end user's
> desktop. I am sorry, but there is no easy conversion between those
> two.
>
> Web applicatons typically users and permissions *winthin the
> application* rather than *within the database*. Django is tailored to
> the former.
>
> I can't see how you could change Django easily. You could experiment
> with creating settings dynamically and closing DB connection just
> before user logs in (Django can open it again when it needs it) to use
> your "dynamic" DB connection, but you'd have to somehow link your
> "dynamic settings" with user sessions and that might be tricky.
>
> It's often difficult to make a car fly, no matter how good the car is.
>
>  Cheers
>
>Jirka
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

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



Re: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread Jirka Vejrazka
> I.e. I want to set up database connection after Django app has started
> *when I want it*.
> Is there a way to do it?

No. At least not easily. Django is a web framework and is expected to
run on a web/application server with a single-user connection to a
target database. That's typical for web applications.

What you have now it a typical "thick" client, running on end user's
desktop. I am sorry, but there is no easy conversion between those
two.

Web applicatons typically users and permissions *winthin the
application* rather than *within the database*. Django is tailored to
the former.

I can't see how you could change Django easily. You could experiment
with creating settings dynamically and closing DB connection just
before user logs in (Django can open it again when it needs it) to use
your "dynamic" DB connection, but you'd have to somehow link your
"dynamic settings" with user sessions and that might be tricky.

It's often difficult to make a car fly, no matter how good the car is.

  Cheers

Jirka

-- 
You received this message because you are subscribed to the Google 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.