Re: Easy question (I hope)

2011-10-12 Thread Tom Evans
On Fri, Oct 7, 2011 at 8:31 PM, Oscar Carballal  wrote:
> I was watching this thread for a while now, and I've got a question.
>
> What is the reason to split the models.py file? I mean, I'm currently
> working on a django project, and the models are pretty "simple" (I
> usually split them into apps) the biggest models file has five or six
> models in the same file. Should I split it? Why?
>
>

To keep each models file small enough that you can find the model you
were looking for quickly, and avoiding a >3k line models.py. One of my
apps has >50 models, having all of them in one file would result in
too much code in one file for my liking.

It splits up the code into nice chunks, making it easier to review,
refactor, modify and document. At least that is the idea.

Cheers

Tom

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



Re: Easy question (I hope)

2011-10-12 Thread Tom Evans
On Fri, Oct 7, 2011 at 4:25 PM, Shawn Milochik  wrote:
> On Fri, Oct 7, 2011 at 11:15 AM, Tom Evans  wrote:
>>
>> I do this a lot, and haven't found any problems with doing so. My main
>> app has no models.py, but has models/{__init__,foo}.py, and it is
>> still found quite happily by syncdb, south, the admin interface, the
>> app template loader etc.
>>
>> Is there a concrete example of a thing that will not work with this
>> structure?
>>
>> Cheers
>>
>> Tom
>>
>>
> If that's the case then I'm wrong. I guess Django just needs to be able to
> import 'models' from the app root. I specifically remember reading that
> 'models.py must exist' whether your app has models or not, or Django won't
> consider it an 'app.' I took that literally. I didn't consider that it might
> be checking by attempting to import rather than checking for the existence
> of a certain filename, and I never tried to do it otherwise.
> Example from docs:
> https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ (says
> models.py must exist for tests to be discovered)
> Ticket:
> https://code.djangoproject.com/ticket/4470 (seems to indicate things don't
> work properly without a single models.py file)
> Shawn
>
>

The documentation is incorrect there - the requirement is that you
have a models module in your app, which has been mistranslated into
'you must have a models.py'.

However, that ticket has reminded me of an issue that you will get -
the app_label of your models will be incorrect. I forgot to mention
that I use a base model class for all models in a subdivided app. This
base model provides the correct app_label in its Meta class (which
means if you define a Meta class on your models, then it must derive
from the base model's meta).

Eg:

  class BaseModel(Model):
  class Meta:
  abstract = True
  app_label = 'the_app_name'

  class Foo(BaseModel):
  name = models.CharField(max_length=32)

  class Bar(BaseModel):
  name = models.CharField(max_length=32)
  location = models.CharField(max_length=32)
  class Meta(BaseModel.Meta):
  unique_together = ( ('name', 'location'), )


Cheers

Tom

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



Re: Why can't "directly" change array elements of model objects in Django shell?

2011-10-12 Thread Tom Evans
On Fri, Oct 7, 2011 at 10:01 PM, Chris Seberino  wrote:
>
>
> On Oct 7, 10:39 am, Jacob Kaplan-Moss  wrote:
>> On Fri, Oct 7, 2011 at 10:30 AM, Chris Seberino  wrote:
>>
>> > I've noticed that this doesn't often work in Django shell...
>>
>> > x = MyModel.objects.all()
>> > x[3].some_field = "new value"
>> > x[3].save()
>
>> This is because `MyModel.objects.all()` isn't a list; it's a QuerySet.
>> That is, `MyModel.objects.all()` *doesn't* hit the database until you
>> say `x[3]`, at which point Django performs a query with a LIMIT and
>
> OK.  I understand.  What is easiest way then to *force* my x[3] code
> above to hit the database so that
> my changes are permanent?

x = list(MyModel.objects.all())
x[3].some_field = "new value"
x[3].save()

Cheers

Tom

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



RE: Alternative to the .using() method

2011-10-12 Thread Sells, Fred
Thanks, is exactly what I need.

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jacob Kaplan-Moss
Sent: Tuesday, October 11, 2011 5:36 PM
To: django-users@googlegroups.com
Subject: Re: Alternative to the .using() method

On Tue, Oct 11, 2011 at 3:47 PM, Sells, Fred
 wrote:
> I'm using a MySQL database and one table resides in a separate database
> than all the others.  It's a generic logging table.
>
> I understand the use of the .using() method, but I wonder if there is a
> way to specify the alternative model in the model definition so I don't
> have to depend on remembering to add the .using() method in any usage.
>
> I could create a view in mysql and make the model "unmanaged" but was
> wondering if there is a more pythonic way?

Indeed there is: what you're looking for is called a "database
router", and you can find documentation here:
https://docs.djangoproject.com/en/dev/topics/db/multi-db/#automatic-database-routing

In your particular case, you'll implement something very similar to
the first example presented there: if the app is your logging app, use
the logging connection; otherwise, use the default connection.

Jacob

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


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



Re: django and unicode

2011-10-12 Thread refreegrata
For example in PostgreSQL, at least from the 8.3 version, you can't
have, in the same server, databases with differents encoding. But can
be defined a client_encoding for any database. With this you can have
a database with encoding='latin1' and client_encoding='utf8'. In
postgresql the client_encoding is a connection property to solve this
problems and avoid complications with weird characters.

However for any encoding just some client_encodings are valid. To
latin1 is valid a client_encoding=utf8 but isn't valid a
client_encoding=EUC_TW (traditional Chinese, Taiwanese). For that is
important read the PostgreSQL documentation.

Well, I don't know if you're using PostgreSQL. If you use another
DBMS, this answer isn't very useful.

I sorry if my english is too rough, but isn't my mother language.
Cheers.

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



configuring

2011-10-12 Thread yezi
hey everyonei just cant proceed my work with django application
because some running errors on configuring mysql and the django frame
work.if u please get me a solution i will be honored to
receive.

i kinda of get an error message


C:\Django-1.3\newproject\djangoblog>python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 14, in 
execute_manager(settings)
  File "C:\Python25\Lib\site-packages\django\core\management
\__init__.py", line
438, in execute_manager
utility.execute()
  File "C:\Python25\Lib\site-packages\django\core\management
\__init__.py", line
379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python25\Lib\site-packages\django\core\management
\__init__.py", line
261, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "C:\Python25\Lib\site-packages\django\core\management
\__init__.py", line
67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name,
name))
  File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line
35, in im
port_module
__import__(name)
  File "C:\Python25\Lib\site-packages\django\core\management\commands
\syncdb.py"
, line 7, in 
from django.core.management.sql import custom_sql_for_model,
emit_post_sync_
signal
  File "C:\Python25\Lib\site-packages\django\core\management\sql.py",
line 6, in
 
from django.db import models
  File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 78,
in 
connection = connections[DEFAULT_DB_ALIAS]
  File "C:\Python25\Lib\site-packages\django\db\utils.py", line 93, in
__getitem
__
backend = load_backend(db['ENGINE'])
  File "C:\Python25\Lib\site-packages\django\db\utils.py", line 33, in
load_back
end
return import_module('.base', backend_name)
  File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line
35, in im
port_module
__import__(name)
  File "C:\Python25\Lib\site-packages\django\db\backends\mysql
\base.py", line 14
, in 
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module: No mo
dule named MySQLdb

C:\Django-1.3\newproject\djangoblog>

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



django-markitup MARKITUP_FILTER configuration

2011-10-12 Thread Э . Мягмаржав
How to set MARKITUP_FILTER setting?
and how to render  MarkupField() to html template with Bold,Italic,
Underline 

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



Re: django and unicode

2011-10-12 Thread Elim Qiu
Thanks refreegrata. I know PostgreSQL is a good RDBMS, but tough on encoding...
I'll start django with MySQL. By doing this, mysql shell cannot do
much data manipulation already...

In php, utf8 tables is not enough. Every time connect to mysql
database, you need to say

mysql_query("SET character_set_results=utf8",$connect);
mysql_query("SET NAMES 'utf8'");


Ideally I can just do everything with utf8. But there are some
non-django apps just not doing well with utf8 I need to work with.



On Wed, Oct 12, 2011 at 6:54 AM, refreegrata  wrote:
> For example in PostgreSQL, at least from the 8.3 version, you can't
> have, in the same server, databases with differeTnts encoding. But can
> be defined a client_encoding for any database. With this you can have
> a database with encoding='latin1' and client_encoding='utf8'. In
> postgresql the client_encoding is a connection property to solve this
> problems and avoid complications with weird characters.
>
> However for any encoding just some client_encodings are valid. To
> latin1 is valid a client_encoding=utf8 but isn't valid a
> client_encoding=EUC_TW (traditional Chinese, Taiwanese). For that is
> important read the PostgreSQL documentation.
>
> Well, I don't know if you're using PostgreSQL. If you use another
> DBMS, this answer isn't very useful.
>
> I sorry if my english is too rough, but isn't my mother language.
> Cheers.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Still getting IntegrityError in test fixture using dumpdata --natural

2011-10-12 Thread Russell Keith-Magee
On Wed, Oct 12, 2011 at 3:05 AM, bobhaugen  wrote:
> Replying to myself:  temporary fix for dumpdata: --exclude
> contenttypes --exclude auth.permission

This isn't a temporary fix -- it's the *actual* fix.

> The result now works as a test fixture.
>
> Not sure what to conclude:
> * the fix for issue #7052 does not work?
> * --natural does not fix the IntegrityErrors with contenttypes in test
> fixtures?
> * contenttypes are trouble in test fixtures?

--natural isn't a magic wand that makes the problem described in #7052
go away all by itself -- it's a tool you can use to avoid the
underlying problem.

Contenttypes are automatically created by syncdb. If your fixtures
*also* contain content types, you can potentially get IntegrityErrors
(because in the process of loading the fixture, you can end up with
duplicated content types). If your fixtures contain numeric references
to content types, then there is also confusion as to whether the
numeric references are to the automatically generated primary keys, or
the content type primary keys described in the fixture.

--natural provides a resolution to this problem by saying "I'm going
to use a name, not a number, to refer to content types". You can then
omit content types from your fixture, and rely on the fact that syncdb
has created the content types with a name that can be resolved at the
time the fixture is loaded.

Yours,
Russ Magee %-)

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



Profiling Django

2011-10-12 Thread michael.pimmer.ext
The django application I am working on is very slow on the server-side, and I
want to know why.
The essence is to identify which code-parts of processing one request take
most time.

The app runs with mod_wsgi on Apache, here is what I tried:

- django-timelog: the information logged is too unspecific and high-leveled.
I want to know which functions and parts of a view require most time.
(moreover, analyze_timelog doesn't work here)
- django-debug-toolbar with profiling from
http://backslashn.com/post/505601626/ - too fine-grained:
   I do not want to know that 138752 calls to
python2.6/posixpath.py:129(islink) take 0.858 seconds. I want to know in
which views / functions it happens.
- profiling with wsgiref, like described in
https://code.djangoproject.com/wiki/ProfilingDjango#no1 - looks like (and
probably is?) exactly the same output as the django-debug-toolbar with
profiling: too fine-grained, I want to get an overview, not the pure
low-level calls.

What is your preferred way to analyze/profile the performance of
django-applications?

thanks,
Michael

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



Ajax replacement in django

2011-10-12 Thread lankesh87
Hello,
 I am developing a web application where i need ajax like features.
But I don't want to use ajax, so my question is- "is there any way to
perform ajax like functions in django?"

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



Re: Ajax replacement in django

2011-10-12 Thread Javier Guerra Giraldez
On Wed, Oct 12, 2011 at 9:17 AM, lankesh87  wrote:
>  I am developing a web application where i need ajax like features.
> But I don't want to use ajax, so my question is- "is there any way to
> perform ajax like functions in django?"

that kind of specifications (ajax-like but no ajax) sound very weird
to me.  I find only two explanations:

A) you don't know how HTTP works

or

B) when you say 'ajax' you're in fact talking about a specific library
that you don't want to use and not the generic javascript-driven
requests.

if A, then please do learn about HTTP first.  then you'll not only
realize what you really need, but will also be in position to make
your applications like you want.

if B, then please tell us what is it that you don't want.

-- 
Javier

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



Re: Ajax replacement in django

2011-10-12 Thread lankesh87
Actually my project guide is asking me to search for ajax replacement
in django. So that way we dont have to use ajax.

I mean if we could only refrsh particular part in our web page without
refreshing the whole page "using django".

Thanx in advance and pardone me for my foolish questions as i am new
to django and web but i do have some basic knowledge on
how html functions.

On Oct 12, 7:24 pm, Javier Guerra Giraldez  wrote:
> On Wed, Oct 12, 2011 at 9:17 AM, lankesh87  wrote:
> >  I am developing a web application where i need ajax like features.
> > But I don't want to use ajax, so my question is- "is there any way to
> > perform ajax like functions in django?"
>
> that kind of specifications (ajax-like but no ajax) sound very weird
> to me.  I find only two explanations:
>
> A) you don't know how HTTP works
>
> or
>
> B) when you say 'ajax' you're in fact talking about a specific library
> that you don't want to use and not the generic javascript-driven
> requests.
>
> if A, then please do learn about HTTP first.  then you'll not only
> realize what you really need, but will also be in position to make
> your applications like you want.
>
> if B, then please tell us what is it that you don't want.
>
> --
> Javier

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



Re: Ajax replacement in django

2011-10-12 Thread Chandrakant Kumar


You are another 'garbage' product of our country's shitty education system.

On 10/12/2011 08:09 PM, lankesh87 wrote:

Actually my project guide is asking me to search for ajax replacement
in django. So that way we dont have to use ajax.

I mean if we could only refrsh particular part in our web page without
refreshing the whole page "using django".

Thanx in advance and pardone me for my foolish questions as i am new
to django and web but i do have some basic knowledge on
how html functions.

On Oct 12, 7:24 pm, Javier Guerra Giraldez  wrote:

On Wed, Oct 12, 2011 at 9:17 AM, lankesh87  wrote:

  I am developing a web application where i need ajax like features.
But I don't want to use ajax, so my question is- "is there any way to
perform ajax like functions in django?"

that kind of specifications (ajax-like but no ajax) sound very weird
to me.  I find only two explanations:

A) you don't know how HTTP works

or

B) when you say 'ajax' you're in fact talking about a specific library
that you don't want to use and not the generic javascript-driven
requests.

if A, then please do learn about HTTP first.  then you'll not only
realize what you really need, but will also be in position to make
your applications like you want.

if B, then please tell us what is it that you don't want.

--
Javier


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



Re: Ajax replacement in django

2011-10-12 Thread Markus Gattol
If you don't want to do AJAX but still need to have a bidirectional link 
between client and server then websockets is probably what you want.

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



Re: Ajax replacement in django

2011-10-12 Thread Donald Stufft
 I don't think there's any reason to insult anyone, let's be civil. 


On Wednesday, October 12, 2011 at 10:50 AM, Chandrakant Kumar wrote:

> 
> You are another 'garbage' product of our country's shitty education system.
> 
> On 10/12/2011 08:09 PM, lankesh87 wrote:
> > Actually my project guide is asking me to search for ajax replacement
> > in django. So that way we dont have to use ajax.
> > 
> > I mean if we could only refrsh particular part in our web page without
> > refreshing the whole page "using django".
> > 
> > Thanx in advance and pardone me for my foolish questions as i am new
> > to django and web but i do have some basic knowledge on
> > how html functions.
> > 
> > On Oct 12, 7:24 pm, Javier Guerra Giraldez > (http://guerrag.com)> wrote:
> > > On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 > > (http://gmail.com)> wrote:
> > > >  I am developing a web application where i need ajax like features.
> > > > But I don't want to use ajax, so my question is- "is there any way to
> > > > perform ajax like functions in django?"
> > > > 
> > > 
> > > that kind of specifications (ajax-like but no ajax) sound very weird
> > > to me. I find only two explanations:
> > > 
> > > A) you don't know how HTTP works
> > > 
> > > or
> > > 
> > > B) when you say 'ajax' you're in fact talking about a specific library
> > > that you don't want to use and not the generic javascript-driven
> > > requests.
> > > 
> > > if A, then please do learn about HTTP first. then you'll not only
> > > realize what you really need, but will also be in position to make
> > > your applications like you want.
> > > 
> > > if B, then please tell us what is it that you don't want.
> > > 
> > > --
> > > Javier
> > > 
> > 
> > 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com 
> (mailto:django-users@googlegroups.com).
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com 
> (mailto:django-users+unsubscr...@googlegroups.com).
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 


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



Re: Ajax replacement in django

2011-10-12 Thread Phang Mulianto
but for the web html standart you need ajax.

maybe you can use some javascript framework like prototype+scripatoulus or
jquery to simply work with ajax and browser compatibility issue.
On Oct 12, 2011 10:55 PM, "Donald Stufft"  wrote:

>  I don't think there's any reason to insult anyone, let's be civil.
>
> On Wednesday, October 12, 2011 at 10:50 AM, Chandrakant Kumar wrote:
>
>
> You are another 'garbage' product of our country's shitty education system.
>
> On 10/12/2011 08:09 PM, lankesh87 wrote:
>
> Actually my project guide is asking me to search for ajax replacement
> in django. So that way we dont have to use ajax.
>
> I mean if we could only refrsh particular part in our web page without
> refreshing the whole page "using django".
>
> Thanx in advance and pardone me for my foolish questions as i am new
> to django and web but i do have some basic knowledge on
> how html functions.
>
> On Oct 12, 7:24 pm, Javier Guerra Giraldez wrote:
>
> On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 wrote:
>
> I am developing a web application where i need ajax like features.
> But I don't want to use ajax, so my question is- "is there any way to
> perform ajax like functions in django?"
>
> that kind of specifications (ajax-like but no ajax) sound very weird
> to me. I find only two explanations:
>
> A) you don't know how HTTP works
>
> or
>
> B) when you say 'ajax' you're in fact talking about a specific library
> that you don't want to use and not the generic javascript-driven
> requests.
>
> if A, then please do learn about HTTP first. then you'll not only
> realize what you really need, but will also be in position to make
> your applications like you want.
>
> if B, then please tell us what is it that you don't want.
>
> --
> Javier
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Ajax replacement in django

2011-10-12 Thread lankesh87
As far I can understand from ur opinions is that to load contents
without refreshing the web page we will have to use ajax and

as python being server side scripting language will not be helpful in
this case. So anyhow I will have to use ajax.. do correct me if i'm
wrong..

once again thank u all for ur time and help.

On Oct 12, 8:06 pm, Phang Mulianto  wrote:
> but for the web html standart you need ajax.
>
> maybe you can use some javascript framework like prototype+scripatoulus or
> jquery to simply work with ajax and browser compatibility issue.
> On Oct 12, 2011 10:55 PM, "Donald Stufft"  wrote:
>
>
>
>
>
>
>
> >  I don't think there's any reason to insult anyone, let's be civil.
>
> > On Wednesday, October 12, 2011 at 10:50 AM, Chandrakant Kumar wrote:
>
> > You are another 'garbage' product of our country's shitty education system.
>
> > On 10/12/2011 08:09 PM, lankesh87 wrote:
>
> > Actually my project guide is asking me to search for ajax replacement
> > in django. So that way we dont have to use ajax.
>
> > I mean if we could only refrsh particular part in our web page without
> > refreshing the whole page "using django".
>
> > Thanx in advance and pardone me for my foolish questions as i am new
> > to django and web but i do have some basic knowledge on
> > how html functions.
>
> > On Oct 12, 7:24 pm, Javier Guerra Giraldez wrote:
>
> > On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 wrote:
>
> > I am developing a web application where i need ajax like features.
> > But I don't want to use ajax, so my question is- "is there any way to
> > perform ajax like functions in django?"
>
> > that kind of specifications (ajax-like but no ajax) sound very weird
> > to me. I find only two explanations:
>
> > A) you don't know how HTTP works
>
> > or
>
> > B) when you say 'ajax' you're in fact talking about a specific library
> > that you don't want to use and not the generic javascript-driven
> > requests.
>
> > if A, then please do learn about HTTP first. then you'll not only
> > realize what you really need, but will also be in position to make
> > your applications like you want.
>
> > if B, then please tell us what is it that you don't want.
>
> > --
> > Javier
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Ajax replacement in django

2011-10-12 Thread Chandrakant Kumar


I am sorry everybody and especially lankesh87, I should not have used 
those words. I had just got into an argument with my dean. Sorry again.


On 10/12/2011 08:25 PM, Donald Stufft wrote:

I don't think there's any reason to insult anyone, let's be civil.

On Wednesday, October 12, 2011 at 10:50 AM, Chandrakant Kumar wrote:



You are another 'garbage' product of our country's shitty education 
system.


On 10/12/2011 08:09 PM, lankesh87 wrote:

Actually my project guide is asking me to search for ajax replacement
in django. So that way we dont have to use ajax.

I mean if we could only refrsh particular part in our web page without
refreshing the whole page "using django".

Thanx in advance and pardone me for my foolish questions as i am new
to django and web but i do have some basic knowledge on
how html functions.

On Oct 12, 7:24 pm, Javier Guerra Giraldez> wrote:
On Wed, Oct 12, 2011 at 9:17 AM, lankesh87> wrote:

I am developing a web application where i need ajax like features.
But I don't want to use ajax, so my question is- "is there any way to
perform ajax like functions in django?"

that kind of specifications (ajax-like but no ajax) sound very weird
to me. I find only two explanations:

A) you don't know how HTTP works

or

B) when you say 'ajax' you're in fact talking about a specific library
that you don't want to use and not the generic javascript-driven
requests.

if A, then please do learn about HTTP first. then you'll not only
realize what you really need, but will also be in position to make
your applications like you want.

if B, then please tell us what is it that you don't want.

--
Javier


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


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


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



Re: Ajax replacement in django

2011-10-12 Thread Brian Schott
This is a bit old-school, but you could do this by using meta-refresh on a 
frame.  I think that should still work in most browsers.  
http://en.wikipedia.org/wiki/Meta_refresh

Basically, you can place an iframe inside your base.html template that includes 
an  link to your dynamic content.   
http://www.w3schools.com/tags/tag_iframe.asp

Create a iframe_base.html template file that has the meta refresh tag included 
in  section and just the iframe parts should refresh.  

Not sure if this is what you want, and not sure this is a good idea, but it 
doesn't require javascript.

Brian Schott
bfsch...@gmail.com



On Oct 12, 2011, at 11:06 AM, Phang Mulianto wrote:

> but for the web html standart you need ajax.
> 
> maybe you can use some javascript framework like prototype+scripatoulus or 
> jquery to simply work with ajax and browser compatibility issue.
> 
> On Oct 12, 2011 10:55 PM, "Donald Stufft"  wrote:
> I don't think there's any reason to insult anyone, let's be civil.
> On Wednesday, October 12, 2011 at 10:50 AM, Chandrakant Kumar wrote:
> 
>> 
>> You are another 'garbage' product of our country's shitty education system.
>> 
>> On 10/12/2011 08:09 PM, lankesh87 wrote:
>>> Actually my project guide is asking me to search for ajax replacement
>>> in django. So that way we dont have to use ajax.
>>> 
>>> I mean if we could only refrsh particular part in our web page without
>>> refreshing the whole page "using django".
>>> 
>>> Thanx in advance and pardone me for my foolish questions as i am new
>>> to django and web but i do have some basic knowledge on
>>> how html functions.
>>> 
>>> On Oct 12, 7:24 pm, Javier Guerra Giraldez wrote:
 On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 wrote:
> I am developing a web application where i need ajax like features.
> But I don't want to use ajax, so my question is- "is there any way to
> perform ajax like functions in django?"
 that kind of specifications (ajax-like but no ajax) sound very weird
 to me. I find only two explanations:
 
 A) you don't know how HTTP works
 
 or
 
 B) when you say 'ajax' you're in fact talking about a specific library
 that you don't want to use and not the generic javascript-driven
 requests.
 
 if A, then please do learn about HTTP first. then you'll not only
 realize what you really need, but will also be in position to make
 your applications like you want.
 
 if B, then please tell us what is it that you don't want.
 
 --
 Javier
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.



smime.p7s
Description: S/MIME cryptographic signature


Re: Ajax replacement in django

2011-10-12 Thread Javier Guerra Giraldez
On Wed, Oct 12, 2011 at 9:39 AM, lankesh87  wrote:
> I mean if we could only refrsh particular part in our web page without
> refreshing the whole page "using django".

i think you really need to check how HTTP works.

in HTTP, the server can't "push" anything to the browser.  the browser
has to ask for it.

Django runs exclusively in the server.

the only browse-side coding environments are javascript and some
plugins (flash, Java, silverlight).  in general, only Javascript is
practical.

you want to replace part of the webpage with different content,
probably in response of some user interaction.  That has to be
initiated at the browser.  Since you don't want to replace the whole
page, it has to be some Javascript code that 'pulls' the new content
from the server and replaces some part of the page with it.

guess what? that javascript-driven requests are called AJAX (even if
the 'X' doesn't imply XML anymore).

using a javascript library it can be real simple.  in jQuery it's:

  $('#partid').load('http://some.url/with/new/content');

from the Django point of view, it will simply get a request for the
new URL, and it should return the partial content.  jQuery will patch
it replacing the content of the '#partid' element of the page


but you _really_ have to understand HTTP and javascript to go from
there to anywhere else.


-- 
Javier

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



Re: Ajax replacement in django

2011-10-12 Thread Tom Evans
On Wed, Oct 12, 2011 at 3:24 PM, Javier Guerra Giraldez
 wrote:
> On Wed, Oct 12, 2011 at 9:17 AM, lankesh87  wrote:
>>  I am developing a web application where i need ajax like features.
>> But I don't want to use ajax, so my question is- "is there any way to
>> perform ajax like functions in django?"
>
> that kind of specifications (ajax-like but no ajax) sound very weird
> to me.

It's definitely weird, but its not crazy. I'm almost certain the OP
does want to use AJAX, but there are AJAX-like techniques that we used
to do AJAX-like things before XMLHttpRequest existed.

The most common way is to use javascript to programmatically load
content into a hidden . The returned content should have a

Re: Ajax replacement in django

2011-10-12 Thread Kurtis Mullins
You could also use Javascript to just hide and display information as you
need it. No Ajax involved -- just need to give all of the data to the
browser up front.

On Wed, Oct 12, 2011 at 11:38 AM, Javier Guerra Giraldez  wrote:

> On Wed, Oct 12, 2011 at 9:39 AM, lankesh87  wrote:
> > I mean if we could only refrsh particular part in our web page without
> > refreshing the whole page "using django".
>
> i think you really need to check how HTTP works.
>
> in HTTP, the server can't "push" anything to the browser.  the browser
> has to ask for it.
>
> Django runs exclusively in the server.
>
> the only browse-side coding environments are javascript and some
> plugins (flash, Java, silverlight).  in general, only Javascript is
> practical.
>
> you want to replace part of the webpage with different content,
> probably in response of some user interaction.  That has to be
> initiated at the browser.  Since you don't want to replace the whole
> page, it has to be some Javascript code that 'pulls' the new content
> from the server and replaces some part of the page with it.
>
> guess what? that javascript-driven requests are called AJAX (even if
> the 'X' doesn't imply XML anymore).
>
> using a javascript library it can be real simple.  in jQuery it's:
>
>  $('#partid').load('http://some.url/with/new/content');
>
> from the Django point of view, it will simply get a request for the
> new URL, and it should return the partial content.  jQuery will patch
> it replacing the content of the '#partid' element of the page
>
>
> but you _really_ have to understand HTTP and javascript to go from
> there to anywhere else.
>
>
> --
> Javier
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Ajax replacement in django

2011-10-12 Thread william ratcliff
I think the OP should ask his manager why they wish to avoid using ajax.
For example, is it sufficient if the page degrades gracefully for those not
running javascript?

On Wed, Oct 12, 2011 at 11:40 AM, Tom Evans wrote:

> On Wed, Oct 12, 2011 at 3:24 PM, Javier Guerra Giraldez
>  wrote:
> > On Wed, Oct 12, 2011 at 9:17 AM, lankesh87  wrote:
> >>  I am developing a web application where i need ajax like features.
> >> But I don't want to use ajax, so my question is- "is there any way to
> >> perform ajax like functions in django?"
> >
> > that kind of specifications (ajax-like but no ajax) sound very weird
> > to me.
>
> It's definitely weird, but its not crazy. I'm almost certain the OP
> does want to use AJAX, but there are AJAX-like techniques that we used
> to do AJAX-like things before XMLHttpRequest existed.
>
> The most common way is to use javascript to programmatically load
> content into a hidden . The returned content should have a
> 

Create a modular application

2011-10-12 Thread Guillaume DE BURE
Hi people,

I just started a new open source project aimed at small companies that would 
need a tool to manage its resources 
(http://github.com/myOpenCompany/myOpenCompany not much to see at the 
moment...), and one of the central idea would be modularization: 

For example, we will start with an "employee" and a "hardware" module. The 
hardware module allows tracking the phones and laptops affected to 
employees. In the employee property page, the list of hardware for this 
employee is displayed.

Now, if the company does not need the "hardware" module, the property page 
will of course not contain this information. This is implies some kind of 
dependency between the two modules, and that the "employee" module is somehow 
aware of the information that the "hardware" module can provide.

The application will contain probably many modules (attendance management, 
skills, missions, training...)

Being still quite new to django, I have some very basic questions on this:
* Should each module be a django app ? Or is it something different ?
* Is there already something existing (a third party app ?) to provide this 
kind of mechanism ?
* If not, does anyone has experience implementing such behaviour ?

Thanks in advance for any feedback,

Guillaume
-- 
Skrooge, a free, Open Source, personal finances software
http://skrooge.org

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



Re: Iteration over queryset in a model

2011-10-12 Thread Daniel Roseman
On Tuesday, 11 October 2011 15:17:18 UTC+1, eyscooby wrote:
>
> slowly getting there thanks to your help. 
> I am actually trying to accomplish this in the Admin interface, so I 
> am not sure how to use the template tag {{ ticket.days_old }} in that 
> situation. 
>
> the other part I left off yesterday under my model I then had.. 
> (trying to get code formatting correct but keeps going to the left 
> margin on me when i post) 
>
> def days_old(self): 
> return self.objects.datecalc() 
> days_old.short_discription = 'Days Old' 
>
> more or less is that a correct way I would pull in a custom manager, 
> lets say if this one didn't have the iteration to it which seems be to 
> be my problem part now. 
>
> thanks 
>

No, because that's not what managers are for. Managers are interacting with 
the database, and getting and returning one or more new model instances. If 
you already have an object, and you want to calculate the date on it, you 
want a model method that simply returns a value, not call the manager.
--
DR.
 

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



Re: Ajax replacement in django

2011-10-12 Thread lankesh87
thank you all for your support.
I learnt my lessons.
I have to go back to AJAX.

Thank you again I really needed your help.

I guess I'll be hanging around as I am starting to like python and
django.

On Oct 12, 8:42 pm, william ratcliff 
wrote:
> I think the OP should ask his manager why they wish to avoid using ajax.
> For example, is it sufficient if the page degrades gracefully for those not
> running javascript?
>
> On Wed, Oct 12, 2011 at 11:40 AM, Tom Evans wrote:
>
>
>
>
>
>
>
> > On Wed, Oct 12, 2011 at 3:24 PM, Javier Guerra Giraldez
> >  wrote:
> > > On Wed, Oct 12, 2011 at 9:17 AM, lankesh87  wrote:
> > >>  I am developing a web application where i need ajax like features.
> > >> But I don't want to use ajax, so my question is- "is there any way to
> > >> perform ajax like functions in django?"
>
> > > that kind of specifications (ajax-like but no ajax) sound very weird
> > > to me.
>
> > It's definitely weird, but its not crazy. I'm almost certain the OP
> > does want to use AJAX, but there are AJAX-like techniques that we used
> > to do AJAX-like things before XMLHttpRequest existed.
>
> > The most common way is to use javascript to programmatically load
> > content into a hidden . The returned content should have a
> > 

Re: Ajax replacement in django

2011-10-12 Thread Micky Hulse
On Wed, Oct 12, 2011 at 7:39 AM, lankesh87  wrote:
> Actually my project guide is asking me to search for ajax replacement
> in django. So that way we dont have to use ajax.

Perhaps it's a trick question?

Maybe you project guide does not like the "Ajax" buzzword? :)

Just call it XHR:




On a more serious note...

I have never used, and this might be a wild goose chase, but what
about html5 WebSockets?




The first answer here does a nice job at explaining the difference
between XMLHttpRequest and WebSocket technology:



Good luck!

Cheers,
M

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



Re: Ajax replacement in django

2011-10-12 Thread lankesh87
thank you to all for your support.
I learnt my lessons.
I have to go back to AJAX.

Thanks again for your help. It was much needed.

On Oct 12, 8:42 pm, william ratcliff 
wrote:
> I think the OP should ask his manager why they wish to avoid using ajax.
> For example, is it sufficient if the page degrades gracefully for those not
> running javascript?
>
> On Wed, Oct 12, 2011 at 11:40 AM, Tom Evans wrote:
>
>
>
>
>
>
>
> > On Wed, Oct 12, 2011 at 3:24 PM, Javier Guerra Giraldez
> >  wrote:
> > > On Wed, Oct 12, 2011 at 9:17 AM, lankesh87  wrote:
> > >>  I am developing a web application where i need ajax like features.
> > >> But I don't want to use ajax, so my question is- "is there any way to
> > >> perform ajax like functions in django?"
>
> > > that kind of specifications (ajax-like but no ajax) sound very weird
> > > to me.
>
> > It's definitely weird, but its not crazy. I'm almost certain the OP
> > does want to use AJAX, but there are AJAX-like techniques that we used
> > to do AJAX-like things before XMLHttpRequest existed.
>
> > The most common way is to use javascript to programmatically load
> > content into a hidden . The returned content should have a
> > 

Re: Ajax replacement in django

2011-10-12 Thread Chandrakant Kumar


But, isn't HTML5 is still work in progress? I mean, how will it behave 
on older browsers?


On 10/12/2011 10:10 PM, Micky Hulse wrote:

On Wed, Oct 12, 2011 at 7:39 AM, lankesh87  wrote:

Actually my project guide is asking me to search for ajax replacement
in django. So that way we dont have to use ajax.

Perhaps it's a trick question?

Maybe you project guide does not like the "Ajax" buzzword? :)

Just call it XHR:




On a more serious note...

I have never used, and this might be a wild goose chase, but what
about html5 WebSockets?




The first answer here does a nice job at explaining the difference
between XMLHttpRequest and WebSocket technology:



Good luck!

Cheers,
M



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



Re: Ajax replacement in django

2011-10-12 Thread Sultan Imanhodjaev
Hello,

Did you look at dajax and dajaxice extensions for django so far? It might
help.
On Oct 12, 2011 10:40 PM, "lankesh87"  wrote:

> thank you all for your support.
> I learnt my lessons.
> I have to go back to AJAX.
>
> Thank you again I really needed your help.
>
> I guess I'll be hanging around as I am starting to like python and
> django.
>
> On Oct 12, 8:42 pm, william ratcliff 
> wrote:
> > I think the OP should ask his manager why they wish to avoid using ajax.
> > For example, is it sufficient if the page degrades gracefully for those
> not
> > running javascript?
> >
> > On Wed, Oct 12, 2011 at 11:40 AM, Tom Evans  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Wed, Oct 12, 2011 at 3:24 PM, Javier Guerra Giraldez
> > >  wrote:
> > > > On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 
> wrote:
> > > >>  I am developing a web application where i need ajax like features.
> > > >> But I don't want to use ajax, so my question is- "is there any way
> to
> > > >> perform ajax like functions in django?"
> >
> > > > that kind of specifications (ajax-like but no ajax) sound very weird
> > > > to me.
> >
> > > It's definitely weird, but its not crazy. I'm almost certain the OP
> > > does want to use AJAX, but there are AJAX-like techniques that we used
> > > to do AJAX-like things before XMLHttpRequest existed.
> >
> > > The most common way is to use javascript to programmatically load
> > > content into a hidden . The returned content should have a
> > > 

Re: Ajax replacement in django

2011-10-12 Thread Micky Hulse
On Wed, Oct 12, 2011 at 9:54 AM, Chandrakant Kumar
 wrote:
> But, isn't HTML5 is still work in progress? I mean, how will it behave on
> older browsers?

Good point. I guess it depends on the requirements of the project.

>From what I read, this sounds like a school project, so why not take
the time to explore state of the art web technologies?

Cheers,
Micky

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



Re: Create a modular application

2011-10-12 Thread Javier Guerra Giraldez
On Wed, Oct 12, 2011 at 11:14 AM, Guillaume DE BURE
 wrote:
> Being still quite new to django, I have some very basic questions on this:
> * Should each module be         a django app ? Or is it something different ?
> * Is there already something existing (a third party app ?) to provide this
> kind of mechanism ?
> * If not, does anyone has experience implementing such behaviour ?

i struggled with the same for some time.  the 'app' name seems to
imply that it's a section of the website, or even a full application.
but in fact it's more about internal functionality.

my process is roughly like this:

- create the project and add a few basic apps: south,
django-extensions, debug-toolbar, so on.

- create an app and open the models.py

- on a terminal, i start a simple shell that runs the graph_models
command of django-extensions, generating a nice relationship diagram
that i keep open on a different window.  the diagram is rebuild each
time a models.py is modified.

- i start writing models, watching the diagram evolve.  i think of
normalization rules, and at the same time imagine user cases and what
kind of data requests i'll need to fulfill the user needs.

- after a while, patterns start to emerge, small clusters of models
are loosely bound to other clusters.  then i try to see the direction
of the arrows, as soon as i see a cluster points to another without
any relationship in the other direction, i interpret as a sign that it
should be a new app.  the important part is the direction of the
arrows, that means one app depends on the other, but not the other
way.  of course, it's better when you can make an app depend only on
Django core; but usually you'll find that some apps are
'infrastructure' and others are more 'high level'

- i keep splitting, and sometimes rejoining apps until most of the use
cases are either obvious from the diagram, or at least have complexity
bounded on a single app.

- then i start adding methods to the models (tests first!... or at
least i should.  creating sample data is the tedious part).  i try to
have tests that represent most use cases in the data manipulation part
(still no views).  sometimes that implies creating a whole API.

- then, and only then, i start creating views.  most of them will be
concerned with a single 'high level' app and maybe some readonly
access to other apps, but there are cases where a view touches
functionality from several apps.  in that case, i create a new
model-less app, just to hold those views.


hope that helps


-- 
Javier

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



Re: Still getting IntegrityError in test fixture using dumpdata --natural

2011-10-12 Thread bobhaugen
On Oct 12, 9:12 am, Russell Keith-Magee 
wrote:
> --natural isn't a magic wand

Dang!  I knew that "magic removal" was a bad idea...

> Contenttypes are automatically created by syncdb. If your fixtures
> *also* contain content types, you can potentially get IntegrityErrors
> (because in the process of loading the fixture, you can end up with
> duplicated content types). If your fixtures contain numeric references
> to content types, then there is also confusion as to whether the
> numeric references are to the automatically generated primary keys, or
> the content type primary keys described in the fixture.
>
> --natural provides a resolution to this problem by saying "I'm going
> to use a name, not a number, to refer to content types". You can then
> omit content types from your fixture, and rely on the fact that syncdb
> has created the content types with a name that can be resolved at the
> time the fixture is loaded.

First time I understood any of that.  I just looked in the doc to see
if it needed your paragraph, and found an almost equally good
explanation here:
https://docs.djangoproject.com/en/1.3/topics/serialization/#natural-keys
I obviously missed it the first time around.

Thank you very much!

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



Re: Why can't "directly" change array elements of model objects in Django shell?

2011-10-12 Thread fei
Instead, you can use the get() function,

x = MyModel.objects.get(id=3)
x.some_field = "new value"
x.save()

The difference between all() and get() is that all() will do a lazy
evaluation and get() will hit the physical database.

Fei

On Oct 12, 11:57 pm, Tom Evans  wrote:
> On Fri, Oct 7, 2011 at 10:01 PM, Chris Seberino  wrote:
>
> > On Oct 7, 10:39 am, Jacob Kaplan-Moss  wrote:
> >> On Fri, Oct 7, 2011 at 10:30 AM, Chris Seberino  
> >> wrote:
>
> >> > I've noticed that this doesn't often work in Django shell...
>
> >> > x = MyModel.objects.all()
> >> > x[3].some_field = "new value"
> >> > x[3].save()
>
> >> This is because `MyModel.objects.all()` isn't a list; it's a QuerySet.
> >> That is, `MyModel.objects.all()` *doesn't* hit the database until you
> >> say `x[3]`, at which point Django performs a query with a LIMIT and
>
> > OK.  I understand.  What is easiest way then to *force* my x[3] code
> > above to hit the database so that
> > my changes are permanent?
>
> x = list(MyModel.objects.all())
> x[3].some_field = "new value"
> x[3].save()
>
> Cheers
>
> Tom

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



Re: Paginator has many Pages, but all are empty?

2011-10-12 Thread Daniel Roseman
On Tuesday, 11 October 2011 17:55:07 UTC+1, ch3ka wrote:
>
> I have a problem with django.core.paginator. 
>
> I have a Page object who's .object_list is [], but at the same time 
> it's repr() states "Page 1 of 11". 
>
> How is that even possible? 
>
> Same with page 2, page 3 ,...


You'll have to show some code. How are you creating the page object? 
-- 
DR. 

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



Second coming of Java?

2011-10-12 Thread ydjango
What do you think?

http://www.cringely.com/2011/10/the-second-coming-of-java/

"When SSDs gain enough capacity there will be a shift from the Ruby
world back to the Java world. Not for prototyping, because, well, it’s
prototyping. But simply because the statement “Ruby is incredibly slow
but I don’t care because my database is slower” will no longer be
true. At that point Ruby (Python, Groovy, you name it) becomes the
bottleneck." - from the above article

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



Re: Second coming of Java?

2011-10-12 Thread Donald Stufft
I think it's a load of tripe. There's plenty ways to speed up Python. And it's 
fast enough. It's not about being the fastest, but about being fast enough to 
get the job done, and having an enjoyable experience writing your web 
application.

Java is not that thing.  


On Wednesday, October 12, 2011 at 4:52 PM, ydjango wrote:

> What do you think?
>  
> http://www.cringely.com/2011/10/the-second-coming-of-java/
>  
> "When SSDs gain enough capacity there will be a shift from the Ruby
> world back to the Java world. Not for prototyping, because, well, it’s
> prototyping. But simply because the statement “Ruby is incredibly slow
> but I don’t care because my database is slower” will no longer be
> true. At that point Ruby (Python, Groovy, you name it) becomes the
> bottleneck." - from the above article
>  
> --  
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com 
> (mailto:django-users@googlegroups.com).
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com 
> (mailto:django-users+unsubscr...@googlegroups.com).
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>  
>  


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



Re: configuring

2011-10-12 Thread Mike Dewhirst
Yeah

The last line of the traceback indicates a problem with your MySQL setup 
possibly with the backend. Check the docs for interfacing Django to MySQL. 

I use PostgreSQL so I can't help much here. 

Good luck

Mike

On 12/10/2011, at 11:12 PM, yezi  wrote:

> hey everyonei just cant proceed my work with django application
> because some running errors on configuring mysql and the django frame
> work.if u please get me a solution i will be honored to
> receive.
> 
> i kinda of get an error message
> 
> 
> C:\Django-1.3\newproject\djangoblog>python manage.py syncdb
> Traceback (most recent call last):
>  File "manage.py", line 14, in 
>execute_manager(settings)
>  File "C:\Python25\Lib\site-packages\django\core\management
> \__init__.py", line
> 438, in execute_manager
>utility.execute()
>  File "C:\Python25\Lib\site-packages\django\core\management
> \__init__.py", line
> 379, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "C:\Python25\Lib\site-packages\django\core\management
> \__init__.py", line
> 261, in fetch_command
>klass = load_command_class(app_name, subcommand)
>  File "C:\Python25\Lib\site-packages\django\core\management
> \__init__.py", line
> 67, in load_command_class
>module = import_module('%s.management.commands.%s' % (app_name,
> name))
>  File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>__import__(name)
>  File "C:\Python25\Lib\site-packages\django\core\management\commands
> \syncdb.py"
> , line 7, in 
>from django.core.management.sql import custom_sql_for_model,
> emit_post_sync_
> signal
>  File "C:\Python25\Lib\site-packages\django\core\management\sql.py",
> line 6, in
> 
>from django.db import models
>  File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 78,
> in  e>
>connection = connections[DEFAULT_DB_ALIAS]
>  File "C:\Python25\Lib\site-packages\django\db\utils.py", line 93, in
> __getitem
> __
>backend = load_backend(db['ENGINE'])
>  File "C:\Python25\Lib\site-packages\django\db\utils.py", line 33, in
> load_back
> end
>return import_module('.base', backend_name)
>  File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>__import__(name)
>  File "C:\Python25\Lib\site-packages\django\db\backends\mysql
> \base.py", line 14
> , in 
>raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: No mo
> dule named MySQLdb
> 
> C:\Django-1.3\newproject\djangoblog>
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: configuring

2011-10-12 Thread Kurtis Mullins
If you're sure you've called the MySQLDb correctly in your settings file, as
described by the documents, then you may simply be missing the Python-MySQL
package.

On Wed, Oct 12, 2011 at 5:59 PM, Mike Dewhirst wrote:

> Yeah
>
> The last line of the traceback indicates a problem with your MySQL setup
> possibly with the backend. Check the docs for interfacing Django to MySQL.
>
> I use PostgreSQL so I can't help much here.
>
> Good luck
>
> Mike
>
> On 12/10/2011, at 11:12 PM, yezi  wrote:
>
> > hey everyonei just cant proceed my work with django application
> > because some running errors on configuring mysql and the django frame
> > work.if u please get me a solution i will be honored to
> > receive.
> >
> > i kinda of get an error message
> >
> >
> > C:\Django-1.3\newproject\djangoblog>python manage.py syncdb
> > Traceback (most recent call last):
> >  File "manage.py", line 14, in 
> >execute_manager(settings)
> >  File "C:\Python25\Lib\site-packages\django\core\management
> > \__init__.py", line
> > 438, in execute_manager
> >utility.execute()
> >  File "C:\Python25\Lib\site-packages\django\core\management
> > \__init__.py", line
> > 379, in execute
> >self.fetch_command(subcommand).run_from_argv(self.argv)
> >  File "C:\Python25\Lib\site-packages\django\core\management
> > \__init__.py", line
> > 261, in fetch_command
> >klass = load_command_class(app_name, subcommand)
> >  File "C:\Python25\Lib\site-packages\django\core\management
> > \__init__.py", line
> > 67, in load_command_class
> >module = import_module('%s.management.commands.%s' % (app_name,
> > name))
> >  File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line
> > 35, in im
> > port_module
> >__import__(name)
> >  File "C:\Python25\Lib\site-packages\django\core\management\commands
> > \syncdb.py"
> > , line 7, in 
> >from django.core.management.sql import custom_sql_for_model,
> > emit_post_sync_
> > signal
> >  File "C:\Python25\Lib\site-packages\django\core\management\sql.py",
> > line 6, in
> > 
> >from django.db import models
> >  File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 78,
> > in  > e>
> >connection = connections[DEFAULT_DB_ALIAS]
> >  File "C:\Python25\Lib\site-packages\django\db\utils.py", line 93, in
> > __getitem
> > __
> >backend = load_backend(db['ENGINE'])
> >  File "C:\Python25\Lib\site-packages\django\db\utils.py", line 33, in
> > load_back
> > end
> >return import_module('.base', backend_name)
> >  File "C:\Python25\Lib\site-packages\django\utils\importlib.py", line
> > 35, in im
> > port_module
> >__import__(name)
> >  File "C:\Python25\Lib\site-packages\django\db\backends\mysql
> > \base.py", line 14
> > , in 
> >raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> > module: No mo
> > dule named MySQLdb
> >
> > C:\Django-1.3\newproject\djangoblog>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Ajax replacement in django

2011-10-12 Thread Russell Keith-Magee
A good thing you did. For everyone's benefit -- this kind of language
and sentiment *will not* be tolerated on django-users. If you can't
keep a civil tongue, you will be asked to leave.

Yours,
Russ Magee %-)

On Wed, Oct 12, 2011 at 11:32 PM, Chandrakant Kumar
 wrote:
>
> I am sorry everybody and especially lankesh87, I should not have used those
> words. I had just got into an argument with my dean. Sorry again.
>
> On 10/12/2011 08:25 PM, Donald Stufft wrote:
>
> I don't think there's any reason to insult anyone, let's be civil.
>
> On Wednesday, October 12, 2011 at 10:50 AM, Chandrakant Kumar wrote:
>
> You are another 'garbage' product of our country's shitty education system.
> On 10/12/2011 08:09 PM, lankesh87 wrote:
>
> Actually my project guide is asking me to search for ajax replacement
> in django. So that way we dont have to use ajax.
> I mean if we could only refrsh particular part in our web page without
> refreshing the whole page "using django".
> Thanx in advance and pardone me for my foolish questions as i am new
> to django and web but i do have some basic knowledge on
> how html functions.
> On Oct 12, 7:24 pm, Javier Guerra Giraldez wrote:
>
> On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 wrote:
>
> I am developing a web application where i need ajax like features.
> But I don't want to use ajax, so my question is- "is there any way to
> perform ajax like functions in django?"
>
> that kind of specifications (ajax-like but no ajax) sound very weird
> to me. I find only two explanations:
> A) you don't know how HTTP works
> or
> B) when you say 'ajax' you're in fact talking about a specific library
> that you don't want to use and not the generic javascript-driven
> requests.
> if A, then please do learn about HTTP first. then you'll not only
> realize what you really need, but will also be in position to make
> your applications like you want.
> if B, then please tell us what is it that you don't want.
> --
> Javier
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Second coming of Java?

2011-10-12 Thread Russell Keith-Magee
On Thu, Oct 13, 2011 at 4:52 AM, ydjango  wrote:
> What do you think?
>
> http://www.cringely.com/2011/10/the-second-coming-of-java/
>
> "When SSDs gain enough capacity there will be a shift from the Ruby
> world back to the Java world. Not for prototyping, because, well, it’s
> prototyping. But simply because the statement “Ruby is incredibly slow
> but I don’t care because my database is slower” will no longer be
> true. At that point Ruby (Python, Groovy, you name it) becomes the
> bottleneck." - from the above article

There are so many mistakes and misunderstandings in that article, it's
difficult to know where to start.

Some indications that he doesn't know what he's talking about:

 * He says "you can replace Ruby with Python, Django or Groovy". So
he's unclear on the difference between a programming language and a
web framework.

 * "Ruby has nothing on Perl". 'Nuff said.

 * "Ruby is already migrating to that JRuby (sic)"... Only for a very
specific (and incorrect) interpretation of "migrating".

 * He makes no mention of the fact that developer time is much more
expensive than server hardware.

 * He appears to be unaware of projects like V8, PyPy, or any of the
other examples of virtual machines for interpreted languages.

Move along; nothing to see here.

Yours,
Russ Magee %-)

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



Re: Profiling Django

2011-10-12 Thread Andre Terra
A good place to start is using django-debug-toolbar and taking a look at the
queries generated for each view, so that you know what's taking long. There
are tools for monitoring database performance, but I have no experience with
them, so I'll leave it to other members in this list to make the
recomendations. Maybe go after disk read/write monitoring if you have access
to that?

When possible, moving the big functions in your code to asynchronous celery
tasks [1] will nearly always speed things up.

If you're doing big (hundreds of thousands of rows) db calls, try using DSE
[2]

[1] http://readthedocs.org/docs/django-celery/en/latest/
[2] http://pypi.python.org/pypi/dse


Cheers,
AT


On Wed, Oct 12, 2011 at 10:19 AM, <
michael.pimmer@boehringer-ingelheim.com> wrote:

> **
>
> The django application I am working on is very slow on the server-side, and
> I want to know why.
> The essence is to identify which code-parts of processing one request take
> most time.
>
> The app runs with mod_wsgi on Apache, here is what I tried:
>
> - django-timelog: the information logged is too unspecific and
> high-leveled. I want to know which functions and parts of a view require
> most time. (moreover, analyze_timelog doesn't work here)
> - django-debug-toolbar with profiling from
> http://backslashn.com/post/505601626/ - too fine-grained:
>I do not want to know that 138752 calls to
> python2.6/posixpath.py:129(islink) take 0.858 seconds. I want to know in
> which views / functions it happens.
> - profiling with wsgiref, like described in
> https://code.djangoproject.com/wiki/ProfilingDjango#no1 - looks like (and
> probably is?) exactly the same output as the django-debug-toolbar with
> profiling: too fine-grained, I want to get an overview, not the pure
> low-level calls.
>
> What is your preferred way to analyze/profile the performance of
> django-applications?
>
> thanks,
> Michael
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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