Re: Django URL pattern - template tags

2011-09-02 Thread Piotr S
All correct :)

On Sat, Sep 3, 2011 at 3:28 AM, Tomas Neme  wrote:

> I'll still answer this just in case. You should have the following in
> your urls.py:
>
> urlpatterns += (..,
> url(r'(P)\w+/(P)\d+/(P)\[w-]+/', your_view,
> name='yoururlname'), )
>
> and then you can have in your template
>
> {{
> n.title }}
>
>
> I hope I didn't make any mistakes.
>
> tomas
>
>
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Can I write tests for 3rd party url shortener?

2011-09-02 Thread Andy McKay

On 2011-09-02, at 4:58 AM, Yaşar Arabacı wrote:
> 
> Is there a way to test whether or not a 3rd party url shortener works. What I 
> have in mind is this:

Sure, python has libraries like urllib for dong that sort of thing.

http://docs.python.org/library/urllib.html

--
  Andy McKay
  a...@clearwind.ca
  twitter: @andymckay
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Too many TCP connections

2011-09-02 Thread Tomas Neme
shot in the dark: aren't they connections to the database, maybe?

On Sat, Sep 3, 2011 at 12:56 AM, shacker  wrote:
> Hmm, appreciate the feedback, but we don't have KeepAlives enabled on our
> Django servers and it's never been a problem. And remember, the other Django
> site on the same server doesn't have the problem. As for serving lots of
> resources - we're just talking about viewing/saving seven User pages in the
> Admin before we've built up over 600 open TCP connections. This is a small
> and very lightly trafficked site - just a little bit of Admin activity
> triggers this (it's not an end user problem either - I can reproduce it
> easily).
> Thanks.
>
> --
> 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/-/CDUJ8AzY-awJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: configuration field

2011-09-02 Thread Andy McKay
On 2011-09-02, at 5:22 PM, Mo Mughrabi wrote:
> The problem with my approach that the xml is not validated and the reading 
> operation can be exhausting to parse the xml every time.

Why are you parsing through the XML every time? That seems awfully inefficient. 
There are xml parsers that don't involve parsing the entire tree, as far as I 
remember: http://docs.python.org/library/markup.html

But I would take the XML and store the bits you need in a more efficient format.
--
  Andy McKay
  a...@clearwind.ca
  twitter: @andymckay
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 URL pattern - template tags

2011-09-02 Thread Tomas Neme
I'll still answer this just in case. You should have the following in
your urls.py:

urlpatterns += (..,
url(r'(P)\w+/(P)\d+/(P)\[w-]+/', your_view,
name='yoururlname'), )

and then you can have in your template

{{
n.title }}


I hope I didn't make any mistakes.

tomas


-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



Re: Problem with file upload!

2011-09-02 Thread Mo Mughrabi
is there any error messages you seeing? or logged? does the file exists on
the filesystem?

On Fri, Sep 2, 2011 at 8:39 PM, Ludvig  wrote:

> Hello,
>
> Usually only read these posts so i hope i'm doing this right!
>
> Recently my file upload just stopped working, and i've no idea what
> i've changed. I noticed that request.FILES is empty so i've googled
> some and cant figured out my problem.
>
> My form looks like this
>
>
>
>
>
> and my code like this,
>
>
> class PhotoUploadView(FormView):
>template_name ="album/photo_upload.html"
>form_class = PhotoUploadForm
>def get_context_data(self,**kwargs):
>context =
> super(PhotoUploadView,self).get_context_data(**kwargs)
>context['user_info'] = self.request.user
>if 'upload_form' in kwargs:
>context['upload_form'] = kwargs['upload_form']
>else:
>context['upload_form'] = PhotoUploadForm()
>album = get_object_or_404(Album,id=self.kwargs['album_id'])
>context['album'] = album
>return context
>
>def form_valid(self,form):
>print 'kek'
>def post(self,*args,**kwargs):
>print self.request.FILES
>print self.request.raw_post_data
>if self.request.method == "POST":
>form =
> PhotoUploadForm(self.request.POST,self.request.FILES)
>if form.is_valid():
>photo = Photo()
>photo.title = form.cleaned_data['title']
>photo.summary = form.cleaned_data['description']
>photo.album = get_object_or_404(Album,id =
> kwargs['album_id'])
>photo.is_cover_photo = True
>path =
>
> self.generate_filename(self.request.FILES['photo'].name,self.request.user,kwargs['album_id'])
>destination = open(path,"wb+")
>for chunk in self.request.FILES['photo'].chunks():
>destination.write(chunk)
>destination.close()
>photo.imagePath = path
>photo.save()
>return
> self.render_to_response(self.get_context_data(upload_form=form))
>
>def generate_filename(self,filename,user,album_id):
>filename = os.path.splitext(filename)[1]
>return settings.MEDIA_ROOT + "/profiles/" + user.username +
> "/" + "albums/" + album_id + "/" + str(hashlib.md5(str(time.time() +
> user.id)).hexdigest()) + filename
>
>
> Also,  i'm a inexperienced programmer. Still only a hobby so be kind
> to me,
>
> thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Multiple Database Routing Based on Site

2011-09-02 Thread Mo Mughrabi
What I did is create an attribute in my models and called it

model.py
class Data(models.Model):
   # connection_name is my database name which points to the name from
settings.py
connection_name = "gis"

name = models.CharField(max_length=50)
area = models.IntegerField()

and created a router.py
class DbRouter(object):

"""A router to control all database operations on models in
the contrib.auth application"""

def db_for_read(self, model, **hints):
if hasattr(model,'connection_name'):
return model.connection_name
return None

def db_for_write(self, model, **hints):
if hasattr(model,'connection_name'):
return model.connection_name
return None

def allow_syncdb(self, db, model):
if hasattr(model,'connection_name'):
return model.connection_name == db
return db == 'default'


so, everytime for read or write operation it will check the model for
attribute connection_name and if not found it will use the default.

hope this will help,
cheers,

On Fri, Sep 2, 2011 at 1:23 PM, Kevin  wrote:

> The only solution I can directly think of, since the SITE_ID is in
> settings.py would be to use some python logic to determine the
> database for that site.
>
> eg.
> if SITE_ID == 1:
>   ...  Database settings for site 1 here ...
>
> Use an if-then like this in your settings.py.
>
> Now if what your going after is storing the SITE_ID in a user's
> profile and using that for routing, this will be more complex, as you
> will need to code a new databasebackend to perform the routing, and
> perhaps some middleware and an authbackend.
>
> Mind you, I haven't done much work on multiple databases, so these are
> just ideas on how I think it might be done.
>
> On Sep 1, 9:54 pm, Terribyte  wrote:
> > I had a kind of crazy idea and I wanted to bounce it off of some
> > people with a lot more django experience than I.
> >
> > Here's my scenario...
> >
> > I would like 1 code base, this code base services potentially hundreds
> > of businesses, each of which I want to have a copy of the same schema
> > but with data only relevant to that business.
> >
> > Basically my idea is the following
> > If the model is a Site object or User object, route to the default
> > database, otherwise route reads and writes to a database name I'll set
> > in the sites table.
> >
> > The trick is I need to set the SITE_ID for the current request, and
> > I'm not sure exactly When that should happen (after login of course),
> > or if this idea is even workable.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



configuration field

2011-09-02 Thread Mo Mughrabi
Hi I have a table which every has TextField to store plain text. Am using
this field for configuration and putting there some XML to read later on.

The problem with my approach that the xml is not validated and the reading
operation can be exhausting to parse the xml every time. And since XMLField
types are obsolete. Is there an alternative? even as a third party? if
anyone can recommend anything, I would appreciate it.


regards,

mo

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Too many TCP connections

2011-09-02 Thread shacker
Hmm, appreciate the feedback, but we don't have KeepAlives enabled on our 
Django servers and it's never been a problem. And remember, the other Django 
site on the same server doesn't have the problem. As for serving lots of 
resources - we're just talking about viewing/saving seven User pages in the 
Admin before we've built up over 600 open TCP connections. This is a small 
and very lightly trafficked site - just a little bit of Admin activity 
triggers this (it's not an end user problem either - I can reproduce it 
easily).

Thanks.

-- 
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/-/CDUJ8AzY-awJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Too many TCP connections

2011-09-02 Thread Cal Leeming [Simplicity Media Ltd]
Only briefly read this email, but it could be due to keep alives not being
enabled, along with lots of resources (images, css, js) etc being called.

Let me know if this helps

Cal

On Fri, Sep 2, 2011 at 8:16 PM, shacker  wrote:
> This is not a database connection question, but a TCP connection problem.
> I've got two different Django sites on the same server (which I admin),
each
> with their own similar vhosts and wsgi processes. The server uses
> ConfigServer firewall  for automatic detection and firewalling of bad
> behavior.
> On one of the sites,  a small amount of clicking around in the admin will
> cause that user's IP to be blocked with a message like:
> DENY 128.33.33.123 * inout 29m 18s lfd - (CT) IP 128.33.33.123 (US/United
> States/[hostname]) found to have 670 connections
>
> (IP / hostname changed). Those 670 open connections can be created by
simply
> going to Users in the admin and clicking and saving seven User records in
> sequence. That's it - firewalled. On the other Django site on the same
> server, you can do that all day long with no problem.
>
> I can sidestep the problem by changing the CT_LIMIT value in ConfigServer
> Firewall to a very high value or disabling it, but then I lose the DDOS
> protection it provides. Rather than work around it, I'd like to figure out
> what in the world is causing this one site to generate so many TCP
> connections during normal usage. But not sure where to begin.
>
> Suggestions? Thanks.
>
> --
> 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/-/4U0mn30f9tgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



Odp: Django URL pattern - template tags

2011-09-02 Thread Petey
Problem solved.
I was too tired to find my mistake earlier ;)

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



Too many TCP connections

2011-09-02 Thread shacker
This is not a database connection question, but a TCP connection problem.

I've got two different Django sites on the same server (which I admin), each 
with their own similar vhosts and wsgi processes. The server uses 
ConfigServer firewall  for automatic detection and firewalling of bad 
behavior. 

On one of the sites,  a small amount of clicking around in the admin will 
cause that user's IP to be blocked with a message like:

DENY 128.33.33.123 * inout 29m 18s lfd - (CT) IP 128.33.33.123 (US/United 
States/[hostname]) found to have 670 connections

(IP / hostname changed). Those 670 open connections can be created by simply 
going to Users in the admin and clicking and saving seven User records in 
sequence. That's it - firewalled. On the other Django site on the same 
server, you can do that all day long with no problem.

I can sidestep the problem by changing the CT_LIMIT value in ConfigServer 
Firewall to a very high value or disabling it, but then I lose the DDOS 
protection it provides. Rather than work around it, I'd like to figure out 
what in the world is causing this one site to generate so many TCP 
connections during normal usage. But not sure where to begin.

Suggestions? Thanks.

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



Re: problem with syncdb and MyQSL

2011-09-02 Thread John Boudreau
This is what I finally got:

C:\Python27>python c:\python27\mysite2\manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Traceback (most recent call last):
  File "c:\python27\mysite2\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\base.py", line
191,
 in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line
220,
 in execute
output = self.handle(*args, **options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line
351,
 in handle
return self.handle_noargs(**options)
  File
"C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py"
, line 101, in handle_noargs
cursor.execute(statement)
  File "C:\Python27\lib\site-packages\django\db\backends\util.py", line 34,
in e
xecute
return self.cursor.execute(sql, params)
  File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py",
line 86
, in execute
return self.cursor.execute(query, args)
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174, in
execute
self.errorhandler(self, exc, value)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in
defau
lterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (2013, 'Lost connection to MySQL server
duri
ng query')

On Fri, Sep 2, 2011 at 1:43 PM, John Boudreau wrote:

> Ok. I created a new database entirely and un-commented the APPS.
>
> I then ran the following command:
>
> C:\Python27>python c:\python27\mysite2\manage.py syncdb
>
> I hit enter about 5 mins ago and it's still at:
>
> Creating tables
> Creating table auth_permission
> Creating table auth_group_permissions
> Creating table auto_group
>
> On Fri, Sep 2, 2011 at 1:08 PM,  wrote:
>
>> The only thing that pops in my mind right about now is to delete the
>> currently created table and then proceed to re-run syncdb (leave the other
>> apps uncommented.)
>>
>>
>> On Sep 2, 2011, at 1:01 PM, John Boudreau 
>> wrote:
>>
>> Great. Yes, when I first experienced the issue (prior to creating the
>> polls app, with those APPS un-commented), I logged into the database and
>> found the following tables had been created:
>>
>>  Table Rows Type Size Comments auth_group_permissions 0 Xeround 0 B
>> auth_permission 0 Xeround 0 B 2 tables 0 -- 0 B
>>
>>
>> So it looks like it began creating the tables for the auth app and
>> stopped
>>
>> On Fri, Sep 2, 2011 at 12:56 PM, Yves S. Garret <
>> yoursurrogate...@gmail.com> wrote:
>>
>>> I'm curious, maybe someone knows this who has actually seen the code
>>> behind the scenes, but is this actually true?  When Django says "Creating
>>> tables ...   Creating table polls_poll", does that mean it's
>>> already connected to the database and working on it or is it a message
>>> that's produced before actually connecting?
>>>
>>> John, do you have a way of finding out for sure if your mysql database is
>>> being connected to and a database is being created by django?  Did you
>>> actually look in the database and verify that this is the case?
>>>
>>> On Fri, Sep 2, 2011 at 12:46 PM, John Boudreau <
>>> johnhboudr...@gmail.com> wrote:
>>>
 Yes I have. When I run the syncdb command it starts creating the tables
 then hangs

 So it is connecting to the MySql DB I created...


 On Fri, Sep 2, 2011 at 12:43 PM, chandrakant kumar <
 k.03chan...@gmail.com> wrote:

> On 9/2/11, John < johnhboudr...@gmail.com>
> wrote:
> > I am a total noob so forgive my ignorance, but I have been going
> > through the Django tutorial -
> > 
> https://docs.djangoproject.com/en/1.3/intro/tutorial01/
> >
> > I am at the point in the tutorial where I run the following command:
> >
> > C:\Python27>python c:\python27\mysite2\manage.py syncdb
> > Creating tables ...
> > Creating table polls_poll
> > Traceback (most recent call last):
> >   File "c:\python27\mysite2\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\base.py",
> > line 191,

Problem with file upload!

2011-09-02 Thread Ludvig
Hello,

Usually only read these posts so i hope i'm doing this right!

Recently my file upload just stopped working, and i've no idea what
i've changed. I noticed that request.FILES is empty so i've googled
some and cant figured out my problem.

My form looks like this




http://groups.google.com/group/django-users?hl=en.



Re: problem with syncdb and MyQSL

2011-09-02 Thread John Boudreau
Ok. I created a new database entirely and un-commented the APPS.

I then ran the following command:

C:\Python27>python c:\python27\mysite2\manage.py syncdb

I hit enter about 5 mins ago and it's still at:

Creating tables
Creating table auth_permission
Creating table auth_group_permissions
Creating table auto_group

On Fri, Sep 2, 2011 at 1:08 PM,  wrote:

> The only thing that pops in my mind right about now is to delete the
> currently created table and then proceed to re-run syncdb (leave the other
> apps uncommented.)
>
>
> On Sep 2, 2011, at 1:01 PM, John Boudreau  wrote:
>
> Great. Yes, when I first experienced the issue (prior to creating the polls
> app, with those APPS un-commented), I logged into the database and found the
> following tables had been created:
>
>  Table Rows Type Size Comments auth_group_permissions 0 Xeround 0 B
> auth_permission 0 Xeround 0 B 2 tables 0 -- 0 B
>
>
> So it looks like it began creating the tables for the auth app and
> stopped
>
> On Fri, Sep 2, 2011 at 12:56 PM, Yves S. Garret <
> yoursurrogate...@gmail.com> wrote:
>
>> I'm curious, maybe someone knows this who has actually seen the code
>> behind the scenes, but is this actually true?  When Django says "Creating
>> tables ...   Creating table polls_poll", does that mean it's
>> already connected to the database and working on it or is it a message
>> that's produced before actually connecting?
>>
>> John, do you have a way of finding out for sure if your mysql database is
>> being connected to and a database is being created by django?  Did you
>> actually look in the database and verify that this is the case?
>>
>> On Fri, Sep 2, 2011 at 12:46 PM, John Boudreau <
>> johnhboudr...@gmail.com> wrote:
>>
>>> Yes I have. When I run the syncdb command it starts creating the tables
>>> then hangs
>>>
>>> So it is connecting to the MySql DB I created...
>>>
>>>
>>> On Fri, Sep 2, 2011 at 12:43 PM, chandrakant kumar <
>>> k.03chan...@gmail.com> wrote:
>>>
 On 9/2/11, John < johnhboudr...@gmail.com>
 wrote:
 > I am a total noob so forgive my ignorance, but I have been going
 > through the Django tutorial -
 > 
 https://docs.djangoproject.com/en/1.3/intro/tutorial01/
 >
 > I am at the point in the tutorial where I run the following command:
 >
 > C:\Python27>python c:\python27\mysite2\manage.py syncdb
 > Creating tables ...
 > Creating table polls_poll
 > Traceback (most recent call last):
 >   File "c:\python27\mysite2\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\base.py",
 > line 191,
 >  in run_from_argv
 > self.execute(*args, **options.__dict__)
 >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
 > line 220,
 >  in execute
 > output = self.handle(*args, **options)
 >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
 > line 351,
 >  in handle
 > return self.handle_noargs(**options)
 >   File "C:\Python27\lib\site-packages\django\core\management\commands
 > \syncdb.py"
 > , line 101, in handle_noargs
 > cursor.execute(statement)
 >   File "C:\Python27\lib\site-packages\django\db\backends\util.py",
 > line 34, in e
 > xecute
 > return self.cursor.execute(sql, params)
 >   File "C:\Python27\lib\site-packages\django\db\backends\mysql
 > \base.py", line 86
 > , in execute
 > return self.cursor.execute(query, args)
 >   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
 > in execute
 > self.errorhandler(self, exc, value)
 >   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
 > 36, in defau
 > lterrorhandler
 > raise errorclass, errorvalue
 > _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
 >
 > Can someone help?
 >
 > I really appreciate it.
 >
 > --
 > You received this message because you are subscribed to the Google
 Groups
 > "Django users" group.
 > To post to this group, send email to 
 django-users@googlegroups.com.
 > To unsubscribe from this group, send email to
 > 
 django-users+unsubscr...@googlegroups.com.
 > For more options, visit this group at
 > 
 http://groups.google.com/group/django-users?hl=en.
 >
 >

 Have you created the database in mysql? use mysqladmin to create
 databse that 

Django URL pattern - template tags

2011-09-02 Thread Petey
 Hey

I've made a view which should generate url in form like this 
(example.com/type/id/slug : example.com/news/1/lorem-ipsum/)

To generate links I use:
{{ n.title|safe}}
It isn't the correct form for that as far as I know.

Could someone explain me how to use {% url %} tag in this situation? I dont 
quite understand this and I can't manage it to work :)

http://pastebin.com/mVU0iFXt

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



Re: problem with syncdb and MyQSL

2011-09-02 Thread yoursurrogategod
The only thing that pops in my mind right about now is to delete the currently 
created table and then proceed to re-run syncdb (leave the other apps 
uncommented.)

On Sep 2, 2011, at 1:01 PM, John Boudreau  wrote:

> Great. Yes, when I first experienced the issue (prior to creating the polls 
> app, with those APPS un-commented), I logged into the database and found the 
> following tables had been created:
> 
> Table  RowsTypeSizeComments
> auth_group_permissions 0   Xeround 0 B
> auth_permission0   Xeround 0 B
> 2 tables   0   --  0 B
> 
> 
> So it looks like it began creating the tables for the auth app and stopped
> 
> On Fri, Sep 2, 2011 at 12:56 PM, Yves S. Garret  
> wrote:
> I'm curious, maybe someone knows this who has actually seen the code behind 
> the scenes, but is this actually true?  When Django says "Creating tables ... 
>   Creating table polls_poll", does that mean it's already connected 
> to the database and working on it or is it a message that's produced before 
> actually connecting?
> 
> John, do you have a way of finding out for sure if your mysql database is 
> being connected to and a database is being created by django?  Did you 
> actually look in the database and verify that this is the case?
> 
> On Fri, Sep 2, 2011 at 12:46 PM, John Boudreau  
> wrote:
> Yes I have. When I run the syncdb command it starts creating the tables then 
> hangs
> 
> So it is connecting to the MySql DB I created...
> 
> 
> On Fri, Sep 2, 2011 at 12:43 PM, chandrakant kumar  
> wrote:
> On 9/2/11, John  wrote:
> > I am a total noob so forgive my ignorance, but I have been going
> > through the Django tutorial -
> > https://docs.djangoproject.com/en/1.3/intro/tutorial01/
> >
> > I am at the point in the tutorial where I run the following command:
> >
> > C:\Python27>python c:\python27\mysite2\manage.py syncdb
> > Creating tables ...
> > Creating table polls_poll
> > Traceback (most recent call last):
> >   File "c:\python27\mysite2\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\base.py",
> > line 191,
> >  in run_from_argv
> > self.execute(*args, **options.__dict__)
> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> > line 220,
> >  in execute
> > output = self.handle(*args, **options)
> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> > line 351,
> >  in handle
> > return self.handle_noargs(**options)
> >   File "C:\Python27\lib\site-packages\django\core\management\commands
> > \syncdb.py"
> > , line 101, in handle_noargs
> > cursor.execute(statement)
> >   File "C:\Python27\lib\site-packages\django\db\backends\util.py",
> > line 34, in e
> > xecute
> > return self.cursor.execute(sql, params)
> >   File "C:\Python27\lib\site-packages\django\db\backends\mysql
> > \base.py", line 86
> > , in execute
> > return self.cursor.execute(query, args)
> >   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
> > in execute
> > self.errorhandler(self, exc, value)
> >   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
> > 36, in defau
> > lterrorhandler
> > raise errorclass, errorvalue
> > _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
> >
> > Can someone help?
> >
> > I really appreciate it.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
> 
> Have you created the database in mysql? use mysqladmin to create
> databse that you entered in settings.py
> --
> 
> Chandrakant Kumar
> irc - k03chandra @ #freenode
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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

Re: problem with syncdb and MyQSL

2011-09-02 Thread John Boudreau
Great. Yes, when I first experienced the issue (prior to creating the polls
app, with those APPS un-commented), I logged into the database and found the
following tables had been created:

TableRowsTypeSizeCommentsauth_group_permissions0Xeround0 Bauth_permission0
Xeround0 B2 tables0--0 B


So it looks like it began creating the tables for the auth app and
stopped

On Fri, Sep 2, 2011 at 12:56 PM, Yves S. Garret
wrote:

> I'm curious, maybe someone knows this who has actually seen the code behind
> the scenes, but is this actually true?  When Django says "Creating tables
> ...   Creating table polls_poll", does that mean it's already
> connected to the database and working on it or is it a message that's
> produced before actually connecting?
>
> John, do you have a way of finding out for sure if your mysql database is
> being connected to and a database is being created by django?  Did you
> actually look in the database and verify that this is the case?
>
> On Fri, Sep 2, 2011 at 12:46 PM, John Boudreau wrote:
>
>> Yes I have. When I run the syncdb command it starts creating the tables
>> then hangs
>>
>> So it is connecting to the MySql DB I created...
>>
>>
>> On Fri, Sep 2, 2011 at 12:43 PM, chandrakant kumar > > wrote:
>>
>>> On 9/2/11, John  wrote:
>>> > I am a total noob so forgive my ignorance, but I have been going
>>> > through the Django tutorial -
>>> > https://docs.djangoproject.com/en/1.3/intro/tutorial01/
>>> >
>>> > I am at the point in the tutorial where I run the following command:
>>> >
>>> > C:\Python27>python c:\python27\mysite2\manage.py syncdb
>>> > Creating tables ...
>>> > Creating table polls_poll
>>> > Traceback (most recent call last):
>>> >   File "c:\python27\mysite2\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\base.py",
>>> > line 191,
>>> >  in run_from_argv
>>> > self.execute(*args, **options.__dict__)
>>> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
>>> > line 220,
>>> >  in execute
>>> > output = self.handle(*args, **options)
>>> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
>>> > line 351,
>>> >  in handle
>>> > return self.handle_noargs(**options)
>>> >   File "C:\Python27\lib\site-packages\django\core\management\commands
>>> > \syncdb.py"
>>> > , line 101, in handle_noargs
>>> > cursor.execute(statement)
>>> >   File "C:\Python27\lib\site-packages\django\db\backends\util.py",
>>> > line 34, in e
>>> > xecute
>>> > return self.cursor.execute(sql, params)
>>> >   File "C:\Python27\lib\site-packages\django\db\backends\mysql
>>> > \base.py", line 86
>>> > , in execute
>>> > return self.cursor.execute(query, args)
>>> >   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
>>> > in execute
>>> > self.errorhandler(self, exc, value)
>>> >   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
>>> > 36, in defau
>>> > lterrorhandler
>>> > raise errorclass, errorvalue
>>> > _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
>>> >
>>> > Can someone help?
>>> >
>>> > I really appreciate it.
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Django users" group.
>>> > To post to this group, send email to django-users@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > django-users+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/django-users?hl=en.
>>> >
>>> >
>>>
>>> Have you created the database in mysql? use mysqladmin to create
>>> databse that you entered in settings.py
>>> --
>>>
>>> Chandrakant Kumar
>>> irc - k03chandra @ #freenode
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> T

Re: problem with syncdb and MyQSL

2011-09-02 Thread Yves S. Garret
I'm curious, maybe someone knows this who has actually seen the code behind
the scenes, but is this actually true?  When Django says "Creating tables
...   Creating table polls_poll", does that mean it's already
connected to the database and working on it or is it a message that's
produced before actually connecting?

John, do you have a way of finding out for sure if your mysql database is
being connected to and a database is being created by django?  Did you
actually look in the database and verify that this is the case?

On Fri, Sep 2, 2011 at 12:46 PM, John Boudreau wrote:

> Yes I have. When I run the syncdb command it starts creating the tables
> then hangs
>
> So it is connecting to the MySql DB I created...
>
>
> On Fri, Sep 2, 2011 at 12:43 PM, chandrakant kumar 
> wrote:
>
>> On 9/2/11, John  wrote:
>> > I am a total noob so forgive my ignorance, but I have been going
>> > through the Django tutorial -
>> > https://docs.djangoproject.com/en/1.3/intro/tutorial01/
>> >
>> > I am at the point in the tutorial where I run the following command:
>> >
>> > C:\Python27>python c:\python27\mysite2\manage.py syncdb
>> > Creating tables ...
>> > Creating table polls_poll
>> > Traceback (most recent call last):
>> >   File "c:\python27\mysite2\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\base.py",
>> > line 191,
>> >  in run_from_argv
>> > self.execute(*args, **options.__dict__)
>> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
>> > line 220,
>> >  in execute
>> > output = self.handle(*args, **options)
>> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
>> > line 351,
>> >  in handle
>> > return self.handle_noargs(**options)
>> >   File "C:\Python27\lib\site-packages\django\core\management\commands
>> > \syncdb.py"
>> > , line 101, in handle_noargs
>> > cursor.execute(statement)
>> >   File "C:\Python27\lib\site-packages\django\db\backends\util.py",
>> > line 34, in e
>> > xecute
>> > return self.cursor.execute(sql, params)
>> >   File "C:\Python27\lib\site-packages\django\db\backends\mysql
>> > \base.py", line 86
>> > , in execute
>> > return self.cursor.execute(query, args)
>> >   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
>> > in execute
>> > self.errorhandler(self, exc, value)
>> >   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
>> > 36, in defau
>> > lterrorhandler
>> > raise errorclass, errorvalue
>> > _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
>> >
>> > Can someone help?
>> >
>> > I really appreciate it.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>> Have you created the database in mysql? use mysqladmin to create
>> databse that you entered in settings.py
>> --
>>
>> Chandrakant Kumar
>> irc - k03chandra @ #freenode
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: problem with syncdb and MyQSL

2011-09-02 Thread John Boudreau
I had the same problem with those un-commented, so I create an app polls
(per the tutorial) and commented those out to see if it made a difference
and it didn't.

In the tutorial is says,

"For the minimalists

Like we said above, the default applications are included for the common
case, but not everybody needs them. If you don't need any or all of them,
feel free to comment-out or delete the appropriate line(s) from
INSTALLED_APPSbefore
running 
syncdb.
The 
syncdb
command
will only create tables for apps in
INSTALLED_APPS
."



On Fri, Sep 2, 2011 at 12:48 PM, Yves S. Garret
wrote:

> I'm looking at this portion:
>
> +++
> INSTALLED_APPS = (
>#'django.contrib.auth',
>#'django.contrib.contenttypes',
>#'django.contrib.sessions',
>#'django.contrib.sites',
>#'django.contrib.messages',
>#'django.contrib.staticfiles',
>'polls'
># Uncomment the next line to enable the admin:
># 'django.contrib.admin',
># Uncomment the next line to enable admin documentation:
># 'django.contrib.admindocs',
> )
> +++
>
> Why did you comment those apps out?  Everything above 'polls' should not be
> commented out.
>
> On Fri, Sep 2, 2011 at 12:43 PM, chandrakant kumar 
> wrote:
>
>> On 9/2/11, John  wrote:
>> > I am a total noob so forgive my ignorance, but I have been going
>> > through the Django tutorial -
>> > https://docs.djangoproject.com/en/1.3/intro/tutorial01/
>> >
>> > I am at the point in the tutorial where I run the following command:
>> >
>> > C:\Python27>python c:\python27\mysite2\manage.py syncdb
>> > Creating tables ...
>> > Creating table polls_poll
>> > Traceback (most recent call last):
>> >   File "c:\python27\mysite2\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\base.py",
>> > line 191,
>> >  in run_from_argv
>> > self.execute(*args, **options.__dict__)
>> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
>> > line 220,
>> >  in execute
>> > output = self.handle(*args, **options)
>> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
>> > line 351,
>> >  in handle
>> > return self.handle_noargs(**options)
>> >   File "C:\Python27\lib\site-packages\django\core\management\commands
>> > \syncdb.py"
>> > , line 101, in handle_noargs
>> > cursor.execute(statement)
>> >   File "C:\Python27\lib\site-packages\django\db\backends\util.py",
>> > line 34, in e
>> > xecute
>> > return self.cursor.execute(sql, params)
>> >   File "C:\Python27\lib\site-packages\django\db\backends\mysql
>> > \base.py", line 86
>> > , in execute
>> > return self.cursor.execute(query, args)
>> >   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
>> > in execute
>> > self.errorhandler(self, exc, value)
>> >   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
>> > 36, in defau
>> > lterrorhandler
>> > raise errorclass, errorvalue
>> > _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
>> >
>> > Can someone help?
>> >
>> > I really appreciate it.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>> Have you created the database in mysql? use mysqladmin to create
>> databse that you entered in settings.py
>> --
>>
>> Chandrakant Kumar
>> irc - k03chandra @ #freenode
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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 t

Re: problem with syncdb and MyQSL

2011-09-02 Thread Yves S. Garret
I'm looking at this portion:

+++
INSTALLED_APPS = (
   #'django.contrib.auth',
   #'django.contrib.contenttypes',
   #'django.contrib.sessions',
   #'django.contrib.sites',
   #'django.contrib.messages',
   #'django.contrib.staticfiles',
   'polls'
   # Uncomment the next line to enable the admin:
   # 'django.contrib.admin',
   # Uncomment the next line to enable admin documentation:
   # 'django.contrib.admindocs',
)
+++

Why did you comment those apps out?  Everything above 'polls' should not be
commented out.

On Fri, Sep 2, 2011 at 12:43 PM, chandrakant kumar wrote:

> On 9/2/11, John  wrote:
> > I am a total noob so forgive my ignorance, but I have been going
> > through the Django tutorial -
> > https://docs.djangoproject.com/en/1.3/intro/tutorial01/
> >
> > I am at the point in the tutorial where I run the following command:
> >
> > C:\Python27>python c:\python27\mysite2\manage.py syncdb
> > Creating tables ...
> > Creating table polls_poll
> > Traceback (most recent call last):
> >   File "c:\python27\mysite2\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\base.py",
> > line 191,
> >  in run_from_argv
> > self.execute(*args, **options.__dict__)
> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> > line 220,
> >  in execute
> > output = self.handle(*args, **options)
> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> > line 351,
> >  in handle
> > return self.handle_noargs(**options)
> >   File "C:\Python27\lib\site-packages\django\core\management\commands
> > \syncdb.py"
> > , line 101, in handle_noargs
> > cursor.execute(statement)
> >   File "C:\Python27\lib\site-packages\django\db\backends\util.py",
> > line 34, in e
> > xecute
> > return self.cursor.execute(sql, params)
> >   File "C:\Python27\lib\site-packages\django\db\backends\mysql
> > \base.py", line 86
> > , in execute
> > return self.cursor.execute(query, args)
> >   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
> > in execute
> > self.errorhandler(self, exc, value)
> >   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
> > 36, in defau
> > lterrorhandler
> > raise errorclass, errorvalue
> > _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
> >
> > Can someone help?
> >
> > I really appreciate it.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> Have you created the database in mysql? use mysqladmin to create
> databse that you entered in settings.py
> --
>
> Chandrakant Kumar
> irc - k03chandra @ #freenode
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: problem with syncdb and MyQSL

2011-09-02 Thread John Boudreau
Yes I have. When I run the syncdb command it starts creating the tables then
hangs

So it is connecting to the MySql DB I created...

On Fri, Sep 2, 2011 at 12:43 PM, chandrakant kumar wrote:

> On 9/2/11, John  wrote:
> > I am a total noob so forgive my ignorance, but I have been going
> > through the Django tutorial -
> > https://docs.djangoproject.com/en/1.3/intro/tutorial01/
> >
> > I am at the point in the tutorial where I run the following command:
> >
> > C:\Python27>python c:\python27\mysite2\manage.py syncdb
> > Creating tables ...
> > Creating table polls_poll
> > Traceback (most recent call last):
> >   File "c:\python27\mysite2\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\base.py",
> > line 191,
> >  in run_from_argv
> > self.execute(*args, **options.__dict__)
> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> > line 220,
> >  in execute
> > output = self.handle(*args, **options)
> >   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> > line 351,
> >  in handle
> > return self.handle_noargs(**options)
> >   File "C:\Python27\lib\site-packages\django\core\management\commands
> > \syncdb.py"
> > , line 101, in handle_noargs
> > cursor.execute(statement)
> >   File "C:\Python27\lib\site-packages\django\db\backends\util.py",
> > line 34, in e
> > xecute
> > return self.cursor.execute(sql, params)
> >   File "C:\Python27\lib\site-packages\django\db\backends\mysql
> > \base.py", line 86
> > , in execute
> > return self.cursor.execute(query, args)
> >   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
> > in execute
> > self.errorhandler(self, exc, value)
> >   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
> > 36, in defau
> > lterrorhandler
> > raise errorclass, errorvalue
> > _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
> >
> > Can someone help?
> >
> > I really appreciate it.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> Have you created the database in mysql? use mysqladmin to create
> databse that you entered in settings.py
> --
>
> Chandrakant Kumar
> irc - k03chandra @ #freenode
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: problem with syncdb and MyQSL

2011-09-02 Thread chandrakant kumar
On 9/2/11, John  wrote:
> I am a total noob so forgive my ignorance, but I have been going
> through the Django tutorial -
> https://docs.djangoproject.com/en/1.3/intro/tutorial01/
>
> I am at the point in the tutorial where I run the following command:
>
> C:\Python27>python c:\python27\mysite2\manage.py syncdb
> Creating tables ...
> Creating table polls_poll
> Traceback (most recent call last):
>   File "c:\python27\mysite2\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\base.py",
> line 191,
>  in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> line 220,
>  in execute
> output = self.handle(*args, **options)
>   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> line 351,
>  in handle
> return self.handle_noargs(**options)
>   File "C:\Python27\lib\site-packages\django\core\management\commands
> \syncdb.py"
> , line 101, in handle_noargs
> cursor.execute(statement)
>   File "C:\Python27\lib\site-packages\django\db\backends\util.py",
> line 34, in e
> xecute
> return self.cursor.execute(sql, params)
>   File "C:\Python27\lib\site-packages\django\db\backends\mysql
> \base.py", line 86
> , in execute
> return self.cursor.execute(query, args)
>   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
> in execute
> self.errorhandler(self, exc, value)
>   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
> 36, in defau
> lterrorhandler
> raise errorclass, errorvalue
> _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
>
> Can someone help?
>
> I really appreciate it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

Have you created the database in mysql? use mysqladmin to create
databse that you entered in settings.py
-- 

Chandrakant Kumar
irc - k03chandra @ #freenode

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



Re: problem with syncdb and MyQSL

2011-09-02 Thread John


On Sep 2, 12:37 pm, "Yves S. Garret" 
wrote:
> Show me your settings.py file, just post all of it.
>

Please see my settings.py file below. I "X's" out the password etc

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'XX',  # Or path to
database file if using sqlite3.
'USER': 'XXX',  # Not used with
sqlite3.
'PASSWORD': 'X',  # Not used with
sqlite3.
'HOST': 'XXX',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': 'XXX',  # Set to empty string for
default. Not used with sqlite3.
}
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/New_York'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

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

# 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 = ''

# 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/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/";, "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/
static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'wd1j5w0mku10#eycqlb)1f4gj8)1o*wqi=il2uobpb_(s5ncps'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'mysite2.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
#'django.contrib.auth',
#'django.contrib.contenttypes',
#'django.contrib.sessions',
#'django.contrib.sites',
#'django.contrib.messages',
#'django.contrib.staticfiles',
'polls'
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',

Re: problem with syncdb and MyQSL

2011-09-02 Thread Yves S. Garret
Show me your settings.py file, just post all of it.

On Fri, Sep 2, 2011 at 11:38 AM, John  wrote:

> I am a total noob so forgive my ignorance, but I have been going
> through the Django tutorial -
> https://docs.djangoproject.com/en/1.3/intro/tutorial01/
>
> I am at the point in the tutorial where I run the following command:
>
> C:\Python27>python c:\python27\mysite2\manage.py syncdb
> Creating tables ...
> Creating table polls_poll
> Traceback (most recent call last):
>  File "c:\python27\mysite2\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\base.py",
> line 191,
>  in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "C:\Python27\lib\site-packages\django\core\management\base.py",
> line 220,
>  in execute
>output = self.handle(*args, **options)
>  File "C:\Python27\lib\site-packages\django\core\management\base.py",
> line 351,
>  in handle
>return self.handle_noargs(**options)
>  File "C:\Python27\lib\site-packages\django\core\management\commands
> \syncdb.py"
> , line 101, in handle_noargs
>cursor.execute(statement)
>  File "C:\Python27\lib\site-packages\django\db\backends\util.py",
> line 34, in e
> xecute
>return self.cursor.execute(sql, params)
>  File "C:\Python27\lib\site-packages\django\db\backends\mysql
> \base.py", line 86
> , in execute
>return self.cursor.execute(query, args)
>  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
> in execute
>self.errorhandler(self, exc, value)
>  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
> 36, in defau
> lterrorhandler
>raise errorclass, errorvalue
> _mysql_exceptions.InterfaceError: (-1, 'error totally whack')
>
> Can someone help?
>
> I really appreciate it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> 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.



problem with syncdb and MyQSL

2011-09-02 Thread John
I am a total noob so forgive my ignorance, but I have been going
through the Django tutorial - 
https://docs.djangoproject.com/en/1.3/intro/tutorial01/

I am at the point in the tutorial where I run the following command:

C:\Python27>python c:\python27\mysite2\manage.py syncdb
Creating tables ...
Creating table polls_poll
Traceback (most recent call last):
  File "c:\python27\mysite2\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\base.py",
line 191,
 in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py",
line 220,
 in execute
output = self.handle(*args, **options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py",
line 351,
 in handle
return self.handle_noargs(**options)
  File "C:\Python27\lib\site-packages\django\core\management\commands
\syncdb.py"
, line 101, in handle_noargs
cursor.execute(statement)
  File "C:\Python27\lib\site-packages\django\db\backends\util.py",
line 34, in e
xecute
return self.cursor.execute(sql, params)
  File "C:\Python27\lib\site-packages\django\db\backends\mysql
\base.py", line 86
, in execute
return self.cursor.execute(query, args)
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174,
in execute
self.errorhandler(self, exc, value)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line
36, in defau
lterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.InterfaceError: (-1, 'error totally whack')

Can someone help?

I really appreciate it.

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



Re: Unable to have a template NOT show up

2011-09-02 Thread Yves S. Garret
You know what would be great?  Seeing the finished code for this tutorial,
has anyone seen it?  I'm know I tripped up somewhere and that's the main
reason why I'm getting these errors, so seeing the finished product would be
a nice thing to look at right now.

On Fri, Sep 2, 2011 at 9:36 AM, Yves S. Garret
wrote:

> Yes, it is.
>
> +
>
> # Django settings for mysite project.
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
># ('Your Name', 'your_em...@example.com'),
> )
>
> MANAGERS = ADMINS
>
> DATABASES = {
>'default': {
>'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>'NAME': 'django.db.backends.sqlite3', # Or path to database
> file if using sqlite3.
>'USER': '',  # Not used with sqlite3.
>'PASSWORD': '',  # Not used with sqlite3.
>'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
>'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
>}
> }
>
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # On Unix systems, a value of None will cause Django to use the same
> # timezone as the operating system.
> # If running in a Windows environment this must be set to the same as
> your
> # system time zone.
> TIME_ZONE = 'America/Chicago'
>
> # Language code for this installation. All choices can be found here:
> # http://www.i18nguy.com/unicode/language-identifiers.html
> LANGUAGE_CODE = 'en-us'
>
> SITE_ID = 1
>
> # If you set this to False, Django will make some optimizations so as
> not
> # to load the internationalization machinery.
> USE_I18N = True
>
> # If you set this to False, Django will not format dates, numbers and
> # calendars according to the current locale
> USE_L10N = True
>
> # Absolute filesystem path to the directory that will hold user-
> uploaded files.
> # Example: "/home/media/media.lawrence.com/media/"
> MEDIA_ROOT = ''
>
> # 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 = ''
>
> # 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/'
>
> # URL prefix for admin static files -- CSS, JavaScript and images.
> # Make sure to use a trailing slash.
> # Examples: "http://foo.com/static/admin/";, "/static/admin/".
> ADMIN_MEDIA_PREFIX = '/static/admin/'
>
> # Additional locations of static files
> STATICFILES_DIRS = (
># Put strings here, like "/home/html/static" or "C:/www/django/
> static".
># Always use forward slashes, even on Windows.
># Don't forget to use absolute paths, not relative paths.
> )
>
> # List of finder classes that know how to find static files in
> # various locations.
> STATICFILES_FINDERS = (
>'django.contrib.staticfiles.finders.FileSystemFinder',
>'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> #'django.contrib.staticfiles.finders.DefaultStorageFinder',
> )
>
> # Make this unique, and don't share it with anybody.
> SECRET_KEY = 'h7zi#fhw#((y9ww$1it(23w$&$n=%x@15@g5qeufopo63lupst'
>
> # List of callables that know how to import templates from various
> sources.
> TEMPLATE_LOADERS = (
>'django.template.loaders.filesystem.Loader',
>'django.template.loaders.app_directories.Loader',
> # 'django.template.loaders.eggs.Loader',
> )
>
> MIDDLEWARE_CLASSES = (
>'django.middleware.common.CommonMiddleware',
>'django.contrib.sessions.middleware.SessionMiddleware',
>'django.middleware.csrf.CsrfViewMiddleware',
>'django.contrib.auth.middleware.AuthenticationMiddleware',
>'django.contrib.messages.middleware.MessageMiddleware',
> )
>
> ROOT_URLCONF = 'mysite.urls'
>
> TEMPLATE_DIRS = (
>"C:/Users/ashvets/My_Templates/Admin/base_site.html"
># Always use forward slashes, even on Windows.
># Don't forget to use absolute paths, not relative paths.
> )
>
> INSTALLED_APPS = (
>'django.contrib.auth',
>'django.contrib.contenttypes',
>'django.contrib.sessions',
>'django.contrib.sites',
>'django.contrib.messages',
>'django.contrib.staticfiles',
>'polls',
> # Uncomment the next line to enable the admin:
> 'django.contrib.admin'
># Uncomment the next line to enable admin documentation:
># 'django.contrib.admindocs',
> )
>
> # A sample logging configuration. The only tangible

Re: Testing reusable apps

2011-09-02 Thread Jacob Kaplan-Moss
On Fri, Sep 2, 2011 at 9:16 AM, Tomek Paczkowski  wrote:
> Hi, I cannot find any good source on how test reusable apps. I poked around
> and found out that people (django-registration, south) tests on blank
> project.
> This seems kind of wrong having to make some outside directory to be able to
> run tests.
> Isn't there any better way?

I think so: I like to use the testing mechanism in
setuptools/distribute and run tests via `python setup.py test`.

Eric Holscher wrote about the approach:
http://ericholscher.com/blog/2009/jun/29/enable-setuppy-test-your-django-apps/.

A good example in some code I've written is
https://github.com/revsys/django-fack. The important parts are in
setup.py, which does::

...
test_suite = "fack._testrunner.runtests",
tests_require = ["mock"],
...

So then fack/_testrunner.py is the test harness itself.

You also might want to check out the tox.ini there too. Tox
(http://tox.rtfd.org/) automates testing against multiple Python
versions (and other types of variable dependencies) and can smooth out
some of the steps in getting quality repeatable testing working.

Jacob

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



Testing reusable apps

2011-09-02 Thread Tomek Paczkowski
Hi, I cannot find any good source on how test reusable apps. I poked around 
and found out that people (django-registration, south) tests on blank 
project.
This seems kind of wrong having to make some outside directory to be able to 
run tests.
Isn't there any better way?

-- 
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/-/X8knTviFzVIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Pickling a QuerySet

2011-09-02 Thread Kevin
Thank you for this Tom, it's been awhile since I read about the
QuerySet API.

Kayode:  I'm not sure you can export such data as a CSV.  Why do you
need the date exported in this manner?  You can export the exact data
from the database into a CSV, but re-importing would need a bit of
work.  I have a routine which imports from a CSV adding new data which
currently does not exist based on a unique field.  It does not update
the data from CSV, although it is possible.  As long as you export
either the primary key or have a unique field.

On Sep 2, 7:26 am, Tom Evans  wrote:
> On Fri, Sep 2, 2011 at 11:05 AM, Kevin  wrote:
> > An interesting question here, not sure if anybody has tried to pickle
> > their QuerySets before.
>
> Not only have people tried this before, but there is an entry in the
> manual about it:
>
> https://docs.djangoproject.com/en/1.3/ref/models/querysets/#pickling-...
>
> wrt to your later question - how can you tell if the object already
> exists in the database - you need to understand what django does when
> you save a model, and how to customize that behaviour.
>
> https://docs.djangoproject.com/en/1.3/ref/models/instances/#what-happ...https://docs.djangoproject.com/en/1.3/ref/models/instances/#how-djang...https://docs.djangoproject.com/en/1.3/ref/models/instances/#forcing-a...
>
> Cheers
>
> Tom

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



Re: Unable to have a template NOT show up

2011-09-02 Thread Yves S. Garret
Yes, it is.

+

# Django settings for mysite project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'django.db.backends.sqlite3', # Or path to database
file if using sqlite3.
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

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

# 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 = ''

# 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/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/";, "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/
static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'h7zi#fhw#((y9ww$1it(23w$&$n=%x@15@g5qeufopo63lupst'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'mysite.urls'

TEMPLATE_DIRS = (
"C:/Users/ashvets/My_Templates/Admin/base_site.html"
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
# Uncomment the next line to enable the admin:
'django.contrib.admin'
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
   

Re: Pickling a QuerySet

2011-09-02 Thread Tom Evans
On Fri, Sep 2, 2011 at 11:05 AM, Kevin  wrote:
> An interesting question here, not sure if anybody has tried to pickle
> their QuerySets before.
>

Not only have people tried this before, but there is an entry in the
manual about it:

https://docs.djangoproject.com/en/1.3/ref/models/querysets/#pickling-querysets

wrt to your later question - how can you tell if the object already
exists in the database - you need to understand what django does when
you save a model, and how to customize that behaviour.

https://docs.djangoproject.com/en/1.3/ref/models/instances/#what-happens-when-you-save
https://docs.djangoproject.com/en/1.3/ref/models/instances/#how-django-knows-to-update-vs-insert
https://docs.djangoproject.com/en/1.3/ref/models/instances/#forcing-an-insert-or-update

Cheers

Tom

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



Re: Pickling a QuerySet

2011-09-02 Thread Kayode Odeyemi
Thanks for this.

I have a question. Is it possible to pickle a QuerySet and write to csv?

I have been trying to use pickle to achieve the same stuff you just did. But
I guess I've not been patient enough.

Thanks

On Fri, Sep 2, 2011 at 11:17 AM, Kevin  wrote:

> Wow!  This is very interesting and I did not expect the results.
>
> The following:
> >>> dat = pickle.loads(open('kbase.dat','rb').read())
> >>> for item in dat:
> ...   item.save()
>
> Worked flawlessly!  It recreated all the data in the database that I
> removed to see what would happen if I unpickled it and saved it all.
>
> I just attempted to also do the same with the data already existing,
> and it did not create new entries in the database, but merely update
> the existing ones.
>
> Are there ways to test if the entry exists in the database after
> unpickling the data?  As it currently stands it will overwrite
> existing data with the new values contained in the pickle.
>
> This would definitely be an interesting take on data backup or even
> migration to a new database server.
>
> On Sep 2, 5:05 am, Kevin  wrote:
> > An interesting question here, not sure if anybody has tried to pickle
> > their QuerySets before.
> >
> > Here's an example that does work:
> > entry_list = Entry.objects.all()
> > response =
> > HttpResponse(pickle.dumps(entry_list),mimetype='application/x-
> > pickle.python')
> > response['Content-Disposition'] = 'attachment;
> filename=kbase.dat'
> > return response
> >
> > This is one of my views.  Now, I have another view that takes a file
> > upload to take in this pickled data.  My objective is to be-able to
> > export an entire model, or select items in a model.
> >
> > It seems to unpickle just fine in the same site, and all the entry
> > objects in the queryset seem to be intact.  Now, what if, the target
> > site did not have the same entry objects and this pickle was imported
> > in?  The model is the exact same, just the actual data in the database
> > is different.  Is there an easy way to compare for differences and
> > sync the pickled data with the data in the database?  I won't run into
> > any conflicts as data is never removed on either end, data is just
> > merely added on one site, and I want to manually sync it with a
> > different site.
> >
> > I'll be running a few tests to see what happens with this data and
> > post back here to let anybody who wants to know, know.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 I write tests for 3rd party url shortener?

2011-09-02 Thread Yaşar Arabacı
Hi,

Is there a way to test whether or not a 3rd party url shortener works. What
I have in mind is this:

get short url from third party application
send a request to that link
see if that link is redirected to what it is supposed to redirected?

-- 
http://yasar.serveblog.net/

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



Explicit transactions in non-web app, avoiding "idle in transaction"

2011-09-02 Thread Willem de Jonge
Hi,

We are using the Django ORM model outside the web context in a long lived 
process.
This works quite well however the Postgres database connection is always 
"idle in transaction", which blocks other DB operations we need to do.

To fix this we use the database-level autocommit option () which gets rid of 
transactions, this works great.
Now we need to put some parts of our code in explicit transaction to ensure 
consistency, and this is the main question:

What is the correct way of doing explicit transactions in Django?

There is transaction.commit() and rollback() however there is no 
transaction.begin().

I found the enter_transaction_management() 
and leave_transaction_management() functions, which are used in the 
commit_on_succes decorator like this:

transaction.enter_transaction_management()
transaction.managed(True)

# this could should be in a transaction
...

transaction.commit()

transaction.leave_transaction_management()

# any DB operation here will automagically begin a new transaction, 
which we don't want

The above code suffers from the problem that any database operation that 
happens after it automagically will start a new transaction, again creating 
an idle transaction.
I found 2 ways to remedy this:

A) Remove the transaction.managed(True) like this:

transaction.enter_transaction_management()

# this could should be in a transaction
...

transaction.commit()

transaction.leave_transaction_management()

# any DB operation here will NOT begin a new transaction

or

B) Match it with a transaction.managed(False) like this:

transaction.enter_transaction_management()
transaction.managed(True)

# this could should be in a transaction
...

transaction.commit()

transaction.managed(False)
transaction.leave_transaction_management()

# any DB operation here will NOT begin a new transaction

What is the "correct" way to do this explicit transaction in Django, is it 
any of the above?

Any help would be appreciated.

Willem


-- 
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/-/j3BZhKKM_rMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Multiple Database Routing Based on Site

2011-09-02 Thread Kevin
The only solution I can directly think of, since the SITE_ID is in
settings.py would be to use some python logic to determine the
database for that site.

eg.
if SITE_ID == 1:
   ...  Database settings for site 1 here ...

Use an if-then like this in your settings.py.

Now if what your going after is storing the SITE_ID in a user's
profile and using that for routing, this will be more complex, as you
will need to code a new databasebackend to perform the routing, and
perhaps some middleware and an authbackend.

Mind you, I haven't done much work on multiple databases, so these are
just ideas on how I think it might be done.

On Sep 1, 9:54 pm, Terribyte  wrote:
> I had a kind of crazy idea and I wanted to bounce it off of some
> people with a lot more django experience than I.
>
> Here's my scenario...
>
> I would like 1 code base, this code base services potentially hundreds
> of businesses, each of which I want to have a copy of the same schema
> but with data only relevant to that business.
>
> Basically my idea is the following
> If the model is a Site object or User object, route to the default
> database, otherwise route reads and writes to a database name I'll set
> in the sites table.
>
> The trick is I need to set the SITE_ID for the current request, and
> I'm not sure exactly When that should happen (after login of course),
> or if this idea is even workable.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Pickling a QuerySet

2011-09-02 Thread Kevin
Wow!  This is very interesting and I did not expect the results.

The following:
>>> dat = pickle.loads(open('kbase.dat','rb').read())
>>> for item in dat:
...   item.save()

Worked flawlessly!  It recreated all the data in the database that I
removed to see what would happen if I unpickled it and saved it all.

I just attempted to also do the same with the data already existing,
and it did not create new entries in the database, but merely update
the existing ones.

Are there ways to test if the entry exists in the database after
unpickling the data?  As it currently stands it will overwrite
existing data with the new values contained in the pickle.

This would definitely be an interesting take on data backup or even
migration to a new database server.

On Sep 2, 5:05 am, Kevin  wrote:
> An interesting question here, not sure if anybody has tried to pickle
> their QuerySets before.
>
> Here's an example that does work:
>         entry_list = Entry.objects.all()
>         response =
> HttpResponse(pickle.dumps(entry_list),mimetype='application/x-
> pickle.python')
>         response['Content-Disposition'] = 'attachment; filename=kbase.dat'
>         return response
>
> This is one of my views.  Now, I have another view that takes a file
> upload to take in this pickled data.  My objective is to be-able to
> export an entire model, or select items in a model.
>
> It seems to unpickle just fine in the same site, and all the entry
> objects in the queryset seem to be intact.  Now, what if, the target
> site did not have the same entry objects and this pickle was imported
> in?  The model is the exact same, just the actual data in the database
> is different.  Is there an easy way to compare for differences and
> sync the pickled data with the data in the database?  I won't run into
> any conflicts as data is never removed on either end, data is just
> merely added on one site, and I want to manually sync it with a
> different site.
>
> I'll be running a few tests to see what happens with this data and
> post back here to let anybody who wants to know, know.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Template image display issue

2011-09-02 Thread SSozuer
my settings.py file was not configured how to handle static files
(images/js/css..) so far i made settings for that.
In deployment, or in production there is no issue anymore.

Selcuk

On Sep 2, 12:35 am, Reinout van Rees  wrote:
> On 01-09-11 23:25, SSozuer wrote:
>
> > Hi,
> > that is my index.html template:
>
> > 
> > 
> > 
> > 
>
> > The index.jpg image in the same directory with template
> > index.html.When i render template, it loads the template but i can't
> > see image in background.
>
> > Web server is apache2 with wsgi.
>
> Your django urls.py probably doesn't have a url for that "index.jpg",
> right? Then django doesn't know what to do with it. Just go directly to
> that URL and see the error message. (First try it with "manage.py
> runserver" locally).
>
> What you need to look at: django staticfiles (included with django 1.3,
> but available separate for earlier django versions).
>
> Reinout
>
> --
> Reinout van Rees                    http://reinout.vanrees.org/
> rein...@vanrees.org            http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"

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



Pickling a QuerySet

2011-09-02 Thread Kevin
An interesting question here, not sure if anybody has tried to pickle
their QuerySets before.

Here's an example that does work:
entry_list = Entry.objects.all()
response =
HttpResponse(pickle.dumps(entry_list),mimetype='application/x-
pickle.python')
response['Content-Disposition'] = 'attachment; filename=kbase.dat'
return response

This is one of my views.  Now, I have another view that takes a file
upload to take in this pickled data.  My objective is to be-able to
export an entire model, or select items in a model.

It seems to unpickle just fine in the same site, and all the entry
objects in the queryset seem to be intact.  Now, what if, the target
site did not have the same entry objects and this pickle was imported
in?  The model is the exact same, just the actual data in the database
is different.  Is there an easy way to compare for differences and
sync the pickled data with the data in the database?  I won't run into
any conflicts as data is never removed on either end, data is just
merely added on one site, and I want to manually sync it with a
different site.

I'll be running a few tests to see what happens with this data and
post back here to let anybody who wants to know, know.

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



Extending admin's index view

2011-09-02 Thread Ivan Ivanov
Hallo everybody!

I've got problem exteding the admin's index view. I need to pass
extra_context to the index of the admin, after the administrator logged
in, that's why I'm trying to extend the view. So...

What I've got is:

In the root of the project I modified urls.py like following:
   (r'^admin/$', project.admin.admin_site.index),
   (r'^admin/', include(admin.site.urls)),

Again in the root of the project I've got admin.py with the following
snippet of code:

[...]
class AdminSiteRegistryFix( object ):
'''
This fix links the '_registry' property to the orginal AdminSites
'_registry' property. This is necessary, because of the character of
the admins 'autodiscover' function. Otherwise the admin site will
say, that you havn't permission to edit anything.
'''

def _registry_getter(self):
return default_site._registry

def _registry_setter(self,value):
default_site._registry = value

_registry = property(_registry_getter, _registry_setter)


class MyAdmin(sites.AdminSite, AdminSiteRegistryFix):
@never_cache
def index(self, request, extra_context={}):
last_report_date = models.Reports.objects.latest().entry_date
now = datetime.now() 
delta = now - last_report_date
extra_context['last_report_interval'] = delta.days

return super(MyAdmin, self).index(request, extra_context)

admin_site = MyAdmin()


And it works. I've got the last_report_interval in the index.html
template and I can write my lovely message to the admin. The problem
is, that the ^admin/$ address swiches between the login and index view,
despite of users authentication status. And this is nice, but not
working after my changes, written above. Now I see only the app list of
the index. When I'm not logged in, I just see an empty list, but I've
got no login form...

Can anyone help me, understanding why has my login form disappeared?

What I can see from the django.contrib.admin.sites is that the
admin_view function is the one, calling the login view. But I have
noting to do with it, I haven't modify it and I don't understand what
disturbs it's functionallity.

Thank you in advance for your help!

Ivan Ivanov











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