Django Celery throwing runtime warnings for naive times

2014-04-28 Thread heidi

  
I run an online game with Django 1.6 and Celery 3.1.11. Kombu is 3.0.15.

Recently I had problems with Celery and DST, so I decided to run the whole 
site on UTC and save myself the bother of worrying about timezones.

The relevant parts of my settings.py:

TIME_ZONE = 'UTC'
USE_TZ = True
CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'UTC'

Now, whenever I send *any* delayed task, I see a bunch of RuntimeWarnings 
that complain about naive datetimes. I went into my settings.py and turned 
this into an exception, and this is the traceback that resulted:

[2014-04-18 15:03:49,748: INFO/MainProcess] Received task: sometask[sometaskid] 
eta:[2014-04-19 00:33:32.410032+00:00][2014-04-18 15:03:50,130: 
ERROR/MainProcess] Error in timer: RuntimeWarning(u'DateTimeField TaskState.eta 
received a naive datetime (2014-04-18 17:50:19.547046) while time zone support 
is active.',)Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 171, 
in apply_entry
entry()
  File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 64, 
in __call__return self.fun(*self.args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 132, 
in _reschedulesreturn fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/events/snapshot.py", line 
73, in capture
self.state.freeze_while(self.shutter, clear_after=self.clear_after)
  File "/usr/local/lib/python2.7/dist-packages/celery/events/state.py", line 
421, in freeze_whilereturn fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/events/snapshot.py", line 
70, in shutter
self.on_shutter(self.state)
  File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 145, 
in on_shutter
_handle_tasks()
  File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 139, 
in _handle_tasks
self.handle_task(task)
  File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 105, 
in handle_task
task_id=uuid, defaults=defaults)
  File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 128, 
in update_task
obj.save()
  File "/usr/local/lib/python2.7/dist-packages/djcelery/models.py", line 358, 
in save
super(TaskState, self).save(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 
545, in save
force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 
573, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, 
update_fields)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 
635, in _save_table
forced_update)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 
679, in _do_updatereturn filtered._update(values) > 0
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 
507, in _updatereturn query.get_compiler(self.db).execute_sql(None)
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 
975, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 
771, in execute_sql
sql, params = self.as_sql()
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 
940, in as_sql
val = field.get_db_prep_save(val, connection=self.connection)
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", 
line 353, in get_db_prep_save
prepared=False)
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", 
line 914, in get_db_prep_value
value = self.get_prep_value(value)
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", 
line 906, in get_prep_valueRuntimeWarning)RuntimeWarning: DateTimeField 
TaskState.eta received a naive datetime (2014-04-18 17:50:19.547046) while time 
zone support is active.


As you can see, none of the traceback is due to my code, so I do not know 
how to proceed. I could merely leave the warnings in (if I recall 
correctly, Celery defaults time offsets to the CELERY_TIMEZONE in 
settings.py, and this is what I want anyway) but my OCD is screaming out at 
me to get this fixed. Plus, I can't ctrl-F to find any warning that *are*due to 
my code.

Any advice?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7aebb9f9-c627-4f6f-ac20-25324c26a3b1%40googlegroups.com.
For more options, visit 

Database update weirdness

2014-02-04 Thread heidi
 

I am developing a game in which the quantity of rebels updates after a turn 
change. Rebels are represented as integers from 0 to 100 in the (MySQL) 
database.

When I save, this happens:

print world.rebels>>> 0

rebstab = 0
world.rebels += rebstab
world.save()
print world.rebels>>> 0

However, when I use F() expressions (as I gather I should to prevent race 
conditions), this happens:

print world.rebels>>> 0

rebstab = 0
world.rebels = F('rebels') + rebstab
world.save()
print world.rebels>>> 100

What's going on?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d49909f9-180d-4144-89c5-dcf00bf8f560%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Weird deletions in Django

2014-02-04 Thread heidi
On Tuesday, February 4, 2014 6:37:55 AM UTC, Avraham Serour wrote:
>
> Sending an email can be faulty, I would use a logger and write the 
> stacktrace 
> Also, is it possible that something other than you django application it's 
> agreeing the database?
>
I have a forum accessing the database but they have completely separate 
tables so I can't see how that would affect things. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/15c69210-b94c-4680-aac7-55b304bb9e75%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Collapsible inlines in Django Admin

2014-02-03 Thread heidi
 

Is there an up-to-date option for allowing collapsible inlines in the 
Django admin site?

I've looked at https://code.djangoproject.com/ticket/494, How to add 
'collapse' to a Django 
StackedInlineand
 Grappelli, but none of them seem to work for Django 1.6.1.

Any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bcde9735-df37-42d0-a3d4-9fd5f66e2059%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Weird deletions in Django

2014-02-03 Thread heidi
 

I have a web game in which an alliance can have multiple members. This is 
represented by a foreign key field on each member's class (seeing as a 
member can only be part of one alliance).

I've been getting weird instances of worlds and alliances being deleted. I 
narrowed it down to where I was sure the worlds were getting deleted only 
because the alliances were, so I removed the cascade deletion. However, I 
still cannot figure out for the life of me *why* the alliances are being 
deleted in the first place.

I overrode the custom delete method like so:
class Alliance(models.Model): 
... 
def delete(self, *args, **kwargs): 
mail.send_mail('Alliance Deletion', '%s has been deleted.' \ 
% self.alliance_name, 'f...@email.com', ['t...@email.com']) 
super(Alliance, self).delete(*args, **kwargs)


However, at least one alliance has been deleted where I did not get an 
email sent to me. I gather this is because I must be calling delete() from 
a QuerySet, but I have been over my code with a fine-toothed comb and there 
is precisely one occasion where I call delete() on any alliance instance, 
and it's not over a QuerySet.

Is there a way to track down what is causing this, or to find out what 
function has executed the delete of an object?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e1ee2b07-6685-41e0-a7c4-9b45cd1eba84%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Password reset not working.

2014-01-30 Thread heidi
Thank you so much! Fixed now. How I missed that I have no idea.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21d4d658-a335-48ef-b8a9-268de6dbf363%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Password reset not working.

2014-01-30 Thread heidi
I'm using Django 1.6.1, and password reset is not working. When users enter 
their email, 502 occurs and this is sent to me:

Traceback (most recent call last):

  File 
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 
114, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)

  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", 
line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File 
"/usr/local/lib/python2.7/dist-packages/django/contrib/auth/views.py", line 
158, in password_reset
form.save(**opts)

  File 
"/usr/local/lib/python2.7/dist-packages/django/contrib/auth/forms.py", line 
256, in save
email = loader.render_to_string(email_template_name, c)

  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", 
line 164, in render_to_string
return t.render(Context(dictionary))

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
line 140, in render
return self._render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
line 134, in _render
return self.nodelist.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
line 840, in render
bit = self.render_node(node, context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
line 854, in render_node
return node.render(context)

  File 
"/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", 
line 447, in render
six.reraise(*exc_info)

  File 
"/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", 
line 433, in render
url = reverse(view_name, args=args, kwargs=kwargs, 
current_app=context.current_app)

  File 
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
509, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, 
**kwargs))

  File 
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
429, in _reverse_with_prefix
(lookup_view_s, args, kwargs, len(patterns), patterns))

NoReverseMatch: Reverse for 'auth_password_reset_confirm' with arguments 
'('MQ', u'3op-83ceb0bee07385a12e2a')' and keyword arguments '{}' not found. 
0 pattern(s) tried: []


Relevant parts of urls.py:

url(r'^login/$',
auth_views.login,
{'template_name': 'registration/login.html'},
name='auth_login'),
url(r'^logout/$',
auth_views.logout,
{'template_name': 'registration/logout.html'},
name='auth_logout'),
url(r'^password/change/$',
auth_views.password_change,
name='auth_password_change'),
url(r'^password/change/done/$',
auth_views.password_change_done,
name='password_change_done'),
url(r'^password/reset/$',
auth_views.password_reset,
name='auth_password_reset'),

url(r'^password/reset/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
auth_views.password_reset_confirm,
name='password_reset_confirm'),
url(r'^password/reset/complete/$',
auth_views.password_reset_complete,
name='auth_password_reset_complete'),
url(r'^password/reset/done/$',
auth_views.password_reset_done,
name='password_reset_done'),

As far as I can see I have it correctly updated for the latest version of 
Django. What's wrong, and how do I fix it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/049d1f4a-c60e-4f08-917b-f955ab302a04%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Upload files

2008-04-08 Thread Heidi Bustamante

Hello, anyone has an example of how to upload images, I also doubt if
the same thing to upload any files (pdf, zip, etc.)?


Heidi

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



Get number of the day

2008-04-01 Thread Heidi Bustamante

Hello
A date anyone, how to get the number of the day that corresponds

Thanks

Heidi

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