why cannot delete attribute id of model?

2016-01-11 Thread Xudong Zhang
I want to delete the id attribute of a model but failed, it comlains that 
the model has no attribute 'id'. But I use hasattr() checked it and it does 
has the attribute.

My sample code

product = Product.objects.get(pk=_id)
if hasttr(product, 'id'):
del product.id

I also tried delattr(product, 'id'), got same result.

Exception Type: AttributeError Exception Value: 

'Product' object has no attribute 'id'


I use python 3 and django 1.8.

Anyone could help here?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75e6687d-d7fe-4681-ba30-8ed74044a03e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Execute code which runs on the database only when the server is running - and doesn't need users to view pages.

2016-01-11 Thread Tony Flury
I have a small background task (executed by using threading.Timer) which I 
want to start up when the server starts, but doesn't need to start when a 
management command runs.

The background task performs operations on the database, so relies on 
importing the models etc.

I have tried using the App.ready hook introduced in Django 1.7, which was 
touted as correct way to do this, but the ready hook is executed during 
management commands as well, and then the management command fails to exit 
- due to the presence of the timer thread - and I don't want Management 
commands to execute this code in anyway.

What is the correct way to run code which uses the models and all the 
wonderful Django stuff, and which is executed only when the server runs 
(and not during a management command).

Currently the only way I can run management command is to comment out my 
timer start call, whenever I want to run management commands. This wont be 
an option when it comes to needing to execute management commands on the 
production server.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7632c40e-0855-453d-95f9-cb2f552ddd22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Execute code which runs on the database only when the server is running - and doesn't need users to view pages.

2016-01-11 Thread Andreas Kuhne
Hi,

Wouldn't it be possible to use celery and tasks for this purpose?
http://www.celeryproject.org/

You could have it running all the time and have a flag in the database for
when the server is running?

Regards,

Andréas

2016-01-11 9:59 GMT+01:00 Tony Flury :

> I have a small background task (executed by using threading.Timer) which I
> want to start up when the server starts, but doesn't need to start when a
> management command runs.
>
> The background task performs operations on the database, so relies on
> importing the models etc.
>
> I have tried using the App.ready hook introduced in Django 1.7, which was
> touted as correct way to do this, but the ready hook is executed during
> management commands as well, and then the management command fails to exit
> - due to the presence of the timer thread - and I don't want Management
> commands to execute this code in anyway.
>
> What is the correct way to run code which uses the models and all the
> wonderful Django stuff, and which is executed only when the server runs
> (and not during a management command).
>
> Currently the only way I can run management command is to comment out my
> timer start call, whenever I want to run management commands. This wont be
> an option when it comes to needing to execute management commands on the
> production server.
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7632c40e-0855-453d-95f9-cb2f552ddd22%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALXYUb%3DOuB5ocYg63QnJg52vTqj64BNUDPz_EcPCrpbasfo%3DTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: CachedStaticFilesStorage and collectstatic for the very first time

2016-01-11 Thread Andrzej Mateja
Hi Simon,

You are right. Package easy_select2 calls the url method, which you can see 
here:
https://github.com/asyncee/django-easy-select2/blob/master/easy_select2/widgets.py#L32

I'm going to report them that problem and I'll try also find a solution.

Cheers
Andrzej

W dniu sobota, 9 stycznia 2016 04:20:28 UTC+1 użytkownik Simon Charette 
napisał:
>
> Hi Andrzej,
>
> If I understand correctly you can't run `collectstatic` with `DEBUG = 
> False`
> if you didn't run it with `DEBUG = True` beforehand.
>
> I can't be sure without the full traceback but I suspect one of your
> applications calls 
> `django.contrib.staticfiles.storage.staticfiles_storage.url`
> at module level triggering the `ValueError` since the hashed path to the
> specified asset has not been computed and cached yet.
>
> If you want to use `CachedStaticFilesStorage` you'll have to make sure not 
> to
> issue such calls in modules loaded when `collectstatic` runs.
>
> Could you possible share the full traceback of the error raised when
> `collectstatic --traceback` is run.
>
> Simon
>
> Le vendredi 8 janvier 2016 15:36:54 UTC-5, Andrzej Mateja a écrit :
>>
>> Thank you Simon for sharing your remarks although it is not the case what 
>> you described. I'm talking about deploying brand new project which is 
>> depending on external application with its own static files. Project should 
>> have also no static files collected yet, static files cashing enabled 
>> (using CachedStaticFilesStorage) and empty cache. In such scenario I always 
>> get ValueError exception in hashed_name method from HashedFilesMixin 
>> class. I'm never able to complete collectstatic with DEBUG = False. My 
>> workaround is:
>> 1. set DEBUG = True
>> 2. run python manage.py collectstatic
>> 3. set DEBUG = False
>> 4. run python manage.py collectstatic again
>>
>> In step 2. all static files from external application are copied to 
>> STATIC_ROOT which enables me to proceed. This workaround is not very 
>> beautiful nor django-like. Why? Because there is no such behaviour when I 
>> fell back to default StaticFilesStorage.
>>
>> Andrzej
>>
>> W dniu piątek, 8 stycznia 2016 19:31:17 UTC+1 użytkownik Simon Charette 
>> napisał:
>>>
>>> Hi Andrzej,
>>>
>>> CachedStaticFilesStorage requires you run `collectstatic` before 
>>> deploying
>>> your application in production (non-DEBUG) mode.
>>>
>>> The deployment should look like that:
>>>
>>> 1) Update your code to the latest version.
>>> 2) Run `collectstatic` to cache paths to hashed versions of your assets.
>>> 3) Restart your server.
>>>
>>> Simon
>>>
>>> Le vendredi 8 janvier 2016 09:19:30 UTC-5, Andrzej Mateja a écrit :

 Hi,

 I have a problem with using CachedStaticFilesStorage as a 
 STATICFILES_STORAGE and with external package containing its own static 
 files (easy_select2 to be specific). If I deploy my project for the very 
 first time with DEBUG = False, empty cache and no external package static 
 files copied to STATIC_ROOT I got an exception: *ValueError: The file 
 'easy_select2/js/init.js' could not be found with 
 >>> 0x>*. with every manage.py command, especially 
 collectstatic. I understand that behaviour of HashedFilesMixin is legit 
 but 
 I'm not so sure if it should be like that when I want to collect my static 
 files.

 As a workaround I set temporally DEBUG = True, run manage.py 
 collectstatic, set DEBUG back to False and do the rest. But I have a 
 feeling that it is not the right way to do it especially because there is 
 no problem when StaticFilesStorage is used - no need to do such tricks.

 Best regards
 Andrzej

>>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9b9aa065-3399-435a-9f59-24fb50b45d1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why cannot delete attribute id of model?

2016-01-11 Thread Vijay Khemlani
I usually do

product.id = None
product.pk = None

But I'm not sure whether that's the best way to do it

On Mon, Jan 11, 2016 at 4:25 AM, Xudong Zhang  wrote:

> I want to delete the id attribute of a model but failed, it comlains that
> the model has no attribute 'id'. But I use hasattr() checked it and it does
> has the attribute.
>
> My sample code
>
> product = Product.objects.get(pk=_id)
> if hasttr(product, 'id'):
> del product.id
>
> I also tried delattr(product, 'id'), got same result.
>
> Exception Type: AttributeError Exception Value:
>
> 'Product' object has no attribute 'id'
>
>
> I use python 3 and django 1.8.
>
> Anyone could help here?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/75e6687d-d7fe-4681-ba30-8ed74044a03e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei2i%3DZXifi7RW6tochQM7kEoamU2%3D%2BFfQxxSbxpriKBQfw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Execute code which runs on the database only when the server is running - and doesn't need users to view pages.

2016-01-11 Thread Tony Flury
Andreas,

Thanks for your answer. Certainly it looks like running celery might alleviate 
the issue with threading stopping the management commands, but the problem with 
your suggestion lies with that flag. If My code was able to identify that the 
server is running to the point of being able to set the flag it would also know 
enough to start my background thread. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a65bcce5-6270-4c88-912c-afee49c85631%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Execute code which runs on the database only when the server is running - and doesn't need users to view pages.

2016-01-11 Thread Andreas Kuhne
Oh ok,

Sorry I misunderstood your problem. How about running the celery task and
then checking if http://localhost is up?

Regards,

Andréas

2016-01-11 13:31 GMT+01:00 Tony Flury :

> Andreas,
>
> Thanks for your answer. Certainly it looks like running celery might
> alleviate the issue with threading stopping the management commands, but
> the problem with your suggestion lies with that flag. If My code was able
> to identify that the server is running to the point of being able to set
> the flag it would also know enough to start my background thread.
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a65bcce5-6270-4c88-912c-afee49c85631%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALXYUbkshnuZrPy9yuPo0DscAY7%3DehuJfjeZ%3DuRcwqdocj03Og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: why cannot delete attribute id of model?

2016-01-11 Thread Tony Flury
Why do you want to delete the id field. The idea of a primary key field is 
central to relational databases. If you to suppress the automatically generated 
primary key then you need to assign another field as the unique primary key: as 
far as I know that will prevent the id field being created. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/633880e3-05fe-434a-979d-8b28c4158bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why cannot delete attribute id of model?

2016-01-11 Thread Vijay Khemlani
At least I use it as part of the process to save a copy of an existing
model instance

On Mon, Jan 11, 2016 at 9:35 AM, Tony Flury 
wrote:

> Why do you want to delete the id field. The idea of a primary key field is
> central to relational databases. If you to suppress the automatically
> generated primary key then you need to assign another field as the unique
> primary key: as far as I know that will prevent the id field being created.
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/633880e3-05fe-434a-979d-8b28c4158bcd%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei23AmAJqoPaW6kf36219jJD5dTS%2BBd5zMZSgFBrMYA43w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: why cannot delete attribute id of model?

2016-01-11 Thread Tony Flury
Stating the value of either the id or pk field to None is the recommended way 
to rest the primary key when you take a copy of a record, but Xudong wanted to 
delete the field entirely: which I don't understand. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/84c08106-fee8-43e3-94e0-ca578c894ba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unable to run django tests

2016-01-11 Thread varun naganathan
HI,
I recently switched my laptop.I have run django unittests previously also.
Im using the command "PYTHONPATH=..:$PYTHONPATH ./runtests.py bug1233"
it shows me an error :
Please install test dependencies first: 
$ pip install -r requirements/py2.txt

however when i run the pip install command:
i get:


Requirement already satisfied (use --upgrade to upgrade): bcrypt in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/base.txt (line 
1))
Requirement already satisfied (use --upgrade to upgrade): docutils in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/base.txt (line 
2))
Requirement already satisfied (use --upgrade to upgrade): jinja2>=2.7 in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/base.txt (line 
3))
Requirement already satisfied (use --upgrade to upgrade): numpy in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/base.txt (line 
4))
Requirement already satisfied (use --upgrade to upgrade): Pillow in 
/usr/lib/python2.7/dist-packages (from -r requirements/base.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): PyYAML in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/base.txt (line 
6))
Requirement already satisfied (use --upgrade to upgrade): pytz>dev in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/base.txt (line 
7))
Requirement already satisfied (use --upgrade to upgrade): selenium in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/base.txt (line 
8))
Requirement already satisfied (use --upgrade to upgrade): sqlparse in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/base.txt (line 
9))
Requirement already satisfied (use --upgrade to upgrade): python-memcached 
in /usr/local/lib/python2.7/dist-packages (from -r requirements/py2.txt 
(line 2))
Requirement already satisfied (use --upgrade to upgrade): mock in 
/usr/local/lib/python2.7/dist-packages (from -r requirements/py2.txt (line 
3))
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.1 in 
/usr/local/lib/python2.7/dist-packages (from bcrypt->-r 
requirements/base.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in 
/usr/lib/python2.7/dist-packages (from bcrypt->-r requirements/base.txt 
(line 1))
Requirement already satisfied (use --upgrade to upgrade): pycparser in 
/usr/local/lib/python2.7/dist-packages (from cffi>=1.1->bcrypt->-r 
requirements/base.txt (line 1))
Cleaning up...


Please help.I have tried to debug the runtests.py script but was unable to 
spot the error.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/79f7f90c-5181-42c9-98ed-dd924687acf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to view the generated SQL for test models?

2016-01-11 Thread Brutus Schraiber
Hi all…

I have some models in a `test.py` file. How can I view the SQL that will be 
generated for them?

Something like `django-admin sql` or similar but for models defined in 
`test.py` not in `models.py`.

Regards,
-brutus

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/322f2058-92ff-4e52-8fea-19ca6d745082%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to define custom labels for admin.ModelAdmin readonly fields.

2016-01-11 Thread Jonty Needham
I have a ModelAdmin class where I am using callables to define accessors to
a foreign key's field.

I.e.

class MyAdmin(admin.ModelAdmin):

def field_name(self, obj):
return obj.fk.field_name

readonly_fields=(field_name, other_field)


Ultimately I need to translate the labels, but I need access to them first
and I can't see from the ModelAdmin code where that is.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANOQRbxAqzHuL77UXdSA8j9ekw%2B%2Be3-0cY%2BJJ%2BoAWVfSQngOfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Upgrading to 1.9 - Any Easy Guide ?

2016-01-11 Thread Vibhu Rishi
Hi

I work on a hobby project on and off which is based on django. After a long
gap, I picked up the work again. In the meantime, it seems that django has
been evolving faster than I have been working. I am currently on 1.6 (which
I think i had upgraded from 1.4 or 1.3 as my starting base). However, the
current new version of Django is 1.9

I created a new virtual environment and used pip to get the latest version
of django.

Now I am getting a lot of errors.

Is there an easy way to upgrade django ? Or a howto for best practices ?

Thanks
V.

-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPiONwmXN%2BVPs7OhpkSL1mMNVskqkVo20UFoY0cEoR5kcUDwXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to define custom labels for admin.ModelAdmin readonly fields.

2016-01-11 Thread Erik Cederstrand

> Den 11. jan. 2016 kl. 23.21 skrev Jonty Needham :
> 
> I have a ModelAdmin class where I am using callables to define accessors to a 
> foreign key's field.
> 
> I.e.
> 
> class MyAdmin(admin.ModelAdmin):
> 
> def field_name(self, obj):
> return obj.fk.field_name
> 
> readonly_fields=(field_name, other_field)
> 
> 
> Ultimately I need to translate the labels, but I need access to them first 
> and I can't see from the ModelAdmin code where that is.

It sounds like you're looking for the 'short_description' option described in 
https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display

Erik

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9E3DD769-26A9-4DD5-A1D7-08327ECB5358%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading to 1.9 - Any Easy Guide ?

2016-01-11 Thread 'Tom Evans' via Django users
On Mon, Jan 11, 2016 at 4:36 PM, Vibhu Rishi  wrote:
> Hi
>
> I work on a hobby project on and off which is based on django. After a long
> gap, I picked up the work again. In the meantime, it seems that django has
> been evolving faster than I have been working. I am currently on 1.6 (which
> I think i had upgraded from 1.4 or 1.3 as my starting base). However, the
> current new version of Django is 1.9
>
> I created a new virtual environment and used pip to get the latest version
> of django.
>
> Now I am getting a lot of errors.

That is the hard way.

>
> Is there an easy way to upgrade django ? Or a howto for best practices ?
>

(Releases have version components: "1.9.1" is major release 1, minor
release 9, minor-minor release 1)

If you are on release 1.N, update to release 1.N+1.Y (with Y being the
highest released minor-minor version), and step through its release
notes dealing with all the things which have changed or been
deprecated, and update them accordingly. Run your test suite to
determine if anything has been broken (pro tip: tests are useful - you
might want to write some if you don't already test your most common
features)

Then, do the next minor release until you reach the latest release.

A more complete process would be to update to 1.N+1, ensure tests pass
and deprecated behaviour handled, THEN subsequently to 1.N+1.Y, ensure
tests pass and only then go to the next minor version. That can be a
bit paranoid, as (deliberately) not much functionality or breaking
changes are added in minor-minor releases of django.

Release notes are here:
https://docs.djangoproject.com/en/1.9/releases/

Cheers

Tom

PS: Best practices are not to fall that far behind!

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1LiKM3pzb1bAFTk88iLmbJKWpEaa3NTMdsVw3WJ%2BRwbdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Post Office - html_content KO with attachment

2016-01-11 Thread 06userit
I am using Django 1.8.7 and Django-post-office to send mails with 
attachment (for instance, one pdf file "test.pdf").

1) Strangely when a mail is sent with an attachment and an HTML_CONTENT (eg 
"Hello World"), the mail is empty, except the file which is correctly 
attached. This HTML_CONTENT does not contain html syntax (for testing 
purpose, such as  ), to keep it very simple.

2) When the mail is sent with same attachment and a (simple) CONTENT (eg 
"Hello World"), the mail is correctly rendered, with the file correctly 
attached

3) when the mail is sent with no attachment and an HTML_CONTENT (eg "Hello 
World"), the mail is correctly rendered (ie, mail is not empty).

So pb is that it is not possible to send mails with attachements and 
html_content : mail is empty (but file is correctly attached).

Has someone already encountered this behaviour with django-post-office ? 
Thks.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/99e3ebdc-2fd6-47d9-a072-1d40a48f4258%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to define custom labels for admin.ModelAdmin readonly fields.

2016-01-11 Thread Jonty Needham
Thanks so much. Sorted competely!

On Mon, Jan 11, 2016 at 5:44 PM, Erik Cederstrand  wrote:

>
> > Den 11. jan. 2016 kl. 23.21 skrev Jonty Needham  >:
> >
> > I have a ModelAdmin class where I am using callables to define accessors
> to a foreign key's field.
> >
> > I.e.
> >
> > class MyAdmin(admin.ModelAdmin):
> >
> > def field_name(self, obj):
> > return obj.fk.field_name
> >
> > readonly_fields=(field_name, other_field)
> >
> >
> > Ultimately I need to translate the labels, but I need access to them
> first and I can't see from the ModelAdmin code where that is.
>
> It sounds like you're looking for the 'short_description' option described
> in
> https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display
>
> Erik
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9E3DD769-26A9-4DD5-A1D7-08327ECB5358%40cederstrand.dk
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANOQRbz5fecLyvotOkFXuSdcdgisFcL2Vt7zqBXGSh01gahFNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


css color for row based on fieldValue in admin.TabularInline

2016-01-11 Thread Vanhecke Mario
Hi,

Does anyone know how I can set the css class for a field or row based on 
the fieldValue in the TabularInline?

Thx

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d7fade28-b2a0-43ba-a088-541c99e6d1cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.