how can i make django url system acept the following url http://www.yoursite.com/notifications?topic=payment&id=identificador-de-notificación-de-pago

2014-07-16 Thread Matias Araujo
Hi all! im devoloping a site in django and i need to recive an http request 
with an url of this type:
 http://testsystemser.cloudapp.net/pago/index
?topic=payment&id=identificador-de-notificación-de-pago 
but i cant make it match with my urlconf in my project, i try with the 
following ur:
url(r'pago/index/(?P\w)/(?P\w)', 'apps.pagos.views.index', 
name='index'),
l but it didnt match so i cant handle the request and recive the 
information i need.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6303a363-cd4d-47cc-af1c-ea804dd77a3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pip search raises "time out"

2013-01-09 Thread Matias Montenegro
I need a hand with this problem. I get a "time out" exception when i run 
"pip search", but "pip install" works fine. I'm using a proxy and I can't 
deactivate it. Does anybody know why it might be happening?
 
http://pastebin.com/2z7SPqf2

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



Incorrect string value when running GeoDjango tutorial

2012-08-14 Thread Matias Burak
Hi, I was trying to go through the GeoDjango tutorial and when I try to 
import data with LayerMapping I'm getting the following error:

  Warning: Incorrect string value: '\xC2\x85land...' for column 'name' 
at row 1

I'm using MySQL and my charset and collation are set to latin1 (I also 
tried utf8).

Any help is appreciated.
Matias.

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



Upload from mobile device using POST

2011-05-01 Thread Matias Hernandez Arellano
(sorry for my english)
(i open this thread cuase the other thread was for another question)

I have a mobile device application (iOS) and i want to upload an image to my 
django application

In my mobile application i create the POST request (and disable csrf in my 
django app) using this:

- (void)upload{
NSData *imageData = UIImageJPEGRepresentation(imageView.image,90);
NSString *urlString = @"http://190.91.43.241:8000/subir/1/";;
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] 
init]autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];

NSString *boundary = [NSString 
stringWithString:@"---14737809831466499882746641449"];
NSString *contentType=[NSString stringWithFormat:@"multipart/form-data; 
boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];

NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] 
dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Disposition: 
form-data; name=\"file\"; filename=\"file\"\r\n"] 
dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: 
application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
//[body appendData:[[NSString 
stringWithFormat:@"\r\n--%@--\r\n",boundary] 
dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"\r\n"] 
dataUsingEncoding:NSUTF8StringEncoding]];
// setting the body of the post to the reqeust
[request setHTTPBody:body];

// now lets make the connection to the web
NSData *returnData = [NSURLConnection sendSynchronousRequest:request 
returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData 
encoding:NSUTF8StringEncoding];
NSLog(@"%@",returnString);

}

And in my Djago app:
def upload_image(request):
if request.method == 'POST':
return request.FILES['file']
return "NO imagen subida"

def subir(request,imagen):
try:
#some functions ..
result =  upload_image(request)
return HttpResponse(result)
except Thrift.TException, tx:
print '%s' % (tx.message)


but i have a error 500 and if i see the logs i have this:
Exception Type: MultiValueDictKeyError
Exception Value:
"Key 'file' not found in "

Any idea?

thanks in advance..

(i'm a newbie with django and python)

Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl




-- 
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: Upload image using GET

2011-05-01 Thread Matias Hernandez Arellano
yes, thanks.. i try using POST but i get a error 500

i only use this to test
def upload_image(request):
if request.method == 'POST':
return "request.FILES['image']"
return "NO imagen subida"


El 01-05-2011, a las 23:11, А. Р. escribió:

> 2011/5/2 Matias Hernandez Arellano <...@archlinux.cl>:
>> 
>> And if it's not possible use GET to pass the image data to the django 
>> application..
>> how can i pass de data from a mobile application (without user actions like 
>> a web form) to the django application, and upload, or copy de data into a 
>> new image??
> 
> http://en.wikipedia.org/wiki/POST_%28HTTP%29
> 
> It is possible to send POST requests without user actions.
> 
> -- 
> 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.
> 

Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl




-- 
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: Upload image using GET

2011-05-01 Thread Matias Hernandez Arellano
Thrift: http://incubator.apache.org/thrift/

And if it's not possible use GET to pass the image data to the django 
application..
how can i pass de data from a mobile application (without user actions like a 
web form) to the django application, and upload, or copy de data into a new 
image??

Thanks in advance

El 01-05-2011, a las 22:59, А. Р. escribió:

> 2011/5/2 msdark <...@gmail.com>:
> 
> 
>> The service is written in C++ and use thrift to create a Client with
>> python.. so i write a simple django application like and interface to
>> the C++ service.
> 
> What is "thrift"? Do you really mean it?
> 
>> 
>> Now i need to upload an image to the django application using a GET
>> method..
> 
> You cannot, I think, unless your image is very tiny, then you can pass
> it's contents as a GET parameter.
> I suggest you use POST instead.
> 
>> The idea is: www.servidor.com/upload/path_to_image_in_device.png
> 
> I cannot get the image specified.
> 
> -- 
> 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.
> 

Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl




-- 
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: File Upload fails

2011-03-17 Thread Matias Aguirre
You are missing the enctype form attribute needed for files input fields. Your
form definition should be:



Check http://www.w3.org/TR/html401/interact/forms.html#adef-enctype for details.

Matías


Excerpts from arapaho's message of Thu Mar 17 15:53:45 -0300 2011:
> Hi,
> 
> Rather new to Django and using 1.2.5 and Windows, I am hung up trying
> to upload a file. I get a post request with request.FILES empty.
> 
> My VIEW is:
> 
> def intro(request):
> c = {}
> c.update(csrf(request))
> 
> if request.method == 'POST': #see if form submitted
> 
> form = FileUploadForm(request.POST,request.FILES)
> print request.FILES
> if form.is_valid():
> text = 'You successfully uploaded file:'
> handle_uploaded_file(request.FILES['file'])
> else:
> text = 'You may upload your student data file here'
> form = FileUploadForm()
> 
> c['form'] = form
> c['text'] = text
> return render_to_response('intro.html', c)
> 
> 
> In SETTINGS I have:
> 
> ROOT_PATH = os.path.dirname(__file__)
> 
> MEDIA_ROOT = '/media/'
> 
> MEDIA_URL = '/media/'
> 
> And my TEMPLATE includes:
> 
> {% csrf_token %}
> 
> 
> {{ form }}
> 
> 
> 
> Any suggestions much appreciated.
> 
> Bob
> 
-- 
Matías Aguirre 

-- 
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: pyfacebook @facebook.require_login() not working

2011-03-15 Thread Matias Aguirre
I don't have the solution for your issue, didn't used pyfacebook, yet. But if
you are looking to register users using Facebook OAuth, then django-social-auth
may fit your needs:

http://github.com/omab/django-social-auth/

Then you can use any other Facebook API around to access users content and it
integrates with django auth system easily.

Also, not related with your work, but I'm glad to announce that it gained
Google OAuth2 support recently :-)

Regards,
Matías

Excerpts from mongoose's message of Tue Mar 15 08:03:07 -0300 2011:
> Hi there,
> 
> First time using pyFacebook. I've literally copied the example
> application [https://github.com/sciyoshi/pyfacebook/tree/master/
> examples/fbsample] and put it up onto my server. I've created an FB
> app and now when I try to load the app basically what happens is that
> the browser keeps refreshing. I noticed in the url (for example)
> 
> 
> https://apps.facebook.com/myapp/?auth_token=8f826cae31717068c18fb16fd7f0a758
> 
> Keeps refreshing with the auth_token changing. If I remove the
> @facebook.require_login() decorator then the page displays without a
> problem.
> I've also commented out the
> 'django.middleware.csrf.CsrfViewMiddleware', but not sure if that's
> relevant at all.
-- 
Matías Aguirre 

-- 
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: acces to dict

2011-03-10 Thread Matias Aguirre
Hi

The problem is that django template system tries __getkey__ first and as you
are using a defaultdict get key call is creating a new entry with key "items"
and empty list as value.

Try passing dict(prod_pool) to your template.

Regards,
Matías

Excerpts from Szabo, Patrick \(LNG-VIE\)'s message of Thu Mar 10 11:28:00 -0200 
2011:
> Hi, 
> 
>  
> 
> I'm passing a dict of lists on to a template like this:
> 
>  
> 
> return render_to_response('reports.html', {'produkte': prod_pool}
> ,context_instance=RequestContext(request))
> 
>  
> 
> prod_pool looks like this:
> 
>  
> 
> defaultdict(, {'Dumme G\xc3\xa4nge revisited':
> ['Absatzkontrolle'], 'Das Sparschwein im Wandel der Zeiten':
> ['Konvertierungsanleitung', 'Sonstiges'], 'Schlager 1':
> ['Konvertierungsanleitung'], 'RWZ 1': ['Absatzkontrolle',
> 'Konvertierungsanleitung'], 'RWZ 3': ['Absatzkontrolle',
> 'Konvertierungsanleitung']})
> 
>  
> 
> In my template i do this:
> 
>  
> 
> {% for produkt, akt in produkte.items %}
> 
> {{ produkt }}
> 
>  
> 
>
> 
>Aktivitaet
> 
>Zeit
> 
>
> 
>
> 
>{% for x in akt%}
> 
>{{ x }}
> 
>{% endfor %}
> 
>
> 
>
> 
>Gesamt: 
> 
> 
> 
>
> 
> 
> 
> {% endfor %}
> 
>  
> 
> Unfortunately i don't get a single table...
> 
> Can anyone help me ?!
> 
>  
> 
> Kind regards
-- 
Matías Aguirre 

-- 
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 filter related (foreign key) objects?

2011-02-16 Thread Matias Aguirre
Just refer to the field name, you don't need the class:

prev = self.bbb_set.filter(date__lt=date)

Take a look to field lookup rules:
http://docs.djangoproject.com/en/dev/topics/db/queries/#field-lookups-intro

Excerpts from serek's message of Wed Feb 16 20:51:05 -0200 2011:
> Hi
> 
> I have not idea how to describe my problem, so I show pice of code:
> 
> 
> class Aaa(models.Model):
> name = models.CharField(max_length=200, unique=True)
> is_active = models.BooleanField()
> 
> class Meta:
> ordering = ('name',)
> 
> def doMagic(self):
> date = '2010-05-04'
> //here I need to take 10 conencted Bbb objects whcich data is less
> then date
> previous10days = self.bbb_set.filter(Bbb.date <
> date).order_by('data')
> 
> 
> class Bbb(models.Model):
> date = models.DateField()
> value = models.DecimalField(max_digits=7, decimal_places=2)
> aaa = models.ForeignKey(Aaa)
> 
> a = Aaa()
> a.doMagic throw error that Bbb.date is undefined - what can be wrong?
> 
-- 
Matías Aguirre 

-- 
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: request.POST parsing without form

2011-01-28 Thread Matias Aguirre
Excerpts from taso's message of Fri Jan 28 17:05:21 -0200 2011:
> Hi,

Hi,

> I am using django strictly as a backend for data processing. As such I
> am not using any forms or templates, just database tables as models.
> The page is js driven and POSTing data is causing me some issues.
> 
> A user action triggers a POST that looks like:
> 
> action "update"
> data{ "field1": 8,"id": 2 }
> (copied from firebug)

So, it's a POST with an "action" fiend and a "data" field that looks like
a JSON value, right?

> When I try to parse the POST data I get errors on every type of method
> I have tried. What I eventually would like to do is something like:
> 
> if request.POST.__getitem__('xaction') == 'update':
> mydata = request.POST.__getitem__('data')
> model_to_update = modelname.get(id=mydata['id']
> for k,v in mydata:
> setattr(model_to_update, k, v)
> model_to_update.save()
> 
> However every time I try to parse the "data" POST values I get errors.
> I wonder if I am missing some assumptions by not importing/using
> forms, or if there is a standard method to iterate through the POST
> data that I am missing. I have literally tried every \*get\* dict
> method from the docs and all throw errors (.list() throws numeric
> indicies errors, iteritems() throws not iterable, etc.)
> 
> Any thoughts?

Did you tried un-encoding the JSON, like this:

from django.utils.simplejson import simplejson

data = simplejson.loads(request.POST['data'])
id = data['id']
...

> Thanks
> Taso

Regards,
Matías
-- 
Matías Aguirre 

-- 
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: Invalidate cached copy when changes are made.

2011-01-27 Thread Matias Aguirre
You could use signals[1] to update cache on save event, but I think you
are approaching the issue in the wrong way, why not paginate[2] the
result?

Regards,
Matías

[1]: http://docs.djangoproject.com/en/dev/topics/signals/
[2]: http://docs.djangoproject.com/en/dev/topics/pagination/

Excerpts from Pranav's message of Fri Jan 28 01:36:02 -0200 2011:
> Hi all,
> 
> I have a model that ruffly looks like so,
> 
> Class Member(model);
>   member_id = model.Integerfield(primary_key=True)
>   organization = model.foreignerkey(primary_key=True)
>   transorg = model.foreignerkey()
>   bo_name = model.foreignerkey()
>  member_create_date = model.datetimefield()
>  member_modified_date = model.datetimefield()
>  ...
>  class meta:
> db_table = 'Member'
> unique_together = ('member_id','organization')
> 
> 
>I have a view (display members) which allows user to search
> based on multiple foreigner keys, the result ruffly returns about 811
> Members and takes a long time to execute. So i started using cache
> which resulted in faster serving of the page but when changes are made
> to one of the Member the change is not shown on the display member
> page, instead it still shows the cached page, i used decorator @cache-
> control(must_revalidate=True) but i figured it has a max age. I
> thought I'll use @condition(Etag_func,last_modified_func,) but i'm not
> clear how to use it, since I'm filtering based on multiple fields,
> also my result returns 811 members, so I'll have to check
> member_modified_date of 811 members??? Is there a way i can use the
> cache so that it gets a new copy when i make changes.
> 
-- 
Matías Aguirre 

-- 
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 facebook authentication

2011-01-25 Thread Matias Aguirre
Hi,

Is your request.get_host() the same defined in Facebook app settings? (Web site
section if I can recall correctly), facebook doesn't accept 127.0.0.1 as
redirect url and might not accept localhost too.

Check social_auth/backends/facebook.py on 
https://github.com/omab/django-social-auth
for an example.

Regards,
Matías

Excerpts from CrabbyPete's message of Wed Jan 26 00:39:05 -0200 2011:
> I am going nuts this should be simple but I keep getting a
> verification error every time in my response in the following code. I
> double checked my APP_ID and SECRET  I try the following code. I'm
> using python2.5. Any help appreciated.
> 
> def login( request ):
> 
> parms = { 'client_id': settings.FACEBOOK_APP_ID,
>   'redirect_uri': 'http://' + request.get_host() +
> request.get_full_path()
> }
> 
> if 'code' in request.GET:
> parms['code'] = request.GET['code']
> parms['client_secret'] = settings.FACEBOOK_APP_SECRET
> url = 'https://graph.facebook.com/oauth/access_token?' +
> urllib.urlencode(parms)
> 
> response = urllib.urlopen(url).read()
> pdb.set_trace()
> response =cgi.parse_qs(response)
> 
> if 'access_token' in response:
> access_token = response['access_token'][0]
> graph = GraphAPI( access_token )
> profile = graph.get_object("me")
> url = reverse('sites')
> url = reverse('sites')
> 
> else:
> parms['scope'] = 'email,user_location'
> url = "https://graph.facebook.com/oauth/authorize?"; +
> urllib.urlencode(parms)
> 
> return HttpResponseRedirect(url)
-- 
Matías Aguirre 

-- 
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: Cant find out the "OR" in query

2011-01-24 Thread Matias Aguirre
Excerpts from nicolas lubkov's message of Mon Jan 24 04:18:18 -0200 2011:
> hi all is pretty simple my question.
> 
> when im making a query in django i use this
> 
> result = person.objects.filter(name = "nick", lastname = "smith")
> 
> this is like "select * from person where name = 'nick' and lastname = 'smith
> 
> i cant figure it out how to make
>   "select * from person where name = 'nick' OR lastname = 'smith

Take a look to Q objects:

http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects
-- 
Matías Aguirre 

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



Re: django url question

2011-01-17 Thread Matias Aguirre
The '?' should be quoted as '%3F' (urllib.urlquote('?')) or it will be treated
as a query parameter (check request.GET in your view ;))

Matías

Excerpts from yanghq's message of Mon Jan 17 05:59:23 -0200 2011:
> hi,
> 
>  In urls.py a pattern like this:
> (r'^test/(?P\w{3,4})/(?P.*)$', 'djprj.test.views.info'),
> 
> In views.py,info defined as follows:
> def info(request,protocol='',url=''):
> 
> 
> when I access "test/http/bbs.test.com/viewforum.php?f=12"
> 
> url is bbs.test.com/viewforum.php,"?f=12" is missing
> 
> can someone explain this? than you for any help
> 
> 
> ---
> Confidentiality Notice: The information contained in this e-mail and any 
> accompanying attachment(s) 
> is intended only for the use of the intended recipient and may be 
> confidential and/or privileged of 
> Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of 
> this communication is 
> not the intended recipient, unauthorized use, forwarding, printing,  storing, 
> disclosure or copying 
> is strictly prohibited, and may be unlawful.If you have received this 
> communication in error,please 
> immediately notify the sender by return e-mail, and delete the original 
> message and all copies from 
> your system. Thank you. 
-- 
Matías Aguirre 

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



Re: Too many items in my drowndown list

2011-01-14 Thread Matias Aguirre
Yes, it's possible, define them in in your inline class.

Excerpts from mongoose's message of Fri Jan 14 08:53:18 -0200 2011:
> Ok so I've tried it but can't get it to work properly. I am using
> inlines. Is it possible to use raw_id_fields with inlines?
> 
> On Jan 4, 9:25 am, mongoose  wrote:
> > Thanks so much I'm going to give this a try!
> >
> > On Jan 3, 1:54 pm, Greg Turner  wrote:
> >
> > > Using a raw_id_field instead of a dropdown list will open a popup with a
> > > 'pseudo' django admin. The reason I call it 'pseudo' is that the list can 
> > > be
> > > searched or filtered just like the normal django admin, but when you click
> > > on an item, it becomes the selected item in your inline, and the window
> > > closes.
> >
> > > On 3 January 2011 18:55, mongoose  wrote:
> >
> > > > Hi there,
> >
> > > > I have a drowdown list in my inlines. The problem is that there are
> > > > over 3500 items which is making is difficult for people to use. Are
> > > > there eaiser ways perhaps to filter or search within the dropdownlist?
> >
> > > > 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.
> >
> > > --
> >
> > > Dr Greg Turner
> > > Director, the Interaction Consortiumhttp://interaction.net.au
> > > Phone: +61 2 8060 1067
> > > skype: gregturner
> > > Follow us on twitter:
> >
> > >http://twitter.com/theixchttp://twitter.com/gsta
> 
-- 
Matías Aguirre 

-- 
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: Need HELP urgently

2011-01-13 Thread Matias Aguirre
Don't see the need to use an ajax solution when a simple raw field makes the
work properly. Don't get me wrong, it's good to have several options, just that
I don't see the need.

Regards,
Matías

Excerpts from felix's message of Thu Jan 13 22:14:43 -0200 2011:
> django ajax select will work (jQuery): 
>   http://code.google.com/p/django-ajax-selects/
> 
-- 
Matías Aguirre 

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



Re: Help optimising database calls

2011-01-12 Thread Matias Aguirre
Try to reduce the queries on your view, select_related won't help a lot if
using Thread model, try to collect Pun values on your view first and group them
by thread, itertools.groupby could be handy in this case. Try something like:

threads = Thread.objects.select_related('user').filter(...)
thread_ids = [th.id for th in threads]
Pun.objects.select_related('thread', 'author').filter(thread__in=thread_ids)

Then group Pun by thread and use that on your template.

Makes sense?

Regards,
Matías

Excerpts from Matt Henderson's message of Wed Jan 12 13:32:37 -0200 2011:
> Hello,
> I'm new to django, and set up a website recently, (puncut.com). I was hoping 
> someone might be able to explain how to optimise database calls because at 
> the moment some pages are taking 5 seconds before django responds.
> I'll summarise the scenario below:
> 
> # models
> class Thread(models.Model) :
>   ... bunch of fields including title, description, author (linked to User)
>   
> class Pun(models.Model) :
>   thread=   models.ForeignKey(Thread)
>   author=   models.ForeignKey(User)
>   ... other fields like content etc.
> 
> class Like(models.Model) :
>   liker =   models.ForeignKey(User)
>   pun   =   models.ForeignKey(Pun)
> 
> So there are puns in threads, and users can like puns. 
> The view which lists latest threads is particularly slow. It sends threads 
> to the template, and the template loops through threads and inside it loops 
> through the puns which are in that thread. in pseudo code:
> for thread in threads 
> for pun in thread.pun_set
> output pun.content
> But I reckon that makes way to many calls to the database. I think I ought 
> to use select_related , but I tried it and it didn't speed it up.
> Thanks for any help,
> Matt
-- 
Matías Aguirre 

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

2011-01-12 Thread Matias Aguirre
The given answers are correct, that's your issue without doubt, create an admin
class for your Priority model and setup a raw_id_field[1]:

class PriorityOptions(admin.ModelAdmin):
raw_id_fields = ('entry',)
register(Priority, PriorityOptions)

Regards,
Matías

[1]: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields

Excerpts from gupta-django's message of Wed Jan 12 03:27:17 -0200 2011:
> I have two application
> 
> 1. App1 - It has a Model Class "Entry" that has 20 entries
> 2. App2 - It has a Model Class "Priority"
> 
> In Priority class I am defining a Foreign Key Relationship as
> 
> from App1.models import Entry
> 
> class Priority(models.Model):
> entry = models.ForeignKey(Entry)
> priority = models.CharField(max_length=2)
> 
> And in App2/admin.py I am simply registering Priority
> 
> admin.site.register(Priority)
> 
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
> 
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
> 
> Thanks
> 
-- 
Matías Aguirre 

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

2011-01-11 Thread Matias Aguirre
So, basically you want this:

C.objects.filter(Bref__Dref__id=D_id).values_list('Aref')

Matías

Excerpts from gia...@gmail.com's message of Tue Jan 11 07:58:05 -0200 2011:
> Let's say I have a model like:
> 
> class A:
> 
> class B:
>  Dref = ForeignKey('D')
> 
> class C:
>   Aref = ForeignKey('A')
>   Bref =  ForeignKey('B')
> 
> class D:
> 
> 
> I also have a view taking a D_id parameter and in this view I would
> like to create and show the list of A objects that are related to D
> through the B and C class.
> 
> Assuming this decription makes any sense ( I'm struggling myself to
> read it :) ), is there any way to accomplish what I need?
> 
> Cheers
> 
> G.
> 
-- 
Matías Aguirre 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: GoFlow - anybody out there used it?

2010-09-06 Thread Matias

El 06/09/10 14:23, Steve Boyle escribió:

Hi,

I've been writing an application that requires a workflow component
and rather than build one from scratch looked around to see what was
already out there.

One app that was mentioned a number of times was "GoFlow" which
apparently is based on "OpenFlow" a Zope product.

It feels as though the project has died judging by the activity /
commits etc, and unfortunately my impression is that there is a *lot*
of tidy up required on the code&  docs.

Has anybody else actually used this project, and if so what are your
thoughts?

It might save me investing a load of time in something that could have
been better spent writing something from scratch.

Many thanks


Steve



Did you give a look to ProcessMaker? At the time I had to implement a 
workflow solution, processmaker and its API did the job for us.



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



[Offtopic] Freelance django dev in Spain

2010-08-11 Thread Matias

Hi,

We are looking for a freelance django dev located here in Spain, 
preferrably in Madrid.


Please, contact me at matiassu...@gmail.com if you want to know more 
about this opportunity.


Sorry for the offtopic.



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



filter users by full name

2010-07-22 Thread Matias

Hi,

What is the recommended way to get all the users whose full_name matches 
a given string?


I need to do something like:

User.objects.filter(get_full_name="John Test")

But that doesn't seem to work.

Is list comprehensions the only way to go?

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



[Offtopic] Design introduction

2010-07-08 Thread Matias

Sorry for this completely offtopic question.

I'm a systems administrator with programming experience (mostly python 
and C) and I love web applications design/programming and I'm pretty 
good with html, javascript, css, etc... but I have a really weak point 
when it comes to "images" desing. I mean, I'd love to learn how to do 
images like this:

http://www.freecsstemplates.org/previews/solutions/images/img01.gif

(from the template http://www.freecsstemplates.org/preview/solutions/)

I understand the basics, and I use quite frequently Gimp, but this is 
not like coding, when you code, most of the times it is easy to 
understand what is happenning (except if the code you are reading is 
perl :-P ) and thus, you can learn but I still can't "read" images I 
see out there, so, I guess there should be any learning path for this 
also or maybe is that just the creative half of my brain is missing.


Would you recommend any book? any website? or some other way to learn to 
do "nice 3d looking menus, buttons"..etc?


Thanks for your help, and sorry for the offtopic, but I didn't find a 
better place to ask this. (didn't look for a lot also...)



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



register model on different App

2010-03-15 Thread Matias
Is there any way to register a model on a different app so that on the 
admin site I get it on a different "box"?


I've created a custom model, that I'd like to be shown on the "Auth" box 
instead of the default one (a box with my app's name).


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



ContentType and __unicode__ description

2010-01-13 Thread Matias

Hi,

I have a model like:

Class MyModel(models.Model):
content = content.ForeignKey(ContentType)

And in the admin interface I have a dropdown box showing all the content 
types I have. Works perfect.


The problem is that on that dropdown box, I have for each item there the 
"name" attribute of the content type. Is there any way to override this 
behaviour in order to get something like "name (app_name/model)" as the 
description so that the user can know to which application the model 
belongs to?




Thanks a lot.

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

2010-01-10 Thread Matias

El 10/01/10 04:18, Ishwor Gurung escribió:

2010/1/10 Matias:
[...]

Thanks, this will do the trick...


Curious. Why doesn't overriding save(..) do for you?



Because I would have to override the save() method on all Model classes

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

2010-01-09 Thread Matias

El 09/01/10 17:12, Andy McKay escribió:

On 10-01-08 7:02 AM, Matias wrote:

Is there any recommended way to attach a post_save signal to ALL models?


When you create a signal you can optionally assign a model to listen
too. Not doing that means it is called for all models.

http://docs.djangoproject.com/en/dev/topics/signals/#connecting-to-signals-sent-by-specific-senders




Thanks, this will do the trick...


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




Register signal on all objects

2010-01-08 Thread Matias

Is there any recommended way to attach a post_save signal to ALL models?

The best way I'm thinking of is maybe by using the ContentType class to 
get a list of all models and iterate over them registering the signal, 
but I'm not sure if this is the best way to do it...


Any comment 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-us...@googlegroups.com.
To unsubscribe from this group, 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: apache2+mod_wsgi: 403 Forbidden

2009-09-08 Thread Matias
sorry, I messed up!

I'm not sure now, i couldn't test it, but maybe you should set the Directory
directive in the specific path where wsgi files are


   Order Allow,Deny
   Deny from all


   Order Allow,Deny
   Allow from all


Regards,
Matias.

On Tue, Sep 8, 2009 at 11:04 AM, Matias  wrote:

> You should use Directory with the real path, not the alias
>
> 
>Order Allow,Deny
>Deny from all
> 
> 
>Order Allow,Deny
>Allow from all
> 
>
> like in the example :)
>
> Regards,
> Matias.
>
> On Mon, Sep 7, 2009 at 5:56 PM, Léon Dignòn  wrote:
>
>>
>> No, I have it here, but forgot to post it:
>>
>> 
>>Order Allow,Deny
>>Deny from all
>> 
>> 
>>Order Allow,Deny
>>Allow from all
>> 
>>
>> On Sep 7, 10:11 pm, Matias  wrote:
>> > I think you missed the allow directive in your apache conf.
>> >
>> > Example from [1]
>> >
>> > Alias /media/ /usr/local/django/mysite/media/
>> >
>> > 
>> > Order deny,allow
>> > Allow from all
>> > 
>> >
>> > WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
>> >
>> > 
>> > Order deny,allow
>> > Allow from all
>> > 
>> >
>> > [1]http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>> >
>> > HTH,
>> > Matias.
>> >
>> >
>> >
>> >
>> >
>> > On Mon, Sep 7, 2009 at 2:55 PM, Léon Dignòn 
>> wrote:
>> >
>> > > I get a 403 forbidden.
>> >
>> > > I serve Django with apache2+mod_wsgi. I disabled some plugins I think
>> > > I don't need. Set the listen port to 8000 on localhost only. Later I
>> > > will serve django through reverse proxy on cherokee webserver. But for
>> > > now, localhost:8000 is returning a 403 forbidden error.
>> >
>> > > Any ideas?
>> >
>> > > # error.log
>> > >[Mon Sep 07 17:14:59 2009] [error] [client 127.0.0.1] client
>> > > denied by server configuration: /htdocs
>> >
>> > > lwp-request -m GET -Sedhttp://127.0.0.1:8000/
>> > > lwp-request <http://127.0.0.1:8000/%0Alwp-request> -m GET -Sed
>> > >http://beispiel.de:8000/
>> > >GEThttp://127.0.0.1:8000/--> 403 Forbidden
>> > >Connection: close
>> > >Date: Mon, 07 Sep 2009 14:56:32 GMT
>> > >Server: Apache
>> > >Content-Length: 202
>> > >Content-Type: text/html; charset=iso-8859-1
>> > >Client-Date: Mon, 07 Sep 2009 14:56:32 GMT
>> > >Client-Peer: 127.0.0.1:8000
>> > >Client-Response-Num: 1
>> > >Title: 403 Forbidden
>> >
>> > > # /etc/apache2/ports.conf
>> > >NameVirtualHost 127.0.0.1:8000
>> > >Listen 127.0.0.1:8000
>> >
>> > > # /etc/apache2/sites-enabled/000-default
>> > >
>> > >ServerName localhost
>> > >ServerAdmin webmas...@localhost
>> > >
>> >
>> > > # /etc/apache2/sites-enabled/beispiel.de
>> > >
>> > >ServerNamewww.beispiel.de
>> > >ServerAlias beispiel.de
>> > >ServerAdmin daniel.nicc...@gmail.com
>> >
>> > >DocumentRoot /var/www/django/beispiel
>> >
>> > >Alias /robots.txt  /var/www/django/beispiel/media/
>> > > robots.txt
>> > >Alias /favicon.ico /var/www/django/beispiel/media/
>> > > favicon.ico
>> > >Alias /media/  /var/www/django/beispiel/media/
>> >
>> > >ErrorLog  "|/usr/sbin/rotatelogs /var/log/apache2/
>> > > beispiel.de/error_log.%Y-%m-%d 86400"
>> > >CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/
>> > > beispiel.de/access_log.%Y-%m-%d 86400" common
>> >
>> > >WSGIScriptAlias / /var/www/django/wsgi-scripts/
>> > > beispiel.wsgi
>> > >
>> >
>> > > # mods-enabled
>> > >alias.conf
>> > >alias.load
>> > >auth_digest.load
>> > >authn_file.load
>> > >authz_default.load
>> > >authz_groupfile.load
>> > >authz_host.load
>> > >authz_user.load
>> > >status.conf
>> > >status.load
>> > >wsgi.conf
>> > >wsgi.load
>> >
>> > --
>> > :wq- Hide quoted text -
>> >
>> > - Show quoted text -
>> >>
>>
>
>
> --
> :wq
>



-- 
:wq

--~--~-~--~~~---~--~~
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: apache2+mod_wsgi: 403 Forbidden

2009-09-08 Thread Matias
You should use Directory with the real path, not the alias


   Order Allow,Deny
   Deny from all


   Order Allow,Deny
   Allow from all


like in the example :)

Regards,
Matias.
On Mon, Sep 7, 2009 at 5:56 PM, Léon Dignòn  wrote:

>
> No, I have it here, but forgot to post it:
>
> 
>Order Allow,Deny
>Deny from all
> 
> 
>Order Allow,Deny
>Allow from all
> 
>
> On Sep 7, 10:11 pm, Matias  wrote:
> > I think you missed the allow directive in your apache conf.
> >
> > Example from [1]
> >
> > Alias /media/ /usr/local/django/mysite/media/
> >
> > 
> > Order deny,allow
> > Allow from all
> > 
> >
> > WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
> >
> > 
> > Order deny,allow
> > Allow from all
> > 
> >
> > [1]http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
> >
> > HTH,
> > Matias.
> >
> >
> >
> >
> >
> > On Mon, Sep 7, 2009 at 2:55 PM, Léon Dignòn 
> wrote:
> >
> > > I get a 403 forbidden.
> >
> > > I serve Django with apache2+mod_wsgi. I disabled some plugins I think
> > > I don't need. Set the listen port to 8000 on localhost only. Later I
> > > will serve django through reverse proxy on cherokee webserver. But for
> > > now, localhost:8000 is returning a 403 forbidden error.
> >
> > > Any ideas?
> >
> > > # error.log
> > >[Mon Sep 07 17:14:59 2009] [error] [client 127.0.0.1] client
> > > denied by server configuration: /htdocs
> >
> > > lwp-request -m GET -Sedhttp://127.0.0.1:8000/
> > > lwp-request <http://127.0.0.1:8000/%0Alwp-request> -m GET -Sed
> > >http://beispiel.de:8000/
> > >GEThttp://127.0.0.1:8000/--> 403 Forbidden
> > >Connection: close
> > >Date: Mon, 07 Sep 2009 14:56:32 GMT
> > >Server: Apache
> > >Content-Length: 202
> > >Content-Type: text/html; charset=iso-8859-1
> > >Client-Date: Mon, 07 Sep 2009 14:56:32 GMT
> > >Client-Peer: 127.0.0.1:8000
> > >Client-Response-Num: 1
> > >Title: 403 Forbidden
> >
> > > # /etc/apache2/ports.conf
> > >NameVirtualHost 127.0.0.1:8000
> > >Listen 127.0.0.1:8000
> >
> > > # /etc/apache2/sites-enabled/000-default
> > >
> > >ServerName localhost
> > >ServerAdmin webmas...@localhost
> > >
> >
> > > # /etc/apache2/sites-enabled/beispiel.de
> > >
> > >ServerNamewww.beispiel.de
> > >ServerAlias beispiel.de
> > >ServerAdmin daniel.nicc...@gmail.com
> >
> > >DocumentRoot /var/www/django/beispiel
> >
> > >Alias /robots.txt  /var/www/django/beispiel/media/
> > > robots.txt
> > >Alias /favicon.ico /var/www/django/beispiel/media/
> > > favicon.ico
> > >Alias /media/  /var/www/django/beispiel/media/
> >
> > >ErrorLog  "|/usr/sbin/rotatelogs /var/log/apache2/
> > > beispiel.de/error_log.%Y-%m-%d 86400"
> > >CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/
> > > beispiel.de/access_log.%Y-%m-%d 86400" common
> >
> > >WSGIScriptAlias / /var/www/django/wsgi-scripts/
> > > beispiel.wsgi
> > >
> >
> > > # mods-enabled
> > >alias.conf
> > >alias.load
> > >auth_digest.load
> > >authn_file.load
> > >authz_default.load
> > >authz_groupfile.load
> > >authz_host.load
> > >authz_user.load
> > >status.conf
> > >status.load
> > >wsgi.conf
> > >wsgi.load
> >
> > --
> > :wq- Hide quoted text -
> >
> > - Show quoted text -
> >
>


-- 
:wq

--~--~-~--~~~---~--~~
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: apache2+mod_wsgi: 403 Forbidden

2009-09-07 Thread Matias
I think you missed the allow directive in your apache conf.

Example from [1]

Alias /media/ /usr/local/django/mysite/media/


Order deny,allow
Allow from all


WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi


Order deny,allow
Allow from all


[1] http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango


HTH,
Matias.

On Mon, Sep 7, 2009 at 2:55 PM, Léon Dignòn  wrote:

>
> I get a 403 forbidden.
>
> I serve Django with apache2+mod_wsgi. I disabled some plugins I think
> I don't need. Set the listen port to 8000 on localhost only. Later I
> will serve django through reverse proxy on cherokee webserver. But for
> now, localhost:8000 is returning a 403 forbidden error.
>
> Any ideas?
>
>
>
>
> # error.log
>[Mon Sep 07 17:14:59 2009] [error] [client 127.0.0.1] client
> denied by server configuration: /htdocs
>
>
> lwp-request -m GET -Sed http://127.0.0.1:8000/
> lwp-request <http://127.0.0.1:8000/%0Alwp-request> -m GET -Sed
> http://beispiel.de:8000/
>GET http://127.0.0.1:8000/ --> 403 Forbidden
>Connection: close
>Date: Mon, 07 Sep 2009 14:56:32 GMT
>Server: Apache
>Content-Length: 202
>Content-Type: text/html; charset=iso-8859-1
>Client-Date: Mon, 07 Sep 2009 14:56:32 GMT
>Client-Peer: 127.0.0.1:8000
>Client-Response-Num: 1
>Title: 403 Forbidden
>
>
> # /etc/apache2/ports.conf
>NameVirtualHost 127.0.0.1:8000
>Listen 127.0.0.1:8000
>
>
> # /etc/apache2/sites-enabled/000-default
>
>ServerName localhost
>ServerAdmin webmas...@localhost
>
>
>
>
> # /etc/apache2/sites-enabled/beispiel.de
>
>ServerName www.beispiel.de
>ServerAlias beispiel.de
>ServerAdmin daniel.nicc...@gmail.com
>
>DocumentRoot /var/www/django/beispiel
>
>Alias /robots.txt  /var/www/django/beispiel/media/
> robots.txt
>Alias /favicon.ico /var/www/django/beispiel/media/
> favicon.ico
>Alias /media/  /var/www/django/beispiel/media/
>
>ErrorLog  "|/usr/sbin/rotatelogs /var/log/apache2/
> beispiel.de/error_log.%Y-%m-%d 86400"
>CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/
> beispiel.de/access_log.%Y-%m-%d 86400" common
>
>WSGIScriptAlias / /var/www/django/wsgi-scripts/
> beispiel.wsgi
>
>
>
> # mods-enabled
>alias.conf
>alias.load
>auth_digest.load
>authn_file.load
>authz_default.load
>authz_groupfile.load
>authz_host.load
>authz_user.load
>status.conf
>status.load
>wsgi.conf
>wsgi.load
> >
>


-- 
:wq

--~--~-~--~~~---~--~~
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: Outputing an integer value in a template, but with some calculation done on it

2009-09-04 Thread Matias
If you're using Pagination
http://docs.djangoproject.com/en/dev/topics/pagination/ you can get the
previous and next pages like this:
{{ current_page.previous_page_number }}

If not, check it out. It's a simple way to manage pagination issues.

HTH,
Matias.

On Thu, Sep 3, 2009 at 8:25 PM, Tim Chase wrote:

>
> > I am trying to output a variable page_no to a template, but I want to
> output
> > page_no + 1 and page_no - 1. How do I do that? I tried to do something
> like
> > {{ page_no + 1 }} and that failed. Tried {% and %} as well, but no
> success.
> >
> > Surely there is a way to do this other than having to calculate these
> values
> > in the view ahead of time?
>
> You bet -- you want the "add" filter:
>
>   {{ page_no|add:"1" }}
>
> detailed at
>
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/#add
>
> -tim
>
>
>
>
>
> >
>


-- 
:wq

--~--~-~--~~~---~--~~
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: pyfacebook, No module named facebook.djangofb...

2009-08-26 Thread Matias
Where did you get the files?
if you go to the pyfacebook at google
http://code.google.com/p/pyfacebook/the project is now hosted in
github.
So if you downloaded from google it may be outdated.
The installation is much more simpler than what the tutorial says, so i
recommend to download from http://github.com/sciyoshi/pyfacebook/tree/master

HTH,

Matias.


On Wed, Aug 26, 2009 at 9:58 PM, garagefan  wrote:

>
> steps followed here:
>
> http://wiki.developers.facebook.com/index.php/PythonPyFacebookTutorial
>
> page with error is here:
>
> http://kennethdavid.net/fbapp/fbsample/
>
> obviously, python.conf is setup correctly to call the correct settings
> file. facebook is a link (ln -s) to /pyfacebook/facebook, as per
> instructions. facebook IS in the site-packages directory, same as
> django
>
> settings as per instructions:
>
> MIDDLEWARE_CLASSES = (
>'django.middleware.common.CommonMiddleware',
>'django.contrib.sessions.middleware.SessionMiddleware',
>'django.contrib.auth.middleware.AuthenticationMiddleware',
>'facebook.djangofb.FacebookMiddleware',
> )
>
>
> svn for pyfacebook is http://pyfacebook.googlecode.com/svn/trunk/ if
> anyone wants to check out the files that come in the folders...r
> you can check them out here
> http://github.com/sciyoshi/pyfacebook/tree/master
>
> running python setup.py install in pyfacebook ends up being an error
> looking for config/Makefile saying that it does not exist, infact... i
> do not have a config dir in python2.5
>
> any help would be appreciated
> >
>


-- 
:wq

--~--~-~--~~~---~--~~
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: html Escape

2009-08-25 Thread Matias
Hi,
I think there is no such filter, so you'll have to code it.
This
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escapingmay
help

HTH,
Matias.

On Tue, Aug 25, 2009 at 5:54 AM, When ideas fail
wrote:

>
> Thanks, can i strip out all tags other than  tags.
>
> I would like people to be able to put links in comments.
>
> Andrew
>
> On 25 Aug, 03:42, Parag Shah  wrote:
> > Hi,
> >
> > You can use the strip_tags function to strip all html from text.
> >
> > from django.utils.html import strip_tags
> >
> > In your view
> > comment = strip_tags(request.POST["comment"])
> >
> > --
> > Regards
> > Parag
> >
> > On Tue, Aug 25, 2009 at 4:25 AM, When ideas fail
> > wrote:
> >
> >
> >
> > > Hello, i want to allow users to post comments and I don't want them to
> > > be allowed to put html in comments.
> >
> > > However I would like the to be able to use paragraph p tags and 
> > > tags but not anything other. Could someone tell me how to do this?
> >
> > > Thanks
> >
> > > Andrew
> >
> > --
> > Thanks & Regards
> > Parag Shahhttp://blog.adaptivesoftware.biz
> >
>


-- 
:wq

--~--~-~--~~~---~--~~
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 tell if a fields was modified

2009-07-24 Thread Matias

Hi,

How can I tell which model fields have been modified (this is, the 
difference between the Model instance and the data originally retrieved 
from the database) from inside the model's save() method?


Any idea?

Thanks a lot!


--~--~-~--~~~---~--~~
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: Restricting fields to certain users in admin

2009-05-19 Thread Matias Surdi

Matias Surdi escribió:
> I need to hide a couple fields from a model depending on the logged in 
> user in the admin interface.
> 
> How would you do this?
> 
> 
> > 
> 


Replying to myself, here is the solution:



class LimitedCustomUserAdmin(UserAdmin):
 inlines = [ProfileAdmin]
 form = forms.CustomUserChangeForm
 fieldsets = (
 (None, {'fields': ('username', 'password')}),
 ('Personal info', {'fields': ('first_name', 'last_name', 
'email')}),
 ('Permissions', {'fields': ('is_staff', 'is_active', 
'is_superuser')}),
 ('Important dates', {'fields': ('last_login', 'date_joined')}),
 ('Groups', {'fields': ('groups',)}),
 )



class CustomUserAdmin(LimitedCustomUserAdmin):
 fieldsets = (
 (None, {'fields': ('username', 'password')}),
 ('Personal info', {'fields': ('first_name', 'last_name', 
'email')}),
 ('Permissions', {'fields': ('is_staff', 'is_active', 
'is_superuser', 'user_permissions')}),
 ('Important dates', {'fields': ('last_login', 'date_joined')}),
 ('Groups', {'fields': ('groups',)}),
 )
 def __init__(self,*args,**kwargs):
 CustomUserAdmin.limited_user_admin = 
LimitedCustomUserAdmin(*args,**kwargs)
 return super(CustomUserAdmin,self).__init__(*args,**kwargs)

 def __call__(self, *args, **kwargs):
 if get_current_user().is_superuser:
 return super(CustomUserAdmin, self).__call__(*args, **kwargs)
 else:
 return CustomUserAdmin.limited_user_admin(*args,**kwargs)



This way, super_users can view/edit the fields defined in 
CustomUserAdmin and non super_users can view/edit the fields on 
LimitedCustomUserAdmin.


Note: You've to register only CustomUserAdmin with the User model.







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



Restricting fields to certain users in admin

2009-05-19 Thread Matias Surdi

I need to hide a couple fields from a model depending on the logged in 
user in the admin interface.

How would you do this?


--~--~-~--~~~---~--~~
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: Javascript Framework``

2009-05-13 Thread Matias Surdi

Ramdas S escribió:
> everything goes well with django.
> 
> 
> 
> On Wed, May 13, 2009 at 11:10 PM, Guri  <mailto:sgurmin...@gmail.com>> wrote:
> 
> 
> Hi,
>   I need some help regarding which javascript framework will go
> well with Django and is better in terms of documentation, easy to use
> and preferred.
> Couple of them I know:
> 1. Dojo with dijit themes
> 2. Scriptaculous
> 3... any other...
> 
> Thanks in Advance
> ~Guri
> 
> 
> 
> 
> 
> -- 
> Ramdas S
> +91 9342 583 065
> 
> 
> > 

Django is compatible with all javascript frameworks. Personally, I 
prefer JQuery.

Matias.


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



Auto populate ModelAdmin

2009-05-12 Thread Matias Surdi

I've noticed that on the admin interface, if a model has for example a 
"name" attribute, if I access to the add form with an url like this:

http://localhost:8000/admin/mymodel/add?name=something

The name field is prepopulated with the parameter value.

Is this behaviour documented somewhere?

Is it possible to prepopulate this way inlines for the model?


Thanks a lot.


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

2009-04-28 Thread Matias Surdi

tdelam escribió:
> Hi Guys,
> 
> This might get lengthy but I am trying to get some insight on the best
> way to generate some dynamic forms in a template. The project is a
> survey. Here is my questions model:
> 
> class Question(models.Model):
>   TRUEFALSE = 1 # a radio button yes/no question
>   MULTIPLEANSWER = 2 # checkbox question
>   SINGLEANSWER = 3 # radio button answer
>   COMMENT = 4 # textarea box for comments
> 
>   QUESTION_CHOICES = (
>   (TRUEFALSE, 'Yes/No question'),
>   (MULTIPLEANSWER, 'Multiple answer question'),
>   (SINGLEANSWER, 'Single answer'),
>   (COMMENT, 'Comment box')
>   )
> 
>   question_type = models.IntegerField(choices=QUESTION_CHOICES,
> default=TRUEFALSE)
>   survey = models.ForeignKey(Survey)
>   title = models.CharField(max_length=250)
> 
>   def __unicode__(self):
>   return self.title
> 
> Questions are built using the django admin and they can select the
> type of question it will be via the QUESTION_CHOICES. In my template I
> am testing for the type of question but I want to display the proper
> form fields for this question. So, a True/False will be radio widget,
> multiple answer will be checkbox and so on, I will need to do this
> dynamically of course so i can show the question with the widget type
> from the constants in my model. How can I do this?
> 
> Currently I have something somewhat working...  :
> 
> class TrueFalseForm(forms.Form):
>   def __init__(self, questions, *args, **kwargs):
>   super(TrueFalseForm, self).__init__(*args, **kwargs)
>   for i, question in enumerate(questions):
>   self.fields['answer'] = 
> forms.ChoiceField(widget=forms.RadioSelect
> (), choices=[['%d % i', question]], label=question)
> 
> 
> Any suggestions would be much appreciated.
> > 
> 


Have you already read this?

http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/




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



Assigning a file manually to a model FileField

2009-03-31 Thread Matias Surdi

I have the following model:

class Document(BaseModel):
 name = models.CharField(max_length=150,blank=True)
 type = models.ForeignKey(DocumentType)
 description = models.TextField(blank=True)
 file = 
models.FileField(upload_to="data/documentation/document/%Y/%m/%d",blank=True)


And suppose, I have the file "/tmp/test.txt" in my local filesystem.

How could I add this file to a new model usign the django shell?


I've tryed by instantiating a new Document, and then doing:

object.file = File(open("/tmp/test.xt"))
object.save()


But this gives me the following error:


Traceback (most recent call last):
   File "./migrate.py", line 175, in 
 object.save()
   File "/home/msurdi/proyecto/it/../it/apps/__init__.py", line 44, in save
 super(BaseModel,self).save(*args,**kwargs)
   File "/usr/lib/python2.5/site-packages/django/db/models/base.py", 
line 408, in save
 self.save_base(force_insert=force_insert, force_update=force_update)
   File "/usr/lib/python2.5/site-packages/django/db/models/base.py", 
line 474, in save_base
 values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) 
or f.pre_save(self, True))) for f in meta.local_fields]
   File 
"/usr/lib/python2.5/site-packages/django/db/models/fields/files.py", 
line 188, in pre_save
 file = super(FileField, self).pre_save(model_instance, add)
   File 
"/usr/lib/python2.5/site-packages/django/db/models/fields/__init__.py", 
line 179, in pre_save
 return getattr(model_instance, self.attname)
   File 
"/usr/lib/python2.5/site-packages/django/db/models/fields/files.py", 
line 139, in __get__
 (file.__class__, self.field.attr_class), {})
TypeError: Cannot create a consistent method resolution
order (MRO) for bases File, FieldFile



Thanks a lot.



--~--~-~--~~~---~--~~
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 way to pass parameters to templates

2009-03-25 Thread Matias Surdi

Which is the correct or recommended way to accomplish what is described 
in the following url with django?

http://www.djangosnippets.org/snippets/11/



My question is, if I have a template like this:

{% for i in args %}{{ i }}{% endfor %}
{{ title }}
{{ name }}
args
{{ args }}
kwargs
{{ kwargs }}


I'd like to "include" it from several places but with different values 
for the variables each time.


Thanks a lot.


--~--~-~--~~~---~--~~
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?[Newbie]

2009-03-05 Thread Matias Surdi

Hi Andrews,

Look at this:

http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/

This helped me a lot a couple months ago when I had to do some dynamic 
forms. Those forms where generated from data entered by the user in a 
previous step.


It can be a bit "messy" if you don't take care, but works.

andrew wrote:
> Hi , Dear all:
> 
> I had searched this forum but with limit information about dynamic
> forms .
> 
>Model:
> -
> class Product(models.Model):
>   name = models.CharField(max_length=30) # Product Name
> type = models.IntegerField(max_length=30)# Type ID
> 
>  I want to create a certain type product list form for visitor to
> choice one and submit.
> the Product table may continuously changed .
> 
> So how can I create a list in the form?
> 
> Any Suggestions and Reference links will be highly appreciated!
> > 
> 


--~--~-~--~~~---~--~~
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: Announcing Django Noob Group

2009-02-19 Thread Matias Surdi

I don't think it is really needed.

I think this list is perfectly OK for newbies and advanced users.There 
is not a clear line defining when you are a newbie and when you are an 
average user as well.

Now, we must search two archives instead of just a centralized one.



Bobby Roberts wrote:
> ... simpleton questions welcome, mentors encouraged to help...
> 
> http://groups.google.com/group/djangonoobs
> > 
> 


--~--~-~--~~~---~--~~
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: Problems with authentication login/logout

2009-01-28 Thread Matias Surdi

Matias Surdi escribió:
> I've followed the documentation on users authentication and it's working 
> fine except for one thing.
> 
> When a user logs out from the public views, it is also logged out from 
> the admin site and when the user logs in in the public view, if it has 
> staff permission it can access the admin site.So far, so good. *The 
> problem is that when the user logs in directly to the admin interface is 
> not being logged in into the public views*.
> 
> What could be happening here?
> 
> Thanks for any idea.
> 
> 
> > 
> 


Ignore this.
Sorry.


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



Problems with authentication login/logout

2009-01-28 Thread Matias Surdi

I've followed the documentation on users authentication and it's working 
fine except for one thing.

When a user logs out from the public views, it is also logged out from 
the admin site and when the user logs in in the public view, if it has 
staff permission it can access the admin site.So far, so good. *The 
problem is that when the user logs in directly to the admin interface is 
not being logged in into the public views*.

What could be happening here?

Thanks for any idea.


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



About django validation system

2009-01-28 Thread Matias Surdi

Shouldn't validation be defined in the modell instead of the forms?


Suppose I've a Model wich has some restrictions on the value a field can 
get, and then I've a custom form for this model for the admin interface 
and two other forms for the public interface.

Does this mean that I've to define my validation rules three times?

What is the logic behind  this?

Where is the correct place to code these custom validation rules in this 
scenario?

Should I post this message to django-devel?

What is the meaning of life? (well, you can ignore this last one :-) )

Thank you very much.


--~--~-~--~~~---~--~~
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: Basic question: hidden input not working

2009-01-26 Thread Matias Surdi

forget it, I've found the solution:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#exclude



Sorry...


Matias Surdi escribió:
> What is wrong with the following code?
> 
> class IPAddressAdminForm(forms.ModelForm):
>  notification_sent = 
> forms.BooleanField(widget=forms.widgets.HiddenInput,required=False)
>  class Meta:
>  model = IPAddress
> 
> 
> class IPAddress(BaseModel):
>  network = models.ForeignKey(Network)
>  ip = models.IPAddressField()
>  user = models.ForeignKey(User,blank=True,null=True)
>  registered = models.DateTimeField(blank=True,null=True)
>  renewed = models.DateTimeField(blank=True,null=True)
>  expires = models.DateTimeField(blank=True,null=True)
>  notification_sent = models.BooleanField(default=False)
> 
> 
> Despite the widget of notification_sent is set to HiddenInput, the label 
> for the boolean field is still rendered in the admin.
> 
> Many thanks for your help
> 
> 
> > 
> 


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



Basic question: hidden input not working

2009-01-26 Thread Matias Surdi

What is wrong with the following code?

class IPAddressAdminForm(forms.ModelForm):
 notification_sent = 
forms.BooleanField(widget=forms.widgets.HiddenInput,required=False)
 class Meta:
 model = IPAddress


class IPAddress(BaseModel):
 network = models.ForeignKey(Network)
 ip = models.IPAddressField()
 user = models.ForeignKey(User,blank=True,null=True)
 registered = models.DateTimeField(blank=True,null=True)
 renewed = models.DateTimeField(blank=True,null=True)
 expires = models.DateTimeField(blank=True,null=True)
 notification_sent = models.BooleanField(default=False)


Despite the widget of notification_sent is set to HiddenInput, the label 
for the boolean field is still rendered in the admin.

Many thanks for your help


--~--~-~--~~~---~--~~
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: Raw SQL parameters

2009-01-19 Thread Matias Surdi

Karen Tracey escribió:
> On Mon, Jan 19, 2009 at 2:06 PM, Matias Surdi  <mailto:matiassu...@gmail.com>> wrote:
> 
> Yes, maybe it's just a problem with sqlite, which is te backend I'm
> using.I'll try with mysql later.
> 
> Is this a bug? should it be reported as a ticket?
> 
> 
> I see you opened ticket #10070, which is fine because I don't know the 
> answer to whether it is a bug that some of the backends do not support 
> this style of parameter passing.  Django apparently doesn't use it 
> internally, nor document support for it 
> (http://docs.djangoproject.com/en/dev/topics/db/sql/ doesn't mention it) 
> so it may be permissible variation in the backends, I don't know.  
> Hopefully someone who knows more than I will respond in that ticket.
> 
> Karen
> 
> > 


Many thanks for your help.


--~--~-~--~~~---~--~~
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: Raw SQL parameters

2009-01-19 Thread Matias Surdi

Karen Tracey escribió:
> On Mon, Jan 19, 2009 at 12:40 PM, Ramiro Morales  <mailto:cra...@gmail.com>> wrote:
> 
> 
> On Mon, Jan 19, 2009 at 3:15 PM, Matias Surdi  <mailto:matiassu...@gmail.com>> wrote:
>  >
>  > The curious thing here, is that the above query works perfect
> running it
>  > directly through sqlite3.
>  >
> 
>  From what I have seen by reading DB backend source code, Django
> cursor's
> execute() method supports only the printf-like parmeter maker style
> with a list
> or tuple of actual parameters.
> 
> If you want to use the pyformat parameter marking style (as described
> in PEP 249),
> you' ll need to use the native DB-API driver API as you've already
> discovered.
> 
> 
> I didn't look at any code, I just tried a similar query on my own DB, 
> using current 1.0.X branch code:
> 
> k...@lbox:~/software/web/xword$ python manage.py shell
> Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
>  >>> from django.db import connection
>  >>> query = "SELECT * FROM Authors WHERE Author = %(name)s"
>  >>> parms = {'name': 'Manny Nosowsky'}
>  >>> cursor = connection.cursor()
>  >>> data = cursor.execute(query, parms)
>  >>> data
> 1L
>  >>> cursor.fetchall()
> ((4L, u'Manny Nosowsky', u'No', u''),)
>  >>>
>  >>>
> 
> That's using MySQL as the DB, so perhaps it is backend-specific?  The 
> only thing I needed to do to make the example shown originally work is 
> remove the quotes (and use table/column/parm names that exist in my DB).
> 
> Karen
> 
> > 


Yes, maybe it's just a problem with sqlite, which is te backend I'm 
using.I'll try with mysql later.

Is this a bug? should it be reported as a ticket?




--~--~-~--~~~---~--~~
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: Raw SQL parameters

2009-01-19 Thread Matias Surdi

Karen Tracey escribió:
> On Mon, Jan 19, 2009 at 11:49 AM, Matias Surdi  <mailto:matiassu...@gmail.com>> wrote:
> 
> 
> Hi,
> 
> 
> I'm trying to run a sql query with parameters taken from a dict, here is
> the relevant part of the code:
>query = "select * from table where name='%(name)s'"
> 
> 
> Remove the single quotes around '%(name)s'.  The backend will handle 
> quoting, I expect the extra quotes are causing confusion somewhere.
> 
> Karen
>  
> 
> 
>parameters = {'name':'valueofname'}
> cursor = connection.cursor()
> data = cursor.execute(query,parameters)
> 
> 
> The error I get is:
> 
> TypeError: format requires a mapping
> 
> 
> But, as far as I know (from PEP249) this should be possible.
> Basically, what I need, is to pass the parameters values in a dict, and
> not as a list or tuple as is shown in django docs.
> 
> Which is the correct way to accomplish this?
> 
> Thanks a lot.
> 
> 
> > 



Sorry, these quotes are a typo, the running code doesn't have them.

I've also tried with:

cursor.execute("select * from table where 
field=:value",{'value':'something'})

And I got the error:
"Type error: not all arguments converted during string formatting"


The curious thing here, is that the above query works perfect running it 
directly through sqlite3.



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



Raw SQL parameters

2009-01-19 Thread Matias Surdi

Hi,


I'm trying to run a sql query with parameters taken from a dict, here is 
the relevant part of the code:
query = "select * from table where name='%(name)s'"
parameters = {'name':'valueofname'}
 cursor = connection.cursor()
 data = cursor.execute(query,parameters)


The error I get is:

TypeError: format requires a mapping


But, as far as I know (from PEP249) this should be possible.
Basically, what I need, is to pass the parameters values in a dict, and 
not as a list or tuple as is shown in django docs.

Which is the correct way to accomplish this?

Thanks a lot.


--~--~-~--~~~---~--~~
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: ModelMultipleChoiceField in admin interface

2009-01-13 Thread Matias Surdi

Daniel Roseman escribió:
> On Jan 12, 5:38 pm, Matias Surdi  wrote:
>> Hi,
>>
>> I've two models related by a ForeignKey field.
>>
>> I'd like to have the possibility of adding child objects (side "One" of
>> the relation) from the admin interface of the parent ("Many" side of the
>> relation).
>>
>> Example:
>>
>> class Child(models.Model):
>> name = models.CharField(max_length=10)
>>
>> class Parent(models.Model):
>>name = models.CharField(max_length=10)
>>childs = models.ForeignKey(Child)
>>
>> In this example, a dropdown is shown on the admin that let's me choose
>> just one child or create another if the one I need doesn't exist.
>>
>> The point is, how can I have a list that lets me choose more than one
>> child and create them as needed?
>>
>> This is not a Many to Many relation, because every child belongs just to
>> one parent, but the widget I need is like the one from that kind of
>> relation in the admin interface (ie: Groups selection in the User edit
>> admin view).
>>
>> Thanks you very much.
> 
> You have the relationship the wrong way round. The ForeignKey belongs
> on the child, since presumably a child can only have one parent but a
> parent can have multiple children.
> 
> Once you've sorted that out, you can then use inline forms on the
> Parent admin to add multiple children to a single parent. See:
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects
> 
> --
> DR.
> > 
> 

hmm... Not really... from your point of view, think about this:  I want 
to edit the children from the parent admin view, and *not* assign 
parents to children from children's admin view

Do you see? the relation is the same, but from the other side.

I think I'm going to need a custom field/widget for this.

Thanks for your help.

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



ModelMultipleChoiceField in admin interface

2009-01-12 Thread Matias Surdi

Hi,

I've two models related by a ForeignKey field.

I'd like to have the possibility of adding child objects (side "One" of 
the relation) from the admin interface of the parent ("Many" side of the 
relation).

Example:

class Child(models.Model):
name = models.CharField(max_length=10)

class Parent(models.Model):
   name = models.CharField(max_length=10)
   childs = models.ForeignKey(Child)


In this example, a dropdown is shown on the admin that let's me choose 
just one child or create another if the one I need doesn't exist.

The point is, how can I have a list that lets me choose more than one 
child and create them as needed?

This is not a Many to Many relation, because every child belongs just to 
one parent, but the widget I need is like the one from that kind of 
relation in the admin interface (ie: Groups selection in the User edit 
admin view).


Thanks you very much.




--~--~-~--~~~---~--~~
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: Iterate over model database fields

2009-01-08 Thread Matias Surdi

Great!!

I think that the _meta attribute will be enough. I think that if I 
define a method on the base model of all my models something like 
get_fields() it could then return a list of the fields by accessing 
self._meta.fields, and this get_fields should be accessible from 
templates,shouldn't it?.

Thanks for your help :-)


bruno desthuilliers wrote:
> On 8 jan, 16:22, Matias Surdi  wrote:
>> Is there any way to iterate over all the fields in a model instance on a
>> template?
> 
> Not directly. The fields names are accessible thru the
> model_instance._meta attribute, and you cannot access '_protected'
> attributes in a template.
> 
>> I'd like to have a "default" template which iterates over whatever model
>> yo give it and prints all its field on a table.
> 
> You'll have to write a (simple) view that returns the model instance's
> fields names and values as context. But that's mostly trivial once you
> know how to get field names and values from an instance (which has
> already been explained here - but feel free to ask if you fail to find
> the relevant posts).
> 
> 
> > 
> 


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



Iterate over model database fields

2009-01-08 Thread Matias Surdi

Is there any way to iterate over all the fields in a model instance on a 
template?

I'd like to have a "default" template which iterates over whatever model 
yo give it and prints all its field on a table.


Any help will be appreciated.


--~--~-~--~~~---~--~~
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: best way to do tabs?

2009-01-08 Thread Matias Surdi

 > implement.  Just google YUI.
Shoudn't it have been "yahoo for YUI" ?

:-D


phoebebright escribió:
> I'm a great fan of YUI and they have some nice tabs that are easy to
> implement.  Just google YUI.
> 
> 
> On Jan 8, 10:03 am, Matias Surdi  wrote:
>> JQuery UI?
>>
>> Margie escribió:
>>
>>> Hi,
>>> This is not a directly a django question, but since django is the only
>>> web framework I know (and it's really cool, by the way!) I hope it's
>>> ok to post this here.
>>> Could someone advise me on the "best" way to do tabs?  IE, I'd like to
>>> have a set of tabs at the top of my page with a sub navigation bar
>>> below.  I am currently using a mechanism that I got from the pinax
>>> project - I use css similar to that in tabs.css, for those of you that
>>> know pinax.  That css controls how the html classes are set up when
>>> html is rendered for a particular tab, causing the tabs to look
>>> "pressed" at the appropriate times.
>>> I'm a newbie at web page design, so I don't have a good feeling for if
>>> this is the right direction to be pursing.  I find the css code and
>>> the way it interacts with site_base.html and base.html fairly
>>> confusing and hard to maintain, so I'm wondering if there is a better
>>> way.  Also (and more importantly) would like my tabs to be more
>>> dynamic.  For example, based on the user clicking on something, I
>>> would like to be able to add additional tabs.  It seems like using the
>>> css mechanism in pinax makes that very difficult, because the css for
>>> each tab has to be defined up front in order to get the shading right
>>> when you click on a tab.
>>> Can anyone advise me on what the best direction to go in is for having
>>> nice tabs that are easy to undrestand?
>>> I have not yet learned jquery or ajax, but they are on my list,
>>> perhaps those provide better frameworks than css?  Anyway, any
>>> pointers from those of you more experienced than me are appreciated!
>>> 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: best way to do tabs?

2009-01-08 Thread Matias Surdi

JQuery UI?



Margie escribió:
> Hi,
> 
> This is not a directly a django question, but since django is the only
> web framework I know (and it's really cool, by the way!) I hope it's
> ok to post this here.
> 
> Could someone advise me on the "best" way to do tabs?  IE, I'd like to
> have a set of tabs at the top of my page with a sub navigation bar
> below.  I am currently using a mechanism that I got from the pinax
> project - I use css similar to that in tabs.css, for those of you that
> know pinax.  That css controls how the html classes are set up when
> html is rendered for a particular tab, causing the tabs to look
> "pressed" at the appropriate times.
> 
> I'm a newbie at web page design, so I don't have a good feeling for if
> this is the right direction to be pursing.  I find the css code and
> the way it interacts with site_base.html and base.html fairly
> confusing and hard to maintain, so I'm wondering if there is a better
> way.  Also (and more importantly) would like my tabs to be more
> dynamic.  For example, based on the user clicking on something, I
> would like to be able to add additional tabs.  It seems like using the
> css mechanism in pinax makes that very difficult, because the css for
> each tab has to be defined up front in order to get the shading right
> when you click on a tab.
> 
> Can anyone advise me on what the best direction to go in is for having
> nice tabs that are easy to undrestand?
> 
> I have not yet learned jquery or ajax, but they are on my list,
> perhaps those provide better frameworks than css?  Anyway, any
> pointers from those of you more experienced than me are appreciated!
> 
> 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
-~--~~~~--~~--~--~---



Run sql query as read only user

2009-01-05 Thread Matias Surdi

Hi,

For some reports, I need to allow the users to enter a sql query.It is 
required for this query (a sql SELECT) to be run as a read only database 
user.


Any idea how to implement this with django?


Thank you very much.


--~--~-~--~~~---~--~~
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: Are Dynamic fields possible?

2009-01-03 Thread Matias Surdi

I've done it, although it was not a trivial task.

This helped me a lot:

http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/



Xan wrote:
> Hi,
> 
> I just want to know if django support dynamic fields, that is the
> option of not specied the type of field in the model and that user
> could specify in application.
> 
> I think for examples about an application for doing notes. In one
> note, one want to have: title, body, media, etc. but the number of
> fields (and its type) is variable. What about something like:
> 
> class Note(models.Note):
> title = models.CharField(max_length=200)
> anything = models.ManyToManyField(DynamicField)
> 
> and when user create a class specifies title and adds want he/she
> wants (body, pictures, etc. with the type of the field).
> 
> Is it possible?
> Thanks a lot,
> Xan.
> 
> PS: Happy new year.
> > 
> 


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



custom field value representation

2009-01-03 Thread Matias Surdi

Hi,

Suppose I have the following model:

class Document(BaseModel):
 name = models.CharField(max_length=150,blank=True)
 description = models.TextField(blank=True)
 file = 
Models.FileField(upload_to="data/documentation/document/%Y/%m/%d",blank=True)


And suppose I've a model I created through the admin interface and 
uploaded a file named "document1.pdf"

Then, when modifying this database entry (in admin->change_form) I see 
the previous value as data/documentation/document/2009/01/03/document1.pdf"

Is there any way to get this value shown as just "document1.pdf" without 
the relative path?.. What i want, is to hide to the end user the 
filesystem location of the uploaded file.

I've accomplished this in the change_list by defining a custom method on 
the model that returns just the file name.

Thank you very much.


--~--~-~--~~~---~--~~
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: PDF creation!!!

2008-12-26 Thread Matias Surdi

I do the reports in HTML, using django templates and then instead of 
send the rendered result to the browser, I filter it throught htmldoc 
linux utility.

Works like a charm for me.


Abdel Bolanos Martinez wrote:
> Please can any one give me good references about tools for create PDF 
> reports, graphs in Django besides RepoLab
> 
> 
> thanks
> 
> 
> 
> 
> 
> Abdel Bolaños Martínez
> Ing. Infórmatico
> Telf. 266-8562
> 5to piso, oficina 526, Edificio Beijing, Miramar Trade Center. ETECSA
> 
> 
> > 

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



Re: Model with 2 foreignkey to User

2008-12-24 Thread Matias Surdi

Maybe this helps:

http://www.b-list.org/weblog/2008/dec/24/admin/



Tirta K. Untario wrote:
> This is a continuation from my last question.
> 
> created_by  = models.ForeignKey(User)
> 
> I want to automatically use current logged in user as value. Can I put the 
> code inside def save(self) for this model? I can't find anything about 
> getting current user value from model.
> 
> Thanks in advance.
> 
> --Tirta
> -Original Message-
> From: "Tirta K. Untario" 
> 
> Date: Wed, 24 Dec 2008 01:39:20 
> To: 
> Subject: Model with 2 foreignkey to User
> 
> 
> 
> Hi all,
> 
> I'm developing a simple todo list. I use Django Auth for handling 
> authentication. This is my models.py
> 
> from django.contrib.auth.models import User
> class Item(models.Model):
> project = models.ForeignKey(Project)
> category= models.ForeignKey(Category)
> title   = models.CharField(max_length=250, unique=True) 
> priority= models.IntegerField(choices=PRIORITY_CHOICES, default=2) 
> completed   = models.BooleanField(default=False) 
> created_at  = models.DateTimeField(default=datetime.datetime.now) 
> created_by  = models.ForeignKey(User)
> assigned_to = models.ForeignKey(User)
> 
> I have 2 fields from Item model that I want to relate with User model: 
> 'created_by' and 'assigned_to'. This is the error message when I try to 
> syncdb:
> 
> Error: One or more models did not validate:
> todo.item: Accessor for field 'created_by' clashes with related field 
> 'User.item_set'. Add a related_name argument to the definition for 
> 'created_by'.
> todo.item: Accessor for field 'assigned_to' clashes with related field 
> 'User.item_set'. Add a related_name argument to the definition for 
> 'assigned_to'.
> 
> If I use only 1 foreignkey, it works without error, i.e:  created_by  = 
> models.ForeignKey(User) without  assigned_to  = models.ForeignKey(User)
> 
> Can anyone help me to solve this problem? TIA.
> 
> --Tirta
> 
> 
> 
> 
> > 


--~--~-~--~~~---~--~~
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: saving unicode data in file

2008-12-24 Thread Matias Surdi

Finally I've solved it with smart_str function.



Matias Surdi wrote:
> Hi, I'm trying to save on a FileField some generated data (a text file 
> obtained from a template):
> 
> The relevant code is:
> 
>  out = Template(open("/path/to/template").read())
>  context = Context({})
>  if request.POST["name"] != "":
>  name = request.POST["name"]
>  else:
>  name = "GeneratedDocument_%i" % obj.id
>  data = out.render(context)
>  obj.file.save("file",ContentFile(data))
> 
> 
> the problem arises with ContentFile(data), if data is just a string like 
> "a simple string" the everything is correct, but the actual data content 
> is an unicode string, so raw binary data is saved to the resulting file 
> instead of the actual text.
> 
> Simplifying, what I want is to save the output of a rendered template to 
> a FileField.
> 
> Any help will be very appreciated.
> 
> 
> Thanks a lot.
> 
> 
> > 
> 


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



saving unicode data in file

2008-12-23 Thread Matias Surdi

Hi, I'm trying to save on a FileField some generated data (a text file 
obtained from a template):

The relevant code is:

 out = Template(open("/path/to/template").read())
 context = Context({})
 if request.POST["name"] != "":
 name = request.POST["name"]
 else:
 name = "GeneratedDocument_%i" % obj.id
 data = out.render(context)
 obj.file.save("file",ContentFile(data))


the problem arises with ContentFile(data), if data is just a string like 
"a simple string" the everything is correct, but the actual data content 
is an unicode string, so raw binary data is saved to the resulting file 
instead of the actual text.

Simplifying, what I want is to save the output of a rendered template to 
a FileField.

Any help will be very appreciated.


Thanks a lot.


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



Re: login_required redirects always to LOGIN_REDIRECT_URL?

2008-12-22 Thread Matias
Hello,

You can add a hidden input named "next" where you put the value of next in
the GET variable.
Like this






Or you can change the action variable of the form to include the current GET
variables. like this





If your view that handles GET and POST aren't the same you must add the
"next" var in the action field on your own.


The latter is the best IMHO.

Hope that helps!

Regards,
Matias.




On Mon, Dec 22, 2008 at 11:47 AM, Jarek Zgoda  wrote:

>
> I'm seeing strange behaviour of login_required decorator: any view
> decorated with it first sends to login page, then to url defined in
> LOGIN_REDIRECT_URL. The url to decorated view is supplied in next
> parameter (/login/?next=/path/to/view/) but is never executed.
>
> Looking at login view code I see that the redirect is taken from
> redirect_field_name field (which in my case is default "next") of
> REQUEST. This works as I expect if I do GET, but this value is not set
> if I issue POST request with credentials after displaying form.
>
> Do I have to write my own login machinery to achieve such
> functionality (redirect to decorated view after login)?
>
> Cheers
> J.
> >
>


-- 
:wq

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



Re: login problem

2008-12-16 Thread Matias
Hello,

You should show the login if the method != "POST".
By calling render_to_response(...) it will render your template, so that is
what the view must return.

I think you want something like this:

def my_view(request):
  if request.method == "POST" :
  username = request.POST['username']
 password = request.POST['password']
 user =  authenticate(username=username, password=password)

 if user is not None:
if user.is_active:
   login(request,user)
   return render_to_response('success.html',
{'username':username})
else:
   return HttpResponse('disabled account')
 else:
return HttpResponse('invalid login')
   else:
 *return render_to_response* ('login.html', {'username': username,
'password' : password})

Regards,
Matias.

On Tue, Dec 16, 2008 at 1:17 AM, vierda  wrote:

>
> Hi Matias,
>
> Thanks for your reply but I did'nt get your point. sorry I'm newbie
> and still learning.
> I modified my_view function in my views as your suggestion (if I
> didn't wrong get your point) as per below:
>
> def my_view(request):
>   if request.method == "POST" :
>   username = request.POST['username']
>  password = request.POST['password']
>  user =  authenticate(username=username, password=password)
>   render_to_response ('login.html', {'username': username,
> 'password' : password})
>
>  if user is not None:
> if user.is_active:
>login(request,user)
>return render_to_response('success.html',
> {'username':username})
> else:
>return HttpResponse('disabled account')
>  else:
> return HttpResponse('invalid login')
>else:
>  return HttpResponse ('home page')
>
> above code run and shows home page text, I assume that the method is
> not POST regarding the result.
> What sholud I do to fix this and show my login page. somebody please
> help me to understand this concept. Thank you
>
> regards,
> -Mila-
>
>
>
> On Dec 15, 9:06 am, Matias  wrote:
> > Hello,
> >
> > You should check by which method was called your view.
> > something like
> >
> > if request.method == "POST":
> > #now you can use request.POST
> > else:
> > #just show the template
> >
> > Hope that helps,
> >
> > Matias.
> >
> >
> >
> > On Mon, Dec 15, 2008 at 5:15 AM, vierda  wrote:
> >
> > > Dear Ronny/all,
> >
> > > Thank you for your reply. I have modified my code and the error still
> > > occur.
> > > my new code as following below:
> >
> > > def my_view(request):
> > >   username = request.POST['username']
> > >   password = request.POST['password']
> > >   user =  authenticate(username=username, password=password)#create
> > > Authentication object
> > >render_to_response ('login.html', {'username': username,
> > > 'password' : password})
> >
> > >   if user is not None:
> > >  if user.is_active:
> > > login(request,user)
> > >  return render_to_response('success.html',
> > > {'username':username})
> > >  else:
> > > return HttpResponse('disabled account')
> > >else:
> > >  return HttpResponse('invalid login')
> >
> > > and my login.html as per below:
> > > 
> >
> > > Enter Username: 
> > > Enter Password: 
> > > 
> > > 
> >
> > > my success.html as per below :
> > > 
> > >  welcome{{username}}
> > > 
> >
> > > somebody kindly help and thank you in advance
> >
> > > On Dec 6, 12:05 am, "Ronny Haryanto"  wrote:
> > > > On Sat, Dec 6, 2008 at 2:42 PM, vierda  wrote:
> > > > > today I try to make login page with follow example code in
> > > > > djangoproject (user authentication chapter), code as following
> below :
> >
> > > > > def my_view(request):
> > > > >   username = request.POST['username']
> > > > >   password = request.POST['password']
> > > > >   user =  authenticate(username=username, password=password)#create
> > > > > Authentication object
> >
> > > > >   if user is not Non

Re: login problem

2008-12-16 Thread Matias
Hello,

You should show the login if the method != "POST".
By calling render_to_response(...) it will render your template, so that is
what the view must return.

I think you want something like this:

def my_view(request):
  if request.method == "POST" :
  username = request.POST['username']
 password = request.POST['password']
 user =  authenticate(username=username, password=password)

 if user is not None:
if user.is_active:
   login(request,user)
   return render_to_response('success.html',
{'username':username})
else:
   return HttpResponse('disabled account')
 else:
return HttpResponse('invalid login')
   else:
 *return render_to_response* ('login.html', {'username': username,
'password' : password})

Regards,
Matias.

On Tue, Dec 16, 2008 at 1:17 AM, vierda  wrote:

>
> Hi Matias,
>
> Thanks for your reply but I did'nt get your point. sorry I'm newbie
> and still learning.
> I modified my_view function in my views as your suggestion (if I
> didn't wrong get your point) as per below:
>
> def my_view(request):
>   if request.method == "POST" :
>   username = request.POST['username']
>  password = request.POST['password']
>  user =  authenticate(username=username, password=password)
>   render_to_response ('login.html', {'username': username,
> 'password' : password})
>
>  if user is not None:
> if user.is_active:
>login(request,user)
>return render_to_response('success.html',
> {'username':username})
> else:
>return HttpResponse('disabled account')
>  else:
> return HttpResponse('invalid login')
>else:
>  return HttpResponse ('home page')
>
> above code run and shows home page text, I assume that the method is
> not POST regarding the result.
> What sholud I do to fix this and show my login page. somebody please
> help me to understand this concept. Thank you
>
> regards,
> -Mila-
>
>
>
> On Dec 15, 9:06 am, Matias  wrote:
> > Hello,
> >
> > You should check by which method was called your view.
> > something like
> >
> > if request.method == "POST":
> > #now you can use request.POST
> > else:
> > #just show the template
> >
> > Hope that helps,
> >
> > Matias.
> >
> >
> >
> > On Mon, Dec 15, 2008 at 5:15 AM, vierda  wrote:
> >
> > > Dear Ronny/all,
> >
> > > Thank you for your reply. I have modified my code and the error still
> > > occur.
> > > my new code as following below:
> >
> > > def my_view(request):
> > >   username = request.POST['username']
> > >   password = request.POST['password']
> > >   user =  authenticate(username=username, password=password)#create
> > > Authentication object
> > >render_to_response ('login.html', {'username': username,
> > > 'password' : password})
> >
> > >   if user is not None:
> > >  if user.is_active:
> > > login(request,user)
> > >  return render_to_response('success.html',
> > > {'username':username})
> > >  else:
> > > return HttpResponse('disabled account')
> > >else:
> > >  return HttpResponse('invalid login')
> >
> > > and my login.html as per below:
> > > 
> >
> > > Enter Username: 
> > > Enter Password: 
> > > 
> > > 
> >
> > > my success.html as per below :
> > > 
> > >  welcome{{username}}
> > > 
> >
> > > somebody kindly help and thank you in advance
> >
> > > On Dec 6, 12:05 am, "Ronny Haryanto"  wrote:
> > > > On Sat, Dec 6, 2008 at 2:42 PM, vierda  wrote:
> > > > > today I try to make login page with follow example code in
> > > > > djangoproject (user authentication chapter), code as following
> below :
> >
> > > > > def my_view(request):
> > > > >   username = request.POST['username']
> > > > >   password = request.POST['password']
> > > > >   user =  authenticate(username=username, password=password)#create
> > > > > Authentication object
> >
> > > > >   if user is not Non

Re: login problem

2008-12-15 Thread Matias
Hello,

You should check by which method was called your view.
something like

if request.method == "POST":
#now you can use request.POST
else:
#just show the template


Hope that helps,

Matias.

On Mon, Dec 15, 2008 at 5:15 AM, vierda  wrote:

>
> Dear Ronny/all,
>
> Thank you for your reply. I have modified my code and the error still
> occur.
> my new code as following below:
>
> def my_view(request):
>   username = request.POST['username']
>   password = request.POST['password']
>   user =  authenticate(username=username, password=password)#create
> Authentication object
>render_to_response ('login.html', {'username': username,
> 'password' : password})
>
>   if user is not None:
>  if user.is_active:
> login(request,user)
>  return render_to_response('success.html',
> {'username':username})
>  else:
> return HttpResponse('disabled account')
>else:
>  return HttpResponse('invalid login')
>
> and my login.html as per below:
> 
>
> Enter Username: 
> Enter Password: 
> 
> 
>
> my success.html as per below :
> 
>  welcome{{username}}
> 
>
> somebody kindly help and thank you in advance
>
>
> On Dec 6, 12:05 am, "Ronny Haryanto"  wrote:
> > On Sat, Dec 6, 2008 at 2:42 PM, vierda  wrote:
> > > today I try to make login page with follow example code in
> > > djangoproject (user authentication chapter), code as following below :
> >
> > > def my_view(request):
> > >   username = request.POST['username']
> > >   password = request.POST['password']
> > >   user =  authenticate(username=username, password=password)#create
> > > Authentication object
> >
> > >   if user is not None:
> > >  if user.is_active:
> > > login(request,user)
> > > return HttpResponse('login success')
> > >  else:
> > > return HttpResponse('disable account')
> > >   else:
> > >  return HttpResponse('invalid login')
> >
> > > the above code always shows MultiValueDictKeyError with exception
> > > value "Key 'username' not found in ".
> >
> > That exception will always be raised if the view is called via GET
> > method instead of POST.
> >
> > If you're sending it via POST, then the information you provided was
> > not sufficient. We need to see template code that renders the form (or
> > the html form if you're not using templates) and probably the form as
> > well.
> >
> > Ronny
> >
>


-- 
:wq

--~--~-~--~~~---~--~~
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: SOAPpy and pyxml installation/usage

2008-12-15 Thread Matias
Try checking the specific exception and its message.

Matias.

2008/12/15 Steve 

>
> OK. I'm having second thoughts on suds. It seems to work great some
> times, but not so great on others. I have the following code, where
> vid is the wsdl of the video.
> Many of them fail. I got these wsdl's from http://www.xmethods.net and
> presumably they're good.
>
> def check(vid):
>   try:
>  client = Client(vid)
>  print "succeeded: " + vid
>   except:
>  print "failed: " + vid
>
> for x in wsdl:
>   check(x)
>
> It fails quite a bit, just to load the wsdl file. Here's the results:
> succeeded: http://ws2.fraudlabs.com/mailboxvalidator.asmx?wsdl
> succeeded: http://www.imcomponents.com/imsoap/?wsdl
> succeeded:
> http://coeservice.en.kku.ac.th:8080/TemperatureConvertor/TemperatureConvertorService?WSDL
> failed: http://ws.strikeiron.com/RealTimeNASDAQStockQuotes?WSDL
> failed: http://ws.strikeiron.com/RealTimeStockQuotes3?WSDL
> failed: http://ws.strikeiron.com/DelayedStockQuotes15min?WSDL
> failed:
> http://www.siprod.net/webservices/xemail/xemailwebservice.asmx?WSDL
> failed: https://api.postalmethods.com/PostalWS.asmx?WSDL
> succeeded: http://ws.fraudlabs.com/browserobjectwebservice.asmx?wsdl
> succeeded: http://ws.fraudlabs.com/areacodeworldwebservice.asmx?wsdl
> succeeded: http://ws.cdyne.com/ProfanityWS/Profanity.asmx?wsdl
> succeeded: http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL
> succeeded: http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl
> succeeded: http://www.ecubicle.net/whois_service.asmx?WSDL
>
> If anyone has any thoughts, I'm all ears. I'm going to try to post
> this on the suds page, see if they can't fix it.
>
> -Steve
>
> On Dec 12, 12:24 am, Jarek Zgoda  wrote:
> > Wiadomość napisana w dniu 2008-12-11, o godz. 09:31, przez Steve:
> >
> > > This may be a more of a generic Python question, but I'm working with
> > > Django so thought that I'd see if there's a Django specific solution
> > > to it.
> >
> > > I'm trying to work with SOAP. I'm new to it and a Jr. programmer as
> > > well. From Dive into Python it has this great example about how to
> > > handle SOAP calls.
> > >http://www.diveintopython.org/soap_web_services/index.html
> >
> > Drop SOAPpy and ZSI, they are not documented and nearly dead. Try suds.
> >
> > --
> > We read Knuth so you don't have to. - Tim Peters
> >
> > Jarek Zgoda, R&D, Redefine
> > jarek.zg...@redefine.pl
> >
>


-- 
:wq

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



Re: Question about field/widget relationship

2008-12-12 Thread Matias
Hello,

The widget kw can be either a class or an instance. You can do
xField(widget=xWidget(choices=mychoices))
Or you can create your xField with your xWidget as default widget and let
the field to accept the choices kw.

Matias.


On Fri, Dec 12, 2008 at 8:44 AM, commander_coder <
commander_co...@hotmail.com> wrote:

>
> How does a field pass attributes to a widget?  I have approximately
> this
>
> class fooForm(forms.Form):
>   x_choice=myForms.xField(widget=myWidgets.xWidget)
>
> where myWidgets.xWidget is a subclass of RadioSelect so it has a
> required argument like "choices=[('a','1'), ('b','a')]" (this is
> generated dynamically so I can't build it in to xWidget).  Where in
> the Django code base does that information get passed?
>
> The examples I've studied don't seem to me to show xField being
> written to pass it explicitly but they do make a super() call, so I
> expect it is done there.   I see in the render code for the widget
> references to the variable self.choices, so it is getting remembered
> by the widget in that way.  However, I've struggled with the Django
> source and I can't make out how it is passed.  I'd be very grateful if
> someone could help me find it.
>
> Jim
> >
>


-- 
:wq

--~--~-~--~~~---~--~~
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: exclude on ModelForm doesn't work

2008-12-12 Thread Matias
Hi,

How do you register the model in the admin site?
You should register your model using a ModelAdmin subclass.

Here is some docs that may help you
http://docs.djangoproject.com/en/dev/ref/contrib/admin/

The ModelForms are ment to be used in your applications rather than the
admin site.

Hope that helps

Matias.

On Fri, Dec 12, 2008 at 10:22 AM, Dennis Schmidt  wrote:

>
> Hello,
>
> I have a problem with ModelForms in the django admin site. I want to
> exclude some fields so they won't be displayed when I edit the model
> in the admin site. This is my code:
>
>
> class CommonInvoiceForm(forms.ModelForm):
>price_factor = forms.ChoiceField(choices=COST_FACTOR_CHOICES)
>
>class Meta:
>from voipgo.accounting.invoices.models import CommonInvoice
>model = CommonInvoice
>exclude = ('template',)
>
>
> So as you can see I add a new field to the form - which works as
> expected. But the 'template' field I don't want to have in there is
> still displayed. 'template' is a normal ForeignKey field in the model
> declaration. What am I doing wrong here?
> >
>


-- 
:wq

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



Best way to modify admin css

2008-11-27 Thread Matias Surdi

Hi,

Which is the best/recommended way to modify admin css ?

I know I can copy the admin templates to my templates dir and modify 
them as I wish, but that could be a problem in the future if these 
templates are updated in a new version and I want to switch to that version.

Thanks in advance.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Two related select boxes, update the second depending on the first

2008-11-12 Thread Matias Surdi

This is exactly what I'm trying to do.

Thanks for your help.



Low Kian Seong escribió:
> Have a go with this:
> 
> 
> http://gtitsworth.blogspot.com/2007/07/chaining-selects-with-django-and-ajax.html
> 
> On Wed, Nov 12, 2008 at 3:54 AM, Matias Surdi <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I want to have on the admin interface a dropdown box and let the user
>> choose one of several options.Then, depending on this selection, update
>> (maybe through ajax) the values available on the second one.
>>
>>
>> Could anyone give me some guidelines or documentation about how is the
>> best way to do this?
>>
>>
>> Thanks a lot.
>>
>>
> 
> 
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Two related select boxes, update the second depending on the first

2008-11-11 Thread Matias Surdi

Hi,

I want to have on the admin interface a dropdown box and let the user 
choose one of several options.Then, depending on this selection, update 
(maybe through ajax) the values available on the second one.


Could anyone give me some guidelines or documentation about how is the 
best way to do this?


Thanks a lot.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: profiles not saving....just not seeing problem

2008-10-24 Thread Matias
Hello,

ModelMultipleChoiceField fields cleaned data are lists, so you are trying to
create an object with a list of ids as id. Also I think you want to retrive
the object, in that case you have to use the get function of the model
manager (e.g.  Object.objects.get(id=someid). )
If you need to get all the options of a multiple choice field, you must use
a ManyToMany relationship instead of a ForeingKey.

Regards,
Matias.


On Fri, Oct 24, 2008 at 4:23 PM, Lar <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I've been beating my head against this for a couple of days.  I am
> creating a User with additional information stored in a profile
> model.  I create the user, then create the profile object. I get the
> form information and if it is valid, I just want to save the
> information and do a bit more processing.
>
> Two questions:
> 1. Why is the profile information not saving?
> 2. If I want to access the activation_string for a specific user and
> change it's value, how do I do that?  I'm sure the way I'm trying to
> do it is incorrect.
>
> Any assistance would be appreciated.
>
> Thanks,
> Laura
>
> **I have this Model:
>
> class StudentProfile(models.Model):
>address = models.CharField(max_length=50)
>city = models.CharField(max_length=60)
>province = models.CharField(max_length=30)
>postalcode = models.CharField(max_length=50)
>telephone = models.CharField(max_length=12)
>memberoffice = models.ForeignKey('memberoffices.MemberOffice')
>creationdate = models.DateTimeField(auto_now_add=True)
>activated = models.BooleanField(default=False)
>activation_string = models.CharField(max_length=30, unique=True)
>activationdate = models.DateTimeField(null=True)
>user = models.ForeignKey(User,unique=True)
>
> **I have set it up in settings.py this way:
> AUTH_PROFILE_MODULE = 'students.StudentProfile'
>
>
> ** I have this form:
> class StudentForm(forms.Form):
>username = forms.CharField(max_length=30)
>first_name = forms.CharField(max_length=30)
>last_name = forms.CharField(max_length=30)
>email = forms.EmailField()
>password1 =
>
> forms.CharField(max_length=30,widget=forms.PasswordInput(render_value=False))
>password2 =
>
> forms.CharField(max_length=30,widget=forms.PasswordInput(render_value=False))
>address = forms.CharField(max_length=50)
>city = forms.CharField(max_length=60)
>province = forms.CharField(max_length=30)
>postalcode = forms.CharField(max_length=50)
>telephone = forms.CharField(max_length=12)
>memberoffice =
> forms.ModelMultipleChoiceField(queryset=MemberOffice.objects.all())
>
> **and this save routine associated with the form to save it:
>def save(self):
>
>newstudent =
> User.objects.create_user(username=self.cleaned_data['username'],
>
> email=self.cleaned_data['email'],
>
> password=self.cleaned_data['password1'])
>newstudent.is_staff = False
>newstudent.first_name = self.cleaned_data['first_name']
>newstudent.last_name = self.cleaned_data['last_name']
>newstudent.save()
>try:
>newStudentProfile = request.newstudent.get_profile()
>except:
>newStudentProfile = StudentProfile(user=newstudent)
>newStudentProfile.address =
> self.cleaned_data['address']
>newStudentProfile.city = self.cleaned_data['city']
>newStudentProfile.province =
> self.cleaned_data['province']
>newStudentProfile.postalcode =
> self.cleaned_data['postalcode']
>newStudentProfile.memberoffice =
> MemberOffice(id=self.cleaned_data['memberoffice'])
>newStudentProfile.save()
>return newstudent
>
> **This is the controlling view.py file:
>
> def registerstudent(request,language):
>if request.POST:
>   form = StudentForm(data=request.POST)
>   if form.is_valid():
>newstudent = form.save()
>newstudent.get_profile().activation_string =
> generate_activation_string()
>email_content =
> create_activation_email_content(newprofile.activation_string)
>
> send_activation_email(newstudent.first_name,newstudent.email,email_content)
>return HttpResponse('You\'ll receive an email. Click the
> link in the email.')
>   else:
>errors = form.errors
>return HttpRespons

Reset trac account password

2008-10-24 Thread Matias
Hello everyone,

Is there a way to reset the password of the trac account?
I didnt find even an email address to do this request.

Thanks in advance,

Matias.

-- 
:wq

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Date Format in Admin

2008-10-24 Thread Matias Surdi

http://docs.djangoproject.com/en/dev/ref/settings/#date-format

Botolph escribió:
> I would like to change the formatting of dates in the admin from -
> MM-DD to DD-MM-. I have set "DATE_FORMAT" in the settings file,
> but that only changes list_display and not the DateField input. In a
> post from Januar 2007 Adrian wrote:
> 
>> Yes, newforms DateFields let you specify the input format(s). This has
>> yet to be integrated into the Django admin, but it will be sooner
>> rather than later.
> 
> Has this been integrated now? If so, where can I change it? I have
> been searching for hours without finding a solution.
> 
> > 
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to get the value of a form field within a template?

2008-10-10 Thread Matias Surdi

The same I do

{{form.interface.initial}}

I'd like to do something like

{{form.interface.value}}


How can I do this?


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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: what is the correct way to create a hidden form field?

2008-10-09 Thread Matias Surdi

Ignore it.
Solved
Matias Surdi escribió:
> I want to output an  
> 
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



what is the correct way to create a hidden form field?

2008-10-09 Thread Matias Surdi

I want to output an http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANNOUNCE: Django 1.0 released

2008-09-04 Thread Matias Surdi

James Bennett escribió:
> The Django team is pleased to announce the release of Django 1.0 this evening:
> 
> Download: http://www.djangoproject.com/download/
> Release notes: http://docs.djangoproject.com/en/dev/releases/1.0/
> 
> Have fun with it, and we'll see you in a few days for DjangoCon.
> 
> 

Many thanks you all for this excellent framework!. Cogratulations!


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django with non-sql database

2008-05-14 Thread Matias Surdi

Hi,

I'm trying to figure out how to use django models without an SQL-capable 
database. The database I'm trying to use are mainly simple plaint text 
configuration files.

I think the way to go is creating a custom manager. Is that correct?
Any better idea?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



help with limit_choices_to

2008-05-08 Thread Matias Surdi

Hi.

I've the following model:

class ExamAttributeCalification(models.Model):
exam_result = models.ForeignKey(ExamResult, 
edit_inline=models.TABULAR, num_in_admin=1)
exam_attribute = 
models.ForeignKey(ExamAttribute,limit_choices_to={"exam__id":1})
 calification = models.IntegerField(core=True)


As you can see, in the last line I've a hardcoded "1". This id should be 
taken dynamically from exam_result.exam.id model attribute.

How could I accomplish this?

Thanks for your help.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



override get_FOO_url()

2008-04-25 Thread Matias Surdi

is it possible to override get_FOO_url() for a FileField in a model?

if not:
  What is the recommended way to require login for users to download a file?


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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: weird error [corrected]

2008-04-25 Thread Matias Surdi

Karen Tracey escribió:
> On Fri, Apr 25, 2008 at 8:02 AM, Matias Surdi <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
> 
> Matias Surdi escribió:
>  > Sorry, there was an error in the previous message:
>  >
>  >
>  > With the following model:
>  >
>  > class Candidate(models.Model):
>  >  name = models.CharField(max_length=100,unique=True)
>  >  file =
>  > models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)
>  >
>  >  def _get_FIELD_url(self,field):
>  >  return "http://www.google.es";
>  >  if getattr(self, field.attname): # value is not blank
>  >  import urlparse
>  >  return urlparse.urljoin(settings.MEDIA_URL,
> getattr(self,
>  > field.attname)).replace('\\', '/')
>  >  return ''
>  >
>  >
>  > when I do object.get_file_url(), http://www.google.es is returned, as
>  > expected
>  >
>  > but with the following one:
>  >
>  > class Candidate(models.Model):
>  >  name = models.CharField(max_length=100,unique=True)
>  >  curriculum =
>  > models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)
>  >
>  >  def _get_FIELD_url(self,field):
>  >  return "http://www.google.es";
>  >  if getattr(self, field.attname): # value is not blank
>  >  import urlparse
>  >  return urlparse.urljoin(settings.MEDIA_URL,
> getattr(self,
>  > field.attname)).replace('\\', '/')
>  >  return ''
>  >
>  > when I do object.get_cirriculum_url(), I don't get the same
> result than
>  > with
>  > the first one.
>  >
> 
> 
> Well, what result do you get?  Why not tell us instead of making us guess?
> 
> Unless it's a typo. one problem is you have is you try to get the 
> 'cirriculum' url but you named the field 'curriculum'.
> 
> (I'm also wondering why you are overriding _get_FIELD_url at all, since 
> it seems pretty hackish, but I guess that's beside the point.)
>  
> 
> 
>  > The only difference is the field name.
>  >
>  > am I missing something here? what could be happening?
>  >
>  > NOTE: Database is destroyed/recreated on each test.
>  >
>  > Thanks.
>  >
>  >
>  > >
>  >
> 
> I think I'm isolating the problem, I think it's related to the field's
> name size... when it's longer than 8 character, the problem appears.
> 
> 
> That's surprising, since there's nothing in Django that has any 
> dependence on field name length here.
> 
> Karen
> 
> > 

Despite the typo, I'm still having the same problem.

What I want to do, is not to have a "public" download url I want to 
check user's permissions before a download is started. So, I want to 
change the behaviour of get__url so that it returns a custom view 
instead of the public url.





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: weird error [corrected]

2008-04-25 Thread Matias Surdi

Matias Surdi escribió:
> Sorry, there was an error in the previous message:
> 
> 
> With the following model:
> 
> class Candidate(models.Model):
>  name = models.CharField(max_length=100,unique=True)
>  file =
> models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)
> 
>  def _get_FIELD_url(self,field):
>  return "http://www.google.es";
>  if getattr(self, field.attname): # value is not blank
>  import urlparse
>  return urlparse.urljoin(settings.MEDIA_URL, getattr(self,
> field.attname)).replace('\\', '/')
>  return ''
> 
> 
> when I do object.get_file_url(), http://www.google.es is returned, as
> expected
> 
> but with the following one:
> 
> class Candidate(models.Model):
>  name = models.CharField(max_length=100,unique=True)
>  curriculum =
> models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)
> 
>  def _get_FIELD_url(self,field):
>  return "http://www.google.es";
>  if getattr(self, field.attname): # value is not blank
>  import urlparse
>  return urlparse.urljoin(settings.MEDIA_URL, getattr(self,
> field.attname)).replace('\\', '/')
>  return ''
> 
> when I do object.get_cirriculum_url(), I don't get the same result than 
> with
> the first one.
> 
> The only difference is the field name.
> 
> am I missing something here? what could be happening?
> 
> NOTE: Database is destroyed/recreated on each test.
> 
> Thanks.
> 
> 
> > 
> 

I think I'm isolating the problem, I think it's related to the field's 
name size... when it's longer than 8 character, the problem appears.



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



weird error [corrected]

2008-04-25 Thread Matias Surdi

Sorry, there was an error in the previous message:


With the following model:

class Candidate(models.Model):
 name = models.CharField(max_length=100,unique=True)
 file =
models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)

 def _get_FIELD_url(self,field):
 return "http://www.google.es";
 if getattr(self, field.attname): # value is not blank
 import urlparse
 return urlparse.urljoin(settings.MEDIA_URL, getattr(self,
field.attname)).replace('\\', '/')
 return ''


when I do object.get_file_url(), http://www.google.es is returned, as
expected

but with the following one:

class Candidate(models.Model):
 name = models.CharField(max_length=100,unique=True)
 curriculum =
models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)

 def _get_FIELD_url(self,field):
 return "http://www.google.es";
 if getattr(self, field.attname): # value is not blank
 import urlparse
 return urlparse.urljoin(settings.MEDIA_URL, getattr(self,
field.attname)).replace('\\', '/')
 return ''

when I do object.get_cirriculum_url(), I don't get the same result than
with
the first one.

The only difference is the field name.

am I missing something here? what could be happening?

NOTE: Database is destroyed/recreated on each test.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



weird error [corrected]

2008-04-25 Thread Matias Surdi

Sorry, there was an error in the previous message:


With the following model:

class Candidate(models.Model):
 name = models.CharField(max_length=100,unique=True)
 file =
models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)

 def _get_FIELD_url(self,field):
 return "http://www.google.es";
 if getattr(self, field.attname): # value is not blank
 import urlparse
 return urlparse.urljoin(settings.MEDIA_URL, getattr(self,
field.attname)).replace('\\', '/')
 return ''


when I do object.get_file_url(), http://www.google.es is returned, as
expected

but with the following one:

class Candidate(models.Model):
 name = models.CharField(max_length=100,unique=True)
 curriculum =
models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)

 def _get_FIELD_url(self,field):
 return "http://www.google.es";
 if getattr(self, field.attname): # value is not blank
 import urlparse
 return urlparse.urljoin(settings.MEDIA_URL, getattr(self,
field.attname)).replace('\\', '/')
 return ''

when I do object.get_cirriculum_url(), I don't get the same result than 
with
the first one.

The only difference is the field name.

am I missing something here? what could be happening?

NOTE: Database is destroyed/recreated on each test.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



weird error

2008-04-25 Thread Matias Surdi

With the following model:

class Candidate(models.Model):
 name = models.CharField(max_length=100,unique=True)
 file = 
models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)

 def _get_FIELD_url(self,field):
 return "http://www.google.es";
 if getattr(self, field.attname): # value is not blank
 import urlparse
 return urlparse.urljoin(settings.MEDIA_URL, getattr(self, 
field.attname)).replace('\\', '/')
 return ''


when I do object.get_file_url(), http://www.google.es is returned, as 
expected

but with the following one:

class Candidate(models.Model):
 name = models.CharField(max_length=100,unique=True)
 curriculum = 
models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300)

 def _get_FIELD_url(self,field):
 return "http://www.google.es";
 if getattr(self, field.attname): # value is not blank
 import urlparse
 return urlparse.urljoin(settings.MEDIA_URL, getattr(self, 
field.attname)).replace('\\', '/')
 return ''

when I do object.get_file_url(), I don't get the same result than with 
the first one.

The only difference is the field name.

am I missing something here? what could be happening?

NOTE: Database is destroyed/recreated on each test.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



order_by for related tables

2008-04-24 Thread Matias Surdi

Hi again,

I can't get to work the order_by('related_table.field') as described in 
http://www.djangoproject.com/documentation/db-api/#order-by-fields

Is this documentation correct?

I'm using django from SVN trunk.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Zero padding an intger in templates

2008-04-24 Thread Matias Surdi

Matias Surdi escribió:
> Hi.
> 
> Which is the correct way to zero-pad an integer in templates? is there 
> any filter?
> 
> Thanks a lot.
> 
> 
> > 
> 

Found it:  variable|stringformat:"04i"


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Zero padding an intger in templates

2008-04-24 Thread Matias Surdi

Hi.

Which is the correct way to zero-pad an integer in templates? is there 
any filter?

Thanks a lot.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Exceptions by mail

2008-04-10 Thread Matias Surdi

Marc Fargas escribió:
> Simply set DEBUG=False in your settings.py, when an exception raises
> django will send the traceback to the people defined in ADMINS (also in
> settings.py)
> 
> Documentation about that is:
> http://www.djangoproject.com/documentation/settings/#error-reporting-via-e-mail
> 
> 
> Regards,
> Marc
> 
> El jue, 10-04-2008 a las 09:46 +0200, Matias Surdi escribió:
>> Hi,
>>
>> I've read somewhere that there is a way in django to send exceptions by 
>> mail. I can't remember where.
>>
>> Does anyone know where could I find documentation about that?
>>
>>
>> >>

Thanks a lot.That was :-)




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Exceptions by mail

2008-04-10 Thread Matias Surdi

Hi,

I've read somewhere that there is a way in django to send exceptions by 
mail. I can't remember where.

Does anyone know where could I find documentation about that?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



override get_file_url()

2008-04-08 Thread Matias Surdi

Hi.

I'm trying to upload files to a directory that is not under the web 
server root, for security reasons.

I wonder if is it possible to override the model's "get_FOO_url()" 
method so that It will return some form of encoded url.

I've already achieved this by defining in my model's class a 
_get_FIELD_url(self,field) method, but I'm not sure that is the correct 
way to do this.


Thanks a lot.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms initial value

2008-04-05 Thread Matias Surdi

Matias Surdi escribió:
> Hi.
> 
> How can I pass an initial value to a newforms form's widget?
> 
> I know that there is an "initial" parameter for widgets, but what if I 
> don't know that parameter's value beforehand?
> 
> What I'm trying to do is to be able to make a request to an url and 
> depending on some url parameters generate a form wich will take its 
> initial values from those url parameters.
> 
> Any idea?
> 
> Thanks a lot.
> 
> 
> > 
> 

I think what I was looking for is this:

 >>> MyForm.base_fields["url"].initial="http://www.url.com";


Could this cause any problem? Is this the correct way to do this?

Thanks for your help.



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



newforms initial value

2008-04-05 Thread Matias Surdi

Hi.

How can I pass an initial value to a newforms form's widget?

I know that there is an "initial" parameter for widgets, but what if I 
don't know that parameter's value beforehand?

What I'm trying to do is to be able to make a request to an url and 
depending on some url parameters generate a form wich will take its 
initial values from those url parameters.

Any idea?

Thanks a lot.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >