Re: Custom template tag problem: "No module named models"

2012-11-08 Thread nolurking
I had the same issue, fixed it with a variation on Jim D.'s solution.

import bookmarks

then bookmarks.models.Bookmark.objects.filter(...)

On Tuesday, October 14, 2008 11:38:20 PM UTC-7, Chris Amico wrote:
>
> I have a simple bookmarks model based on the one in James Bennett's  href="http://code.google.com/p/cab/source/browse/trunk/models.py? 
> r=130 
> ">Cab 
> application. I'm using a generic relation so it can 
> live in its own app and a user can bookmark any object on the site 
> (I'm planning on reusing this app on a couple projects). I'm running 
> into a problem creating an {% if_bookmarked %} template tag. 
>
> When I load the tag library I get this error: 'bookmarks' is not a 
> valid tag library: Could not load template library from 
> django.templatetags.bookmarks, No module named models 
>
> Here's what the tag module looks like: 
>
> from django import template 
> from django.contrib.contenttypes.models import ContentType 
> from bookmarks.models import Bookmark 
>
>
> class IfBookmarkedNode(template.Node): 
> def __init__(self, user, obj, nodelist_true, nodelist_false): 
> self.nodelist_true = nodelist_true 
> self.nodelist_false = nodelist_false 
> self.user_id = template.Variable(user_id) 
> self.obj = template.Variable(obj) 
>
> def render(self, context): 
> try: 
> self.user_id = template.resolve_variable(self.user_id, 
> context) 
> self.obj = template.resolve_variable(self.obj, context) 
> except template.VariableDoesNotExist: 
> return '' 
> ctype = ContentType.objects.get_for_model(obj) 
> if Bookmark.objects.filter(content_type=ctype, 
> object_id=obj.id, user__pk=user_id.id): 
> return self.nodelist_true.render(context) 
> else: 
> return self.nodelist_false.render(context) 
>
>
> def do_if_bookmarked(parser, token): 
> bits = token.contents.split() 
> if len(bits) != 3: 
> raise template.TemplateSyntaxError("'%s' tag takes exactly two 
> arguments" % bits[0]) 
> nodelist_true = parser.parse(('else', 'endif_bookmarked')) 
> token = parser.next_token() 
> if token.contents == 'else': 
> nodelist_false = parser.parse(('endif_bookmarked',)) 
> parser.delete_first_token() 
> else: 
> nodelist_false = template.NodeList() 
> return IfBookmarkedNode(bits[1], bits[2], nodelist_true, 
> nodelist_false) 
>
>
> And this is the model it should be importing: 
>
>
> class Bookmark(models.Model): 
> "A bookmarked item, saved by a user with a timestamp" 
> # generic relation 
> content_type = models.ForeignKey(ContentType) 
> object_id = models.PositiveIntegerField() 
> content_object = generic.GenericForeignKey('content_type', 
> 'object_id') 
>
> # who and when 
> user = models.ForeignKey(User) 
> timestamp = models.DateTimeField(auto_now_add=True) 
>
>
>
> The bookmarking model works fine on its own, and I've gotten the 
> functions in the template tag to work in isolation in the interpreter, 
> but when I load the tag library it breaks the template. What am I 
> missing here?

-- 
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/-/Gqnjk38KVP0J.
To post to this group, send email 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 in virtualenv + nginx + uwsgi set up guide

2012-11-08 Thread Chris Pagnutti
Hi.  I'm looking for a recent guide for setting up nginx to serve django 
projects in a virtualenv via uwsgi.  I can find a whole pile of them, but 
they're all so different, and some are dated.  I'm looking for something 
complete and recent that actually works.  Ideally, I'd like it to be for a 
Debian-based system, but I think if the guide is good, I should be able to 
do it for any distro.

Thanks a whole bunch.

-- 
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/-/oqNciN_d9QUJ.
To post to this group, send email 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: tutorial first step. -ImportError: No module named django.core-

2012-11-08 Thread Daniel
Francesco and Elena, 

I read up on virtualenv and to my understanding, what you said was right - 
that it sets the PATH for you just by using it.  One thing that I'm still 
not sure on, is that for Linux, you have to specify the 'source' command 
which will change the environment in place.  I'm not sure if this happens 
automatically on Windows or what.  As for the setting the PATH variable at 
the beginning, that seems like it may work, I'm just hesitant because that 
is used as a system-wide deal, whereas the virtualenv isn't.  The 
distinction eludes me.

In terms of typing out the path for the admin file, I guess it's not really 
that big of a deal, since I won't be making many projects in the near 
future, I just thought there might be a quick fix available.  Thanks for 
the input!

Dan

On Thursday, November 8, 2012 4:22:35 AM UTC-6, elena wrote:
>
> Francesco and Daniel,
>
> This is an interesting problem with the tutorial! We will have to make 
> sure that it's changed -- obviously the tutorial needs to be clearer!
>
> Any suggestions you guys have about how/where we could insert some 
> information that could make this clearer *please* point out where it'd be 
> helpful or better yet write some words (community for-the-win! :) 
>
> Daniel: in response to what you were saying about the location of 
> `django-admin.py` being a hassle I remember when I was learning be 
> concerned by this also! But turns out that nowadays actually I rarely use 
> `django-admin.py` but usually in my set-up keep a copy of it at 
> `~/code/bin/` with a bunch of other useful bits-and-pieces (though this 
> approach is a bit out-dated with virtualenv). Besides starting a new whole 
> project is a pretty big deal (compared to most dev work) and personally I 
> think needing to find django-admin.py for it makes it seem as special as it 
> is.
>
> ---
> Elena :)
> @elequ
>
>
> On Thu, Nov 8, 2012 at 7:29 PM, Francescos 
>  > wrote:
>
>> Good good!
>> So, this means I was executing the wrong django-admin.py file.
>> Daniel, I'm curious about your question, too. Because I though that 
>> activating virtualenv the path is automatically set to the specified 
>> environment and then no need to include the right django-admin.py file into 
>> some environment variable...
>> Anyway, maybe a solution for you is to put, possibly at the beginning, 
>> your django-admin.py path into the PATH variable.
>> Elena we need you... :D
>>
>> Francesco
>>
>> On Thursday, November 8, 2012 3:26:36 AM UTC, Daniel wrote:
>>>
>>> Hi Elena, I actually had the exact same problem Francesco was having.  I 
>>> wasn't able to start a project, and then I tried your question.  The cmd 
>>> line went something like this:
>>>
>>> (env) path/to/directory/python env/Scripts/django-admin.py startproject 
>>> newproject
>>>
>>> It worked!  While I'm happy with the result, I'd like to keep projects 
>>> in the root folder, and typing out the path to django-admin.py every time 
>>> seems like quite a hassle.  Is there a way to point to the file without 
>>> having to specify its location?  All the tutorials and such that I've seen 
>>> online simply use the django-admin.py startproject (name) convention and it 
>>> works fine.
>>>
>>> Dan
>>>
>>> On Monday, November 5, 2012 6:54:18 AM UTC-6, elena wrote:

 Hi Francesco,

 What happens when you try:

 $ cd C:\Python27\fra_env\

 (or whatever the equivalent of this might be in the shell you are using)

 $ python Scripts\django-admin.py startproject mysite

 Regards,
 Elena :)



 On Mon, Nov 5, 2012 at 1:19 AM, Francescos wrote:

> Hi Elena,
>
> Thanks for replying.
> I guess the PATH var is well set. In fact, if I hit python into 
> cmd.exe and then import django everything work (I can print the 
> django version, as well).
> So, Django is installed and reachable apparently. At this point I 
> guess there is a problem in looking for the modules..
> I also guess is important to consider that I am using 
> virtualenv that, 
> once activated, it adds to the PATH this: 
> C:\Python27\fran_env\Scriptswhere is located django-admin.py. This file 
> is also located here: 
> C:\Python27\fra_env\Lib\site-packages\django\bin
>
> Francesco
>
> On Sunday, November 4, 2012 2:07:53 AM UTC, elena wrote:
>
>> Hi Francesco,
>>
>> What you're seeing is the most basic django/python error. It means 
>> that your python can't find django from your current path.
>>
>> You should start by checking for the simple things.
>>
>> What happens when you try putting the following in your terminal?:
>> $ python
>>
>> and then:
>> >>> import django
>>
>> Also where is your django-admin.py file located? 
>>
>> Elena :)
>>
>>
>> ---
>> 

Re: How to call a database function from Django?

2012-11-08 Thread Arnold Krille
On Thursday 08 November 2012 15:17:38 Kurtis Mullins wrote:
> I usually create management commands and call that. Here's the docs:
> https://docs.djangoproject.com/en/dev/howto/custom-management-commands/

As an alternative you can use django_extensions and create a job. Might be to 
much when its just one job. But as soon as your project gets bigger and needs 
several jobs with mixed intervals, its easier.

Have fun,

Arnold

signature.asc
Description: This is a digitally signed message part.


Re: Consume Web Service

2012-11-08 Thread Tim Sawyer
I keep it simple and just create the XML manually.  Works for me on 
simple services.


http://drumcoder.co.uk/blog/2009/nov/23/running-soap-webservice-without-library/

Tim.

On 08/11/12 21:26, Derrick Jackson wrote:

Hi all,

I have a web service that I need to consume.  Do you have
any recommendations as to what I should be using to consume it?
  SoapLIb, Suds, etc...

--
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/-/wHxZM3GF5ysJ.
To post to this group, send email 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.



Consume Web Service

2012-11-08 Thread Derrick Jackson
Hi all,

I have a web service that I need to consume.  Do you have 
any recommendations as to what I should be using to consume it?  SoapLIb, 
Suds, etc...

-- 
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/-/wHxZM3GF5ysJ.
To post to this group, send email 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 call a database function from Django?

2012-11-08 Thread Tom Evans
On Thu, Nov 8, 2012 at 7:41 PM, Andre Lopes  wrote:
> Hi all,
>
> I need to run a script once a day. The script basically will call a
> postgresql function. I've google and I found a solution just like
> this. The problem is that does not work.
>
> [code]
> import os
> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
> from myapp.models import *
>
> MyModelClass.objects.raw("select materialize('some', 't_some_table');")
> [/code]
>
> I've created a file with the code above, but the RAW does not run the
> function "materialize".
>
> There is a better way to call a function using the Django environment?
>
>
>
> Best Regards,
>

You can always get a raw cursor to your database server:

from django.db import connection
cursor = connection.cursor()

Once you have a cursor you can do any PEP 249/Python DB 2.0 API stuff
you want, including raw SQL queries.

As Kurt said, wrap this up in a management command to make it all nice
and pretty.

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: How to call a database function from Django?

2012-11-08 Thread Kurtis Mullins
I usually create management commands and call that. Here's the docs:
https://docs.djangoproject.com/en/dev/howto/custom-management-commands/


On Thu, Nov 8, 2012 at 2:41 PM, Andre Lopes  wrote:

> Hi all,
>
> I need to run a script once a day. The script basically will call a
> postgresql function. I've google and I found a solution just like
> this. The problem is that does not work.
>
> [code]
> import os
> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
> from myapp.models import *
>
> MyModelClass.objects.raw("select materialize('some', 't_some_table');")
> [/code]
>
> I've created a file with the code above, but the RAW does not run the
> function "materialize".
>
> There is a better way to call a function using the Django environment?
>
>
>
> Best 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.
>
>

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



How to call a database function from Django?

2012-11-08 Thread Andre Lopes
Hi all,

I need to run a script once a day. The script basically will call a
postgresql function. I've google and I found a solution just like
this. The problem is that does not work.

[code]
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from myapp.models import *

MyModelClass.objects.raw("select materialize('some', 't_some_table');")
[/code]

I've created a file with the code above, but the RAW does not run the
function "materialize".

There is a better way to call a function using the Django environment?



Best 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: Help with error uploading files

2012-11-08 Thread Carlos Aguilar
The screenshot is captured with chrome extension, then, capture all page
and save to png.

The problem is caused by s3_folder_storages. I am replacing the
DEFAULT_FILE_STORAGE bY s3boto storage.

I think as field is ImageField png or jpg are valid images

Best Regards


On Thu, Nov 8, 2012 at 1:21 PM, Dennis Lee Bieber wrote:

> On Wed, 7 Nov 2012 21:10:06 -0800 (PST), Carlos Aguilar
>  declaimed the following in
> gmane.comp.python.django.user:
>
> > Hello,
> >
> > I am working in a project that requires you upload an image in a model.
> The
> > project was started by other developer.
> >
> > Today testing, without realize changes in the model I am receiving the
> > following error:
> >
> > 'cStringIO.StringO' object has no attribute 'size'
>
> Is that a cut? If it is, I suspect a typo...
>
> >
> > I not have idea what is causing the error, then I appreciate your help to
> > fix this.
> >
> > One screenshot of the error:
> >
> > <
> https://lh6.googleusercontent.com/-duPf2J5ejnI/UJs-gygXKgI/CDA/SmKl6Zk2sPM/s1600/waitress-error.png
> >
>
> What type of screen are you using... Even at "full view" my browser
> shows ant droppings... The text lines are TWO PIXELS tall!
>
> Not to mention you called it a PNG file, but that site is displaying a
> JPEG.
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Carlos Aguilar
Consultor Hardware y Software
DWD
http://www.dwdandsolutions.com
http://www.houseofsysadmin.com
Cel: +50378735118
USA: (301) 337-8541

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

2012-11-08 Thread Kurtis Mullins
(However, I don't know of any ways to crop images before upload ... except
maybe with Flash or Java)


On Thu, Nov 8, 2012 at 1:25 PM, Kurtis Mullins wrote:

> I've used JCrop in combination with a custom Django Form and PIL before. I
> had good results.
>
>
> On Thu, Nov 8, 2012 at 8:09 AM, Gink Labrev  wrote:
>
>> How to crop image before upload ?
>> I found this project:
>> https://github.com/jonasundderwolf/django-image-cropping, but it does
>> not work well.
>> Does someone know other solutions ?
>>
>> 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: How to crop image ?

2012-11-08 Thread Kurtis Mullins
I've used JCrop in combination with a custom Django Form and PIL before. I
had good results.


On Thu, Nov 8, 2012 at 8:09 AM, Gink Labrev  wrote:

> How to crop image before upload ?
> I found this project:
> https://github.com/jonasundderwolf/django-image-cropping, but it does not
> work well.
> Does someone know other solutions ?
>
> 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: Help with error uploading files

2012-11-08 Thread Carlos Aguilar
Yesterday doing few test I note that the problem is causes by the following 
configs

DEFAULT_FILE_STORAGE = 'waitress.apps.venues.storage.CachedS3BotoStorage'
DEFAULT_S3_PATH = "media"

I test 2 file storages one is s3_folder_storages.s3.DefaultStorages.

I am using the same config in other project without problems.

I will appreciate your 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/-/8waBUK8RcFYJ.
To post to this group, send email 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: reading raw binary data from clob columns using oracle backend

2012-11-08 Thread Ian
On Wednesday, November 7, 2012 6:16:23 AM UTC-7, MichaƂ Nowotka wrote:
>
> Hello,
> I'm working with oracle legacy DB and need to read and write binary data 
> (png images, and and MDL *Molfiles*).
> Django's inspectdb command generated text fields for these columns, saying 
> that's only a guess.
> Now, when I'm trying to retrieve a value from this class fields i get:
> DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0x89 in position 
> 0: invalid start byte.
> error. 
>
> Is there any way to read and write these columns?
> Any help would be appreciated.
>

Django has no built-in field type for BLOB columns.  You might try using 
the custom field type given in one of the answers here:

http://stackoverflow.com/questions/5581466/django-models-blob-field

I haven't used this myself, so I can't vouch for how well it will work.

-- 
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/-/4EzQIAYCLjQJ.
To post to this group, send email 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: Reverse of admin:jsi18n

2012-11-08 Thread Dan Gentry
Correction:

My URL tag does not include the quotes.  Should be:

{% url admin:jsi18n %}

-- 
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/-/ifbpxbJtw_wJ.
To post to this group, send email 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.



Reverse of admin:jsi18n

2012-11-08 Thread Dan Gentry
Using Django 1.3, I'm declaring a javascript file in the Media class of a 
ModelForm.  For the jsi18n javascript catalog, the examples show the path 
hard coded:

js = ('/admin/jsi18n/')

However, I want to make this a little more portable by replacing the path 
with a reverse() call.  I tried this:

js = (reverse('admin:jsi18n'))

which failed when the form was imported.  However, I can use the same 
argument in a URL call in the template:

{% url 'admin:jsi18n' %}

Any advice on how I can use reverse() in the Media class?  I haven't found 
anything helpful in my searches.

Thanks,

Dan Gentry

-- 
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/-/WUsQvc_QxKAJ.
To post to this group, send email 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: tutorial first step. -ImportError: No module named django.core-

2012-11-08 Thread Francesco Serafini
Elena,

I think the place where should be put a warning about which django-admin.py
script has to be run is
here.
Hence when the reader is going to install virtualenv.
Hoping this help

Franz


2012/11/8 Elena Williams 

> Francesco and Daniel,
>
> This is an interesting problem with the tutorial! We will have to make
> sure that it's changed -- obviously the tutorial needs to be clearer!
>
> Any suggestions you guys have about how/where we could insert some
> information that could make this clearer *please* point out where it'd be
> helpful or better yet write some words (community for-the-win! :)
>
> Daniel: in response to what you were saying about the location of
> `django-admin.py` being a hassle I remember when I was learning be
> concerned by this also! But turns out that nowadays actually I rarely use
> `django-admin.py` but usually in my set-up keep a copy of it at
> `~/code/bin/` with a bunch of other useful bits-and-pieces (though this
> approach is a bit out-dated with virtualenv). Besides starting a new whole
> project is a pretty big deal (compared to most dev work) and personally I
> think needing to find django-admin.py for it makes it seem as special as it
> is.
>
> ---
> Elena :)
> @elequ
>
>
> On Thu, Nov 8, 2012 at 7:29 PM, Francescos 
> wrote:
>
>> Good good!
>> So, this means I was executing the wrong django-admin.py file.
>> Daniel, I'm curious about your question, too. Because I though that
>> activating virtualenv the path is automatically set to the specified
>> environment and then no need to include the right django-admin.py file into
>> some environment variable...
>> Anyway, maybe a solution for you is to put, possibly at the beginning,
>> your django-admin.py path into the PATH variable.
>> Elena we need you... :D
>>
>> Francesco
>>
>> On Thursday, November 8, 2012 3:26:36 AM UTC, Daniel wrote:
>>>
>>> Hi Elena, I actually had the exact same problem Francesco was having.  I
>>> wasn't able to start a project, and then I tried your question.  The cmd
>>> line went something like this:
>>>
>>> (env) path/to/directory/python env/Scripts/django-admin.py startproject
>>> newproject
>>>
>>> It worked!  While I'm happy with the result, I'd like to keep projects
>>> in the root folder, and typing out the path to django-admin.py every time
>>> seems like quite a hassle.  Is there a way to point to the file without
>>> having to specify its location?  All the tutorials and such that I've seen
>>> online simply use the django-admin.py startproject (name) convention and it
>>> works fine.
>>>
>>> Dan
>>>
>>> On Monday, November 5, 2012 6:54:18 AM UTC-6, elena wrote:

 Hi Francesco,

 What happens when you try:

 $ cd C:\Python27\fra_env\

 (or whatever the equivalent of this might be in the shell you are using)

 $ python Scripts\django-admin.py startproject mysite

 Regards,
 Elena :)



 On Mon, Nov 5, 2012 at 1:19 AM, Francescos wrote:

> Hi Elena,
>
> Thanks for replying.
> I guess the PATH var is well set. In fact, if I hit python into
> cmd.exe and then import django everything work (I can print the
> django version, as well).
> So, Django is installed and reachable apparently. At this point I
> guess there is a problem in looking for the modules..
> I also guess is important to consider that I am using 
> virtualenv that,
> once activated, it adds to the PATH this: 
> C:\Python27\fran_env\Scriptswhere is located django-admin.py. This file 
> is also located here:
> C:\Python27\fra_env\Lib\site-packages\django\bin
>
> Francesco
>
> On Sunday, November 4, 2012 2:07:53 AM UTC, elena wrote:
>
>> Hi Francesco,
>>
>> What you're seeing is the most basic django/python error. It means
>> that your python can't find django from your current path.
>>
>> You should start by checking for the simple things.
>>
>> What happens when you try putting the following in your terminal?:
>> $ python
>>
>> and then:
>> >>> import django
>>
>> Also where is your django-admin.py file located?
>>
>> Elena :)
>>
>>
>> ---
>> Elena :)
>> @elequ
>> 04022 90172
>>
>>
>>
>> On Sun, Nov 4, 2012 at 6:24 AM, Francescos wrote:
>>
>>>  Hello everyone,
>>> Following the django tut I've sat up all the installation and
>>> reached the step where I had to run the command: django-admin.py
>>> startproject mysite
>>> result: I receive the error specified in the subject.
>>> I installed virtualenv (as said 
>>> here)
>>> and activate it 

Re: 1.5: syntax of AUTH_USER_MODEL

2012-11-08 Thread Michael K


On Monday, October 29, 2012 11:09:11 AM UTC-4, Tomas Neme wrote:
>
>
> This is, IMO, the biggest and most stupid problem in django core 
> design, because it stops you from having an otherwise completely legal 
> configurations, like having a 'cms.plugins.picture' app alongside a 
> 'myproject.custom.picture' one which might do something completely 
> different. I.E.: you can't have apps with repeated app labels even if 
> there's no python path conflict between them. 
>
> I don't know what the reason behind this is. I know it allows you to 
> make a model part of any given app regardless of where it's located 
> (via Meta.app_label), but this could very easily be extended (in a 
> backwards-incompatible way, I'm afraid) to require to be the fully 
> qualified name of the app package 
>
>
>
This is actually a good feature for Django to have.  By enforcing app 
labels, you enforce data integrity at the application level, not just the 
database level.  I used to think this was horrible as well until I built a 
work-around for it and then had all kinds of database integrity issues.

In addition, if an application by the same name is being used in multiple 
places, you should instead manage the different use with URL patterns and 
not try to rig it otherwise.  If it's a completely different application 
than the others, the option I choose is to rename the app's folder and 
update my INSTALLED_APPS accordingly.  If you didn't write the application 
and it's not truly decoupled, you may have to make other changes.


--Michael

-- 
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/-/rgOnguKNJUQJ.
To post to this group, send email 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.



coding advise / associating a class with a table row

2012-11-08 Thread Gene Horodecki
Hi there,  I seem to find a particular scenario a lot and I'm wondering 
if someone can help me with it.  I'm working on a project where I am 
selecting from a series of actions to take on a server. These actions 
need to be defined in a child class because there is code associated 
with them.  However, because I want to select them in a form it benefits 
me to have a row in a table with a description for each action.  Is 
there any elegant way that people have used to couple a table row with a 
python class?  The only way I can think of is to hard code the 
relationships between rows and classes but it seems a brutal way of 
doing it.  I could put the name of the class in a field in the table but 
that doesn't seem quite right either.


What would be nice is something like the @register decorator so that 
each class registers with the 'name' field in its row and a dictionary 
could be built when the server is started, but I cannot find any 
information on how to create another decorator that works like @register.


Any other ideas?  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: Access queryset in get_context_data()?

2012-11-08 Thread Arturo Fernandez
Hi!

You can use access to queryset through kwargs dictionary:

qs = kwargs['object_list']

Don't forget that *object_list *is the variable used by Django's class view.

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



How to crop image ?

2012-11-08 Thread Gink Labrev
How to crop image before upload ?
I found this project:
https://github.com/jonasundderwolf/django-image-cropping, but it does not
work well.
Does someone know other solutions ?

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: tutorial first step. -ImportError: No module named django.core-

2012-11-08 Thread Elena Williams
Francesco and Daniel,

This is an interesting problem with the tutorial! We will have to make sure
that it's changed -- obviously the tutorial needs to be clearer!

Any suggestions you guys have about how/where we could insert some
information that could make this clearer *please* point out where it'd be
helpful or better yet write some words (community for-the-win! :)

Daniel: in response to what you were saying about the location of
`django-admin.py` being a hassle I remember when I was learning be
concerned by this also! But turns out that nowadays actually I rarely use
`django-admin.py` but usually in my set-up keep a copy of it at
`~/code/bin/` with a bunch of other useful bits-and-pieces (though this
approach is a bit out-dated with virtualenv). Besides starting a new whole
project is a pretty big deal (compared to most dev work) and personally I
think needing to find django-admin.py for it makes it seem as special as it
is.

---
Elena :)
@elequ


On Thu, Nov 8, 2012 at 7:29 PM, Francescos wrote:

> Good good!
> So, this means I was executing the wrong django-admin.py file.
> Daniel, I'm curious about your question, too. Because I though that
> activating virtualenv the path is automatically set to the specified
> environment and then no need to include the right django-admin.py file into
> some environment variable...
> Anyway, maybe a solution for you is to put, possibly at the beginning,
> your django-admin.py path into the PATH variable.
> Elena we need you... :D
>
> Francesco
>
> On Thursday, November 8, 2012 3:26:36 AM UTC, Daniel wrote:
>>
>> Hi Elena, I actually had the exact same problem Francesco was having.  I
>> wasn't able to start a project, and then I tried your question.  The cmd
>> line went something like this:
>>
>> (env) path/to/directory/python env/Scripts/django-admin.py startproject
>> newproject
>>
>> It worked!  While I'm happy with the result, I'd like to keep projects in
>> the root folder, and typing out the path to django-admin.py every time
>> seems like quite a hassle.  Is there a way to point to the file without
>> having to specify its location?  All the tutorials and such that I've seen
>> online simply use the django-admin.py startproject (name) convention and it
>> works fine.
>>
>> Dan
>>
>> On Monday, November 5, 2012 6:54:18 AM UTC-6, elena wrote:
>>>
>>> Hi Francesco,
>>>
>>> What happens when you try:
>>>
>>> $ cd C:\Python27\fra_env\
>>>
>>> (or whatever the equivalent of this might be in the shell you are using)
>>>
>>> $ python Scripts\django-admin.py startproject mysite
>>>
>>> Regards,
>>> Elena :)
>>>
>>>
>>>
>>> On Mon, Nov 5, 2012 at 1:19 AM, Francescos wrote:
>>>
 Hi Elena,

 Thanks for replying.
 I guess the PATH var is well set. In fact, if I hit python into
 cmd.exe and then import django everything work (I can print the django
 version, as well).
 So, Django is installed and reachable apparently. At this point I guess
 there is a problem in looking for the modules..
 I also guess is important to consider that I am using 
 virtualenv that,
 once activated, it adds to the PATH this: 
 C:\Python27\fran_env\Scriptswhere is located django-admin.py. This file is 
 also located here:
 C:\Python27\fra_env\Lib\site-packages\django\bin

 Francesco

 On Sunday, November 4, 2012 2:07:53 AM UTC, elena wrote:

> Hi Francesco,
>
> What you're seeing is the most basic django/python error. It means
> that your python can't find django from your current path.
>
> You should start by checking for the simple things.
>
> What happens when you try putting the following in your terminal?:
> $ python
>
> and then:
> >>> import django
>
> Also where is your django-admin.py file located?
>
> Elena :)
>
>
> ---
> Elena :)
> @elequ
> 04022 90172
>
>
>
> On Sun, Nov 4, 2012 at 6:24 AM, Francescos wrote:
>
>>  Hello everyone,
>> Following the django tut I've sat up all the installation and reached
>> the step where I had to run the command: django-admin.py
>> startproject mysite
>> result: I receive the error specified in the subject.
>> I installed virtualenv (as said 
>> here)
>> and activate it before running the command django-admin.py
>> startproject mysite.
>> Any suggestion for this problem? Thanks everyone.
>> Configuration:
>> - Windows 7 & cmd.exe
>> - Python2.7
>> - virtualenviroment at: C:\Python27\fra_env\
>> - PATH contains: C:\Python27\fra_env\Scripts
>> - django-admin.py is in C:\Python27\fra_env\Scripts AND
>> C:\Python27\fra_env\Lib\**si**te-packages\django\bin
>>
>> I hope someone can help me!
>> 

Re: tutorial first step. -ImportError: No module named django.core-

2012-11-08 Thread Francescos
Good good!
So, this means I was executing the wrong django-admin.py file.
Daniel, I'm curious about your question, too. Because I though that 
activating virtualenv the path is automatically set to the specified 
environment and then no need to include the right django-admin.py file into 
some environment variable...
Anyway, maybe a solution for you is to put, possibly at the beginning, your 
django-admin.py path into the PATH variable.
Elena we need you... :D

Francesco

On Thursday, November 8, 2012 3:26:36 AM UTC, Daniel wrote:
>
> Hi Elena, I actually had the exact same problem Francesco was having.  I 
> wasn't able to start a project, and then I tried your question.  The cmd 
> line went something like this:
>
> (env) path/to/directory/python env/Scripts/django-admin.py startproject 
> newproject
>
> It worked!  While I'm happy with the result, I'd like to keep projects in 
> the root folder, and typing out the path to django-admin.py every time 
> seems like quite a hassle.  Is there a way to point to the file without 
> having to specify its location?  All the tutorials and such that I've seen 
> online simply use the django-admin.py startproject (name) convention and it 
> works fine.
>
> Dan
>
> On Monday, November 5, 2012 6:54:18 AM UTC-6, elena wrote:
>>
>> Hi Francesco,
>>
>> What happens when you try:
>>
>> $ cd C:\Python27\fra_env\
>>
>> (or whatever the equivalent of this might be in the shell you are using)
>>
>> $ python Scripts\django-admin.py startproject mysite
>>
>> Regards,
>> Elena :)
>>
>>
>>
>> On Mon, Nov 5, 2012 at 1:19 AM, Francescos wrote:
>>
>>> Hi Elena,
>>>
>>> Thanks for replying.
>>> I guess the PATH var is well set. In fact, if I hit python into cmd.exe 
>>> and then import django everything work (I can print the django version, 
>>> as well).
>>> So, Django is installed and reachable apparently. At this point I guess 
>>> there is a problem in looking for the modules..
>>> I also guess is important to consider that I am using 
>>> virtualenv that, 
>>> once activated, it adds to the PATH this: C:\Python27\fran_env\Scriptswhere 
>>> is located django-admin.py. This file is also located here: 
>>> C:\Python27\fra_env\Lib\**site-packages\django\bin
>>>
>>> Francesco
>>>
>>> On Sunday, November 4, 2012 2:07:53 AM UTC, elena wrote:
>>>
 Hi Francesco,

 What you're seeing is the most basic django/python error. It means that 
 your python can't find django from your current path.

 You should start by checking for the simple things.

 What happens when you try putting the following in your terminal?:
 $ python

 and then:
 >>> import django

 Also where is your django-admin.py file located? 

 Elena :)


 ---
 Elena :)
 @elequ
 04022 90172



 On Sun, Nov 4, 2012 at 6:24 AM, Francescos wrote:

>  Hello everyone,
> Following the django tut I've sat up all the installation and reached 
> the step where I had to run the command: django-admin.py startproject 
> mysite
> result: I receive the error specified in the subject.
> I installed virtualenv (as said 
> here)
>  
> and activate it before running the command django-admin.py 
> startproject mysite.
> Any suggestion for this problem? Thanks everyone.
> Configuration:
> - Windows 7 & cmd.exe
> - Python2.7
> - virtualenviroment at: C:\Python27\fra_env\
> - PATH contains: C:\Python27\fra_env\**Scripts
> - django-admin.py is in C:\Python27\fra_env\Scripts AND 
> C:\Python27\fra_env\Lib\**site-packages\django\bin
>
> I hope someone can help me!
> Francesco
>
> -- 
> 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/-/v_**l9HV306cIJ
> .
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@**
> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/kmyIAnk7cYcJ.
>>>
>>> To post to this group, send email to django...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.