HELP with Templates

2009-07-31 Thread Venkat Rao

Hello,

I am developing a personal website with django on  google app engine.
The site works when I do not use templates. See here:
vrao423.appspot.com. But when I change try to use templates I separate
the base into files index and base.

Here is my base:
http://www.w3.org/
TR/html4/strict.dtd">







Venkat S. Rao's Homepage






$(function() {
$("#1, #2, #3").lavaLamp({
fx: "backout",
speed: 700,
click: function(event, menuItem) {
return false;
}
});
});









Venkat S. Rao





  
Home
Projects
http://vrao423.wordpress.com/;>Blog
http://www.youtube.com/vrao423;>You Tube
Contact Me
 






{% block content%}


{% endblock %}




 Venkat S. Rao 2009







Here is my index.html:

{% extends 'base.html' %}


{% block content %}


setInterval("nextSlide()",gSlideshowInterval * 1000);


http://farm4.static.flickr.com/
3460/3773940130_38a07acdc0.jpg" BORDER=0 width="550px" NAME="slide">
{% endblock %}

{% endblock %}

my urls.py looks like:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r"^$", 'main.views.index'),
)

I am gettting a template not found. I have spent about 4 hours trying
to figure this out. But I am very stuck.

Here is part of the error I get:

 C:\Program Files\Google\google_appengine\google\appengine\tools
\dev_appserver.py in ExecuteOrImportScript(handler_path='main.py',
cgi_path=r'C:\Users\Ashok\workspace\PersonalSite\main.py',
import_hook=)
 2022   exec module_code in script_module.__dict__
 2023 else:
 2024   script_module.main()
 2025
 2026 sys.stdout.flush()
script_module = , script_module.main = 
 C:\Users\Ashok\workspace\PersonalSite\src\main.py in main()
   34
   35   # Run the WSGI CGI handler with that application.
   36   util.run_wsgi_app(application)
   37
   38 if __name__ == '__main__':
global util = ,
util.run_wsgi_app = , application
= 
 C:\Program Files\Google\google_appengine\google\appengine\ext\webapp
\util.py in run_wsgi_app
(application=)
   74   env["wsgi.multithread"] = False
   75   env["wsgi.multiprocess"] = False
   76   result = application(env, _start_response)
   77   if result is not None:
   78 for data in result:
result undefined, application = , env = {'APPLICATION_ID': 'vrao423',
'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE':
'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1',
'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'application/
xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/
*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', 'HTTP_CONNECTION': 'keep-
alive', ...}, global _start_response = 

Please Help!

Thank You,

Venkat Rao
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



howto change FileField value in model.save() ?

2009-07-31 Thread Shuge Lee

Take a look here

http://dpaste.com/73953/

or following

# in models.py

class Seed(models.Model):
name = models.CharField(max_length=128)

UPLOAD_ROOT = 'uploads'
files = models.FileField(upload_to=UPLOAD_ROOT, blank=True,
null=True)
source = models.CharField(max_length=256, blank=True, null=True)

def save(self, force_insert=False, force_update=False):
# I want to change self.files here
# how to do it ?





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



Re: Stopping people loging in twice

2009-07-31 Thread Malcolm Tredinnick

On Fri, 2009-07-31 at 20:56 -0700, django user wrote:
> So is there a viable django solution for this problem?

You can implement your own session support. It's not that difficult.
Django is just a layer on top of Python, so there's a Django solution to
any computable problem. Django's default contrib.sessions framework,
however, is not going to be useful to you for this problem.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: Stopping people loging in twice

2009-07-31 Thread django user

So is there a viable django solution for this problem?

On Jul 31, 7:50 pm, Malcolm Tredinnick 
wrote:
> On Fri, 2009-07-31 at 19:43 -0700, django user wrote:
> > I'm interested in a solution for this as well.
>
> > I am thinking that a good way might be to rewrite the auth middleware
> > to check and see if a user login for this user exists and if it does
> > then remove that login and log in the current user. A message could
> > then be passed to the login page letting them know that they have
> > logged in elsewhere and their session at this computer was ended.
>
> HTTP is a stateless protocol. By design. As has been pointed out in
> another reply in this thread, the concept of "already logged in" is
> therefore no very well defined. Because it implies there is a concept of
> logged out. Which generally doesn't happen. All you can know is that you
> have seen a particular session cookie before. However, you are not
> guaranteed to know that you will never see a session cookie again in the
> future unless the user explicitly tells you to delete it. And that isn't
> always possible. What if you have browser-based sessions, so the cookies
> expires when the browser is closed. And now the user's browser crashes,
> or they shut it down, or their laptop battery runs out? They no longer
> have the cookie and so they cannot tell you to remove it. That's just
> one of a large number of scenarios in which you are setting things up so
> that users will not be able to use your site as a result of fairly
> normal behaviour of themselves and their computers.
>
>
>
> > I don't know if django has a good way to query if the user is logged
> > in or not...
>
> You cannot query for session identifiers by username, no.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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 Allow "-" character in usernames in the admin application

2009-07-31 Thread Vasil Vangelovski

You can unregister the User model and default UserAdmin from the admin 
site, then register it again but after changing  form and add_form of 
UserAdmin with you custom form classes. Looking at the code for 
django.contrib.auth.admin will probably make things clearer for you:

http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/admin.py



tristan wrote:
> In our webapp we needed to allow dashes "-" in our usernames. I've
> enabled that for the consumer signup process just fine with this regex
> r'^[\w-]+$'
>
> How can I tell the admin app so that I can edit usernames in auth >
> users to allows the "-" character in usernames?
> >
>   


--~--~-~--~~~---~--~~
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: permalink don't works

2009-07-31 Thread Brian May

On Thu, Jul 30, 2009 at 12:18:17AM -0700, gentlestone wrote:
> I found this text on the tutorial page 
> http://docs.djangoproject.com/en/dev/ref/models/instances/
> -
> ...you could reference this using permalink() as follows:
> 
> @models.permalink
> def get_absolute_url(self):
> return ('archive_view', (), {
> 'year': self.created.year,
> 'month': self.created.month,
> 'day': self.created.day})
> 
> Notice that we specify an empty sequence for the second parameter in
> this case, because we only want to pass keyword parameters, not
> positional ones.
> ---
> isn't it the right text?

Yes, you are right. Not sure how I missed this now. Repeatedly. :-(
-- 
Brian May 

--~--~-~--~~~---~--~~
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: Stopping people loging in twice

2009-07-31 Thread Malcolm Tredinnick

On Fri, 2009-07-31 at 19:43 -0700, django user wrote:
> I'm interested in a solution for this as well.
> 
> I am thinking that a good way might be to rewrite the auth middleware
> to check and see if a user login for this user exists and if it does
> then remove that login and log in the current user. A message could
> then be passed to the login page letting them know that they have
> logged in elsewhere and their session at this computer was ended.

HTTP is a stateless protocol. By design. As has been pointed out in
another reply in this thread, the concept of "already logged in" is
therefore no very well defined. Because it implies there is a concept of
logged out. Which generally doesn't happen. All you can know is that you
have seen a particular session cookie before. However, you are not
guaranteed to know that you will never see a session cookie again in the
future unless the user explicitly tells you to delete it. And that isn't
always possible. What if you have browser-based sessions, so the cookies
expires when the browser is closed. And now the user's browser crashes,
or they shut it down, or their laptop battery runs out? They no longer
have the cookie and so they cannot tell you to remove it. That's just
one of a large number of scenarios in which you are setting things up so
that users will not be able to use your site as a result of fairly
normal behaviour of themselves and their computers.


> 
> I don't know if django has a good way to query if the user is logged
> in or not...

You cannot query for session identifiers by username, no.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: Stopping people loging in twice

2009-07-31 Thread django user

I'm interested in a solution for this as well.

I am thinking that a good way might be to rewrite the auth middleware
to check and see if a user login for this user exists and if it does
then remove that login and log in the current user. A message could
then be passed to the login page letting them know that they have
logged in elsewhere and their session at this computer was ended.

I don't know if django has a good way to query if the user is logged
in or not...

On Jul 31, 8:04 am, When ideas fail  wrote:
> Hello, if i am using this generic view in my urls.py?
>
> (r'^accounts/login/$', 'django.contrib.auth.views.login',
> {'template_name': 'myapp/login.html'}),
>
> Is there a way i can stopped people who are already logged in logging
> in again?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Log in problem

2009-07-31 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Try: {% if user.is_authenticated() %}

If that doesn't work, you would need to setup the
TEMPLATE_CONTEXT_PROCESSORS setting in settings.py.

http://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors

Luke
luke.seelenbin...@gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire


When ideas fail wrote:
> Ok, thanks, i will try that. As a thought could i not have something
> like:
> 
> {% ifequal user.username "" %}
> 
> login form
> 
> {% else %}
> 
>  you are already logged in
> 
> I don't know if that would work or not though.
> 
> On 1 Aug, 01:30, Luke Seelenbinder 
> wrote:
> No it doesn't. That would be your problem, you would have to write a
> custom backend if you wanted to not show the login form to already
> logged-in visitors.
> 
> Luke
> luke.seelenbin...@gmail.com
> 
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> 
> 
> 
> When ideas fail wrote:
 I'm using (r'^login/$', 'django.contrib.auth.views.login',
 {'template_name': 'blogSite/login.html'}), for the view, so does that
 pass a request of not?
 On 1 Aug, 01:09, Luke Seelenbinder 
 wrote:
 Are you passing the "request" to it?
 That's the only thing I can think of that would mess it up, otherwise it
 looks good syntactically.
 Luke
 luke.seelenbin...@gmail.com
 "I [may] disapprove of what you say, but I will defend to the death your
 right to say it." -- Voltaire
 When ideas fail wrote:
>>> Hi, i am using this template to log people in, but it seems to always
>>> return the login form no matter what i do, i can be logged in or
>>> logged out and it will still say i need to log in.
>>> Does anyone know what might be happening. Any help would be
>>> appreciated.
>>> Thanks
>>> {% extends "blogSite/index.html" %}
>>> {% block content %}
>>>{% if not request.user.is_authenticated %}
>>>{% if form.errors %}
>>>Sorry, that's not a valid 
>>> username or
>>> password
>>>{% endif %}
>>> Please enter you user name and password 
>>> below:
>>>
>>>>> for="username">Username:
>>>>> value=""
>>> id="username">
>>>>> for="password">Password:
>>>>> name="password" value=""
>>> id="password">
>>>
>>>>> value="../login/" />
>>>
>>>{% else %}
>>> you are already logged in 
>>>{% endif %}
>>> {% endblock %}
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpzqlIACgkQXQrGVCncjPzD9gCgne53F8UBFiwMpzD0WxfLFDd9
7K4AoIXGlYzqJNh3g+J8pBqsDFH4MaYa
=8Mku
-END PGP SIGNATURE-

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



Re: Dynamic Choices for ChoiceField

2009-07-31 Thread Malcolm Tredinnick

On Fri, 2009-07-31 at 16:31 -0700, mviamari wrote:
> Hello,
> 
> I'm trying to make a form for data entry into my database that uses
> ChoiceFields for foreign keys.  Obviously, the ideal choice would be
> ModelChoiceField, however I'm not using the django ORM, so I've
> assumed that's not going to work (I'm using Elixir/SQLAlchemy).
> 
> I originally set the choices parameter in the ChoiceField declaration
> to be derived from a query result from SQLAlchemy (returned as an
> array of tuples).  The problem is that the choices don't update when
> the database changes.  They are fixed to whatever was present when the
> server is initialized (or at least it appears to be).

If you have specified the choices field as a parameter to a Field
subclass in a Form class, then it will be evaluated whenever that Form
class is parsed (probably at import time). That's normal Python
behaviour.

> I'm looking for suggestions/advice on to get the ChoiceField choices
> to update when the form is the used.

"Used" is probably a bit ambiguous here. It's probably easier to think
in terms of "when an instance of the form class is created." The
solution is to update the choices attribute on the appropriate field in
the Form subclass's __init__() method. For example

class MyForm(forms.Form):
   options = forms.ChoiceField()

   def __init__(self, *args, **kwargs):
  super(MyForm, self).__init__(*args, **kwargs)
  choices = ...   # <-- create a sequence of 2-tuples
  self.fields["options"].choices = choices

You can do whatever you like to populate the "choices" variable in the
above fragment. The only requirement is that you end up with a sequence
of pairs which are the submitted form value and the human readable text
for the form element.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 get some related data from different tables to one queryset?

2009-07-31 Thread Malcolm Tredinnick

On Fri, 2009-07-31 at 14:42 -0700, Unnamed_Hero wrote:
> I have something like this:
> 
> class Translation1(models.Model):
> code = models.IntegerField(primary_key=True)
> description = models.CharField()
> 
> class Translation2(models.Model):
> code = models.IntegerField(primary_key=True)
> description = models.CharField()
> 
> class TranslationN(models.Model):
> code = models.IntegerField(primary_key=True)
> description = models.CharField()
> 
> class MainDB (models.Model):
>tr1_code = models.IntegerField() #code from Translation1
>tr2_code = models.IntegerField() #code from Translation2
>tr3_code = models.IntegerField() #code from Translation3

If these are meant to be referring to entries in the tables for
Translation1, etc, then make them ForeignKey fields, not IntegerFields.
The way you have set up your models, there is no way for Django to know
there is any relationship here.

[...]
> For limiting fields I've created a manager for MainDB, and it works
> fine. Then I've tried to do like this:
> 
> 
> class my_MainDB (MainDB):
>tr1_value = models.ForeignKey (Translation1)
> 
> #views.py
>  result = my_MainDB.gos_req.select_related() #gos_req - my manager
> 
> but I see it is wrong, because djando doesn't know that tr1_value must
> be related to tr1_code field...

[...]
> Is my only way is using this RAW SQL?

Unless you are able to fix your modelling, yes. You haven't modelled a
system of related data. You have said there are various integers
floating around, but not relationships between them.

Regards,
Malcolm

> > 
> 


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



Re: using the stable api

2009-07-31 Thread Malcolm Tredinnick

On Fri, 2009-07-31 at 11:42 -0400, Faheem Mitha wrote:
> 
> Hi everybody,
> 
> I upgraded from somewhere around Django 1.0 to 1.0.2, and some things 
> broke and had to be changed. In the following, f is an object of class 
> 'django.core.files.uploadedfile.TemporaryUploadedFile'. I need to
> 
> 1) Get the contents of the file corresponding to f. I had to change 
> f['content'] to f._file.read()
> 
> From the docs (specifically, 'core/files/uploadedfile.py') it looks like 
> f.read() might be the right thing?

The correct way to access uploaded file data is documented here:
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handling-uploaded-files

That is the public API, and you are correct in thinking that read() is
the method you're after here.

> 
> 2) Get the filename of the file corresponding to f. I had to change 
> f['filename'] to f._name.

This is also documented in the above reference. Use the "name" attribute
on the UploadedFile isntance.

> 
> 3) Get the sessionid. I had to change request.COOKIES['sessionid'] to 
> request.COOKIES[settings.SESSION_COOKIE_NAME]

The default value of settings.SESSION_COOKIE_NAME has always (and
remains) "sessionid". However, it's a little more portable to use the
latter form (request.COOKIES[settings.SESSION_COOKIE_NAME) in your
applications, since then they are usable no matter what the setting
happens to be. A Django application writer is not necessarily in control
of the settings that will be used when the application is installed.


> 
> It is presumably better to use a stable API rather than less stable 
> internals,

It is *always* better. :-)

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: Stopping people loging in twice

2009-07-31 Thread Brian May

On Fri, Jul 31, 2009 at 08:04:50AM -0700, When ideas fail wrote:
> Is there a way i can stopped people who are already logged in logging
> in again?

My initial thought - this sounds risky - for a website.

How do you know if the user is already logged in?

The computer they were using may have died, and now they are trying to log in
on another computer. They can't log out on the first computer - it crashed.

Instead they will have to wait for the session to time out.
-- 
Brian May 

--~--~-~--~~~---~--~~
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: Log in problem

2009-07-31 Thread When ideas fail

Ok, thanks, i will try that. As a thought could i not have something
like:

{% ifequal user.username "" %}

login form

{% else %}

 you are already logged in

I don't know if that would work or not though.

On 1 Aug, 01:30, Luke Seelenbinder 
wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> No it doesn't. That would be your problem, you would have to write a
> custom backend if you wanted to not show the login form to already
> logged-in visitors.
>
> Luke
> luke.seelenbin...@gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
>
> When ideas fail wrote:
> > I'm using (r'^login/$', 'django.contrib.auth.views.login',
> > {'template_name': 'blogSite/login.html'}), for the view, so does that
> > pass a request of not?
>
> > On 1 Aug, 01:09, Luke Seelenbinder 
> > wrote:
> > Are you passing the "request" to it?
> > That's the only thing I can think of that would mess it up, otherwise it
> > looks good syntactically.
>
> > Luke
>
> > luke.seelenbin...@gmail.com
>
> > "I [may] disapprove of what you say, but I will defend to the death your
> > right to say it." -- Voltaire
>
> > When ideas fail wrote:
>  Hi, i am using this template to log people in, but it seems to always
>  return the login form no matter what i do, i can be logged in or
>  logged out and it will still say i need to log in.
>  Does anyone know what might be happening. Any help would be
>  appreciated.
>  Thanks
>  {% extends "blogSite/index.html" %}
>  {% block content %}
>     {% if not request.user.is_authenticated %}
>             {% if form.errors %}
>                             Sorry, that's not a valid 
>  username or
>  password
>             {% endif %}
>                      Please enter you user name and password below:
>                     
>                                       for="username">Username:
>                                       value=""
>  id="username">
>                                       for="password">Password:
>                                       name="password" value=""
>  id="password">
>                             
>                                       value="../login/" />
>                     
>     {% else %}
>              you are already logged in 
>     {% endif %}
>  {% endblock %}
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkpzjIsACgkQXQrGVCncjPwajACfaas+qNkiozhiTDdnxJHFb0OB
> SuoAn31FpPjrbeD4AlOqeOt5B6adzXd/
> =qG2H
> -END PGP SIGNATURE-
--~--~-~--~~~---~--~~
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: Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?

2009-07-31 Thread Vasil Vangelovski

Thanks :)

Luke Seelenbinder wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> No, you would not. Hope that helps.
>
> Luke
>
> luke.seelenbin...@gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
> Vasil Vangelovski wrote:
>   
>> It's like this:
>> I actually have 3 projects. These projects share apps. So all the apps 
>> besides the third party ones are placed in one folder which is on 
>> PYTHONPATH. The third party ones are in another folder on the 
>> PYTHONPATH. Yes 2 of these projects use the admin and do use the 
>> ModelBackend for authentication, I have django.contrib.auth in 
>> INSTALLED_APPS for those 2.
>>
>> But this smaller project I'm asking about provides just a few views for 
>> a REST API. Now the calls to that REST service are made only by one 
>> application on the internal network which will have it's own 
>> username/password in the settings file. And this project doesn't use the 
>> admin or any of the models in django.contrib.auth (besides returning 
>> User from the authenticate method in the backend).
>>
>> So I guess I don't need django.contrib.auth in INSTALLED_APPS for that 
>> project.
>>
>> Luke Seelenbinder wrote:
>> Vasil,
>>
>> That will vary on what the apps you are using. If none of the apps
>> depend on django.contrib.auth, you won't need it, unless you want to use
>> the django admin (which depends on django.contrib.auth).
>>
>> To fully answer your question, we would need to know what apps it is using.
>>
>> Luke
>> luke.seelenbin...@gmail.com
>>
>> "I [may] disapprove of what you say, but I will defend to the death your
>> right to say it." -- Voltaire
>>
>>
>> Vasil Vangelovski wrote:
>>   
>> 
> I'm making a very small project that will use the apps/models from a 
> larger one. This will be hosted on a separate domain. Now the larger 
> project uses the models from django.contrib.auth, but I don't need and 
> don't want to store users in a database for this smaller one. I'll just 
> provide my own authentication backend that reads usernames and password 
> from a config file and uses Base64 authentication. Do I still need to 
> put django.contrib.auth in INSTALLED_APPS?
>
> 
>   
>
>   
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkpzjOQACgkQXQrGVCncjPysvQCcCXJrUwoK7pzgqp8LCh0BDby5
> VIsAn3rEh74fXv9xaAF0AOFO83rYJ0TW
> =K69Z
> -END PGP SIGNATURE-
>
> >
>   


--~--~-~--~~~---~--~~
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: Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?

2009-07-31 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

No, you would not. Hope that helps.

Luke

luke.seelenbin...@gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire


Vasil Vangelovski wrote:
> It's like this:
> I actually have 3 projects. These projects share apps. So all the apps 
> besides the third party ones are placed in one folder which is on 
> PYTHONPATH. The third party ones are in another folder on the 
> PYTHONPATH. Yes 2 of these projects use the admin and do use the 
> ModelBackend for authentication, I have django.contrib.auth in 
> INSTALLED_APPS for those 2.
> 
> But this smaller project I'm asking about provides just a few views for 
> a REST API. Now the calls to that REST service are made only by one 
> application on the internal network which will have it's own 
> username/password in the settings file. And this project doesn't use the 
> admin or any of the models in django.contrib.auth (besides returning 
> User from the authenticate method in the backend).
> 
> So I guess I don't need django.contrib.auth in INSTALLED_APPS for that 
> project.
> 
> Luke Seelenbinder wrote:
> Vasil,
> 
> That will vary on what the apps you are using. If none of the apps
> depend on django.contrib.auth, you won't need it, unless you want to use
> the django admin (which depends on django.contrib.auth).
> 
> To fully answer your question, we would need to know what apps it is using.
> 
> Luke
> luke.seelenbin...@gmail.com
> 
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> 
> 
> Vasil Vangelovski wrote:
>   
 I'm making a very small project that will use the apps/models from a 
 larger one. This will be hosted on a separate domain. Now the larger 
 project uses the models from django.contrib.auth, but I don't need and 
 don't want to store users in a database for this smaller one. I'll just 
 provide my own authentication backend that reads usernames and password 
 from a config file and uses Base64 authentication. Do I still need to 
 put django.contrib.auth in INSTALLED_APPS?

 
>>

> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpzjOQACgkQXQrGVCncjPysvQCcCXJrUwoK7pzgqp8LCh0BDby5
VIsAn3rEh74fXv9xaAF0AOFO83rYJ0TW
=K69Z
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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: Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?

2009-07-31 Thread Vasil Vangelovski

It's like this:
I actually have 3 projects. These projects share apps. So all the apps 
besides the third party ones are placed in one folder which is on 
PYTHONPATH. The third party ones are in another folder on the 
PYTHONPATH. Yes 2 of these projects use the admin and do use the 
ModelBackend for authentication, I have django.contrib.auth in 
INSTALLED_APPS for those 2.

But this smaller project I'm asking about provides just a few views for 
a REST API. Now the calls to that REST service are made only by one 
application on the internal network which will have it's own 
username/password in the settings file. And this project doesn't use the 
admin or any of the models in django.contrib.auth (besides returning 
User from the authenticate method in the backend).

So I guess I don't need django.contrib.auth in INSTALLED_APPS for that 
project.

Luke Seelenbinder wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Vasil,
>
> That will vary on what the apps you are using. If none of the apps
> depend on django.contrib.auth, you won't need it, unless you want to use
> the django admin (which depends on django.contrib.auth).
>
> To fully answer your question, we would need to know what apps it is using.
>
> Luke
> luke.seelenbin...@gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
> Vasil Vangelovski wrote:
>   
>> I'm making a very small project that will use the apps/models from a 
>> larger one. This will be hosted on a separate domain. Now the larger 
>> project uses the models from django.contrib.auth, but I don't need and 
>> don't want to store users in a database for this smaller one. I'll just 
>> provide my own authentication backend that reads usernames and password 
>> from a config file and uses Base64 authentication. Do I still need to 
>> put django.contrib.auth in INSTALLED_APPS?
>>
>> 
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkpziWMACgkQXQrGVCncjPxAVQCfb2PIkFzWgU5v2CGYe8oh5gG3
> vNUAnihZxM5r0KgJpAR7V0G+TrEFFETD
> =qJUh
> -END PGP SIGNATURE-
>
> >
>   


--~--~-~--~~~---~--~~
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: Log in problem

2009-07-31 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

No it doesn't. That would be your problem, you would have to write a
custom backend if you wanted to not show the login form to already
logged-in visitors.

Luke
luke.seelenbin...@gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire


When ideas fail wrote:
> I'm using (r'^login/$', 'django.contrib.auth.views.login',
> {'template_name': 'blogSite/login.html'}), for the view, so does that
> pass a request of not?
> 
> On 1 Aug, 01:09, Luke Seelenbinder 
> wrote:
> Are you passing the "request" to it?
> That's the only thing I can think of that would mess it up, otherwise it
> looks good syntactically.
> 
> Luke
> 
> luke.seelenbin...@gmail.com
> 
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> 
> 
> 
> When ideas fail wrote:
 Hi, i am using this template to log people in, but it seems to always
 return the login form no matter what i do, i can be logged in or
 logged out and it will still say i need to log in.
 Does anyone know what might be happening. Any help would be
 appreciated.
 Thanks
 {% extends "blogSite/index.html" %}
 {% block content %}
{% if not request.user.is_authenticated %}
{% if form.errors %}
Sorry, that's not a valid 
 username or
 password
{% endif %}
 Please enter you user name and password below:

Username:
>>> value=""
 id="username">
Password:
>>> value=""
 id="password">

>>> value="../login/" />

{% else %}
 you are already logged in 
{% endif %}
 {% endblock %}
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpzjIsACgkQXQrGVCncjPwajACfaas+qNkiozhiTDdnxJHFb0OB
SuoAn31FpPjrbeD4AlOqeOt5B6adzXd/
=qG2H
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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: Log in problem

2009-07-31 Thread When ideas fail

I'm using (r'^login/$', 'django.contrib.auth.views.login',
{'template_name': 'blogSite/login.html'}), for the view, so does that
pass a request of not?

On 1 Aug, 01:09, Luke Seelenbinder 
wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Are you passing the "request" to it?
> That's the only thing I can think of that would mess it up, otherwise it
> looks good syntactically.
>
> Luke
>
> luke.seelenbin...@gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
>
> When ideas fail wrote:
> > Hi, i am using this template to log people in, but it seems to always
> > return the login form no matter what i do, i can be logged in or
> > logged out and it will still say i need to log in.
>
> > Does anyone know what might be happening. Any help would be
> > appreciated.
>
> > Thanks
>
> > {% extends "blogSite/index.html" %}
>
> > {% block content %}
> >    {% if not request.user.is_authenticated %}
> >            {% if form.errors %}
> >                            Sorry, that's not a valid 
> > username or
> > password
> >            {% endif %}
> >                     Please enter you user name and password below:
> >                    
> >                                    Username:
> >                                     > value=""
> > id="username">
> >                                    Password:
> >                                     > value=""
> > id="password">
>
> >                            
> >                                     > value="../login/" />
> >                    
> >    {% else %}
> >             you are already logged in 
> >    {% endif %}
>
> > {% endblock %}
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkpzh8AACgkQXQrGVCncjPxJVACfQ68PD0uA2KGisU43jpzSLTbj
> p78AnjVqqu37G8JTPQHI4Lnuatn++JuJ
> =DCaK
> -END PGP SIGNATURE-
--~--~-~--~~~---~--~~
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: Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?

2009-07-31 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Vasil,

That will vary on what the apps you are using. If none of the apps
depend on django.contrib.auth, you won't need it, unless you want to use
the django admin (which depends on django.contrib.auth).

To fully answer your question, we would need to know what apps it is using.

Luke
luke.seelenbin...@gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire


Vasil Vangelovski wrote:
> I'm making a very small project that will use the apps/models from a 
> larger one. This will be hosted on a separate domain. Now the larger 
> project uses the models from django.contrib.auth, but I don't need and 
> don't want to store users in a database for this smaller one. I'll just 
> provide my own authentication backend that reads usernames and password 
> from a config file and uses Base64 authentication. Do I still need to 
> put django.contrib.auth in INSTALLED_APPS?
> 
> > 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpziWMACgkQXQrGVCncjPxAVQCfb2PIkFzWgU5v2CGYe8oh5gG3
vNUAnihZxM5r0KgJpAR7V0G+TrEFFETD
=qJUh
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?

2009-07-31 Thread Vasil Vangelovski

I'm making a very small project that will use the apps/models from a 
larger one. This will be hosted on a separate domain. Now the larger 
project uses the models from django.contrib.auth, but I don't need and 
don't want to store users in a database for this smaller one. I'll just 
provide my own authentication backend that reads usernames and password 
from a config file and uses Base64 authentication. Do I still need to 
put django.contrib.auth in INSTALLED_APPS?

--~--~-~--~~~---~--~~
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: Log in problem

2009-07-31 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Are you passing the "request" to it?
That's the only thing I can think of that would mess it up, otherwise it
looks good syntactically.

Luke

luke.seelenbin...@gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire


When ideas fail wrote:
> Hi, i am using this template to log people in, but it seems to always
> return the login form no matter what i do, i can be logged in or
> logged out and it will still say i need to log in.
> 
> Does anyone know what might be happening. Any help would be
> appreciated.
> 
> Thanks
> 
> {% extends "blogSite/index.html" %}
> 
> {% block content %}
>   {% if not request.user.is_authenticated %}
>   {% if form.errors %}
>   Sorry, that's not a valid username or
> password
>   {% endif %}
>Please enter you user name and password below:
>   
>   Username:
>id="username">
>   Password:
>id="password">
> 
>   
>value="../login/" />
>   
>   {% else %}
>you are already logged in 
>   {% endif %}
> 
> {% endblock %}
> > 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpzh8AACgkQXQrGVCncjPxJVACfQ68PD0uA2KGisU43jpzSLTbj
p78AnjVqqu37G8JTPQHI4Lnuatn++JuJ
=DCaK
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Log in problem

2009-07-31 Thread When ideas fail

Hi, i am using this template to log people in, but it seems to always
return the login form no matter what i do, i can be logged in or
logged out and it will still say i need to log in.

Does anyone know what might be happening. Any help would be
appreciated.

Thanks

{% extends "blogSite/index.html" %}

{% block content %}
{% if not request.user.is_authenticated %}
{% if form.errors %}
Sorry, that's not a valid username or
password
{% endif %}
 Please enter you user name and password below:

Username:

Password:





{% else %}
 you are already logged in 
{% endif %}

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



Dynamic Choices for ChoiceField

2009-07-31 Thread mviamari

Hello,

I'm trying to make a form for data entry into my database that uses
ChoiceFields for foreign keys.  Obviously, the ideal choice would be
ModelChoiceField, however I'm not using the django ORM, so I've
assumed that's not going to work (I'm using Elixir/SQLAlchemy).

I originally set the choices parameter in the ChoiceField declaration
to be derived from a query result from SQLAlchemy (returned as an
array of tuples).  The problem is that the choices don't update when
the database changes.  They are fixed to whatever was present when the
server is initialized (or at least it appears to be).

I've worked around this by using CharFields and implementing my own
validation method that checks for the value in the aforesaid query
result.  Unforunately, that doesn't help me if i want to use the
forms.as_ methods.

I'm looking for suggestions/advice on to get the ChoiceField choices
to update when the form is the used.

Thanks,
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
-~--~~~~--~~--~--~---



how to get some related data from different tables to one queryset?

2009-07-31 Thread Unnamed_Hero

I have something like this:

class Translation1(models.Model):
code = models.IntegerField(primary_key=True)
description = models.CharField()

class Translation2(models.Model):
code = models.IntegerField(primary_key=True)
description = models.CharField()

class TranslationN(models.Model):
code = models.IntegerField(primary_key=True)
description = models.CharField()

class MainDB (models.Model):
   tr1_code = models.IntegerField() #code from Translation1
   tr2_code = models.IntegerField() #code from Translation2
   tr3_code = models.IntegerField() #code from Translation3
   name = models.CharField()
   model = models.CharField ()
   some_field1 = models.CharField ()
   some_fieldN = models.CharField ()


How can I get info from MainDB, but code1 description instead of
tr1_code,  code2 description instead of tr2_code

For limiting fields I've created a manager for MainDB, and it works
fine. Then I've tried to do like this:


class my_MainDB (MainDB):
   tr1_value = models.ForeignKey (Translation1)

#views.py
 result = my_MainDB.gos_req.select_related() #gos_req - my manager

but I see it is wrong, because djando doesn't know that tr1_value must
be related to tr1_code field...

The raw sql query is look like this:

SELECT
A1,A2,A20,A18,A45,A4,A5,A41,A36,A38,K1,K2,A27,A25,FED.RA,FED.N1,EC.RA,EC.N1,A34
FROM C12B,RKA,C014P FED,C014P EC WHERE A34='02100' AND A38=K1 AND
A41=FED.RA AND A36=EC.RA ORDER BY A1

c12b - is MainDB; RKA, C014P... - are like translation1 (2,3,...)

Is my only way is using this RAW SQL?
--~--~-~--~~~---~--~~
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: Multi select field with images

2009-07-31 Thread django user

shameless bump. Still can't figure out how this would be
accomplished...

On Jul 8, 8:01 pm, Tim Boy  wrote:
> What's the best way to make this "custom" widget. I can't find any
> information online with someone making a widget do anything different to the
> actual html of the widget.
>
> TIA
>
> On Wed, Jul 8, 2009 at 12:20 AM, mugisha moses  wrote:
>
> > you have to do a custom select widget .  even if you passed the
> > choices the image urls they would not be rendered.
>
> > On Wed, Jul 8, 2009 at 8:44 AM, ankit rai wrote:
> > > little more explanation is required
>
> > > On Wed, Jul 8, 2009 at 10:31 AM, djangou...@gmail.com <
> > djangou...@gmail.com>
> > > wrote:
>
> > >> I have a modelform and I want to make one of my select multiple fields
> > >> choices be images and not text.
>
> > >> ideas/suggestions appreciated
>
> > >> -- Sent from my Palm Pre
>
> > --
> > 
> > Mugisha Moses
> > P.O. Box 1420 Kampala, Uganda
> >http://appfrica.org
> > skype name :  mossplix
> > twitter: @mugisha
--~--~-~--~~~---~--~~
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 Allow "-" character in usernames in the admin application

2009-07-31 Thread tristan

In our webapp we needed to allow dashes "-" in our usernames. I've
enabled that for the consumer signup process just fine with this regex
r'^[\w-]+$'

How can I tell the admin app so that I can edit usernames in auth >
users to allows the "-" character in usernames?
--~--~-~--~~~---~--~~
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: forward declaration

2009-07-31 Thread Daymien

I got it!
thank you
--~--~-~--~~~---~--~~
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: quick question: how to have *.domainname.com url in django

2009-07-31 Thread Javier Guerra

On Fri, Jul 31, 2009 at 1:23 PM, weiwei wrote:
> Could you please expand  the process " send all those names to the
> same Django instance" a little bit more detailed?

that's totally about the frontend server and not about Django.  As
Graham said, apache accepts wildcard characters in the hostname.
other servers do it different.

-- 
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: forward declaration

2009-07-31 Thread Alex Gaynor

On Fri, Jul 31, 2009 at 1:56 PM, Daymien wrote:
>
> Hallo,
>
> How could I implement forward declaration in django models?
> this example wouldn't work for me:
> Has anyone an idear or a solution?
>
> This django model show a simple implementation for a bloodline app!
> 
> from django.db import models
> from django.contrib.auth.models import User
> from django.contrib import admin
>
> class Parent:
>    pass
> class Child:
>    pass
>
> class AbstractUser(models.Model):
>    user_id = models.ForeignKey(User, blank=True)
>    birthday = models.DateField("birthday", blank=True, null=True)
>    day_of_death = models.DateField("day of death", blank=True,
> null=True)
>    parents = models.ManyToManyField(Parent, blank=True, null=True)
>    childs = models.ManyToManyField(Child, blank=True, null=True)
>
> class Parent(AbstractUser):
>    #user_id = models.ForeignKey(User, blank=True)
>    def __unicode__(self):
>        return "%s %s" % (self.user_id.first_name,
> self.user_id.last_name)
>
> class Child(AbstractUser):
>    #user_id = models.ForeignKey(User, blank=True)
>    def __unicode__(self):
>        return "%s %s" % (self.user_id.first_name,
> self.user_id.last_name)
>
> class MyUser(AbstractUser):
>    """ Represent a User for this site
>    """
>    def __unicode__(self):
>        return "%s %s" % (self.user_id.first_name,
> self.user_id.last_name)
>
> admin.site.register(MyUser)
> admin.site.register(Parent)
> admin.site.register(Child)
> 
> I got this error message:
> AssertionError: ManyToManyField( stammbaum.bloodline.models.Parent at 0x84fc11c>) is invalid. First
> parameter to ManyToManyField must be either a model, a model name, or
> the string 'self'
>
> regards
> R.Klain
> >
>

Take a look at how you can pass the string name of the class to avoid
this issue: 
http://docs.djangoproject.com/en/dev/ref/models/fields/#module-django.db.models.fields.related

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



forward declaration

2009-07-31 Thread Daymien

Hallo,

How could I implement forward declaration in django models?
this example wouldn't work for me:
Has anyone an idear or a solution?

This django model show a simple implementation for a bloodline app!

from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin

class Parent:
pass
class Child:
pass

class AbstractUser(models.Model):
user_id = models.ForeignKey(User, blank=True)
birthday = models.DateField("birthday", blank=True, null=True)
day_of_death = models.DateField("day of death", blank=True,
null=True)
parents = models.ManyToManyField(Parent, blank=True, null=True)
childs = models.ManyToManyField(Child, blank=True, null=True)

class Parent(AbstractUser):
#user_id = models.ForeignKey(User, blank=True)
def __unicode__(self):
return "%s %s" % (self.user_id.first_name,
self.user_id.last_name)

class Child(AbstractUser):
#user_id = models.ForeignKey(User, blank=True)
def __unicode__(self):
return "%s %s" % (self.user_id.first_name,
self.user_id.last_name)

class MyUser(AbstractUser):
""" Represent a User for this site
"""
def __unicode__(self):
return "%s %s" % (self.user_id.first_name,
self.user_id.last_name)

admin.site.register(MyUser)
admin.site.register(Parent)
admin.site.register(Child)

I got this error message:
AssertionError: ManyToManyField() is invalid. First
parameter to ManyToManyField must be either a model, a model name, or
the string 'self'

regards
R.Klain
--~--~-~--~~~---~--~~
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: odd behavior with session variable that contains a list

2009-07-31 Thread Margie

Makes perfect sense, thanks for that pointer!

On Jul 31, 11:17 am, Alex Gaynor  wrote:
> On Fri, Jul 31, 2009 at 1:15 PM, Margie wrote:
>
> > I am seeing some behavior with session that I don't understand.  If I
> > have a session variable called recentAddIds that contains a list.  I
> > find that if I append to that list, like this:
>
> >   request.session['recentAddIds'].append(newlySavedId)
>
> > Then when I next receive a GET, I find that request.session
> > ['recentAddIds'] does not contain the appended data (but does contain
> > the data that was there prior to the append).
>
> > If I instead make a copy of the list and put that copy into the
> > session variable, then when I next receive a GET, my session variable
> > does not contain the newly appended data.
>
> >    request.session['recentAddIds'] = [x for x in request.session
> > ['recentAddIds']] + [newlySavedId]
>
> > Can anyone explain why this is and if it is expected behavior?  Is it
> > ok for sesion variables to contain lists or other complex structures,
> > or should they just be simple strings?
>
> > Margie
>
> The reason this is is because of how some of python's magic methods
> work.  doing request.SESSION['key'].append() uses the __getitem__
> method on request.SESSION and calls append on the result, whereas
> doing request.SESSION['key'] = val uses the __setitem__ 
> method.http://docs.djangoproject.com/en/dev/topics/http/sessions/#when-sessi...
> describes how to work with this behavior.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
--~--~-~--~~~---~--~~
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: quick question: how to have *.domainname.com url in django

2009-07-31 Thread weiwei

Could you please expand  the process " send all those names to the
same Django instance" a little bit more detailed?


Thanks


On Jul 31, 7:17 am, Javier Guerra  wrote:
> On Fri, Jul 31, 2009 at 12:26 AM, weiwei wrote:
> > thanks, i was thinking to have each user have a url 
> > ashttp://username.domain.com/
>
> after you manage to configure your frontend server (apache, lightttpd,
> nginx, whatever) to send all those names to the same Django instance,
> i'd just write a middleware that picks the name from the original URL
> and stores it (or maybe the whole User object) in the request.
>
> --
> 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: odd behavior with session variable that contains a list

2009-07-31 Thread Alex Gaynor

On Fri, Jul 31, 2009 at 1:15 PM, Margie wrote:
>
> I am seeing some behavior with session that I don't understand.  If I
> have a session variable called recentAddIds that contains a list.  I
> find that if I append to that list, like this:
>
>   request.session['recentAddIds'].append(newlySavedId)
>
> Then when I next receive a GET, I find that request.session
> ['recentAddIds'] does not contain the appended data (but does contain
> the data that was there prior to the append).
>
> If I instead make a copy of the list and put that copy into the
> session variable, then when I next receive a GET, my session variable
> does not contain the newly appended data.
>
>    request.session['recentAddIds'] = [x for x in request.session
> ['recentAddIds']] + [newlySavedId]
>
> Can anyone explain why this is and if it is expected behavior?  Is it
> ok for sesion variables to contain lists or other complex structures,
> or should they just be simple strings?
>
> Margie
> >
>

The reason this is is because of how some of python's magic methods
work.  doing request.SESSION['key'].append() uses the __getitem__
method on request.SESSION and calls append on the result, whereas
doing request.SESSION['key'] = val uses the __setitem__ method.
http://docs.djangoproject.com/en/dev/topics/http/sessions/#when-sessions-are-saved
describes how to work with this behavior.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



odd behavior with session variable that contains a list

2009-07-31 Thread Margie

I am seeing some behavior with session that I don't understand.  If I
have a session variable called recentAddIds that contains a list.  I
find that if I append to that list, like this:

   request.session['recentAddIds'].append(newlySavedId)

Then when I next receive a GET, I find that request.session
['recentAddIds'] does not contain the appended data (but does contain
the data that was there prior to the append).

If I instead make a copy of the list and put that copy into the
session variable, then when I next receive a GET, my session variable
does not contain the newly appended data.

request.session['recentAddIds'] = [x for x in request.session
['recentAddIds']] + [newlySavedId]

Can anyone explain why this is and if it is expected behavior?  Is it
ok for sesion variables to contain lists or other complex structures,
or should they just be simple strings?

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



Re: Template links when Django not domain root

2009-07-31 Thread Adam Yee

On Jul 30, 7:29 pm, Graham Dumpleton 
wrote:
> If you are using mod_wsgi then you definitely do not need
> FORCE_SCRIPT_NAME as mod_wsgi does the correct think in respect of
> setting up SCRIPT_NAME/PATH_INFO. The only time it might not be right
> with mod_wsgi is if you used WSGIScriptAliasMatch to map the
> application and you didn't set up the directive properly. This can
> happen because how you set up pattern and target for that directive
> will control how SCRIPT_NAME is calculated. WSGIScriptAliasMatch
> should only be used if absolutely required.
>
> So, post how you configured mod_wsgi to mount your application just to
> eliminate that as possibility. Verify that FORCE_SCRIPT_NAME isn't set
> in settings.py or if it is that it is set to None.
>
> Someone with more Django knowledge would then need to tell you if you
> are specifying urls.py correctly, whether any other settings you need
> to check and whether how URL references are generated are correct. All
> I can tell you is that if mod_wsgi is set up properly, you should
> never need FORCE_SCRIPT_NAME with mod_wsgi.
>
> You may need to explain better what is meant by 'This is causing all
> my template links to break'. Ie., what errors are you getting, what
> are the URLs it is generating and what they should be etc.
>
> Graham
>
> On Jul 31, 12:09 pm, Streamweaver  wrote:
>
>
>
> > I'm not actually using {% url %} at this time.  I am setup for
> > mod_wsgi and don't know how to go about configuring links in the
> > templates when the sites root is on a subdirectory.  There isn't much
> > in the way of examples on FORCE_SCRIPT_NAME I can find and I'm not
> > really an apache admin so I'm a bit out of my depth here.
>
> > Is this the avenue I should be pursuing or is there some way to set
> > this up better.  the url filter seems to violate DRY methodology.
>
> > Thanks again.
>
> > On Jul 30, 9:52 pm, Graham Dumpleton 
> > wrote:
>
> > > Using FORCE_SCRIPT_NAME is only appropriate for certain WSGI hosting
> > > mechanisms. Using it may simply hide the fact that the OPs application
> > > code is wrong to begin with.
>
> > > OP should indicate how they are hosting their application for real
> > > site. Ie., mod_python, mod_wsgi, fastcgi or other.
>
> > > Graham
>

Graham is right about needing to mount your site correctly.  Post your
Apache config at http://groups.google.com/group/modwsgi?hl=en and they
can help with that.  I've not had to use FORCE_SCRIPT_NAME when using
mod_wsgi.  What I found that works is passing the script_name in each
view context.  This is violating DRY, but I haven't worried about that
too much.  This is a way to make apps portable.  If you still need or
want to use the {% url %} tag, you just need to preceed it by a
{{ script_name }} (I'm mostly sure, correct me if wrong).  You can
give script_name to your context with request.META['SCRIPT_NAME'] if
it exists.

hope this helps,
Adam

> > > On Jul 31, 6:04 am, Alex Koshelev  wrote:
>
> > > > If you are using `{% url %}` template tag or `reverse` function you can 
> > > > set
> > > > FORCE_SCRIPT_NAME [1] settings variable specified for your deployment
> > > > project root. Or working with right web-server in front of django 
> > > > project
> > > > force it to tell proper SCRIPT_NAME himself.
>
> > > > [1]:http://docs.djangoproject.com/en/dev/ref/settings/#force-script-name
>
> > > > ---
> > > > Alex Koshelev
>
> > > > On Thu, Jul 30, 2009 at 10:55 PM, Streamweaver 
> > > > wrote:
>
> > > > > I have a django project that has worked just fine in development but
> > > > > I'm trying to move it to a demo site and the application is not on a
> > > > > root domain or sub-domain.
>
> > > > > Instead the site root URL is suppose to be something like
> > > > >https://site.domain.com/appname/
>
> > > > > This is causing all my template links to break.  The {% url %} tag
> > > > > seems to work only for the site root and doesn't bring in the
> > > > > subdirectory name.
>
> > > > > What's the Django way of handling this?  I'm surprised I haven't been
> > > > > able to find something about this.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



One to many relationship question

2009-07-31 Thread supercodepoet

I come from the world of Java and Hibernate and trying to get familiar
with Django (loving it by the way). The issue I am running into is the
relationship setup between the model classes and there related
objects. For instance say i have:

class Blog(models.Model):
   name = models.CharField()

class Entry(models.Model)
 name = models.CharField()
 blog = models.ForeignKey(Blog, related_name="entries")

I would love to be able to create this:

blog = new Blog(name="Test blog")
entry = new Entry()
entry.name = "Entry 1"
entry.blog = blog

and then be able to pass blog and around to different functions or
views and still be able to access the entries tied to it without
having to save the blog object first (there may be business logic that
does things to blog first before it is finally saved). Using it this
way blog.entries was empty because I believe I have not saved it yet
and blog.entries.add(entry) through a constraint error because the
entry.blog_id value did not exist in the blog table again because I
have not saved it yet.

In hibernate I could do this because the ORM treated the objects just
like POJOs and I mught have to do a little extra lifting to make sure
the save went ok. I am wondering if the Django ORM has the same type
on construct built into it so I can use my model classes like POPOs
until I need to persist?

Thanks for any help,
Travis

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



Re: Error with runserver using jython

2009-07-31 Thread Brandon

If I trash the .class files created by startproject, I can
successfully run the built-in server after the classes are re-
compiled.

On Jul 31, 11:21 am, fwierzbicki  wrote:
> On Jul 31, 9:46 am, Brandon Taylor  wrote:> Hi 
> everyone,
>
> > I created a new project through jython/django-admin.py and now I'm
> > receiving this error when attempting to start the development server
> > using jython...
>
> This is a known bug on Jython, but we haven't gotten to the bottom of
> it yet.  Seehttp://bugs.jython.org/issue1262to see how we are
> progressing...
>
> -Frank
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error with runserver using jython

2009-07-31 Thread fwierzbicki



On Jul 31, 9:46 am, Brandon Taylor  wrote:
> Hi everyone,
>
> I created a new project through jython/django-admin.py and now I'm
> receiving this error when attempting to start the development server
> using jython...
This is a known bug on Jython, but we haven't gotten to the bottom of
it yet.  See http://bugs.jython.org/issue1262 to see how we are
progressing...

-Frank

--~--~-~--~~~---~--~~
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: Stopping people loging in twice

2009-07-31 Thread Masklinn

On 31 Jul 2009, at 17:04 , When ideas fail wrote:
>
> Hello, if i am using this generic view in my urls.py?
>
> (r'^accounts/login/$', 'django.contrib.auth.views.login',
> {'template_name': 'myapp/login.html'}),
>
> Is there a way i can stopped people who are already logged in logging
> in again?
How about simply providing different content if the user is already  
logged in (in your template)?

Alternatively, you can create your own decorator (I'd have suggested 
http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.decorators.user_passes_test
 
  but it redirects to the login page so that's not an option): you  
merely need to check if request.user.is_authenticated().

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



creating a list of sql that is executed

2009-07-31 Thread delfick755

Hello,

I have a situation where I've created a site using django, using
sqlite3.

Thus far I've always had the database under version control (which,
seeing as it's a binary file, doesn't mean much other than the fact I
have a backup)

The problem becomes when I make changes on my home computer that may
involve a change to the database, commit and update on the server
where there may have already been changes to the database, thus
leading to unresolvable conflicts.

So I'm wondering if there is a way to intercept whenever something is
done to the database and keep a record of it.

Then somehow make it so when I do an svn up it automatically executes
the changes that were made.

This way not only do I keep a history of what changes are made, but I
can resolve conflicts without having to scrap changes (which
fortunately doesn't tend to be disastrous in this case)

Thankyou for help.

Regards,
Stephen
--~--~-~--~~~---~--~~
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: Stopping people loging in twice

2009-07-31 Thread Gaddoz

I would like to do something like this, too!

Please help!



On Fri, Jul 31, 2009 at 5:04 PM, When ideas
fail wrote:
>
> Hello, if i am using this generic view in my urls.py?
>
> (r'^accounts/login/$', 'django.contrib.auth.views.login',
> {'template_name': 'myapp/login.html'}),
>
> Is there a way i can stopped people who are already logged in logging
> in again?
>
> Thanks
> >
>

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



Re: Threaded application + IntegrityError

2009-07-31 Thread ramya

http://stackoverflow.com/questions/1212864/threaded-application-integrityerror


On Jul 31, 9:41 am, ramya  wrote:
> Hi,
> I have python threaded application + Postgres. I am using Django's ORM
> to save to Postgres..
> I have concurrent save calls. Occasionally 2 threads save with the
> same primary key which leads to an issue.
>
> Postgres log:
> ERROR:  duplicate key value violates unique constraint "store_pkey"
> STATEMENT:  INSERT INTO "store" ("store_id", "address") VALUES
> (E'HAN277', E'101 Ocean Street')
>
> Code:
> In the code I see an IntegrityError. I tried different ways to handle
> this.
>
> a.
> try:
>   a.save()
> except IntegrityError:
>   pass
>
> This causes InternalError
>
> b. Tried to do transaction roll back.. but not sure.. As far as I
> understand you need to distinct save calls to have transactions
>
>           sid = transaction.savepoint()
>           try:
>             row.save()
>           except IntegrityError, e:
>             transaction.savepoint_rollback(sid)
>             pass
>           transaction.commit()
> The first savepoint fails with
>
> AttributeError: 'NoneType' object has no attribute 'cursor'
>
> a. I read somewhere django is not 100% thread safe. Is it a good
> choice in my usecase. I was already using Django for other application
> and need an ORM.. So naturally I chose Django
> b. How to handle this situation.. Any comments.
>
> Thanks and regards,
> Ramya
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



using the stable api

2009-07-31 Thread Faheem Mitha


Hi everybody,

I upgraded from somewhere around Django 1.0 to 1.0.2, and some things 
broke and had to be changed. In the following, f is an object of class 
'django.core.files.uploadedfile.TemporaryUploadedFile'. I need to

1) Get the contents of the file corresponding to f. I had to change 
f['content'] to f._file.read()

>From the docs (specifically, 'core/files/uploadedfile.py') it looks like 
f.read() might be the right thing?

2) Get the filename of the file corresponding to f. I had to change 
f['filename'] to f._name.

3) Get the sessionid. I had to change request.COOKIES['sessionid'] to 
request.COOKIES[settings.SESSION_COOKIE_NAME]

It is presumably better to use a stable API rather than less stable 
internals, so my question is - what is the best expression to use in the 
examples above so that they are less likely to break on upgrade? Please CC 
me on any reply.

  Regards, Faheem.

--~--~-~--~~~---~--~~
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: Threaded application + IntegrityError

2009-07-31 Thread Joshua Russo
On Fri, Jul 31, 2009 at 12:41 PM, ramya  wrote:

>
> Hi,
> I have python threaded application + Postgres. I am using Django's ORM
> to save to Postgres..
> I have concurrent save calls. Occasionally 2 threads save with the
> same primary key which leads to an issue.
>
> Postgres log:
> ERROR:  duplicate key value violates unique constraint "store_pkey"
> STATEMENT:  INSERT INTO "store" ("store_id", "address") VALUES
> (E'HAN277', E'101 Ocean Street')
>
> Code:
> In the code I see an IntegrityError. I tried different ways to handle
> this.
>
> a.
> try:
>  a.save()
> except IntegrityError:
>  pass
>
> This causes InternalError
>
> b. Tried to do transaction roll back.. but not sure.. As far as I
> understand you need to distinct save calls to have transactions
>
>  sid = transaction.savepoint()
>  try:
>row.save()
>  except IntegrityError, e:
>transaction.savepoint_rollback(sid)
>pass
>  transaction.commit()
> The first savepoint fails with
>
> AttributeError: 'NoneType' object has no attribute 'cursor'
>
>
> a. I read somewhere django is not 100% thread safe. Is it a good
> choice in my usecase. I was already using Django for other application
> and need an ORM.. So naturally I chose Django
> b. How to handle this situation.. Any comments.


One trick you could try is:

try:
 a.save()
except IntegrityError:
 wait(.1)
 a.save()

This generally only works for lightly used multi-threaded application, and
you should be able to embed the Try-Except blocks to try more than twice.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Stopping people loging in twice

2009-07-31 Thread When ideas fail

Hello, if i am using this generic view in my urls.py?

(r'^accounts/login/$', 'django.contrib.auth.views.login',
{'template_name': 'myapp/login.html'}),

Is there a way i can stopped people who are already logged in logging
in again?

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



[solved] processing html arrays

2009-07-31 Thread Salvatore Leone

Salvatore Leone ha scritto:
> Hi,
>
> I've a form with a html array. How can I process this array in my view 
> after the submit?
>
> I'm pretty sure the html code is correct because I can manage the array 
> with a php script... so there must be a way to do it in python.
>
> -Salvatore
>   
there is a poor documented django data type: MultiValueDict.
It' an extension of dicts for holding a list of values for the same key

multi_value_dict = request.FILES
for i in multi_value_dict.getlist('attacched_file[]'):
  print i.name


the code is self explanatory: 
http://code.djangoproject.com/browser/django/trunk/django/utils/datastructures.py

--~--~-~--~~~---~--~~
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: Thoughts on many-to-many relationship

2009-07-31 Thread Wyley

Hi Prabhu,

You are correct about how to fix the error you're seeing, but I think
you're confused about why you're seeing it.  As with all
relationships,
an object in a many-to-many relationship must have a primary key value
before you can point a foreign key value at it from another table.

When you say:

group = Group()
group.name = name

you are instantiating a new Group object and assigning its name
attribute.  This object does not get a primary key value until you
call
its save() method.  (This is because the call to save() is the first
time Django actually contacts the database to store your new Group
object; before that point, it has no idea what the primary key value
should be.)  You can shorten the code to this:

group = Group(name=name)
group.save()

In your code, you are then retrieving the new group object you just
saved with this call:

group = Group.objects.get(name=name)

You don't need to do this; you can just use the same group object that
you called save() on initially, and avoid a second database hit.
Then,
simply add the permissions to this group that you want:

codename_list = [perm + '_' + model for model in models_list for perm
in permission_list]
permissions = Permission.objects.filter(codename__in=codename_list)
for p in permissions:
group.permissions.add(p)

It shouldn't be necessary to call group.save() again at this point,
because you're not actually modifying the group object; those calls to
add() are storing the relationship between the group and each
permission
in a separate table.  See:

http://docs.djangoproject.com/en/dev/topics/db/queries/#saving-foreignkey-and-manytomanyfield-fields

Hope that's helpful.  Good luck!

Richard


On Jul 31, 5:52 am, prabhu S  wrote:
> Hi All,
>
> When I try to create a Group (django.contrib.auth.models.Group)
> dynamically, I get the below error.
>
> 'Group' instance needs to have a primary key value before a many-to-
> many relationship can be used.
>
> This is because I am trying to add permissions to the group object and
> trying to save every thing in one shot. As a work around to this
> problem, I am doing an intermediate save and reload of Group object,
> which seems to work fine.
>
> Is there a logical reason behind this error? Is this something
> fixable?
>
> Regards,
> Prabhu
> P.S: Exact source code here 
> -http://github.com/prabhu/invoicy/blob/3f32fff86b806bc0b769de6de7dbe04...
--~--~-~--~~~---~--~~
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: "join" query in Django?

2009-07-31 Thread Javier Guerra

On Fri, Jul 31, 2009 at 1:42 AM, Asinox wrote:
> i try
> with .filter("field1__field2") where the field1 is the PK and the
> field2 is the FK.

that dowsn't sound right.  i think you've misread the ORM chapters of
the documentation.

don't try to think in terms of the SQL you want.  much better is to
think in terms of the data you want from the DB.

-- 
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: quick question: how to have *.domainname.com url in django

2009-07-31 Thread Javier Guerra

On Fri, Jul 31, 2009 at 12:26 AM, weiwei wrote:
> thanks, i was thinking to have each user have a url as 
> http://username.domain.com/


after you manage to configure your frontend server (apache, lightttpd,
nginx, whatever) to send all those names to the same Django instance,
i'd just write a middleware that picks the name from the original URL
and stores it (or maybe the whole User object) in the request.

-- 
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
-~--~~~~--~~--~--~---



redirecting after login

2009-07-31 Thread When ideas fail

I was wondering if there was a way to redirect users after login to
the page they where looking at before they logged in.

So if they where on "/blog/" when they logged in they could be
redirected back and if they where on "/about_us/" they could be
redirected to "/about_us/"?

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



Re: i need custom database behaviour, but i dont know how to do it

2009-07-31 Thread Mirat Bayrak
i read it but i want to try my method, can anybody has idea how can i
implement it?

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



Re:

2009-07-31 Thread Margie

Hi Vasil.

Thanks for the snippets, those are useful.  I was somehow just very
confused on the mechanism that was being described, but it all makes
sense now.

Margie


On Jul 30, 11:41 am, Margie  wrote:
> Hi Vasil,
>
> Could you clarify how I access the variable from the javascript?  For
> example, using my DateWidget as an example, say in my wdigets.py I
> have this (note I've added ?myVar='xyz' in second line:
>
> class DateWidget(widgets.DateInput):
>     class Media:
>         js = ("js/jquery.datePicker.min-2.1.2.js",
>                "js_custom/date_widget.js?myVar='xyz''")
>
> The complete contents of date_widget.js is currently:
>
>   $(document).ready(function() {
>                       Date.firstDayOfWeek = 0;
>                       Date.format = 'mm/dd/';
>                       $('.chipvision_date_widget').datePicker();
>                     });
>
> How do I access myVar from inside date_widget.js?
>
> I know the .js files listed in the Media class get output into my html
> via my inclusion of  {{ media }} in my template.  So I see that I get
> this in my html
>
> 
> 
>
> But I seem to have some missing piece - I don't get how to get access
> to xyz from the .js script itself.  Sorry if this is a dumb question -
> I've written various bits of javascript/jquery but haven't encountered
> this.
>
> Margie
>
> On Jul 29, 5:51 pm, Vasil Vangelovski  wrote:
>
> > Of course that the files specified in the class Media are accessed via
> > GET. How else would they be accessed? It's possible to fetch a js file
> > with additional get arguments and access those values from the js. So
> > you can pass prePopulateString as a get parameter to the js file in
> > class Media for example:
>
> > class Media:
> >    js = ('myAutoCompleteInit.js?prepopString=%s'%prePopulateString)
>
> > Then pass that parameter to the js method you need inside 
> > myAutoCompleteInit.js.
>
> > On Thu, Jul 30, 2009 at 1:53 AM, Margie wrote:
>
> > >> There's no easy way of passing dynamic javascript in the Media class.
> > >> However, you can fake it, with a bit of work, by passing the parameter
> > >> to the script in a querystring. So, for example, in the list of js
> > >> files to be included you would have
> > >>     'js/myfile.js?renderclass=%s' % self.prePopulateString
>
> > >> Then your js can find its own 

Re: How can I reload attributes from the database

2009-07-31 Thread Karen Tracey
On Fri, Jul 31, 2009 at 8:53 AM, Fleg  wrote:

>
> Yes, I saw this case and that's what I need...
> The point is that the proposed fix implies to patch the django core
> which I would prefer to avoid.
> The other solution need to add as many lines of code as you have
> associated objects (and for all objects)... which is quite heavy (if
> you add a foreign key to your table you need to update the model
> definition + the reload method...).
> F.
>

I wasn't suggesting you use the proposed fix: it's four years old and the
Django code in question has undergone substantial changes (django/core/meta
no longer exists) so it isn't directly applicable any more anyway.

Implementing the workaround doesn't require changing your reload method
every time you change your model.  The particular use case in the ticket
involved only one attribute that needed to be re-loaded, so it was easiest
to just re-assign that attribute.

If you have many  (or potentially all) fields that need to be reloaded there
is no reason you can't use the field information contained in the model's
_meta.fields list to do a more wholesale "reload" that doesn't rely on
knowing what attributes, specifically, need to be re-assigned.  Essentially
you probably want to implement the code that would be placed in Django core
if this were to be supported by Django, only in your own code.  You'll have
to dig into some of the model internals probably to figure out how to do it,
but I don't think it is that hard.  Relying on internals means it could
break if they change in the future but I think you'd only need to use some
basic stuff that is unlikely to change at this point.

Karen

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



Error with runserver using jython

2009-07-31 Thread Brandon Taylor

Hi everyone,

I created a new project through jython/django-admin.py and now I'm
receiving this error when attempting to start the development server
using jython...

iMac:musaic bt$ jython manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 4, in 
import settings # Assumed to be in the same directory.
  File "manage.py", line 4, in 
import settings # Assumed to be in the same directory.
java.lang.ArrayIndexOutOfBoundsException: 12840
at org.python.objectweb.asm.ClassReader.readClass(Unknown Source)
at org.python.objectweb.asm.ClassReader.accept(Unknown Source)
at org.python.objectweb.asm.ClassReader.accept(Unknown Source)
at org.python.core.AnnotationReader.(AnnotationReader.java:44)
at org.python.core.imp.readCode(imp.java:154)
at org.python.core.imp.createFromPyClass(imp.java:120)
at org.python.core.imp.loadFromSource(imp.java:504)
at org.python.core.imp.find_module(imp.java:410)
at org.python.core.imp.import_next(imp.java:620)
at org.python.core.imp.import_name(imp.java:731)
at org.python.core.imp.importName(imp.java:791)
at org.python.core.ImportFunction.__call__(__builtin__.java:1236)
at org.python.core.PyObject.__call__(PyObject.java:367)
at org.python.core.__builtin__.__import__(__builtin__.java:1207)
at org.python.core.__builtin__.__import__(__builtin__.java:1190)
at org.python.core.imp.importOne(imp.java:802)
at org.python.pycode._pyx0.f$0(manage.py:11)
at org.python.pycode._pyx0.call_function(manage.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1197)
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:
166)
at org.python.util.jython.run(jython.java:229)
at org.python.util.jython.main(jython.java:117)

java.lang.ArrayIndexOutOfBoundsException:
java.lang.ArrayIndexOutOfBoundsException: 12840

My project structure is simply:

~/jython_django_projects/
__init__.py
manage.py
settings.py
urls.py

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



Threaded application + IntegrityError

2009-07-31 Thread ramya

Hi,
I have python threaded application + Postgres. I am using Django's ORM
to save to Postgres..
I have concurrent save calls. Occasionally 2 threads save with the
same primary key which leads to an issue.

Postgres log:
ERROR:  duplicate key value violates unique constraint "store_pkey"
STATEMENT:  INSERT INTO "store" ("store_id", "address") VALUES
(E'HAN277', E'101 Ocean Street')

Code:
In the code I see an IntegrityError. I tried different ways to handle
this.

a.
try:
  a.save()
except IntegrityError:
  pass

This causes InternalError

b. Tried to do transaction roll back.. but not sure.. As far as I
understand you need to distinct save calls to have transactions

  sid = transaction.savepoint()
  try:
row.save()
  except IntegrityError, e:
transaction.savepoint_rollback(sid)
pass
  transaction.commit()
The first savepoint fails with

AttributeError: 'NoneType' object has no attribute 'cursor'


a. I read somewhere django is not 100% thread safe. Is it a good
choice in my usecase. I was already using Django for other application
and need an ORM.. So naturally I chose Django
b. How to handle this situation.. Any comments.

Thanks and regards,
Ramya
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



processing html arrays

2009-07-31 Thread Salvatore Leone

Hi,

I've a form with a html array. How can I process this array in my view 
after the submit?

I'm pretty sure the html code is correct because I can manage the array 
with a php script... so there must be a way to do it in python.

-Salvatore

--~--~-~--~~~---~--~~
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: clean_() doesn't handle images?

2009-07-31 Thread Martje

Excellent! Thank you!

On 31 jul, 14:42, Karen Tracey  wrote:
> On Fri, Jul 31, 2009 at 3:18 AM, Martje  wrote:
>
> > I don't understand, sorry :$. Do you care to explain a little bit
> > more? Or could you give an example?
>
> > I'm using the admin interface btw.
>
> You added a custom field clean method to your model definition.  This has no
> effect, as models (currently) don't support validation or cleaning.
> Validation/cleaning is done for forms, so you need to add your custom field
> clean method to the form used to upload your file.  Admin supports this by
> allowing you to specify the form it is to use for a model:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom...
>
> Karen
>
>
>
> > On 31 jul, 01:45, Karen Tracey  wrote:
> > > On Thu, Jul 30, 2009 at 4:02 PM, Martje 
> > wrote:
>
> > > > Hey,
>
> > > > I've got the following code in my models.py:
>
> > > > from django import forms
> > > > class Foto(models.Model):
> > > >    omschrijving = models.CharField(max_length=100)
> > > >    afbeelding = models.ImageField(upload_to='media/afbeeldingen/
> > > > header/fotos')
>
> > > >    def clean_afbeelding(self):
> > > >        raise forms.ValidationError("Never good! :-)")
>
> > > > Still, if I upload an image it validates, where it shouldn't, right?
>
> > > Custom clean methods need to be added to the form you are using, not the
> > > model.
>
> > > Karen
>
>
--~--~-~--~~~---~--~~
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: Setting up django on xampp with apache, python 2.6 and mod_wsgi

2009-07-31 Thread Michael Ralan

Karen hi,

Thanks for the reply. I think I narrowed it down to the way I
installed Python on this server. I can run django applications and
other python scripts just fine from the command line.

It turns out that a quick way to test my Python + Apache setup is
replace the .wsgi file with the following

import socket
def application(environ, start_response):
status = '200 OK'
output = 'Hello world!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)

return [output]

Notice how it bypasses django and tests to see if Python can actually
run in the apache context. If that doesn't work, then it surely means
Python has been installed incorrectly. I googled some more and found
out that Python needs to be installed 'for all users', instead of
'just for me' (there are some required registry settings the xampp
process won't be able to find unless Python has been set up as such).

I switched my .wsgi file back to what it was previously and now my
django app is running!

Thanks again.



On Jul 31, 3:23 pm, Karen Tracey  wrote:
> On Fri, Jul 31, 2009 at 8:53 AM, Michael Ralan  wrote:
>
> > I get an (unhelpful) xampp error message that reads
>
> > Microsoft Visual C++ Runtime Library
> > ---
> > Runtime Error!
>
> > Program: C:\xampp\apache\bin\httpd.exe
>
> > R6034
>
> > An application has made an attempt to load the C runtime library
> > incorrectly.
> > Please contact the application's support team for more information.
>
> > Furthermore, the following is in my apache errors.log
>
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] mod_wsgi
> > (pid=2136): Target WSGI script 'C:/xampp/htdocs/testproject/apache/
> > django.wsgi' cannot be loaded as Python module.
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] mod_wsgi
> > (pid=2136): Exception occurred processing WSGI script 'C:/xampp/htdocs/
> > testproject/apache/django.wsgi'.
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] Traceback (most
> > recent call last):
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:/xampp/
> > htdocs/testproject/apache/django.wsgi", line 6, in 
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]     import
> > django.core.handlers.wsgi
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
> > \Python26\\Lib\\site-packages\\django\\core\\handlers\\wsgi.py", line
> > 8, in 
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]     from django
> > import http
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
> > \Python26\\Lib\\site-packages\\django\\http\\__init__.py", line 5, in
> > 
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]     from urllib
> > import urlencode
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
> > \Python26\\lib\\urllib.py", line 26, in 
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]     import
> > socket
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
> > \Python26\\lib\\socket.py", line 46, in 
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]     import
> > _socket
> > [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] ImportError: DLL
> > load failed: A dynamic link library (DLL) initialization routine
> > failed.
>
> All of which implies to me there's nothing wrong with your definitions, but
> there is something fundamentally broken with the server setup.  From the
> traceback you can see mod_wsgi itself is getting loaded fine, the django
> code is being found, etc.  Where things go south is when Python tries to
> load a C extension ("import _socket").  If Python can't load C extensions
> there's not much Python code that is going to work on this server.
>
> You don't see an error when you remove your changes to http.conf because
> then you're probably not trying to use Python code at all from this server.
> That doesn't mean there's anything wrong with the changes you made, it just
> means they are exposing an underlying problem you had not run across before
> because it is in code you were not attempting to use.
>
> For some reason Python on this server cannot load C extensions, that's the
> problem you need to fix.  I'd Google around for Python, xampp, C extensions,
> that unhelpful error message, etc. and see if there is some trick to getting
> Python to work correctly in this environment.  Until you've got a server
> that can actually run Python properly you've no chance of getting Django to
> work on top of it.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group 

Re: Setting up django on xampp with apache, python 2.6 and mod_wsgi

2009-07-31 Thread Karen Tracey
On Fri, Jul 31, 2009 at 8:53 AM, Michael Ralan  wrote:

>
>
> I get an (unhelpful) xampp error message that reads
>
>
> Microsoft Visual C++ Runtime Library
> ---
> Runtime Error!
>
> Program: C:\xampp\apache\bin\httpd.exe
>
> R6034
>
> An application has made an attempt to load the C runtime library
> incorrectly.
> Please contact the application's support team for more information.
>
> Furthermore, the following is in my apache errors.log
>
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] mod_wsgi
> (pid=2136): Target WSGI script 'C:/xampp/htdocs/testproject/apache/
> django.wsgi' cannot be loaded as Python module.
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] mod_wsgi
> (pid=2136): Exception occurred processing WSGI script 'C:/xampp/htdocs/
> testproject/apache/django.wsgi'.
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] Traceback (most
> recent call last):
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:/xampp/
> htdocs/testproject/apache/django.wsgi", line 6, in 
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] import
> django.core.handlers.wsgi
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
> \Python26\\Lib\\site-packages\\django\\core\\handlers\\wsgi.py", line
> 8, in 
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] from django
> import http
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
> \Python26\\Lib\\site-packages\\django\\http\\__init__.py", line 5, in
> 
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] from urllib
> import urlencode
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
> \Python26\\lib\\urllib.py", line 26, in 
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] import
> socket
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
> \Python26\\lib\\socket.py", line 46, in 
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] import
> _socket
> [Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] ImportError: DLL
> load failed: A dynamic link library (DLL) initialization routine
> failed.
>
>
All of which implies to me there's nothing wrong with your definitions, but
there is something fundamentally broken with the server setup.  From the
traceback you can see mod_wsgi itself is getting loaded fine, the django
code is being found, etc.  Where things go south is when Python tries to
load a C extension ("import _socket").  If Python can't load C extensions
there's not much Python code that is going to work on this server.

You don't see an error when you remove your changes to http.conf because
then you're probably not trying to use Python code at all from this server.
That doesn't mean there's anything wrong with the changes you made, it just
means they are exposing an underlying problem you had not run across before
because it is in code you were not attempting to use.

For some reason Python on this server cannot load C extensions, that's the
problem you need to fix.  I'd Google around for Python, xampp, C extensions,
that unhelpful error message, etc. and see if there is some trick to getting
Python to work correctly in this environment.  Until you've got a server
that can actually run Python properly you've no chance of getting Django to
work on top of it.

Karen

--~--~-~--~~~---~--~~
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 on Jython

2009-07-31 Thread Brandon

Nevermind. I chose the "standard" option when installing Jython, which
doesn't include sources. If you choose the "all" option, distutils is
included.

Hope that helps someone,
Brandon

On Jul 31, 7:48 am, Brandon Taylor  wrote:
> Hello everyone,
>
> I'm getting a Jython environment set up, and have it installed and
> working properly. Now it's time to install django-jython and django
> itself.
>
> The problem is, I can't install django-jython because I don't have
> distutils installed for Jython. I also can't seem to find distutils
> ANYWHERE so I can install it.
>
> Can someone please point me in the direction of distutils that I can
> install for Jython?
>
> TIA,
> Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I reload attributes from the database

2009-07-31 Thread Fleg

Yes, I saw this case and that's what I need...
The point is that the proposed fix implies to patch the django core
which I would prefer to avoid.
The other solution need to add as many lines of code as you have
associated objects (and for all objects)... which is quite heavy (if
you add a foreign key to your table you need to update the model
definition + the reload method...).
F.

On Jul 31, 2:30 pm, Karen Tracey  wrote:
> On Fri, Jul 31, 2009 at 5:51 AM, Fleg  wrote:
>
> > Thanks for your suggestion, but I cannot... I need to do that from a
> > method of the model itself.
> > Basically, I need to use some stored procedures to modify datas in the
> > database (and these stored procs can also modify some other tables),
> > thus I need to reload after calling these procedures in order to
> > update the modified values. And this must be done from the instance
> > because it's only a part of a process.
>
> > Example:
> > action=Scheduler.objects.get(id_schedule=22)
> > action.do_something()
>
> > and in the Scheduler class I have
> > def do_something(self):
> >    call_proc_stock_1() --> this will update id_status in table
> > schedule and modify the line corresponding to the id_release in table
> > release
> >    do_smething_else() etc...
>
> > So after call_proc_stock_1() I need to reload to have the correct
> > (updated) id_status and id_release objects (and not only the value of
> > the key, the whole associated object).
>
> Sounds similar to the use case for reload that was mentioned here:
>
> http://code.djangoproject.com/ticket/901
>
> That was closed wontfix, but the discussion includes a way to accomplish the
> desired effect: reload the model instance into a new object, and re-set the
> possibly changed attribute(s) on the existing instance from the newly-loaded
> one.
>
> Karen
--~--~-~--~~~---~--~~
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: Setting up django on xampp with apache, python 2.6 and mod_wsgi

2009-07-31 Thread Michael Ralan


I get an (unhelpful) xampp error message that reads


Microsoft Visual C++ Runtime Library
---
Runtime Error!

Program: C:\xampp\apache\bin\httpd.exe

R6034

An application has made an attempt to load the C runtime library
incorrectly.
Please contact the application's support team for more information.

Furthermore, the following is in my apache errors.log

[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=2136): Target WSGI script 'C:/xampp/htdocs/testproject/apache/
django.wsgi' cannot be loaded as Python module.
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=2136): Exception occurred processing WSGI script 'C:/xampp/htdocs/
testproject/apache/django.wsgi'.
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:/xampp/
htdocs/testproject/apache/django.wsgi", line 6, in 
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] import
django.core.handlers.wsgi
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\Lib\\site-packages\\django\\core\\handlers\\wsgi.py", line
8, in 
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] from django
import http
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\Lib\\site-packages\\django\\http\\__init__.py", line 5, in

[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] from urllib
import urlencode
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\urllib.py", line 26, in 
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] import
socket
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1]   File "C:\
\Python26\\lib\\socket.py", line 46, in 
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] import
_socket
[Fri Jul 31 12:04:18 2009] [error] [client 127.0.0.1] ImportError: DLL
load failed: A dynamic link library (DLL) initialization routine
failed.


On Jul 31, 2:48 pm, Karen Tracey  wrote:
> On Fri, Jul 31, 2009 at 8:36 AM, Michael Ralan  wrote:
>
> > Hi,
>
> > I've searched the internet and come across a couple of pages
> > ostensibly showing how this is done, but even the django documentation
> > itself (sans being xampp-specific) has not met me with success.
>
> > I got to the point where I've installed mod_wsgi, set up the test app
> > but am struggling with the changes I need to make to http.conf. I've
> > done them but when I request a page, httpd.exe throws an error
> > complaining about it trying to load a library incorrectly.
>
> Details of this error may help people help you.  Trying to spot what might
> be wrong in the absence of the specifics of the error that gets reported is
> making things needlessly hard on potential helpers.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django on Jython

2009-07-31 Thread Brandon Taylor

Hello everyone,

I'm getting a Jython environment set up, and have it installed and
working properly. Now it's time to install django-jython and django
itself.

The problem is, I can't install django-jython because I don't have
distutils installed for Jython. I also can't seem to find distutils
ANYWHERE so I can install it.

Can someone please point me in the direction of distutils that I can
install for Jython?

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



Re: Setting up django on xampp with apache, python 2.6 and mod_wsgi

2009-07-31 Thread Karen Tracey
On Fri, Jul 31, 2009 at 8:36 AM, Michael Ralan  wrote:

>
> Hi,
>
> I've searched the internet and come across a couple of pages
> ostensibly showing how this is done, but even the django documentation
> itself (sans being xampp-specific) has not met me with success.
>
> I got to the point where I've installed mod_wsgi, set up the test app
> but am struggling with the changes I need to make to http.conf. I've
> done them but when I request a page, httpd.exe throws an error
> complaining about it trying to load a library incorrectly.


Details of this error may help people help you.  Trying to spot what might
be wrong in the absence of the specifics of the error that gets reported is
making things needlessly hard on potential helpers.

Karen

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



Re: dynamic form

2009-07-31 Thread derek

On Jul 31, 10:31 am, Salvatore Leone 
wrote:
> Hi,
>
> I've got a form with various information and a file upload widget.
>
> Is there a way to uploads many files at the same time? So to have a link
> "add file" (and even "remove" file for already selected files).
>
Look at:
http://scompt.com/archives/2007/11/03/multiple-file-uploads-in-django

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Setting up django on xampp with apache, python 2.6 and mod_wsgi

2009-07-31 Thread Michael Ralan

Hi,

I've searched the internet and come across a couple of pages
ostensibly showing how this is done, but even the django documentation
itself (sans being xampp-specific) has not met me with success.

I got to the point where I've installed mod_wsgi, set up the test app
but am struggling with the changes I need to make to http.conf. I've
done them but when I request a page, httpd.exe throws an error
complaining about it trying to load a library incorrectly. If I take
remove the bit I added to http.conf apache will work.

This is what I've added to my http.conf where testproject is the name
of my app.

#django specific stuff

ServerAdmin r...@mysite.com
ServerName localhost
ServerAlias localhost.com

Allow from all

#WSGIDaemonProcess www-data
#WSGIProcessGroup www-data
WSGIScriptAlias / c:/xampp/htdocs/testproject/apache/django.wsgi


This is the contents of my django.wsgi

import os, sys
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
sys.path.append('c:/xampp/htdocs')
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


The mod_wsgi I'm using I downloaded from
http://code.google.com/p/modwsgi/downloads/list

I don't see anything wrong?

Any helpful comments will be much appreciated,

Thanks

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



Re: clean_() doesn't handle images?

2009-07-31 Thread Karen Tracey
On Fri, Jul 31, 2009 at 3:18 AM, Martje  wrote:

>
> I don't understand, sorry :$. Do you care to explain a little bit
> more? Or could you give an example?
>
> I'm using the admin interface btw.
>

You added a custom field clean method to your model definition.  This has no
effect, as models (currently) don't support validation or cleaning.
Validation/cleaning is done for forms, so you need to add your custom field
clean method to the form used to upload your file.  Admin supports this by
allowing you to specify the form it is to use for a model:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin

Karen



>
> On 31 jul, 01:45, Karen Tracey  wrote:
> > On Thu, Jul 30, 2009 at 4:02 PM, Martje 
> wrote:
> >
> > > Hey,
> >
> > > I've got the following code in my models.py:
> >
> > > from django import forms
> > > class Foto(models.Model):
> > >omschrijving = models.CharField(max_length=100)
> > >afbeelding = models.ImageField(upload_to='media/afbeeldingen/
> > > header/fotos')
> >
> > >def clean_afbeelding(self):
> > >raise forms.ValidationError("Never good! :-)")
> >
> > > Still, if I upload an image it validates, where it shouldn't, right?
> >
> > Custom clean methods need to be added to the form you are using, not the
> > model.
> >
> > Karen
> >
>

--~--~-~--~~~---~--~~
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 can I reload attributes from the database

2009-07-31 Thread Karen Tracey
On Fri, Jul 31, 2009 at 5:51 AM, Fleg  wrote:

>
> Thanks for your suggestion, but I cannot... I need to do that from a
> method of the model itself.
> Basically, I need to use some stored procedures to modify datas in the
> database (and these stored procs can also modify some other tables),
> thus I need to reload after calling these procedures in order to
> update the modified values. And this must be done from the instance
> because it's only a part of a process.
>
> Example:
> action=Scheduler.objects.get(id_schedule=22)
> action.do_something()
>
>
> and in the Scheduler class I have
> def do_something(self):
>call_proc_stock_1() --> this will update id_status in table
> schedule and modify the line corresponding to the id_release in table
> release
>do_smething_else() etc...
>
> So after call_proc_stock_1() I need to reload to have the correct
> (updated) id_status and id_release objects (and not only the value of
> the key, the whole associated object).
>

Sounds similar to the use case for reload that was mentioned here:

http://code.djangoproject.com/ticket/901

That was closed wontfix, but the discussion includes a way to accomplish the
desired effect: reload the model instance into a new object, and re-set the
possibly changed attribute(s) on the existing instance from the newly-loaded
one.

Karen

--~--~-~--~~~---~--~~
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: annotations only in 1.1 ?

2009-07-31 Thread gentlestone

thx

(how stupid I am :-))

On 31. Júl, 14:17 h., Daniel Roseman  wrote:
> On Jul 31, 12:54 pm, gentlestone  wrote:
>
> > I want find all instances of model KeyWord, where ManyToMany field
> > categories is empty. I think in versieon 1.1 is the appropriate code
> > like this:
>
> > ... KeyWord.objects.annotate(cnt = Count(categories)).filter(cnt =
> > 0) ...
>
> > What is the similar code in old version 1.0 for resolve the same
> > result. Should I use extra() method and go to the table level
> > (SELECT ...) ?
>
> You don't need annotations for this at all.
>
>     KeyWord.objects.filter(category__isnull=True)
>
> --
> DR
--~--~-~--~~~---~--~~
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: encoding problem

2009-07-31 Thread cootetom

You could try file_name.decode('utf-8', 'replace') which will tell the
encoder not to throw errors but for any character it can't encode it
will replace with a ?



On Jul 31, 12:26 pm, alecs  wrote:
> Environment:
>
> Request Method: GET
> Request 
> URL:http://172.16.23.33/file/4719e0bdedaa4f741f032991894d52ecb08c3476a598...
> Django Version: 1.0.3
> Python Version: 2.6.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'filez.filezupload',
>  'debug_toolbar']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> Traceback:
> File "/usr/share/python-support/python-django/django/core/handlers/
> base.py" in get_response
>   91.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/usr/share/python-support/python-django/django/contrib/auth/
> decorators.py" in __call__
>   78.             return self.view_func(request, *args, **kwargs)
> File "/var/www/filez/filezupload/views.py" in send_file
>   253.         content_disp = u'attachment; filename="%s" ' %
> upfile.file_name
>
> Exception Type: UnicodeDecodeError at /file/
> 4719e0bdedaa4f741f032991894d52ecb08c3476a598504fd1fee92d
> Exception Value: ('ascii', '\xd0\x9d
> \xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb0
> \xd0\xbf\xd0\xbe\xd1\x87\xd1\x82\xd1\x8b.doc', 0, 1, 'ordinal not in
> range(128)')
>
> If I do upfile.file_name.decode('utf8').encode('cp1251') it works in
> IE ...
--~--~-~--~~~---~--~~
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: annotations only in 1.1 ?

2009-07-31 Thread Daniel Roseman

On Jul 31, 12:54 pm, gentlestone  wrote:
> I want find all instances of model KeyWord, where ManyToMany field
> categories is empty. I think in versieon 1.1 is the appropriate code
> like this:
>
> ... KeyWord.objects.annotate(cnt = Count(categories)).filter(cnt =
> 0) ...
>
> What is the similar code in old version 1.0 for resolve the same
> result. Should I use extra() method and go to the table level
> (SELECT ...) ?

You don't need annotations for this at all.

KeyWord.objects.filter(category__isnull=True)

--
DR
--~--~-~--~~~---~--~~
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: i need custom database behaviour, but i dont know how to do it

2009-07-31 Thread Mirat Bayrak
thank you a lot, i am reading now

--~--~-~--~~~---~--~~
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: i need custom database behaviour, but i dont know how to do it

2009-07-31 Thread Daniel Roseman

On Jul 31, 12:45 pm, Mirat Bayrak  wrote:
> > Do you mean you want the foreign key value to be the 'path' field of
> > the Category model? You could do this, but why would you want to? If
> > you ever want to refer to the category path from an Announce instance,
> > you just do:
> >   announce.category.path
>
> hmm i have to explain more i think lets think that i have a category tree
> like that
>
> All
>    '--- Animals
>     '                     '---Dogs
>     '                     '---Cats
>     '                     '---Fishes
>     '
>     '--- Computers
>                              '--- Laptops
>                              '--- Desktops
>                              '--- Accessories
>
> and that category items has path property like :
>
> All =  "all"
> Animals = "all/animals"
> Dogs = "all/animals/dogs"
> Cats = "all/animals/cats"
> Fishes = "all/animals/fishes"
>
> Now, that is important part,  lets think that i am selected Animals
> category, than announces that is in  Dogs, Cats and Fishes category must be
> shown..
>
> İ tried doing it with loops before but at the result i see that i am making
> too much database queries than i found a method...
>
> later, i found that, if i wrote category path on announces, and write a
> custom manager, i can make a query like
>
> *Announce.objects.GetByCategory("/all/animals")*
> that makes a querty on database
>
> *select * from announces where category startswith 'all/animals' * (i dont
> know sql well ill research later)
>
> than it will result all announces whichs category is Dogs or Cats or Fishes
>
> or *Announce.objects.GetByCategory("/all/")* will return all announces that
> is categorized with Animals or Computers or Laptops or Cats
>
> My english is very bad, i wish i explained well my stiuation. After that
> problem solved i think i can publish my category applicaton.

The question of how to deal with nested categories comes up here a
lot, and I always do the same thing - recommend the MPTT algorithm.
There is an excellent Django implementation, django-mptt, which can be
found at http://code.google.com/p/django-mptt/. This would enable you
to get a category and all its ancestors with a single query.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Finding a Django expert to review my code

2009-07-31 Thread Michelschr

Another approach: if you don't have it yet, start by writing tests,
targeting a coverage of your code greater than 95%.

Tests are very useful for a lot of reasons, specially to ease the
evolution of your code... And in your situation, writing the tests
will lead you to review your code by yourself!

Hope it helps,

Michel

On Jul 31, 8:21 am, Rex  wrote:
> I just created my first Django site (as an academic research project).
> Now that it is done, I would like to get feedback on my code from a
> Django expert so that I can learn where I can improve as a Django dev.
> How can I find someone to spend 1 or 2 hours reviewing my code with
> me? I found a few employment posting websites, but they seemed more
> geared toward posting jobs or large freelance projects, not something
> small like this.
>
> Thanks,
>
> Rex
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



annotations only in 1.1 ?

2009-07-31 Thread gentlestone

I want find all instances of model KeyWord, where ManyToMany field
categories is empty. I think in versieon 1.1 is the appropriate code
like this:

... KeyWord.objects.annotate(cnt = Count(categories)).filter(cnt =
0) ...

What is the similar code in old version 1.0 for resolve the same
result. Should I use extra() method and go to the table level
(SELECT ...) ?

--~--~-~--~~~---~--~~
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: i need custom database behaviour, but i dont know how to do it

2009-07-31 Thread Mirat Bayrak
i am little confused, may be i only create category_path on announce model
and write path of selected category to there... it should work and simple :\

--~--~-~--~~~---~--~~
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: i need custom database behaviour, but i dont know how to do it

2009-07-31 Thread Mirat Bayrak
>
>
> Do you mean you want the foreign key value to be the 'path' field of
> the Category model? You could do this, but why would you want to? If
> you ever want to refer to the category path from an Announce instance,
> you just do:
>   announce.category.path
>
>
hmm i have to explain more i think lets think that i have a category tree
like that

All
   '--- Animals
' '---Dogs
' '---Cats
' '---Fishes
'
'--- Computers
 '--- Laptops
 '--- Desktops
 '--- Accessories

and that category items has path property like :

All =  "all"
Animals = "all/animals"
Dogs = "all/animals/dogs"
Cats = "all/animals/cats"
Fishes = "all/animals/fishes"

Now, that is important part,  lets think that i am selected Animals
category, than announces that is in  Dogs, Cats and Fishes category must be
shown..

İ tried doing it with loops before but at the result i see that i am making
too much database queries than i found a method...

later, i found that, if i wrote category path on announces, and write a
custom manager, i can make a query like

*Announce.objects.GetByCategory("/all/animals")*
that makes a querty on database

*select * from announces where category startswith 'all/animals' * (i dont
know sql well ill research later)

than it will result all announces whichs category is Dogs or Cats or Fishes

or *Announce.objects.GetByCategory("/all/")* will return all announces that
is categorized with Animals or Computers or Laptops or Cats

My english is very bad, i wish i explained well my stiuation. After that
problem solved i think i can publish my category applicaton.

--~--~-~--~~~---~--~~
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: encoding problem

2009-07-31 Thread alecs

Environment:

Request Method: GET
Request URL: 
http://172.16.23.33/file/4719e0bdedaa4f741f032991894d52ecb08c3476a598504fd1fee92d
Django Version: 1.0.3
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'filez.filezupload',
 'debug_toolbar']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/share/python-support/python-django/django/core/handlers/
base.py" in get_response
  91. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/share/python-support/python-django/django/contrib/auth/
decorators.py" in __call__
  78. return self.view_func(request, *args, **kwargs)
File "/var/www/filez/filezupload/views.py" in send_file
  253. content_disp = u'attachment; filename="%s" ' %
upfile.file_name

Exception Type: UnicodeDecodeError at /file/
4719e0bdedaa4f741f032991894d52ecb08c3476a598504fd1fee92d
Exception Value: ('ascii', '\xd0\x9d
\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb0
\xd0\xbf\xd0\xbe\xd1\x87\xd1\x82\xd1\x8b.doc', 0, 1, 'ordinal not in
range(128)')


If I do upfile.file_name.decode('utf8').encode('cp1251') it works in
IE ...
--~--~-~--~~~---~--~~
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: encoding problem

2009-07-31 Thread Daniel Roseman

On Jul 31, 11:55 am, alecs  wrote:
> I'm sending a file to user:
>
> upfile = UpFile.objects.get(file_hash=request.path[6:])
>         user = get_object_or_404(User, username=request.user.username)
>         down_file_log = DownFile.objects.create(user_id=user,
> file_id=upfile)
>         wrapper = FileWrapper(file(upfile.file_path))
>         response = HttpResponse(wrapper)
>         response['Content-Length'] = os.path.getsize(upfile.file_path)
>         response['Content-Type'] = upfile.file_content_type + ';
> charset=utf8'
>         response['Content-Disposition'] = 'attachment; filename=\"' +
> upfile.file_name + '\"'
>         return response
>
> Mysql database encoding is utf8_bin.
> The problem is in the filename: everything works OK with English, but
> if the file_name is in Russian then in IE6 it's horrible and unreadable
> (when you press on file link and download window appears) :(( But in
> Firefox && Opera it's OK :((
> Any suggestions ?

This *might* work:
 content_disp = u'attachment; filename="%s" ' % upfile.file_name
 response['Content-Disposition'] = content_disp.encode('utf-8')
--
DR.
--~--~-~--~~~---~--~~
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: i need custom database behaviour, but i dont know how to do it

2009-07-31 Thread Daniel Roseman

On Jul 31, 11:25 am, Mirat Bayrak  wrote:
> I am working on a *Categories* application for my project. The model that i
> need to categorize ise *Announces*.. i descibed category in announces like
> this
>
> class Category
>     ...
>     ...
>     path = models.CharField 
>
> class Announce:
>     ...
>     ...
>     ...
>     category = models.ForeignKey(Category)
>
> So my question,
>
> This* Announce model saves id of category* on database and calls with id
> when it needed, but *i want to make it save Category.path *
>
> can i do it easly? or should i override something ? any ideas?

Do you mean you want the foreign key value to be the 'path' field of
the Category model? You could do this, but why would you want to? If
you ever want to refer to the category path from an Announce instance,
you just do:
   announce.category.path

--
DR.
--~--~-~--~~~---~--~~
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: Admin Customisations

2009-07-31 Thread Daniel Roseman

2009/7/31 Steven Church :
> Daniel,
>
> Thank you for replying. I have finally found time now to start working on
> this project again. I have the following.
>
> def viewlink(self, obj):
> return 'View & Print'
> viewlink.allow_tags = True
>
> and i have put the "viewlink" within the list_display: i get the following
> error.
>
> TemplateSyntaxError at /admin/application/student/
>
> Caught an exception while rendering: not all arguments converted during
> string formatting

You need to learn about Python string formatting, because what you've
done there is invalid Python code. The official docs are here:
http://docs.python.org/library/stdtypes.html#string-formatting
but basically your return statement should be like this:

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



encoding problem

2009-07-31 Thread alecs

I'm sending a file to user:

upfile = UpFile.objects.get(file_hash=request.path[6:])
user = get_object_or_404(User, username=request.user.username)
down_file_log = DownFile.objects.create(user_id=user,
file_id=upfile)
wrapper = FileWrapper(file(upfile.file_path))
response = HttpResponse(wrapper)
response['Content-Length'] = os.path.getsize(upfile.file_path)
response['Content-Type'] = upfile.file_content_type + ';
charset=utf8'
response['Content-Disposition'] = 'attachment; filename=\"' +
upfile.file_name + '\"'
return response

Mysql database encoding is utf8_bin.
The problem is in the filename: everything works OK with English, but
if the file_name is in Russian then in IE6 it's horrible and unreadable
(when you press on file link and download window appears) :(( But in
Firefox && Opera it's OK :((
Any suggestions ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



i need custom database behaviour, but i dont know how to do it

2009-07-31 Thread Mirat Bayrak
I am working on a *Categories* application for my project. The model that i
need to categorize ise *Announces*.. i descibed category in announces like
this

class Category
...
...
path = models.CharField 

class Announce:
...
...
...
category = models.ForeignKey(Category)

So my question,

This* Announce model saves id of category* on database and calls with id
when it needed, but *i want to make it save Category.path *

can i do it easly? or should i override something ? any ideas?

--~--~-~--~~~---~--~~
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: Create a web application

2009-07-31 Thread pallavi

hey susanne, sorry i could not help as i gave up that aplication.
perhaps some one surely can help u here

On Jul 31, 1:36 am, susanne  wrote:
> Hello Mr.pallavi, Mr.George and other members,
> I have similar application like palavi. I followed this hints but not
> success.
> Please let me know how did you proceed.
>
> my python application has functions to perform different
> calculations.
>
> 1) The program reads input file called IN.txt.
> the IN.txt file contains names of three other files( x.dat, y.txt,
> z.dat) that are
> in the same directory.
>
> 2) then the application reads the data in the files x.dat, y.txt,
> z.dat and performs some calculations.
>
> 3) outputs the results in a file called out.txt
>
> The application is running perfectly from command mode. I need to make
> it a web application so that it can be run in a browser from anywhere.
> I tried with cherrypy and django tutorials, but could not succeed, as
> i am completely new to this field. can some one help with steps to
> proceed.
>
> Thanks in advance!
> Susanne
>
>
>
>
>
> > My main python program is science.py
> > it have several modules.in it (each definition reads some parameters
> > and results some data, that will be read
> > by next module). but at the end, only few of the results are printed
> > to a data file.
> > science.py
> > ---
> > def function1(parameter1,parmeter2) :
> >                   {
> >                        -
> >                        -
> >                   }
> >                   return data1
> > def function2(data1,parmeter3) :
> >                   {
> >                        -
> >                        -
> >                   }
> >                   return data2
> > #output is printed to a file as data.dat that contains data1, data2
> > view.py
> > 
> > from django.http import HttpResponse
> > from science import function1
> > from science import function2
> > def science_service(request):
> >          return HttpResponse(
> >          # function1 reads parameter1, and parameter2
> >          function1 (parameter1, parameter2), , mimetype="text/plain"
> >          )
> > def science_service(request):
> >          return HttpResponse(
> >          function2 (data1, parameter3), , mimetype="text/plain"
> >          )
> > is this the correct way to write my view based on George's
> > suggestion:
> > i keep my science.py in the current working directory.
> > pls shed some lightyour suggestions are very valuable for novice
> > like me.
>
> You're on the right track.
>
> 1. You can't name both views the same, if they're in the same module.
> Otherwise the second definition will override the first one.
> 2. There's a slight mistake in your response:
> {{{
> def science_service(request):
>      return HttpResponse(
>          function1(p1, p2), mimetype="text/plain"
>      )
>
> }}}
>
> Of course you'll have to instantiate p1 and p2 somewhere in the
> module,
> if you're not passing those in through the request somehow.
>
> --
> George- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Thoughts on many-to-many relationship

2009-07-31 Thread prabhu S

Hi All,

When I try to create a Group (django.contrib.auth.models.Group)
dynamically, I get the below error.

'Group' instance needs to have a primary key value before a many-to-
many relationship can be used.

This is because I am trying to add permissions to the group object and
trying to save every thing in one shot. As a work around to this
problem, I am doing an intermediate save and reload of Group object,
which seems to work fine.

Is there a logical reason behind this error? Is this something
fixable?

Regards,
Prabhu
P.S: Exact source code here -
http://github.com/prabhu/invoicy/blob/3f32fff86b806bc0b769de6de7dbe049788f0b24/invoicy/common/utils/decorators.py

--~--~-~--~~~---~--~~
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 can I reload attributes from the database

2009-07-31 Thread Fleg

Thanks for your suggestion, but I cannot... I need to do that from a
method of the model itself.
Basically, I need to use some stored procedures to modify datas in the
database (and these stored procs can also modify some other tables),
thus I need to reload after calling these procedures in order to
update the modified values. And this must be done from the instance
because it's only a part of a process.

Example:
action=Scheduler.objects.get(id_schedule=22)
action.do_something()


and in the Scheduler class I have
def do_something(self):
call_proc_stock_1() --> this will update id_status in table
schedule and modify the line corresponding to the id_release in table
release
do_smething_else() etc...

So after call_proc_stock_1() I need to reload to have the correct
(updated) id_status and id_release objects (and not only the value of
the key, the whole associated object).

F.




On Jul 30, 3:26 pm, Karen Tracey  wrote:
> On Thu, Jul 30, 2009 at 9:10 AM, Fleg  wrote:
>
> > Nobody knows ?
>
> Simply re-get the instance from the DB?
>
> Karen
>
>
>
> > On Jul 29, 6:12 pm, Fleg  wrote:
> > > Hi,
> > > I have a model mapping tables in a database with several foreign keys.
>
> > > class Scheduler(models.Model):
> > >         id_schedule = models.AutoField(primary_key=True)
> > >         id_parent = models.ForeignKey
> > > ("Scheduler",db_column='id_parent',to_field='id_schedule')
> > >         id_object_type = models.ForeignKey(ObjectTypes,
> > > db_column='id_object_type',to_field='id_object_type')
> > >         id_action = models.ForeignKey(Actions,
> > > db_column='id_action',to_field='id_action')
> > >         id_status = models.ForeignKey(Status,
> > > db_column='id_status',to_field='id_status')
> > >         id_release = models.ForeignKey(Releases,
> > > db_column='id_release',to_field='id_release')
> > >         id_object = models.IntegerField()
> > >         begin_execute = models.DateTimeField(null=True,blank=True)
> > >         end_execute = models.DateTimeField(null=True,blank=True)
> > >         pid = models.IntegerField()
>
> > > I am working with an instance of this model and at some point I need
> > > to reload it's attributes from the database.
> > > I couldn't find a correct way to do it. Can somebody help me ?
>
> > > PS: I tryed to write a "reload" method like this:
> > > def __reload__(self):
> > >                 self.__init__(**Scheduler.objects.filter
> > > (id_schedule=self.id_schedule).values()[0])
>
> > > but unfortunately, it updates only the keys but not the objects
> > > associated with the foreign keys !
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Finding a Django expert to review my code

2009-07-31 Thread Hernan Olivera

2009/7/31 Hernan Olivera :
> 2009/7/31 Daniel Roseman :
>>
>> On Jul 31, 7:21 am, Rex  wrote:
>>> I just created my first Django site (as an academic research project).
>>> Now that it is done, I would like to get feedback on my code from a
>>> Django expert so that I can learn where I can improve as a Django dev.
>>> How can I find someone to spend 1 or 2 hours reviewing my code with
>>> me? I found a few employment posting websites, but they seemed more
>>> geared toward posting jobs or large freelance projects, not something
>>> small like this.
>>>
>>> Thanks,
>>>
>>> Rex
>>
>> You might try www.rentacoder.com - they have a category for 'personal
>> project/homework help' which might be appropriate. Or, if you need
>> someone local to sit down with you, try http://djangopeople.net/.
>> --
>> DR.
>> >>
>>
>
>
> I'll suggest you something different. Put your code in a public
> accesible site, and make this open and collaborative. Let all of us
> tell you wath we think about the code, and coordinate some way to rank
> que suggestions, for example we can vote it, or argument why, etc. You
> can get all out collective intelligence in this way, and all of us
> could learn for this. Then, use your budget to support this, or donate
> it to Django Project, or somoething. I think this is much more
> interesting in an academic way, and for the community.
>
> What do you think?
>
>
> Open greetings ;-)
>
> --
> Hernan Olivera
>


May be your budget can be a prize for the best suggestions/revisors,
and the like.

-- 
Hernan Olivera

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



Re: Finding a Django expert to review my code

2009-07-31 Thread Hernan Olivera

2009/7/31 Daniel Roseman :
>
> On Jul 31, 7:21 am, Rex  wrote:
>> I just created my first Django site (as an academic research project).
>> Now that it is done, I would like to get feedback on my code from a
>> Django expert so that I can learn where I can improve as a Django dev.
>> How can I find someone to spend 1 or 2 hours reviewing my code with
>> me? I found a few employment posting websites, but they seemed more
>> geared toward posting jobs or large freelance projects, not something
>> small like this.
>>
>> Thanks,
>>
>> Rex
>
> You might try www.rentacoder.com - they have a category for 'personal
> project/homework help' which might be appropriate. Or, if you need
> someone local to sit down with you, try http://djangopeople.net/.
> --
> DR.
> >
>


I'll suggest you something different. Put your code in a public
accesible site, and make this open and collaborative. Let all of us
tell you wath we think about the code, and coordinate some way to rank
que suggestions, for example we can vote it, or argument why, etc. You
can get all out collective intelligence in this way, and all of us
could learn for this. Then, use your budget to support this, or donate
it to Django Project, or somoething. I think this is much more
interesting in an academic way, and for the community.

What do you think?


Open greetings ;-)

-- 
Hernan Olivera

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



Re: Finding a Django expert to review my code

2009-07-31 Thread Daniel Roseman

On Jul 31, 7:21 am, Rex  wrote:
> I just created my first Django site (as an academic research project).
> Now that it is done, I would like to get feedback on my code from a
> Django expert so that I can learn where I can improve as a Django dev.
> How can I find someone to spend 1 or 2 hours reviewing my code with
> me? I found a few employment posting websites, but they seemed more
> geared toward posting jobs or large freelance projects, not something
> small like this.
>
> Thanks,
>
> Rex

You might try www.rentacoder.com - they have a category for 'personal
project/homework help' which might be appropriate. Or, if you need
someone local to sit down with you, try http://djangopeople.net/.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



dynamic form

2009-07-31 Thread Salvatore Leone

Hi,

I've got a form with various information and a file upload widget.

Is there a way to uploads many files at the same time? So to have a link 
"add file" (and even "remove" file for already selected files).

A possible way is to use some ajax framework (like jquery).

So my questin is:

do I have to manualy import jquery in my template or there some "django 
way" for doing it?

--Salvatore

--~--~-~--~~~---~--~~
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: Handle event on a django event Calendar

2009-07-31 Thread kimo

i tried but i have no calendar displayed, i have  an error calendar()
takes exaclty 3 arguments (1given)

When i tried to put 3 arguments in my urls.py, nothing change.

Thank you for help.

On Jul 30, 2:19 pm, kimo  wrote:
> Thank you.
>
> I will have a look.
>
> On Jul 30, 2:14 pm, Steve Schwarz  wrote:
>
> > On Thu, Jul 30, 2009 at 6:41 AM, kimo  wrote:
>
> > > Hi,
>
> > > Is there a way to have a django Clandar Event, i have a Event model,
> > > and i want to display the event information on the calendar in order
> > > to know if the organiser is free or busy on the date event.
>
> > > Many Thanks.
>
> > > I didn't find the Django Calendar. Where can i find some good example
> > > please ?
>
> > Hi,
>
> > Googling for "django calendar" found this article which contains some links
> > to other django calendar 
> > projects:http://journal.uggedal.com/creating-a-flexible-monthly-calendar-in-dj...
>
> > Best Regards,
> > Steve
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: clean_() doesn't handle images?

2009-07-31 Thread Martje

I don't understand, sorry :$. Do you care to explain a little bit
more? Or could you give an example?

I'm using the admin interface btw.

On 31 jul, 01:45, Karen Tracey  wrote:
> On Thu, Jul 30, 2009 at 4:02 PM, Martje  wrote:
>
> > Hey,
>
> > I've got the following code in my models.py:
>
> > from django import forms
> > class Foto(models.Model):
> >    omschrijving = models.CharField(max_length=100)
> >    afbeelding = models.ImageField(upload_to='media/afbeeldingen/
> > header/fotos')
>
> >    def clean_afbeelding(self):
> >        raise forms.ValidationError("Never good! :-)")
>
> > Still, if I upload an image it validates, where it shouldn't, right?
>
> Custom clean methods need to be added to the form you are using, not the
> model.
>
> Karen
--~--~-~--~~~---~--~~
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 save a model...

2009-07-31 Thread zayatzz

Thanks Malcolm,

I will test it when i get back home :)

Alan

On Jul 31, 9:46 am, Malcolm Tredinnick 
wrote:
> On Thu, 2009-07-30 at 12:33 -0700, zayatzz wrote:
> > ... Hello!
>
> > I have a model (profile) which's only required field is its foreignkey
> > - django.contrib.auth.User.
>
> > Following the example of forementioned model and its manager i created
> > manager for the profile:
>
> > class ProfileManager(models.Manager):
> >    def create_profile(self, username):
> >            "Creates and saves a User with the given username, e-mail and
> > password."
> >            now = datetime.datetime.now()
> >            profile = self.model(None, username)
> >            profile.save()
> >            return profile
>
> It's very tricky to pass positional arguments to the __init__ method of
> a model. Django does it itself when it creates models, because it knows
> how the fields are structured, but it's very hard to get right and not
> recommended in normal code. Instead, use keyword arguments. So you would
> write something like this:
>
>         user_instance = User.objects.get(username=username)
>         profile = self.model(user = user_instance)
>         profile.save()
>
> The other change I've made here is to retrieve the correct User object,
> since Django doesn't automatically know how to go from your "username"
> string to a particular User instance.
>
>
>
>
>
> > and Profile model is like this :
> > class Profile(models.Model):
> >    user = models.ForeignKey(User, unique=True)
> >         ..
> >         several other stuff all have null=True
> >         ...
> >    objects = ProfileManager()
>
> > Now when i do this in a view:
> >                    profile = Profile.objects.create_profile(request.user)
>
> > I get an error:
>
> > Exception Type:    TypeError
> > Exception Value:   int() argument must be a string or a number, not
> > 'User'
>
> > So why is this not working?
>
> For the future, it is highly recommended to post the full traceback. On
> the debug page you see in your web browser, there is a link that says
> "cut-and-paste view". Click on that to get something that is suitable
> for sticking in email. In this case, it's kind of possible to guess what
> was causing the error (although I may have guessed poorly). At other
> times, it isn't, so a little guidance from the traceback can often work
> wonders.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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: "join" query in Django?

2009-07-31 Thread Malcolm Tredinnick

On Thu, 2009-07-30 at 23:42 -0700, Asinox wrote:
> Thanks Malcom for replay, but, is not working for me, i think that is
> simple just .filter("field1__field2"), but i cant make the join i try
> with .filter("field1__field2") where the field1 is the PK and the
> field2 is the FK.
> 
> here is my query:
> 
> p = Diligencia.objects.filter(Q(socio=request.user.id),Q(status=0) | Q
> (status=1)| Q(status=3)).filter("id__diligencia")
> 
> and the error is: too many values to unpack

It's effectively impossible to debug this from the information you've
provided, because we cannot see the model(s) you are trying to query
against. I am, however, very suspicious of the bit that says
filter("id__diligencia"), since "id" is almost always the auto-generated
primary key field and not a reference to another model.

Please construct some simple models that show the problem you're seeing.
Also, the error isn't just reported as you say above. It also has a
traceback in there, which is typically very useful, as it shows us where
the error is coming from.

> 
> im new with Django i cant understand this error, i searched and i cant
> find answer about it.
> 
> The another try was:
> 
> p = Diligencia.objects.filter(Q(socio=request.user.id),Q(status=0) | Q
> (status=1)| Q(status=3)).select_related()
> 
> in this case i dont have errors but the data that i want to show from
> the second table is not showing... and Django dont have any setting
> function that will show the "SQL" that is happening in any query,

You can try this approach, which shows the SQL after the query has been
run:

http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running

Or look at the output of p.query.as_sql() (where "p" is your queryset,
above) to see the results of the SQL that would be sent to the database.
Or look at django-debug-toolbar for a more in-browser view of thigns.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 save a model...

2009-07-31 Thread Malcolm Tredinnick

On Thu, 2009-07-30 at 12:33 -0700, zayatzz wrote:
> ... Hello!
> 
> I have a model (profile) which's only required field is its foreignkey
> - django.contrib.auth.User.
> 
> Following the example of forementioned model and its manager i created
> manager for the profile:
> 
> class ProfileManager(models.Manager):
>   def create_profile(self, username):
>   "Creates and saves a User with the given username, e-mail and
> password."
>   now = datetime.datetime.now()
>   profile = self.model(None, username)
>   profile.save()
>   return profile

It's very tricky to pass positional arguments to the __init__ method of
a model. Django does it itself when it creates models, because it knows
how the fields are structured, but it's very hard to get right and not
recommended in normal code. Instead, use keyword arguments. So you would
write something like this:

user_instance = User.objects.get(username=username)
profile = self.model(user = user_instance)
profile.save()

The other change I've made here is to retrieve the correct User object,
since Django doesn't automatically know how to go from your "username"
string to a particular User instance.

> 
> and Profile model is like this :
> class Profile(models.Model):
>   user = models.ForeignKey(User, unique=True)
> ..
> several other stuff all have null=True
> ...
>   objects = ProfileManager()
> 
> Now when i do this in a view:
>   profile = Profile.objects.create_profile(request.user)
> 
> I get an error:
> 
> Exception Type:   TypeError
> Exception Value:  int() argument must be a string or a number, not
> 'User'
> 
> So why is this not working?

For the future, it is highly recommended to post the full traceback. On
the debug page you see in your web browser, there is a link that says
"cut-and-paste view". Click on that to get something that is suitable
for sticking in email. In this case, it's kind of possible to guess what
was causing the error (although I may have guessed poorly). At other
times, it isn't, so a little guidance from the traceback can often work
wonders.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: "join" query in Django?

2009-07-31 Thread Asinox

Thanks Malcom for replay, but, is not working for me, i think that is
simple just .filter("field1__field2"), but i cant make the join i try
with .filter("field1__field2") where the field1 is the PK and the
field2 is the FK.

here is my query:

p = Diligencia.objects.filter(Q(socio=request.user.id),Q(status=0) | Q
(status=1)| Q(status=3)).filter("id__diligencia")

and the error is: too many values to unpack

im new with Django i cant understand this error, i searched and i cant
find answer about it.

The another try was:

p = Diligencia.objects.filter(Q(socio=request.user.id),Q(status=0) | Q
(status=1)| Q(status=3)).select_related()

in this case i dont have errors but the data that i want to show from
the second table is not showing... and Django dont have any setting
function that will show the "SQL" that is happening in any query, like
CodeIgniter "Profiler APP", that show you the SQL and you will see if
the query is selecting the data that you want... im lost with
Django...i missing PHP and Codeigniter :(, but i want to learn Django

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



Re: Finding a Django expert to review my code

2009-07-31 Thread Parag Shah
Hi Rex,

I am not a django expert (in fact I have just started working with Django
about a month back), but I have been in software development for a while.

Remote code review sounds like an interesting exercise. I will be glad to
help you with the review, but with no prior promises on the outcome :-) I am
hoping to share what I know and also learn some new things myself.

-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz

On Fri, Jul 31, 2009 at 11:51 AM, Rex  wrote:

>
> I just created my first Django site (as an academic research project).
> Now that it is done, I would like to get feedback on my code from a
> Django expert so that I can learn where I can improve as a Django dev.
> How can I find someone to spend 1 or 2 hours reviewing my code with
> me? I found a few employment posting websites, but they seemed more
> geared toward posting jobs or large freelance projects, not something
> small like this.
>
> Thanks,
>
> Rex
> >
>

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



Re: Finding a Django expert to review my code

2009-07-31 Thread Ben Atkin
I'd probably try emailing some of the top Django developers. This seems like
it would be a buyer's market, due to the job being short and fun for a
dedicated Django dev. Don't hire a noob like me. ;)

http://code.djangoproject.com/wiki/DevelopersForHire

Ben

On Thu, Jul 30, 2009 at 11:21 PM, Rex  wrote:

>
> I just created my first Django site (as an academic research project).
> Now that it is done, I would like to get feedback on my code from a
> Django expert so that I can learn where I can improve as a Django dev.
> How can I find someone to spend 1 or 2 hours reviewing my code with
> me? I found a few employment posting websites, but they seemed more
> geared toward posting jobs or large freelance projects, not something
> small like this.
>
> Thanks,
>
> Rex
> >
>

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



Re: Finding a Django expert to review my code

2009-07-31 Thread Daniel Brown

Good evening Rex,

I'm a beginner to Python and Django and I've found running my scripts
through PyLint (http://pypi.python.org/pypi/pylint) to be very worth
while.

Regards,

Daniel

2009/7/30 Rex :
>
> I just created my first Django site (as an academic research project).
> Now that it is done, I would like to get feedback on my code from a
> Django expert so that I can learn where I can improve as a Django dev.
> How can I find someone to spend 1 or 2 hours reviewing my code with
> me? I found a few employment posting websites, but they seemed more
> geared toward posting jobs or large freelance projects, not something
> small like this.
>
> Thanks,
>
> Rex
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >