Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Doug Ballance
I made an error when I changed a variable name just before posting.
Replace "self._age" with "self._last_updated".

-- 
You received this message because you are subscribed to the Google 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: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Doug Ballance
A method similar to what Anssi describes is what we use for local
caching of data that is too large to comfortably fetch from cache/
parse from file every time we need it. A  Doing a lazy fetch with a
maximum age like that also helps with load times since it is only
fetched when accessed. Of course the fetch needs to be reasonably
possible with the time frame of a single request in order to not
frustrate users.

# Put this class somewhere and import into your settings.py
import datetime
import urllib2
class LazyFetch(object):
def __init__(self,url,max_age=60*60):
self.url=url
self.reload_delta=datetime.timedelta(seconds=max_age)

def _get_content(self):
last_updated=getattr(self,'_last_updated',None)
if not last_updated or datetime.datetime.now()-last_updated >
self.reload_delta:
self._content=urllib2.urlopen(self.url).read()
self._age=datetime.datetime.now()
return self._content
content=property(_get_content)

somepage=LazyFetch("http://www.example.com",30)

then elsewhere in your code you can import settings and access the
page content

current_content=settings.somepage.content

Accessing the property "content" would call get_content() which checks
to see if the content hasn't been loaded, or expired.. and reloads on
demand.  This is just a barebones example though, you'd want to throw
in some exception handing to the urlopen call at the very least.

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



Re: MySQL Query

2012-02-08 Thread 常 剑
seems like you have no module MySQLdb in your python site-packages, 
install it and try again
在 2012-2-9,AM2:15, Bill 写道:

> Hello
> 
> I am completing the Django tutorials, however I am having a problem
> when syncing the DB to Django.  I am getting the following message.
> Any help would be appreciated.
> 
> C:\Python27\Django-131\django\bin\mysite>manage.py syncdb
> Traceback (most recent call last):
>  File "C:\Python27\Django-131\django\bin\mysite\manage.py", line 14,
> in > 
>execute_manager(settings)
>  File "C:\Python27\lib\site-packages\django\core\management
> \__init__.py", line
> 438, in execute_manager
>utility.execute()
>  File "C:\Python27\lib\site-packages\django\core\management
> \__init__.py", line
> 379, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "C:\Python27\lib\site-packages\django\core\management
> \__init__.py", line
> 261, in fetch_command
>klass = load_command_class(app_name, subcommand)
>  File "C:\Python27\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:\Python27\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>__import__(name)
>  File "C:\Python27\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:\Python27\lib\site-packages\django\core\management\sql.py",
> line 6, in
> 
>from django.db import models
>  File "C:\Python27\lib\site-packages\django\db\__init__.py", line 78,
> in  e>
>connection = connections[DEFAULT_DB_ALIAS]
>  File "C:\Python27\lib\site-packages\django\db\utils.py", line 93, in
> __getitem
> __
>backend = load_backend(db['ENGINE'])
>  File "C:\Python27\lib\site-packages\django\db\utils.py", line 33, in
> load_back
> end
>return import_module('.base', backend_name)
>  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>__import__(name)
>  File "C:\Python27\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
> 
> Many thanks
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Speficy a Database for Testing

2012-02-08 Thread Andy McKay
You can define a custom test runner to do this. For example:

https://docs.djangoproject.com/en/dev/topics/testing/#django.test.simple.DjangoTestSuiteRunner.setup_databases

On Wed, Feb 8, 2012 at 7:42 AM, xina towner  wrote:
> Yes, but django makes a new testDatabase and that's my problem, I want
> django to use a database I've previously done.

-- 
You received this message because you are subscribed to the Google 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: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Andy McKay
You can define multiple caches:

https://docs.djangoproject.com/en/1.3/topics/cache/#django-s-cache-framework

You could then use a file system cache or your own local memcache.

https://docs.djangoproject.com/en/1.3/topics/cache/#filesystem-caching

You can then get that cache and access it in your code:

from django.core.cache import get_cache
cache = get_cache('my-filesystem-cache-defined-in-settings')

On Wed, Feb 8, 2012 at 3:29 PM, bfrederi  wrote:
> I'm already using memcached over http so I can have multiple memcached
> instances. But there isn't any way to set priority or which cache the
> item goes to or is pulled from. So if I had a local memcached
> instance, there's no way I could be sure which memcached instance the
> data was coming from. I already store the data on disk as a back-up in
> case the connection to my memcached servers fails. But I'm really
> looking to store it in local memory. And hopefully without adding any
> other tools to my stack.

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

2012-02-08 Thread Andy McKay
> The Django crowd seems to prefer PostgreSQL collectively, but I know
> there are a million sites out there using MySQL, so that would
> probably resonate with people. Sort of the "frank Wiles of the mySQL
> world"?

+1 on good MySQL speakers, whilst its not preferred by many, its very
under represented.

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



Can anyone please explain the following settings?

2012-02-08 Thread John Yeukhon Wong
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, "site_media", "media")

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com;, "http://example.com/media/;
MEDIA_URL = "/site_media/media/"

# Absolute path to the directory that holds static files like app
media.
# Example: "/home/media/media.lawrence.com/apps/"
STATIC_ROOT = os.path.join(PROJECT_ROOT, "site_media", "static")

# URL that handles the static files like app media.
# Example: "http://media.lawrence.com;
STATIC_URL = "/site_media/static/"

I am kinda new with site_media settings. THis is a legacy code.
Right now I have two directories under the site_root

/media/  and /site_media/ (which contains site_media/static/*.*)  The
latter one is where all the css, js comes from. But I have the same
exact copies in /media/.

I just don't understand what each of the options above mean Can
someone please explain them?  Thanks.

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



Re: Django (and Python) speakers

2012-02-08 Thread Steve Holden
We can ask, I suppose. I understood that one of the reasons he didn't
make the last DjangoCon US was our tardiness in putting the schedule
together. I don't know what other factors may have played into that
decision. The speaker expenses bill would, of course, be high ...

regards
 Steve

On Feb 7, 9:30 pm, Jeremy Dunck  wrote:
> I'd also like to see Malcolm again, but I fear that'll take a trip to Sydney. 
> :)
>
>
>
>
>
>
>
> On Tue, Feb 7, 2012 at 9:29 PM, Jeremy Dunck  wrote:
> > The original musketeers, Jacob, Simon, and Adrian, are all great
> > speakers, of course.
>
> > I thought Jeff Balough, Mike Malone, and Eric Florenzano did very well
> > on their talks.  David Cramer represents Disqus well and has recently
> > released Sentry 2.
>
> > As a particular pain points for me, I'd like to hear from someone
> > using MySQL and Django at scale. Similarly, a walkthrough of how to
> > work with celery under evented IO would be useful.
>
> > Coverage of puppet (my preference) or Chef would also be interesting.
>
> > PyPy deserves attention as well as the general progress towards Python 3.
>
> > I'd like to hear Jeff Croft talk about design and open source.
>
> > I fear I've given too many topics, but there you go. :)
>
> > On Tue, Feb 7, 2012 at 5:00 PM, Steve Holden  wrote:
> >> I don't know if readers have heard the news that PyCon has closed
> >> registration early because it is full. So you may be interested in six
> >> new conferences, three about Python and three about Django, that we
> >> have just announced:
>
> >>  http://www.prweb.com/releases/2012/1/prweb8945991.htm
>
> >> With this announcement I would like to solicit suggestions for
> >> speakers. Who do you think does an excellent job of covering their
> >> material? Whom do you enjoy hearing? Who has information you need. The
> >> conferences will be two-day single-track events, and besides having
> >> guest speakers we will also be including some talks submitted by the
> >> community. So we'll be trying to retain the "community" feel of
> >> DjangoCon and PyCon.
>
> >> Amy other ideas for speakers or other activities please get in touch!
>
> >> regards
> >>  Steve
>
> >> --
> >> You received this message because you are subscribed to the Google 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 
> >> athttp://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 Python) speakers

2012-02-08 Thread Steve Holden
Thanks for your ideas!

On Feb 7, 9:29 pm, Jeremy Dunck  wrote:
> The original musketeers, Jacob, Simon, and Adrian, are all great
> speakers, of course.
>
Indeed, though they are all so busy we can't rely on them having time
to speak to us.

> I thought Jeff Balough, Mike Malone, and Eric Florenzano did very well
> on their talks.  David Cramer represents Disqus well and has recently
> released Sentry 2.
>
Thanks.

> As a particular pain points for me, I'd like to hear from someone
> using MySQL and Django at scale. Similarly, a walkthrough of how to
> work with celery under evented IO would be useful.
>
The Django crowd seems to prefer PostgreSQL collectively, but I know
there are a million sites out there using MySQL, so that would
probably resonate with people. Sort of the "frank Wiles of the mySQL
world"?

> Coverage of puppet (my preference) or Chef would also be interesting.
>
It's almost starting to be there are as many deployment systems as web
frameworks!

> PyPy deserves attention as well as the general progress towards Python 3.
>
I agree that the convergence of Python 3, Django and PyPy is an
exciting prospect. Few better qualifies to speak on that topic than
Alex Gaynor, I'd have said.

> I'd like to hear Jeff Croft talk about design and open source.
>
> I fear I've given too many topics, but there you go. :)
>
Hey, I asked! Thanks again for your enthusiastic input!

regards
 Steve
>
>
>
> On Tue, Feb 7, 2012 at 5:00 PM, Steve Holden  wrote:
> > I don't know if readers have heard the news that PyCon has closed
> > registration early because it is full. So you may be interested in six
> > new conferences, three about Python and three about Django, that we
> > have just announced:
>
> >  http://www.prweb.com/releases/2012/1/prweb8945991.htm
>
> > With this announcement I would like to solicit suggestions for
> > speakers. Who do you think does an excellent job of covering their
> > material? Whom do you enjoy hearing? Who has information you need. The
> > conferences will be two-day single-track events, and besides having
> > guest speakers we will also be including some talks submitted by the
> > community. So we'll be trying to retain the "community" feel of
> > DjangoCon and PyCon.
>
> > Amy other ideas for speakers or other activities please get in touch!
>
> > regards
> >  Steve
>
> > --
> > You received this message because you are subscribed to the Google 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 
> > athttp://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.



site_media and media

2012-02-08 Thread John Yeukhon Wong
I am working on someone's legacy code. We do testings on virtual
machine (like virtulabox). The virtual machine image contains a
working version of our project, and under the directory we have this:

project
  - media/
  - site_media
   - static

-- 
You received this message because you are subscribed to the Google 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: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread bfrederi
I'm already using memcached over http so I can have multiple memcached
instances. But there isn't any way to set priority or which cache the
item goes to or is pulled from. So if I had a local memcached
instance, there's no way I could be sure which memcached instance the
data was coming from. I already store the data on disk as a back-up in
case the connection to my memcached servers fails. But I'm really
looking to store it in local memory. And hopefully without adding any
other tools to my stack.

On Feb 8, 5:04 pm, Brett Epps  wrote:
> I'd recommend caching the data using Django's caching framework and either
> the local memory or memcached backend.  To update the cache, write a
> management command that runs periodically as a cron job.  (If you find
> yourself needing more sophisticated background task management, check out
> Celery.)
>
> Brett
>
> On 2/8/12 4:14 PM, "bfrederi"  wrote:
>
>
>
>
>
>
>
> >I have some data that I retrieve using urllib and then cache on a
> >different server that I frequently use through my site. Since it gets
> >used so frequently, I was wondering why it might be a good/bad idea to
> >make the urllib request in the settings.py. It's data that gets
> >changed infrequently, but should update every once in a while, but I'd
> >prefer that it stayed in local memory as much as possible, since it
> >gets used so much. Any advice on how to make a dynamic global variable
> >like that is much appreciated.
>
> >Thanks,
> >Brandon
>
> >--
> >You received this message because you are subscribed to the Google 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: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Brett Epps
I'd recommend caching the data using Django's caching framework and either
the local memory or memcached backend.  To update the cache, write a
management command that runs periodically as a cron job.  (If you find
yourself needing more sophisticated background task management, check out
Celery.)

Brett


On 2/8/12 4:14 PM, "bfrederi"  wrote:

>I have some data that I retrieve using urllib and then cache on a
>different server that I frequently use through my site. Since it gets
>used so frequently, I was wondering why it might be a good/bad idea to
>make the urllib request in the settings.py. It's data that gets
>changed infrequently, but should update every once in a while, but I'd
>prefer that it stayed in local memory as much as possible, since it
>gets used so much. Any advice on how to make a dynamic global variable
>like that is much appreciated.
>
>Thanks,
>Brandon
>
>-- 
>You received this message because you are subscribed to the Google 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: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread bfrederi
So would I put that class in my settings.py? Where would I put that
class to make sure that the data is frequently retrieved from local
memory?

On Feb 8, 4:47 pm, akaariai  wrote:
> On Feb 9, 12:14 am, bfrederi  wrote:
>
> > I have some data that I retrieve using urllib and then cache on a
> > different server that I frequently use through my site. Since it gets
> > used so frequently, I was wondering why it might be a good/bad idea to
> > make the urllib request in the settings.py. It's data that gets
> > changed infrequently, but should update every once in a while, but I'd
> > prefer that it stayed in local memory as much as possible, since it
> > gets used so much. Any advice on how to make a dynamic global variable
> > like that is much appreciated.
>
> Don't do that in settings.py. Use Django's caching framework. Or
> something like:
> class MyUrlLoader(object):
>     cache = {} # map of url -> (timeout cutpoint, data)
>     def get_data(url):
>            val = self.cache.get(url)
>            if val is None or datetime.now() > val[0]:
>                 val = (datetime.now() + timedelta(seconds=60),
> loaded_data)
>                 self.cache[url]  = val
>            return val[1]
>
> No idea if the above actually works, but the idea should work. But you
> really are duplicating what the cache framework does, so first try
> that.
>
>  - Anssi

-- 
You received this message because you are subscribed to the Google 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: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread akaariai
On Feb 9, 12:14 am, bfrederi  wrote:
> I have some data that I retrieve using urllib and then cache on a
> different server that I frequently use through my site. Since it gets
> used so frequently, I was wondering why it might be a good/bad idea to
> make the urllib request in the settings.py. It's data that gets
> changed infrequently, but should update every once in a while, but I'd
> prefer that it stayed in local memory as much as possible, since it
> gets used so much. Any advice on how to make a dynamic global variable
> like that is much appreciated.

Don't do that in settings.py. Use Django's caching framework. Or
something like:
class MyUrlLoader(object):
cache = {} # map of url -> (timeout cutpoint, data)
def get_data(url):
   val = self.cache.get(url)
   if val is None or datetime.now() > val[0]:
val = (datetime.now() + timedelta(seconds=60),
loaded_data)
self.cache[url]  = val
   return val[1]

No idea if the above actually works, but the idea should work. But you
really are duplicating what the cache framework does, so first try
that.

 - Anssi

-- 
You received this message because you are subscribed to the Google 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: localize custom commands

2012-02-08 Thread ScOut3R
Dear Anssi,

thank you for the quick answer. It worked like a charm! I've used
translation.activate().

Best regards,
Mate

On Feb 8, 10:50 pm, akaariai  wrote:
> On Feb 8, 10:44 pm, ScOut3R  wrote:
>
> > Dear Django users,
>
> > i'm trying to figure out how to localize strings in a custom command.
> > My command sends out emails with static strings defined in the
> > [command].py file. Makemessages picks up these strings but the
> > outgoing email's contents are in the original locale not the one which
> > is set in the settings.py.
>
> > Is there a way to localize custom commands?
>
> This is likely a problem of not having the correct language activated.
> en-us is force-actiavated in base commands (so that content type names
> are not translated). So, you should activate your preferred language
> by hand.
>
>  - Anssi

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



Dynamic settings variables (dynamic global variable)

2012-02-08 Thread bfrederi
I have some data that I retrieve using urllib and then cache on a
different server that I frequently use through my site. Since it gets
used so frequently, I was wondering why it might be a good/bad idea to
make the urllib request in the settings.py. It's data that gets
changed infrequently, but should update every once in a while, but I'd
prefer that it stayed in local memory as much as possible, since it
gets used so much. Any advice on how to make a dynamic global variable
like that is much appreciated.

Thanks,
Brandon

-- 
You received this message because you are subscribed to the Google 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: localize custom commands

2012-02-08 Thread akaariai
On Feb 8, 10:44 pm, ScOut3R  wrote:
> Dear Django users,
>
> i'm trying to figure out how to localize strings in a custom command.
> My command sends out emails with static strings defined in the
> [command].py file. Makemessages picks up these strings but the
> outgoing email's contents are in the original locale not the one which
> is set in the settings.py.
>
> Is there a way to localize custom commands?

This is likely a problem of not having the correct language activated.
en-us is force-actiavated in base commands (so that content type names
are not translated). So, you should activate your preferred language
by hand.

 - Anssi

-- 
You received this message because you are subscribed to the Google 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: UnboundLocalError: local variable 'full_path' referenced before assignment

2012-02-08 Thread akaariai
Quickly looking through the code it seems this is a bug in Django. The
full_path variable is used in a place where it is not guaranteed to be
initialized. In fact, the whole loaddata.py file seems like a good
candidate for some cleanup. 9 levels of indentation in a method and
this sort of bug is likely...

The code was going to tell you that fixture loading didn't succeed, so
the error when reporting this error isn't that critical.

Please file a bug in trac about this. Try to include enough
information so that the error can be reproduced. A failing test case
in django's test suite is perfect, a sample project demonstrating the
problem is good and verbal explanation will do.

 - Anssi

On Feb 8, 10:27 pm, rok  wrote:
> When executing the "manage.py syncdb" I get the following error:
>
> Creating tables ...
> Installing custom SQL ...
> Installing indexes ...
> Traceback (most recent call last):
>   File "./manage.py", line 26, in 
>     execute_from_command_line(sys.argv)
>   File "/home/rok/apps/django-trunk/django/core/management/
> __init__.py", line 440, in execute_from_command_line
>     utility.execute()
>   File "/home/rok/apps/django-trunk/django/core/management/
> __init__.py", line 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/home/rok/apps/django-trunk/django/core/management/base.py",
> line 196, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/home/rok/apps/django-trunk/django/core/management/base.py",
> line 232, in execute
>     output = self.handle(*args, **options)
>   File "/home/rok/apps/django-trunk/django/core/management/base.py",
> line 371, in handle
>     return self.handle_noargs(**options)
>   File "/home/rok/apps/django-trunk/django/core/management/commands/
> syncdb.py", line 164, in handle_noargs
>     call_command('loaddata', 'initial_data', verbosity=verbosity,
> database=db)
>   File "/home/rok/apps/django-trunk/django/core/management/
> __init__.py", line 147, in call_command
>     return klass.execute(*args, **defaults)
>   File "/home/rok/apps/django-trunk/django/core/management/base.py",
> line 232, in execute
>     output = self.handle(*args, **options)
>   File "/home/rok/apps/django-trunk/django/core/management/commands/
> loaddata.py", line 239, in handle
>     (full_path, ''.join(traceback.format_exception(sys.exc_type,
> UnboundLocalError: local variable 'full_path' referenced before
> assignment
>
> Does this ring a bell to anyone? I'm running the django trunk from Feb
> 8th (so 1.4 candidate).
> Rok

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



localize custom commands

2012-02-08 Thread ScOut3R
Dear Django users,

i'm trying to figure out how to localize strings in a custom command.
My command sends out emails with static strings defined in the
[command].py file. Makemessages picks up these strings but the
outgoing email's contents are in the original locale not the one which
is set in the settings.py.

Is there a way to localize custom commands?

Best regards,
Mate

-- 
You received this message because you are subscribed to the Google 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: Translation inside the database

2012-02-08 Thread Thorsten Sanders

Am 08.02.2012 21:35, schrieb akaariai:

On Feb 8, 9:33 pm, Thorsten Sanders  wrote:

Hello,

I have tables having translation like this:

name_en,name_de,name_fr...

With google I found 2 solutions which support that, but they dont allow
to use those fields then with order,filter, values etc...so its kinda
useless.

With some trying arround, I came up with the following:

from django.db import models
from django.utils.translation import get_language

class TransCharField(models.CharField):

  def __getattribute__(self,value):
  if value == 'column':
  return '%s_%s' % (super(TransCharField,
self).__getattribute__(value),get_language())
  else:
  return super(TransCharField, self).__getattribute__(value)

Inside model then for example:

name = TransCharField(max_length=255)

I did some testing and it seems to work proper as I want it, I can just
use the orm normal and using name and inside the query the field get
translated to the right name.

My question is if that solution can have any side effects or if there is
a better way to do that, I will btw only do read operations on those
tables, there will never be write/updates to it via django.

syncdb etc woud break for sure, but it seems that will not be a
problem for you. Serialization will give you only one language. I
can't think of anything else that will break for sure. On the other
hand, it wouldn't be surprising if the list of things that do not work
would be a lot longer. If it works, use it. But it will not work 100%.
Yep I know syncdb breaks and that is not a big problem for me, 
serialization if used should only give 1 language as well and prolly it 
will be used and exactly the "it wouldn't be surprising if the list of 
things that do not work would be a lot longer" is why I am asking, I had 
it before that something works nice 99% of the time but the other 1% it 
dont, in a upcoming project I plan to use that approach for a lot of 
queries and would be quite bad if some side effects will appear, because 
it would be prolly a lot of work to change it.


A safer way would be to do something like:
SomeModel.objects.filter(t('some_column')=someval).order_by(t('some_column'))

def t(col):
 return '%s_%s', (col, get_language())

  - Anssi



--
You received this message because you are subscribed to the Google 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: Translation inside the database

2012-02-08 Thread akaariai
On Feb 8, 9:33 pm, Thorsten Sanders  wrote:
> Hello,
>
> I have tables having translation like this:
>
> name_en,name_de,name_fr...
>
> With google I found 2 solutions which support that, but they dont allow
> to use those fields then with order,filter, values etc...so its kinda
> useless.
>
> With some trying arround, I came up with the following:
>
> from django.db import models
> from django.utils.translation import get_language
>
> class TransCharField(models.CharField):
>
>      def __getattribute__(self,value):
>          if value == 'column':
>              return '%s_%s' % (super(TransCharField,
> self).__getattribute__(value),get_language())
>          else:
>              return super(TransCharField, self).__getattribute__(value)
>
> Inside model then for example:
>
> name = TransCharField(max_length=255)
>
> I did some testing and it seems to work proper as I want it, I can just
> use the orm normal and using name and inside the query the field get
> translated to the right name.
>
> My question is if that solution can have any side effects or if there is
> a better way to do that, I will btw only do read operations on those
> tables, there will never be write/updates to it via django.

syncdb etc woud break for sure, but it seems that will not be a
problem for you. Serialization will give you only one language. I
can't think of anything else that will break for sure. On the other
hand, it wouldn't be surprising if the list of things that do not work
would be a lot longer. If it works, use it. But it will not work 100%.

A safer way would be to do something like:
SomeModel.objects.filter(t('some_column')=someval).order_by(t('some_column'))

def t(col):
return '%s_%s', (col, get_language())

 - Anssi

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



UnboundLocalError: local variable 'full_path' referenced before assignment

2012-02-08 Thread rok
When executing the "manage.py syncdb" I get the following error:

Creating tables ...
Installing custom SQL ...
Installing indexes ...
Traceback (most recent call last):
  File "./manage.py", line 26, in 
execute_from_command_line(sys.argv)
  File "/home/rok/apps/django-trunk/django/core/management/
__init__.py", line 440, in execute_from_command_line
utility.execute()
  File "/home/rok/apps/django-trunk/django/core/management/
__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/rok/apps/django-trunk/django/core/management/base.py",
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/home/rok/apps/django-trunk/django/core/management/base.py",
line 232, in execute
output = self.handle(*args, **options)
  File "/home/rok/apps/django-trunk/django/core/management/base.py",
line 371, in handle
return self.handle_noargs(**options)
  File "/home/rok/apps/django-trunk/django/core/management/commands/
syncdb.py", line 164, in handle_noargs
call_command('loaddata', 'initial_data', verbosity=verbosity,
database=db)
  File "/home/rok/apps/django-trunk/django/core/management/
__init__.py", line 147, in call_command
return klass.execute(*args, **defaults)
  File "/home/rok/apps/django-trunk/django/core/management/base.py",
line 232, in execute
output = self.handle(*args, **options)
  File "/home/rok/apps/django-trunk/django/core/management/commands/
loaddata.py", line 239, in handle
(full_path, ''.join(traceback.format_exception(sys.exc_type,
UnboundLocalError: local variable 'full_path' referenced before
assignment

Does this ring a bell to anyone? I'm running the django trunk from Feb
8th (so 1.4 candidate).
Rok

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



Translation inside the database

2012-02-08 Thread Thorsten Sanders

Hello,

I have tables having translation like this:

name_en,name_de,name_fr...

With google I found 2 solutions which support that, but they dont allow 
to use those fields then with order,filter, values etc...so its kinda 
useless.


With some trying arround, I came up with the following:

from django.db import models
from django.utils.translation import get_language

class TransCharField(models.CharField):

def __getattribute__(self,value):
if value == 'column':
return '%s_%s' % (super(TransCharField, 
self).__getattribute__(value),get_language())

else:
return super(TransCharField, self).__getattribute__(value)

Inside model then for example:

name = TransCharField(max_length=255)

I did some testing and it seems to work proper as I want it, I can just 
use the orm normal and using name and inside the query the field get 
translated to the right name.


My question is if that solution can have any side effects or if there is 
a better way to do that, I will btw only do read operations on those 
tables, there will never be write/updates to it via django.


Greetings,
Thorsten

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



Re: MySQL Query

2012-02-08 Thread Bill
Many thanks it is now working!!

On Feb 8, 6:21 pm, Sandro Dutra  wrote:
> Probably you've to install python-mysqldb.
>
> 2012/2/8 Bill :
>
>
>
>
>
>
>
> > Hello
>
> > I am completing the Django tutorials, however I am having a problem
> > when syncing the DB to Django.  I am getting the following message.
> > Any help would be appreciated.
>
> > C:\Python27\Django-131\django\bin\mysite>manage.py syncdb
> > Traceback (most recent call last):
> >  File "C:\Python27\Django-131\django\bin\mysite\manage.py", line 14,
> > in 
> >    execute_manager(settings)
> >  File "C:\Python27\lib\site-packages\django\core\management
> > \__init__.py", line
> > 438, in execute_manager
> >    utility.execute()
> >  File "C:\Python27\lib\site-packages\django\core\management
> > \__init__.py", line
> > 379, in execute
> >    self.fetch_command(subcommand).run_from_argv(self.argv)
> >  File "C:\Python27\lib\site-packages\django\core\management
> > \__init__.py", line
> > 261, in fetch_command
> >    klass = load_command_class(app_name, subcommand)
> >  File "C:\Python27\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:\Python27\lib\site-packages\django\utils\importlib.py", line
> > 35, in im
> > port_module
> >    __import__(name)
> >  File "C:\Python27\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:\Python27\lib\site-packages\django\core\management\sql.py",
> > line 6, in
> >  
> >    from django.db import models
> >  File "C:\Python27\lib\site-packages\django\db\__init__.py", line 78,
> > in  > e>
> >    connection = connections[DEFAULT_DB_ALIAS]
> >  File "C:\Python27\lib\site-packages\django\db\utils.py", line 93, in
> > __getitem
> > __
> >    backend = load_backend(db['ENGINE'])
> >  File "C:\Python27\lib\site-packages\django\db\utils.py", line 33, in
> > load_back
> > end
> >    return import_module('.base', backend_name)
> >  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line
> > 35, in im
> > port_module
> >    __import__(name)
> >  File "C:\Python27\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
>
> > Many thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://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: MySQL Query

2012-02-08 Thread Bill
Many thanks it is now working!!

On Feb 8, 6:21 pm, Anoop Thomas Mathew  wrote:
> Hi,
> Make sure that you have installed MySQL-python package for python bindings
> to mysql.
>
> Thanks,
> Anoop Thomas Mathew
>
> ___
> Life is short, Live it hard.
>
> On 8 February 2012 23:45, Bill  wrote:
>
>
>
>
>
>
>
> > Hello
>
> > I am completing the Django tutorials, however I am having a problem
> > when syncing the DB to Django.  I am getting the following message.
> > Any help would be appreciated.
>
> > C:\Python27\Django-131\django\bin\mysite>manage.py syncdb
> > Traceback (most recent call last):
> >  File "C:\Python27\Django-131\django\bin\mysite\manage.py", line 14,
> > in 
> >    execute_manager(settings)
> >  File "C:\Python27\lib\site-packages\django\core\management
> > \__init__.py", line
> > 438, in execute_manager
> >    utility.execute()
> >  File "C:\Python27\lib\site-packages\django\core\management
> > \__init__.py", line
> > 379, in execute
> >    self.fetch_command(subcommand).run_from_argv(self.argv)
> >  File "C:\Python27\lib\site-packages\django\core\management
> > \__init__.py", line
> > 261, in fetch_command
> >    klass = load_command_class(app_name, subcommand)
> >  File "C:\Python27\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:\Python27\lib\site-packages\django\utils\importlib.py", line
> > 35, in im
> > port_module
> >    __import__(name)
> >  File "C:\Python27\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:\Python27\lib\site-packages\django\core\management\sql.py",
> > line 6, in
> >  
> >    from django.db import models
> >  File "C:\Python27\lib\site-packages\django\db\__init__.py", line 78,
> > in  > e>
> >    connection = connections[DEFAULT_DB_ALIAS]
> >  File "C:\Python27\lib\site-packages\django\db\utils.py", line 93, in
> > __getitem
> > __
> >    backend = load_backend(db['ENGINE'])
> >  File "C:\Python27\lib\site-packages\django\db\utils.py", line 33, in
> > load_back
> > end
> >    return import_module('.base', backend_name)
> >  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line
> > 35, in im
> > port_module
> >    __import__(name)
> >  File "C:\Python27\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
>
> > Many thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: could i use a select?

2012-02-08 Thread Javier Guerra Giraldez
On Wed, Feb 8, 2012 at 9:53 AM, Dennis Lee Bieber  wrote:
> I don't
> think the slice is "present" early enough to be turned into an "offset x
> limit y" query

yes, it is; and yes, it does

-- 
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: Models inheritance in django: how to change PK "_ptr_id" on "id"?

2012-02-08 Thread Artyom Chernetzov
Thanks, everybody, problem was: I add ForeignKey field in object after 
dbsync. I just needed to reset database, it solve problem.

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



Re: MySQL Query

2012-02-08 Thread Sandro Dutra
Probably you've to install python-mysqldb.

2012/2/8 Bill :
> Hello
>
> I am completing the Django tutorials, however I am having a problem
> when syncing the DB to Django.  I am getting the following message.
> Any help would be appreciated.
>
> C:\Python27\Django-131\django\bin\mysite>manage.py syncdb
> Traceback (most recent call last):
>  File "C:\Python27\Django-131\django\bin\mysite\manage.py", line 14,
> in >
>    execute_manager(settings)
>  File "C:\Python27\lib\site-packages\django\core\management
> \__init__.py", line
> 438, in execute_manager
>    utility.execute()
>  File "C:\Python27\lib\site-packages\django\core\management
> \__init__.py", line
> 379, in execute
>    self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "C:\Python27\lib\site-packages\django\core\management
> \__init__.py", line
> 261, in fetch_command
>    klass = load_command_class(app_name, subcommand)
>  File "C:\Python27\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:\Python27\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>    __import__(name)
>  File "C:\Python27\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:\Python27\lib\site-packages\django\core\management\sql.py",
> line 6, in
>  
>    from django.db import models
>  File "C:\Python27\lib\site-packages\django\db\__init__.py", line 78,
> in  e>
>    connection = connections[DEFAULT_DB_ALIAS]
>  File "C:\Python27\lib\site-packages\django\db\utils.py", line 93, in
> __getitem
> __
>    backend = load_backend(db['ENGINE'])
>  File "C:\Python27\lib\site-packages\django\db\utils.py", line 33, in
> load_back
> end
>    return import_module('.base', backend_name)
>  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>    __import__(name)
>  File "C:\Python27\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
>
> Many thanks
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



MySQL Query

2012-02-08 Thread Bill
Hello

I am completing the Django tutorials, however I am having a problem
when syncing the DB to Django.  I am getting the following message.
Any help would be appreciated.

C:\Python27\Django-131\django\bin\mysite>manage.py syncdb
Traceback (most recent call last):
  File "C:\Python27\Django-131\django\bin\mysite\manage.py", line 14,
in 
execute_manager(settings)
  File "C:\Python27\lib\site-packages\django\core\management
\__init__.py", line
438, in execute_manager
utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management
\__init__.py", line
379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management
\__init__.py", line
261, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "C:\Python27\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:\Python27\lib\site-packages\django\utils\importlib.py", line
35, in im
port_module
__import__(name)
  File "C:\Python27\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:\Python27\lib\site-packages\django\core\management\sql.py",
line 6, in
 
from django.db import models
  File "C:\Python27\lib\site-packages\django\db\__init__.py", line 78,
in 
connection = connections[DEFAULT_DB_ALIAS]
  File "C:\Python27\lib\site-packages\django\db\utils.py", line 93, in
__getitem
__
backend = load_backend(db['ENGINE'])
  File "C:\Python27\lib\site-packages\django\db\utils.py", line 33, in
load_back
end
return import_module('.base', backend_name)
  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line
35, in im
port_module
__import__(name)
  File "C:\Python27\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

Many thanks

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



Re: how to make a small change for apps installed under /site-packages dir

2012-02-08 Thread Tom Lesters
> Generally speaking, using virtualenv (no-site-packages) + pip (with a
> requirement file you keep in your project) is a GoodPractice(tm) when
> it comes to dependencies.

I'm actually using virtuallenv + pip now, thanks for advice anyways!

> Daniel already provided the simplest solution for this problem.
> Monkeypatching doesn't totally solve this
> problem but from experience it makes for easier updates.

Daniel's solution works great in this case.
will do more research on Monkey patching.
Thanks a lot!

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: Foreign Key + Primary key

2012-02-08 Thread akaariai
On Feb 8, 7:01 pm, Sandeep kaur  wrote:
> Is there any way of having a field in table, declared both as foreign
> key as well as primary key?
> I want something like this in models:
>      publisher = models.ForeignKey(Publisher,primary_key=True)

If the above doesn't work, then I guess the answer is no.

You could probably do:
  publisher = models.ForeignKey(Publisher, unique=True)
which is at least somewhat close to what you wanted. You will have an
extra column for the PK, but otherwise this should function pretty
close to having the ForeignKey as PK.

 - Anssi

-- 
You received this message because you are subscribed to the Google 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: Foreign Key + Primary key

2012-02-08 Thread yati sagade
Even if there was provision for that(I don't know), it really wouldn't make
sense. A parent relation tuple can be referenced by multiple child relation
tuples - thereby breaking the uniqueness constraint that comes with a
primary key.

On Wed, Feb 8, 2012 at 10:31 PM, Sandeep kaur  wrote:

> Is there any way of having a field in table, declared both as foreign
> key as well as primary key?
> I want something like this in models:
> publisher = models.ForeignKey(Publisher,primary_key=True)
>
> --
> Sandeep Kaur
> E-Mail: mkaurkha...@gmail.com
> Blog: sandymadaan.wordpress.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Yati Sagade 

(@yati_itay )

-- 
You received this message because you are subscribed to the Google 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: Foreign Key + Primary key

2012-02-08 Thread Joel Goldstick
On Wed, Feb 8, 2012 at 12:01 PM, Sandeep kaur  wrote:
> Is there any way of having a field in table, declared both as foreign
> key as well as primary key?
> I want something like this in models:
>     publisher = models.ForeignKey(Publisher,primary_key=True)
>
> --
> Sandeep Kaur
> E-Mail: mkaurkha...@gmail.com
> Blog: sandymadaan.wordpress.com
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

I'm not sure if I am reading you right but maybe you are thinking
about one to one relationship:

https://docs.djangoproject.com/en/dev/topics/db/models/#one-to-one-relationships

-- 
Joel Goldstick

-- 
You received this message because you are subscribed to the Google 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: [Session] [Bangalore - India] Python & Django – Introduction & Demo

2012-02-08 Thread yati sagade
Sorry, That is, do you guys *have* any similar plans for Kolkata?

On Wed, Feb 8, 2012 at 11:21 PM, yati sagade  wrote:

> Great news! would love to be there - Do you plans for something similar in
> Kolkata?
>
>
> On Wed, Feb 8, 2012 at 8:31 PM, Sivasubramaniam Arunachalam <
> sivasubramania...@gmail.com> wrote:
>
>> Hi All,
>>
>> There is a Django introduction session with demo scheduled in Bar Camp
>> 2012.
>>
>> *Venue : SAP Labs India , Bangalore, India*
>> *Date : 11-Feb-2012*
>>
>> More details @
>> http://barcampbangalore.org/bcb/bcb11/python-django-introduction-demo
>>
>> Thanks & Regards,
>> Sivasubramaniam Arunachalam
>>
>>
>>  --
>> You received this message because you are subscribed to the Google 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.
>>
>
>
>
> --
> Yati Sagade 
>
> (@yati_itay )
>
>
>


-- 
Yati Sagade 

(@yati_itay )

-- 
You received this message because you are subscribed to the Google 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: [Session] [Bangalore - India] Python & Django – Introduction & Demo

2012-02-08 Thread yati sagade
Great news! would love to be there - Do you plans for something similar in
Kolkata?

On Wed, Feb 8, 2012 at 8:31 PM, Sivasubramaniam Arunachalam <
sivasubramania...@gmail.com> wrote:

> Hi All,
>
> There is a Django introduction session with demo scheduled in Bar Camp
> 2012.
>
> *Venue : SAP Labs India , Bangalore, India*
> *Date : 11-Feb-2012*
>
> More details @
> http://barcampbangalore.org/bcb/bcb11/python-django-introduction-demo
>
> Thanks & Regards,
> Sivasubramaniam Arunachalam
>
>
>  --
> You received this message because you are subscribed to the Google 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.
>



-- 
Yati Sagade 

(@yati_itay )

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



Foreign Key + Primary key

2012-02-08 Thread Sandeep kaur
Is there any way of having a field in table, declared both as foreign
key as well as primary key?
I want something like this in models:
 publisher = models.ForeignKey(Publisher,primary_key=True)

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

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



Re: Generic relationships between existing entities, many2many

2012-02-08 Thread arkai...@gmail.com
Hi,
Maybe I focused too much on the type of solution I was looking for and not
on the problem itself.

Let's try with music:

I have a Bands application with a Band model that can be used for CRUD of
band entity and for voting bands, commenting on them etc..
I have a Venue application  with a Venue model that can be used for CRUD of
venue entity and "" "" 

I have a Media application that contains a Picture model that is used for
storing pics, commenting etc...
I have an Articles application that contains an Article model that people
use to write post-like articles writing about bands or venues or whateveer.
I have an Events application that conains an Event model that people use to
describe when and how an event will happen.

Now, as a side note, almost all of those models have comments through
django.contrib.comments plugged in by their own application, model
untouched.

What I would like to do is to be able of tagging Pictures,Articles and
Events with Bands, Venues, a combination of several of each or none at all.
Plus to the Band and Venue model types I will be adding soon other models
as Promoter etc.. that could be tagged as well in any of the others.

The kind of information I am going to read is like:

   - For this Article give me bands
   - For this Picture give me venues and bands
   - For this Event give me venues
   - For this Band how many entities are tagged(Pictures,Articles...),
   retrieve them
   - For this Venue give me pictures


To me it is the same pattern over and over with different entities on both
sides, so I was looking for a generic way of handling it.

Following the external approach of django.contrib.comments, something like
this:

Example:

> {%gettags currentband Article as articles_for_currentband%}
> {%gettags Bands currentarticle as bandtags_for_this_article%}
> {%tagcount currentband %}
>


--
Arkaitz


On Tue, Feb 7, 2012 at 7:11 PM, arkai...@gmail.com wrote:

> Hi,
>
> So, I have the 4 entities represented below which are strong and
> independent entities on my application, now the problem is that each
> Article or Picture could be "tagged" with a Presenter or an Event, being as
> they are the 4 of them independent entities that could become more complex
> It doesn't look right to add Event and Presenter field to both Article and
> Picture or the contrary, specially because they could be tagged with none.
> In the long run as well other entities might need to be tagged and other
> taggable entities might appear.
>
>> class Article(models.Model):
>>
>>
>>
>> #Fields
>> class Picture(models.Model):
>>
>> #Fields
>> class Presenter(models.Model):
>>
>> # Fields
>> class Event(models.Model):
>>
>> # Fields
>>
>> The closer I am getting is to some kind of double-headed Generic
> contenttype based intermediate model like this(haven't tested yet as it is
> a bit more complex than that), but I am looking for ideas:
>
>> class GenericTag(models.Model):
>>
>>
>>
>> # Event,Presenter instance..
>> tagcontent_type = models.ForeignKey(ContentType)
>>
>>
>>
>> tagobject_id = models.PositiveIntegerField()
>> tagcontent_object = generic.GenericForeignKey('tagcontent_type', 
>> 'tagobject_id')
>>
>>
>>
>> # Picture,Article instance
>> objcontent_type = models.ForeignKey(ContentType)
>>
>>
>>
>> objobject_id = models.PositiveIntegerField()
>> objcontent_object = generic.GenericForeignKey('objcontent_type', 
>> 'objobject_id')
>>
>>
>>  And with that just do queries based on the information I have, I think
> there have to be more elegant ways to do this without stuffing all
> tagmodels as fields into taggablemodels.
> So, basically, there are several "taggable" objects and "tag" objects
> which will never overlap and I would like a way of relating them with
> django without touching the models themselves as they are entities of their
> own apps.
>
> I was looking into a proxy model with a many2many field, but cannot add
> fields to proxy models.
>
> Thanks
>
> --
> Arkaitz
>

-- 
You received this message because you are subscribed to the Google 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: Speficy a Database for Testing

2012-02-08 Thread Mark Furbee
I'm not sure that you can specify a different existing database. I think
(not certain) that Django's testing is built to have no effect on real
data, hence creating a blank test database. You can, however, use fixtures
to create data in the test database after it is created and before the unit
tests are performed. I assume the reason you want to use a previously,
externally created DB is that you want to test based on the data in that
DB. If this is the case, it is perfect to use a fixture of that DB's data.

Mark

On Wed, Feb 8, 2012 at 7:42 AM, xina towner  wrote:

> Yes, but django makes a new testDatabase and that's my problem, I want
> django to use a database I've previously done.
>
>
> On 8 February 2012 16:34, Mark Furbee  wrote:
>
>> Denis Darii already answered this on February 1st:
>>
>> "You can redefine your database connection by adding somewhere at the
>> end of your settings.py something like:
>>
>> import sys
>>
>> if 'test' in sys.argv:
>>
>> DATABASES = ...
>>
>> hope this helps."
>>
>>
>> Did you try this?
>>
>> On Wed, Feb 8, 2012 at 7:19 AM, xina towner  wrote:
>>
>>> Can I create a Database manually and then specify to the testing unit to
>>> use that?
>>>
>>> --
>>> Gràcies,
>>>
>>> Rubén
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> 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.
>>
>
>
>
> --
> Gràcies,
>
> Rubén
>
>  --
> You received this message because you are subscribed to the Google 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: Speficy a Database for Testing

2012-02-08 Thread xina towner
Yes, but django makes a new testDatabase and that's my problem, I want
django to use a database I've previously done.

On 8 February 2012 16:34, Mark Furbee  wrote:

> Denis Darii already answered this on February 1st:
>
> "You can redefine your database connection by adding somewhere at the end
> of your settings.py something like:
>
> import sys
>
> if 'test' in sys.argv:
>
> DATABASES = ...
>
> hope this helps."
>
>
> Did you try this?
>
> On Wed, Feb 8, 2012 at 7:19 AM, xina towner  wrote:
>
>> Can I create a Database manually and then specify to the testing unit to
>> use that?
>>
>> --
>> Gràcies,
>>
>> Rubén
>>
>>  --
>> You received this message because you are subscribed to the Google 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.
>



-- 
Gràcies,

Rubén

-- 
You received this message because you are subscribed to the Google 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: could i use a select?

2012-02-08 Thread J. Cliff Dyer
On Wed, 2012-02-08 at 09:53 -0500, Dennis Lee Bieber wrote:
> On Tue, 7 Feb 2012 21:23:58 -0800 (PST), akaariai 
> wrote:
> 
> >I think you could do
> >Customer.objects.annotate(tot_invoice=Sum(invoice_set__total_invoice)).order_by('tot_invoice')
> >[0:10].
> 
>   NOTE: the OP needs a /descending/ sort order (wants the 10 highest
> totals, not the 10 lowest).
> 
>   This may be an example of why I find SQL more understandable than
> the object-based approaches [caveat: I'm no where near familiar with
> Django's full query model], unless the back-end database feeds records
> from the result set on-demand... Transferring a large result set back to
> the client side just to slice off the first 10 entries just seems
> inefficient over having the DBMS itself limit the data set (I don't
> think the slice is "present" early enough to be turned into an "offset x
> limit y" query). Having to transfer the entire result set just to access
> the last 10 seems even more inefficient.
> 
> -- 
>   Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
> 

The only change you would need to make is to change the order_by clause
to .order_by('-tot_invoice').  This will not transfer the entire result
set.  Django implements the slicing so that it is done at the sql
level.  


-- 
You received this message because you are subscribed to the Google 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: Speficy a Database for Testing

2012-02-08 Thread Mark Furbee
Denis Darii already answered this on February 1st:

"You can redefine your database connection by adding somewhere at the end
of your settings.py something like:

import sys

if 'test' in sys.argv:

DATABASES = ...

hope this helps."


Did you try this?

On Wed, Feb 8, 2012 at 7:19 AM, xina towner  wrote:

> Can I create a Database manually and then specify to the testing unit to
> use that?
>
> --
> Gràcies,
>
> Rubén
>
>  --
> You received this message because you are subscribed to the Google 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.



Speficy a Database for Testing

2012-02-08 Thread xina towner
Can I create a Database manually and then specify to the testing unit to
use that?

-- 
Gràcies,

Rubén

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



[Session] [Bangalore - India] Python & Django – Introduction & Demo

2012-02-08 Thread Sivasubramaniam Arunachalam
Hi All,

There is a Django introduction session with demo scheduled in Bar Camp 2012.

*Venue : SAP Labs India , Bangalore, India*
*Date : 11-Feb-2012*

More details @
http://barcampbangalore.org/bcb/bcb11/python-django-introduction-demo

Thanks & Regards,
Sivasubramaniam Arunachalam

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



Custom times in admin time selector

2012-02-08 Thread Sebastian Goll
Hi all,

For DateTimeFields, the admin presents selector widgets for both the
date and time form fields. The default choices for the time selector
are: Now, Midnight, 6 a.m., Noon.

I'd like to replace those default choices with something different,
depending on the ModelAdmin instance in question.

Can this be done easily? How would I do this?

Best wishes,
Sebastian.

-- 
You received this message because you are subscribed to the Google 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: Error with test database

2012-02-08 Thread xina towner
It does not work U_U

On 8 February 2012 14:19, Renne Rocha  wrote:

>   The order in which the tables are created depends on the order in which
> you have them in your INSTALLED_APPS.
>   Try moving the app you want to be created first before the others.
>
>   Renne Rocha
>   http://rennerocha.com/
>
>
> On Wed, Feb 8, 2012 at 11:07 AM, xina towner  wrote:
>
>> I've already done that,
>> this works with databases, but with tables too?
>>
>>
>> On 8 February 2012 14:04, Renne Rocha  wrote:
>>
>>>   You can configure the setting TEST_DEPENDENCIES. See the docs for more
>>> info:
>>>
>>>
>>> https://docs.djangoproject.com/en/1.3/topics/testing/#controlling-creation-order-for-test-databases
>>>
>>>
>>>   Renne Rocha
>>>   http://rennerocha.com/
>>>
>>>
>>>
>>> On Wed, Feb 8, 2012 at 10:57 AM, xina towner wrote:
>>>
 Hello, I've a problem, I have to created a script that makes my
 database in a specifically order but when  I want to make test django do it
 in a different order.

 How can I solve this? because it can't create the database so I can't
 test my app.
 Can I change the order how django initiates the database? or say to
 django to use my script?

 --
 Gràcies,

 Rubén

  --
 You received this message because you are subscribed to the Google
 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.
>>>
>>
>>
>>
>> --
>> Gràcies,
>>
>> Rubén
>>
>>  --
>> You received this message because you are subscribed to the Google 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.
>



-- 
Gràcies,

Rubén

-- 
You received this message because you are subscribed to the Google 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: Error with test database

2012-02-08 Thread Renne Rocha
  The order in which the tables are created depends on the order in which
you have them in your INSTALLED_APPS.
  Try moving the app you want to be created first before the others.

  Renne Rocha
  http://rennerocha.com/


On Wed, Feb 8, 2012 at 11:07 AM, xina towner  wrote:

> I've already done that,
> this works with databases, but with tables too?
>
>
> On 8 February 2012 14:04, Renne Rocha  wrote:
>
>>   You can configure the setting TEST_DEPENDENCIES. See the docs for more
>> info:
>>
>>
>> https://docs.djangoproject.com/en/1.3/topics/testing/#controlling-creation-order-for-test-databases
>>
>>
>>   Renne Rocha
>>   http://rennerocha.com/
>>
>>
>>
>> On Wed, Feb 8, 2012 at 10:57 AM, xina towner wrote:
>>
>>> Hello, I've a problem, I have to created a script that makes my database
>>> in a specifically order but when  I want to make test django do it in a
>>> different order.
>>>
>>> How can I solve this? because it can't create the database so I can't
>>> test my app.
>>> Can I change the order how django initiates the database? or say to
>>> django to use my script?
>>>
>>> --
>>> Gràcies,
>>>
>>> Rubén
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> 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.
>>
>
>
>
> --
> Gràcies,
>
> Rubén
>
>  --
> You received this message because you are subscribed to the Google 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: Error with test database

2012-02-08 Thread xina towner
Can I specify to test tool to use an specific database?

On 8 February 2012 14:07, xina towner  wrote:

> I've already done that,
> this works with databases, but with tables too?
>
>
> On 8 February 2012 14:04, Renne Rocha  wrote:
>
>>   You can configure the setting TEST_DEPENDENCIES. See the docs for more
>> info:
>>
>>
>> https://docs.djangoproject.com/en/1.3/topics/testing/#controlling-creation-order-for-test-databases
>>
>>
>>   Renne Rocha
>>   http://rennerocha.com/
>>
>>
>>
>> On Wed, Feb 8, 2012 at 10:57 AM, xina towner wrote:
>>
>>> Hello, I've a problem, I have to created a script that makes my database
>>> in a specifically order but when  I want to make test django do it in a
>>> different order.
>>>
>>> How can I solve this? because it can't create the database so I can't
>>> test my app.
>>> Can I change the order how django initiates the database? or say to
>>> django to use my script?
>>>
>>> --
>>> Gràcies,
>>>
>>> Rubén
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> 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.
>>
>
>
>
> --
> Gràcies,
>
> Rubén
>
>


-- 
Gràcies,

Rubén

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



Fail to load media files in Django(on Windows7)

2012-02-08 Thread 530056...@qq.com
When i'm trying to load 
http://127.0.0.1:8000/media/javascripts/bg-input.png(This
PNG file exists)

I get a 500 http response saying:

UnicodeDecodeError at /media/javascripts/bg-input.png
'ascii' codec can't decode byte 0xca in position 0: ordinal not in
range(128)
Request Method: GET
Request URL:http://127.0.0.1:8000/media/javascripts/bg-input.png
Django Version: 1.3.1
Exception Type: UnicodeDecodeError
Exception Value:
'ascii' codec can't decode byte 0xca in position 0: ordinal not in
range(128)
Exception Location: T:\Python27\lib\mimetypes.py in enum_types, line
250
Python Executable:  T:\Python27\python.exe
Python Version: 2.7.0
Python Path:
['T:\\djangos\\deadline',
 'T:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
 'T:\\Python27\\lib\\site-packages\\django_pagination-1.0.7-
py2.7.egg',
 'T:\\Python27\\lib\\site-packages\\simplejson-2.3.2-py2.7.egg',
 'C:\\Windows\\system32\\python27.zip',
 'T:\\Python27\\DLLs',
 'T:\\Python27\\lib',
 'T:\\Python27\\lib\\plat-win',
 'T:\\Python27\\lib\\lib-tk',
 'T:\\Python27',
 'T:\\Python27\\lib\\site-packages',
 'T:\\Python27\\lib\\site-packages\\PIL']
Server time:星期二, 7 二月 2012 13:33:53 +0800

Unicode error hint The string that could not be encoded/decoded was:
/x

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/media/javascripts/bg-input.png

Django Version: 1.3.1
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'pagination',
 'deadline.reg',
 'deadline.helpers',
 'deadline.users',
 'deadline.tasks',
 'deadline.comments']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.csrf.CsrfResponseMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'pagination.middleware.PaginationMiddleware')


Traceback:
File "T:\Python27\lib\site-packages\django\core\handlers\base.py" in
get_response
  111. response = callback(request,
*callback_args, **callback_kwargs)
File "T:\Python27\lib\site-packages\django\views\static.py" in serve
  54. mimetype, encoding = mimetypes.guess_type(fullpath)
File "T:\Python27\lib\mimetypes.py" in guess_type
  294. init()
File "T:\Python27\lib\mimetypes.py" in init
  355. db.read_windows_registry()
File "T:\Python27\lib\mimetypes.py" in read_windows_registry
  260. for ctype in enum_types(mimedb):
File "T:\Python27\lib\mimetypes.py" in enum_types
  250. ctype = ctype.encode(default_encoding) #
omit in 3.x!

Exception Type: UnicodeDecodeError at /media/javascripts/bg-input.png
Exception Value: 'ascii' codec can't decode byte 0xca in position 0:
ordinal not in range(128)

#settings.py
...
# Absolute filesystem path to the directory that will hold user-
uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = 'T:/djangos/deadline/media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash.
# Examples: "http://media.lawrence.com/media/;, "http://example.com/
media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static
files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/;
STATIC_URL = '/static/'


#urls.py

url(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),


This problem happens when I am running on windows 7. In ubuntu 11.04
it works fine.
Windows 7 version: 7600 Ultimate
Django version: 1.3.1 Final
A link on stackoverflow
http://stackoverflow.com/questions/9171497/fail-to-load-media-files-in-djangoon-windows#comment11560283_9171497

-- 
You received this message because you are subscribed to the Google 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: Error with test database

2012-02-08 Thread xina towner
I've already done that,
this works with databases, but with tables too?

On 8 February 2012 14:04, Renne Rocha  wrote:

>   You can configure the setting TEST_DEPENDENCIES. See the docs for more
> info:
>
>
> https://docs.djangoproject.com/en/1.3/topics/testing/#controlling-creation-order-for-test-databases
>
>
>   Renne Rocha
>   http://rennerocha.com/
>
>
>
> On Wed, Feb 8, 2012 at 10:57 AM, xina towner  wrote:
>
>> Hello, I've a problem, I have to created a script that makes my database
>> in a specifically order but when  I want to make test django do it in a
>> different order.
>>
>> How can I solve this? because it can't create the database so I can't
>> test my app.
>> Can I change the order how django initiates the database? or say to
>> django to use my script?
>>
>> --
>> Gràcies,
>>
>> Rubén
>>
>>  --
>> You received this message because you are subscribed to the Google 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.
>



-- 
Gràcies,

Rubén

-- 
You received this message because you are subscribed to the Google 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: Error with test database

2012-02-08 Thread Renne Rocha
  You can configure the setting TEST_DEPENDENCIES. See the docs for more
info:


https://docs.djangoproject.com/en/1.3/topics/testing/#controlling-creation-order-for-test-databases


  Renne Rocha
  http://rennerocha.com/



On Wed, Feb 8, 2012 at 10:57 AM, xina towner  wrote:

> Hello, I've a problem, I have to created a script that makes my database
> in a specifically order but when  I want to make test django do it in a
> different order.
>
> How can I solve this? because it can't create the database so I can't test
> my app.
> Can I change the order how django initiates the database? or say to django
> to use my script?
>
> --
> Gràcies,
>
> Rubén
>
>  --
> You received this message because you are subscribed to the Google 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.



Error with test database

2012-02-08 Thread xina towner
Hello, I've a problem, I have to created a script that makes my database in
a specifically order but when  I want to make test django do it in a
different order.

How can I solve this? because it can't create the database so I can't test
my app.
Can I change the order how django initiates the database? or say to django
to use my script?

-- 
Gràcies,

Rubén

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



Re: How to submit tests and docs while submitting patches

2012-02-08 Thread akaariai
On Feb 8, 1:06 pm, Karthik Abinav  wrote:
> Hi,
>
>  I would like to contribute to django. But I am not clear as to how to
> submit the tests and docs while submitting my patches. Or does every patch
> need a tests and docs. Help would be appreciated.

In general, new features need documentation and all patches need tests
if at all possible. There are some cases where writing a test is
exceptionally hard (for example, testing the test runner), and that
might be a good reason to skip the tests part.

Optimally you should include code, documentation and tests in a single
patch. You can find the tests from the tests subdirectory,
documentation from doc subdirectory. For first-time contributor
knowing where you should put your tests and what documentation to
write can be a challenge. It is OK to first submit just the code
portion of the patch. When posting the patch into trac, just say that
you are unsure of what tests/documentation is needed. Reviewers will
usually help you out from there.

 - Anssi

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



How to submit tests and docs while submitting patches

2012-02-08 Thread Karthik Abinav
Hi,

 I would like to contribute to django. But I am not clear as to how to
submit the tests and docs while submitting my patches. Or does every patch
need a tests and docs. Help would be appreciated.

Thanks,
Karthik Abinav

-- 
You received this message because you are subscribed to the Google 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: same code runs on two machines and barfs on the third

2012-02-08 Thread akaariai


On Feb 8, 11:27 am, kenneth gonsalves  wrote:
> On Wed, 2012-02-08 at 00:15 -0800, akaariai wrote:
> > On Feb 8, 9:15 am, kenneth gonsalves  wrote:
> > > On Tue, 2012-02-07 at 19:29 +1100, Mike Dewhirst wrote:
> > > > On 7/02/2012 6:14pm, kenneth gonsalves wrote:
> > > > > On Tue, 2012-02-07 at 08:06 +0100, Babatunde Akinyanmi wrote:
> > > > >> Perhaps you made a change to a model and forgot to syncdb on
> > your
> > > > >> Fedora 15 machine.
>
> > > > When you have eliminated all the possibilities what remains must
> > be
> > > > the
> > > > problem :)
>
> > > > The trick is to confirm your assumptions one by one.
>
> > > code: all three machines are running code pulled from the same repo.
> > > django version: all three are on r 17461
> > > database: the table structure on all three is identical. (in fact
> > two
> > > machines have the same data also). Postgresql versions differ, but
> > this
> > > is a django error - not a database error.
> > > The offending line of code worked fine on the F15 machine when it
> > was
> > > running F14
>
> > Most likely, for some reason, the offending machine's definition is
> > missing the tournament field in the models.py file.
>
> field is there. instead of:
>
> cr = Team.objects.filter(tournament_id=tournid)
>
> I do:
> tourn = Tournament.objects.get(pk=tournid)
> cr = Team.objects.filter(tournament=tourn)
>
> it works on the offending machine.
>
>
>
> > Anyways double-check that the offending machine is really using the
> > same version of the project's code than the other machines.  Check
> > especially carefully the models.py file containing the Team model
> > definition. To see that you are really using the file you think you
> > are, put an assert(False) just before the Team model definition on
> > your offending machine. This should make the project totally non-
> > functional on that machine (easy way to see that yes, the change had
> > an effect => this file is really in use). Of course, if this is a
> > production machine, don't do the assert trich. Use logging instead.
>
> > If the model is double-checked correct, and the assert is raised, then
> > we have a more complex problem...
>
> model is correct. Database is correct - we have a more complex
> problem ;-)

Can you run
print Task._meta.get_fields_with_model()
print Task._meta.get_field_by_name('tournament')
print Task._meta.get_field_by_name('tournament').attname
on the offending server and provide the output?

 - Anssi

-- 
You received this message because you are subscribed to the Google 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: same code runs on two machines and barfs on the third

2012-02-08 Thread kenneth gonsalves
On Wed, 2012-02-08 at 00:15 -0800, akaariai wrote:
> On Feb 8, 9:15 am, kenneth gonsalves  wrote:
> > On Tue, 2012-02-07 at 19:29 +1100, Mike Dewhirst wrote:
> > > On 7/02/2012 6:14pm, kenneth gonsalves wrote:
> > > > On Tue, 2012-02-07 at 08:06 +0100, Babatunde Akinyanmi wrote:
> > > >> Perhaps you made a change to a model and forgot to syncdb on
> your
> > > >> Fedora 15 machine.
> >
> > > When you have eliminated all the possibilities what remains must
> be
> > > the
> > > problem :)
> >
> > > The trick is to confirm your assumptions one by one.
> >
> > code: all three machines are running code pulled from the same repo.
> > django version: all three are on r 17461
> > database: the table structure on all three is identical. (in fact
> two
> > machines have the same data also). Postgresql versions differ, but
> this
> > is a django error - not a database error.
> > The offending line of code worked fine on the F15 machine when it
> was
> > running F14
> 
> Most likely, for some reason, the offending machine's definition is
> missing the tournament field in the models.py file.

field is there. instead of:

cr = Team.objects.filter(tournament_id=tournid)

I do:
tourn = Tournament.objects.get(pk=tournid)
cr = Team.objects.filter(tournament=tourn)

it works on the offending machine.
> 
> Anyways double-check that the offending machine is really using the
> same version of the project's code than the other machines.  Check
> especially carefully the models.py file containing the Team model
> definition. To see that you are really using the file you think you
> are, put an assert(False) just before the Team model definition on
> your offending machine. This should make the project totally non-
> functional on that machine (easy way to see that yes, the change had
> an effect => this file is really in use). Of course, if this is a
> production machine, don't do the assert trich. Use logging instead.
> 
> If the model is double-checked correct, and the assert is raised, then
> we have a more complex problem... 

model is correct. Database is correct - we have a more complex
problem ;-)
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google 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: Finding It Hard To Make It Work!

2012-02-08 Thread coded kid
Thanks bro. Will do. But do you know about a specific Topic I should
learn?

On Feb 8, 10:18 am, Thomas Weholt  wrote:
> Google "ajax tutorial" or even better just google jquery and take it
> from there. There are several tutorials on how to integrate jquery and
> django as well.
>
> Thomas
>
>
>
>
>
>
>
>
>
> On Wed, Feb 8, 2012 at 10:11 AM, coded kid  wrote:
> > How bro? Don't know Ajax. Can you please put me through? I'm a
> > Nigerian bro!
>
> > On Feb 8, 10:02 am, Babatunde Akinyanmi  wrote:
> >> Use AJAX or asynchronous programming
>
> >> On 2/8/12, coded kid  wrote:
>
> >> > Hello, I want to make the below codes let users update their status in
> >> > the Django . And their update should display on the same template. But
> >> > it’s not working.  E.g when a user type in “To be a hacker is not a
> >> > day’s job” in the status textarea and click on update button below the
> >> > form. The update should display on the same template for his or her
> >> > friends to see. Just like how we post status update on fb.
>
> >> > In models.py
> >> > from django.contrib.auth.models import User
> >> > from django.forms import ModelForm, Textarea, HiddenInput
> >> > from django.db import models
>
> >> >     class mob (models.Model):
> >> >     username=models.ForeignKey(User, unique=True)
> >> >     state_province=models.CharField(max_length=50)
> >> >     body=models.TextField(max_length=1)
> >> >     date=models.DateTimeField()
>
> >> >     def __unicode__(self):
> >> >         return u"%s - %s - %s - %s" % (self.username,
> >> > self.state_province, self.body,   self.date)
>
> >> >     def get_absolute_url(self):
> >> >         return "/post/%s/" % unicode(self.id)
> >> >     def get_author_url(self):
> >> >         return "/u/%s/p/0" % (self.username)
>
> >> >     class mobForm(ModelForm):
> >> >     class Meta:
> >> >         model=mob
> >> >         fields=('body','username','state_province','date')
> >> >         widgets={
> >> >             'body':Textarea(attrs={"rows":2, "cols":40}),
> >> >             'username': (HiddenInput),
> >> >             'state_province': (HiddenInput),
> >> >             'date':(HiddenInput),
> >> >         }
>
> >> > In views.py
> >> > from myweb.meekapp.models import mobForm, mob
> >> > from django.shortcuts import render_to_response
> >> > from django.contrib.auth.models import User
> >> > from django.http import HttpResponse, Http404
> >> > from django.template import RequestContext
> >> > from django.http import HttpResponseRedirect
>
> >> >     def homey(request):
> >> >  #if there’s nothing in the field do nothing.
> >> >     if request. method != "":
> >> >         return HttpResponseRedirect('/homi/')
>
> >> >     newmob=mob()
> >> >     newmob.username=request.user
> >> >     newmob.date=datetime.datetime.now()
> >> >     newmob.body=request.POST['body']
> >> >     if request.POST['body'] <> '':
> >> >         newmob.body=body.objects.get(id=request.POST['body'])
> >> >         newmob.save()
> >> >         return HttpResponseRedirect('/homi/')
> >> >     else:
> >> >         return render_to_response('meek_home.html', {'mobForm':
> >> > mobForm },context_instance=RequestContext(request))
>
> >> > in template
>
> >> >     {% extends "base_meek.html" %}
> >> >           {% block body %}
> >> >        
> >> >    
> >> >      
> >> >            {{ mobForm }}
> >> >      
> >> >      
> >> >    
> >> >        {% endblock %}
>
> >> > What am I doing wrong? Would love to hear your opinion.
>
> >> > --
> >> > You received this message because you are subscribed to the Google Groups
> >> > "Django users" group.
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > django-users+unsubscr...@googlegroups.com.
> >> > For more options, visit this group at
> >> >http://groups.google.com/group/django-users?hl=en.
>
> >> --
> >> Sent from my mobile device
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Mvh/Best regards,
> Thomas Weholthttp://www.weholt.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: Finding It Hard To Make It Work!

2012-02-08 Thread Thomas Weholt
Google "ajax tutorial" or even better just google jquery and take it
from there. There are several tutorials on how to integrate jquery and
django as well.

Thomas

On Wed, Feb 8, 2012 at 10:11 AM, coded kid  wrote:
> How bro? Don't know Ajax. Can you please put me through? I'm a
> Nigerian bro!
>
> On Feb 8, 10:02 am, Babatunde Akinyanmi  wrote:
>> Use AJAX or asynchronous programming
>>
>> On 2/8/12, coded kid  wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> > Hello, I want to make the below codes let users update their status in
>> > the Django . And their update should display on the same template. But
>> > it’s not working.  E.g when a user type in “To be a hacker is not a
>> > day’s job” in the status textarea and click on update button below the
>> > form. The update should display on the same template for his or her
>> > friends to see. Just like how we post status update on fb.
>>
>> > In models.py
>> > from django.contrib.auth.models import User
>> > from django.forms import ModelForm, Textarea, HiddenInput
>> > from django.db import models
>>
>> >     class mob (models.Model):
>> >     username=models.ForeignKey(User, unique=True)
>> >     state_province=models.CharField(max_length=50)
>> >     body=models.TextField(max_length=1)
>> >     date=models.DateTimeField()
>>
>> >     def __unicode__(self):
>> >         return u"%s - %s - %s - %s" % (self.username,
>> > self.state_province, self.body,   self.date)
>>
>> >     def get_absolute_url(self):
>> >         return "/post/%s/" % unicode(self.id)
>> >     def get_author_url(self):
>> >         return "/u/%s/p/0" % (self.username)
>>
>> >     class mobForm(ModelForm):
>> >     class Meta:
>> >         model=mob
>> >         fields=('body','username','state_province','date')
>> >         widgets={
>> >             'body':Textarea(attrs={"rows":2, "cols":40}),
>> >             'username': (HiddenInput),
>> >             'state_province': (HiddenInput),
>> >             'date':(HiddenInput),
>> >         }
>>
>> > In views.py
>> > from myweb.meekapp.models import mobForm, mob
>> > from django.shortcuts import render_to_response
>> > from django.contrib.auth.models import User
>> > from django.http import HttpResponse, Http404
>> > from django.template import RequestContext
>> > from django.http import HttpResponseRedirect
>>
>> >     def homey(request):
>> >  #if there’s nothing in the field do nothing.
>> >     if request. method != "":
>> >         return HttpResponseRedirect('/homi/')
>>
>> >     newmob=mob()
>> >     newmob.username=request.user
>> >     newmob.date=datetime.datetime.now()
>> >     newmob.body=request.POST['body']
>> >     if request.POST['body'] <> '':
>> >         newmob.body=body.objects.get(id=request.POST['body'])
>> >         newmob.save()
>> >         return HttpResponseRedirect('/homi/')
>> >     else:
>> >         return render_to_response('meek_home.html', {'mobForm':
>> > mobForm },context_instance=RequestContext(request))
>>
>> > in template
>>
>> >     {% extends "base_meek.html" %}
>> >           {% block body %}
>> >        
>> >    
>> >      
>> >            {{ mobForm }}
>> >      
>> >      
>> >    
>> >        {% endblock %}
>>
>> > What am I doing wrong? Would love to hear your opinion.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> >http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> Sent from my mobile device
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.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: Finding It Hard To Make It Work!

2012-02-08 Thread coded kid
How bro? Don't know Ajax. Can you please put me through? I'm a
Nigerian bro!

On Feb 8, 10:02 am, Babatunde Akinyanmi  wrote:
> Use AJAX or asynchronous programming
>
> On 2/8/12, coded kid  wrote:
>
>
>
>
>
>
>
>
>
> > Hello, I want to make the below codes let users update their status in
> > the Django . And their update should display on the same template. But
> > it’s not working.  E.g when a user type in “To be a hacker is not a
> > day’s job” in the status textarea and click on update button below the
> > form. The update should display on the same template for his or her
> > friends to see. Just like how we post status update on fb.
>
> > In models.py
> > from django.contrib.auth.models import User
> > from django.forms import ModelForm, Textarea, HiddenInput
> > from django.db import models
>
> >     class mob (models.Model):
> >     username=models.ForeignKey(User, unique=True)
> >     state_province=models.CharField(max_length=50)
> >     body=models.TextField(max_length=1)
> >     date=models.DateTimeField()
>
> >     def __unicode__(self):
> >         return u"%s - %s - %s - %s" % (self.username,
> > self.state_province, self.body,   self.date)
>
> >     def get_absolute_url(self):
> >         return "/post/%s/" % unicode(self.id)
> >     def get_author_url(self):
> >         return "/u/%s/p/0" % (self.username)
>
> >     class mobForm(ModelForm):
> >     class Meta:
> >         model=mob
> >         fields=('body','username','state_province','date')
> >         widgets={
> >             'body':Textarea(attrs={"rows":2, "cols":40}),
> >             'username': (HiddenInput),
> >             'state_province': (HiddenInput),
> >             'date':(HiddenInput),
> >         }
>
> > In views.py
> > from myweb.meekapp.models import mobForm, mob
> > from django.shortcuts import render_to_response
> > from django.contrib.auth.models import User
> > from django.http import HttpResponse, Http404
> > from django.template import RequestContext
> > from django.http import HttpResponseRedirect
>
> >     def homey(request):
> >  #if there’s nothing in the field do nothing.
> >     if request. method != "":
> >         return HttpResponseRedirect('/homi/')
>
> >     newmob=mob()
> >     newmob.username=request.user
> >     newmob.date=datetime.datetime.now()
> >     newmob.body=request.POST['body']
> >     if request.POST['body'] <> '':
> >         newmob.body=body.objects.get(id=request.POST['body'])
> >         newmob.save()
> >         return HttpResponseRedirect('/homi/')
> >     else:
> >         return render_to_response('meek_home.html', {'mobForm':
> > mobForm },context_instance=RequestContext(request))
>
> > in template
>
> >     {% extends "base_meek.html" %}
> >           {% block body %}
> >        
> >    
> >      
> >            {{ mobForm }}
> >      
> >      
> >    
> >        {% endblock %}
>
> > What am I doing wrong? Would love to hear your opinion.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Sent from my mobile device

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



Re: Finding It Hard To Make It Work!

2012-02-08 Thread Babatunde Akinyanmi
Use AJAX or asynchronous programming

On 2/8/12, coded kid  wrote:
> Hello, I want to make the below codes let users update their status in
> the Django . And their update should display on the same template. But
> it’s not working.  E.g when a user type in “To be a hacker is not a
> day’s job” in the status textarea and click on update button below the
> form. The update should display on the same template for his or her
> friends to see. Just like how we post status update on fb.
>
> In models.py
> from django.contrib.auth.models import User
> from django.forms import ModelForm, Textarea, HiddenInput
> from django.db import models
>
>
>
> class mob (models.Model):
> username=models.ForeignKey(User, unique=True)
> state_province=models.CharField(max_length=50)
> body=models.TextField(max_length=1)
> date=models.DateTimeField()
>
> def __unicode__(self):
> return u"%s - %s - %s - %s" % (self.username,
> self.state_province, self.body,   self.date)
>
> def get_absolute_url(self):
> return "/post/%s/" % unicode(self.id)
> def get_author_url(self):
> return "/u/%s/p/0" % (self.username)
>
> class mobForm(ModelForm):
> class Meta:
> model=mob
> fields=('body','username','state_province','date')
> widgets={
> 'body':Textarea(attrs={"rows":2, "cols":40}),
> 'username': (HiddenInput),
> 'state_province': (HiddenInput),
> 'date':(HiddenInput),
> }
>
>
> In views.py
> from myweb.meekapp.models import mobForm, mob
> from django.shortcuts import render_to_response
> from django.contrib.auth.models import User
> from django.http import HttpResponse, Http404
> from django.template import RequestContext
> from django.http import HttpResponseRedirect
>
> def homey(request):
>  #if there’s nothing in the field do nothing.
> if request. method != "":
> return HttpResponseRedirect('/homi/')
>
> newmob=mob()
> newmob.username=request.user
> newmob.date=datetime.datetime.now()
> newmob.body=request.POST['body']
> if request.POST['body'] <> '':
> newmob.body=body.objects.get(id=request.POST['body'])
> newmob.save()
> return HttpResponseRedirect('/homi/')
> else:
> return render_to_response('meek_home.html', {'mobForm':
> mobForm },context_instance=RequestContext(request))
>
>
>
>
> in template
>
> {% extends "base_meek.html" %}
>   {% block body %}
>
>   
> 
>   {{ mobForm }}
> 
> 
>   
>{% endblock %}
>
>
>
> What am I doing wrong? Would love to hear your opinion.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



Re: same code runs on two machines and barfs on the third

2012-02-08 Thread akaariai
On Feb 8, 9:15 am, kenneth gonsalves  wrote:
> On Tue, 2012-02-07 at 19:29 +1100, Mike Dewhirst wrote:
> > On 7/02/2012 6:14pm, kenneth gonsalves wrote:
> > > On Tue, 2012-02-07 at 08:06 +0100, Babatunde Akinyanmi wrote:
> > >> Perhaps you made a change to a model and forgot to syncdb on your
> > >> Fedora 15 machine.
>
> > When you have eliminated all the possibilities what remains must be
> > the
> > problem :)
>
> > The trick is to confirm your assumptions one by one.
>
> code: all three machines are running code pulled from the same repo.
> django version: all three are on r 17461
> database: the table structure on all three is identical. (in fact two
> machines have the same data also). Postgresql versions differ, but this
> is a django error - not a database error.
> The offending line of code worked fine on the F15 machine when it was
> running F14

Most likely, for some reason, the offending machine's definition is
missing the tournament field in the models.py file.

Anyways double-check that the offending machine is really using the
same version of the project's code than the other machines.  Check
especially carefully the models.py file containing the Team model
definition. To see that you are really using the file you think you
are, put an assert(False) just before the Team model definition on
your offending machine. This should make the project totally non-
functional on that machine (easy way to see that yes, the change had
an effect => this file is really in use). Of course, if this is a
production machine, don't do the assert trich. Use logging instead.

If the model is double-checked correct, and the assert is raised, then
we have a more complex problem...

 - Anssi

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