Django 1.5 static files strangeness

2012-04-04 Thread Mike Dewhirst
I'm getting odd static files 404 behaviour switching to DEBUG = False on 
my Windows XP dev machine.


My staging server is Linux running under Apache and the same code and 
the same version of Django and that is running fine with DEBUG = FALSE


See the 200 versus 404 info below ...

 manage.py runserver DEBUG = False ###
Validating models...

0 errors found
Django version 1.5.dev17868, using settings 'strxs.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[05/Apr/2012 14:29:20] "GET /admin/company/company/2/ HTTP/1.1" 200 85287
[05/Apr/2012 14:29:21] "GET /admin/jsi18n/ HTTP/1.1" 200 2158
[05/Apr/2012 14:29:21] "GET /static/css/darker.css HTTP/1.1" 404 504
[05/Apr/2012 14:29:21] "GET /static/js/tiny_mce/tiny_mce.js HTTP/1.1" 
404 504
[05/Apr/2012 14:29:23] "GET /static/js/tiny_mce/tiny_mce.js HTTP/1.1" 
404 504

###


Note that when DEBUG = True a number of settings are printed.
 manage.py runserver DEBUG = True ###
SETTINGS_DIR   = C:/users/miked/py/strxs/strxs
APP_ROOT   = C:/users/miked/py/strxs  (root for all 
app dirs)

FIXTURE_DIRS   = C:/users/miked/py/strxs/fixtures
MEDIA_ROOT = /srv/www/strxs/media/(store 
uploaded images etc)
MEDIA_URL  = /media/ (to serve 
uploaded images)
STATIC_ROOT= /srv/www/strxs/static/   (collectstatic 
destination)
STATIC_URL = /static/(to serve css, 
js etc)

STATICFILES_DIRS#1 = C:/users/miked/py/strxs/static/
STATICFILES_DIRS#2 = C:/users/miked/py/strxs/company/static/
TEMPLATE_DIRS#1= C:/users/miked/py/strxs/templates/

Validating models...

0 errors found
Django version 1.5.dev17868, using settings 'strxs.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[05/Apr/2012 14:30:18] "GET /admin/company/company/2/ HTTP/1.1" 200 85271
[05/Apr/2012 14:30:19] "GET /static/css/darker.css HTTP/1.1" 200 274
[05/Apr/2012 14:30:19] "GET /admin/jsi18n/ HTTP/1.1" 200 2158
[05/Apr/2012 14:30:20] "GET /static/js/tiny_mce/tiny_mce.js HTTP/1.1" 
200 207762

###

The workaround is obviously to use DEBUG = True on the dev machine

Might be a bug

Mike

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

2012-04-04 Thread Alec Taylor
Unknown command: 'collectstatic'

Note: I am running the latest official build of Django (1.4) with the
latest dev build of django-staticfiles.

Also of relevance:
> python manage.py help | grep -i "static"
satchmo_copy_static

(yes, I am running a satchmo shop)

On Thu, Apr 5, 2012 at 11:13 AM, swiharta  wrote:
> I had to upgrade my version of django-staticfiles and do collectstatic. Hope
> that helps.
>
>
> On Thursday, February 2, 2012 12:26:47 PM UTC-5, Alec Taylor wrote:
>>
>> Trunk version cannot load Admin CSS.
>>
>> First I tried setting the ADMIN_MEDIA_PREFIX to MEDIA_PREFIX, when
>> that didn't work I tried manual replacing. Yes, I know it has been
>> depreciated and that the css are stored in
>> django\django\contrib\admin\static\admin\css, however it did not work
>> when omitted so I placed that \static\admin\ folder as a subdirectory
>> of my regular static directory.
>>
>> ADMIN_MEDIA_PREFIX is now set to: '/static/admin/' in settings.py.
>>
>> This partially worked, the top of my admin pages now look like this:
>> 
>> > href="/static/admin/css/dashboard.css"/>
>>
>> So dashboard.css is loading fine now, it's just base.css which isn't.
>>
>> How should I go about getting that base.css link to not 404, or
>> *actually* changing that ADMIN_MEDIA_PREFIX?
>>
>> Thanks for all suggestions,
>>
>> Alec Taylor
>
> --
> 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/-/uT6xUVl_99gJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: twitter

2012-04-04 Thread Ovnicraft
On Wed, Apr 4, 2012 at 8:13 PM, Randa Hisham  wrote:

> hey
> iam looking for django app that working with twitter stream api,any
> recommends?
>

Hello i recommend you use
https://dev.twitter.com/docs/twitter-libraries#python and integrate with
you django project.

Regards,

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



-- 
Cristian Salamea
@ovnicraft

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



twitter

2012-04-04 Thread Randa Hisham
hey
iam looking for django app that working with twitter stream api,any
recommends?

-- 
Randa Hesham
Software Developer

Twitter:@ro0oraa 
FaceBook:Randa Hisham 

ٍ

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

2012-04-04 Thread swiharta
I had to upgrade my version of django-staticfiles and do collectstatic. 
Hope that helps.

On Thursday, February 2, 2012 12:26:47 PM UTC-5, Alec Taylor wrote:
>
> Trunk version cannot load Admin CSS.
>
> First I tried setting the ADMIN_MEDIA_PREFIX to MEDIA_PREFIX, when
> that didn't work I tried manual replacing. Yes, I know it has been
> depreciated and that the css are stored in
> django\django\contrib\admin\static\admin\css, however it did not work
> when omitted so I placed that \static\admin\ folder as a subdirectory
> of my regular static directory.
>
> ADMIN_MEDIA_PREFIX is now set to: '/static/admin/' in settings.py.
>
> This partially worked, the top of my admin pages now look like this:
> 
>  href="/static/admin/css/dashboard.css"/>
>
> So dashboard.css is loading fine now, it's just base.css which isn't.
>
> How should I go about getting that base.css link to not 404, or
> *actually* changing that ADMIN_MEDIA_PREFIX?
>
> Thanks for all suggestions,
>
> Alec Taylor
>
>

-- 
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/-/uT6xUVl_99gJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 add audio to a Django based webpage?

2012-04-04 Thread Andy McKay
On Wed, Apr 4, 2012 at 12:50 PM, Homer  wrote:

> Should I add something else so that it would work? Thanks for your help!

There's nothing I've seen yet that's a Django problem. Does the
outputted HTML look right? Does that work? If not tell us and we'll
see if we can help you figure out how your Django templating isn't
outputting the right value.

I'll also recommend the HTML audio tag.

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



Upgrading from django 1.3 to django 1.4 -- timezone support

2012-04-04 Thread Rajat Jain
Hi,

I have a MySQL 5.5 backend and I use it via the Django 1.3 framework. I am 
trying to switch to Django 1.4, but want to know how it will affect me. 
Currently I store all the timezones in PST.

As far as I understand from reading the documents, if I upgrade to 1.4 and 
keep the USE_TZ = False option in my settings.py, then my app should work 
as it worked in 1.3 and no side effect should occur. Am I correct?

Thanks,
Rajat

-- 
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/-/GXd_GOuoEDwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: custom manager to control access

2012-04-04 Thread Mike Dewhirst

Anssi

Thanks for that - I'll do some testing.

I'm also thinking of middleware to look at the request and discover the 
company on the way in so I can make it available to everything which 
processes the request and produces a response.


Cheers

Mike


On 4/04/2012 5:55pm, akaariai wrote:

On Apr 4, 3:15 am, Mike Dewhirst  wrote:

I have now discarded the idea :)

I'm not very comfortable with thread locals. I need a bullet-proof
approach which makes data from other companies invisible to members of
this company. I suppose a view decorator is the way to go but I would
have preferred a deeper model-level approach.

You have two ways to pass this kind of information around:
   1. explicitly as parameters
   2. using thread locals (or other "global state").

So, you need to use explicit parameters. You should do something like
this:

class MemberManager(models.Manager):
 def visible_for_user(self, user):
 # Replace the below filter condition with appropriate logic.
 return self.get_query_set().filter(company=user.company)

Now, instead of using Member.objects.all() you should use
Member.objects.visible_for_user(request.user) in your code. I think
you can set the manager default for relations, so that you could do
group.membership.visible_for_user(request.user), but I haven't ever
done that. You will need to be careful when coding so that you don't
accidentally show or modify data from other companies. The way I would
do this is have the logic in the Model/Manager classes, and then use
that logic in your view code.

  - 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 Model - create a filter and use it as argument

2012-04-04 Thread akaariai
On Apr 5, 1:00 am, Ivo Marcelo Leonardi Zaniolo 
wrote:
> Hi there,
>
> I'm need to pass a QuerySet as an argument, like a function pointer that
> will be
> evaluate in other time. Somebody has one idea how I can do this?
> I dont want to create a "box" method to encapsulate it.
>
> So, can anyone help me?

QuerySets are evaluated only when accessed. So, you can just do:

def method(qs):
qs = qs.filter(somethingelse=bar)
list(qs)

qs = SomeModel.objects.filter(something=foo)
method(qs)

The queryset will be evaluated at list(qs) time.

 - 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: How to add audio to a Django based webpage?

2012-04-04 Thread Joel Goldstick
On Wed, Apr 4, 2012 at 3:50 PM, Homer  wrote:
> I tried to use  command in my templates directly, but it seems it is
> not working... Here is my code:
> {% for item in ShowAudio %}
> 

Re: Django Contrib Auth + Class Based Generic Views

2012-04-04 Thread Matheus Ashton
Ok, Thanks for the advices :) but I still have the original problem, when i
access the HomeView the template is rendered with a render_to_response
view, with a simple Context object and not a RequestContext object, because
of that I do not have the authenticated user data in my template...

2012/4/4 Sergiy Khohlov 

> Sound good!
> Usually  project is not so simple (only url.py + settings.py)
>
> 2012/4/4 Javier Guerra Giraldez :
> > On Wed, Apr 4, 2012 at 4:14 AM, Sergiy Khohlov 
> wrote:
> >> As result  your views.py should be :
> >>
> >> from django.views.generic import TemplateView
> >> # Create your views here.
> >> class HomeView(TemplateView):
> >>template_name='home.html'
> >>
> >>  Only three lines of the code !
> >> You dont  need more!
> >
> > if in urls.py you replace
> >
> >  (r'^$', login_required(HomeView.as_view())),
> >
> > with
> >  (r'^$',
> login_required(TemplateView(template_name='home.html').as_view())),
> >
> >
> > you don't need any HomeView class!
> >
> >
> > --
> > Javier
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Image Cropping in template form

2012-04-04 Thread Patrick Sweet
Hi folks, I'm hoping someone can help me with this. I can't get the
image_cropping widget to work in my template.

I've installed django-image-cropping (
https://github.com/jonasundderwolf/django-image-cropping ) and have set up
my models appropriately. It works absolutely perfect in the admin, but I
can't seem to get it to work with a front-end form in a template.

Digging around for information, I've tried to import image_cropping.widgets
and assign the ImageCropWidget to the cropping field, but the form field
still shows up as a text input.
*
FROM Forms.py:*
class ProfileForm(forms.ModelForm):
class Meta:
model = Candidate
exclude = ('user')
widgets = {
'cropping': ImageCropWidget(),
}

And in my template, I'm calling the form field directly, not "as_p" or
"as_table."
*FROM form.html:*

{{ Form.cropping.errors }}
{{ Form.cropping }}



Any help would be greatly appreciated.

- Pat

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

2012-04-04 Thread Diego Schulz
On Wed, Apr 4, 2012 at 3:47 PM, Martin Sommer  wrote:
> I have Python and Django properly installed, but am not getting the
> first project to work. When I do this:
>
> python manage.py runserver
>
> ... I get this:
>
> Traceback (most recent call last):
>  File "manage.py", line 14, in ?
>    execute_manager(settings)
>  File "/usr/lib/python2.4/site-packages/django/core/management/
> __init__.py", line 438, in execute_manager
>    utility.execute()
>  File "/usr/lib/python2.4/site-packages/django/core/management/
> __init__.py", line 379, in execute
>    self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/usr/lib/python2.4/site-packages/django/core/management/
> base.py", line 191, in run_from_argv
>    self.execute(*args, **options.__dict__)
>  File "/usr/lib/python2.4/site-packages/django/core/management/
> base.py", line 209, in execute
>    translation.activate('en-us')
>  File "/usr/lib/python2.4/site-packages/django/utils/translation/
> __init__.py", line 100, in activate
>    return _trans.activate(language)
>  File "/usr/lib/python2.4/site-packages/django/utils/translation/
> __init__.py", line 43, in __getattr__
>    if settings.USE_I18N:
>  File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
> line 276, in __getattr__
>    self._setup()
>  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
> line 42, in _setup
>    self._wrapped = Settings(settings_module)
>  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
> line 139, in __init__
>    logging_config_func(self.LOGGING)
>  File "/usr/lib/python2.4/site-packages/django/utils/dictconfig.py",
> line 553, in dictConfig
>    dictConfigClass(config).configure()
>  File "/usr/lib/python2.4/site-packages/django/utils/dictconfig.py",
> line 321, in configure
>    del logging._handlerList[:]
> AttributeError: 'module' object has no attribute '_handlerList'
>
> Any ideas?

Is this a Django 1.4 installation? I ask that because it looks like
you have Python 2.4,
and Django 1.4 will NOT work with Python 2.4, requires at least Python 2.5.

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.



How to add audio to a Django based webpage?

2012-04-04 Thread Homer
I tried to use  command in my templates directly, but it seems it 
is not working... Here is my code:
{% for item in ShowAudio %}

Difficult setup on Suse Linux

2012-04-04 Thread Martin Sommer
I have Python and Django properly installed, but am not getting the
first project to work. When I do this:

python manage.py runserver

... I get this:

Traceback (most recent call last):
  File "manage.py", line 14, in ?
execute_manager(settings)
  File "/usr/lib/python2.4/site-packages/django/core/management/
__init__.py", line 438, in execute_manager
utility.execute()
  File "/usr/lib/python2.4/site-packages/django/core/management/
__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.4/site-packages/django/core/management/
base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.4/site-packages/django/core/management/
base.py", line 209, in execute
translation.activate('en-us')
  File "/usr/lib/python2.4/site-packages/django/utils/translation/
__init__.py", line 100, in activate
return _trans.activate(language)
  File "/usr/lib/python2.4/site-packages/django/utils/translation/
__init__.py", line 43, in __getattr__
if settings.USE_I18N:
  File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
line 276, in __getattr__
self._setup()
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
line 42, in _setup
self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
line 139, in __init__
logging_config_func(self.LOGGING)
  File "/usr/lib/python2.4/site-packages/django/utils/dictconfig.py",
line 553, in dictConfig
dictConfigClass(config).configure()
  File "/usr/lib/python2.4/site-packages/django/utils/dictconfig.py",
line 321, in configure
del logging._handlerList[:]
AttributeError: 'module' object has no attribute '_handlerList'

Any ideas?

Thanks,
Martin

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



Re: Problem with Django tutorial

2012-04-04 Thread maxim
Continuing on in the tutorial, I got to the part where it explains how to 
use the admin site. It seems that after enabling the admin, it cannot find 
the css files it uses, so the web page looks very strange.

When making a request for an admin page I get the following output from the 
runserver:
[04/Apr/2012 14:36:12] "GET /admin/ HTTP/1.1" 200 3740
[04/Apr/2012 14:36:13] "GET /admin/admin/css/base.css HTTP/1.1" 404 3861
[04/Apr/2012 14:36:13] "GET /admin/admin/css/dashboard.css HTTP/1.1" 404 
3876

Which seems to indicate that it can't find base.css and dashboard.css.

I tried following the steps in the Customizing Admin Look and feel to get 
custom templates working to change the urls, but with no luck.
How do I get the default admin to find its css files?


On Wednesday, 4 April 2012 12:51:39 UTC-4, maxim wrote:
>
> I can't get the tutorial working for me. When I try to run the command:
> python manage.py syncdb
>
> I get this error:
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 443, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 382, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
> line 196, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
> line 232, in execute
> output = self.handle(*args, **options)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
> line 371, in handle
> return self.handle_noargs(**options)
>   File 
> "/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", 
> line 57, in handle_noargs
> cursor = connection.cursor()
>   File 
> "/usr/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 
> 15, in complain
> raise ImproperlyConfigured("settings.DATABASES is improperly 
> configured. "
> django.core.exceptions.ImproperlyConfigured: settings.DATABASES is 
> improperly configured. Please supply the ENGINE value. Check settings 
> documentation for more details.
>
> My settings file has this for databases:
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3', # Add 
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': '/home/maxim/mysite/mysite.db',  # Or 
> path to database file if using sqlite3.
> 'USER': '',  # Not used with sqlite3.
> 'PASSWORD': '',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for 
> localhost. Not used with sqlite3.
> 'PORT': '',  # Set to empty string for 
> default. Not used with sqlite3.
> }
> }
>
>
>

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



Re: Problem with Django tutorial

2012-04-04 Thread maxim
Ah, thank you. Your answer fixed the problem.

On Wednesday, 4 April 2012 13:25:19 UTC-4, JoeLinux wrote:
>
> The correct answer is that the default project layout has changed. See my 
> previous email. Let me know if that works!
> --
> Joey "JoeLinux" Espinosa*
> *
>  
> 
>
>
>
> On Wed, Apr 4, 2012 at 1:24 PM, maxim  wrote:
>
>> No, I tried removing the file, creating it with touch and I also used 
>> sqlite3 to create a table in there to make sure it actually has some 
>> database in there:
>> sqlite3 /home/maxim/mysite/mysite.db
>> SQLite version 3.6.23.1
>> Enter ".help" for instructions
>> Enter SQL statements terminated with a ";"
>> sqlite> .schema
>> CREATE TABLE my_table (id int);
>>
>> I still get that error in all cases.
>>
>> On Wednesday, 4 April 2012 13:19:13 UTC-4, creecode wrote:
>>>
>>> Hello maxim,
>>>
>>> On Wednesday, April 4, 2012 9:51:39 AM UTC-7, maxim wrote:
>>>
>>> I can't get the tutorial working for me. When I try to run the command:
 python manage.py syncdb

>>>  
>>>
 My settings file has this for databases:

>>>  
>>>
 'NAME': '/home/maxim/mysite/mysite.db'**, 
  # Or path to database file if using sqlite3.

>>>
>>> I'm not sure but could it be there is no file at 
>>> /home/maxim/mysite/mysite.db ?  If not you might try to touch that path and 
>>> then try your syncdb.  It looks like are are on some kind of unix/linux 
>>> variant so you probably have a touch command.
>>>
>>> Toodle-looo..
>>> creecode
>>>
>>  -- 
>> 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/-/R2FY3gjMxH0J.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/scumR4YKrlEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problem with Django tutorial

2012-04-04 Thread Joey Espinosa
The correct answer is that the default project layout has changed. See my
previous email. Let me know if that works!
--
Joey "JoeLinux" Espinosa*
*





On Wed, Apr 4, 2012 at 1:24 PM, maxim  wrote:

> No, I tried removing the file, creating it with touch and I also used
> sqlite3 to create a table in there to make sure it actually has some
> database in there:
> sqlite3 /home/maxim/mysite/mysite.db
> SQLite version 3.6.23.1
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite> .schema
> CREATE TABLE my_table (id int);
>
> I still get that error in all cases.
>
> On Wednesday, 4 April 2012 13:19:13 UTC-4, creecode wrote:
>>
>> Hello maxim,
>>
>> On Wednesday, April 4, 2012 9:51:39 AM UTC-7, maxim wrote:
>>
>> I can't get the tutorial working for me. When I try to run the command:
>>> python manage.py syncdb
>>>
>>
>>
>>> My settings file has this for databases:
>>>
>>
>>
>>> 'NAME': '/home/maxim/mysite/mysite.db'**,
>>>  # Or path to database file if using sqlite3.
>>>
>>
>> I'm not sure but could it be there is no file at
>> /home/maxim/mysite/mysite.db ?  If not you might try to touch that path and
>> then try your syncdb.  It looks like are are on some kind of unix/linux
>> variant so you probably have a touch command.
>>
>> Toodle-looo..
>> creecode
>>
>  --
> 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/-/R2FY3gjMxH0J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Problem with Django tutorial

2012-04-04 Thread Joey Espinosa
Which settings.py file are you modifying? I had this problem at first too
when I didn't read about Django's changes from 1.3 to 1.4. Here's an
excerpt from
https://docs.djangoproject.com/en/1.4/releases/1.4/#updated-default-project-layout-and-manage-py
 :

Django 1.4 ships with an updated default project layout and manage.py file
> for the 
> startproject
>  management
> command. These fix some issues with the previous manage.py handling of
> Python import paths that caused double imports, trouble moving from
> development to deployment, and other difficult-to-debug path issues.



manage.py
mysite/
__init__.py
settings.py
urls.py
myapp/
__init__.py
models.py

So basically, now there's a directory inside the project directory with the
same name:

$ django-admin.py startproject example

$ ls
> example/__init__.pymanage.pysettings.pyurls.py
> $ ls example/
> __init__.py*settings.py*urls.pyviews.pywsgi.py


 The correct settings.py file you should use is NOT the one in the main
project directory, it's the one INSIDE the directory that's created inside
the project directory (the one I bolded). That's one major thing that's
changed with this version of Django. The outer "settings.py" and "urls.py"
shouldn't even exist, but for some reason they're being created anyway.


--
Joey "JoeLinux" Espinosa*
*





On Wed, Apr 4, 2012 at 1:15 PM, maxim  wrote:

> Yes
>
>
> On Wednesday, 4 April 2012 13:12:27 UTC-4, JoeLinux wrote:
>>
>> Are you using Django 1.4?
>> --
>> Joey "JoeLinux" Espinosa*
>> *
>>   
>> 
>>
>>
>>
>> On Wed, Apr 4, 2012 at 12:51 PM, maxim  wrote:
>>
>>> I can't get the tutorial working for me. When I try to run the command:
>>> python manage.py syncdb
>>>
>>> I get this error:
>>> Traceback (most recent call last):
>>>   File "manage.py", line 10, in 
>>> execute_from_command_line(sys.**argv)
>>>   File 
>>> "/usr/lib/python2.7/site-**packages/django/core/**management/__init__.py",
>>> line 443, in execute_from_command_line
>>> utility.execute()
>>>   File 
>>> "/usr/lib/python2.7/site-**packages/django/core/**management/__init__.py",
>>> line 382, in execute
>>> self.fetch_command(subcommand)**.run_from_argv(self.argv)
>>>   File 
>>> "/usr/lib/python2.7/site-**packages/django/core/**management/base.py",
>>> line 196, in run_from_argv
>>> self.execute(*args, **options.__dict__)
>>>   File 
>>> "/usr/lib/python2.7/site-**packages/django/core/**management/base.py",
>>> line 232, in execute
>>> output = self.handle(*args, **options)
>>>   File 
>>> "/usr/lib/python2.7/site-**packages/django/core/**management/base.py",
>>> line 371, in handle
>>> return self.handle_noargs(**options)
>>>File "/usr/lib/python2.7/site-**packages/django/core/**
>>> management/commands/syncdb.py"**, line 57, in handle_noargs
>>> cursor = connection.cursor()
>>>   File 
>>> "/usr/lib/python2.7/site-**packages/django/db/backends/**dummy/base.py",
>>> line 15, in complain
>>> raise ImproperlyConfigured("**settings.DATABASES is improperly
>>> configured. "
>>> django.core.exceptions.**ImproperlyConfigured: settings.DATABASES is
>>> improperly configured. Please supply the ENGINE value. Check settings
>>> documentation for more details.
>>>
>>> My settings file has this for databases:
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.sqlite3', # Add
>>> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>>> 'NAME': '/home/maxim/mysite/mysite.db'**,
>>>  # Or path to database file if using sqlite3.
>>> 'USER': '',  # Not used with sqlite3.
>>> 'PASSWORD': '',  # Not used with sqlite3.
>>> 'HOST': '',  # Set to empty string for
>>> localhost. Not used with sqlite3.
>>> 'PORT': '',  # Set to empty string for
>>> default. Not used with sqlite3.
>>> }
>>> }
>>>
>>>
>>>  --
>>> 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/-/**PPPfCQEQOKEJ
>>> .
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users+unsubscribe@*
>>> *googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en
>>> .
>>>
>>
>>  --
> You received this 

Re: Problem with Django tutorial

2012-04-04 Thread maxim
No, I tried removing the file, creating it with touch and I also used 
sqlite3 to create a table in there to make sure it actually has some 
database in there:
sqlite3 /home/maxim/mysite/mysite.db
SQLite version 3.6.23.1
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .schema
CREATE TABLE my_table (id int);

I still get that error in all cases.

On Wednesday, 4 April 2012 13:19:13 UTC-4, creecode wrote:
>
> Hello maxim,
>
> On Wednesday, April 4, 2012 9:51:39 AM UTC-7, maxim wrote:
>
> I can't get the tutorial working for me. When I try to run the command:
>> python manage.py syncdb
>>
>  
>
>> My settings file has this for databases:
>>
>  
>
>> 'NAME': '/home/maxim/mysite/mysite.db',  # Or 
>> path to database file if using sqlite3.
>>
>
> I'm not sure but could it be there is no file at 
> /home/maxim/mysite/mysite.db ?  If not you might try to touch that path and 
> then try your syncdb.  It looks like are are on some kind of unix/linux 
> variant so you probably have a touch command.
>
> Toodle-looo..
> creecode
>

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



Re: Problem with Django tutorial

2012-04-04 Thread creecode
Opps...

On Wednesday, April 4, 2012 10:19:13 AM UTC-7, creecode wrote:
>
>
> It looks like are are on some kind of unix/linux variant so you probably 
> have a touch command.
>

That should have been "It looks like you are on..."  

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



Re: Problem with Django tutorial

2012-04-04 Thread creecode
Hello maxim,

On Wednesday, April 4, 2012 9:51:39 AM UTC-7, maxim wrote:

I can't get the tutorial working for me. When I try to run the command:
> python manage.py syncdb
>
 

> My settings file has this for databases:
>
 

> 'NAME': '/home/maxim/mysite/mysite.db',  # Or 
> path to database file if using sqlite3.
>

I'm not sure but could it be there is no file at 
/home/maxim/mysite/mysite.db ?  If not you might try to touch that path and 
then try your syncdb.  It looks like are are on some kind of unix/linux 
variant so you probably have a touch command.

Toodle-looo..
creecode

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



Re: Problem with Django tutorial

2012-04-04 Thread maxim
Yes

On Wednesday, 4 April 2012 13:12:27 UTC-4, JoeLinux wrote:
>
> Are you using Django 1.4?
> --
> Joey "JoeLinux" Espinosa*
> *
>   
> 
>
>
>
> On Wed, Apr 4, 2012 at 12:51 PM, maxim  wrote:
>
>> I can't get the tutorial working for me. When I try to run the command:
>> python manage.py syncdb
>>
>> I get this error:
>> Traceback (most recent call last):
>>   File "manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File 
>> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
>> 443, in execute_from_command_line
>> utility.execute()
>>   File 
>> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
>> 382, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
>> line 196, in run_from_argv
>> self.execute(*args, **options.__dict__)
>>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
>> line 232, in execute
>> output = self.handle(*args, **options)
>>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
>> line 371, in handle
>> return self.handle_noargs(**options)
>>   File 
>> "/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py",
>>  
>> line 57, in handle_noargs
>> cursor = connection.cursor()
>>   File 
>> "/usr/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 
>> 15, in complain
>> raise ImproperlyConfigured("settings.DATABASES is improperly 
>> configured. "
>> django.core.exceptions.ImproperlyConfigured: settings.DATABASES is 
>> improperly configured. Please supply the ENGINE value. Check settings 
>> documentation for more details.
>>
>> My settings file has this for databases:
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.sqlite3', # Add 
>> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>> 'NAME': '/home/maxim/mysite/mysite.db',  # Or 
>> path to database file if using sqlite3.
>> 'USER': '',  # Not used with sqlite3.
>> 'PASSWORD': '',  # Not used with sqlite3.
>> 'HOST': '',  # Set to empty string for 
>> localhost. Not used with sqlite3.
>> 'PORT': '',  # Set to empty string for 
>> default. Not used with sqlite3.
>> }
>> }
>>
>>
>>  -- 
>> 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/-/PPPfCQEQOKEJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/3ZDAMJucaLIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problem with Django tutorial

2012-04-04 Thread Joey Espinosa
Are you using Django 1.4?
--
Joey "JoeLinux" Espinosa*
*
 




On Wed, Apr 4, 2012 at 12:51 PM, maxim  wrote:

> I can't get the tutorial working for me. When I try to run the command:
> python manage.py syncdb
>
> I get this error:
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line
> 443, in execute_from_command_line
> utility.execute()
>   File
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line
> 382, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py",
> line 196, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py",
> line 232, in execute
> output = self.handle(*args, **options)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py",
> line 371, in handle
> return self.handle_noargs(**options)
>   File
> "/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py",
> line 57, in handle_noargs
> cursor = connection.cursor()
>   File
> "/usr/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line
> 15, in complain
> raise ImproperlyConfigured("settings.DATABASES is improperly
> configured. "
> django.core.exceptions.ImproperlyConfigured: settings.DATABASES is
> improperly configured. Please supply the ENGINE value. Check settings
> documentation for more details.
>
> My settings file has this for databases:
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': '/home/maxim/mysite/mysite.db',  # Or
> path to database file if using sqlite3.
> 'USER': '',  # Not used with sqlite3.
> 'PASSWORD': '',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
> 'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
> }
> }
>
>
>  --
> 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/-/PPPfCQEQOKEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Problem with the tutorial.

2012-04-04 Thread maxim
When I try to run the command:
python manage.py syncdb

I get the following error:
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
443, in execute_from_command_line
utility.execute()
  File 
"/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
line 232, in execute
output = self.handle(*args, **options)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
line 371, in handle
return self.handle_noargs(**options)
  File 
"/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", 
line 57, in handle_noargs
cursor = connection.cursor()
  File "/usr/lib/python2.7/site-packages/django/db/backends/dummy/base.py", 
line 15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly 
configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is 
improperly configured. Please supply the ENGINE value. Check settings 
documentation for more details.

But my settings file has the DATABASE section:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/home/maxim/mysite/mysite.db',  # Or 
path to database file if using sqlite3.
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for 
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for default. 
Not used with sqlite3.
}
}

What could be causing the error?

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



Problem with Django tutorial

2012-04-04 Thread maxim
I can't get the tutorial working for me. When I try to run the command:
python manage.py syncdb

I get this error:
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
443, in execute_from_command_line
utility.execute()
  File 
"/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
line 232, in execute
output = self.handle(*args, **options)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
line 371, in handle
return self.handle_noargs(**options)
  File 
"/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", 
line 57, in handle_noargs
cursor = connection.cursor()
  File "/usr/lib/python2.7/site-packages/django/db/backends/dummy/base.py", 
line 15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly 
configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is 
improperly configured. Please supply the ENGINE value. Check settings 
documentation for more details.

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


-- 
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/-/PPPfCQEQOKEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: calculate default values for fields based on the content of other fields

2012-04-04 Thread Tom Evans
On Wed, Apr 4, 2012 at 4:51 PM, Jaroslav Dobrek
 wrote:
>> You could override Model.save() on the model you wish to calculate
>> fields for. This could populate the fields if they are not already
>> populated and the instance has a base adjective.
>>
>
> I had thought of this possibilty, too. I would prefer it, because it
> is the simplest one.
> But I don't understand how to find out in the save() function if the
> admin has modified the field.
> If I don't know this, the field will get the default value every time
> an administrator saves the word.

save() happens before the data is saved to the database (well, its the
last things that happens in Model.save()). So you can pull the
original data from the database, and compare it to the one you are
being asked to save.

However, I don't think you need to do this at all. I would say you
would only populate the other fields if they are all empty, and the
base is not empty. If the other fields are not empty, either it has
already been pre-populated, or it has been filled in manually, and you
should not change it. Seems pretty straightforward!

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.



Need Help wtih Importing Data into a Model

2012-04-04 Thread Mark Phillips
I build a model in django (my first, after the tutorial!), and it seems to
be working. I can see the tables in the admin interface and interact with
them. My problem revolves around adding data to the tables. Here is an
example of three tables that I am working on:

class Person(models.Model):
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200)
phone_celll = models.CharField(max_length=12)
email = models.CharField(max_length=200)
home_address_id = models.ForeignKey(Location)

class Coach(models.Model):
person_id = models.ForeignKey(Person)

I copied some data from existing mysql tables into the Person table in this
model from the mysql command line using

INSERT INTO table1 SELECT * from table2;

When I look at the tables in the admin web page, all the data is there.

I then tried to add some data to the Coach table using the admin web page,
but none of the data from the Person table appears when I click the green +
sign. Instead, I get the add data form for the Person table.

I have tried restarting the server, syncing the db, logging out and into
the web interface. The data is in the Person table when I look using the
mysql command line interface, and it is also there when I use the admin web
page for these tables. However, I am not able to access the data from this
table when I try to create a Coachrecord.

What am I doing wrong?

I am running
Linux version 3.1.0-1-amd64 (Debian 3.1.8-2)
mysql  Ver 14.14 Distrib 5.1.61, for debian-linux-gnu (x86_64) using
readline 6.2
django 1.3.1 final

Thanks,

Mark

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



[ANN]: Plata v1.1 (django-based shop no. 42)

2012-04-04 Thread Matthias Kestenholz
Hi fellow Djangonauts

I'm very proud to announce the release of Plata v1.1. Plata is the
BSD licensed Django-based shop by the makers of FeinCMS.
(It does not have any FeinCMS-dependencies though.)

Like many other shop projects such as django-shop, cartridge etc. it
grew out of the frustration of working with big shop frameworks which
strive to do everything with lost and lots of settings instead of
giving the programmer a tool with which it's easy to quickly build
a customized solution for customers (which is the primary reason
for working with Django, not with a turnkey CMS system).

Plata solves a few hard problems:

- Order management with multiple currencies, tax rates and discounts
- Payment (Payment modules for cash on delivery, paypal and ogone are
  bundled)
- Exact, transactional stock tracking for shops which sell goods which
  are often and/or quickly sold out

... but does not try to solve everything. Because of that it does not
come with a product model (which should differ for almost every
installation anyway to keep things simple for the webshop owner) and
keeps everything else mostly stupid but extensible.


Github: https://github.com/matthiask/plata/
RTD: http://readthedocs.org/docs/plata-django-shop/
PyPI: http://pypi.python.org/pypi/Plata/

Examples:
https://github.com/matthiask/plata/tree/master/examples
http://readthedocs.org/docs/plata-django-shop/en/latest/examples.html





===
Plata 1.1 release notes
===

Welcome to Plata 1.1!


Backwards-incompatible changes
==

Order status addition
-

The order status "confirmed" was confusingly named; what it really meant
all the time is that the order can be considered paid. Whether an order is
confirmed or not depends on the shop owner's definitions.

Because of this the existing ``Order.CONFIRMED`` status has been renamed
to ``Order.PAID``, ``Order.CONFIRMED`` has been added as a new order status
coming after ``Order.PAID``. Plata only knows about ``Order.PAID`` and never
changes an order to ``COMPLETED`` itself.

To update your installations to Plata v1.1, you'll have to make the following
changes:

* The method ``order.is_completed()`` has been removed. Either check for
  ``not order.balance_remaining`` (which only looks at the balance, not at the
  order status) or check for ``order.status >= order.PAID`` yourself. For
  consistency, the method ``order.is_confirmed()`` has been removed too.

* ``order.is_paid()`` has been deprecated and will be removed in the next
  release. Use ``order.status >= order.PAID`` or ``not order.balance_remaining``
  directly to clearly communicate your intentions instead.

* The shop signal ``order_completed`` has been renamed to ``order_paid``. Signal
  handlers receive the same arguments as before.

* The email template used in the ``SendInvoiceHandler`` has been renamed to
  ``order_paid.txt``.

* If you wrote your own payment modules, the method you'll want to call at the
  end is now named ``order_paid``, not ``order_completed`` anymore. Apart from
  the renaming the signature of the function has not changed.


Stock tracking
--

* The stock transaction app has been converted to south too now. The
  initial migration should be applied with ``--fake`` if you are already
  using stock tracking::

  ./manage.py migrate stock 0001 --fake

* Stock transactions have been made more useful on their own; if possible,
  the name, sku and line item price fields are filled in automatically.
  The south schemamigration for adding all additional fields is provided.

* Previously, stock transactions of type ``PAYMENT_PROCESS_RESERVATION``
  influenced the ``items_in_stock`` field on products even after the
  reservation period was over. This happened because the stock is not
  automatically recalculated when 15 minutes have passed. Plata is smarter
  now and only takes the payment process reservation stock transactions
  into account when validating the order (respectively the cart) during
  the checkout process. A few stock transaction manager methods have been
  removed during the refactoring because their functionality does not
  match Plata's own behavior anymore:

  * ``StockTransaction.objects.stock()``
  * ``StockTransaction.objects.expired()``
  * ``StockTransaction.objects._expired()`` (this method was meant for
internal use only anyway)

  If you need their functionality, you should have a closer look at
  ``StockTransaction.objects.items_in_stock`` first (especially the
  new argument, ``include_reservations``).


Language-aware orders
-

The order model has a new field ``language_code``. When the order is
created in ``shop.order_from_request(request, create=True)`` this field
is filled with the current language for your convenience. The PDF
generation code and the e-mail notification handlers automatically
activate the language set on the order; if you provide your own
signal 

Re: calculate default values for fields based on the content of other fields

2012-04-04 Thread Jaroslav Dobrek
> You could override Model.save() on the model you wish to calculate
> fields for. This could populate the fields if they are not already
> populated and the instance has a base adjective.
>

I had thought of this possibilty, too. I would prefer it, because it
is the simplest one.
But I don't understand how to find out in the save() function if the
admin has modified the field.
If I don't know this, the field will get the default value every time
an administrator saves the word.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: where do you host your django app and how to you deploy it?!

2012-04-04 Thread Marcin Tustin
I have to say that switching to gunicorn from apache+mod_wsgi has made my
site noticeably faster, and uses less memory. I would avoid apache for WSGI
apps where the choice exists.

On Wed, Apr 4, 2012 at 16:24, Daniel Sokolowski <
daniel.sokolow...@klinsight.com> wrote:

> I would use Linode VPS. Used WebFaction before however I quickly run
> into a wall where server was running out of resources when attempting
> to run 3-4 django sites from one account --- so skip the training
> wheels and go VPS.
>
> Linode has an unbeatable help center - http://library.linode.com/ and
> great customer service. Use this link please if you do sign up with
> them, I'll get a small kick back :)
> http://www.linode.com/?r=7d884fa5262b62b8735502da003fee34061db49b
>
> Be VERY careful of other VPS providers as not all are equal - you pay
> for what you get. Linode runs on XEN virtualization (very close to
> hardware) in which for one you can create a swap space. Burst.net
> which we also tried runs on OpenVZ (a super chroot like enviroment)
> does not allow swap space; this means you sites will be killed if it
> exceeds you memory limits, unacceptable and too unpredictable.
>
> Also I would strongly suggest stick to a simple setup, Sqlite3 +
> Apache (on instance both for django and static serving). In my
> experience majority of sites will be happy with that site and you will
> KNOW when you need to a more complex setup. Sqlite3 is solid for read
> operations, and only starts choking on a large parallel write
> requests, Apache is tried and true and just works, NGINX sounds great
> but why complicate things for some therotical speed gains; most your
> bottle necks will be in your code not the server. There is only one
> project that I have considered using something else the Sqlite3  with
> over 600 active users; over the 2 years the site did not once generate
> a Sqlite3 write time out error or performed poorly. Lastly Sqlite3
> makes it is a zip to copy from development server to live server since
> the database is a file.
>
> Our development is a mirror copy of the live server. So deployment is
> a matter of copying the site to live server and switching to live
> mode; also all of the projects are as self contained as possible with
> PIP, keeping settings files and raw media files with project folder.
>
> Sample apache conf and wsgi files - http://dpaste.com/726790/,
> http://dpaste.com/726792/.
>
> Daniel Sokolowski
> webdesign.danols.com
>
>
>
> On Apr 2, 6:48 am, fix3d  wrote:
> > Where do you host your django app and how to you deploy it?!
> >
> > Please share personal exp.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Marcin Tustin
Tel: 07773 787 105

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: where do you host your django app and how to you deploy it?!

2012-04-04 Thread Daniel Sokolowski
I would use Linode VPS. Used WebFaction before however I quickly run
into a wall where server was running out of resources when attempting
to run 3-4 django sites from one account --- so skip the training
wheels and go VPS.

Linode has an unbeatable help center - http://library.linode.com/ and
great customer service. Use this link please if you do sign up with
them, I'll get a small kick back :) 
http://www.linode.com/?r=7d884fa5262b62b8735502da003fee34061db49b

Be VERY careful of other VPS providers as not all are equal - you pay
for what you get. Linode runs on XEN virtualization (very close to
hardware) in which for one you can create a swap space. Burst.net
which we also tried runs on OpenVZ (a super chroot like enviroment)
does not allow swap space; this means you sites will be killed if it
exceeds you memory limits, unacceptable and too unpredictable.

Also I would strongly suggest stick to a simple setup, Sqlite3 +
Apache (on instance both for django and static serving). In my
experience majority of sites will be happy with that site and you will
KNOW when you need to a more complex setup. Sqlite3 is solid for read
operations, and only starts choking on a large parallel write
requests, Apache is tried and true and just works, NGINX sounds great
but why complicate things for some therotical speed gains; most your
bottle necks will be in your code not the server. There is only one
project that I have considered using something else the Sqlite3  with
over 600 active users; over the 2 years the site did not once generate
a Sqlite3 write time out error or performed poorly. Lastly Sqlite3
makes it is a zip to copy from development server to live server since
the database is a file.

Our development is a mirror copy of the live server. So deployment is
a matter of copying the site to live server and switching to live
mode; also all of the projects are as self contained as possible with
PIP, keeping settings files and raw media files with project folder.

Sample apache conf and wsgi files - http://dpaste.com/726790/,
http://dpaste.com/726792/.

Daniel Sokolowski
webdesign.danols.com



On Apr 2, 6:48 am, fix3d  wrote:
> Where do you host your django app and how to you deploy it?!
>
> Please share personal exp.

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



ModelForm based on User allows any username without checking

2012-04-04 Thread Bastian
Hi,

I have a form that asks the registering user to choose a username. That 
form is a ModelForm based on the django.contrib.auth.models Users:

class usernameForm(forms.ModelForm):
class Meta:
model = User
fields = ('username', )

The strange thing is that when it appears on the page it comes with the 
warning that says no more than 30 characters... but it actually does not 
check anything. I tried to enter whatever username, with spaces and () and 
in the view when I ask if form.is_valid() it returns True all the time!

Obviously this must be a mistake on my side somewhere but on such a simple 
setup I don't see where I am wrong, any idea welcome.

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



Re: Why using Generic Views?

2012-04-04 Thread Dan Gentry
I use generic views - either function or class based - for the common
functionality in my apps.  As Serge mentioned, a list works pretty
much the same in every application, so I just provide a few parameters
to a generic view.  More complicated forms still require custom code.

On Apr 3, 1:07 am, abisson  wrote:
> Good evening,
>
> I just finished the Django 1.4 Tutorial, and I really don't understand
> the point of Generic Views in Django? As far as I can see, we wrote
> more code than before, and what other example would make the Generic
> Views better than normal views?
>
> Thanks for the clarifications!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: where do you host your django app and how to you deploy it?!

2012-04-04 Thread Eugenio Minardi
Servage for low-cost websites
https://www.servage.net/wiki/Install_Djangounlimited space, domains,
ecc.

With the coupon code django2012 you can get the discount

Eugenio

On Wed, Apr 4, 2012 at 3:24 PM, Dan Gentry  wrote:

> Dreamhost shared account
>
> http://dashdrum.com/blog/2011/08/django-on-dreamhost/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: calculate default values for fields based on the content of other fields

2012-04-04 Thread Tom Evans
On Wed, Apr 4, 2012 at 2:09 PM, Jaroslav Dobrek
 wrote:
> Hello,
>
> is there a way to calculate default values for certain fields based
> on the content of other fields?
>
> […]
>
> Any ideas how to realize this?
>
> Jaroslav

Three ways immediately spring to mind.

You could override Model.save() on the model you wish to calculate
fields for. This could populate the fields if they are not already
populated and the instance has a base adjective.

Similar, but not the same, you could add a pre_save signal to that
model which does the same thing. The pre_save signal is emitted as
part of Model.save(), so you can see how similar it is.

Finally, you could leave the model unmodified, and simply make an AJAX
service for generating the various adjective forms, and hook that into
a custom admin form, adding a widget that collects the adjective from
the un-submitted form, calls the AJAX service, and populates the
appropriate fields.

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: where do you host your django app and how to you deploy it?!

2012-04-04 Thread j_syk
I have a Linode VPS. Best decision I've made. I had tried A Small Orange 
and Webfaction, was happy with the customer/tech service from both (ASO 
isn't really setup for easy Django setup), but eventually you may run into 
situations were you wish you had full access to the server. 

I use Nginx & Gunicorn. It's a really easy setup to get started with and 
it's good.


On Monday, April 2, 2012 5:48:24 AM UTC-5, fix3d wrote:
>
> Where do you host your django app and how to you deploy it?! 
>
> Please share personal exp.

-- 
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/-/HQhgwNVPGcIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 Contrib Auth + Class Based Generic Views

2012-04-04 Thread Sergiy Khohlov
Sound good!
Usually  project is not so simple (only url.py + settings.py)

2012/4/4 Javier Guerra Giraldez :
> On Wed, Apr 4, 2012 at 4:14 AM, Sergiy Khohlov  wrote:
>> As result  your views.py should be :
>>
>> from django.views.generic import TemplateView
>> # Create your views here.
>> class HomeView(TemplateView):
>>    template_name='home.html'
>>
>>  Only three lines of the code !
>> You dont  need more!
>
> if in urls.py you replace
>
>  (r'^$', login_required(HomeView.as_view())),
>
> with
>  (r'^$', login_required(TemplateView(template_name='home.html').as_view())),
>
>
> you don't need any HomeView class!
>
>
> --
> Javier
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: where do you host your django app and how to you deploy it?!

2012-04-04 Thread Dan Gentry
Dreamhost shared account

http://dashdrum.com/blog/2011/08/django-on-dreamhost/

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



calculate default values for fields based on the content of other fields

2012-04-04 Thread Jaroslav Dobrek
Hello,

is there a way to calculate default values for certain fields based
on the content of other fields?

I am implementing a dictionary. Admins are supposed to add words of
certain languages and parts-of-speech. Some words of some
part-of-speech and language are, on one hand, morphologically very
regular, but, one the other hand, come with a huge number of
morphological
forms. This is true for German adjectives: They usually have 183
morphological forms (if form-meaning pairs are counted). On the other
hand, there are very few irregular adjectives. The most user-friendly
way for admins to code German adjectives would be this: The admin adds
a new adjective and types in the adjective's base form:

base form: |gut|

Then he clicks some button or saves the adjective or, ideally, does
nothing, and the program fills in the 183 fields below, using the base
form and
assuming that the adjective is regular:

attributive positive strong masculine nominative singular: |guter|
attributive positive strong masculine genitive singular:   |guten|
attributive positive strong masculine dative singular: |gutem|
attributive positive strong masculine accusative singular: |guten|
...
attributive comparative strong masculine nominative singular: |
guterer|
...

The admin now has the possibility to correct the wrong forms before
saving the adjective. This way, in the vast majority of cases all the
coding is done completely
automatically. And for the very few irregular adjectives, the admin
only has to modify those
forms that have been guessed wrongly.

Any ideas how to realize this?

Jaroslav

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

2012-04-04 Thread DIEGO CENZANO PRADO
It worked. Thank you very much.

El miércoles 4 de abril de 2012 13:31:58 UTC+2, Andre Terra (airstrike) 
escribió:
>
> When you type 'django-admin.py foo' in a command prompt, windows will use 
> the system wide python install which is what is associated with the .py 
> extension. In order to avoid this, you must call 'python django-admin.py 
> foo'.
>
> If you don't like having to type 'python' before calling a script, you can 
> alter your virtualenv activate script so that window's file association for 
> Python files gets changed when a new environment gets activated. This has 
> the downside of not reverting the association when you close a prompt 
> without properly deactivating (by typing 'deactivate'), but I still like 
> it, so there's a how-to below.
>
>
> In order to tell the virtualenv to use your virtual python install when 
> calling file.py directly, you need to modify the activate.bat script and 
> add the following line somewhere in the beginning (after @echo off):
>
> FTYPE Python.File="C:\Environments\django1.3\Scripts\python.exe" "%1" %*
>
> Then add a line to revert this association change in deactivate.bat 
> (located in the same folder):
>
> FTYPE Python.File="C:\Python27\python.exe" "%1" %* 
>
> I did my best to guess the paths, but you might have to adjust them 
> appropriately.
>
>
> Hope that helps!
>
> Cheers,
> AT
>
> On Wed, Apr 4, 2012 at 6:01 AM, DIEGO CENZANO PRADO <
> diego.cenz...@bbva.com> wrote:
>
>> I have install django with 'python setup.py install' in a virtual 
>> environment called 'django1.3'
>>
>> I run it and receive the following error mesage:
>>
>> (django1.3) C:\Documentos de Diego\Dropbox\Codigo\Django>django-admin.py
>>
>> Traceback (most recent call last):
>>
>>   File "C:\Environments\django1.3\Scripts\django-admin.py", line 2, in 
>> 
>>
>> from django.core import management
>>
>> ImportError: No module named django.core
>> Can anybody help me, please?
>>
>> -- 
>> 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/-/WKzPnfWfh9UJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/FcJW1LhQmWkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 Contrib Auth + Class Based Generic Views

2012-04-04 Thread Javier Guerra Giraldez
On Wed, Apr 4, 2012 at 4:14 AM, Sergiy Khohlov  wrote:
> As result  your views.py should be :
>
> from django.views.generic import TemplateView
> # Create your views here.
> class HomeView(TemplateView):
>    template_name='home.html'
>
>  Only three lines of the code !
> You dont  need more!

if in urls.py you replace

  (r'^$', login_required(HomeView.as_view())),

with
  (r'^$', login_required(TemplateView(template_name='home.html').as_view())),


you don't need any HomeView class!


-- 
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: Profiling Django (WAS Django database-api)

2012-04-04 Thread Javier Guerra Giraldez
On Wed, Apr 4, 2012 at 4:07 AM, Tom Evans  wrote:
> One pretty cool method I've used for live debugging in the past is to
> 'log' to rabbitmq (Note - not celery - raw amqp), and send messages to
> a logging exchange. You can use a topic key so that different
> processes can be distinguished.

a similar thing can be done with ZeroMQ, with the advantage of not
needing a mq daemon.  but i guess Andre already uses rabbitmq, so
yours would be the easiest way.

-- 
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: Problem using django-admin.py in a virtual environment

2012-04-04 Thread Andre Terra
When you type 'django-admin.py foo' in a command prompt, windows will use
the system wide python install which is what is associated with the .py
extension. In order to avoid this, you must call 'python django-admin.py
foo'.

If you don't like having to type 'python' before calling a script, you can
alter your virtualenv activate script so that window's file association for
Python files gets changed when a new environment gets activated. This has
the downside of not reverting the association when you close a prompt
without properly deactivating (by typing 'deactivate'), but I still like
it, so there's a how-to below.


In order to tell the virtualenv to use your virtual python install when
calling file.py directly, you need to modify the activate.bat script and
add the following line somewhere in the beginning (after @echo off):

FTYPE Python.File="C:\Environments\django1.3\Scripts\python.exe" "%1" %*

Then add a line to revert this association change in deactivate.bat
(located in the same folder):

FTYPE Python.File="C:\Python27\python.exe" "%1" %*

I did my best to guess the paths, but you might have to adjust them
appropriately.


Hope that helps!

Cheers,
AT

On Wed, Apr 4, 2012 at 6:01 AM, DIEGO CENZANO PRADO
wrote:

> I have install django with 'python setup.py install' in a virtual
> environment called 'django1.3'
>
> I run it and receive the following error mesage:
>
> (django1.3) C:\Documentos de Diego\Dropbox\Codigo\Django>django-admin.py
>
> Traceback (most recent call last):
>
>   File "C:\Environments\django1.3\Scripts\django-admin.py", line 2, in
> 
>
> from django.core import management
>
> ImportError: No module named django.core
> Can anybody help me, please?
>
> --
> 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/-/WKzPnfWfh9UJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django Contrib Auth + Class Based Generic Views

2012-04-04 Thread Sergiy Khohlov
 So  much code .
Ok,  lets start

2012/4/4 Matheus Ashton :
> urls.py:
>
> urlpatterns = patterns('',
>     url(r'^/login$', LoginView.as_view()),
>     url(r'^$', HomeView.as_view(), {}, 'home'),
> )
>
More simple way  is using decorator for checking  if user is authorized.

Add next string to your  urls.py

# import decorator functionality
from django.contrib.auth.decorators import login_required

#  import your views

from home.views import HomeView

 final  urls.py   is :


from django.conf.urls.defaults import patterns, include, url
from django.contrib.auth.decorators import login_required
from home.views import HomeView

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^login/', 'django.contrib.auth.views.login', {'template_name':
'login.html'}),
(r'^$', login_required(HomeView.as_view())),
)

 First line is mean  that default djano auth  mechanism  is used for
checking user's auth.
Socond line means : each request is passed to  HomeView but   should
be  authorized. If  user is not authorized  then  redirect to login
windows should be .


As result  your views.py should be :

from django.views.generic import TemplateView
# Create your views here.
class HomeView(TemplateView):
template_name='home.html'

 Only three lines of the code !
You dont  need more!


 Thanks,
 Serge



> views.py:
>
> class LoginView(FormView):
>   form_class = LoginForm
>   template_name = "auth/form.html"
>
>   def post(self, request, *args, **kwargs):
>     form = self.get_form(self.get_form_class())
>     if form.is_valid():
>       user = self.request['login']
>       password = self.request['password']
>       try:
>         auth = Authenticator()
>         auth.authenticate(user, password, self.request)
>         return self.form_valid(form)
>   def get_success_url(self):
>     return reverse('home')
>
> class HomeView(TemplateView):
>    template_name = 'user/home.html'
>
>
> components.py:
>
> class Authenticator():
>   def authenticate(self, user, password, request = None):
>     self.user = auth.authenticate(username=user, password=password)
>     if request:
>       return self.login(request)
>
>     return self.user
>
>   def login(self, request):
>     if self.user is not None:
>       if self.user.is_active:
>         auth.login(request, self.user)
>         return self.user
>       else:
>         raise UserDisabledException("Usuario inativo")
>     else:
>       raise InvalidLoginException("Usuario/Senha invalidos")
>
> class UserDisabledException(Exception):
>   def __init__(self, value):
>     self.value = value
>
>   def __str__(self):
>     return repr(self.value)
>
> class InvalidLoginException(Exception):
>   def __init__(self, value):
>     self.value = value
>
>   def __str__(self):
>     return repr(self.value)
>
>
> Thanks again :)
>
> 2012/4/3 Sergiy Khohlov 
>>
>> Please provide your urls.py  and  your view which is used for this 
>>
>> 2012/4/3 Matheus Ashton :
>> > Hello Everybody,
>> >
>> > I'm having a problem using the django.contrib.auth app and class based
>> > generic views in Django 1.3 / 1.4:
>> >
>> > After submitting the login form, my view receives the post data and
>> > tries to
>> > authenticate the user and then redirect to a success page. Ok nothing
>> > new..
>> > The problem is: My HomeView wich extends the TemplateView, receive the
>> > redirect from the login form and uses a render_to_response function to
>> > render the template, and that is my problem, because render_to_response
>> > does
>> > not create a RequestContext object, the one I need to show the newly
>> > authenticated user data, because that is a requirement for
>> > django.contrib.auth app, if the request is not a RequestContext, the
>> > authenticated user data, is not passed to the template
>> >
>> > (https://docs.djangoproject.com/en/1.4/topics/auth/#authentication-data-in-templates)..
>> >
>> > Does someone can help me with this problem?
>> >
>> > PS: Sorry about my English, it is not my first language
>> >
>> > Thanks :D
>> >
>> > --
>> > 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/-/ywPX8VH5CUQJ.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, 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

Re: Profiling Django (WAS Django database-api)

2012-04-04 Thread Tom Evans
On Tue, Apr 3, 2012 at 11:25 PM, Andre Terra  wrote:
> Hey Javier,
>
> Thanks for the reply. My problem with the logs in the past was that they
> tended to make the task even slower (due to recursion) but I guess that's
> probably because I didn't call the logging from the appropriate places in
> the code.
>
> To make things a little more complicated, the task involves writing a large
> amount of data to a temp database, handling it and then saving some
> resulting queries to the permanent DB. This makes it a tad harder to analyze
> what goes on in the first part of the code.
>
> I'll try logging again over the weekend and see how that works.. I just wish
> there were third party apps and tools for debugging this sort of problem.
>
> Thanks again for your input.
>
> Cheers,
> AT

Hi Andre

One pretty cool method I've used for live debugging in the past is to
'log' to rabbitmq (Note - not celery - raw amqp), and send messages to
a logging exchange. You can use a topic key so that different
processes can be distinguished.

Then, if you want to see the running logs of what is happening, you
simply attach a dumb listener that binds a queue to that exchange,
receives the message and prints it out. If you're no longer
interested, detach the listener, and rabbitmq will just discard the
messages with little overhead.

If you want to do stuff with AMQP, I'd recommend pika [1], which is
just brilliant and easy to understand (other amqp libraries, less
so!).

Cheers

Tom

[1] http://pika.github.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.



Problem using django-admin.py in a virtual environment

2012-04-04 Thread DIEGO CENZANO PRADO
I have install django with 'python setup.py install' in a virtual 
environment called 'django1.3'

I run it and receive the following error mesage:

(django1.3) C:\Documentos de Diego\Dropbox\Codigo\Django>django-admin.py

Traceback (most recent call last):

  File "C:\Environments\django1.3\Scripts\django-admin.py", line 2, in 


from django.core import management

ImportError: No module named django.core
Can anybody help me, please?

-- 
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/-/WKzPnfWfh9UJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: custom manager to control access

2012-04-04 Thread akaariai
On Apr 4, 3:15 am, Mike Dewhirst  wrote:
> I have now discarded the idea :)
>
> I'm not very comfortable with thread locals. I need a bullet-proof
> approach which makes data from other companies invisible to members of
> this company. I suppose a view decorator is the way to go but I would
> have preferred a deeper model-level approach.

You have two ways to pass this kind of information around:
  1. explicitly as parameters
  2. using thread locals (or other "global state").

So, you need to use explicit parameters. You should do something like
this:

class MemberManager(models.Manager):
def visible_for_user(self, user):
# Replace the below filter condition with appropriate logic.
return self.get_query_set().filter(company=user.company)

Now, instead of using Member.objects.all() you should use
Member.objects.visible_for_user(request.user) in your code. I think
you can set the manager default for relations, so that you could do
group.membership.visible_for_user(request.user), but I haven't ever
done that. You will need to be careful when coding so that you don't
accidentally show or modify data from other companies. The way I would
do this is have the logic in the Model/Manager classes, and then use
that logic in your view code.

 - 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: AttributeError at /admin/coltrane/entry/add/ 'Entry' object has no attribute 'pubdate'

2012-04-04 Thread akaariai
Do you get a stacktrace from the error? You should get one, and it
should point out the code-path to the erroneous pubdate usage. If you
do not get one for one reason or another, search your project for the
string "pubdate" and go through all locations containing that string.

The code snippets you have below seem clean to me.

 - Anssi

On Apr 3, 10:59 pm, laurence Turpin 
wrote:
> Hello,
>
> I'm trying to learn Django from the book "Practical Django Projects 2nd
> Edition"
>  I'm using Django 1.3.1 and Python 2.7.2 on Windows 7
> Also I'm using Eclipse Indigo with pydev
>
> The current project I'm working on is to create a Weblog called coltrane.
> coltrane is an application that exists in a project called
> "cmswithpythonanddjango"
>
> Inside the models.py is a class called Entry which holds the fields used to
> Enter a weblog entry.
> When I go to localhost:8000/admin/    I get the option to add and Entry.
> I can select this option fill out sample data, but when I try to save it.
> I get the following error.
>
> AttributeError at /admin/coltrane/entry/add/
>
> 'Entry' object has no attribute 'pubdate'
>
> There is a field called pub_date in Entry
>
> It's as if I have made a typing error somewhere and typed pubdate instead of 
> pub_date.
>
> Below is the models.py, views.py , url.py , and admin.py files
>
> //
>
> Here is my models.py
>
> /
>
> from django.db import models
> import datetime
> from tagging.fields import TagField
> from django.contrib.auth.models import User
> from markdown import markdown
>
> class Category(models.Model):
>     title = models.CharField(max_length=250, help_text="Maximum 250
> characters.")
>     slug = models.SlugField(help_text="Suggested value automatically
> generated from title. Must be unique.")
>     description = models.TextField()
>
>     class Meta:
>         ordering = ['title']
>         verbose_name_plural = "Categories"
>
>     def __unicode__(self):
>             return self.title
>
>     def get_absolute_url(self):
>         return "/categories/%s/" % self.slug
>
> class Entry(models.Model):
>     LIVE_STATUS = 1
>     DRAFT_STATUS = 2
>     HIDDEN_STATUS = 3
>     STATUS_CHOICES = (
>     (LIVE_STATUS, 'Live'),
>     (DRAFT_STATUS, 'Draft'),
>     (HIDDEN_STATUS, 'Hidden')
>     )
>
>     # Core fields
>     title = models.CharField(max_length=250, help_text = "Maximum 250
> characters. ")
>     excerpt = models.TextField(blank=True, help_text = "A short summary of
> the entry. Optional.")
>     body = models.TextField()
>     pub_date = models.DateTimeField(default = datetime.datetime.now)
>
>     # Fields to store generated HTML
>     excerpt_html = models.TextField(editable=False, blank=True)
>     body_html = models.TextField(editable=False, blank=True)
>
>     # Metadata
>     author = models.ForeignKey(User)
>     enable_comments = models.BooleanField(default=True)
>     featured = models.BooleanField(default=False)
>     slug = models.SlugField(unique_for_date = 'pub_date', help_text =
> "Suggested value automatically generated from title. Must be unique.")
>     status = models.IntegerField(choices=STATUS_CHOICES,
> default=LIVE_STATUS, help_text = "Only entries with live status will be
> publicly displayed.")
>
>     # Categorization.
>     categories = models.ManyToManyField(Category)
>     tags = TagField(help_text = "Separate tags with spaces.")
>
>     class Meta:
>         verbose_name_plural = "Entries"
>         ordering = ['-pub_date']
>
>     def __unicode__(self):
>         return self.title
>
>     def save(self, force_insert=False, force_update=False):
>         self.body_html = markdown(self.body)
>         if self.excerpt:
>             self.excerpt_html = markdown(self.excerpt)
>             super(Entry, self).save(force_insert, force_update)
>
>     def get_absolute_url(self):
>         return "/weblog/%s/%s/" %
> (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug)
>
> ///
>
> Here is the views.py
>
> //
>
> from django.shortcuts import 

Re: Questions about UnicodeDecodeError

2012-04-04 Thread Ian Clelland
On Monday, April 2, 2012, Ali Mesdaq wrote:

> I did have UTF-8 in the db before but then when I was inserting(done by a
> script) values in I would get errors. I really want to avoid doing
> conversions before I insert the data so I can maintain the data in the
> exact format as it was seen in.


This, in general, isn't going to be possible. Even if you get it to the
point where it looks like its working, you may still end up with silent
data corruption, and not be able to retrieve your data when you need it.

If your database column only supports ASCII, and you cant change the
database, then your best option is probably going to be to use a strict
ASCII encoding, like base64 or base85. If you are pretty sure that the data
is *mostly* ASCII, then you could go with something like quoted-printable.
The point, though, is that you need to do *something* to your data to
coerce it into the ASCII range before you put it in the database.

As long as you remember to encode the data on save, and decode it (once!)
before displaying it, you should be able to get it to work.

Ian


>  I may be forced into doing that it seems
> to make django even work. I tried to get my app to work by creating the
> __unicode__ method return a string of "blah" and it still dies on me.
>
> Thanks,
> Ali Mesdaq
> Security Researcher
> Cell:  +1 (619) 952-8488  |  Fax:  +1 (408) 321-9818
> Email:  ali.mes...@fireeye.com
>
>
> Next Generation Threat Protection
> http://www.FireEye.com 
>
>
>
>
>
>
>
> On 4/1/12 3:04 PM, "Bill Freeman"  wrote:
>
> >If you can, switch to UTF-8 in the db.  Web traffic can arrive in a
> >variety of
> >encodings, and while the headers tell the server how to make unicode out
> >of it, but by having the db set for ASCII, you limit what you can store
> >(since
> >not all unicode characters can be converted to ASCII.
> >
> >On Fri, Mar 30, 2012 at 7:45 PM, Ali Mesdaq 
> >wrote:
> >> I have a situation where I am reading data that I have no control over
> >>and
> >> inserting it into a db. The data is http headers. I am storing them in
> >> postgres db in a text field and the db encoding is SQL_ASCII. Since the
> >> data can be anything even non compliant http headers with anything for
> >>its
> >> values I don't want to modify the data before I store it in the db.
> >> However this is causing issues with certain values causing the
> >> UnicodeDecodeError. For example I have a specific case where the user
> >> agent is set to 'KC\xd4\xda\xcf\xdf\xc9\xfd\xbc\xb6'. I have been trying
> >> to look for a way to deal with these cases gracefully in the models
> >> __unicode__ method but nothing I have tried has worked.
> >>
> >> Thanks,
> >> Ali Mesdaq
> >> Security Researcher
> >> Cell:  +1 (619) 952-8488  |  Fax:  +1 (408) 321-9818
> >> Email:  ali.mes...@fireeye.com
> >>
> >>
> >> Next Generation Threat Protection
> >> http://www.FireEye.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.
> >>
> >
> >--
> >You received this message because you are subscribed to the Google Groups
> >"Django users" group.
> >To post to this group, send email to django-users@googlegroups.com.
> >To unsubscribe from this group, send email to
> >django-users+unsubscr...@googlegroups.com.
> >For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Model validation fails, when inherited model redeclare parent field

2012-04-04 Thread shiva
Jani, thank you.

2012/4/4 Jani Tiainen :
> Hi,
>
> You'ew hitting limitation of Django ORM which prohibits overriding fields.
>
> https://docs.djangoproject.com/en/1.3/topics/db/models/#field-name-hiding-is-not-permitted
>
>
> 4.4.2012 6:34, shiva kirjoitti:
>
>> Hello!
>>
>> In our apps (that use Django 1.2.7) we use following models:
>>
>> class BaseRegistration(models.Model):
>>        exhibition = models.ForeignKey(...)
>>        year = models.IntegerField(...)
>>        user = models.ForeignKey('auth.User')
>>
>> class BarcodeRegistration(BaseRegistration):
>>        class Meta:
>>                abstract = True
>>
>> class EventRegistration(BarcodeRegistration):
>>        event = models.ForeignKey(...)
>>
>> I append *validate_unique* by *user* and *event* fields in
>> EventRegistration class:
>>
>> class EventRegistration(BarcodeRegistration):
>>        event = models.ForeignKey(...)
>>        user = models.ForeignKey('auth.User')
>>
>>        class Meta:
>>                unique_together = ('event', 'user')
>>
>> But in django command manage.py validate fails with error:
>>
>> exhibition.eventregistration: "unique_together" refers to user. This
>> is not in the same model as the unique_together statement.
>>
>> After some "pdb'ing" of django.core.management.validation,
>> django.db.models.base, and django.db.models.options I found, that is
>> happend because:
>>
>> In [13]: EventRegistration._meta.get_field('user') in
>> EventRegistration._meta.parents.keys()[0]._meta.local_fields
>> Out[13]: True
>>
>> In [14]: EventRegistration._meta.get_field('user') in
>> EventRegistration._meta.local_fields
>> Out[14]: False
>>
>> Is it's something wrong with our code?
>>
>> Thanks
>>
>> --
>> Shavrin Ivan
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.