Trailing zeros in DecimalField

2013-05-18 Thread Pedro J. Aramburu
I've been reviewing the code of *models.DecimalField* and *
forms.DecimalField* because trailing zeros after the decimal point are 
being removed in my forms. I didn't find anything suggesting that it's done 
there, instead they are handled properly according to my needs. Although 
the proper handling, on the django admin site forms the trailing zeros are 
being removed. 

Does anyone knows how to "fix" it? Is this a django-admin thing or have I 
missed something?

I would appreciate any insight.

-- 
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: Admin Site m2m Inline get_or_create

2013-02-04 Thread Pedro J. Aramburu
Anyone? Please?

El viernes, 1 de febrero de 2013 19:43:24 UTC-3, Pedro J. Aramburu escribió:
>
> Dear Djangonauts,
> I'm in a bit of a pickle here and I would appreciate your help. I have a 
> model which needs multiple dates. I thought on serializing them onto a 
> TextField but it isn't pretty and a query-hell so instead settled for a m2m 
> field. 
>
> Now, on the django admin site I want to be able to let them write or pick 
> with the datepicker (a DateWidget) the date and get_or_create it. I figured 
> that I will need to use an InlineModelAdmin but now I'm stuck because it's 
> not like replacing the select widget (from the "through" table).
>
> Has anybody did something like this before? I appreciate some guidance.
>

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




Admin Site m2m Inline get_or_create

2013-02-01 Thread Pedro J. Aramburu
Dear Djangonauts,
I'm in a bit of a pickle here and I would appreciate your help. I have a 
model which needs multiple dates. I thought on serializing them onto a 
TextField but it isn't pretty and a query-hell so instead settled for a m2m 
field. 

Now, on the django admin site I want to be able to let them write or pick 
with the datepicker (a DateWidget) the date and get_or_create it. I figured 
that I will need to use an InlineModelAdmin but now I'm stuck because it's 
not like replacing the select widget (from the "through" table).

Has anybody did something like this before? I appreciate some guidance.

-- 
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: How to create superuser?

2013-01-07 Thread Pedro J. Aramburu
If you're using bash, you should set it up on ~/.bashrc file, that way it 
will always load, for every virtualenv and every terminal session.

BTW ~/ stands for the home directory and instead of LC_ALL try something 
like this:

export LANG="en_US.UTF-8"

That would give less trouble with other programs.

El martes, 8 de enero de 2013 00:04:52 UTC-3, Skip Montanaro escribió:
>
> Google to the rescue:
>
>
> http://stackoverflow.com/questions/10882839/django-unsupported-locale-setting-on-mac-os-x
>
> After setting LC_ALL in venv/bin/activate and re-sourcing solved my 
> problem.  Not sure if this should be handled automatically by either Django 
> or virtualenv setup, but maybe a note in the tutorial would be helpful for 
> other clueless newbies like me.
>
> Skip
>
>

-- 
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/-/l9QtQFJkrjwJ.
To post to this group, send email 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: Change label/title from an application added to django admin

2013-01-06 Thread Pedro J. Aramburu
Currently, there isn't a proper way of doing it. I will say that your best 
choice is to edit the template for the admin "index" and the "app index" so 
if app_name is "Emp" call it other way.

I know it's a dirty hack but currently there is no "standard" application 
on django so there isn't an editable app_name. There is an app_label but 
it's used when you have models on other places than models.py or something 
like that then, app_name is get from the app_label which is the last term 
in the installed_apps string splitted by dots but I think it actually get's 
it from the model namespace, as the second last term. myapp.Model then 
app_label is myapp. some.thing.other.Model think it's other.

El domingo, 23 de diciembre de 2012 19:02:21 UTC-3, Emiliano Dalla Verde 
Marcozzi escribió:
>
> Hello,
> I created an app called 'emp' with the command: django-admin.py startapp 
> emp.
> Then, i edited my models.py, added an admin.py file to register my 
> clases/models
> in the django admin. Now, when i login into the django admin, i have a 
> list of
> Applications, and it says 'Emp' in that list. I want to change 'Emp' for 
> another word,
> for example, 'Employee', how can i do that in django 1.4 ? 
> Thanks in advance,
> Emiliano.
>

-- 
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/-/8QUhThEXpsMJ.
To post to this group, send email 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: Modelforms and class based views

2013-01-06 Thread Pedro J. Aramburu
https://docs.djangoproject.com/en/1.4/topics/forms/modelforms/#model-formsets

El domingo, 6 de enero de 2013 11:46:40 UTC-3, Pedro J. Aramburu escribió:
>
> Have you tried merging the forms with formsets?
> https://docs.djangoproject.com/en/1.4/topics/forms/formsets/
>
> El viernes, 4 de enero de 2013 13:51:41 UTC-3, Marco A Morales escribió:
>>
>> Hi everyone,
>>
>> I'm still wraping my head around class based views and I'm trying my 
>> first project with class based views. I'm having trouble deciding how to 
>> write a view that will display a two Modelforms, one having a foreign key 
>> over the other. 
>>
>> I will need to do the .save(commit=False) part to save my first model and 
>> then be able to save the model with foreign key.
>>
>> How would you guys do it? 
>>
>

-- 
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/-/y4oCHhgDnCkJ.
To post to this group, send email 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: Modelforms and class based views

2013-01-06 Thread Pedro J. Aramburu
Have you tried merging the forms with formsets?
https://docs.djangoproject.com/en/1.4/topics/forms/formsets/

El viernes, 4 de enero de 2013 13:51:41 UTC-3, Marco A Morales escribió:
>
> Hi everyone,
>
> I'm still wraping my head around class based views and I'm trying my first 
> project with class based views. I'm having trouble deciding how to write a 
> view that will display a two Modelforms, one having a foreign key over the 
> other. 
>
> I will need to do the .save(commit=False) part to save my first model and 
> then be able to save the model with foreign key.
>
> How would you guys do it? 
>

-- 
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/-/L6_1LmB8JAEJ.
To post to this group, send email 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: InMemoryUploadedFile no `encoding` Attribute

2013-01-06 Thread Pedro J. Aramburu
I believe that as InMemoryUploadedFile is "InMemory", internally uses a 
cStringIO as the "container" for the file. So basically the class it's just 
a wrapper that returns the StringO object, a string representation of the 
file. You should check for the attributes of StringO or maybe use 
SimpleUploadedFile class, maybe that works.

El sábado, 5 de enero de 2013 22:46:02 UTC-3, Braden Walters escribió:
>
> I've had a bit of an issue with InMemoryUploadedFile instances that come 
> in request.FILES to a view. I passed one of them to another constructor to 
> initialise it, and then I tried to access the `encoding` attribute (which 
> appears in the help() for the class). I followed the class hierarchy and 
> found that it leads to FileProxyMixin, where the `encoding` attribute is 
> defined. This is where my mind is blown though:
>
>
>   def __init__(self, f, *args, **kwargs):
>> print type(f) # => > 'django.core.files.uploadedfile.InMemoryUploadedFile'>
>> print type(f.encoding) # => AttributeError: 'cStringIO.StringO' object 
>> has no attribute 'encoding'
>>
>>
>
> How can it in the first line claim that it is an InMemoryUploadedFile, but 
> in the second line, where I try to access an attribute on it, claim to be a 
> StringO? To test that this issue is not the result of the instance being 
> passed too far into my code (where my code messes something up), I tried 
> the same test in the view directly with the request.FILES['file'] instance, 
> and the same issue occurs. I should be able to continue without this 
> attribute, but now I'm just curious. If anyone knows what's going on, 
> please let me know. Thanks.
>

-- 
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/-/MYQvAXCbagIJ.
To post to this group, send email 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: Can't set static file directory.

2013-01-06 Thread Pedro J. Aramburu
That is in a development server? Why not use ./manage.py runserver? If not 
you can point apache to the wsgi file and use django itself to serve the 
static files modifying a little bit urls.py. But it's not recommended for 
production use.

https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-static-files-in-development

The built in dev server does it by default (so no need to modify urls.py).


El sábado, 5 de enero de 2013 15:38:32 UTC-3, Mārtiņš Jakubovičs escribió:
>
> Hello.
>
> I try a lot of things and can't understand, why not working STATIC_ROOT 
> and MEDIA_ROOT in settings.py.
>
> I want, that all my media and static folders is in different place that 
> python files, so I set media, static and templates to different place. 
> Templates TEMPLATE_DIRS works well, bet MEDIA_ROOT and STATIC_ROOT not.
>
> I try setup like this:
>
> /home/domain/www/my_proj/ there is project folder and all apps, and there 
> I place my htdocs folder, in which is static, templates and media folders.
>
> When i set in STATIC_ROOT = '/home/domain/www/my_proj/htdocs/static'
>
> In apache error log i got:
>
> File does not exist: /home/domain/www/my_proj/my_proj/static
>
> I don't get, why django don't want to take new setting...
>
> I use django 1.4.
>
> Thanks.
>

-- 
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/-/j9XVHZag1k0J.
To post to this group, send email 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: Can't set static file directory.

2013-01-06 Thread Pedro J. Aramburu
Because it's configured that way in apache, not in django, and it doesn't 
exist ergo the error message.

El sábado, 5 de enero de 2013 15:38:32 UTC-3, Mārtiņš Jakubovičs escribió:
>
> Hello.
>
> I try a lot of things and can't understand, why not working STATIC_ROOT 
> and MEDIA_ROOT in settings.py.
>
> I want, that all my media and static folders is in different place that 
> python files, so I set media, static and templates to different place. 
> Templates TEMPLATE_DIRS works well, bet MEDIA_ROOT and STATIC_ROOT not.
>
> I try setup like this:
>
> /home/domain/www/my_proj/ there is project folder and all apps, and there 
> I place my htdocs folder, in which is static, templates and media folders.
>
> When i set in STATIC_ROOT = '/home/domain/www/my_proj/htdocs/static'
>
> In apache error log i got:
>
> File does not exist: /home/domain/www/my_proj/my_proj/static
>
> I don't get, why django don't want to take new setting...
>
> I use django 1.4.
>
> Thanks.
>

-- 
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/-/LI1154qhJUkJ.
To post to this group, send email 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 implement CSS into Django!!!!

2013-01-06 Thread Pedro J. Aramburu
Czaro, to better understand the problem it will be good if you could tell 
us something more about how are you calling your css files from your 
templates and where are they located. I will also assume Django 1.4 to tell 
you some tips (mostly already covered).

   - Set your STATIC_ROOT.
   I use STATIC_ROOT = os.path.join(PROJECT_ROOT, 'public/static') where 
   PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)). This gives me 
   the folder where the settings file is, which is the "project level" folder. 
   I use the public subfolder to put the static and media folders.
   - Set your STATICFILES_FINDERS so it can find your files if you have 
   them on your apps.
   If they are in your apps the AppDirectoriesFinder will look on a static 
   folder within the app. It's usually good to have a subfolder with the same 
   name of the app (app_name/static/app_name) so there won't be collisions 
   when you do the collectstatic operation.
   - In your templates you can


   1.  
  But you have to check if your static template context processor is 
  there *django.core.context_processors.static* (I think it is by 
  default).
  2. Using a template tag (which is more... template-friendly? It reads 
  better I believe):
  {% load staticfiles %}
   

   - When you are on the builtin development server, Django will take care 
   of looking where the file is. You only need the collectstatic operation on 
   production time because if you do it one time, for example, django will 
   default to that file first (I think), serving you maybe an old copy of the 
   file. Collect static looks with the finders for the static files and copy 
   them onto the STATIC_ROOT.
   - If you are using another development server (like apache) and you 
   haven't pointed the static files from there you can add some tricks to the 
   urls.py 
   file 
https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-static-files-in-development
 
   and django will serve them too. For the built in runserver command it does 
   it by default so you don't have to modify anything.

I think that's all. Let us know how did it go.


El domingo, 6 de enero de 2013 10:43:49 UTC-3, bb6xt escribió:
>
>  On Sunday 06 January 2013 11:49:46 AM 
> django...@googlegroups.comwrote:
>
> Czaro Jan 05 06:12PM -0800   I've been trying to get my CSS to work with 
> my python powered site forever but I have no luck. I read the djangobook 
> and a massive load of other resources but they all say a different thing 
> and nothing worked for me. I would appreciate a few helpful steps on how to 
> get my CSS to work. Some details: I;m in development mode. I'm using 
> runserver and when i run it I only see the HTML and not the CSS. I'm also 
> not sure if my CSS files need to be hosted on a separate server. Any help 
> will be greatly appreciated. Thanks!!1   Nikolas Stevenson-Molnar 
> Jan 05 07:06PM -0800   In a production environment, yes your static files 
> (incl CSS) will need to be served outside of Django (can be on the same 
> server, but it's generally recommended to use a separate serve or CDN). On 
> your local development server (where you're using the runserver command), 
> you can use the built-in staticfiles app. This document will give you the 
> full rundown: https://docs.djangoproject.com/en/1.4/howto/static-files/   
> Essentially, you add staticfiles to your installed apps in your settings, 
> tell it where to find your static content on disk, and then use {{ 
> STATIC_URL }} in your templates.   _Nik   On 1/5/2013 6:12 PM, Czaro wrote:
>
>
>
> Hi Czaro,
>
>  
>
> I am assuming the following directory structure and django 1.4 or higher:
>
> myproject/
>
> manage.py
>
> myproject/
>
> __init__.py
>
> settings.py
>
> urls.py
>
> wsgi.py
>
> appname/
>
> __init__.py
>
> models.py
>
> tests.py
>
> views.py
>
> static/
>
> appname/
>
> mystyle.css
>
>  
>
> Like Nikolas said, ensure that 'django.contrib.staticfiles' is in the 
> installed apps, 'django.contrib.staticfiles.finders.AppDirectoriesFinder' 
> is in the STATICFILES_FINDERS and STATIC_ROOT points to the absolute path 
> to the directory where your static files should be collected to (eg 
> STATIC_ROOT = '/home/user/dj_static/'). Also be sure that your css file is 
> stored according to the above directory structure (in this case I named it 
> 'mystyle.css'). Now, just leave your STATIC_URL pointing to '/static/' (the 
> default). In your template, say in the head section, put . Finally, run 
> '$python manage.py collectstatic' in the shell, when prompted type 'yes', 
> now run '$python manage.py runserver'. Goto the page in your browser.
>
>  
>
> Hope this was helpful.
>
>  
>
> --Ab
>

-- 
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/-/KFPoSi5flY0J.
To post to this group, send email to 

Re: Django app custom settings testing

2013-01-04 Thread Pedro J. Aramburu
Thanks very much and, yes, that code is what I've found. In your personal
opinion, would you use a setup like that (
http://passingcuriosity.com/2010/default-settings-for-django-applications/)
for default settings? or is it a little bit over the top for small apps?

I think I'll try my approach for testing purposes because I really don't
need diffsettings, only the test suite "compatibility". The other way that
people seem to do it is using getattr(settings, 'SETTING_X', default value)
every time they need the setting but it seems to violate the DRY principle
and then you don't have a centralized place for the settings.

The last thing I can think of is "updating" the approach and caching the
values only when it's not in testing environment, but, how do you tell?
I thought looking for DEBUG=True but then I remembered the testing
environment set it to False to resemble the production environment. And,
lastly, would it be worth the overhead of logic for caching a few settings?

Sorry about being so "dense" with this. It's just that I'm a newbie and
trying to understand the best practices so if I Open Source the app it
won't be a piece of sh... Sorry again, I got carried away.

--
Tres42
Pedro J. Aramburu


On Fri, Jan 4, 2013 at 12:59 PM, nkryptic <nkryp...@gmail.com> wrote:

> The only thing I've seen which handles all the cases you mention is
> http://passingcuriosity.com/2010/default-settings-for-django-applications/. 
> That may also be what you were referring to about seeing something on
> github.
>
> As to your new question, I think that would work, because every time you
> need the value you'd be doing a fresh lookup.  That said, it's not ideal
> because *every time* you need the value you'd be doing a fresh lookup.
>
>
> On Thursday, January 3, 2013 4:10:37 PM UTC-5, Pedro J. Aramburu wrote:
>
>> No, you're not, but, there isn't a way to load or inject the app settings
>> so that diffsettings and other project level things (like testing) can see
>> them? That's my question. I've read something on a github repo but it seems
>> clunky and over-done. My main goal really is to change some settings on the
>> tests so I can test different scenarios.
>>
>> Right now it seems I can do it by manually changing the "constants"
>> importing app.settings, saving the old values, assigning new values and
>> restoring at the end. But, as the settings.py is loaded once, the
>> "validation" is also done once (the ImproperlyConfigured part).
>>
>> Now, my new question: If I do an object Settings or something like that,
>> and set the __getattr__ to "dinamically" get the settings of the project
>> settings and if it's not there default to a setting of the same object,
>> then I should be able to change the settings with
>> "@override_settings(SETTING_A=**True)" or "with
>> self.settings(SETTING_A=True):**".
>>
>> And, for example, on the explicit case of SETTING_B that depends on
>> SETTING_A, I could override it's getter (and setter maybe) so I could raise
>> the exceptions if needed. The thing is, I know __get__ descriptor has
>> "priority" over "__getattr__" but on the same class (or object). If i use
>> the @property decorator I will still have "precedence" over getattr? Since
>> I'm applying it's __get__ descriptor to an object inside.
>>
>> Just want to know if my approach would work. As I see it, it's like lazy
>> loading the settings so if the settings change in the project environment,
>> they should also change in the app. Or something like that is what I'm
>> trying to do.
>>
>> What do you think? What would you do?
>>
>> Thank you.
>>
>> --
>> Tres42
>> Pedro J. Aramburu
>>
>>
>> On Thu, Jan 3, 2013 at 3:37 PM, Bill Freeman <ke1...@gmail.com> wrote:
>>
>>>  This approach is only useful for modules that import app.settings and
>>> use things that it defines.  It doesn't affect things that import settings
>>> from django.conf .
>>>
>>> Your app can import settings from app, and get your settings.  That's
>>> not going to affect any other app.  If you want to affect what other apps
>>> see, you must either put the settings in the main settings file, or modify
>>> django.conf.settings itself.  This last is fraught with peril, since you
>>> can't reliably control the order in which you modify the settings object
>>> versus when other modules may use its values in a persistent way.
>>>
>>> Or am I missing your point?
>>>
>>> Bill
>>>
>>>
>>> On Thu, Jan 3, 2013 

Re: Django app custom settings testing

2013-01-03 Thread Pedro J. Aramburu
No, you're not, but, there isn't a way to load or inject the app settings
so that diffsettings and other project level things (like testing) can see
them? That's my question. I've read something on a github repo but it seems
clunky and over-done. My main goal really is to change some settings on the
tests so I can test different scenarios.

Right now it seems I can do it by manually changing the "constants"
importing app.settings, saving the old values, assigning new values and
restoring at the end. But, as the settings.py is loaded once, the
"validation" is also done once (the ImproperlyConfigured part).

Now, my new question: If I do an object Settings or something like that,
and set the __getattr__ to "dinamically" get the settings of the project
settings and if it's not there default to a setting of the same object,
then I should be able to change the settings with
"@override_settings(SETTING_A=True)" or "with
self.settings(SETTING_A=True):".

And, for example, on the explicit case of SETTING_B that depends on
SETTING_A, I could override it's getter (and setter maybe) so I could raise
the exceptions if needed. The thing is, I know __get__ descriptor has
"priority" over "__getattr__" but on the same class (or object). If i use
the @property decorator I will still have "precedence" over getattr? Since
I'm applying it's __get__ descriptor to an object inside.

Just want to know if my approach would work. As I see it, it's like lazy
loading the settings so if the settings change in the project environment,
they should also change in the app. Or something like that is what I'm
trying to do.

What do you think? What would you do?

Thank you.

--
Tres42
Pedro J. Aramburu


On Thu, Jan 3, 2013 at 3:37 PM, Bill Freeman <ke1g...@gmail.com> wrote:

> This approach is only useful for modules that import app.settings and use
> things that it defines.  It doesn't affect things that import settings from
> django.conf .
>
> Your app can import settings from app, and get your settings.  That's not
> going to affect any other app.  If you want to affect what other apps see,
> you must either put the settings in the main settings file, or modify
> django.conf.settings itself.  This last is fraught with peril, since you
> can't reliably control the order in which you modify the settings object
> versus when other modules may use its values in a persistent way.
>
> Or am I missing your point?
>
> Bill
>
>
> On Thu, Jan 3, 2013 at 12:05 AM, Pedro J. Aramburu <
> paramb...@tres42.com.ar> wrote:
>
>> Hi, I'm having troubles using the override_settings decorator. The thing
>> is I'm writing an app that has it's own settings and I'm doing it with the
>> approach of putting a settings.py file on the app folder with something
>> like this:
>>
>> from django.conf import settings
>> from django.core.exceptions import ImproperlyConfigured
>>
>>
>> SETTING_A = getattr(settings, 'APP_SETTING_A', False)
>>
>> SETTING_B = getattr(settings, 'APP_SETTING_B', False)
>>
>> if SETTING_A and not SETTING_B:
>> raise ImproperlyConfigured('"SETTING_A" is set to True but
>> "SETTING_B" is missing.')
>> -
>> Where SETTING_B should be a tuple that depends on SETTING_A (I know I
>> didn't type check yet). Then I use the settings importing app.settings. The
>> thing is, I believe, that the settings are loaded once and as they're
>> outside the project settings.py, override settings doesn't have any effect.
>>
>> What would you recommend?
>>
>> --
>> 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/-/22xrwU84AG8J.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Django app custom settings testing

2013-01-02 Thread Pedro J. Aramburu
Hi, I'm having troubles using the override_settings decorator. The thing is 
I'm writing an app that has it's own settings and I'm doing it with the 
approach of putting a settings.py file on the app folder with something 
like this:

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured


SETTING_A = getattr(settings, 'APP_SETTING_A', False)

SETTING_B = getattr(settings, 'APP_SETTING_B', False)

if SETTING_A and not SETTING_B:
raise ImproperlyConfigured('"SETTING_A" is set to True but "SETTING_B" 
is missing.')
-
Where SETTING_B should be a tuple that depends on SETTING_A (I know I 
didn't type check yet). Then I use the settings importing app.settings. The 
thing is, I believe, that the settings are loaded once and as they're 
outside the project settings.py, override settings doesn't have any effect.

What would you recommend?

-- 
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/-/22xrwU84AG8J.
To post to this group, send email 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!!! Admin Site app name rename

2012-12-06 Thread Pedro J. Aramburu
I understand that but, there isn't a way to safely change the app_label 
attribute. As I understand, django manages the apps through INSTALLED_APPS 
and django admin strips the app name from the module "path" (please correct 
me). For example:

Say I have the catalog app (package). Inside I have the Product model. 
Then, django admin takes the registered models and for each get it's 
model._meta.app_label (
https://github.com/django/django/blob/1.4.2/django/contrib/admin/sites.py#L337) 
and group.

The model._meta.app_label is "created" by the ModelBase class at 
https://github.com/django/django/blob/1.4.2/django/db/models/base.py#L50. 
It looks one level up from the model module by splitting the string by the 
dots. In this case, "catalog.models", so the app_label would be "catalog". 
If it were "some.thing.catalog.models" the app_label would also be 
"catalog". The thing is that the app_label is used on other places like in 
https://github.com/django/django/blob/1.4.2/django/db/models/base.py#L205 to 
get a model so if I rename it on the class Meta it would raise an 
error. It's suppose to be used when you have models inside submodules of 
your app (
https://docs.djangoproject.com/en/1.4/ref/models/options/#app-label). Also, 
if I rename it arbitrarily I can't rename it to the spanish equivalent 
because of the "tilde" or however you say it. As an example, catalog 
(catalogue) in spanish is catálogo so it wouldn't be a valid module name. 

So, there's the dilemma. Any thoughts? I think I may have found a way but I 
will need to discuss it with active django developers because it will need 
tinkering of the Django source code and I don't want to mess it up. Where 
do I get in touch with some developer?



El miércoles, 5 de diciembre de 2012 17:53:43 UTC-3, Chris Cogdon escribió:
>
> Most objects have a way of giving them a "label" attribute, or even a 
> "short_description" attribute. So, if you didn't want to go to the trouble 
> of internationalizing (i17ning?) your application, just use those idioms to 
> create visible names for your custom-created models and forms, etc.
>
> To change the django-supplied names, then that should just be a matter of 
> switching the language in the settings.
>
> If you want to change the "Django Administration" name to something app 
> specific, then I would supply a new admin/base_site.html template (copy the 
> one from django-source/contrib/admin/templates/admin, modify it, and put it 
> into a templates/admin folder in your own app)
>
>
>
> On Tuesday, December 4, 2012 8:58:38 PM UTC-8, Pedro J. Aramburu wrote:
>>
>> I hope someone could help me. My main language is Spanish but when I 
>> write code I like it to be en english. Being that way it will be easier to 
>> open source something in the future. The main problem is the app name in 
>> the Admin Site. 
>> For example, I'm writing a kind of eCommerce site without the ability to 
>> make transactions (or buy) online. So it's more like a product 
>> catalog/catalogue. For that reason I created a catalog app with the desired 
>> modules, etc. When I configure the admin site then, I have the Catalog 
>> section with the CRUD for the models but, as my main language is Spanish, 
>> my clients also read Spanish so instead of "Catalog" it should say 
>> "Catálogo".
>> I've read the documentation and googled a lot and find some "solutions" 
>> but they were pretty old. The most promising was to modify the admin site 
>> templates and put something like the following on the __init__.py file:
>>
>> from django.utils.translation import ugettext_noop as _
>>
>> _('Catalog')
>>
>>
>> That way the makemessages would pick the string and then I could 
>> translate it. Well, it didn't work.
>>
>> I found that the templates have some translation applied to them but I 
>> then realized that the app.name isn't translated but the surroundings 
>> are (
>> https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/index.html).
>>  
>> The app.name is just a string interpolation.
>>
>> Have been any progress regarding this subject? Have anyone had to deal 
>> with something like this? Can I change the app name in some way or the 
>> app_label? What's the difference? How should approach it? Isn't somewhere a 
>> verbose_name for apps or something? Even if it's hard coded, with no 
>> translation.
>>
>> Thank you in advance for your time.
>>
>

-- 
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/-/nZ9P2g4qnvgJ.
To post to this group, send email 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 introduce a text area as a field of a database entry

2012-12-06 Thread Pedro J. Aramburu
CharField is for "short" strings mostly under 255 of length. TextField is 
for "unlimited" text (the length depends of the database engine). If you 
just want a textarea for the CharField then you will need to replace the 
default widget. You'll need to read a little about Forms to change the 
widget of the field 
(https://docs.djangoproject.com/en/1.4/ref/forms/widgets/) and the Admin 
interface to see how to set a custom Form.

El jueves, 6 de diciembre de 2012 08:18:38 UTC-3, joy escribió:
>
> My model.py
>
> ##model.py
> from django.db import models
>
> class Text(models.Model):
>pag= models.CharField(max_length=10)  
>content = models.CharField(max_length=500) 
> ##should i put something different in the previous line to have a textarea 
> in the admin view of this field?
>
>def __unicode__(self):
>return self.pag
>
> thanks Joy
>

-- 
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/-/b1OPVXYJ-WMJ.
To post to this group, send email 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 include html in your text area

2012-12-06 Thread Pedro J. Aramburu
Joy, look into the database if it is being saved without escaping. If 
that's the case you need to render it without escaping marking it as safe 
with the safe filter. For example:

This will not be escaped: {{ data|safe }}

or you can use a template block like this:

{% autoescape off %}
Hello {{ name }}{% endautoescape %}

Read more about it 
at: 
https://docs.djangoproject.com/en/1.4/topics/templates/#automatic-html-escaping

If you wan't some text field where you can format take a look at:

https://github.com/aljosa/django-tinymce

or

https://github.com/shaunsephton/django-ckeditor


El jueves, 6 de diciembre de 2012 15:07:32 UTC-3, joy escribió:
>
> May i use html inside a text area? (i need some link in my text but the 
> TextField of my object Text gives me back the html without formatting it)
>
> Is there any workaround?
>
> Joy
>

-- 
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/-/EDyVq6fWZ28J.
To post to this group, send email 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.



HELP!!! Admin Site app name rename

2012-12-05 Thread Pedro J. Aramburu
I hope someone could help me. My main language is Spanish but when I write 
code I like it to be en english. Being that way it will be easier to open 
source something in the future. The main problem is the app name in the 
Admin Site. 
For example, I'm writing a kind of eCommerce site without the ability to 
make transactions (or buy) online. So it's more like a product 
catalog/catalogue. For that reason I created a catalog app with the desired 
modules, etc. When I configure the admin site then, I have the Catalog 
section with the CRUD for the models but, as my main language is Spanish, 
my clients also read Spanish so instead of "Catalog" it should say 
"Catálogo".
I've read the documentation and googled a lot and find some "solutions" but 
they were pretty old. The most promising was to modify the admin site 
templates and put something like the following on the __init__.py file:

from django.utils.translation import ugettext_noop as _

_('Catalog')


That way the makemessages would pick the string and then I could translate 
it. Well, it didn't work.

I found that the templates have some translation applied to them but I then 
realized that the app.name isn't translated but the surroundings are 
(https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/index.html).
 
The app.name is just a string interpolation.

Have been any progress regarding this subject? Have anyone had to deal with 
something like this? Can I change the app name in some way or the 
app_label? What's the difference? How should approach it? Isn't somewhere a 
verbose_name for apps or something? Even if it's hard coded, with no 
translation.

Thank you in advance for your time.

-- 
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/-/pv0olVGwqNEJ.
To post to this group, send email 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.