Re: internationalization makemessage don't work

2012-02-28 Thread nicolas HERSOG
Hi everyone,

Thanks to you i found the problem. My template folder was conf via my
settings.py outsite my project folder.
So when i typed python manage.py makemessage -l  django didn't
parse my settings py in order to find the templates.
Now everything is ok

Thx to you :)
Nicolas

On Tue, Feb 28, 2012 at 12:03 AM, Diego Schulz  wrote:

> On Mon, Feb 27, 2012 at 7:19 PM, Denis Darii 
> wrote:
> > Of course, from the django
> > documentation(
> https://docs.djangoproject.com/en/dev/topics/i18n/translation/#message-files
> ):
> >>
> >> The script should be run from one of two places:
> >>
> >> The root directory of your Django project.
> >> The root directory of your Django app.
> >>
> >> The script runs over your project source tree or your application source
> >> tree and pulls out all strings marked for translation.
> >
> >
> > So "The script runs over your project source tree or your application
> source
> > tree"...
> >
> >
> > On Mon, Feb 27, 2012 at 11:03 PM, nicolas HERSOG 
> wrote:
> >>
> >> I've already tried this, django created LC_MESSAGE folder in locale, but
> >> this folder is empty (no django.po file is generated :/)
> >>
> >> I'm guessing if the problem is not the way i tagged the things to
> >> translate ...
> >> I added to all the html files i wanted to translate the tag {% load i18n
> >> %} and all the strings i wanted to translate are between {%trans
> >> "myStringToTranslate" %}
> >>
> >> Is the fact that my /template folder is not in the same path than m apps
> >> may be a problem ?
> >>
> >>
> >> On Mon, Feb 27, 2012 at 10:58 PM, Denis Darii 
> >> wrote:
> >>>
> >>> Hi Nicolas.
> >>> Try to run makemessages script from the root directory of your Django
> >>> app, so:
> >>>
> >>> $ cd /your/app/path/
> >>> $ mkdir locale
> >>> $ django-admin.py makemessages -l en
> >>>
> >>>
> >>>
> >>> On Mon, Feb 27, 2012 at 10:54 PM, nicolas HERSOG 
> >>> wrote:
> 
>  Yes, I have my app in INSTALLED_APPS and I also have added this key in
>  my settings :
> 
>  USE_I18N = True
>  USE_L10N = True
> 
>  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',
>  'debug_toolbar.middleware.DebugToolbarMiddleware',
>  )
>
> I'm not completely sure about this, but I think you should try adding
> 'django.middleware.locale.LocaleMiddleware' to your MIDDLEWARE_CLASSES.
> You should pay attention to the order, though.
> LocaleMiddleware should be put after SessionMiddleware and before
> CommonMiddleware.
>
> Here's a snippet from a working example:
>
> MIDDLEWARE_CLASSES = (
>'django.contrib.sessions.middleware.SessionMiddleware',
>'django.middleware.locale.LocaleMiddleware',
>'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
>'django.contrib.auth.middleware.AuthenticationMiddleware',
>'django.contrib.messages.middleware.MessageMiddleware',
> # Uncomment the next line for simple clickjacking protection:
># 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> )
>
>
> diego
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: "model_name" object has no attribute '_adding'

2012-02-28 Thread akaariai
On Feb 28, 11:39 pm, Andres Reyes  wrote:
> I'm curious as to where is this in the documentation. I think this is
> a private attribute so it shouldn't be depended upon

It is a private attribute. So use it at your own risk. If it changes
underneath you, though luck.

 - Anssi

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



Re: User actions logging app

2012-02-28 Thread Babatunde Akinyanmi
Yes, they definitely will.

On 2/28/12, akaariai  wrote:
> On Feb 28, 11:35 pm, Mario Gudelj  wrote:
>> Hi list,
>>
>> I was wandering if someone could recomend an easy django app for logging
>> user actions performed on models. I'd like to log changes logged in users
>> make around the app.
>
> I think there are some apps out there. The first question however is
> do you want to log "user a changed object b" or do you need an audit
> trail also, that is do you need to have the information of user a
> changed object b's field c from value "foo" to value "bar".
>
> I really am not the one to tell you which app is the correct one. I
> usually have a small create_log_entry() method for creating entries
> for modifications, and database triggers for the audit trail. The
> create_log_entry is often the right way to go, as more often than not
> I want to set all changes to the "main" record. That is, if somebody
> changes an article's attachment, it is the article that needs to have
> the changed log entry, not the attachment.
>
> The log entry model is something like this:
> class LogEntry(object):
> to_pk = models.IntegerField() #lets assume you are working only
> with integer primary keys
> to_type = models.CharField(max_length=40, choices=(('article',
> 'Article'), ...))
> mod_type = choices "INSERT/UPDATE/DELETE"
> who = FK(user)
> what = models.TextField() # A "comment" for the edit
> when = models.DateTimeField()
> @classmethod
> def create_log_entry(cls, to_obj, edit_type, user, what_done):
>   ...
>
> Combined with database-level triggers you can get a good audit trail.
> I have some scripts to ease maintain the DB triggers for PostgreSQL
> when using Django. I hope I will have some time to polish them for
> release, I believe they could be some use for the community.
>
>  - Anssi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



Re: Going crazy with WSGI

2012-02-28 Thread atlastorm
Thanks a lot, Javier. Things are a lot clearer now. Appreciate it.

On Feb 28, 7:46 pm, Javier Guerra Giraldez  wrote:
> On Tue, Feb 28, 2012 at 5:58 AM, atlastorm  wrote:
> > Right now I'm practicing Django by running the Django server
> > (manage.py runserver) and everything works. Apache also runs but I
> > have no clue what its doing.
>
> nothing.
>
> the Django development server (the one that runs with the runserver
> command) is an intentionally-limited web server.  you don't need
> Apache for development.  but this server will absolutely not be
> appropriate for real world serving, no matter how light the load.
>
> > If I close the Django server, how do I
> > run my application? If I save a django.wsgifile in mysite/apache/
> > django.wsgiwill things happen automatically?
>
> you need the mod_wsgi docs for that.  the Django page about deployment
> in mod_wsgi should be enough to get you running in the simplest case.
>
> > When I practiced CGI with python, I had to import the cgi module and
> > use that to get the inputs from an html form. Do I have to do
> > something similar with Django?
>
> no.  Django manages everything betweenWSGIand your apps.  you
> shouldn't need any extra Python code besides what you run under the
> development server.   in fact, the development server usesWSGItoo,
> so if your code already runs there, it should also run on
> Apache/mod_wsgi once you get that configured.
>
> --
> Javier

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



Re: question about "\d" in url pattern

2012-02-28 Thread Zheng Li

thank you very much

On 2012/02/28, at 0:37, Justin Myers wrote:

> On Feb 27, 1:44 am, Masklinn  wrote:
>> On 27 févr. 2012, at 07:23, Zheng Li  wrote:
>>> i thought "\d+" in url promises i can get an int point in cheer_confirm, 
>>> and am i wrong?
>> 
>> \d+ ensures you will only get naturals, but django will not perform any 
>> conversion automatically. Especially not here as it would require 
>> introspecting the regular expression to see which pattern was matched and 
>> whether it is convertible.
> 
> This is also in the docs: 
> https://docs.djangoproject.com/en/1.3/topics/http/urls/#notes-on-capturing-text-in-urls
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: User actions logging app

2012-02-28 Thread akaariai
On Feb 28, 11:35 pm, Mario Gudelj  wrote:
> Hi list,
>
> I was wandering if someone could recomend an easy django app for logging
> user actions performed on models. I'd like to log changes logged in users
> make around the app.

I think there are some apps out there. The first question however is
do you want to log "user a changed object b" or do you need an audit
trail also, that is do you need to have the information of user a
changed object b's field c from value "foo" to value "bar".

I really am not the one to tell you which app is the correct one. I
usually have a small create_log_entry() method for creating entries
for modifications, and database triggers for the audit trail. The
create_log_entry is often the right way to go, as more often than not
I want to set all changes to the "main" record. That is, if somebody
changes an article's attachment, it is the article that needs to have
the changed log entry, not the attachment.

The log entry model is something like this:
class LogEntry(object):
to_pk = models.IntegerField() #lets assume you are working only
with integer primary keys
to_type = models.CharField(max_length=40, choices=(('article',
'Article'), ...))
mod_type = choices "INSERT/UPDATE/DELETE"
who = FK(user)
what = models.TextField() # A "comment" for the edit
when = models.DateTimeField()
@classmethod
def create_log_entry(cls, to_obj, edit_type, user, what_done):
  ...

Combined with database-level triggers you can get a good audit trail.
I have some scripts to ease maintain the DB triggers for PostgreSQL
when using Django. I hope I will have some time to polish them for
release, I believe they could be some use for the community.

 - Anssi

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



Re: Django 1.4b1; syncdb parameters

2012-02-28 Thread KACAH


On Feb 28, 4:39 pm, Ramiro Morales  wrote:

> I suspect the reason is a cleanup performed during the 1.4 development cycle
> in handling of options passed to management commands that focused in the
> options passed via the command line.
>
> You are seeing this because presumably you are using the command y calling it
> from Python code. A valid use case. Perhaps an addition to the release notes
> would be helpful.
>
> Now, the mentioned cleanup was performed well before the 1.4 alpha (Dec 27
> 2011): 1 Oct 23 2011 so I don't understand how you are seeing the change in
> behavior between alpha1 and beta1.
>
> --
> Ramiro Morales

Sorry, my fault, seems it was version 1.3 without this bug, but 1.4a
also has it. Thanks for your reply.

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



Django online training

2012-02-28 Thread Jon Dickinson
Hi,

I'm fairly new to Python and Django. I've dabbled a bit on some toy
projects, but I am about to give it a go on a more serious piece of
work. Normally I code in Java using a TDD approach and I want to
retain that security blanket when I start a larger Django project. I'm
comfortable with tools that will let me write acceptance level tests
against a running Django server. What I need is an introduction into
how to TDD views, models and any internal logic that I need to write
for the app.

I would like an hour of online one-to-one training from someone who
has experience of TDDing a Django app so I can get hands on experience
and ask questions about the best way to approach this.

I'm offering $69 for one hour. Is anyone interested?

If so, please email me directly (jon at accoladedev dot co dot uk). I
don't need to see a whole CV, but do give me an overview of how long
you have been working with Python and Django and a brief description
of a project where you used TDD on with Django.

I have a GoToMeeting account so we can use that unless you have
another tool you are more comfortable with.

I am on GMT, send me some dates and times you are available in the
next week or so.

Thanks,
Jon.

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



cache template tag with an model instance as argument

2012-02-28 Thread Manuel Kaufmann
Hello,

I'm having a weird behavior with the {% cache %} template tag. I'm
using something like this:

{% get_current_language as LANGUAGE_CODE %}
{% cache CACHE_MIDDLEWARE_SECONDS request.user.username post LANGUAGE_CODE %}

Where post is an instance of my own model Post (I'm using
django-cache-machine[0] to cache querysets):

class Post(caching.base.CachingMixin, models.Model):
   
   objects = caching.base.CachingManager()
   

The problem is that "sometimes" (I'm not sure when yet) Django renders
the same chunk of HTML code for different Posts. I can "fix" this
changing "post" by "post.id" but there are other cases when this "fix"
is not possible: with an object_list of Post for example.

I was taking a look at the source code of the cache template tag:
https://code.djangoproject.com/browser/django/tags/releases/1.3.1/django/templatetags/cache.py
and I found that it uses a wrapper of the function urllib.quote from
the standard lib:
https://github.com/python-git/python/blob/master/Lib/urllib.py#L1181

... meanwhile I was writing this email ...

The instance object is converted to a string before send it to the
urllib.quote function. So, if there are two (or more) instance that
have the same unicode representation the "cache" templatetag will
fail.

So, I think the key should be generated with something else, something
like a hash, a md5 of pickled instance or something like that. I don't
know, I'm not a ninja on these topics:

A working example of my thoughts could be something like this:

>>> from django.utils.hashcompat import md5_constructor
>>> import pickle
>>> md5_constructor(pickle.dumps(Post.objects.filter(title='Same 
>>> Title')[0])).hexdigest() == 
>>> md5_constructor(pickle.dumps(Post.objects.filter(title='Same 
>>> Title')[1])).hexdigest()
False

What do you think?

[0] https://github.com/jbalogh/django-cache-machine

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
PyAr: http://www.python.com.ar/

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

2012-02-28 Thread Andres Reyes
I'm curious as to where is this in the documentation. I think this is
a private attribute so it shouldn't be depended upon

2012/2/28 akaariai :
> On Feb 28, 6:30 am, dizzydoc  wrote:
>> Hi django users,
>>
>> I have just migrated my projected from django 1.2.7 to django 1.3.
>>
>> I am receiving the following error while saving an object from admin.
>>
>>  "model_name" object has no attribute '_adding'
>>
>> I am getting this error in clean method of some of my models where i
>> use it the following way:
>>
>> def clean( self ):
>>         from django.core.exceptions import ValidationError
>>         if self._adding: (do this)
>>         else: (do this)
>>
>> Please help if you have any clue, while i search for the fix.
>
> The _adding variable was moved to ModelState. So, above should read:
> if self._state.adding:
>
>  - Anssi
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Andrés Reyes Monge
armo...@gmail.com
+(505)-8873-7217

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



User actions logging app

2012-02-28 Thread Mario Gudelj
Hi list,

I was wandering if someone could recomend an easy django app for logging
user actions performed on models. I'd like to log changes logged in users
make around the app.

Cheers,

m

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



Re: Using RequireJS with Django

2012-02-28 Thread ojo
On Feb 28, 8:11 am, jpk  wrote:
> I'm working on a django project with a quickly growing javascript
> front-end using backbone.  The backbone application has grown to the
> point where it needs to be split into modules across multiple files.
> I'm looking into RequireJS to do that.

> So, what I'm looking for is wisdom related to carrying out that
> process and maintaining it.  Has anyone set up require in a django
> project before, and have any tips to share?  I'd love to hear them!
>

You may want to take a look at JqResources: 
https://github.com/ojo/django-jqresources

--
Regards
Aleksander Zdyb

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 creating foreign key on a model created by inspectdb

2012-02-28 Thread Joel Goldstick
On Tue, Feb 28, 2012 at 3:24 PM, Joel Goldstick
 wrote:
> I have a legacy database from which I created a model called 'LandSupplier'
>
>    class LandSupplier(models.Model):
>        landsupplierid = models.AutoField(primary_key=True,
> db_column='LandSupplierId') # Field name made lowercase.
>        ...
>        class Meta:
>            db_table = u'LandSupplier'
>            ordering = ("name",)
>
> I have a second model called LandOffer:
>
>    class LandOffer(models.Model):
>        id = models.AutoField(primary_key=True)
>        name = models.CharField(max_length=300, db_column='Name') #
> Field name made lowercase.
>        supplier = models.ForeignKey('LandSupplier', 
> db_column='landsupplierid')
>
> I get this error:
>
> Request Method: GET
> Request URL:    http://localhost:8000/admin/land/landoffer/
> Django Version: 1.3.1
> Exception Type: OperationalError
> Exception Value:        (1054, "Unknown column
> 'land_landoffer.landsupplierid' in 'field list'")
>
> It seems to take my fieldname, but not my table name.  I'm wondering
> how to fix this.  I could rename the table to 'land_landoffer' but
> that would mess up a lot of other code, and I would rather learn what
> I am doing wrong here
>
> --
> Joel Goldstick

Nothing like posting to clear the problem.  I put this in my model,
and then added supplier_id to my table by hand.  Problem solved

supplier = models.ForeignKey('LandSupplier')



-- 
Joel Goldstick

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



Problem creating foreign key on a model created by inspectdb

2012-02-28 Thread Joel Goldstick
I have a legacy database from which I created a model called 'LandSupplier'

class LandSupplier(models.Model):
landsupplierid = models.AutoField(primary_key=True,
db_column='LandSupplierId') # Field name made lowercase.
...
class Meta:
db_table = u'LandSupplier'
ordering = ("name",)

I have a second model called LandOffer:

class LandOffer(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=300, db_column='Name') #
Field name made lowercase.
supplier = models.ForeignKey('LandSupplier', db_column='landsupplierid')

I get this error:

Request Method: GET
Request URL:http://localhost:8000/admin/land/landoffer/
Django Version: 1.3.1
Exception Type: OperationalError
Exception Value:(1054, "Unknown column
'land_landoffer.landsupplierid' in 'field list'")

It seems to take my fieldname, but not my table name.  I'm wondering
how to fix this.  I could rename the table to 'land_landoffer' but
that would mess up a lot of other code, and I would rather learn what
I am doing wrong here

-- 
Joel Goldstick

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



new plugable django app released (django-hitcount-mixed-object)

2012-02-28 Thread rmaceissoft
I recently released a plugable django app (django-hitcount-mixed-
object) in order to count hits/views over mixed object using NoSQL in
order to increase the performance of this functionality.

To count hits/views of simple objects is a simple task, in comparison
with mixed objects.

What is a mixed object?. Let's see with a use case.

Imagine that your app allows customize the ordered items, similar how
happen at ordering food sites. I mean that two ordered items can
specify the same dish, but with different toppings. and you need to
know how many times the same dish with the sames toppings have been
ordered.

In this case, the composition of dish with toppings ordered is the
mixed object, and it can be divided into:
1) object -> match with dish
2) related objects -> match with toppings

If this example or similar one is your problem, this django app is for
you.

Your are welcome to send your feedback about the this plugable. You
can download it from pypi[1] or make a fork at github[2]

[1] - http://pypi.python.org/pypi/django-hitcount-mixed-object/

[2] - https://github.com/rmaceissoft/django-hitcount-mixed-object

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



Re: Login Issues

2012-02-28 Thread rafiee.nima
sorry
site_media=os.path.join(os.path.dirname(__file__),'site_media')   is
not needed it was a line of code from my own project :D

On Feb 28, 7:54 pm, "rafiee.nima"  wrote:
> hi
> check if you import login view in url.py to be like this :
> from django.contrib.auth.views import login
>
> and also check your pattern in url.py to be like this :
> site_media=os.path.join(os.path.dirname(__file__),'site_media')
> urlpatterns = patterns(' ',
>     (r'^login/$',login), )
> and dont change the location of login.html in registration.html
>
> On Feb 28, 6:01 am, hack  wrote:
>
>
>
>
>
>
>
> > I'm attempting to follow the instructions on the Django website and
> > use the registration/login.html.  I created the file in myapp/
> > registration/login.html.
>
> > I've added the following to my urls.py file:
> > url(r'^login/$', 'django.contrib.auth.views.login'),
>
> > When I attempt to access /myapp/login I get the following error:
> > Could not import hcp.views.django.contrib.auth.views. Error was: No
> > module named django.contrib.auth.views
>
> > I did setup my urls file by moving it into the myapp directory and
> > putting the following in the original:
> > url(r'^myapp/',include('myapp.urls')),
>
> > Any suggestions on why django thinks the template doesn't exist?  Any
> > help would be greatly appreciated.  Thanks.

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



Re: Resize Image On Save is resizing all images in directory?

2012-02-28 Thread richard
After a bit more debugging I have found that when the save method gets
called it loops through every record in the UserProfilePic table so
that is why
the self.profilepic.path gets assigned eg image1.jpg, image2.jpg and
when doing a resize it loops over them all opening each path from the
table reszing each image.

Can anyone explain why this works like that?

On Feb 28, 6:39 am, richard  wrote:
> Hi I have an upload form that uploads an image and on the save i
> resize the image. But when i do this images that are in the same
> directory seem to get resized aswell even though they have unique hash
> names? any help please.
>
> MODELS.py
>
> def upload_to(instance, old_filename):
>     import time
>     import hashlib
>     import os
>
>     extension = os.path.splitext(old_filename)[1]
>     filename = hashlib.md5(str(time.time())).hexdigest() + extension
>     return "photos/%s/%s" % (instance.userprofile.user_id, filename)
>
> class UserProfilePic(models.Model):
>     current = models.BooleanField()
>     userprofile = models.ForeignKey(UserProfile)
>     profilepic = models.ImageField(upload_to=upload_to)
>
>     def save(self):
>         from PIL import Image, ImageOps
>
>         super(UserProfilePic, self).save()
>
>         #create profile image
>         filename2 = self.profilepic.path
>         im2 = Image.open(filename2)
>         im2 = ImageOps.fit(im2, (170, 190), Image.ANTIALIAS,
> (0.5,0.5)).save(filename, "JPEG", quality=100)

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

2012-02-28 Thread rafiee.nima
hi
check if you import login view in url.py to be like this :
from django.contrib.auth.views import login

and also check your pattern in url.py to be like this :
site_media=os.path.join(os.path.dirname(__file__),'site_media')
urlpatterns = patterns(' ',
(r'^login/$',login), )
and dont change the location of login.html in registration.html



On Feb 28, 6:01 am, hack  wrote:
> I'm attempting to follow the instructions on the Django website and
> use the registration/login.html.  I created the file in myapp/
> registration/login.html.
>
> I've added the following to my urls.py file:
> url(r'^login/$', 'django.contrib.auth.views.login'),
>
> When I attempt to access /myapp/login I get the following error:
> Could not import hcp.views.django.contrib.auth.views. Error was: No
> module named django.contrib.auth.views
>
> I did setup my urls file by moving it into the myapp directory and
> putting the following in the original:
> url(r'^myapp/',include('myapp.urls')),
>
> Any suggestions on why django thinks the template doesn't exist?  Any
> help would be greatly appreciated.  Thanks.

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



Re: Forms - All fields into first attribute

2012-02-28 Thread Tom Evans
On Tue, Feb 28, 2012 at 3:44 PM, Xavier Pegenaute  wrote:
> Hi,
>
> I am using Django 1.3.1, and I have a strange behavior problem, all
> the different fields submitted are going as value of the first field.
> Here is the http header (print request):
> "
>  GET:,
> POST: [u'surName1=surName2=dni=birthDate=28/02/2012address=postalCode=locality=province=country=telf=email=mail@mail.orgjob=
> \r\nsurName1=\r\nsurName2=\r\ndni=\r\nbirthDate=\r\naddress=\r
> \npostalCode=\r\nlocality=\r\nprovince=\r\ncountry=\r\ntelf=\r\nemail=
> \r\njob=']}>,
> COOKIES:..."
>
> The template which renders the form is this:
> "
>  5 

You asked for text/plain encoding, and got it. Forms are submitted
with enctype "application/x-www-form-urlencoded" (the default) or
"multipart/form-data" (if sending files).

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: "model_name" object has no attribute '_adding'

2012-02-28 Thread akaariai
On Feb 28, 6:30 am, dizzydoc  wrote:
> Hi django users,
>
> I have just migrated my projected from django 1.2.7 to django 1.3.
>
> I am receiving the following error while saving an object from admin.
>
>  "model_name" object has no attribute '_adding'
>
> I am getting this error in clean method of some of my models where i
> use it the following way:
>
> def clean( self ):
>         from django.core.exceptions import ValidationError
>         if self._adding: (do this)
>         else: (do this)
>
> Please help if you have any clue, while i search for the fix.

The _adding variable was moved to ModelState. So, above should read:
if self._state.adding:

 - Anssi

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



Forms - All fields into first attribute

2012-02-28 Thread Xavier Pegenaute
Hi,

I am using Django 1.3.1, and I have a strange behavior problem, all
the different fields submitted are going as value of the first field.
Here is the http header (print request):
"
,
POST:

Django 1.4b1 (dev): Can't enable Admin site when following the official tutorial

2012-02-28 Thread fjavieralba
Hi,

I'm installed the last version of Django (1.4b1) and I'm following the
tutorial (https://docs.djangoproject.com/en/dev/intro/tutorial01/)

I'm  tryied to enable the Admin site (following exactly the steps
described on the tutorial), but when I try to acces to localhost:8000
or localhost:8000/admin I get the following error:


ImportError at /admin
cannot import name ListFilter
...
Exception Location: /Users/fjavieralba/virtualenvs/personal_page/lib/
python2.7/site-packages/django/contrib/admin/validation.py in
, line 6
...


I'm using Mac OS X Lion and VirtualEnv. My python version is 2.7.1


Thanks!

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



Re: Can't get pagination to work in django.!!!

2012-02-28 Thread Tony Kyriakides
Sorry tom! Thanks a lot mate you just made my day!

On Feb 28, 5:34 pm, Tom Evans  wrote:
> Hi. Re-read what I said:
>
> > 24      {% for entry in entries %}
>
>            ^^^
>
> > 25      {{ entry.title }}
> > {{ entry.posted }} {{ entry.submitter }}
> > 26      {% endfor %}
>
> Compare and contrast what you are doing with 'entries' in that for
> loop and what the docs do with the equivalent object in the linked
> example, 'contacts'.
>
> This is the part of the docs I linked you to:
>
> {% for contact in contacts.object_list %}
>     {# Each "contact" is a Contact model object. #}
>     {{ contact.full_name|upper }}
>     ...
> {% endfor %}
>
> Any clearer?
>
> 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: Can't get pagination to work in django.!!!

2012-02-28 Thread Tom Evans
Hi. Re-read what I said:

> 24  {% for entry in entries %}
   ^^^
> 25  {{ entry.title }}
> {{ entry.posted }} {{ entry.submitter }}
> 26  {% endfor %}

Compare and contrast what you are doing with 'entries' in that for
loop and what the docs do with the equivalent object in the linked
example, 'contacts'.

This is the part of the docs I linked you to:

{% for contact in contacts.object_list %}
{# Each "contact" is a Contact model object. #}
{{ contact.full_name|upper }}
...
{% endfor %}

Any clearer?

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: DatabaseError: execute used with asynchronous query

2012-02-28 Thread j_syk
As far as I remember, I quickly switched back to 'sync' worker type (the 
default) for the app which had this problem. I've never seen the error 
again. I have another project running on eventlet, still with gunicorn, 
postgres, and psycopg2. Never have had any problems with that one. So maybe 
it is a problem with gevent. 

I'd like to hear from someone who has had success with gevent.


On Tuesday, February 28, 2012 7:34:03 AM UTC-6, Daniel Svonava wrote:
>
> Hi, this same error happened to me as well. My setup:
>
> Django==1.3.1
> gevent==0.13.6
> greenlet==0.3.4
> gunicorn==0.13.4
> psycopg2==2.4.4
>
> I use this function to make psycopg2 "green" (in the gunicorn config):
>
> worker_class = "gevent"
> def def_post_fork(server, worker):
> from psyco_gevent import make_psycopg_green
> make_psycopg_green()
> worker.log.info("Made Psycopg Green")
> post_fork = def_post_fork
>
>
> This is making me worried of using the Gunicorn+Gevent+psycopg2 combo.
>
> Cheers,
> Daniel
>
> On Friday, January 20, 2012 3:46:47 PM UTC+1, j_syk wrote:
>>
>> I was testing one my apps today with a form that features a drop-down 
>> field that initiates a json lookup for additional detail. You choose a 
>> location, it populates address fields. It's been working for weeks. 
>> Today, when I clicked an entry, the target detail field didn't change. 
>>
>> I have debug off, so instantly I feel my phone buzz and I've been sent 
>> a http500 report e-mail with the following message- 
>>
>>
>> DatabaseError: execute cannot be used while an asynchronous query is 
>> underway 
>>
>>
>> I can't seem to reproduce the error, it's never happened before, and I 
>> haven't changed this piece of code for a while, so I doubt it's 
>> something new. 
>>
>> I'm willing to write it off as a fluke, but at the same time I'd like 
>> to learn more and the search results on the topic don't seem good. 
>>
>> Server setup is Django 1.3.1, Gunicorn 0.13 with geventlet processes, 
>> Nginx 0.7, postgres 8.4.8, 
>> That particular page was using Jquery and a .getJSON call to a json 
>> output produced by a django view which calls a basic query. 
>>
>> What should I know about the "asynchronous query" error? Are there 
>> ways to prevent it? Should I be worried?
>
>

-- 
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/-/yrBK5DVnN30J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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't get pagination to work in django.!!!

2012-02-28 Thread Tony Kyriakides
hey tom its still not working :P it was easier for me to copy it from
the docs...i still get the same error

template:
Entries

{% for entry in entries %}
{{ entry.title }}
{{ entry.posted }} {{ entry.submitter }}
{% endfor %}



{% if entries.has_previous %}
previous
{% endif %}


Page {{ entries.number }} of
{{ entries.paginator.num_pages }}.


{% if entries.has_next %}
next
{% endif %}


On Feb 28, 5:01 pm, Tom Evans  wrote:
> On Tue, Feb 28, 2012 at 2:45 PM, Tony Kyriakides
>
>
>
>
>
>
>
>
>
>  wrote:
> > I get this error:
>
> > Template error
>
> > In template /home/tony/Documents/vidupdate/templates/index.html, error
> > at line 24
>
> > Caught TypeError while rendering: 'Page' object is not iterable
> > 14      {% else %}
> > 15      Register
> > 16      Login
> > 17      {% endif %}
> > 18      feedback
> > 19      Contact
> > 20      
> > 21      
> > 22      Entries
> > 23      
> > 24      {% for entry in entries %}
> > 25      {{ entry.title }}
> > {{ entry.posted }} {{ entry.submitter }}
> > 26      {% endfor %}
>
> https://docs.djangoproject.com/en/1.3/topics/pagination/#using-pagina...
>
> Compare and contrast what you are doing with 'entries' in that for
> loop and what the docs do with the equivalent object in the linked
> example, 'contacts'.
>
> Your pagination links are referring to 'contacts' rather than
> 'entries' - copy/paste error there?
>
> 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: passing '&' in url

2012-02-28 Thread Tom Evans
On Tue, Feb 28, 2012 at 11:13 AM, vijay shanker  wrote:
> i need to pass " & " as query e.g q=larsen & turbo
> urlencode does not works as finally its as good as without it for
> above eg.
> please suggest.
>

>>> from django.http import QueryDict
>>> qstring = QueryDict('', mutable=True)
>>> qstring['query'] = 'hello&goodbye'
>>> qstring.urlencode()
'query=hello%26goodbye'

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: Can't get pagination to work in django.!!!

2012-02-28 Thread Tom Evans
On Tue, Feb 28, 2012 at 2:45 PM, Tony Kyriakides
 wrote:
> I get this error:
>
> Template error
>
> In template /home/tony/Documents/vidupdate/templates/index.html, error
> at line 24
>
> Caught TypeError while rendering: 'Page' object is not iterable
> 14      {% else %}
> 15      Register
> 16      Login
> 17      {% endif %}
> 18      feedback
> 19      Contact
> 20      
> 21      
> 22      Entries
> 23      
> 24      {% for entry in entries %}
> 25      {{ entry.title }}
> {{ entry.posted }} {{ entry.submitter }}
> 26      {% endfor %}

https://docs.djangoproject.com/en/1.3/topics/pagination/#using-paginator-in-a-view

Compare and contrast what you are doing with 'entries' in that for
loop and what the docs do with the equivalent object in the linked
example, 'contacts'.

Your pagination links are referring to 'contacts' rather than
'entries' - copy/paste error there?

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: Going crazy with WSGI

2012-02-28 Thread Javier Guerra Giraldez
On Tue, Feb 28, 2012 at 5:58 AM, atlastorm  wrote:
> Right now I'm practicing Django by running the Django server
> (manage.py runserver) and everything works. Apache also runs but I
> have no clue what its doing.

nothing.

the Django development server (the one that runs with the runserver
command) is an intentionally-limited web server.  you don't need
Apache for development.  but this server will absolutely not be
appropriate for real world serving, no matter how light the load.

> If I close the Django server, how do I
> run my application? If I save a django.wsgi file in mysite/apache/
> django.wsgi will things happen automatically?

you need the mod_wsgi docs for that.  the Django page about deployment
in mod_wsgi should be enough to get you running in the simplest case.


> When I practiced CGI with python, I had to import the cgi module and
> use that to get the inputs from an html form. Do I have to do
> something similar with Django?

no.  Django manages everything between WSGI and your apps.  you
shouldn't need any extra Python code besides what you run under the
development server.   in fact, the development server uses WSGI too,
so if your code already runs there, it should also run on
Apache/mod_wsgi once you get that configured.


-- 
Javier

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



Can't get pagination to work in django.!!!

2012-02-28 Thread Tony Kyriakides
I get this error:

Template error

In template /home/tony/Documents/vidupdate/templates/index.html, error
at line 24

Caught TypeError while rendering: 'Page' object is not iterable
14  {% else %}
15  Register
16  Login
17  {% endif %}
18  feedback
19  Contact
20  
21  
22  Entries
23  
24  {% for entry in entries %}
25  {{ entry.title }}
{{ entry.posted }} {{ entry.submitter }}
26  {% endfor %}
27  
28
29  
30  {% if entries.object_list and posts.paginator.num_pages > 1 %}
31  
32  
33  {% if entries.has_previous %}
34  previous

this is my view:

from django.shortcuts import render_to_response
from vidupdate.posts.models import Entry
from django.template import RequestContext
from django.core.paginator import Paginator, InvalidPage, EmptyPage

def homepage(request):
entries = Entry.objects.all().order_by('-posted')
paginator = Paginator(entries, 2)

try: page = int(request.GET.get('page', '1'))
except ValueError: page = 1

try:
entries = paginator.page(page)
except (InvalidPage, EmptyPage):
entries = paginator.page(paginator.num_pages)

return render_to_response('index.html', {'entries' : entries},
context_instance=RequestContext(request))

this is in my template:

{% for entry in entries %}
{{ entry.title }}
{{ entry.posted }} {{ entry.submitter }}
{% endfor %}




{% if contacts.has_previous %}
previous
{% endif %}


Page {{ contacts.number }} of
{{ contacts.paginator.num_pages }}.


{% if contacts.has_next %}
next
{% endif %}



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



Resize Image On Save is resizing all images in directory?

2012-02-28 Thread richard
Hi I have an upload form that uploads an image and on the save i
resize the image. But when i do this images that are in the same
directory seem to get resized aswell even though they have unique hash
names? any help please.

MODELS.py

def upload_to(instance, old_filename):
import time
import hashlib
import os

extension = os.path.splitext(old_filename)[1]
filename = hashlib.md5(str(time.time())).hexdigest() + extension
return "photos/%s/%s" % (instance.userprofile.user_id, filename)

class UserProfilePic(models.Model):
current = models.BooleanField()
userprofile = models.ForeignKey(UserProfile)
profilepic = models.ImageField(upload_to=upload_to)

def save(self):
from PIL import Image, ImageOps

super(UserProfilePic, self).save()

#create profile image
filename2 = self.profilepic.path
im2 = Image.open(filename2)
im2 = ImageOps.fit(im2, (170, 190), Image.ANTIALIAS,
(0.5,0.5)).save(filename, "JPEG", quality=100)

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

2012-02-28 Thread Ramiro Morales
On Tue, Feb 28, 2012 at 10:44 AM, KACAH  wrote:
> Hi django users,
>
> In Django 1.4b1, syncdb.Command().execute() has required parameters
> "verbosity" and "database". In 1.4a version they had default values
> (verbosity=1, database="default"). Is this a bug or feature?

I suspect the reason is a cleanup performed during the 1.4 development cycle
in handling of options passed to management commands that focused in the
options passed via the command line.

You are seeing this because presumably you are using the command y calling it
from Python code. A valid use case. Perhaps an addition to the release notes
would be helpful.

Now, the mentioned cleanup was performed well before the 1.4 alpha (Dec 27
2011): 1 Oct 23 2011 so I don't understand how you are seeing the change in
behavior between alpha1 and beta1.


-- 
Ramiro Morales

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



Re: How to generate common blocks?

2012-02-28 Thread francofuji
You can use custom template tags [1] as some one suggest to you or template
context processors [2].

[1] https://docs.djangoproject.com/en/1.3/howto/custom-template-tags/
[2]
https://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors

Regards


On Mon, Feb 27, 2012 at 3:25 PM, Paul  wrote:

> I have a question regarding the use of the template mechanism.
>
> Say i'm using a common website layout with header, footer and in the
> center three columns. Only the center is specific to the request (so
> the specific view function will generate the center block), i'm not
> sure however what the best way is to generate the common blocks in the
> side bars. Lets say i want to have multiple blocks with dynamic
> contents (such as a random selected review or frequently searched
> items). I guess is can call specific functions to generate the common
> blocks but i would have to do so for each view function? This doesn't
> make sense to me because quickly blocks will be generated that are not
> actually used; would it be possible to do something smart? Like
> specifying block-functions inside the template code?
>
> Many thanks for any directions!
>
> Paul
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: "model_name" object has no attribute '_adding'

2012-02-28 Thread Andres Reyes
I don't remember reading anything about an "_adding" attribute in the
documentation. However, if you want to check for an INSERT vs an
UPDATE just check for the existence of a primary key

def clean( self ):
   from django.core.exceptions import ValidationError
   if self.pk is None: (do this)
   else: (do this)

2012/2/27 dizzydoc :
> Hi django users,
>
> I have just migrated my projected from django 1.2.7 to django 1.3.
>
> I am receiving the following error while saving an object from admin.
>
>  "model_name" object has no attribute '_adding'
>
> I am getting this error in clean method of some of my models where i
> use it the following way:
>
> def clean( self ):
>        from django.core.exceptions import ValidationError
>        if self._adding: (do this)
>        else: (do this)
>
> Please help if you have any clue, while i search for the fix.
>
> 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.
>



-- 
Andrés Reyes Monge
armo...@gmail.com
+(505)-8873-7217

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



Django 1.4b1; syncdb parameters

2012-02-28 Thread KACAH
Hi django users,

In Django 1.4b1, syncdb.Command().execute() has required parameters
"verbosity" and "database". In 1.4a version they had default values
(verbosity=1, database="default"). Is this a bug or feature?

Thanks.

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



Re: DatabaseError: execute used with asynchronous query

2012-02-28 Thread Daniel Svonava
Hi, this same error happened to me as well. My setup:

Django==1.3.1
gevent==0.13.6
greenlet==0.3.4
gunicorn==0.13.4
psycopg2==2.4.4

I use this function to make psycopg2 "green" (in the gunicorn config):

worker_class = "gevent"
def def_post_fork(server, worker):
from psyco_gevent import make_psycopg_green
make_psycopg_green()
worker.log.info("Made Psycopg Green")
post_fork = def_post_fork


This is making me worried of using the Gunicorn+Gevent+psycopg2 combo.

Cheers,
Daniel

On Friday, January 20, 2012 3:46:47 PM UTC+1, j_syk wrote:
>
> I was testing one my apps today with a form that features a drop-down 
> field that initiates a json lookup for additional detail. You choose a 
> location, it populates address fields. It's been working for weeks. 
> Today, when I clicked an entry, the target detail field didn't change. 
>
> I have debug off, so instantly I feel my phone buzz and I've been sent 
> a http500 report e-mail with the following message- 
>
>
> DatabaseError: execute cannot be used while an asynchronous query is 
> underway 
>
>
> I can't seem to reproduce the error, it's never happened before, and I 
> haven't changed this piece of code for a while, so I doubt it's 
> something new. 
>
> I'm willing to write it off as a fluke, but at the same time I'd like 
> to learn more and the search results on the topic don't seem good. 
>
> Server setup is Django 1.3.1, Gunicorn 0.13 with geventlet processes, 
> Nginx 0.7, postgres 8.4.8, 
> That particular page was using Jquery and a .getJSON call to a json 
> output produced by a django view which calls a basic query. 
>
> What should I know about the "asynchronous query" error? Are there 
> ways to prevent it? Should I be worried?


On Friday, January 20, 2012 3:46:47 PM UTC+1, j_syk wrote:
>
> I was testing one my apps today with a form that features a drop-down 
> field that initiates a json lookup for additional detail. You choose a 
> location, it populates address fields. It's been working for weeks. 
> Today, when I clicked an entry, the target detail field didn't change. 
>
> I have debug off, so instantly I feel my phone buzz and I've been sent 
> a http500 report e-mail with the following message- 
>
>
> DatabaseError: execute cannot be used while an asynchronous query is 
> underway 
>
>
> I can't seem to reproduce the error, it's never happened before, and I 
> haven't changed this piece of code for a while, so I doubt it's 
> something new. 
>
> I'm willing to write it off as a fluke, but at the same time I'd like 
> to learn more and the search results on the topic don't seem good. 
>
> Server setup is Django 1.3.1, Gunicorn 0.13 with geventlet processes, 
> Nginx 0.7, postgres 8.4.8, 
> That particular page was using Jquery and a .getJSON call to a json 
> output produced by a django view which calls a basic query. 
>
> What should I know about the "asynchronous query" error? Are there 
> ways to prevent it? Should I be worried?


On Friday, January 20, 2012 3:46:47 PM UTC+1, j_syk wrote:
>
> I was testing one my apps today with a form that features a drop-down 
> field that initiates a json lookup for additional detail. You choose a 
> location, it populates address fields. It's been working for weeks. 
> Today, when I clicked an entry, the target detail field didn't change. 
>
> I have debug off, so instantly I feel my phone buzz and I've been sent 
> a http500 report e-mail with the following message- 
>
>
> DatabaseError: execute cannot be used while an asynchronous query is 
> underway 
>
>
> I can't seem to reproduce the error, it's never happened before, and I 
> haven't changed this piece of code for a while, so I doubt it's 
> something new. 
>
> I'm willing to write it off as a fluke, but at the same time I'd like 
> to learn more and the search results on the topic don't seem good. 
>
> Server setup is Django 1.3.1, Gunicorn 0.13 with geventlet processes, 
> Nginx 0.7, postgres 8.4.8, 
> That particular page was using Jquery and a .getJSON call to a json 
> output produced by a django view which calls a basic query. 
>
> What should I know about the "asynchronous query" error? Are there 
> ways to prevent it? Should I be worried?

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



passing '&' in url

2012-02-28 Thread vijay shanker
i need to pass " & " as query e.g q=larsen & turbo
urlencode does not works as finally its as good as without it for
above eg.
please suggest.

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

2012-02-28 Thread Russell Keith-Magee

On 28/02/2012, at 7:10 PM, Johan wrote:

> Hi. I can see that the setUp method of my TestCase specialization is
> being run for each test case. I thought that the test DB is cleared
> every time before setUp is called. Is this the case? I'm having a
> problem where I am assuring that only one of a certain record will be
> in the DB but because the db isn't cleared I end up with two records
> and this breaks my code.
> 

It depends whether you're using Django's TestCase (django.tests.TestCase) or 
unittest's TestCase (unittest.TestCase). 

The vanilla unittest.TestCase does nothing to manage your database. If you 
access a database during the TestCase, it's also your responsibility to clean 
up afterwards.

django.test.TestCase is a subclass of unittest.TestCase, so anything that works 
in a normal Python TestCase will also work in a Django TestCase. The Django 
TestCase subclass just adds a bunch of extra tools to make testing 
database-backed websites easier.

One of the most important of these extra tools is database clearing. If you use 
django.test.TestCase, the database will be cleared before the start of every 
test. If you create database objects during the test (during setUp, or during 
the test itself), that data will be cleared out before the start of the next 
test.

Yours,
Russ Magee %-)

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



AW: custom tag not working

2012-02-28 Thread Szabo, Patrick (LNG-VIE)
Nevermind...i loaded the filter.py in the wrong template -.-

 

Von: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] Im Auftrag von Szabo, Patrick
(LNG-VIE)
Gesendet: Dienstag, 28. Februar 2012 13:15
An: django-users@googlegroups.com
Betreff: custom tag not working

 

Hi, 

 

I want to perform a substring on certain texts in my template (I can't
substring beforelong story -.-).

I already have custom tags working so I really don't know why this one
isn't.

In the files where I have the other tags as well I did this:

 

@register.filter(name ="cutnr")

@stringfilter

def cutnr(prodstr):

return substring_before(prodstr, " #")

 

In my template there is:

 

{% for produkt, akt in produkte.items %}



{{ var|cutnr:"asdsa#sss" }}

...

 

So for testing i wanted to give my function a random string just to
check it out. 

Unfortunately I get this: 

 

Exception Value:

Invalid filter: 'cutnr'

 

Any ideas ?

 

Best regards

. . . . . . . . . . . . . . . . . . . . . . . . . .

Ing. Patrick Szabo
XSLT Developer 

LexisNexis
A-1030 Wien, Marxergasse 25

patrick.sz...@lexisnexis.at

Tel.: +43 1 53452 1573 

Fax: +43 1 534 52 146 

 

 

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


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer 
LexisNexis
A-1030 Wien, Marxergasse 25

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 1 53452 1573 
Fax: +43 1 534 52 146 





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



custom tag not working

2012-02-28 Thread Szabo, Patrick (LNG-VIE)
Hi, 

 

I want to perform a substring on certain texts in my template (I can't
substring beforelong story -.-).

I already have custom tags working so I really don't know why this one
isn't.

In the files where I have the other tags as well I did this:

 

@register.filter(name ="cutnr")

@stringfilter

def cutnr(prodstr):

return substring_before(prodstr, " #")

 

In my template there is:

 

{% for produkt, akt in produkte.items %}



{{ var|cutnr:"asdsa#sss" }}

...

 

So for testing i wanted to give my function a random string just to
check it out. 

Unfortunately I get this: 

 

Exception Value:

Invalid filter: 'cutnr'

 

Any ideas ?

 

Best regards


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer 
LexisNexis
A-1030 Wien, Marxergasse 25

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 1 53452 1573 
Fax: +43 1 534 52 146 





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

2012-02-28 Thread George Silva
You need to use the tearDown method to clear any records that you've might
create.

On Tue, Feb 28, 2012 at 8:10 AM, Johan  wrote:

> Hi. I can see that the setUp method of my TestCase specialization is
> being run for each test case. I thought that the test DB is cleared
> every time before setUp is called. Is this the case? I'm having a
> problem where I am assuring that only one of a certain record will be
> in the DB but because the db isn't cleared I end up with two records
> and this breaks my code.
>
> Regards
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
George R. C. Silva

Desenvolvimento em GIS
http://geoprocessamento.net
http://blog.geoprocessamento.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.



ManyToManyField default

2012-02-28 Thread Klemens
Hi,

found nothing helpful about this topic. Only problems and bugreports ;)

this (seems) to work in my project without any troubles in the admin interface:

...
# site with SITE_ID = 1 is the default site to publish
sites = models.ManyToManyField(Site, default=(1, ))
...

so when i create a new object, the change_from has already the site
with the id 1 highlighted.

is this the correct way to do it?

regards,
klemens

-- 
klemens mantzos
http://fetzig.at/

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



Re: Getting Started with Mac OS X

2012-02-28 Thread Tom Evans
On Tue, Feb 28, 2012 at 12:36 AM, JChlipala  wrote:
> Hello,
>
> I am a Django beginner, and am trying to get Django set up in Mac OS
> X.  I am going through the tutorial, but getting stuck very early
> (essentially at the beginning).  I have installed Python and Django.
> The next instruction is to enter the command "django-admin.py
> startproject mysite".  When I do this, I get the following error:
>
> File "", line 1
> django-admin.py startproject mysite
>                                        ^
>
> SyntaxError:  invalid syntax
>
> Does anybody know why I am getting this error?

You need to type that command at the console command prompt, not the
python prompt.

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.



Django Unittesting Question.

2012-02-28 Thread Johan
Hi. I can see that the setUp method of my TestCase specialization is
being run for each test case. I thought that the test DB is cleared
every time before setUp is called. Is this the case? I'm having a
problem where I am assuring that only one of a certain record will be
in the DB but because the db isn't cleared I end up with two records
and this breaks my code.

Regards

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



Re: Going crazy with WSGI

2012-02-28 Thread atlastorm
Thanks Javier for the explanation. I've done some more reading, some
things have become clearer, but:

Right now I'm practicing Django by running the Django server
(manage.py runserver) and everything works. Apache also runs but I
have no clue what its doing. If I close the Django server, how do I
run my application? If I save a django.wsgi file in mysite/apache/
django.wsgi will things happen automatically?

When I practiced CGI with python, I had to import the cgi module and
use that to get the inputs from an html form. Do I have to do
something similar with Django?

Thanks again for the help. Appreciate it.

On Feb 28, 10:02 am, Javier Guerra Giraldez 
wrote:
> On Mon, Feb 27, 2012 at 11:19 PM, atlastorm  wrote:
> > WSGI is a script that connects Django to
> > Apache.
>
> not really
>
> WSGI is just a standard, a document that says "the web server will
> call the app as a function with such and such parameters, the app will
> return such and such values with the response"
>
> armed with that, any Python developer can write a web app just
> following the 'app' part of the standard, and any web server that
> wants to call those apps do the calls following the other part.
>
> specifically, mod_wsgi is the apache plugin that launches a Python
> interpreter and do all the calls according to the standard, and Django
> is a framework that follows the WSGI standard.
>
> besides, some WSGI-compliant servers need a little extra information
> to specify exactly what web app to call, and in mod_wsgi case, it's
> done with 'the wsgi file'.  but this is specific to mod_wsgi, other
> servers do that differently.
>
> --
> Javier

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



Re: Getting Started with Mac OS X

2012-02-28 Thread Praveen Rachabattuni
Hi,

I am using on Mac OS X Lion and its working pretty well.
Seems there is something wrong with your django installation, try 
reinstalling 

$ pip uninstall django
$ pip install django

Hope that helps.

Regards,
Praveen R

On Tuesday, 28 February 2012 06:06:21 UTC+5:30, JChlipala wrote:
>
> Hello, 
>
> I am a Django beginner, and am trying to get Django set up in Mac OS 
> X.  I am going through the tutorial, but getting stuck very early 
> (essentially at the beginning).  I have installed Python and Django. 
> The next instruction is to enter the command "django-admin.py 
> startproject mysite".  When I do this, I get the following error: 
>
> File "", line 1 
> django-admin.py startproject mysite 
> ^ 
>
> SyntaxError:  invalid syntax 
>
> Does anybody know why I am getting this error?  The tutorial has a 
> note for Mac OS X users explaining what to do if you get a "permission 
> denied" error, but that is obviously not what is happening to me. 
>
> Thank you for any help!

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