Re: Problem with cache.

2010-08-10 Thread Aljoša Mohorović
On Tue, Aug 10, 2010 at 6:55 PM, Felipe  wrote:
> So, when I erase the cache, the value is corrected, and the variable
> turns showing the real value which is stored in the database.

what do you mean when you say cache? browser cache, memcached or something else?

> Could this to be a problem with the memcached ?

are you using memcached? if you're using memcached
(http://docs.djangoproject.com/en/1.2/topics/cache/#topics-cache) are
you using low-level API or per-site/per-view cache API?

Aljosa Mohorovic

-- 
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: Problem with cache.

2010-08-10 Thread Aljoša Mohorović
On Tue, Aug 10, 2010 at 7:17 PM, Felipe  wrote:
> So,
>
> I'm using a filesystem caching and I'm using cache.get and cache.set
> to set and get the cache.
>
> But sometimes django shows a different value of the stored value in
> the database.

cache is not updated automatically, if value in database has changed
you need to update cache.
where are you caching (cache.set) this value, in a view or after
Model.save() is called?
post part of code where you are using cache.get/set.

Aljosa

-- 
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: Problem with cache.

2010-08-11 Thread Aljoša Mohorović
On Wed, Aug 11, 2010 at 12:27 PM, Felipe  wrote:
> The number 487.000 for example, that would stay the same value for all
> the time is changing with a certain frequency when django consult it's
> cache in /var/tmp/djangocache and the value showed is 287.000.
>
> The cache is generating strange values that I don't know where they
> come from.

can you post code where you use cache?

Aljosa

-- 
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: Image and thumbnal solution

2010-08-11 Thread Aljoša Mohorović
On Wed, Aug 11, 2010 at 1:00 PM, zero00  wrote:
> I tried the most simple way:
>
> class Model(models.Model):
>   thumbnail = models.ImageModel(upload_to="thumb_path" height=100,
> width=100)
>   image = models.ImageModel(upload_to"image_path")
>
> but apparently the default save function is not equip to handle
> multiple file uploads.

this shouldn't be a problem, what kind of error do you get?
also, try looking at http://code.google.com/p/django-photologue/  or
http://bitbucket.org/jdriscoll/django-imagekit/

Aljosa Mohorovic

-- 
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: Django images, can't load a simple image into html page when I using django!

2010-08-11 Thread Aljoša Mohorović
On Wed, Aug 11, 2010 at 1:14 PM, pj-linden  wrote:
> I have yust started with a django project and have the default settup,
> I have followed the django tutorials and now I am trying to load an
> image into the html page that i have created but for some reason the
> image will not show!
> when i using chrome as the reader of the page I can read in the
> javascript-konsol:
>
> "Resource interpreted as image but transferred with MIME type text/
> html."

did you setup serving of static files for development?
http://docs.djangoproject.com/en/1.2/howto/static-files/#howto-static-files

could you provide more details about image you are trying to display,
where it's located?

Aljosa Mohorovic

-- 
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: Image and thumbnal solution

2010-08-11 Thread Aljoša Mohorović
> image = models.ImageModel(upload_to"image_path")

is this copy/paste error or did you forget "=" for upload_to?

Aljosa Mohorovic

-- 
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: Image and thumbnal solution

2010-08-11 Thread Aljoša Mohorović
On Wed, Aug 11, 2010 at 2:02 PM, zero00  wrote:
> Im testing various things right now and i narrow the problem to this:
>
>  height_field=150, width_field=150
>
> thumb = models.ImageField(upload_to="images/services/thumbs",
> height_field=150, width_field=150)
>
> those parameters are the thing thats breaking up the code

width_field/height_field should point to another field in model, not
width/height of image.
check for more details:
http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.ImageField

Aljosa Mohorovic

-- 
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: Image and thumbnal solution

2010-08-11 Thread Aljoša Mohorović
On Wed, Aug 11, 2010 at 2:26 PM, zero00  wrote:
> I get it now thanks

no problem, glad i could 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-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: pyfacebook

2010-08-12 Thread Aljoša Mohorović
On Thu, Aug 12, 2010 at 1:34 AM, Alessandro Ronchi
 wrote:
> Is pyfacebook compatible with django 1.2.1? I didn't find nothing, and
> it gives me a 403 error I cannot understand:

pyfacebook is no longer actively developed, try
http://github.com/facebook/python-sdk
it's the official python sdk maintained by facebook people and it's
based on the new graph api.
i'm using it successfully on a live project.

Aljosa Mohorovic

-- 
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: Image and thumbnal solution

2010-08-12 Thread Aljoša Mohorović
On Wed, Aug 11, 2010 at 9:40 PM, Franklin Einspruch
 wrote:
> I still don't get this. Are you supposed to do something like...
>
> image = models.ImageField()
> image.height_field = 'height'
> image.width_field = 'width'
>
> And make 'height' and 'width' columns in the table? I really wish the
> docs had some sample code here...

it's not required to use width_field/height_field, for advanced usage
try looking at http://bitbucket.org/jdriscoll/django-imagekit/ source
code.

Aljosa Mohorovic

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



how do forms select language to render?

2010-09-05 Thread Aljoša Mohorović
if django.utils.translation.get_language() and LANGUAGE_CODE returns
one language what does form.as_p use that it renders localized stuff
in another language?

Aljosa Mohorovic

-- 
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: Launching Background Processes from a View

2010-09-06 Thread Aljoša Mohorović
On Mon, Sep 6, 2010 at 7:19 AM, Heath  wrote:
> What I require seems simple, just run the requested process in the
> background. The terminal equivalent would be:
>
> "nohup   &" and return control to the view.
>
> Any ideas on how to achieve this?

if this already works in a shell is there some reason why
"os.system('cmd')" or something similar doesn't work for you?

Aljosa Mohorovic

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



Client#post returns None for response

2010-09-27 Thread Aljoša Mohorović
i'm trying to test post request using Client from django.test.client
(v1.1.2) but it returns None for response.
target url is a django-piston resource and i can test it normally from
django shell:
>>> h.request(url, "POST", urlencode(data)) # h is httplib2.Http object

but when i try to use Client#post(url, data) i get this:

  File 
"/home/aljosa/Projects/Sites/ozujsko.com/env/lib/python2.6/site-packages/django/test/client.py",
line 317, in post
response = self.request(**r)
  File 
"/home/aljosa/Projects/Sites/ozujsko.com/env/lib/python2.6/site-packages/django/test/client.py",
line 225, in request
response = self.handler(environ)
  File 
"/home/aljosa/Projects/Sites/ozujsko.com/env/lib/python2.6/site-packages/django/test/client.py",
line 73, in __call__
response = middleware_method(request, response)
  File 
"/home/aljosa/Projects/Sites/ozujsko.com/env/lib/python2.6/site-packages/django/middleware/common.py",
line 84, in process_response
if response.status_code == 404:
AttributeError: 'NoneType' object has no attribute 'status_code'


url is relative path (url = "/some/path/") and i can't figure out why
is this happening.
any idea?

Aljosa Mohorovic

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



custom form based on user in admin

2010-12-02 Thread Aljoša Mohorović
is this the best way to use different forms for users in admin app?

=
class MyModelForm:
  ...

class RootMyModelForm:
  ...

class MyModelAdmin(admin.ModelAdmin):
form = MyModelForm

def get_form(self, request, obj=None, **kwargs):
if request.user.is_superuser:
self.form = RootMyModelForm
else:
self.form = MyModelForm

return super(MyModelAdmin, self).get_form(request, obj, **kwargs)
=

other options?

Aljosa Mohorovic

-- 
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: django-mptt compared w/ django-treebeard

2012-02-03 Thread Aljoša Mohorović
On Thu, Feb 2, 2012 at 8:13 PM, creecode  wrote:
> I wouldn't assume that just because something hasn't been updated for awhile
> that it isn't good.

like i said, i've used treebeard w/o problems so i don't think it's bad.
my question/interest is mostly because i've noticed that most projects use mptt.

Aljosa

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

2012-03-01 Thread Aljoša Mohorović
if you're using apache please check /etc/apache2/envvars and make sure
that LANG is not C.
if you uncomment system locale it should work as expected.

## Uncomment the following line to use the system default locale instead:
. /etc/default/locale

Aljosa Mohorovic

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

2012-03-01 Thread Aljoša Mohorović
although it's possible that this is not the problem, could you post
additional details after you restart apache:
1) envvars content
$ cat /etc/apache2/envvars

2) env settings for apache/site user (usually www-data):
$ cat /etc/default/locale
$ sudo su - www-data
$ export

Aljosa

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

2012-03-01 Thread Aljoša Mohorović
On Thu, Mar 1, 2012 at 6:16 PM, andi-h  wrote:
> Would it help to change the locale settings on this Ubuntu server to
> de_DE.UTF-8, too?

don't know, but give it a shot.
also, what's the output of:
$ locale -a

Aljosa

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



Re: How to install django-mce?

2012-04-08 Thread Aljoša Mohorović
On Sun, Apr 8, 2012 at 10:34 PM, Roy Smith  wrote:
> I'm trying to install django-tinymce 1.5.1b2 into a django-1.3 site.  The

just use "pip install django-tinymce"

> directories, but no tiny_mce directory under those.  Even odder, the media
> and static trees look like identical copies of each other.  Also, it seems

it contains both media and static so it can be compatible w/ django
before staticfiles were part of django.

> directory.  I'm guessing the installation directions predate django 1.3 and
> collectstatic?

no, files (static/media) are new and included to work properly w/
django 1.3, didn't try w/ 1.4.

docs are little out of date but should work.
http://django-tinymce.readthedocs.org/en/latest/installation.html

feel free to contact me if you need help.

Aljosa

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

2012-06-04 Thread Aljoša Mohorović
take a look at gist w/ base64 file upload solution:
https://github.com/toastdriven/django-tastypie/issues/42

it works great, you can add Base64FileField implementation to your app
(it's only ~15 lines of code) and you can upload from anything that
can open a file and encode it.
you can also use flash/swf if you need to make it work in older browsers.

Aljosa

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

2012-07-17 Thread Aljoša Mohorović
On Tue, Jul 17, 2012 at 10:47 AM, Benasg  wrote:
> Hello, when I using django comments without tinymce it`s works perfect, but
> when I add tiny I get error "This field is required".
> Any suggestion?

can you post models.py code before and after you added tinymce?

Aljosa
--
https://twitter.com/maljosa
https://github.com/aljosa

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

2012-08-02 Thread Aljoša Mohorović
On Thu, Aug 2, 2012 at 3:19 AM, jondbaker  wrote:
> TINYMCE_JS_URL = os.path.join(PROJECT_ROOT,
> 'templates/static/js/tiny_mce/tiny_mce.js')
> TINYMCE_JS_ROOT = os.path.join(PROJECT_ROOT, 'templates/static/js/tiny_mce')

You don't need to set TINYMCE_JS_URL/TINYMCE_JS_ROOT because it is set
automatically based on staticfiles settings.
It's available as configuration option if you need to override default setup.
When you "pip install django-tinymce" all required files are copied so
you can skip step 4 as described in docs, you just need to set
STATIC_ROOT/STATIC_URL.

basically, if you have tinymce in INSTALLED_APPS and urlpatterns and
django has staticfiles properly configured it will work as expected.

let me know if you're still having issues w/ setup and feel free to
contact me if you have any questions.

Aljosa
--
https://twitter.com/maljosa
https://github.com/aljosa

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

2012-08-03 Thread Aljoša Mohorović
documentation is not completely updated so steps in previous emails are correct.
i won't be available until next week but check second snippet under:
http://django-tinymce.readthedocs.org/en/latest/usage.html#the-flatpages-link-list-view

and be sure that you have something like:
"""
admin.site.unregister(FlatPage)
admin.site.register(FlatPage, TinyMCEFlatPageAdmin)
"""

Aljosa

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

2012-08-05 Thread Aljoša Mohorović
On Fri, Aug 3, 2012 at 6:20 PM, Jonathan Baker
 wrote:
> If you're up for it, I'd love to help update the documentation to save
> future users (and yourself) some time with the issues I ran in to.

sure, just send pull requests for https://github.com/aljosa/django-tinymce

Aljosa
--
https://twitter.com/maljosa
https://github.com/aljosa

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

2012-08-09 Thread Aljoša Mohorović
On Thu, Aug 9, 2012 at 1:19 PM, Pervez Mulla  wrote:
> Please tell me how can I know ,the details about user login and logout
> details , and how can I store that data in DB in Django.

User model (auth.models.User) has last_login and if you need custom
data stored you can try using:
https://docs.djangoproject.com/en/1.4/topics/signals/
it will enable you to "catch" events on models and get data from
request/response.
based on that you should have enough data to start.

Aljosa
--
https://twitter.com/maljosa
https://github.com/aljosa

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

2012-08-20 Thread Aljoša Mohorović
skip step #4, 1-3 should be enough:
http://django-tinymce.readthedocs.org/en/latest/installation.html#id2

Aljosa
--
https://twitter.com/maljosa
https://github.com/aljosa

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

2012-08-20 Thread Aljoša Mohorović
HTMLField() is probably the easiest way to use django-tinymce:
http://django-tinymce.readthedocs.org/en/latest/usage.html#the-htmlfield-model-field-type

let me know if you have any issues.

Aljosa
--
https://twitter.com/maljosa
https://github.com/aljosa

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

2011-09-14 Thread Aljoša Mohorović
if you need to simulate https for development, like for facebook apps,
you can setup apache proxy.
something like:



ProxyPass / http://localhost:8000/ retry=1
ProxyPassReverse / http://localhost:8000/
ProxyPreserveHost On

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

SSLEngine on
SSLCertificateFile/etc/ssl/certificate.crt
SSLCertificateKeyFile /etc/ssl/example.com.key
SSLCertificateChainFile /etc/ssl/intermediate.crt
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 TinyMCE don't displays Html tags to vistors

2011-09-20 Thread Aljoša Mohorović
On Tue, Sep 20, 2011 at 8:18 AM, Tsung-Hsien  wrote:
> I've been done my admin interface with TinyMCE. However,  aftering
> editing, I see words with HTML tags update to my website.
>
> What's a good way to solve this?

you need to add "{{ tinymce_content|safe }}", docs:
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#safe

Aljosa

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



3rd party apps with staticfiles support - howto support older versions

2011-10-04 Thread Aljoša Mohorović
given that since django v1.3 staticfiles are included and media folder
is now static folder, how can a 3rd party app support v1.3 and
previous releases w/o creating duplicated content in 2 folders (media
and static)?

Aljosa

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



access model/instance from custom field/widget

2011-10-04 Thread Aljoša Mohorović
if i have a modelform with custom field and widget how can i access
current model/instance (or None) in field/widget?
is it possible?

Aljosa

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



howto disable label for field in admin app form?

2011-10-04 Thread Aljoša Mohorović
is it possible to disable rendering of label for field in forms?
i would like to render a field in a custom form (admin add/edit form) w/o label.
any info/tips appreciated

Aljosa

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: howto disable label for field in admin app form?

2011-10-04 Thread Aljoša Mohorović
On Tue, Oct 4, 2011 at 2:20 PM, Иван Иванов  wrote:
> You can loop through the fields of the form and show only those parts
> of the field, you need:
>
> https://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields

not exactly what i'm looking for although it works ok for frontend but
my issue is related to admin form.
i can control rendering of form fields but not label, currently the
easiest way seems to be just adding javascript to remove label from
rendered html.

Aljosa

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: howto disable label for field in admin app form?

2011-10-04 Thread Aljoša Mohorović
On Tue, Oct 4, 2011 at 2:22 PM, BILLION Sébastien
 wrote:
> It's a strange question...
> You can replace an admin template with {% extends "admin/change_form.html %}
> for example.

i don't see why it's a strange question, i have a form field and i
would like to disable rendering of label?
i appreciate suggestions and did consider overriding admin templates
but "admin/change_form.html" is messy and don't know if it's a smart
thing to do in my case.
i've expected some option where i can set label=None by overriding
field/widget init and disable label.
thanks for suggestions but i think i'll just use javascript to remove label.

Aljosa

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: howto disable label for field in admin app form?

2011-10-04 Thread Aljoša Mohorović
On Tue, Oct 4, 2011 at 2:46 PM, Ivan Ivanov  wrote:
> I think, this is exactly what you want.

i need to do this on field level, not form. thanks for suggestion.
javascript works just fine in this case

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 widgets: passing data between widget/field/form/model

2011-10-19 Thread Aljoša Mohorović
i'm subclassing ForeignKey but can't figure out howto access actual
instance (model data).
if i'm doing "class MyField(ForeignKey)", what do i need to override,
which MyField method, where i have access to related instance data (or
None if it doesn't exists)?

digging through the code i've found "self.rel" and "self.related" but
didn't figure out how to get actual model instance or related model
instance.

i've read https://docs.djangoproject.com/en/1.3/howto/custom-model-fields/
and similar docs, tried searching through the source code but the best
thing i've found was id or similar.

is this some kind design decision or am i just missing something obvious?

what i'm actually trying to create is a custom widget (would call it
advanced compared to basic widgets available in django forms/admin)
but i need model instance data in widget.

i've heard theories while asking about this that it's not necessary to
have model instance to create a custom widget but i've found it
impossible to create a generic reusable widget which interacts with
the entire form and available form data (client and server side) and
also with external services (rest/soap api) without access to model
instance.

any tips, links, docs or any constructive comments are appreciated.

Aljosa

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



Re: custom widgets: passing data between widget/field/form/model

2011-10-19 Thread Aljoša Mohorović
On Wed, Oct 19, 2011 at 1:21 PM, Tom Evans  wrote:
> I suggest you rethink your approach. Subclassing ForeignKey so that
> you can build a better widget does not seem sane. Why do you think
> this would help?

because the simplest way to make it reusable is to have "from
myapp.fields MyCustomField" and use it as any other field.
even if it's just to change default widget on ForeignKey.

also, it's probably more realistic that i'll have access to model
instance in field then in widget.

Aljosa

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



Re: custom widgets: passing data between widget/field/form/model

2011-10-21 Thread Aljoša Mohorović
any other comments/suggestions on this?

Aljosa

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



why are csrf (403) errors ignored?

2011-11-20 Thread Aljoša Mohorović
is this a design decision?
i would expect that csrf 403 errors are as important as 404/500 and
reported by default.
anybody using some custom settings to log csrf errors?
what's your experience with logging csrf errors?

Aljosa

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

2013-04-22 Thread Aljoša Mohorović
check http://django-imagekit.readthedocs.org

Aljosa

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Please help in starting up with Django App Template - Just started up with Django

2013-05-05 Thread Aljoša Mohorović
while virtualenv is activated execute in shell:
$ pip install -r requirements.txt

requirements.txt is the file located in
django-classifieds/requirements.txt which contains list of
dependencies required.

Aljosa

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django - Query

2013-05-05 Thread Aljoša Mohorović
you're catching DoesNotExist but should also catch MultipleObjectsReturned
check https://docs.djangoproject.com/en/1.5/ref/exceptions/

Aljosa

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Please help in starting up with Django App Template - Just started up with Django

2013-05-05 Thread Aljoša Mohorović
i'm not using windows but if it's in site-packages it will be on PYTHONPATH.
check 
http://docs.python.org/2/using/cmdline.html?highlight=pythonpath#envvar-PYTHONPATH

Aljosa

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Reloading modules during development

2013-05-05 Thread Aljoša Mohorović
django has development server which autoreloads
check https://docs.djangoproject.com/en/1.5/ref/django-admin/

Aljosa

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django - Query

2013-05-05 Thread Aljoša Mohorović
something like:

try:
# code
except Movie.DoesNotExist:
# code
except Movie.MultipleObjectsReturned:
# code
except:
# catch all exceptions

check http://docs.python.org/2/tutorial/errors.html#handling-exceptions

Aljosa

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




limit_choices_to (or some other way) to filter ForeignKey choices based on current model field

2011-04-16 Thread Aljoša Mohorović
if i have something like this:
===
class MyModel(models.Model):
name  = models.CharField(max_length=255)

class OtherModel(models.Model):
name  = models.CharField(max_length=255)
mymodel = models.ForeignKey(MyModel)

class MyModelItem(models.Model):
mymodel = models.ForeignKey(MyModel)
other = models.ForeignKey(OtherModel, null=True, blank=True)
===

how can i use limit_choices_to (or some other way) to filter
ForeignKey choices based on current model field?
basically, how can i do:
other = models.ForeignKey(OtherModel, null=True, blank=True,
limit_choices_to={'mymodel': 'self.mymodel'})

any options works for me (overwriting admin.TabularInline or form for
TabularInline).
thanks for any info.

Aljosa

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



staticfiles - media and static folders, any way to avoid duplicated content?

2011-04-28 Thread Aljoša Mohorović
if i support both staticfiles and django.contrib.staticfiles i need to
copy content from media folder to static folder so when i create a
python package i have media and static folders with the same content.
any way to avoid this and still support both?

Aljosa Mohorovic

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

2010-12-14 Thread Aljoša Mohorović
first step is to setup your fb canvas app to use oauth 2.0 -
http://developers.facebook.com/docs/authentication/canvas

howto ask use to authorize your app?
you need to point user to proper url -
http://developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application

this code generates url to ask user for permissions in 'scope' arg:
===
fb_auth_url = "https://graph.facebook.com/oauth/authorize";
args = {
  'client_id': settings.FACEBOOK_API_KEY,
  'redirect_uri': 'http://apps.facebook.com/%s/' % getattr(settings,
'FACEBOOK_APP_NAME', None),
  'type': 'user_agent',
  'display': 'page',
  'scope': 
'user_photos,user_videos,publish_stream,offline_access,user_birthday,...',
}
url = "%s?%s" % (fb_auth_url, urllib.urlencode(args))
===
full list of permissions ('scope' arg) is available -
http://developers.facebook.com/docs/authentication/permissions

what's next after user authorizes app and ext. permissions?
when user authorizes your app and returns to your app you'll get
'signed_request' on first request.
you can extract data from 'signed_request' with this code:

===
import json # or simplejson as json
import base64
import hashlib
import hmac

# code for facebook signed_request based on/copied from:
http://sunilarora.org/parsing-signedrequest-parameter-in-python-bas
# additional info:
http://stackoverflow.com/questions/3302946/how-to-base64-url-decode-in-python

def base64_url_decode(inp):
padding_factor = (4 - len(inp) % 4) % 4
inp += "="*padding_factor
return base64.b64decode(unicode(inp).translate(dict(zip(map(ord,
u'-_'), u'+/'

def parse_signed_request(signed_request, secret):
l = signed_request.split('.', 2)
encoded_sig = l[0]
payload = l[1]

sig = base64_url_decode(encoded_sig)
data = json.loads(base64_url_decode(payload))

if data.get('algorithm').upper() != 'HMAC-SHA256':
# log.error('Unknown algorithm')
return None
else:
expected_sig = hmac.new(secret, msg=payload,
digestmod=hashlib.sha256).digest()

if sig != expected_sig:
return None
else:
# log.debug('valid signed request received..')
return data
===

ok, so what's in data from 'signed_request'?
data from 'signed_request':
===
data = parse_signed_request(request.GET.get('signed_request'),
settings.FACEBOOK_SECRET_KEY)

# fb uid for user
uid = data.get('user_id')

# with access token you can access graph api and actually do something
# check http://developers.facebook.com/docs/api for more info
access_token = data.get('oauth_token')
===

so how do i actually do something?
when you have access_token it's pretty simple to use graph api.
to publish something:
===
h = httplib2.Http()
api_url = "http://graph.facebook.com/PROFILE_ID/feed";
args = {...} # provide arguments as described here -
http://developers.facebook.com/docs/reference/api/post#publishing
resp, content = h.request(api_url, "POST", urlencode(args))
===

i've posted this from my head, maybe i forgot something, so post
additional questions if something doesn't work as expected.
official facebook python-sdk actually works but nobody is maintaining it.

also, if you ever used google apis or anything else that actually
worked prepare yourself for hell know as facebook platform.

Aljosa Mohorovic

-- 
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: tinymce

2010-12-17 Thread Aljoša Mohorović
On Fri, Dec 17, 2010 at 3:27 PM, alecx
 wrote:
> I integrated django-tinymce into my application. Now I can edit the
> text in the former textarea field.
> But when I submit the form, the field is empty.
> I am not able to figure out why the text I wrote in the editor field
> is not submitted.
> Has someone a tip for me?

please post your views.py and template code, at least parts with form
logic and related stuff.


Aljosa

-- 
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: Facebook session problems.

2011-01-30 Thread Aljoša Mohorović
On Sun, Jan 30, 2011 at 6:30 AM, CrabbyPete  wrote:
> I log in and all is good except I loose the session if I go to another
> web site and come back.

if this is facebook canvas app it wont work properly in safari and
explorer because of some iframe restrictions.
is this facebook canvas app and you're using safari/explorer?
if it is i can share more info about possible solutions.

Aljosa Mohorovic

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

2011-01-31 Thread Aljoša Mohorović
On Mon, Jan 31, 2011 at 2:59 PM, CrabbyPete  wrote:
> I am loosing the django session.

try setting the P3P on response:
response['P3P:CP'] = "IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi
HIS OUR IND CNT"
it probably wont help but it fixes this issue with explorer so it doesn't hurt.

test if you can use cookies, most session issues in iframe apps are
cookie related.
also, try using a different browser just to figure out if it's browser
related or if it's server-side problem.

Aljosa Mohorovic

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