Re: Reading from a file and displaying into a table on the web app.

2014-04-28 Thread Ravi Hemnani
Hey, 

Sorry to reply so late. I figured that thing out and i was able to send the 
results into a table successfully. 

Thanks for the help :D

On Thursday, 24 April 2014 20:23:29 UTC+5:30, Erik Cederstrand wrote:
>
>
> Den 24/04/2014 kl. 16.46 skrev Ravi Hemnani 
> >: 
>
>
> > def table(request): 
> > with open('/home/ravi/python/temp.txt', 'r') as f: 
> > for line in f: 
> > context = {'line': line} 
>
> Here you are ovwewriting 'content' on every iteration. When the loop 
> exits, only the last line in the file will be in context. You want 
> something like this instead: 
>
> def table(request): 
> with open('/home/ravi/python/temp.txt', 'r') as f: 
> context = {'lines': f.readlines()} 
>
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a35af90c-ae87-4f16-9cbb-cf37c793bb2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


migrate command fails with foreign key to user model

2014-04-28 Thread Ryan
I have used django in the past, but not for some time.  So the changes 
surrounding the user models are new to me.  I downloaded v1.7b2 and 
proceeded to start a new development I am planning.  However I came across 
a problem when trying to run migrate after generating the migrations on an 
app that has a model that contains a foreign key to the user model.  So I 
created a simple test app to isolate the problem, with a model defined as 
below:

from django.db import models
from django.conf import settings

class TestModel(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)

When I run "makemigrations test_app" the migrations seem to be created fine 
as there are no errors produced.  However when I run "migrate" I get the 
folllowing errors:

C:\Users\osborn_r\django\test_project>python manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: admin, contenttypes, auth, sessions
  Apply all migrations: test_app, auth
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying test_app.0001_initial...Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line
427, in execute_from_command_line
utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line
419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
288,
 in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
337,
 in execute
output = self.handle(*args, **options)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\migrate.py
", line 145, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
  File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
line 60
, in migrate
self.apply_migration(migration, fake=fake)
  File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
line 88
, in apply_migration
if self.detect_soft_applied(migration):
  File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
line 13
2, in detect_soft_applied
apps = project_state.render()
  File "C:\Python27\lib\site-packages\django\db\migrations\state.py", line 
63, i
n render
model=dangling_lookup[0]))
ValueError: Lookup failed for model referenced by field 
auth.Permission.content_
type: contenttypes.ContentType

Can anyone spot what I have done wrong?

-- 
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/f38bf94b-da37-4b2e-8722-a3263b12442d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I can't run django server nor activate the virtualenv

2014-04-28 Thread Fred DJar



*Hello guys, i'm a newbie so bear with me :)I have installed python 2.7 and 
django 1.6 on my desktop (ubuntu 14)but i can't run the application or 
activate the virtualenv*

*this is the message i got:*
ubuntu@ubuntu:~/Downloads/saf$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 399, in execute_from_command_line
utility.execute()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 280, in execute
translation.activate('en-us')
  File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", 
line 130, in activate
return _trans.activate(language)
  File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 188, in activate
_active.value = translation(language)
  File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 159, in _fetch
app = import_module(appname)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
line 40, in import_module
__import__(name)

-- 
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/803f2d00-66bc-4a27-8389-6014730222d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 https://groups.goog

Re: I can't run django server nor activate the virtualenv

2014-04-28 Thread Victor Hooi
Hi Fred,

Are there any lines *below* the error message you pasted?

The last line I can see is:

File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
> line 40, in import_module 

__import__(name)


Is there anything else?

Cheers,
Victor

On Monday, 28 April 2014 03:03:40 UTC-7, Fred DJar wrote:
>
>
>
>
> *Hello guys, i'm a newbie so bear with me :)I have installed python 2.7 
> and django 1.6 on my desktop (ubuntu 14)but i can't run the application or 
> activate the virtualenv*
>
> *this is the message i got:*
> ubuntu@ubuntu:~/Downloads/saf$ python manage.py runserver
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 399, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 280, in execute
> translation.activate('en-us')
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py",
>  
> line 130, in activate
> return _trans.activate(language)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 188, in activate
> _active.value = translation(language)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 159, in _fetch
> app = import_module(appname)
>   File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
> line 40, in import_module
> __import__(name)
>
>

-- 
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/c972709d-3b18-4ee0-82a7-aca095df2602%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I can't run django server nor activate the virtualenv

2014-04-28 Thread Fred DJar
There is one other line:
ImportError : No module named bootstrapform

On Monday, 28 April 2014 11:34:35 UTC+1, Victor Hooi wrote:
>
> Hi Fred,
>
> Are there any lines *below* the error message you pasted?
>
> The last line I can see is:
>
> File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
>> line 40, in import_module 
>
> __import__(name)
>
>
> Is there anything else?
>
> Cheers,
> Victor
>
> On Monday, 28 April 2014 03:03:40 UTC-7, Fred DJar wrote:
>>
>>
>>
>>
>> *Hello guys, i'm a newbie so bear with me :)I have installed python 2.7 
>> and django 1.6 on my desktop (ubuntu 14)but i can't run the application or 
>> activate the virtualenv*
>>
>> *this is the message i got:*
>> ubuntu@ubuntu:~/Downloads/saf$ python manage.py runserver
>> Traceback (most recent call last):
>>   File "manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
>> line 399, in execute_from_command_line
>> utility.execute()
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
>> line 392, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
>> line 242, in run_from_argv
>> self.execute(*args, **options.__dict__)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
>> line 280, in execute
>> translation.activate('en-us')
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py",
>>  
>> line 130, in activate
>> return _trans.activate(language)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>>  
>> line 188, in activate
>> _active.value = translation(language)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>>  
>> line 177, in translation
>> default_translation = _fetch(settings.LANGUAGE_CODE)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>>  
>> line 159, in _fetch
>> app = import_module(appname)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 
>> 40, in import_module
>> __import__(name)
>>
>>

-- 
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/26114e5c-8952-4e38-9445-d1fb808152c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


IndentationError :Unexpected Indent

2014-04-28 Thread Kelvin Mwangi
 I have been following up on the tutorial on Python version 1.6 and I got 
stuck at an indentation error I can't seem to debug. Its under the first 
tutorial of creating Django application and I modified my polls\models.py 
file to look like this;

from django.db import models
import datetime
from django.utils import timezone

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):  
return self.question
def was_published_recently (self):
return self.pub_date > = timezone.now() - datetime.timedelta(days=1)

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __unicode__(self):  
return self.choice_text 

I keep getting an error at that line that starts with "def 
was_published_recently.." and can't seem to debug the error. Can anyone 
kindly help me here? I'm stuck. :( 

-- 
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/0e2ec62a-a7a5-4ebd-b639-975cc514e060%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: IndentationError :Unexpected Indent

2014-04-28 Thread Andreas Kuhne
2014-04-28 7:55 GMT+02:00 Kelvin Mwangi :

>  I have been following up on the tutorial on Python version 1.6 and I got
> stuck at an indentation error I can't seem to debug. Its under the first
> tutorial of creating Django application and I modified my polls\models.py
> file to look like this;
>
> from django.db import models
> import datetime
> from django.utils import timezone
>
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
> def __unicode__(self):
> return self.question
> def was_published_recently (self):
> return self.pub_date > = timezone.now() - datetime.timedelta(days=1)
>
> class Choice(models.Model):
> poll = models.ForeignKey(Poll)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
> def __unicode__(self):
> return self.choice_text
>
> I keep getting an error at that line that starts with "def
> was_published_recently.." and can't seem to debug the error. Can anyone
> kindly help me here? I'm stuck. :(
>
>  --
> 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/0e2ec62a-a7a5-4ebd-b639-975cc514e060%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

You have too many indentations. Make sure that def was_published_recently
(self): starts on the same column as def __unicode__(self):

Python is very sensitive to indentations. As a rule of thumb read the pep
08 coding coventions (http://legacy.python.org/dev/peps/pep-0008/).

Regards,

Andréas

-- 
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/CALXYUbk_hDQcY9SaubiUt1umWP5tEc2t%2BWz6uUngdMP1sVS2Cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Subjectively Required Fields

2014-04-28 Thread Daniel Watkins
Hello all,

We're running in to an interesting validation problem.  We have a model 
which represents a (specific type of) date interval, bounded by a start 
date and end date. Both fields are optional, but if end date is specified 
then start date must be specified. We are creating an instance of this 
using a ModelForm.

We initially tried to do this with the model's clean method:

def clean(self):
if self.end_date and not self.start_date:
raise ValidationError('Start date must be specified if an end 
date is specified.')

This works fine if start date is not specified. However, the error is also 
shown if an invalid date is given, along with the "Invalid date" message 
against the field. This isn't really what we want (as it's not especially 
user-friendly).

I'm pretty sure that this is because the form strips out the invalid date 
from the data it puts in to the model before this is validated, though I'm 
not 100% sure on this.

Is there any way we can achieve what we want with model validation, or will 
we have to put the logic in to the form?


Cheers,

Dan

-- 
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/468dc535-c494-4418-86c7-c857f66d130d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ANN: ReportLab PLUS 3.1 - rapid PDF creation for Django sites

2014-04-28 Thread Andy Robinson
ReportLab are pleased to announce the release of the Python 3-compatible 
version of our PDF generation toolkit.   

After an extensive rewrite, our framework now runs under Pythons 2.7, 3.3 
and 3.4; and both the open source and commercial tools can be installed 
with pip and managed from requirements files.

We have been using Django ourselves for 8 years now, and our Django-powered 
solutions powers some of the biggest dynamic PDF generation solutions on 
the net.  See who ReportLab work with

Many of you will know the open source ReportLab PDF Toolkit.  ReportLab 
PLUS, which sits on top of it, lets you develop attractive documents very 
quickly directly from your Django solution.   
   - code PDF templates in a high level markup language, the same way you 
make your web templates
   - include professionally designed artwork and background pages with a 
single tag using our PageCather technology
   - create business and custom graphics with identical style in print and 
web using our Diagra charts


The ability to create personalised, publication quality PDF documents from 
a CMS in real time is a game-changer, opening new communication channels 
and allowing clients to streamline work and save on print.

ReportLab PLUS can be tried freely 
with a nag line, but needs an annual 
subscription before production use. We 
are happy to provide support, mentoring and a design-and-build service.  

Find out more... 

Andy Robinson
CEO / Chief Architect
ReportLab

 

-- 
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/805adf45-f65e-45e8-bb69-e4e6ed24c360%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What are the active Django e-commerce frameworks right now (2014)?

2014-04-28 Thread Andy Robinson
I second the recommendation for Stripe.

I have no need for shopping carts but suffered for years dealing with 
credit card payments for license renewals.  Many solutions were running 
into problems with foreign banks blocking payments (which the payment 
solution can't do anything about), spurious rejections and so on.  I 
discovered Stripe and had it running in literally a couple of hours, and we 
have never had an issue with an incorrectly blocked payment.   
 Business-wise, the alternatives needed months of form-filling with payment 
providers, merchant accounts, PCI-DSS certificate vendors.  It is 
ridiculously easy to get up and running with Stripe and just make an HTML 
button for each product you want to sell.


On Saturday, April 26, 2014 5:44:21 PM UTC+1, Jared Nielsen wrote:
>
> Check out Stripe. Not a framework, but very easy to implement with Django. 
>
> On Saturday, April 26, 2014 4:57:51 AM UTC-6, Brutus Schraiber wrote:
>>
>> Thanks 'somecallitblues' I will definitely take a closer look at Mezzanine 
>> and Cartridge.
>>
>> But I'm kinda baffled. Only one answer after two weeks?
>>
>> Sure webshops might not be the hot topic anymore than they where a good 
>> couple of years ago, and most people just use PHP and Magento anyway, but 
>> still?
>>
>> Was my question too long? Is this the wrong place to ask such questions?
>>
>> I know I generally should use stackoverflow etc. first, but this is not 
>> the kind of question thats welcome there...
>>
>> Any chance I get some more opinions on this? Or hints where I can get 
>> such?
>>
>

-- 
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/da185c4c-5279-4b5b-92b8-2347bc9454a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django ユーザー登録について

2014-04-28 Thread Lachlan Musicman
Hito san,

I don't mean to be rude mate, but Google is really really awesome -
just pump in the error message

http://stackoverflow.com/questions/10388033/csrf-verification-failed-request-aborted

L.

On 28 April 2014 16:09, hito koto  wrote:
> Hi, Thank you!
>
> I write to Views.py :
> def attendance(request, user_id):
> Attendence_data.objects.get(pk=user_id)
>
> if request.method == "POST":
> form = Attendance_dataForm(request.POST, instance = attendance)
> if form.is_valid():
> form.save()
> return
> HttpResponseRedirect('/ihttest/ihttcs_test/tcsarticles/get/%s' % user.id)
>
> else:
> form = Attendance_dataForm()
> args = {}
> args.update(csrf(request))
> args['form'] = form
> return render_to_response('staff_data.html', args,  context_instance =
> RequestContext(request, {'form': form}))
>
> But i also have error:
>
> Forbidden (403)
>
> CSRF verification failed. Request aborted.
>
> Help
>
> Reason given for failure:
>
> CSRF token missing or incorrect.
>
>
> In general, this can occur when there is a genuine Cross Site Request
> Forgery, or when Django's CSRF mechanism has not been used correctly. For
> POST forms, you need to ensure:
>
> Your browser is accepting cookies.
> The view function uses RequestContext for the template, instead of Context.
> In the template, there is a {% csrf_token %} template tag inside each POST
> form that targets an internal URL.
> If you are not using CsrfViewMiddleware, then you must use csrf_protect on
> any views that use the csrf_token template tag, as well as those that accept
> the POST data.
>
> You're seeing the help section of this page because you have DEBUG = True in
> your Django settings file. Change that to False, and only the initial error
> message will be displayed.
>
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>
>
>
>
>
> 2014年4月28日月曜日 14時41分39秒 UTC+9 jjmutumi:
>>
>> Hi there, I think your problem is you have not initialized attendance
>> that you use at `instance = attendance`. So it is just using the name
>> of your view function which also happens to be 'attendance' and
>> showing you that error.
>>
>> Initialize to model object with the usual:
>> Attendence_data.objects.get(pk=user_id) or if you are using
>> djago.shortcuts: get_object_or_404(Attendence_data, pk=user_id)
>>
>> On 4/28/14, hito koto  wrote:
>> > Ok, Thank you!
>> >
>> > this is my models.py:
>> >
>> >
>> > from django.db import models
>> > from django.contrib.auth.models import User
>> > #from owner.models import GroupSchedule
>> >
>> >
>> >
>> > class GroupRestrictionMixin(object):
>> > group_field = 'group'
>> >
>> > def dispatch(request, *args, **kwargs):
>> > self.request = request
>> > self.args = args
>> > self.kwargs = kwargs
>> >
>> > obj_group = getattr(self.get_object(), self.group_field)
>> > user_groups = request.user.groups
>> >
>> > if obj_group not in user_groups:
>> > raise PermissionDenied
>> >
>> > return super(GroupRestrictionMixin, self).dispatch(request,
>> > *args,
>> > **kwargs)
>> >
>> >
>> > class User(models.Model):
>> > user_name = models.CharField(max_length=255, help_text="氏名(名)")
>> > first_kana = models.CharField(max_length=255, help_text="ふりがな(性)")
>> > last_kana  = models.CharField(max_length=255, help_text="ふりがな(名)")
>> > employee_number = models.CharField(blank=True, max_length=22,
>> > help_text="社員番号")
>> > gender = models.CharField(max_length=6, choices=(('male',
>> > '男性'),('female', '女性')), help_text="性別" )
>> > created_at = models.DateTimeField(auto_now_add=True,
>> > help_text="登録日")
>> >
>> >
>> > class Attendance_data(models.Model):
>> > user = models.ForeignKey(User)
>> > user_name = models.CharField(max_length=255, help_text="氏名(名)")
>> > employee_number = models.CharField(blank=True, max_length=22,
>> > help_text="社員番号")
>> >
>> > def __unicode__(self):
>> > return self.user_name, employee_number
>> >
>> > class Leave_work(models.Model):
>> > user = models.ForeignKey(User)
>> > user_name = models.CharField(max_length=255, help_text="氏名(名)")
>> > employee_number = models.CharField(blank=True, max_length=22,
>> > help_text="社員番号")
>> >
>> > def __unicode__(self):
>> > return self.user_name, employee_unmber
>> >
>> > this is my Views.py:
>> >
>> > def staff_data(request, user_id=1):
>> > user = get_object_or_404(User, pk=user_id)
>> > return render_to_response("staff_data.html",
>> >  {"user": User.objects.get(id=user_id) })
>> >
>> > def attendance(request, user_id):
>> > if request.method == "POST":
>> >
>> > form = Attendance_dataForm(request.POST, instance = attendance)
>> > if form.is_valid():
>> > form.save()
>> > return HttpResponseRedirect('/articles/get/%s' % user.id)
>> > else:
>> > form = 

Re: IndentationError :Unexpected Indent

2014-04-28 Thread Rene Zelaya
Ditto from what Andreas said - Python is very sensitive to indentation.  If 
the method 'was_published_recently' is part of the Poll model, then there 
should be the same amount of indentations before 'def was_published...' as 
for the 'def __unicode__' method.  Then, for uniformity's sake (even though 
it is technically not necessary), the 'return self.pub_date...' line should 
also have the same number of indents FROM the indent where the 'def 
was_published...' method line starts (in this case 3), like so:

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __unicode__(self):  
return self.question

   def was_published_recently (self):
  return self.pub_date > = timezone.now() - datetime.timedelta(days=1)

This is to indicate it is IN the 'was_published_recently' method.
Cheers.


On Monday, April 28, 2014 1:55:27 AM UTC-4, Kelvin Mwangi wrote:
>
>  I have been following up on the tutorial on Python version 1.6 and I got 
> stuck at an indentation error I can't seem to debug. Its under the first 
> tutorial of creating Django application and I modified my polls\models.py 
> file to look like this;
>
> from django.db import models
> import datetime
> from django.utils import timezone
>
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
> def __unicode__(self):  
> return self.question
> def was_published_recently (self):
> return self.pub_date > = timezone.now() - datetime.timedelta(days=1)
>
> class Choice(models.Model):
> poll = models.ForeignKey(Poll)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
> def __unicode__(self):  
> return self.choice_text 
>
> I keep getting an error at that line that starts with "def 
> was_published_recently.." and can't seem to debug the error. Can anyone 
> kindly help me here? I'm stuck. :( 
>
>

-- 
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/725f3014-2e81-4af5-9ccb-41cc696191b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


SQL query to authenticate user from non-django app

2014-04-28 Thread Goran Mekic
Hi,

I have a Django project with its DB. How can I use Django DB users to
auth, for example, vsftpd? I mean, I couldn't find suitable SQL query to
check the password. Thank you!


signature.asc
Description: Digital signature


Re: I can't run django server nor activate the virtualenv

2014-04-28 Thread Rene Zelaya
Hi Fred - 

So if you can't activate your virtualenv, and you installed Django in that 
virtualenv, that is likely the root of your problem, because without it, 
none of the modules will appear as installed and you will not be able to 
run the server (or access the python manage.py shell, etc).  I would first 
figure out why you can't activate the virtual environment -- what is the 
error when you try to activate it?

Rene

On Monday, April 28, 2014 6:03:40 AM UTC-4, Fred DJar wrote:
>
>
>
>
> *Hello guys, i'm a newbie so bear with me :)I have installed python 2.7 
> and django 1.6 on my desktop (ubuntu 14)but i can't run the application or 
> activate the virtualenv*
>
> *this is the message i got:*
> ubuntu@ubuntu:~/Downloads/saf$ python manage.py runserver
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 399, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 280, in execute
> translation.activate('en-us')
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py",
>  
> line 130, in activate
> return _trans.activate(language)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 188, in activate
> _active.value = translation(language)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 159, in _fetch
> app = import_module(appname)
>   File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
> line 40, in import_module
> __import__(name)
>
>

-- 
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/c48bd8cd-4978-4583-ae76-33583e11e848%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: IndentationError :Unexpected Indent

2014-04-28 Thread Dow Street
Based on the code below it looks like your indentation is off for def 
was_published recently code block (i.e. 3 spaces instead of 4).  If that does 
not solve the problem, you might also check to ensure that you're not mixing 
tabs and spaces when indenting.  Depending on your environment that can lead to 
some confusing errors.  For example, if you have a tab in one line, and 
multiple spaces in the next line (of the same code block), in your editor it 
might appear visually that the indentation is the same, but the interpreter may 
treat them differently.

Different folks prefer tabs vs. spaces, but the key is to be consistent.  
google's style guide calls for 4 spaces:

https://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Indentation

R,
Dow


On Apr 28, 2014, at 6:54 AM, Rene Zelaya  wrote:

> Ditto from what Andreas said - Python is very sensitive to indentation.  If 
> the method 'was_published_recently' is part of the Poll model, then there 
> should be the same amount of indentations before 'def was_published...' as 
> for the 'def __unicode__' method.  Then, for uniformity's sake (even though 
> it is technically not necessary), the 'return self.pub_date...' line should 
> also have the same number of indents FROM the indent where the 'def 
> was_published...' method line starts (in this case 3), like so:
> 
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
> 
> def __unicode__(self):  
> return self.question
> 
>def was_published_recently (self):
>   return self.pub_date > = timezone.now() - datetime.timedelta(days=1)
> 
> This is to indicate it is IN the 'was_published_recently' method.
> Cheers.
> 
> 
> On Monday, April 28, 2014 1:55:27 AM UTC-4, Kelvin Mwangi wrote:
>  I have been following up on the tutorial on Python version 1.6 and I got 
> stuck at an indentation error I can't seem to debug. Its under the first 
> tutorial of creating Django application and I modified my polls\models.py 
> file to look like this;
> 
> from django.db import models
> import datetime
> from django.utils import timezone
> 
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
> def __unicode__(self):  
> return self.question
>   def was_published_recently (self):
>   return self.pub_date > = timezone.now() - 
> datetime.timedelta(days=1)
> 
> class Choice(models.Model):
> poll = models.ForeignKey(Poll)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
>   def __unicode__(self):  
> return self.choice_text 
> 
> I keep getting an error at that line that starts with "def 
> was_published_recently.." and can't seem to debug the error. Can anyone 
> kindly help me here? I'm stuck. :( 
> 
> 
> -- 
> 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/725f3014-2e81-4af5-9ccb-41cc696191b9%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/913E6FEB-A50B-4BD3-93A5-23200C539D58%40prodigy.net.
For more options, visit https://groups.google.com/d/optout.


Re: I can't run django server nor activate the virtualenv

2014-04-28 Thread Fred DJar
Thanks Rene
The virtualenv was created in Ubuntu but now i'm running windows, should i 
run it in Ubuntu because i've noticed that virtualenv folder structure 
differentiate from Ubuntu to windows
this is the message i got from the prompt command: activate is not 
recognized as an internal or external command, operable program or batch 
file

On Monday, 28 April 2014 11:03:40 UTC+1, Fred DJar wrote:
>
>
>
>
> *Hello guys, i'm a newbie so bear with me :)I have installed python 2.7 
> and django 1.6 on my desktop (ubuntu 14)but i can't run the application or 
> activate the virtualenv*
>
> *this is the message i got:*
> ubuntu@ubuntu:~/Downloads/saf$ python manage.py runserver
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 399, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 280, in execute
> translation.activate('en-us')
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py",
>  
> line 130, in activate
> return _trans.activate(language)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 188, in activate
> _active.value = translation(language)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>  
> line 159, in _fetch
> app = import_module(appname)
>   File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
> line 40, in import_module
> __import__(name)
>
>

-- 
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/6e5e3ded-7ad0-4fdc-94dc-e40c9d0e4b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Celery throwing runtime warnings for naive times

2014-04-28 Thread John DeRosa
I suggest you file a ticket in the celery project 
(https://github.com/celery/celery/issues), or ask for help on the #celery IRC 
channel. (See 
http://celery.readthedocs.org/en/latest/getting-started/resources.html for 
"help" resources...) They'd be more profitable avenues for you, given the code 
path that's in the stack dump.

John

On Apr 28, 2014, at 3:33 AM, heidi  wrote:

> 
> 
> 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 _reschedules
> return 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_while
> return 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_update
> return filtered._update(values) > 0
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", 
> line 507, in _update
> return 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_value
> RuntimeWarning)
> 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 an

Re: migrate command fails with foreign key to user model

2014-04-28 Thread Simon Charette
This is a release blocker for Django 1.7 which is being tracked in 
#22485
.

Le lundi 28 avril 2014 04:54:32 UTC-4, Ryan a écrit :
>
> I have used django in the past, but not for some time.  So the changes 
> surrounding the user models are new to me.  I downloaded v1.7b2 and 
> proceeded to start a new development I am planning.  However I came across 
> a problem when trying to run migrate after generating the migrations on an 
> app that has a model that contains a foreign key to the user model.  So I 
> created a simple test app to isolate the problem, with a model defined as 
> below:
>
> from django.db import models
> from django.conf import settings
>
> class TestModel(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>
> When I run "makemigrations test_app" the migrations seem to be created 
> fine as there are no errors produced.  However when I run "migrate" I get 
> the folllowing errors:
>
> C:\Users\osborn_r\django\test_project>python manage.py migrate
> Operations to perform:
>   Synchronize unmigrated apps: admin, contenttypes, auth, sessions
>   Apply all migrations: test_app, auth
> Synchronizing apps without migrations:
>   Creating tables...
>   Installing custom SQL...
>   Installing indexes...
> Running migrations:
>   Applying test_app.0001_initial...Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
> line
> 427, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
> line
> 419, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\base.py", 
> line 288,
>  in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "C:\Python27\lib\site-packages\django\core\management\base.py", 
> line 337,
>  in execute
> output = self.handle(*args, **options)
>   File 
> "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py
> ", line 145, in handle
> executor.migrate(targets, plan, fake=options.get("fake", False))
>   File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
> line 60
> , in migrate
> self.apply_migration(migration, fake=fake)
>   File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
> line 88
> , in apply_migration
> if self.detect_soft_applied(migration):
>   File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
> line 13
> 2, in detect_soft_applied
> apps = project_state.render()
>   File "C:\Python27\lib\site-packages\django\db\migrations\state.py", line 
> 63, i
> n render
> model=dangling_lookup[0]))
> ValueError: Lookup failed for model referenced by field 
> auth.Permission.content_
> type: contenttypes.ContentType
>
> Can anyone spot what I have done wrong?
>

-- 
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/4ec04a34-72ea-4483-8258-f11457baff37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Subjectively Required Fields

2014-04-28 Thread Mario Gudelj
Your clean method needs to return cleaned_data I believe
On 28/04/2014 10:02 pm, "Daniel Watkins" 
wrote:

> Hello all,
>
> We're running in to an interesting validation problem.  We have a model
> which represents a (specific type of) date interval, bounded by a start
> date and end date. Both fields are optional, but if end date is specified
> then start date must be specified. We are creating an instance of this
> using a ModelForm.
>
> We initially tried to do this with the model's clean method:
>
> def clean(self):
> if self.end_date and not self.start_date:
> raise ValidationError('Start date must be specified if an end
> date is specified.')
>
> This works fine if start date is not specified. However, the error is also
> shown if an invalid date is given, along with the "Invalid date" message
> against the field. This isn't really what we want (as it's not especially
> user-friendly).
>
> I'm pretty sure that this is because the form strips out the invalid date
> from the data it puts in to the model before this is validated, though I'm
> not 100% sure on this.
>
> Is there any way we can achieve what we want with model validation, or
> will we have to put the logic in to the form?
>
>
> Cheers,
>
> Dan
>
> --
> 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/468dc535-c494-4418-86c7-c857f66d130d%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHqTbjmnsxeVfLKJq%3DhFCwuTLb4YiWTMCaPb0yBdHW7SXKOBRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Is it a django's bug or something mistaken,when I can't encode chinese characters in django environment?

2014-04-28 Thread jie . li0117

My environment is python3.3.4 django1.6.2,when I work on a django 
project,and I need to send email to my users through a email proxy 
service,but I went wrong with the django's send_mail. So I wrote a function 
with python's stmplib and email Lib.The code is like:

def email_user(context):



fromEmail = 'admin@***.cn'
toEmail = ['***@qq.com']
msg = MIMEMultipart('alternative')
msg.set_charset('utf8')
msg['Subject'] = '欢迎注册心优雅社区,请激活您的账号'
msg['From'] = fromEmail
msg['To'] = ','.join(toEmail)
html = """
亲爱的%(username)s:

您好!

您在心优雅社区注册账号时使用了这个邮箱,现在您需要点击下面的链接激活该账号:

%(protocol)s://%(domain)s 

如果链接无法点击,请将它完整复制到浏览器的地址栏进行访问.

链接有效期为%(expiration_days)s天,失效后需重新注册.

如果您并未进行过此操作,那么可能是有人误用了您的邮箱,请忽略此邮件."""%context
part = MIMEText(html,'html',_charset='UTF-8')
msg.attach(part)

username = 'postmaster@***org'
password = ''
s = smtplib.SMTP('.com:25')
s.login(username,password)
s.sendmail(fromEmail,toEmail,msg.as_string())
s.quit()

When I test it in the python IDLE,it work well. But,when I called this 
function to send email in my django project,or run it in "manage.py 
shell",UnicodeEncodeError let me crazy.

'ascii' codec can't encode characters in position 439-441: ordinal not in 
range(128)
Unicode error hint

The string that could not be encoded/decoded was: 亲爱的

-- 
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/1054ff4e-8a48-4cfa-a755-82230565bf0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it a django's bug or something mistaken,when I can't encode chinese characters in django environment?

2014-04-28 Thread Simon Charette
Maybe those API's expect you to pass them bytes and not text.

Did you try encoding your subject and your body as 'utf-8' bytes (using 
.encode('utf-8'))?

Simon

Le lundi 28 avril 2014 23:00:03 UTC-4, jie.l...@gmail.com a écrit :
>
>
> My environment is python3.3.4 django1.6.2,when I work on a django 
> project,and I need to send email to my users through a email proxy 
> service,but I went wrong with the django's send_mail. So I wrote a function 
> with python's stmplib and email Lib.The code is like:
>
> def email_user(context):
>
>
>
> fromEmail = 'admin@***.cn'
> toEmail = ['***@qq.com']
> msg = MIMEMultipart('alternative')
> msg.set_charset('utf8')
> msg['Subject'] = '欢迎注册心优雅社区,请激活您的账号'
> msg['From'] = fromEmail
> msg['To'] = ','.join(toEmail)
> html = """
> 亲爱的%(username)s:
>
> 您好!
>
> 您在心优雅社区注册账号时使用了这个邮箱,现在您需要点击下面的链接激活该账号:
>
> %(protocol)s://%(domain)s 
>
> 如果链接无法点击,请将它完整复制到浏览器的地址栏进行访问.
>
> 链接有效期为%(expiration_days)s天,失效后需重新注册.
>
> 如果您并未进行过此操作,那么可能是有人误用了您的邮箱,请忽略此邮件."""%context
> part = MIMEText(html,'html',_charset='UTF-8')
> msg.attach(part)
>
> username = 'postmaster@***org'
> password = ''
> s = smtplib.SMTP('.com:25')
> s.login(username,password)
> s.sendmail(fromEmail,toEmail,msg.as_string())
> s.quit()
>
> When I test it in the python IDLE,it work well. But,when I called this 
> function to send email in my django project,or run it in "manage.py 
> shell",UnicodeEncodeError let me crazy.
>
> 'ascii' codec can't encode characters in position 439-441: ordinal not in 
> range(128)
> Unicode error hint
>
> The string that could not be encoded/decoded was: 亲爱的
>
>

-- 
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/6d531540-1558-4c7a-a919-f50b39c3c038%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: placing views and models in configuration root

2014-04-28 Thread Andreas Bloch
so what do you when you're making trivial sites, that don't have any 
database models, like about-page, landing-page and so on?
would you make a separate app for those and stuff them all in there or just 
use templateviews and route them from the configuration root urls.py?

-- 
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/6399b238-222a-42f5-9786-b416e01234fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: migrate command fails with foreign key to user model

2014-04-28 Thread Ryan
Thanks for the info.  At least I now know it wasn't anything I was doing 
wrong!

On Monday, 28 April 2014 17:54:29 UTC+1, Simon Charette wrote:
>
> This is a release blocker for Django 1.7 which is being tracked in 
> #22485
> .
>
> Le lundi 28 avril 2014 04:54:32 UTC-4, Ryan a écrit :
>>
>> I have used django in the past, but not for some time.  So the changes 
>> surrounding the user models are new to me.  I downloaded v1.7b2 and 
>> proceeded to start a new development I am planning.  However I came across 
>> a problem when trying to run migrate after generating the migrations on an 
>> app that has a model that contains a foreign key to the user model.  So I 
>> created a simple test app to isolate the problem, with a model defined as 
>> below:
>>
>> from django.db import models
>> from django.conf import settings
>>
>> class TestModel(models.Model):
>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>>
>> When I run "makemigrations test_app" the migrations seem to be created 
>> fine as there are no errors produced.  However when I run "migrate" I get 
>> the folllowing errors:
>>
>> C:\Users\osborn_r\django\test_project>python manage.py migrate
>> Operations to perform:
>>   Synchronize unmigrated apps: admin, contenttypes, auth, sessions
>>   Apply all migrations: test_app, auth
>> Synchronizing apps without migrations:
>>   Creating tables...
>>   Installing custom SQL...
>>   Installing indexes...
>> Running migrations:
>>   Applying test_app.0001_initial...Traceback (most recent call last):
>>   File "manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File 
>> "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
>> 427, in execute_from_command_line
>> utility.execute()
>>   File 
>> "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
>> 419, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File "C:\Python27\lib\site-packages\django\core\management\base.py", 
>> line 288,
>>  in run_from_argv
>> self.execute(*args, **options.__dict__)
>>   File "C:\Python27\lib\site-packages\django\core\management\base.py", 
>> line 337,
>>  in execute
>> output = self.handle(*args, **options)
>>   File 
>> "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py
>> ", line 145, in handle
>> executor.migrate(targets, plan, fake=options.get("fake", False))
>>   File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
>> line 60
>> , in migrate
>> self.apply_migration(migration, fake=fake)
>>   File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
>> line 88
>> , in apply_migration
>> if self.detect_soft_applied(migration):
>>   File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
>> line 13
>> 2, in detect_soft_applied
>> apps = project_state.render()
>>   File "C:\Python27\lib\site-packages\django\db\migrations\state.py", 
>> line 63, i
>> n render
>> model=dangling_lookup[0]))
>> ValueError: Lookup failed for model referenced by field 
>> auth.Permission.content_
>> type: contenttypes.ContentType
>>
>> Can anyone spot what I have done wrong?
>>
>

-- 
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/d3b85387-1c06-4f48-876c-0f6a75bbb4d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.