Re: [ver. 1.5] Specifying custom User model (extends AbstractUser) doesn't work

2013-03-21 Thread Lewis Taylor
And this is why I learnt the names of many of those major in the Django 
community! Now if I post after them, it's mostly to say. Yes I agree.

Like I'm doing now :-)

On Wednesday, 24 October 2012 05:02:02 UTC+1, Surya Mukherjee wrote:
>
> Django's standard User class isn't sufficient for my needs so I am making 
> my own User class. As per the User Authentication doc page, I am 
> subclassing AbstractUser (not AbstractBaseUser) to add some new stuff.
>
> 
> from django.contrib.auth.models import AbstractUser
>
> class MyUser(AbstractUser):
> test = 'Hello world'
> 
>
> Pretty simple so far. In settings.py:
> 
> # Specifies SDBUser as the custom User class for Django to use
> AUTH_USER_MODEL = 'app.MyUser'
> 
>
> But when i try to syncdb, everything breaks:
>
> [root@Surya project]# manage syncdb
> CommandError: One or more models did not validate:
> app.userprofile: 'user' defines a relation with the model 'auth.User', 
> which has been swapped out. Update the relation to point at 
> settings.AUTH_USER_MODEL.
> auth.user: Model has been swapped out for 'app.SDBUser' which has not been 
> installed or is abstract.
> django_openid_auth.useropenid: 'user' defines a relation with the model 
> 'auth.User', which has been swapped out. Update the relation to point at 
> settings.AUTH_USER_MODEL.
>
> django_openid_auth is a third party OpenID library, but the first two are 
> pure Django and they're still breaking. Wat do?
>
>

-- 
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: en vs. en_US (was 'Problems creating a new locale')

2009-09-27 Thread Lewis Taylor

Hi michael,

the language code should always be in the form xx or xx-xx and the
locale folders should be in the form xx or xx_XX. If you look through
the translation code you can see that what django does is given a
language xx-xx, it will check for xx_XX locale then xx. given xx (en
for example), it'll just look for locale xx, it won't search for more
specific dialects.

One flaw is that if django doesn't find the specified language in the
conf/locale folder of the django directory, it returns the default
language code in the settings, so you must have en_US in the django
locale directory if you want specific languages.




On Sep 26, 4:31 pm, Michael Scheper  wrote:
> Hello again,
>
> I poked at this a bit more yesterday and traced this problem to core
> Python behaviour. The critical line of Django code is in the
> django.utils.translation.trans_real.translation(language) function, in
> _translation() under _fetch():
>
> t = gettext_module.translation('django', path, [loc], klass)
>
> When the value of loc doesn't include a territory (i.e. when it's
> 'en', and not something like 'en_AU' or 'en_US'), you really don't
> know which locale you're going to get. I've experimented with it and
> it seems to depend on what order the file system returns the locale
> directories. I've written in the Django i18n forums about this 
> (seehttp://www.nabble.com/Strange-gettext.find-results-td25621560.html)
> but I would call this a bug, either in Django or Python.
>
> As a result of this bug, users in Portugal might see the Brazilian
> content, and users in Spain might see Argentine content. Luckily,
> Django has separate locales for zh_CH and zh_TW, not just zh;
> otherwise, things could have gotten /really/ nasty!
>
> In any case, to solve my own problem, I'm working on a hack for
> LocaleMiddleware so it looks at request.META.HTTP_ACCEPT_LANGUAGE if
> request.LANGUAGE_CODE is 'en', and chooses the right locale,
> regardless of whether Django supports it yet.
>
> Cheers,
> MS.
>
> On Sep 21, 1:43 pm, Michael Scheper  wrote:
>
> > G'day everyone,
>
> > What I want to do: To keep my American users happy, I want to localise
> > my site for en-us locale users. That way, they'll see all the dropped
> > 'u's and past participles and other things that don't exist in 'U.S.
> > English' (and that U.S. date format and all the other spelling
> > variations), but my site will still be correct for users in en-au, en-
> > nz, en-gb, en-za, en-ca, etc.
>
> > Unfortunately, it's not working. Even when I have my browser set to
> > U.S. English, the version of my site I see is in international
> > English.
>
> > Details: I'm using Python 2.5.2, and 'Django version 1.0-final-SVN-
> > unknown'.
>
> > What I've tried:
>
> > 1. I've made sure that i18n/l10n is working in general by translating
> > a few things to Dutch (nl) and setting my browser to that locale. It
> > works. (This article helped a 
> > lot:http://devdoodles.wordpress.com/2009/02/14/multi-language-support-in-...)
>
> > 2. According tohttp://docs.djangoproject.com/en/dev/topics/i18n/,
> > 'Django does not support localizing your application into a locale for
> > which Django itself has not been translated. [...] If you want to
> > support a locale for your application that is not already part of
> > Django, you'll need to make at least a minimal translation of the
> > Django core.' I've done this by copying the 'en' directory to 'en_US'
> > in /var/lib/python-support/python2.5/django/conf/locale and /usr/share/
> > python-support/python-django/django/conf/locale.* I also set LANGUAGES
> > to include only 'en' and 'en-us' (and 'nl') in settings.py. Since I
> > did these two things, putting {{ request.LANGUAGE_CODE }} in a
> > template yields 'en-us' when I set my browser to U.S. English, and
> > just 'en' when I use other English locales. (Before doing these
> > things, it returned 'en' regardless of which English locale I had my
> > browser set to.)
>
> > 3. I used django-admin makemessages -l en and django-admin
> > makemessages -l en-us to create language files, created the American
> > translations, and ran django-admin compilemessages. (I also tried
> > using en_US instead of en-us, since that's the standard used in the
> > two system directories I noted above. No difference.)
>
> > What's not working: The U.S. English text isn't showing up when I set
> > my browser to U.S. English, even though {{ request.LANGUAGE_CODE }}
> > does display 'en-us'.
>
> > * I have root on my own development server, so I was able to copy
> > these locale directories. My web host probably won't let me do this,
> > however, so I need to find another way that works.
>
> > Any advice?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 

URL resolving of patterns including 0 or 1 operator fails.......

2009-09-25 Thread Lewis Taylor

Here it goes:

I wanted a clean url structure so i tried to abstract as much as i
could in one url pattern. it looks something like this:

url(r'^approved/((?P[a-zA-Z ,-]+)?)(/?)((?P[0-9]+)?)
(/?)
$', get_approved_images, name='approved_images')

this in theory should allow the return of
1) all images - /approved/
2) pagination options for all images - /approved/2/
3) images from a specific country - /approved/china/
4) pagination for countries - /approved/china/3/

this works fine, but when trying to resolve the url with no page or
country there are problems i.e.

{% url approved_images %}

i thought as there can be 0 or 1 of both country and page as specified
in the url pattern there shouldn't be a problem, however it doesn't
seem that way. I haven't looked inside the code as i have higher
priority things to do at present, but if anyone could help with a
solution or a reason why it doesn't work that would be appreciated, if
not i suggest a patch as it makes sense that allowing url's to match a
particular pattern should also mean that any url that matches that
pattern should be resolvable :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 scalability with files

2009-08-27 Thread Lewis Taylor

Question:

I have an imagefield that i want to create a thumbnail for on approval
of the image. The problem is (setup is 2 django instances, load
balancer and DB) if the image is stored on one machine it's not the
cleanest solution to have to get the image from the other server and
process it. Is there a better solution django offers, and why are
blobs not supported. ideally i would have the image stored in DB and
that way there would never be sync issues.

Thanks

Lewis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: JSON Serialization with ImageField

2009-08-24 Thread Lewis Taylor

The reason I'm trying it is due to a requirement, the data rather than
being sent using a normal post request in a multienc form has to be sent
over in a json string
in the post request containing the base64 encoded image.

On Mon, 2009-08-24 at 18:38 +0200, Maksymus007 wrote:
> On Tue, Aug 4, 2009 at 10:58 PM, scuzz wrote:
> >
> > Hi,
> >
> > I'm trying to receive a file encoded in a json string and store it in
> > an ImageField. I was hoping to use the standard Django deserialisation
> > like:
> >
> > serializers.deserialize("json", "...snip..., \"myImageField\":
> > \"base64encodedimage\", ...snip...)
> >
> > however it tries to store the image content string directly in the
> > field rather than going through the imagefield file storage mechanism.
> > has anyone solved this?
> >
> > i've got control of the creation of the json string, so i can encode
> > the image however works best. i wasn't expecting base64 strings to
> > just work but that's a separate though related problem. i'm guessing i
> > need a hook into the deserialization to handle images specially but i
> > don't see how to go about it.
> >
> > thanks for any help
> >
> 
> I may be wrong, but ImageField handles file upload via POST by
> utilizing request.FILES - which is an array containing information
> about file and generator for reading data - why you try to put there
> raw data ?
> 
> > 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: JSON Serialization with ImageField

2009-08-24 Thread Lewis Taylor

Did you find a way to do this? I'm having the same problem.

Lewis

On Aug 4, 9:58 pm, scuzz  wrote:
> Hi,
>
> I'm trying to receive a file encoded in a json string and store it in
> an ImageField. I was hoping to use the standard Django deserialisation
> like:
>
> serializers.deserialize("json", "...snip..., \"myImageField\":
> \"base64encodedimage\", ...snip...)
>
> however it tries to store the image content string directly in the
> field rather than going through the imagefield file storage mechanism.
> has anyone solved this?
>
> i've got control of the creation of the json string, so i can encode
> the image however works best. i wasn't expecting base64 strings to
> just work but that's a separate though related problem. i'm guessing i
> need a hook into the deserialization to handle images specially but i
> don't see how to go about it.
>
> thanks for any 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
-~--~~~~--~~--~--~---