Re: mod_python, multiple django-sites, memory usage

2007-09-10 Thread Atilla

If you are considering running mod_fcgi systems, take a loot at
mod_wsgi first. It's quite stable already, the setup is not any more
difficult than mod_fcgi and it's a lot more easy to configure the
finer details. Additionally, some simplistic tests show quite good
performance, although that's yet to be targeted with a more suitable
benchmark.

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



Re: How to implement multi-level cascaded DISTINCT JOIN using django's object model?

2007-03-08 Thread Atilla

On 08/03/07, Alex Dong <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I have a data model like this:
> * a `user` has multiple `questions`
> * a `user` could give multiple `answer`s or `comment`s to any
> `question`s.
> So here, there are
> * a one-to-many relationship from `user` to `question`
> * a many-to-many relationship between `question` and `answer`,
> `question` and `comment`.
> Now I need to pull out a list of all the questions a given user has
> either answered or commented on.  I could do `user.question_set` or
> `user.answer_set`.
>
> Now if I write a template like this:
> ` {% for answer in user.answer_set %}
>  ... {{ answer.question. ... }}
>   {% endfor %}
> `
> I could end up with showing the same questions many times.
>
> I know for sure that this task is not that difficult if I retreat to
> using `JOIN` and use raw sql for my query. But I'm wondering does
> Django  offers a neat solution for this question without using raw
> sql?
>
> Thanks,
> Alex
>

How about this: Question.objects.filter(answer__user_id=userID) - this
should give you the question objects for which the user has given
answers. Extend the filter with a Q clause to do the OR for comments.
You may need to throw a .distinct() in there as well. I've got a
similar thing that works, I'm just not sure about the exact syntax for
your case.

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



Re: Any HTML to Latex module available in Python that can be integrated into Django

2007-03-08 Thread Atilla

If you're familiar with XSLT then that should also be a good
candidate. The problem there is that things could get complicated, if
the HTML document is not a well-formed XML document.


On 08/03/07, Kjell Magne Fauske <[EMAIL PROTECTED]> wrote:
>
>
>
> On Mar 7, 8:17 pm, "Ramdas S" <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have a web site, which needs to output HTML content as Latex
> >
> > Ramdas S
>
> I don't know of any Python library that converts from HTML to LaTeX.
> However, writing one should not be that difficult. It is at least much
> easier than writing a LaTeX2Html translator. You could parse the HTML
> code using for instance elementree[1] and Beautifulsoup[2]. You can
> then iterate over the parsed html tree and output corresponding LaTeX
> markup:
> name -> \section{name}
> name -> \subsection {name}
>  -> \begin{itemize}
> text -> \item text
> 
>
> [1] http://effbot.org/zone/element-index.htm
> [2] http://www.crummy.com/software/BeautifulSoup/
>
> reStructuredText(http://docutils.sourceforge.net/rst.html ) can
> generate both LaTeX and HTML from simple text files. It is used to
> document Django.
>
>
> - Kjell Magne Fauske
>
>
> >
>

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



Re: newbie question: select_related from parent to child

2007-03-08 Thread Atilla

On 06/03/07, roberto <[EMAIL PROTECTED]> wrote:
>
> dear all,
>
> i'm starting to use django and i have what may seem to a lot of you
> the stupidest question ever, though i have not been able to solve
> this,.
>
> i have to classes:
>
> class warriors(models.Model):
> username = models.CharField(maxlength=50)
>
> class warriors_gaming(models.Model):
> warrior_id = models.OneToOneField(warriors)
> points = models.IntegerField()
>
> what i'd like is to perform a sql query like:
>
> select * from warriors, warriors_gaming where warriors.id =
> warriors_gaming = warrior_id and warriors.username = 'me'
>
> the object i would result therefore would have all properties of both
> tables. i am trying with:
>
> warriors_info = warriors.objects.get(username__exact = "robbie")
>
> which works ok however warriors_info.points does not exist as method
> or property. no luck with:
>
> warriors_info = warriors_gaming.objects.get(warriors__username__exact
> = "robbie")
>
> which gives me an error stating that 'warrior' is unknown. tried with:
>
> warriors_list = warriors_gaming.objects.select_related()
>
> which works, however i cannot find a place where to set my username =
> 'me' clause. i am sure this must be pretty simple but cannot find a
> way to do this... hopefully some nice soul will help me out to get
> started.
>
> thank you in advance,
>
> r.
>
>

Go carefully trough the DB API documentation. You can chain your query
methods to form quite complex expressions.  Look at .filter()

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



Re: newb: Model.objects.select_related().get(id=4)

2007-03-09 Thread Atilla

On 08/03/07, johnny <[EMAIL PROTECTED]> wrote:
>
> class City(models.Model):
> # ...
>
> class Person(models.Model):
> # ...
> hometown = models.ForeignKey(City)
>
> class Book(models.Model):
> # ...
> author = models.ForeignKey(Person)
> edited = models.ForeignKey(Person)
>
> If do this: Book.objects.select_related().get(id=4), Would it get one
> book object, the 2 person and 2 city object, like below?
>
> book: -person-city (author who created it),
>   -person-city (editor who edited it)
>
> Thank you
>
Yes, select_related() will automatically join the related tables and
select their values for you in 1 query.

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



Re: howto add join table field?

2007-03-09 Thread Atilla

On 09/03/07, Greg Donald <[EMAIL PROTECTED]> wrote:
>
> How can I add a field in a join table?
>
> I have this:
>
> class Item(models.Model):
> name = models.CharField(maxlength=32)
>
> class List(models.Model):
> name = models.CharField(maxlength=32)
> items = models.ManyToManyField(Item)
>
> which creates the 'list_items' join table fine, but then how do I put
> a field in that same table?
>
> When I try to add something like this:
>
> class List_Items(models.Model):
> quantity = models.IntegerField()
>
> I get errors:
>
> _mysql_exceptions.OperationalError: (1050, "Table 'stuff_list_items'
> already exists")
>
> Does Django have join models or the like?
>
>
> Thanks,
>
If you need additional fields in the M2M table, you'll have to create
the mapping on your own. Instead of using a M2M directly, link the
elements trough your List_Items model, adding the fields that you
like.

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



Re: select_related() does not select many-to-many relations?

2007-03-09 Thread Atilla

On 08/03/07, akonsu <[EMAIL PROTECTED]> wrote:
>
> hello,
>
> as the subject says, select_related() does not return many-to-many
> relations. is this a feature or a bug?
>
> thanks
> konstantin
>
>

>From what I've seen select_related() always joins up the related
tables and select their values. Can you provide an example where this
fails ?

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



Re: trying to make select_related() work

2007-03-09 Thread Atilla

On 09/03/07, akonsu <[EMAIL PROTECTED]> wrote:
>
> hello,
>
> the code below generates two queries to the database. is there a way
> to make it get all objects related to object 'aa' and then just look
> up the right one when get() is called?
>
> thanks
> konstantin
>
> class AA(models.Model) :
> name = models.SlugField()
>
> class BB(models.Model) :
> name = models.SlugField()
>
> class AB(models.Model) :
> aa = models.ForeignKey(AA)
> bb = models.ForeignKey(BB)
>
> r = AB.objects.select_related().filter(aa__name = 'aa')
>
> l = list(r)  # this evaluates 'r' but the statements below hit the
> database anyway...
>
> print r.get(bb__name = 'bb1')
> print r.get(bb__name = 'bb2')
>
>

Calling .get() will always execute a query to retrieve you 1 specific
item.  Perhaps you need to rethink the way you're trying to fetch and
use your data. What exactly are you trying to accomplish here ?

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



Re: trying to translate a join query to django

2007-03-09 Thread Atilla

On 07/03/07, hotani <[EMAIL PROTECTED]> wrote:
>
> This is the table (model) setup:
> [county] (list of counties)
> [office] (list of offices)
> [active counties] (a relational table with a county_id, office_id and
> 'active' column)
> [division] (columns: 'name', 'county_id' which points to the first
> county table)
>
> Obviously the division table is directly linked to the county table
> which is just a list of names. What I need to do is extract the
> divisions for a particular office, based on the active counties table.
> The problem is, 'active counties' is not directly linked to divisions!
>
> This is how I would do it in sql, assuming the current office has an
> id of '3':
>
> SELECT d."name"
> FROM division d
> LEFT JOIN active_counties c ON (d.county_id=c.county_id)
> WHERE c.office_id='3'
>
> I'm hoping to avoid a custom SQL query from django, but right now I'm
> not seeing any alternatives.
>

Hmm, it depends on how exactly you've created your models. It's
nothing complicated that you're doing so far and it can be expressed
easily in the Django way.

Assuming you have the following models:

Country
Office
ActiveOffices
country = models.ForeignKey(Country)
office = models.ForeignKey(Office)
active - (do you really need that? if there's no entry in a M2M
relationship, it means it's not active. if it doesnt serve a specific
purpose, simply use M2M instead)
Division
name = models.TextField()
country = models.ForeignKey(Country)

You could get it, the proper way, using
Division.obejcts.filter(country__activeoffices__active = True,
country__activeoffices_office=OfficeID).

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



Re: Api and user auth

2007-03-09 Thread Atilla

On 07/03/07, Grupo Django <[EMAIL PROTECTED]> wrote:
>
> Hello, I have two questions:
>
> -Where can I browse the django API?
>
> - I have made a news app. One of the fields is author, i want to set
> its default value to the username logged in the admin zone. How could
> I do it? What do I have to import to use request.username? so I would
> do: default= request.username, editable=False.
>
> Thank you!
>
 You can find all necessary documentation on www.djangoproject.com. If
you want to go trough the source, some examples and suggestions, you
might want to see code.djangoproject.com

In order to automatically set the author, in your model definition
you'll need to do two things. First of all - include the User model in
the file where you define your models. Second - go to
http://code.djangoproject.org/wiki/CookBookThreadlocalsAndUser and see
how to do the trick to set the current user in your model. Note that
default works, it's not always necessary to modify the save() methods,
if you don't need to.

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



Re: trying to make select_related() work

2007-03-11 Thread Atilla

On 09/03/07, akonsu <[EMAIL PROTECTED]> wrote:
>
> thanks for your response.
>
> well, i am trying to get a list of dependents of a given object in a
> single query. i want to be able to retrieve the dependents by key (the
> object name) from this list.
>
> i do not see any way of doing this but getting the query set and
> converting it to a dictionary manually:
>
> d = dict()
> for x in AB.objects.select_related().filter(aa__name = 'aa')  :
> y = x.bb
> d[y.name] = y
>
> i was trying to avoid this extra list traversal...
>
> konstantin

I'm still a little bit confused, but here's what I'd suggest:

In the model you've described you can say something like:
BB.objects.filter(ab__aa__name="aa") to get the list of BB objects
that are mapped to that specific AA object.

In addition - if you don't have other fields in the AB model,
substitute that with a M2M field in one of the AA or BB models.  It
will allow you to use the full M2M relationship syntax in your
QuerySets.

Finally - those model names are giving us headaches. Sometimes it
helps a lof if you ask your questions in the context of your system
and people might have more clues and ideas for you.

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



Re: Chaining ManyToMany Filters Update

2007-03-12 Thread Atilla

On 12/03/07, Boris Smus <[EMAIL PROTECTED]> wrote:
 >[56]:cs.filter(default_recipe__ingredients__ingredient__id=3).filter(default_recipe__ingredients__ingredient__id=1)
> Out[56]:[]
This would map to a Query that looks like this "... WHERE id=3 AND
id=1".  that would most certainly return no results. If you're trying
to do OR, look into the DB API manual for Q objects, which are the way
to express OR statements.

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



Re: low performance of FastCGI deployment

2007-03-12 Thread Atilla

I am running a system with basically the same versions of all software
packages as you are. It is in production and under stress testing it
performed very very well and there've been no issues with performance
so far. I am using Apache + FastCGI, server-managed.

First thing you might want to look at is Apache configuration. What
MPM are you using for Apache - prefork or worker/threaded? Are you
loading too many apache mods that you might not need. Are the
MaxRequestsPerChild and other similar server directives set up
properly ? Note that the FCGI also has a finite number of requests to
serve, before being recycled, but unless you've changed the default
values you should be Ok.

On 12/03/07, Alexander Boldakov <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> My django application runs slower under Apache+FastCGI or
> Lighttpd+FastCGI than under django development HTTP server. The
> approximate times for generating the page are 0.6 vs 1.0 seconds for
> FastCGI and development server correspondingly.
>
> I've tried different combinations of 'prefork' and 'threaded', unix
> domain socket and tcp socket, manually/web server started fastcgi
> server as described on django FastCGI documentation page, but nothing
> helped.
>
> If you have any idea of solving this problem, i will greatly
> appreciate it!
>
> Django version is 0.95. Python version is 2.4.4. Apache version is
> 2.2.3. Flup version is 0.5.
>
> Alexander Boldakov
>
>
> >
>

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



Re: Related foreign fields in admin application

2007-03-14 Thread Atilla
On 14/03/07, Krassimir Grozdanov <[EMAIL PROTECTED]> wrote:
> I am a python and Django novice so please excuse me if my question is
> too stupid.
>
> I have 3 models: Regions, Municipalities  and Persons.
> In the admin interface, when editing the Person object, I want to
> limit the choices for the Municipalities based on the Region choice
> (e.g. I want to limit the list only to Municipalities that are in the
> chosen region). Please advice me which is the best way to do that.
>
> Here follow my models:
>
> class Region(models.Model):
> region = models.CharField(maxlength=128)
>
> def __str__(self):
> return self.region
> class Meta:
> verbose_name = 'Област'
> verbose_name_plural = 'Области'
> class Admin:
> pass
>
> class Municipality(models.Model):
> region = models.ForeignKey(Region)
> municipality = models.CharField(maxlength=128)
>
> def __str__(self):
> return self.municipality
> class Meta:
> verbose_name = 'Община'
> verbose_name_plural = 'Общини'
> class Admin:
> pass
>
> class Person(models.Model):
> PERSON_TYPES = (
> ('Да', 'Юридическо лице'),
> ('Не', 'Физическо лице')
> )
> region = models.ForeignKey(Region, null = True)
> municipality = models.ForeignKey(Municipality, null = True)
> name = models.CharField(maxlength=384)
> type = models.CharField("Юридическо лице", maxlength=8, choices =
> PERSON_TYPES, default = 'Да', radio_admin = True)
> dnomer = models.CharField(maxlength=16, blank = True)
> bulstat = models.CharField('БУЛСТАТ', maxlength=16, blank = True)
> egn = models.CharField('ЕГН', maxlength=10, blank = True)
> city = models.CharField(maxlength=64)
> postcode_p = models.CharField(maxlength=16, blank = True)
> address_p = models.CharField(maxlength=128, blank = True)
> phone_p = models.CharField(maxlength=64, blank = True)
>
> def __str__(self):
> return self.name
> class Meta:
> verbose_name = 'Юридическо лице'
> verbose_name_plural = 'Юридически лица'
> class Admin:
> pass

I am afraid that currently, there isn't a out-of-the-box
implementation of that type of filters in the admin panel. It's more
of a true interface for administrators, rather than a proper content
management insterface.

You'll probably have to extend some control and modify the necessary
view from the admin panel, if you want it to go there. If you're using
the newforms admin - it might be easier to write that there.

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



Re: newb: Django & CountingDown

2007-03-14 Thread Atilla

On 14/03/07, johnny <[EMAIL PROTECTED]> wrote:
>
> I have an app that is for online test taking. Most online test are 30
> mins to 2hrs. I need to create count down clock from when the test is
> stared. If 30 mins test, then count down will start from 30 mins : 00
> Secs, 29 min: 59 secs and so on. How do I do this?

One simple way will be to add a simple JavaScript clock countdown in
your application. You can find many examples online, or even ready
scripts.  You have to make sure on the track the time used on the
server side though - you should register the time at which user got
the test and the time at which he submitted the answers, at the very
least. If you have multiple pages/forms, make sure you register the
time at which the user requested each page and adjust the countdown
accordingly. Do not implement this with some random script entirely on
the client side, as then it'll be very easy to cheat.

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



Re: Starting a new, external process

2007-03-14 Thread Atilla

I don't have a full example, but the thread module won't do what you
need. You need to spawn an external process to do your job. For this
take a look at python's documentation. It's a faily simple thing to
do, if you just want to run mencoder on the file,

On 14/03/07, Henrik Lied <[EMAIL PROTECTED]> wrote:
>
> Hi there!
>
> I have a model which allows people to upload videos.
> In the save-method I run os.system("mencoder *variables"), which
> converts the uploaded video to a flash file.
>
> I don't want the user to have to wait until the conversion is done
> before he can go on with his business. I've tried the Thread-module,
> but the current job still waits for the background process to finish..
>
> Does anyone have a good idea (with a full example) on how I should go
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: start exactly one thread in Django application

2007-03-15 Thread Atilla

On 15/03/07, skink <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'd like to start one thread in order to do some periodic actions.
>
> It should be started automatically, not within some view code.
>
> Where is the best place to start such thread?
>
> regards,
> skink
>

What kind of actions are you talking about?

If you're trying to run some priodic maintenance, you should consider
writing a proper external (as in - not in your web service code)
script and schedule it to run with cron, for example. You'd still
include and use the django code/models of course.

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



Re: newb: Django ORM for Custom SQL

2007-03-15 Thread Atilla

> I need to retrieve latest record (each record has a time stamp,
> created_at), only one record, from sale table where product_id=1.  How
> do I do this in Django ORM?  I have looked at .objects.extra{}, but I
> am getting ProgrammingError 1064.
>
> I need to get this sql into Django ORM:
>
> select created_at
>   , amount
>   , ...
>   from sales
>   where product_id = 1
> order
> by created_at desc
>  limit 1

It's very simple - use your normal QuerySet syntax to filter the
product_id and then just say .latest(). See the djando models
documetnation on how to specify on which field(s) should .latest work.

It'll look like:
ModelName.objects.filter(product=product_id).latest();

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



Re: Method problem with .save()

2007-03-15 Thread Atilla

On 15/03/07, DuncanM <[EMAIL PROTECTED]> wrote:
>
> I have 2 classes:

This post is really too long to be able to understand what and where
it's going on.

"Revision matching query does not exist" is usually caused when you're
trying to select something out of the database and your query coudn't
match what you're looking for. DoesNotExist  is an exception that
notifies you of this and is something you should be catching, if
you're doing selects that might not give you any results.

Furtermore, this model looks a bit bloated. Maybe you should consider
a M2M relation, with an additional field, that specifies the position
of the player, instead of harcoding them as separate fields in your
model. It's much more heavy and difficult to process in the way you've
defined it.

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



Re: low performance of FastCGI deployment

2007-03-15 Thread Atilla

On 14/03/07, Alexander Boldakov <[EMAIL PROTECTED]> wrote:
>
> The web pages served in my django applications are not static media
> files, but dynamically generated content (the result of applying XSLT
> transformation to the XML data retrieved from XML database). I
> consider the architecture of public site with static version of data
> and private dynamic site, but the problem of synchronization of the
> two systems is not trivial in my case. Though i agree that serving big
> dynamic content will fail with increasing the number of users.
>
> P.S. Your writeup is very exciting and interesting!

What kind of XML tools are you using to apply the XSLTs? This can be
quite a heavy task, and combined with the large output sizes - it will
make your processes stay in memory quite long. LibXML is VERY fast
when it comes to XML processing, but even with it sometimes the
processing can be quite heavy, as your user base grows.

In any case - consider caching the results of the transformations, or
reusable parts of them. Any piece of the output that you can reuse and
cache can significantly improve your performance. If you can cache the
whole output - even better, then it's as simple as enabling Django's
Cache middleware.

If your server are stuggling and you have a user base that's rather
big and will need proper performance, then you'll need more machines
to serve your content. In that case having Memcached cahing will
really benefit you, as cached output will be shared between your
server nodes.

How big is the application you're writing and what's its target ?

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



Re: How to use Django session without browser cookies support

2007-03-15 Thread Atilla

On 13/03/07, Sengtha <[EMAIL PROTECTED]> wrote:
>
> I am currently working on one project which needs to view page on
> browser that doesn't support cookies.
> By what I know, all Django sessions are based on browser cookies. And
> Django sessions are save in django_session table. I wonder there is
> any way to implement Django session like PHP session.use_trans_sid
> without relying on client's browser cookies.
>
> Please help
>
> Thanks
>

What I can think of the top of my head is writing a middleware that
replaces all your internal URLs in the output, appending to them the
session ID variable. You can start by extending the django session
middleware, to support the SID-in-Url format, when processing the
request and then add the necessary method that will rewrite the URLs
in the response phase.

In-URL session ID is really not one of the greatest ideas though, but
if there's no other choice, I guess that's the way to go.

For the rewriting of the URLs you can go with regular expressions or
XSLT transformations. The second one is only usable if you're
returning properly structured XML to the browser, so then you'll need
to validate the output of your templates, before you can apply the
XSLTs.

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



Re: Related foreign fields in admin application

2007-03-16 Thread Atilla

Weeel, there is the newforms-admin branch. I haven't tried it myself
though, I've just seen people om the IRC channel discuss it. Judging
from the roadmap, it should be pretty usable.

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

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



Re: How much is Django memory footprint?

2007-03-20 Thread Atilla

I've a moderatelly small apllication in production, that runs on FCGI,
instead of mod-python. From stress-tests it's prooven to be very fast
and responsive. FCGI is dynamically managed by Apache.

The memory footprint of my FCGI processes is around 12MB per process,
In addition, my Apache processes take around 6MB each.

I guess that ~18MB per process is normal in your case. A 50 MB process
is quite large however, what type of processing are you doing?

Also - for most of the cases you'd like to recycle an apache child
after a number of requests, so set the MaxRequestsPerChild to some
reasonable limit. If it is unlimited and something in your code
doesn't collect garbage memory properly, or it leaks memory, you'll
end up with your Apache children growing significantly, and loosing
the  copy-on-write pages that are shared between children.

In addition, make sure you take off any Apache modules that you're not using.

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



Re: How much is Django memory footprint?

2007-03-20 Thread Atilla

On 20/03/07, Nuno Mariz <[EMAIL PROTECTED]> wrote:
>
> The processing is nothing in special, right now a weblog and a online
> store.
> I've removed some modules, like fcgi, include and suexec(I can't
> remember the instalation of this modules ;) ) and the size of the
> processes is now 22Mb.
> Do you have KeepAlive On?
> In my case did't solve the problem.
> Also, can I reduce the memory footprint if I had a independent server
> to serve static media, like lighttpd?

If you have a lot of static content, you definitely want to have a
separate server to handle that. Even if it is Apache - just use a
stripped down version (no funky modules) to serve your static data,
and keep the django system separate. All of the Django tutorials
recommend using a separate server for static files - extensively.

Try locating any other modules you're not using and turning them off.
For most of the performance tests I've done on systems running
mod-python/mod-perl, it really makes a difference - sometimes
immediately noticeable.

I've keep alive off, for many cases in serving dynamic content
KeepAlive in Apache will not help you at all. When it comes to serving
static content, and especially lots of javascript/css/image files for
web-pages, then it's a blessing - you can keep it on on your static
file server, whether it's Apache or something smaller/faster.

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



Re: Illegal mix of collations

2007-03-27 Thread Atilla
On 26/03/07, Gerard M <[EMAIL PROTECTED]> wrote:
>
> Hello dear django comunnity, Im having a bad time with my database in
> MySQL the problem is that when I try to store a word with some "rare"
> characters like á é í and many others, django shows this message to
> me
>
> OperationalError at /uploading/
> (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and
> (utf8_general_ci,COERCIBLE) for operation '='")
> Request Method: POST
> Request URL: http://localhost:8000/uploading/
> Exception Type: OperationalError
> Exception Value: (1267, "Illegal mix of collations
> (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for
> operation '='")
> Exception Location: C:\Python24\lib\site-packages\MySQLdb
> \connections.py in defaulterrorhandler, line 35
>
> I've tried changing the default encoding of my database from latin1 to
> utf8 but didnt work, or maybe I didnt set it well, If any of you
> happen to know how can I solve this problem, would you be so kind to
> tell me how please? thank you a lot
>

I'm not 100% sure, but changing the dafault encoding of the database
will not update the collations of the tables that are already created,
so your collision will still remain. The queries for table creation
generated by Django don't issue encoding and collation commands, so
your initial tables should be created with the default latin1_swedish
encoding. Try changing them manually, or recreating them with the
default UTF8 encoding that you've set now.

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



Re: fcgi - issues

2007-03-27 Thread Atilla

On 26/03/07, David M. Besonen <[EMAIL PROTECTED]> wrote:
>
> are there any issues/caveats/problems around using django + fcgi?
>
> i'm guessing there might things to be wary of, given that
> mod_python appears more prominently in the installation
> instructions.
>
>
> thanks,
> david

I am using fastcgi, dynamiccally managed by Apache, with no problems
on a production system. The performance is quite good and there aren't
any significant problems that I can think of, except of the actual
configuration.

Mind that there are two FCGI modules for Apache2 - "fgci" and "fcgid"
- the later seemed like a better choice to me, as it is smarter when
the proceses are managed dynamically.

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



Re: Nested Sets for trees - any models been made before?

2007-03-27 Thread Atilla

> Currently I am trying to store a "tree" in a database and want to use Nested
> Sets in order to do this. I was wondering if this exists within Django atm
> or if there are plans to add it in the future or has someone developed it on
> the side? If the answer to these questions is "NO", is there a reason which
> prevents Nested Sets from being implemented in Django?
>
> I m imagining a model;
>   class Node(models.Model):
>  name = models.TextField()
>  lft = models.IntegerField()
>  rgt = models.IntegerField()
>  objects = NSManager()
>
> and having a manager do all of  the query work...as well as making
> changes to save and delete. Does this seem like the right idea? I m just
> checking before I jump in.
>

The best way to manipulate the tree "transparently" would be a custom
manager, that knows how to deal with the necessary updates to the
nested set values, upon insertion, updates, etc. I think it would be
quite nice to manipulate it, using the QuerySet syntax, but do mind
that it could be rather heavy sometimes. If your application would
require frequent inserts/updates, rather than reads, it might become
very slow. Also - if your database is not transaction managed, you can
run into problems and collisions in your tree structure.

Other than that - the Nested Sets idea is very good for storing tree
data in a relational DB, it can offer some considerable gains on
read-heavy systems and it will be very good to see it implemented in
Django.

We're currently trying a similar thing, implementing the tree
management as stored procedures in MySQL, rather than in the
application logic. So far it looks quite promising, since there's no
need to transfer data to the application for this purpose and we're
not doing heavy processing in the procedures.

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



Re: special chars "error in Admin"

2007-03-29 Thread Atilla

Have you tried switching to UTF-8, if you need support for "funny"
character sets ? You'll need to change your database and table
encodings to UTF8 (with appropriate collation, if you need proper
sorting) and the output content-type.


On 28/03/07, enquest <[EMAIL PROTECTED]> wrote:
>
> In Django admin entering the following quote chars " " 'copy paste' in a
> textarea field gives this error...  "Data truncated for column ..."
>
> How can this be? And what is the solution for this nasty problem.
> Because people wil copy and paste out of MS Word etc...
>
> The database is latin1 as standerd Django does.
>
> Enquest

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



Re: Long time process and FCGI

2007-03-29 Thread Atilla

Hello,

By the looks of it, mod_fcgi has a limit as to how much time it could
wait for response from a script. Since you're doing a heavy operation
that takes a while, i guess it times out.

The point is  - if your executed action takes so much time, you're
clearly having a wrong conception on when and how you should be
executing it. It could be better off as an external process (that
still uses django in its code) that is triggered by certain actions in
your web-application, or scheduled by cron. In any case - it is not
the job of your django view to handle bulk transfers, it was not meant
to be doing that, even if the mod_fcgi didn't have the timeout.


On 30/03/07, Anderson Santos Silva <[EMAIL PROTECTED]> wrote:
>
> Hello, I have a process that sends an e-mail to more then 5000 addresses
> (grouping it in 50 each time) and after a while it gives me the error:
>
> ---
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
>
> Please contact the server administrator, [EMAIL PROTECTED] and
> inform them of the time the error occurred, and anything you might have
> done that may have caused the error.
>
> More information about this error may be available in the server error log.
>
> Additionally, a 404 Not Found error was encountered while trying to use
> an ErrorDocument to handle the request.
>

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



Re: Long time process and FCGI

2007-03-30 Thread Atilla

Well, one thing that you could do is to execute an external script
from your view. Then you'd immediatelly return from the view, and the
script could mail them in the background. That is, of course, if you
don't need any feedback to be displayed.

If you do need to do something like that, you'll need to make your
view provide some output every once in a while, so your webserver does
not time it out. However - that would cause your view to return data
to the browser quite slow. If you want it more interactive, you could
make the view generate output to a page with something AJAX-y, instead
of a normal web page.
http://my.opera.com/WebApplications/blog/show.dml/438711 - this idea
is quite nice, although I guess you don't need anything so flashy in
your case.


On 30/03/07, Anderson Santos Silva <[EMAIL PROTECTED]> wrote:
>
> That's exactly what I thought when I dealed with that, but I can't
> imagine a separated process running in the background and return a
> response to the user that his "action" was activated if every method
> waits to get back instead of a kind of thread operation. (Yes, I came
> from windows programming {delphi} to Web, so my knowledge is kind of
> limited with Python)
>
>  Any suggestion?
>
>
>
>
> Atilla wrote:
> > Hello,
> >
> > By the looks of it, mod_fcgi has a limit as to how much time it could
> > wait for response from a script. Since you're doing a heavy operation
> > that takes a while, i guess it times out.
> >
> > The point is  - if your executed action takes so much time, you're
> > clearly having a wrong conception on when and how you should be
> > executing it. It could be better off as an external process (that
> > still uses django in its code) that is triggered by certain actions in
> > your web-application, or scheduled by cron. In any case - it is not
> > the job of your django view to handle bulk transfers, it was not meant
> > to be doing that, even if the mod_fcgi didn't have the timeout.
> >
> >
> > On 30/03/07, Anderson Santos Silva <[EMAIL PROTECTED]> wrote:
> >
> >> Hello, I have a process that sends an e-mail to more then 5000 addresses
> >> (grouping it in 50 each time) and after a while it gives me the error:
> >>
> >> ---
> >> Internal Server Error
> >>
> >> The server encountered an internal error or misconfiguration and was
> >> unable to complete your request.
> >>
> >> Please contact the server administrator, [EMAIL PROTECTED] and
> >> inform them of the time the error occurred, and anything you might have
> >> done that may have caused the error.
> >>
> >> More information about this error may be available in the server error log.
> >>
> >> Additionally, a 404 Not Found error was encountered while trying to use
> >> an ErrorDocument to handle the request.
> >>
> >>
> >
> > >
> >
> >
>

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



Re: Admin - order ForeignKey by

2007-04-02 Thread Atilla

Have you tried specifying "project__name" ? That should be resolved
correctly in the query set. If it doesn't work, you'll have to
redefine the order_by method and include the join of the tables there
explicitly.

On 31/03/07, Gilhad <[EMAIL PROTECTED]> wrote:
>
> I have something like this:
>
> class Project(models.Model):
> name = models.CharField(maxlength=10)
> order = models.IntegerField()
> 
> def __str__(self): return self.name
>
> class Task(models.Model):
> project = models.ForeignKey(Project)
> description = models.CharField(maxlength=100)
>
>
> Is there a way in Admin, when editing Task, to have the Select field for
> Project sorted by Project.order (or at least by Project.name) instead of
> Project.id?
>
> (The Project.id order looks pretty chaotic, as it reflex the time (id is
> AutoField), when the Project was entered, which is surely not too much
> descriptive, as many related Projects are entered at very different times)
>
> --
> Zdravi
>  Gilhad
>  [EMAIL PROTECTED]
>
> >
>

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



Re: M2M relationships via an intermediary table .. how do i get to the data in my template?

2007-04-02 Thread Atilla

On 30/03/07, oliver <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I am starting out with django and python, don't have much experience
> in either. I have managed to create a few "simple" website with django
> and really enjoy working with it.
>
> But I am a bit stuck on my latest project. I am using a M2M relation
> via an intermediary table.
>
> http://dpaste.com/hold/7651/  I put all the code in there ..
>
> I have a Image model, a ImageGroup (intermediate table) model and a
> News (New) model.
> New(s) has a:
> imagecollection = models.ManyToManyField(ImageGroup...)
>
>
> and ImageGroup holds:
> Position (for sorting)
> and a ForgeignKey to Image
>
> Image holds:
> Caption and the path to the image file.
>
> I made a simple inclusion tag to get my News objects and send them to
> my template.
> But I am stuck on how do I get to the image data in my template? More
> specific for this example I only need the 1st image, later on I will
> need all related images but I hope I will understand how to do it once
> I get to that stage.
>
> I guess I need something in the inclusion_tag to get me the related
> images in the order of the intermediate table "position" field?
>
> I tried this but django complains about "self" (global name 'self' is
> not defined)
> images = ImageGroup.objects.filter( new =
> self.id ).order_by( 'position' )[:1]
>

That can't work. I guess what you're trying to do can be accomplished
with ImageGroup.objects.select_related().latest().  Or any other
filter you require, instead of the latest() shortcut.

See how to read out the list of related fields in the django docs, and
also not that you can do filter() on fields of the related models as
well, for example Image.objsects.filter(imagegroup__new__islive=True).

Also - "News" has no singular form,"New" is a weird class name to use,
isn't it ? :)


> I read the docs and found examples in this group but I can't get my
> head around it how it works on my model layout.
>
> any help will 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: URLField to short for google maps

2007-04-02 Thread Atilla

On 01/04/07, TaMeR <[EMAIL PROTECTED]> wrote:
>
> The standard URLField is to short for the google maps.
> I have a basic route that is almost 300 char long and they will get
> longer.
> I am developing on sqlite3 but I think it has something to do with
> Django.
> Does anybody know how I can fix that?

The newforms URLField has no hardcoded limits. Are you sure your field
in the database is long enough to store the field? Try just returning
a page with the submitted URL, so you can see if it breaks somewhere
in your code, or it's truncated in the database.

Also - when storing URLs - remember that they can grow quite large and
there is no upper limit defined by the specifications.  It all depends
on how much data will the browsers and backends accpet. Make sure you
use an appropriate field, that can store quite long URLs, if you want
to be sure it'll work for anything.

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



Re: HowTo assign user to group at registration

2007-04-03 Thread Atilla

On 03/04/07, TaMeR <[EMAIL PROTECTED]> wrote:
>
>
> I use two registration forms one for clients one for vendors.
> Depending on form used I would like to assign the user to a group.
>
> How do I use new_user.groups.add('Client')
>
> Below is my code that does not raise any errors but also does not add
> the user to the group.
>
> =  CODE =
> def register(request, success_url='/accounts/register/complete/'):
>
> Context::
> form
> The registration form
>
> Template::
> registration/registration_form.html
>
> """
> if request.method == 'POST':
> form = RegistrationForm(request.POST)
> if form.is_valid():
> new_user 
> =RegistrationProfile.objects.create_inactive_user(username=form.clean_data['username'],
>
> password=form.clean_data['password1'],
>
> email=form.clean_data['email'])
> new_user.groups.add('Client')
> return HttpResponseRedirect(success_url)
> else:
> form = RegistrationForm()
> return render_to_response('registration/registration_form.html',
>   { 'form': form },
>   context_instance=RequestContext(request)
>  )
>
>

If i remember correctly, .add() takes an object that it needs
association to, so you'll have to do (where condition expresses which
group you want to add the user to):

group  = Group.objects.get(condition)
new_user.groups.add(group)

I'm not sure why it doesn't raise errors there though, if .add() only
accepts a related object.

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



Re: Dynamic query building

2007-04-03 Thread Atilla
On 03/04/07, Honza Král <[EMAIL PROTECTED]> wrote:
> something like this works for me...
>
> q = Q( tag__name=first_tag )
> for tag in other_tags:
>   q = q | Q( tag__name=tag )

What kind of query does this build BTW? Is it smart enough to put them
all into a "WHERE name IN ( all-your-tags-here) ?

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



Re: Ordered list of objects?

2007-04-04 Thread Atilla

On 04/04/07, Nathan R. Yergler <[EMAIL PROTECTED]> wrote:
>
> I'm working on an app for a client, and one of the requirements is
> that they be able to re-order objects in the admin interface.  I know
> exactly how I'd do with with an object database, but the ideas I've
> come up with for doing it with Django all involve using some tracking
> field, and then updating that to contain the relative order of
> objects.
>
> So... am I missing something obvious here that will let me do with
> with a minimal amount of pain?
>
> Thanks,
>
> Nathan

What kind of ordering does it have to be and on what amount of items?
Perhaps it could be useful to create a separate Model that defines the
order of items, with a relation to the actual model that defines the
objects themselves. The biggest issue is how to create usable controls
that define the ordering, which is not always a simple thing to
implement.

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



Re: Per-app permissions ?

2007-04-04 Thread Atilla

On 03/04/07, Chris Brand <[EMAIL PROTECTED]> wrote:
>
> What's the best way to restrict access on a per-app basis ?
> I want to have two apps, with some users allowed access to one, others
> allowed access to the other, and some allowed access to both.
>
> Any advice would be very much appreciated.
>
> Thanks,
>
> Chris
>
  You could define custom permissions, that are controllable trough
the admin interface. Then in your views you can use the permission
required decorator, to define what permission is required for
accessing those ( i think there was a way to add this in your url
configuration as well, so then you'd simply add a different permission
required for each app and that'd be all, but i'm not sure how it's
done). And then you can define user groups that have the different
permission sets for each/both apps and assign users to those in the
admin interface.

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



Re: Using a ForeignKey in ordering

2007-04-04 Thread Atilla

On 04/04/07, James Turnbull <[EMAIL PROTECTED]> wrote:
>
> I'm trying to group items in the Admin interface based on a foreign
> key, and I'm hitting a few stumbling blocks.
>
> Simplified objects are...
>
> > class MenuItem(models.Model):
> > name = models.CharField(maxlength=200)
> >
> > class Page(models.Model):
> > name = models.CharField(maxlength=200)
> > menu_item = models.ForeignKey('MenuItem', blank=True, null=True)
> >
> > class Meta:
> > ordering = ('menu_item_id')
>
> What I want is on the "Page" admin screen to display the objects in
> the order of their related MenuItems.
>
> I managed to get this to work, using the above argument of
> 'menu_item_id', but manage.py gives the following error:
>
> > Error: Couldn't install apps, because there were errors in one or
> > more models:
> > pages.page: "ordering" refers to "menu_item_id", a field that
> > doesn't exist.
>
> If I tried ordering = ('menu_item') then the Admin interface bombed
> out due to broken SQL - the ORDER BY referenced the menu_item table
> but it was not in the FROM clause.
>
> I considered the 'order_with_respect_to' option, but it would appear
> to serve some other function (although I'm not sure exactly what that
> is...)
>
> So, my questions a) Is this a bug or am I missing something and b) If
> this is a bug would the correct solution be to patch the manager to
> accept _id in ordering or patch the SQL query to use the correct tables?
>
> Thanks,
>
> James

There was a simmilar question a couple of days ago:

On Mar 31, 7:14 am, Gilhad <[EMAIL PROTECTED]> wrote:
> I have something like this:
>
> class Project(models.Model):
> name = models.CharField(maxlength=10)
> order = models.IntegerField()
> 
> def __str__(self): return self.name
>
> class Task(models.Model):
> project = models.ForeignKey(Project)
> description = models.CharField(maxlength=100)
>
> Is there a way in Admin, when editing Task, to have the Select field for
> Project sorted by Project.order (or at least by Project.name) instead of
> Project.id?
>
> (The Project.id order looks pretty chaotic, as it reflex the time (id is
> AutoField), when the Project was entered, which is surely not too much
> descriptive, as many related Projects are entered at very different times)
>
> --
> Zdravi
>  Gilhad
>  [EMAIL PROTECTED]


How about

   class Meta:
   ordering = ['name']

More info:
http://www.djangoproject.com/documentation/0.95/model-api/#id5

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



Re: built-in comment system with custom views

2007-04-04 Thread Atilla

On 03/04/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I was following tutorial on django built-in comment system in wiki on
> djangoproject.com; Everything went fine, however, I can't figure out
> how to use them with custom views, I keep getting different errors.
> Tutorial example works only with generic views.
>

If you got the tutorial straight, that's good, but you have to
consider that it is a special case, demonstrating the most generic
Django capabilities. I'd advise you to read up on the documentation on
the website, see how views are created and used and slowly start
writing your own. If you're getting errors that you can't understand
from the documentation, paste them here, or ask directly on the IRC
channel, so people can help you out with the specifics.

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



Re: Bad SQL when ordering a model by related models

2007-04-10 Thread Atilla
> - structure/models.py
> class Issue(models.Model):
> (...)
> pub_date = models.DateField('Publication date', unique=True)
> (...)
>
> class Meta:
> ordering = ['-pub_date']
> -
>
> - stories/models.py
> class Story(models.Model):
> (...)
> issue = models.ForeignKey(Issue)
> (...)
>
> class Meta:
> verbose_name_plural = "Stories"
> ordering= ['issue']
> -
>
> Returns the error: "OperationalError at /admin/stories/story/ (1054,
> "Unknown column 'structure_issue.-pub_date' in 'order clause'")"
>
> SQL:
> 'SELECT
> `stories_story`.`id`,`stories_story`.`head`,`stories_story`.`deck`,`stories_story`.`slug`,`stories_story`.`section_id`,`stories_story`.`issue_id`,`stories_story`.`content`,`stories_story`.`summary`,`stories_story`.`photo`,`stories_story`.`caption`,`stories_story`.`photographer_id`,`stories_story`.`section_order`,`structure_section`.`id`,`structure_section`.`name`,`structure_section`.`short_name`,`structure_section`.`slug`,`structure_issue`.`id`,`structure_issue`.`volume_id`,`structure_issue`.`issue`,`structure_issue`.`extra`,`structure_issue`.`pub_date`,`structure_issue`.`sections_id`,`structure_issue`.`is_published`,`structure_volume`.`id`,`structure_volume`.`volume`,`structure_flatplanorder`.`id`,`structure_flatplanorder`.`name`,`structure_flatplanorder`.`section1_id`,`structure_flatplanorder`.`section2_id`,`structure_flatplanorder`.`section3_id`,`structure_flatplanorder`.`section4_id`,`structure_flatplanorder`.`section5_id`,`structure_flatplanorder`.`section6_id`,`structure_flatplanorder`.`section7_id`,`structure_flatplanorder`.`section8_id`,`structure_flatplanorder`.`section9_id`,`structure_flatplanorder`.`section10_id`,`structure_flatplanorder`.`section11_id`,`structure_flatplanorder`.`section12_id`,`structure_flatplanorder`.`section13_id`,`structure_flatplanorder`.`section14_id`,`structure_flatplanorder`.`section15_id`,`structure_flatplanorder`.`section16_id`,`structure_section5`.`id`,`structure_section5`.`name`,`structure_section5`.`short_name`,`structure_section5`.`slug`
> FROM `stories_story` , `structure_section`, `structure_issue`,
> `structure_volume`, `structure_flatplanorder`, `structure_section`
> `structure_section5` WHERE `stories_story`.`section_id` =
> `structure_section`.`id` AND `stories_story`.`issue_id` =
> `structure_issue`.`id` AND `structure_issue`.`volume_id` =
> `structure_volume`.`id` AND `structure_issue`.`sections_id` =
> `structure_flatplanorder`.`id` AND
> `structure_flatplanorder`.`section1_id` = `structure_section5`.`id`
> ORDER BY `structure_issue`.`-pub_date` ASC'
>
> It seems as though Django's not recognizing its own ordering syntax
> when attempting to sort objects based on a related object's ordering.
> I should also mention that if I sort Issue by ['pub_date'] and Story
> by ['-issue'] everything works fine. I'm still willing to do that as a
> workaround, but I figured there might be a lot of instances where
> that's either not ideal or impossible.

I don't think you're doing anything incorrect here. If this ordering
behavior is supposed to be undefined, it's not documented as such. I'd
consider filing a ticket for that issue, so it might get more
attention.

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



Re: Providing action specific feedback messages to users and HttpResponseRedirects

2007-04-13 Thread Atilla

If you're simply trying to display error messages, if something is
invalid - check carefully how this is being done in the examples in
the documentation. The idea here is that you issue a redirect only
when your data is validated, your object is saved and you must proceed
to a different step. Now - if you want to return the same form on
success, but still add an extra message - you can do different things.

Quite a lot of people are happy with adding a get parameter in the URL
and displaying a message, if it's set. just redirect to
"your_form?success=true", for example. Another way would be to
redirect to "your_form/success", and setting up the pattern in the
URLconf to match the success as an optional variable, that gets passed
to the view. In essence  - the effect is the same, it only matters
what you prefer as a concept.

I am sure there are other curious ways of doing that - using the
session variables, for example, just make a pick that you find more
reasonable.

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



Re: content type for html parts

2007-04-13 Thread Atilla

The correct type for HTML documents is text/html. The correct type for
XHTML documents "should" be application/xhtml+xml, however - IE (maybe
not all versions) will bork on that and will not render, but instead
give you a save dialog.

If your validator fails on "partial" documents, that should be
expected, unless you can instruct it in a way that it knows it's a
partial code it's processing. I am not sure that there's a type that
explicitly defines the content as partial-XML though. I'd say that you
should keep the content type what it originally was (say
application/xhtml+xml), since it's essentially the correct type for
what you're serving. See http://www.ietf.org/rfc/rfc3023.txt  and/or
http://www.w3.org/TR/xhtml-media-types/.

I'm not really sure what'd be fully correct in your case, to be
honest, the media type specifications are quite messy on that. And
again - mind that "application/xhtml+xml" Will break in some
implementations of IE.

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



Re: a way to find out which page (as determined by the paginator) that a specifc object occurs on?

2007-04-16 Thread Atilla

> Of course one should not assume that post pk's are monotonically
> increasing as the order the query set is sorted by can have no
> relation to the post pk's. This means we can not even do something
> simple as a binary search of slices of the query set.

If it were the case, it'd be farily easy to find what you need, true.
However - what you're trying to do looks a bit too specific to handle
it in such a generic way. If you have a discussion list, probably the
posts in it follow some logical flow that you don't want to disrupt -
is that the case ? What I mean is - would you have views, that display
your model items with different order_by clauses ? If not - there is
an answer to "If I could find an efficient way to do "find the index
in the given qs
of the object with pk = " - add an extra column in your model
that describes that, and use it to find the page for your permalinks.

You could keep the page, where each item is located in, but that's not
a good solution, since it'd force your views to a singe page size.

I'm interested a way that could be handled as well, if there are any
reasonable solutions

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



Re: temp tables

2007-04-16 Thread Atilla

> Is there a way to force the db connection to stay open if you are
> excecuting raw sql that is creating a temp table?  When the connection
> closes...the temp tables go away.
>

Temp tables are meant to be temporary.  You can't guarantee, even with
persistent db-connection pooling that the same user would use the same
connection on the next request, so you can't guarantee that the temp
table, with the data from the previous request will be there.

What exactly are you trying to do - temporary tables are the good
solution to quite specific problems, there might be a better way to do
whatever you're attempting.

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



Re: etag and 404.

2007-04-16 Thread Atilla

> When I enable etags, django is sending back an etag on 404 pages.
> When a client does a subsequent request for  the same nonexistent
> page, a 304 response is sent back, because the page has not changed
> (based on the etag).
>
> When I disable etags, multiple requests for a non existent page all
> return 404 as expected.
>
> Is there a way to disable etag generation on 404 pages, while still
> performing it on all 'real' pages?

I guess the simplest thing would be to write a middleware class, that
inherits the conditional get middleware, overloads the method and
simply add a condition, that checks the status code of the response.
If it's 404, remove the Etag. Then use that middleware instead of the
normal one.

I think the behaviour is correct though, why do you want to redefine it ?

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



Re: temp tables

2007-04-17 Thread Atilla

On 16/04/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> We are trying to use them to generate a report where a bunch of
> calculations are being made... via a custom sql query... then hand all
> of the results back to my django view to display.
>
> After they are displayed...they can be nuked...but the guy working on
> this piece told me he couldn't get the temp table to stick around long
> enough with the django connection to be able to get the results back
> because I believe he runs several queries...then compiles them all
> into one be result ( not sure on this, as he is writing it, and I
> haven't reviewed his code as of yet ) ...  so he started hardcoding
> the db un/password in there and creating a mysqldb connection...which
> I didn't agree with...so thought I'd ask about it on here.
>
> I'll have to look deeper into his code to see exactly what he may be
> doing wrong...but I thought I'd ask on here...just to find out if
> there were any special types of things you needed to do with temp
> tables.

If the report can't be created and displayed in a single-step view,
using python/django/sql as needed,  you might also want to create a
special table/model that keeps the results of reports/summaries you're
making, so they persist and can be rendered in a different view. You
can always purge that table afterwards. You can even create it as a
HEAP table, if it won't be growing too big and keep it small and fast
in-memory.

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



Re: etag and 404.

2007-04-17 Thread Atilla

On 16/04/07, cactus <[EMAIL PROTECTED]> wrote:
>
> > I think the behaviour is correct though, why do you want to redefine it ?
>
> If the behavior is indeed correct, then I don't think I need to
> redefine it.
> It just seemed odd to return a 'not-modified' response to a query for
> a page that did not exist.
>
> Apache, when configured with mod_expires, does *not* return etags on
> 404 responses, but of course does on 200 responses.
>
> Based upon that, to me it seemed like incorrect behavior.

Correct, but a browser, or a proxy server in the request chain would
get the not-modified, only if it already got the correct response
once, so essentially what is being said is "the page you're requesting
is still not there", with the 404 page you've already sent. It's not
stopping you to redefine the behaviour though - you're always free to
do that, if you find it odd or inconsistent.

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



Re: etag and 404.

2007-04-18 Thread Atilla

I stand corrected, thank you for the referenced reply. I've missed
that part of the specification. If you make any changes to the
conditional get middleware, please consider sending a patch for it,
that could be incorporated in the code later, hopefully.

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



Re: why there is no something like HttpResponseRedirect but status is 303

2007-04-18 Thread Atilla

On 18/04/07, Gilbert Fine <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
>According to HTTP standard, the meaning of 303 status is (copied
> from rfc2616):
>
> 10.3.4 303 See Other
>
> The response to the request can be found under a different URI and
> SHOULD be retrieved using a GET method on that resource. This method
> exists primarily to allow the output of a POST-activated script to
> redirect the user agent to a selected resource. The new URI is not a
> substitute reference for the originally requested resource. The 303
> response MUST NOT be cached, but the response to the second
> (redirected) request might be cacheable.
>
> The different URI SHOULD be given by the Location field in the
> response. Unless the request method was HEAD, the entity of the
> response SHOULD contain a short hypertext note with a hyperlink to the
> new URI(s).
>
>   Note: Many pre-HTTP/1.1 user agents do not understand the 303
>   status. When interoperability with such clients is a concern,
> the
>   302 status code may be used instead, since most user agents
> react
>   to a 302 response as described here for 303.
>
>As tested in my browser, we need 303 status, instead of 302. But
> don't see wrapper like HttpResponseRedirect to do this. So I am
> curious, I am the only one that want to use status 303?
>
>Thanks.

Setting the status to whatever you want is fairly straightforward. If
you find yourself in need to use it frequently, you can define a
subclass of HttpResponse, that sets the necessary information as
needed. You can file a ticket with the code attached, if you believe
it should be included in the framework.

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



Re: Encoding in models.py (and maybe other files too)

2007-04-18 Thread Atilla
> >> just asking :)
> >
> > I don't know about Nicolas, but I'm writing something for a
> > Spanish-speaking customer, so I might have a TelephoneField
> > ("teléfono") in there, for example.
>
> the way to do it is verbose_name = _("telephone")

Yes, instead of naming your models with "funky" characters, you can
always set the verbose displayed name to whatever you need it to be.

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



Re: Encoding in models.py (and maybe other files too)

2007-04-18 Thread Atilla

On 18/04/07, mamcxyz <[EMAIL PROTECTED]> wrote:
>
> > Yes, instead of naming your models with "funky" characters, you can
> > always set the verbose displayed name to whatever you need it to be.
>
> The are not funky. Are the normal characters in each labguage. Anyway,
> that show too if the "funky" chars appear in "text" so

Ah, so I've misunderstood what the problem is. I usually try to make
everything in utf-8 from the very beginning, since I've had a lot of
encoding issues in past projects, so when I encounter these errors the
usual suspect is mixing Unicode and non-Unicode strings. As long as
you keep that consistent and set your encoding correct, things will be
pretty much OK. But I have to agree with Malcolm here - adding a
default would just result in people asking the reverse question - "why
does my code break in configuration X?".

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



Re: "mpm-prefork" vs. "mpm-worker"

2007-04-25 Thread Atilla

In my experience so far, there's nothing that prevents you from
efficiently using the worker MPM with the latest
Apache/Mod_python/Django versions.

You have to be more careful when it comes to configuration,
optimization, concurrency-load-memory when running under worker MPM,
but so far I haven't hit a problem.

When it comes to multiple installations, I've no practical knowledge
on the question, but it seems to me, from the posts and links above,
that it is mostly a configuration issue, rather than the worker MPM
specifics.

I personally find it Very bad to bind Django users to 1 apache worker
model, considering how the Apache modules progress and the performance
you can get out of using clever configurations.

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



Re: "mpm-prefork" vs. "mpm-worker"

2007-04-26 Thread Atilla

On 26/04/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
>
> On Apr 25, 7:10 pm, Atilla <[EMAIL PROTECTED]> wrote:
> > I personally find it Very bad to bind Django users to 1 apache worker
> > model, considering how the Apache modules progress and the performance
> > you can get out of using clever configurations.
>
> Can you elaborate on this further? I often see people being critical
> of worker MPM but they normally don't explain why they think it is bad
> and provide justification.
>
> Specifically, what sort of configuration are you talking about when
> you say "1 apache worker"? Default configurations of worker MPM still
> use multiple Apache child processes so you aren't normally channeling
> all requests through one process. Also, the GIL is not as big an issue
> as people think it is when using Apache as there can be a lot of other
> stuff happening at the same time which isn't being done in Python so
> you still achieve a fair degree of parallelism.
>
> I've ranted about this recently in:
>
>   http://groups.google.com/group/karrigell/browse_frm/thread/488ffd42cee600b4
>
> so will not post all the details again.
>
> Graham
>

Perhaps I haven't expressed myself too clearly, since I think there's
a misunderstanding here. I was saying that I find it bad to tell
people that they should only use "prefork" as the MPM in Apache,
especially not providing a good explanation for that.

I am not critical of the worker MPM, in fact I was saying that I
rather like it and I have used in different places. There are new MPMs
for apache, in development that also look quite promising, should they
reach a stable implementation. Depending on the nature of your
application and the code that's being used, you can have significant
gains, depending on the module and configuration being used.

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



Re: How to change the encoding from UTF-8 to something else ?

2007-05-15 Thread Atilla

On 15/05/07, Martin Tomov <[EMAIL PROTECTED]> wrote:
>
> http://code.djangoproject.com/ticket/72
>
> About this tichet. The last question is mine.
>
> How to change the encoding, sent by the HTTP headers to something
> else, but UTF-8 ? The meta thing in the html is useless.
>
> Thanks

This ticket is 2 years old and was marked as fixed.

What version are you using and have you set the encoding variable in
your settings file correctly ? The HTTP headers that are sent in my
applications are correct and do include the correct encoding in the
Content-Type header. I am running with code checked out from SVN
around a month ago.

The meta tag in the actual HTML is not useless, but it's
interpretation is dependant on the browser. Generally, when no
encoding information is specified for the document the browser will
either "guess" it (IE) or assume a default value. If it encounters the
correct meta tag, it will re-parse the document using the encoding
specified in there. This is the behavior for every reasonable browser,
but the "correct" thing to do is to always have a proper HTTP header,
specifying the encoding.

Also - what is wrong with UTF-8 and why do you want to change it ?

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



Re: More info in Django server logs

2007-05-16 Thread Atilla

On 15/05/07, Kostadin Cholakov <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> We are using the development server only! Can you give me some
> reference for the necessary changes in the code? Thanks!
>
> On 5/15/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> >
> > On Tue, 2007-05-15 at 19:14 +, Kostadin Cholakov wrote:
> > > Hello,
> > >
> > > We are currently using Django for access to a linguistic database
> > > where people can validate certain entries by checking certain
> > > checkboxes! We have the problem that the users are not in our
> > > departament and they are connected to Internet through a different
> > > proxy server. When the annotators check boxes and go to the next page
> > > and then again go back, the boxes are not checked anymore. We tried to
> > > reproduce this error with different browsers but we were not able to
> > > do this! So, we susspect that their server caches some pages and when
> > > the annotators go back to a previous page, it doesn't invoke GET to
> > > get a fresh page with the updated entries and checkboxes but rather
> > > their server takes the original cached page! We would like to see
> > > which machine exactly accesses our database and see what kind of
> > > request it makes... But the log files just show the URL which is being
> > > used, the time and POST or GET... Is there any way that one could
> > > retrieve more information like IP for example? I am new to Django and
> > > I was not able to find something on this issue! Thanks!
> >
> > It depends on what web server you are using. Every web server has ways
> > to configure what information is logged.
> >
> > If you are just using the development server, then you're out of luck
> > without changing the code.
> >
> > Regards,
> > Malcolm
> >

If this application is not going to be very limited use, in-house
only, with no more than 1 person making requests at a time,  then
you'd better consider hosting it in a proper environment. Where proper
is anything to your liking, except the development server. If people
are going to use this thing, you'll run in a lot more issues than the
current one you're having.

I'd say that catching up with the documentation about deployment,
instead of applying duct-tape patches will result in a lot less
trouble for you.

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



Re: browser detection middleware

2007-05-22 Thread Atilla

On 22/05/07, omat <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> Is it a good idea to use a middleware class to detect the browser
> client looking at the HTTP_USER_AGENT so as to serve presentation
> logic accordingly, for mobile devices or older browsers, etc...?
>
> I know this is mostly done by 

Re: Generell Questions on Django

2007-05-23 Thread Atilla

On 23/05/07, OliverMarchand <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I am new to Django (4+years Python experience) and would like to
> evaluate for my financial company whether Django may be a good
> solution to our problem of designing our applications all a-z from
> scratch. Now my colleagues first reaction was very defensive:
> a) that's for websites, not serious applications
> b) it will be slow, ORMs are always slow
> c) those HTML forms are too limiting
>
> I have the feeling that all of the above do have some truth ion them,
> but weighed against all of the beneficial factors it seems that a
> Django solution would overall be a very good idea.
>
> Now I know that my statements are very generell. I have looked at the
> list of sites and some of them are imressive enough to show some of
> what I would like to point out. But do you have any quick comments on
> these issues?
>
> thanks, Oliver

It all depends on what do you want to do. Maybe you can give us some
details - django is good, but it's not good for Everything.

a - I thought websites should be serious applications.

b - That statement is weak, many things are "slow" compared to lower
level implementation, but are a lot better in other ways. With the
hardware that "serious applications" will be running on, "slow" is a
term that does not apply. The amount of requests per second I can get
out of my django-based systems is impressive.

c - noone is forcing you to use them in the way they're defined. You
can make your own, or not use them at all, if you don't need them.

Again, it only depends on what are you trying to write.

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



Re: "showable" but not "editable" field in the Admin screens

2007-05-23 Thread Atilla

On 23/05/07, Brian Rosner <[EMAIL PROTECTED]> wrote:
>
> You may also want to check out http://code.djangoproject.com/ticket/3990.
>
> On May 22, 5:19 am, "Seiji - technics" <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > Is there a way to show as specific field in the admin screens but
> > without permitting to edit it?
> > I want something similar to "editable=False" option but without
> > excluding the field from the screen.
> >
> > Thanks in advance for the help.
> >
> > Seiji

On that note - the name "editable" is a bit misleading. i expected it
to define the field as read-only, not as completely invisible in
generic forms.

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



Re: subclassing of models

2007-05-23 Thread Atilla

On 23/05/07, OliverMarchand <[EMAIL PROTECTED]> wrote:
>
> Dear Djangos,
>
> Is it possible to subclass a model? This example somehow doesn't work
> for in the sense that I only see the geography on the admin screen.
>
> 
> from django.db import models
>
> class Geography(models.Model):
> name = models.CharField(maxlength=30)
> def __str__(self):
> return self.name
> class Admin:
> pass
>
> class Continent(Geography):
> pass
>
> class Country(Geography):
> continent = models.ForeignKey(Continent)
> ---
>
> Any ideas?
>
> greetings, Oliver
>

Model Inheritance is, sadly, not supported and the branch that
implements that is stalled (or is it ?).

For now  - one of the ways people prefer to do similar things is to
associate entries in the models, via a relationship. You can search
the mailing list archive for different solutions that people have
tried.

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



Re: How to define unsigned integer primary keys with auto increment for MySQL

2007-05-23 Thread Atilla

On 23/05/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Tue, 2007-05-22 at 06:43 -0700, Fay wrote:
> > I'm using MySQL. The primary key field generated by django uses
> > integer, not unsigned. I'd like to us unsigned integer instead. I can
> > explicitly specify PositiveIntegerField with primary_key option, but
> > that doesn't seem to give me auto increment. Any ideas? Thanks.
>
> Write the necessary SQL to alter the table after it's created and put it
> in the "initial SQL" file for that model. See the model-api docs for
> more information on initial SQL.
>
> Regards,
> Malcolm
>

However, it doesn't make much sense to have signed auto-incremental
keys, does it?

I'd say that unsigned should be the default result, instead of having
to define this yourself. What are the reasons for having them signed
by default ? Database engines with no support for signed/unsigned
columns ?

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



Re: LIKE '%something%' custom queries

2007-05-23 Thread Atilla

On 23/05/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I'm reimplementing an in-database tree system and I'm using custom SQL
> queries. I want to use % in LIKE but Django doesn't let me.
>
> The code:
> ##
> def getBranch(table_name, parent_depth, parent_cutLevel, max_depth):
> cursor = connection.cursor()
> cursor.execute("SELECT *, INSTR(level,'0')-1 AS depth,
> INSTR(level,'0')-1 - "+ parent_depth +" AS relativeDepth FROM  " +
> table_name + " WHERE level LIKE '"+ parent_cutLevel +"%' AND
> INSTR(level,'0')-1 <= ("+ max_depth +"+"+ parent_depth +") ORDER BY
> level")
> row = cursor.fetchall()
> return row
> ##
>
> The exception:
> ##
> not enough arguments for format string
> Exception Location: /usr/lib64/python2.4/site-packages/django/db/
> backends/util.py in execute, line 19
> ##
> I can "print" the query string, but can't make the query as cursor
> code uses %letters... Is there a solution for this. ( \ doesn't work,
> % in variable also)
>

Umm... the "%" symbol has a special meaning in a string, which is to
interpolate it and fill it with arguments from a provided list. In a
cursor it's a variable placeholder used for prepared (or normal)
queries. If you want it literal, you must escape it properly.

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



Re: subclassing of models

2007-05-23 Thread Atilla

> Given that there is no branch, that statement is incorrect.
>
> Model inheritance is two stations down the line. Unicode gets finished
> first, then query refactor then model inheritance.
>
> Regards,
> Malcolm


Well, I'm certainly  glad to know this. I hadn't checked up on it for
a long time. I'll do my research  better next time.

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



Re: Django Forms

2007-05-25 Thread Atilla

On 24/05/07, robo <[EMAIL PROTECTED]> wrote:
>
> Hi everyone. for the code below at 
> http://www.djangoproject.com/documentation/forms/
>
> def create_place(request):
> manipulator = Place.AddManipulator()
>
> if request.method == 'POST':
> # If data was POSTed, we're trying to create a new Place.
> new_data = request.POST.copy()
>
> # Check for errors.
> errors = manipulator.get_validation_errors(new_data)
> manipulator.do_html2python(new_data)
>
> if not errors:
> # No errors. This means we can save the data!
> new_place = manipulator.save(new_data)
>
> # Redirect to the object's "edit" page. Always use a
> redirect
> # after POST data, so that reloads don't accidently create
> # duplicate entires, and so users don't see the confusing
> # "Repost POST data?" alert box in their browsers.
> return HttpResponseRedirect("/places/edit/%i/" %
> new_place.id)
> else:
> # No POST, so we want a brand new form without any data or
> errors.
> errors = new_data = {}
>
> # Create the FormWrapper, template, context, response.
> form = forms.FormWrapper(manipulator, new_data, errors)
> return render_to_response('places/create_form.html', {'form':
> form})
>
> What does the line "return HttpResponseRedirect("/places/edit/%i/" %
> new_place.id)" mean? Why do we redirect to .../edit/... ? Does this
> mean I have to create a view for this url? I am very confused about
> this and I need clarification. Thanks.

The reason for the redirect is stated in the comment over there. You
can issue a redirect to any page to your liking, including the same
one, if needed. In this case a successful post redirects you to the
page where the newly creared item is displayed. You don't have to do
it this way, if you don't want to.

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