RE: newbie having trouble with conversion to south

2010-10-28 Thread Sells, Fred
I noticed that easy_install left south as an egg.  Can I just unzip that or is 
there some ezsetup I have to use to expose the files so I can edit that line.  
I have not needed to "look under the hood" of easy_install's before, so this is 
probably a RTFM question, but...

Sorry to be so "needy" but this system is in production and I'm nervous about 
that which I have not done before.


You should see this ticket on South's trac:
http://south.aeracode.org/ticket/567; Your options are: downgrade to
0.7.1, use a version from their repository or you can just safely
delete the extra args.

-- 
Łukasz Rekucki

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

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



Forms in a Workflow for Related Models

2010-10-28 Thread ghachey
Hi,

I think I have a particular case.  I could not find an easy way to do
this going carefully through all the documentation.  I also couldn't
find anything close enough in these archives to help me out with my
limited experience so I am resorting to asking you.

I have a Paper model which records research paper information
(references for a given paper).  And, I have a Questionnaire model
which records a questionnaire instance for a given paper instance.
They look like this,

class Paper(models.Model):
  author = models.CharField(max_length=256)
  title = models.CharField(max_length=256)
  .
  .

class Questionnaire(models.Model):
  paper = models.ForeignKey(Paper,
db_column='paper_fk',blank=True,null=True)
  reviewer = models.CharField(
verbose_name="Who is the reviewer?",
max_length=5,choices=REVIEWERS,unique=True)
  question1 = models.CharField(max_length=256)
  .
  .

I have a view that pulls all paper instances (for a particular
research) showing the title and the abstract only on a page.  I would
like to be able to click on the title of any one of the papers opening
a new browser window in which I could complete a questionnaire for
that particular paper.

Ideally, it would ask first which *reviewer* would like to submit (or
update) a questionnaire for that paper (see the Questionnaire model).
Subsequently, it would show an empty Questionnaire form (if reviewer
has not submitted a questionnaire for that paper yet) or the
previously submitted instance of that questionnaire for that paper by
that reviewer.

I simply cannot find an easy way of achieving this.  I have looked at
inline formset (with online one inline), a combination of forms, etc.
but none of those seem to do what I want easily.

Any ideas would be greatly appreciated, even telling me to do this in
a completely different way.

Thank you,

--
GH

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



Re: Graphic and form in the same template

2010-10-28 Thread pjrhar...@gmail.com
It can't be done like that.

Look at any website and you'll see that never is the picture somehow
"embedded" in the page, it's linked by an img tag that points at the
url of the image.

What he was saying is that you need two separate views. In the first,
return your page with an img tag pointing at the other view that
returns the img.

On Oct 26, 5:16 pm, Waleria  wrote:
> I don't understand what you said.
>
> Thanks
>
> On 26 out, 12:19, Daniel Roseman  wrote:
>
> > On Oct 26, 3:08 pm, Waleria  wrote:
>
> > > I know that the execution of the function stops there, but i don't
> > > know how do i resolve. I need to display the graphic generated and
> > > just below the form.
>
> > > Can you help me, please?
>
> > > Thanks
>
> > Well as far as I can tell, the generated graphic doesn't depend on the
> > request or the form at all. So why does it need to be created in the
> > same view as the form? It seems like you just need your template to
> > contain a normal HTML image tag, whose `src` attribute is a URL that
> > points to the gera_grafico function (or a wrapped version that returns
> > the FigureCanvas).
> > --
> > DR.

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



Re: Model Inheritance.

2010-10-28 Thread Tom Eastman

On 29/10/10 11:06, Carles Barrobés wrote:

Your "place" object will contain an attribute called "restaurant" to
access
the object as an instance of the subclass.

If this place object is an instance of another place subclass,
accessing the
restaurant attribute will raise a DoesNotExist error.

Carles.


That's correct, but I want to take a 'Place' object, that doesn't have a 
'restaurant', and turn it *in to* a 'Restaurant' by adding the 
corresponding row to the Restaurant table.


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



Re: adding field to query set

2010-10-28 Thread owidjaya
Ok the motive is for this reason.
I have a table generator class that display an html table from the
query set depending on the columns that you selected
class TableGenerator(name,mapping,data):

  def __init__(self,name,mapping,data):
 self._mapping = mapping
 self._name = name
 self._data = data
  def render_table(self):
  # pseudo code
  *  iterate through the mapping construct the table header
  *  iterate through self._data queryset and construct the columns
for the table body based on the mapping

-- mapping is a variable that holds the mapping of table header with
the actual field name of the model attribute
-- data is just the queryset object.

so here I want to generate a table to display every attribute in
project while also display the related fields of user.first_name and
user.last_name concatenated.
How can i refer to that field in my TableGenerator class using the
mapping generically?


On Oct 28, 3:27 pm, Jumpfroggy  wrote:
> What's your motive?  Are you worried about performance?
>
> If performance is not an issue, you can just do this:
>
>     for project in Project.objects.all():
>         print project.user.first_name + ' ' + project.user.last_namea
>
> This might speed things up:
>
>     projects = Project.objects.all().select_related('user')
>     for project in projects:
>         print project.user.first_name + ' ' + project.user.last_namea
>
> If that's not fast enough, you may want to do something using .extra()
> or .raw().  I'm not sure how to do this effeciently with .extra().

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



Re: adding field to query set

2010-10-28 Thread Jumpfroggy
What's your motive?  Are you worried about performance?

If performance is not an issue, you can just do this:

for project in Project.objects.all():
print project.user.first_name + ' ' + project.user.last_namea

This might speed things up:

projects = Project.objects.all().select_related('user')
for project in projects:
print project.user.first_name + ' ' + project.user.last_namea

If that's not fast enough, you may want to do something using .extra()
or .raw().  I'm not sure how to do this effeciently with .extra().

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



Re: Model Inheritance.

2010-10-28 Thread Carles Barrobés
Your "place" object will contain an attribute called "restaurant" to
access
the object as an instance of the subclass.

If this place object is an instance of another place subclass,
accessing the
restaurant attribute will raise a DoesNotExist error.

Carles.


On 28 Oct, 01:39, Tom Eastman  wrote:
> I'm working with model inheritance, and I need to convert my objects
> into instances of its subclass.  Is there an easy way to do this?
>
> Looking at the example in:
>
> >http://docs.djangoproject.com/en/1.2/topics/db/models/#multi-table-in...
>
> I have a whole bunch of 'Place' objects that are in my database, and I
> want to turn them into 'Restaurant' objects.  How can I achieve this?
>
> (I want to end up with the implicit one-to-one relation in 'Restaurant'
> to be pointing to the already existing object in 'Place')
>
> Cheers!
>
>      Tom

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



adding field to query set

2010-10-28 Thread owidjaya
If I have such models

class Project(models.Model):
  project = models.CharField(max_length=200)
  user = models.ForeignKey(User) # user is from
django.contrib.auth.models => user

I would like to be able to display an an attribute that is made up of
first_name and last_name concatenated when i iterate the queryset

So in essence, can i create such sql from django without using cursor
class?

SELECT   P.*, CONCAT(A.first_name, A.last_name)
FROM project P
LEFT OUTER JOIN auth_user A ON A.id = P.user_id

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



adding field to query set

2010-10-28 Thread owidjaya
If i have such models

class Project(model.Model):
  project = model.

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



Re: How to aggregate values by month

2010-10-28 Thread Mikhail Korobov
Hi Rogério,

You can give http://bitbucket.org/kmike/django-qsstats-magic/src a
try.
It currently have efficient aggregate lookups (1 query for the whole
time series) only for mysql but it'll be great if someone contribute
efficient lookups for other databases :)

On 28 окт, 19:31, Rogério Carrasqueira
 wrote:
> Hello!
>
> I'm having an issue to make complex queries in django. My problem is, I have
> a model where I have the sales and I need to make a report showing the sales
> amount per month, by the way I made this query:
>
> init_date = datetime.date(datetime.now()-timedelta(days=365))
> ends_date = datetime.date(datetime.now())
> sales =
> Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_ 
> created__month).aggregate(total_sales=Sum('total_value'))
>
> At the first line I get the today's date past one year
> after this I got the today date
>
> at sales I'm trying to between a range get the sales amount grouped by
> month, but unfortunatelly I was unhappy on this, because this error
> appeared:
>
> global name 'date_created__month' is not defined
>
> At date_created is the field where I store the information about when the
> sale was done., the __moth was a tentative to group by this by month.
>
> So, my question: how to do that thing without using a raw sql query and not
> touching on database independence?
>
> Thanks so much!
>
> Rogério Carrasqueira
>
> ---
> e-mail: rogerio.carrasque...@gmail.com
> skype: rgcarrasqueira
> MSN: rcarrasque...@hotmail.com
> ICQ: 50525616
> Tel.: (11) 7805-0074

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



limit_choice_to all objects of a particular model (using inheritance)

2010-10-28 Thread pixelcowboy
Example

class Base():
 pass

class A(Base)
parent=models.Foreignkey("self", limit_choices_to=(all members of the
B class)


class B(Base)
parent=models.Foreignkey("self", limit_choices_to=(all members of the
A class)

What would be the query syntax for limit_choices_to, to get only the
objects of a certain class?)

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



odd apache issues

2010-10-28 Thread kicker
I'm having an odd issue when I start up my project using apache/wsgi.
The project works fine when using the development server, but when I
load it up in apache it states that mysql is
"'django.db.backends.mysql' isn't an available database backend.".

Here is my db config (edited to remove user/pass):

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'baz',  # Or path to database file
if using sqlite3.
'USER': 'foo',  # Not used with sqlite3.
'PASSWORD': 'bar',  # Not used with sqlite3.
'HOST': 'localhost',  # Set to empty
string for localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

here is my wsgi file:

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'baz.settings'
os.environ['PYTHON_EGG_CACHE'] = '/var/www/baz/.egg'
sys.path.append('/var/www')
sys.path.append('/usr/lib64/python2.4/site-packages/')

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Anything I'm missing?

Here is the more verbose output:

Environment:

Request Method: GET
Request URL: http://10.1.18.30/admin/
Django Version: 1.2.3
Python Version: 2.4.3
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
  80. response = middleware_method(request)
File "/usr/lib/python2.4/site-packages/django/contrib/sessions/
middleware.py" in process_request
  10. engine = import_module(settings.SESSION_ENGINE)
File "/usr/lib/python2.4/site-packages/django/utils/importlib.py" in
import_module
  35. __import__(name)
File "/usr/lib/python2.4/site-packages/django/contrib/sessions/
backends/db.py" in ?
  3. from django.contrib.sessions.models import Session
File "/usr/lib/python2.4/site-packages/django/contrib/sessions/
models.py" in ?
  4. from django.db import models
File "/usr/lib/python2.4/site-packages/django/db/__init__.py" in ?
  77. connection = connections[DEFAULT_DB_ALIAS]
File "/usr/lib/python2.4/site-packages/django/db/utils.py" in
__getitem__
  91. backend = load_backend(db['ENGINE'])
File "/usr/lib/python2.4/site-packages/django/db/utils.py" in
load_backend
  49. raise ImproperlyConfigured(error_msg)

Exception Type: ImproperlyConfigured at /admin/
Exception Value: 'django.db.backends.mysql' isn't an available
database backend.
Try using django.db.backends.XXX, where XXX is one of:
'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2',
'sqlite3'
Error was: cannot import name utils

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



How to get ISO date format in admin interface

2010-10-28 Thread Svenn Are Bjerkem
Hi,
I want to have ISO date format -MM-DD in the columns in the admin
interface. Currently I have localized dates depending on the
LANGUAGE_CODE setting. I have tried to set
DATE_FORMAT = 'Y-m-d'
in my settings.py and even tried it in the global_settings.py, but I
have got the understanding that localized settings have priority
without being able to find them.
There is no change if I set USE_I18N = True or False

--
Svenn

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



Re: newbie having trouble with conversion to south

2010-10-28 Thread Łukasz Rekucki
On 28 October 2010 20:23, Sells, Fred  wrote:
> I’m using django 1.2.1, Python 2.4 and MySQL 5.0 and south 0.7.2
>
> I’ve got an existing app, aptly named “app” which I’m am trying to convert
> to south so I can make some DB changes.  It seemed to install OK and I get
> to here.  At which point I’m lost.  Could it be that Python 2.4 logging is
> not compatible with south?  I’m currently locked in to Python 2.4 to match
> the release packaged with CentOs.  That’s a management edict and there’s no
> point in trying to get them to change just because it would make sense.
>

You should see this ticket on South's trac:
http://south.aeracode.org/ticket/567; Your options are: downgrade to
0.7.1, use a version from their repository or you can just safely
delete the extra args.

-- 
Łukasz Rekucki

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



Re: Import csv file in admin

2010-10-28 Thread Jorge
>
> Hang on, what you're doing here is repeatedly setting the data values
> for each line to the *same* form_input model. Presumably what you
> actually want to do is to create new Data instances for each line in
> the CSV, with the place set to the value of the form.
>
> In this case, I'd recommend not to bother with a ModelForm at all.
> Instead, just use a standard Form, and create new Data instances in
> your for loop:
>
> class DataInput(forms.Form):
>     file = forms.FileField()
>     place = forms.ModelChoiceField(queryset=Places.objects.all())
>
>     def save(self):
>          records = csv.reader(self.cleaned_data[file])
>          for line in records:
>              data_obj = Data()
>              data_obj.time = datetime.strptime(line[1],
>                                        "%m/%d/%y %H: %M: %S")
>              data_obj.data_1 = line[2]
>              data_obj.data_2 = line[3]
>              data_obj.data_3 = line[4]
>              data_obj.save()
>
> --
> DR.

Daniel

The idea of using a form becomes a problem, because to replace the
standar modelform inside the admin with ModelAdmin.form i need another
modelform, according to this:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#adding-custom-validation-to-the-admin.
If there's any way to replace a modelform with a standar form inside
the admin view, i will appreciate some ideas.

 When i replace the modelform with a standar form, arrise an
ImproperlyConfigured bug: DataAdmin.form does not inherit from
BaseModelForm at admin.py: admin.site.register(Data, DataAdmin)

But anyways i take your point of create new data instances inside the
for loop:

def save(self, commit=True, *args, **kwargs):
 file = self.cleaned_data['file']
 records = csv.reader(file)
 for line in records:
 form_input = super(DataInput, self).save(commit=False,
*args,  **kwargs)
 form_input.place = self.cleaned_data['place']
 form_input.time = datetime.strptime(line[1], "%m/%d/%y %H:
%M: %S")
 form_input.data_1 = line[2]
 form_input.data_2 = line[3]
 form_input.data_3 = line[4]
 form_input.save()

However i still got the AttributeError: 'NoneType' object has no
attribute 'save'.

Regards!

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



How do I filter/exclude custom queryset fields created by .extra()?

2010-10-28 Thread Jumpfroggy
I have something like this:

class Node(Model):
widgets = ForeignKey(Widget)

And I want to retrieve all nodes that have >0 widgets.  I have
an .extra() query like this:

nodes = Node.objects.all().extra(
select={
'num_widgets': 'SELECT COUNT(*) FROM appname_node_widgets
WHERE appname_node_widgets.node_id = appname_node.id',
}
)

This works fine, since I can now do this:

print nodes[0].num_widgets

But I can't filter or exclude on this field.  I try this:

nodes = nodes.exclude(num_widgets=0)

Gives a "FieldError: Cannot resolve keyword 'num_widgets' into
field."  I understand that the fields created by the .extra() call are
not "real" fields attached to the model, but they are fields attached
to the QuerySet.  Is there a way to use fields created with .extra()
in subsequent filter/exclude calls?

My next guess is to drop down to custom SQL and write the whole query
out by hand, but I thought I'd check to see if I'm doing something
wrong here.  I thought I remembered being able to use .extra() fields
in later .filter() statements, but I might be imagining that.

Any thoughts?  Thanks!

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



Re: Unable to filter a query on >1 ManyToMany relationships

2010-10-28 Thread Jumpfroggy
Tom,

Thanks for the link, I read through that and it makes sense.

So if both conditions are in the same filter, they are both applied
simultaneously.  Since I wanted two separate conditions, I needed two
separate filter() statements.

In other words, my method, is "Find a node who's parent is both A and
B".
What I wanted, and what you recommended, is "Find a node who's parents
include A and include B".

Very interesting.  I get it now, and yes it is documented.  For some
reason I have a really hard time navigating the docs, even though I've
read the page you mentioned about a dozen times.  I think a lot of it
has to do with the horrible heading / lack of indents in the docs.

But I digress.  Thanks tom so much, this answers my question!

-James

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



Re: newbie having trouble with conversion to south

2010-10-28 Thread Shawn Milochik
A short note about your primary concern:

You can simply change the shebang line of your manage.py script to
point to the 'python' in your virtualenv. The same goes for a .wsgi
file. There's nothing particularly magical about "activating" a
virtualenv in an interactive terminal session.

Shawn

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



Re: Cherokee for home developing

2010-10-28 Thread Max Countryman
He mentioned uwsgi. He should know that the wizard is currently broken. That 
means that it produces a configuration that doesn't work properly. Please refer 
to the Cherokee mailing list of you're unaware of these issues. It should be 
fixed in v1.09 which is coming soon. Thanks!

On Oct 28, 2010, at 14:51, Robbington  wrote:

> 
> Hi Max,
> 
> I am not sure what you mean by ' Do not use the uwsgi wizard: it's
> currently broken'?
> 
> Rob,
> 
> Ps, should you wish to discuss this further, perhaps it is better you
> email me directly, as to avoid filling Karims post with unnecessary
> messages.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



RE: newbie having trouble with conversion to south

2010-10-28 Thread Sells, Fred
I have played with VirtualEnv, but not really applied it.  My biggest
concern would be automating a
Restart if the server reboots.  Also since I'm "old school" and using
Apache with mod_python for
Django, I'm not if that's a problem.  To be honest, I have not
researched VirtualEnv much because my
Management is reluctant to "add on"  due to security concerns in a HIPAA
environment.

-Original Message-
From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of Shawn Milochik
Sent: Thursday, October 28, 2010 2:35 PM
To: django-users@googlegroups.com
Subject: Re: newbie having trouble with conversion to south

>From the traceback it seems that your hypothesis about the Python
version may be correct. I don't know what versions of Python South
tests with.

However, I'm in the same situation you are (Cent OS), and I get along
wonderfully with virtualenv. I'm using Python 2.7 and everything's
grand. If you need help with this let me know.

Shawn

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


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



Re: Cherokee for home developing

2010-10-28 Thread Cal Leeming [Simplicity Media Ltd]
I use Django + UWSGI + Cherokee with all my sites , with around 200k page
views a day.

Various teething problems, but generally stable.

On Thu, Oct 28, 2010 at 7:32 PM, Max Countryman  wrote:

> Oh I forgot to mention! Do not use the uwsgi wizard: it's currently broken.
> Expect a fix soon and refer to the various threads detailing the set up
> process without the wizard on Cherokee's mailing list.
>
> On Oct 28, 2010, at 14:06, Robbington  wrote:
>
> > Glad to finally see some one using Cherokee with django. Dont just use
> > it in development, its actually less memory intensive than apache as
> > well as having an awesome admin interface.
> >
> > Anyway enough plugging.
> >
> > To avoid problems and for simplicty I would advise using Cherokee
> > Uwsgi config to serve up your python code.
> >
> > Rob
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 

Cal Leeming

Operational Security & Support Team

*Out of Hours: *+44 (07534) 971120 | *Support Tickets: *
supp...@simplicitymedialtd.co.uk
*Fax: *+44 (02476) 578987 | *Email: *cal.leem...@simplicitymedialtd.co.uk
*IM: *AIM / ICQ / MSN / Skype (available upon request)
Simplicity Media Ltd. All rights reserved.
Registered company number 7143564

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



Re: Cherokee for home developing

2010-10-28 Thread Robbington

Hi Max,

I am not sure what you mean by ' Do not use the uwsgi wizard: it's
currently broken'?

Rob,

Ps, should you wish to discuss this further, perhaps it is better you
email me directly, as to avoid filling Karims post with unnecessary
messages.

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



Re: Using localflavor with admin?

2010-10-28 Thread Frank Wiles
On Thu, Oct 28, 2010 at 12:23 AM, Victor Hooi  wrote:
> Hi,
>
> Is there any way to combine the localflavor module (http://
> docs.djangoproject.com/en/dev/ref/contrib/localflavor/) with Django's
> in-built admin module?
>
> For example, I'd like to create a model with say, a Postcode and phone-
> number field, and have these validated in the admin, as per the rules
> setup in localflavor?

Hi Victor,

You just need to use the the model fields to achieve this.  So for
example, if I was going to do a US Phone Number field I would do:

from django.db import models
from django.contrib.localflavor.us.models import PhoneNumberField

class Test(models.Model):
phone = PhoneNumberField()

You'd obviously need to reference the exact field you're looking for,
but then it just automagically works in the admin.

-- 
Frank Wiles
Revolution Systems | http://www.revsys.com/
fr...@revsys.com   | (800) 647-6298

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



Re: Database error: Table 'test_XXX.django_content_type' doesn't exist

2010-10-28 Thread Frank Wiles
On Thu, Oct 28, 2010 at 1:27 AM, girish shabadimath
 wrote:
> Hi all,
> im using django 1.2
> there are two databases involved in my project (default and XYZ (used only
> for migration))
> i use a consistant MySQL storage type for all apps, all models (including
> m2m).
> This is done by registering a post-syncdb  signal in management.py
> file which converts all tables to innodb.
> (code partially taken from:
> http://code.djangoproject.com/wiki/AlterModelOnSyncDB )
> (Description of management.py magic is at
> http://code.djangoproject.com/wiki/Signals)
>
> i wrote few tests for one of my application,
> when i run ./manage.py test following error occurs:
> DatabaseError: (1146, "Table 'test_XXX.django_content_type' doesn't exist")
> any clues?

I wager if you do a syncdb to another database (as test is doing for
you) you'll find that the table 'django_content_type' does indeed not
exist. Possibly because you don't have 'django.contrib.contenttypes'
in INSTALLED_APPS.

-- 
Frank Wiles
Revolution Systems | http://www.revsys.com/
fr...@revsys.com   | (800) 647-6298

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



Re: newbie having trouble with conversion to south

2010-10-28 Thread Shawn Milochik
>From the traceback it seems that your hypothesis about the Python
version may be correct. I don't know what versions of Python South
tests with.

However, I'm in the same situation you are (Cent OS), and I get along
wonderfully with virtualenv. I'm using Python 2.7 and everything's
grand. If you need help with this let me know.

Shawn

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



Re: Cherokee for home developing

2010-10-28 Thread Max Countryman
Oh I forgot to mention! Do not use the uwsgi wizard: it's currently broken. 
Expect a fix soon and refer to the various threads detailing the set up process 
without the wizard on Cherokee's mailing list. 

On Oct 28, 2010, at 14:06, Robbington  wrote:

> Glad to finally see some one using Cherokee with django. Dont just use
> it in development, its actually less memory intensive than apache as
> well as having an awesome admin interface.
> 
> Anyway enough plugging.
> 
> To avoid problems and for simplicty I would advise using Cherokee
> Uwsgi config to serve up your python code.
> 
> Rob
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Cherokee for home developing

2010-10-28 Thread Max Countryman
Rob, 

I have been using Cherokee for Django deployment for almost a year now. I know 
several other devs who prefer it as well. Also there's always some activity on 
the Cherokee list itself related to Django. 

On Oct 28, 2010, at 14:06, Robbington  wrote:

> Glad to finally see some one using Cherokee with django. Dont just use
> it in development, its actually less memory intensive than apache as
> well as having an awesome admin interface.
> 
> Anyway enough plugging.
> 
> To avoid problems and for simplicty I would advise using Cherokee
> Uwsgi config to serve up your python code.
> 
> Rob
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Cherokee for home developing

2010-10-28 Thread Karim Gorjux
On Thu, Oct 28, 2010 at 21:06, Robbington  wrote:
> Glad to finally see some one using Cherokee with django. Dont just use
> it in development, its actually less memory intensive than apache as
> well as having an awesome admin interface.

Now I can just develop on Django with Cherokee I haven't any hosting
at the momento

> Anyway enough plugging.
>
> To avoid problems and for simplicty I would advise using Cherokee
> Uwsgi config to serve up your python code.

Now I solved all my problems working with settings.py. Seems that also
the debug works, but If I'll be again in trouble I'll get a try at
uwsgi.

Anyway the Cherokee server is hosted in a VirtualBox on my Mac. I had
a lot of trouble trying to configure a web server with django on the
Mac and I'm really happy to had found this solution.

Thanks Rob for the support :-)

-- 
K.
Blog Personale: http://www.karimblog.net

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



newbie having trouble with conversion to south

2010-10-28 Thread Sells, Fred
I’m using django 1.2.1, Python 2.4 and MySQL 5.0 and south 0.7.2

 

I’ve got an existing app, aptly named “app” which I’m am trying to convert to 
south so I can make some DB changes.  It seemed to install OK and I get to 
here.  At which point I’m lost.  Could it be that Python 2.4 logging is not 
compatible with south?  I’m currently locked in to Python 2.4 to match the 
release packaged with CentOs.  That’s a management edict and there’s no point 
in trying to get them to change just because it would make sense.

 

C:\temp\DjangoSouthRecovery\mds30>python manage.py schemamigration app --auto

 ? The field 'Facility.FAC_ID' does not have a default specified, yet is NOT 
NULL.

 ? Since you are adding this field, you MUST specify a default

 ? value to use for existing rows. Would you like to:

 ?  1. Quit now, and add a default to the field in models.py

 ?  2. Specify a one-off value to use for existing columns now

 ? Please select a choice: 2

 ? Please enter Python code for your one-off default value.

 ? The datetime module is available, so you can do e.g. datetime.date.today()

 >>> 'xxx'

 + Added field FAC_ID on app.Facility

Created 0002_auto__add_field_facility_FAC_ID.py. You can now apply this 
migration with: ./manage.py migrate app

 

C:\temp\DjangoSouthRecovery\mds30>python manage.py migrate app

Running migrations for app:

 - Migrating forwards to 0002_auto__add_field_facility_FAC_ID.

 > app:0002_auto__add_field_facility_FAC_ID

Traceback (most recent call last):

  File "manage.py", line 11, in ?

execute_manager(settings)

  File 
"c:\alltools\python\Lib\site-packages\django\core\management\__init__.py", line 
438, in execute_manager

utility.execute()

  File 
"c:\alltools\python\Lib\site-packages\django\core\management\__init__.py", line 
379, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

  File "c:\alltools\python\Lib\site-packages\django\core\management\base.py", 
line 191, in run_from_argv

self.execute(*args, **options.__dict__)

  File "c:\alltools\python\Lib\site-packages\django\core\management\base.py", 
line 218, in execute

output = self.handle(*args, **options)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\management\commands\migrate.py",
 line 105, in handle

ignore_ghosts = ignore_ghosts,

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\__init__.py",
 line 191, in migrate_app

success = migrator.migrate_many(target, workplan, database)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\migrators.py",
 line 221, in migrate_many

result = migrator.__class__.migrate_many(migrator, target, migrations, 
database)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\migrators.py",
 line 292, in migrate_many

result = self.migrate(migration, database)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\migrators.py",
 line 125, in migrate

result = self.run(migration)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\migrators.py",
 line 98, in run

dry_run.run_migration(migration)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\migrators.py",
 line 177, in run_migration

self._run_migration(migration)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\migrators.py",
 line 167, in _run_migration

raise exceptions.FailedDryRun(migration, sys.exc_info())

south.exceptions.FailedDryRun:  ! Error found during dry run of 
'0002_auto__add_field_facility_FAC_ID'! Aborting.

Traceback (most recent call last):

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\migrators.py",
 line 164, in _run_migration

migration_function()

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\migration\migrators.py",
 line 57, in 

return (lambda: direction(orm))

  File 
"C:\temp\DjangoSouthRecovery\mds30\..\mds30\app\migrations\0002_auto__add_field_facility_FAC_ID.py",
 line 12, in forwards

db.add_column('facility', 'FAC_ID', 
self.gf('django.db.models.fields.CharField')(default='xxx', max_length=16), 
keep_default=False)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\db\generic.py",
 line 269, in add_column

self.execute(sql)

  File 
"c:\alltools\python\lib\site-packages\south-0.7.2-py2.4.egg\south\db\generic.py",
 line 129, in execute

get_logger().debug('south execute "%s" with params "%s"' % (sql, params), 
extra={

  File "c:\alltools\python\lib\logging\__init__.py", line 918, in debug

apply(self._log, (DEBUG, msg, args), kwargs)

TypeError: _log() got an unexpected keyword argument 'extra'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to 

Re: Cherokee for home developing

2010-10-28 Thread Robbington
Glad to finally see some one using Cherokee with django. Dont just use
it in development, its actually less memory intensive than apache as
well as having an awesome admin interface.

Anyway enough plugging.

To avoid problems and for simplicty I would advise using Cherokee
Uwsgi config to serve up your python code.

Rob

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



Re: Cherokee for home developing

2010-10-28 Thread Karim Gorjux
On Thu, Oct 28, 2010 at 19:32, Karim Gorjux  wrote:
> Hi all! I'm trying to create my devbox for Django and I use a server

I fixed the problem with the settings.py and now admin works.

The problem now is to avoid the flup's "Unhandled Exception" and let
django shows it debug

-- 
K.
Blog Personale: http://www.karimblog.net

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



Re: How to aggregate values by month

2010-10-28 Thread Javier Guerra Giraldez
2010/10/28 Rogério Carrasqueira :
> Thanks for you answer. Unfortunatelly I need to output my results on a JSON
> file. Do you have any other approach?

if the {% regroup %} is what you need, you should know that it's an
application of itertools.groupby()

-- 
Javier

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



Re: Factory Squirrel

2010-10-28 Thread Phlip
Tx! But!

> http://github.com/dnerdy/factory_boy

How does this do aggregation?

> Also, there is a more general python 
> solution:http://farmdev.com/projects/fixture/ that supports django.

That one's a little _too_ general. But it supports aggregation
(association, etc.)..

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



Re: help with model definition

2010-10-28 Thread pixelcowboy
Yes, it works! Thanks so much, that is the perfect solution!
Inheritance in Django in my opinion should do much more, but in this
case it actually does the job!

On Oct 27, 2:31 pm, pixelcowboy  wrote:
> The second solution would be great, but is the relationship inherited?
> I didnt think that was possible. Will try it out, first solution is
> also an option. Thanks for your help.
>
> On Oct 27, 1:35 pm, Marc Aymerich  wrote:
>
> > On Tue, Oct 26, 2010 at 6:21 PM, pixelcowboy wrote:
>
> > > I have a question regarding the best way to conceptualize a model. I
> > > have a tasks model, which I want to hook to a few different other
> > > models: The model Project, the model Company and a few other undefined
> > > models. The problem is that I want a particular instance of the task
> > > to be pluggable to one and only one of those models, which I dont know
> > > how I would achieve using 2 or more separate foreign keys. The only
> > > idea I have is to use generic relationships, and unique them. Any
> > > ideas?
>
> > Maybe something like this?
>
> > class Base(models.Model):
> >     pass
>
> > class Project(Base):
> >     pass
>
> > class Company(Base):
> >     pass
>
> > class Task(models.Model):
> >      base = models.ForeignKey(Base)
>
> > --
> > Marc

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



Re: overriding save-method

2010-10-28 Thread Patrick
that's how i did it finally... i had to refresh my knowledge about the
property statement first :) thanks again!

class Setting(models.Model):
name = models.CharField(max_length=100)
_value_json = models.TextField()
def _set_json_value(self, value):
self._value_json = json.dumps(value)
def _get_json_value(self):
return json.loads(self._value_json)
value = property(_get_json_value, _set_json_value)

On 27 Okt., 23:40, Patrick  wrote:
> hm .. i thought of that too but i considered it not to be the best
> approach.
> i will try that snippet though.. thank you!
>
> On 27 Okt., 15:49, Shawn Milochik  wrote:
>
> > Try this instead:
>
> >http://djangosnippets.org/snippets/1478/
>
> > Or you could do it manually in your model:
>
> > 1. Add field _value_json to your model.
> > 2. Add functions (get_value, set_value) which do the simplejson work.
> > 3. Add a property named 'value' with get_value and set_value as its
> > getter and setter.

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



Cherokee for home developing

2010-10-28 Thread Karim Gorjux
Hi all! I'm trying to create my devbox for Django and I use a server
in my lan with Ubuntu and Cherokee installed in. For every project I
use virtualenv so I install django and flup and I create in cherokee
panel the virtual server using the path of my virtualenv. All I do is
explained in the Cherokee documentation page.

The only change I do is the interpreter in Information Resource
Settings where I use the absolute path of the python executable on my
virtualenv.

The browser at my virtual host's ulr show the "it worked!" message, if
I just try to enable the admin and I try to go there in the browser I
get this message:

Unhandled Exception
An unhandled exception was thrown by the application.

This is really strange. If I try to reload the url, I get randomly a
"Unhandled Exception" or a "It worked!" message.

I tried also with an application that I develop that I'm sure it
worked before and with my surprise still works in cherokee, but if I
try to get the admin page I simply can't. The result is the same error
ad describe above.

Anyone could help me? I'm really near to get my devbox working and
never think about deploying or the stuff around that anymore... help
me just developing!

Thanks in advance! :-)

-- 
K.
Personal Blog: http://www.karimblog.net

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



Re: How to aggregate values by month

2010-10-28 Thread Casey S. Greene

Hi Rogério,

You can output to json using templates if this is the only thing holding 
you back from a working solution using regroup.  You can use 
render_to_string with a json template which you can then return with an 
HttpResponse.  It doesn't take advantage of the serialization library 
but it does work.


-- Casey

On 10/28/2010 09:41 AM, Rogério Carrasqueira wrote:

Hi Franklin!

Thanks for you answer. Unfortunatelly I need to output my results on a
JSON file. Do you have any other approach?

Cheers,

Rogério Carrasqueira

---
e-mail: rogerio.carrasque...@gmail.com

skype: rgcarrasqueira
MSN: rcarrasque...@hotmail.com 
ICQ: 50525616
Tel.: (11) 7805-0074



2010/10/28 Franklin Einspruch >

It may not be a complete answer, but you should know about {% regroup
%} just in case:


http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#regroup

- Franklin

--
Art, writing, journal: http://einspruch.com
Comics: http://themoonfellonme.com




2010/10/28 Rogério Carrasqueira >:
 > Hello!
 >
 > I'm having an issue to make complex queries in django. My problem
is, I have
 > a model where I have the sales and I need to make a report
showing the sales
 > amount per month, by the way I made this query:
 >
 > init_date = datetime.date(datetime.now()-timedelta(days=365))
 > ends_date = datetime.date(datetime.now())
 > sales =
 >

Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_created__month).aggregate(total_sales=Sum('total_value'))
 >
 > At the first line I get the today's date past one year
 > after this I got the today date
 >
 > at sales I'm trying to between a range get the sales amount
grouped by
 > month, but unfortunatelly I was unhappy on this, because this error
 > appeared:
 >
 > global name 'date_created__month' is not defined
 >
 > At date_created is the field where I store the information about
when the
 > sale was done., the __moth was a tentative to group by this by month.
 >
 > So, my question: how to do that thing without using a raw sql
query and not
 > touching on database independence?
 >
 > Thanks so much!
 >
 > Rogério Carrasqueira
 >
 > ---
 > e-mail: rogerio.carrasque...@gmail.com

 > skype: rgcarrasqueira
 > MSN: rcarrasque...@hotmail.com 
 > ICQ: 50525616
 > Tel.: (11) 7805-0074
 >
 > --
 > You received this message because you are subscribed to the
Google Groups
 > "Django users" group.
 > To post to this group, send email to
django-users@googlegroups.com .
 > To unsubscribe from this group, send email to
 > django-users+unsubscr...@googlegroups.com
.
 > For more options, visit this group at
 > http://groups.google.com/group/django-users?hl=en.
 >

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


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


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



Re: How to aggregate values by month

2010-10-28 Thread Scott Gould
Personally I hate writing raw SQL so I would probably try something
like this (untested):

sales = Sale.objects.filter(date_created__range=(init_date,ends_date))
.values(date_ created__month)
.aggregate(total_sales=Sum('total_value'))

sales_by_month = [(x.year, x.month, [y for y in sales if y.year ==
x.year and y.month == x.month])
for x in set([z.year, z.month for z in sales])]

Should give you a list of (year, month, subqueryset) tuples. Of
course, there might be performance issues with nested list
comprehensions like that depending on the size of the initial
queryset, but at least it's a one-line, SQL-free solution!

On Oct 28, 9:31 am, Rogério Carrasqueira
 wrote:
> Hello!
>
> I'm having an issue to make complex queries in django. My problem is, I have
> a model where I have the sales and I need to make a report showing the sales
> amount per month, by the way I made this query:
>
> init_date = datetime.date(datetime.now()-timedelta(days=365))
> ends_date = datetime.date(datetime.now())
> sales =
> Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_ 
> created__month).aggregate(total_sales=Sum('total_value'))
>
> At the first line I get the today's date past one year
> after this I got the today date
>
> at sales I'm trying to between a range get the sales amount grouped by
> month, but unfortunatelly I was unhappy on this, because this error
> appeared:
>
> global name 'date_created__month' is not defined
>
> At date_created is the field where I store the information about when the
> sale was done., the __moth was a tentative to group by this by month.
>
> So, my question: how to do that thing without using a raw sql query and not
> touching on database independence?
>
> Thanks so much!
>
> Rogério Carrasqueira
>
> ---
> e-mail: rogerio.carrasque...@gmail.com
> skype: rgcarrasqueira
> MSN: rcarrasque...@hotmail.com
> ICQ: 50525616
> Tel.: (11) 7805-0074

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



Re: How to aggregate values by month

2010-10-28 Thread Rogério Carrasqueira
Hello Everybody!

I tried this way also:

sales = Sale.objects.extra(select={'
month':
'month(date_created)'}).filter(date_created__range=(init_date,ends_date)).values('month').aggregate(total_sales=Sum('total_value'))

but returned {}

Any ideias?

Cheers,

Rogério Carrasqueira

---
e-mail: rogerio.carrasque...@gmail.com
skype: rgcarrasqueira
MSN: rcarrasque...@hotmail.com
ICQ: 50525616
Tel.: (11) 7805-0074



Em 28 de outubro de 2010 11:41, Rogério Carrasqueira <
rogerio.carrasque...@gmail.com> escreveu:

> Hi Franklin!
>
> Thanks for you answer. Unfortunatelly I need to output my results on a JSON
> file. Do you have any other approach?
>
> Cheers,
>
>
> Rogério Carrasqueira
>
> ---
> e-mail: rogerio.carrasque...@gmail.com
> skype: rgcarrasqueira
> MSN: rcarrasque...@hotmail.com
> ICQ: 50525616
> Tel.: (11) 7805-0074
>
>
>
> 2010/10/28 Franklin Einspruch 
>
> It may not be a complete answer, but you should know about {% regroup
>> %} just in case:
>>
>>
>> http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#regroup
>>
>> - Franklin
>>
>> --
>> Art, writing, journal: http://einspruch.com
>> Comics: http://themoonfellonme.com
>>
>>
>>
>>
>> 2010/10/28 Rogério Carrasqueira :
>> > Hello!
>> >
>> > I'm having an issue to make complex queries in django. My problem is, I
>> have
>> > a model where I have the sales and I need to make a report showing the
>> sales
>> > amount per month, by the way I made this query:
>> >
>> > init_date = datetime.date(datetime.now()-timedelta(days=365))
>> > ends_date = datetime.date(datetime.now())
>> > sales =
>> >
>> Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_created__month).aggregate(total_sales=Sum('total_value'))
>> >
>> > At the first line I get the today's date past one year
>> > after this I got the today date
>> >
>> > at sales I'm trying to between a range get the sales amount grouped by
>> > month, but unfortunatelly I was unhappy on this, because this error
>> > appeared:
>> >
>> > global name 'date_created__month' is not defined
>> >
>> > At date_created is the field where I store the information about when
>> the
>> > sale was done., the __moth was a tentative to group by this by month.
>> >
>> > So, my question: how to do that thing without using a raw sql query and
>> not
>> > touching on database independence?
>> >
>> > Thanks so much!
>> >
>> > Rogério Carrasqueira
>> >
>> > ---
>> > e-mail: rogerio.carrasque...@gmail.com
>> > skype: rgcarrasqueira
>> > MSN: rcarrasque...@hotmail.com
>> > ICQ: 50525616
>> > Tel.: (11) 7805-0074
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com
>> .
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: How to aggregate values by month

2010-10-28 Thread Rogério Carrasqueira
Hi Franklin!

Thanks for you answer. Unfortunatelly I need to output my results on a JSON
file. Do you have any other approach?

Cheers,

Rogério Carrasqueira

---
e-mail: rogerio.carrasque...@gmail.com
skype: rgcarrasqueira
MSN: rcarrasque...@hotmail.com
ICQ: 50525616
Tel.: (11) 7805-0074



2010/10/28 Franklin Einspruch 

> It may not be a complete answer, but you should know about {% regroup
> %} just in case:
>
>
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#regroup
>
> - Franklin
>
> --
> Art, writing, journal: http://einspruch.com
> Comics: http://themoonfellonme.com
>
>
>
>
> 2010/10/28 Rogério Carrasqueira :
> > Hello!
> >
> > I'm having an issue to make complex queries in django. My problem is, I
> have
> > a model where I have the sales and I need to make a report showing the
> sales
> > amount per month, by the way I made this query:
> >
> > init_date = datetime.date(datetime.now()-timedelta(days=365))
> > ends_date = datetime.date(datetime.now())
> > sales =
> >
> Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_created__month).aggregate(total_sales=Sum('total_value'))
> >
> > At the first line I get the today's date past one year
> > after this I got the today date
> >
> > at sales I'm trying to between a range get the sales amount grouped by
> > month, but unfortunatelly I was unhappy on this, because this error
> > appeared:
> >
> > global name 'date_created__month' is not defined
> >
> > At date_created is the field where I store the information about when the
> > sale was done., the __moth was a tentative to group by this by month.
> >
> > So, my question: how to do that thing without using a raw sql query and
> not
> > touching on database independence?
> >
> > Thanks so much!
> >
> > Rogério Carrasqueira
> >
> > ---
> > e-mail: rogerio.carrasque...@gmail.com
> > skype: rgcarrasqueira
> > MSN: rcarrasque...@hotmail.com
> > ICQ: 50525616
> > Tel.: (11) 7805-0074
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How to aggregate values by month

2010-10-28 Thread Franklin Einspruch
It may not be a complete answer, but you should know about {% regroup
%} just in case:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#regroup

- Franklin

-- 
Art, writing, journal: http://einspruch.com
Comics: http://themoonfellonme.com




2010/10/28 Rogério Carrasqueira :
> Hello!
>
> I'm having an issue to make complex queries in django. My problem is, I have
> a model where I have the sales and I need to make a report showing the sales
> amount per month, by the way I made this query:
>
> init_date = datetime.date(datetime.now()-timedelta(days=365))
> ends_date = datetime.date(datetime.now())
> sales =
> Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_created__month).aggregate(total_sales=Sum('total_value'))
>
> At the first line I get the today's date past one year
> after this I got the today date
>
> at sales I'm trying to between a range get the sales amount grouped by
> month, but unfortunatelly I was unhappy on this, because this error
> appeared:
>
> global name 'date_created__month' is not defined
>
> At date_created is the field where I store the information about when the
> sale was done., the __moth was a tentative to group by this by month.
>
> So, my question: how to do that thing without using a raw sql query and not
> touching on database independence?
>
> Thanks so much!
>
> Rogério Carrasqueira
>
> ---
> e-mail: rogerio.carrasque...@gmail.com
> skype: rgcarrasqueira
> MSN: rcarrasque...@hotmail.com
> ICQ: 50525616
> Tel.: (11) 7805-0074
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



How to aggregate values by month

2010-10-28 Thread Rogério Carrasqueira
Hello!

I'm having an issue to make complex queries in django. My problem is, I have
a model where I have the sales and I need to make a report showing the sales
amount per month, by the way I made this query:

init_date = datetime.date(datetime.now()-timedelta(days=365))
ends_date = datetime.date(datetime.now())
sales =
Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_created__month).aggregate(total_sales=Sum('total_value'))

At the first line I get the today's date past one year
after this I got the today date

at sales I'm trying to between a range get the sales amount grouped by
month, but unfortunatelly I was unhappy on this, because this error
appeared:

global name 'date_created__month' is not defined


At date_created is the field where I store the information about when the
sale was done., the __moth was a tentative to group by this by month.

So, my question: how to do that thing without using a raw sql query and not
touching on database independence?

Thanks so much!

Rogério Carrasqueira

---
e-mail: rogerio.carrasque...@gmail.com
skype: rgcarrasqueira
MSN: rcarrasque...@hotmail.com
ICQ: 50525616
Tel.: (11) 7805-0074

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



Re: Famous 'ascii' codec can't decode byte 0xc3 error

2010-10-28 Thread Tom Evans
On Thu, Oct 28, 2010 at 11:41 AM, Duong Dang  wrote:
> Hi,
>
> I am having the following unicode error with django 1.2:
>
> ./standalone.py print the string out just fine. But in in my app, when
> ever mymodel.update() is called I get this famous error: 'ascii' codec
> can't decode byte 0xc3
>
> Thanks
>
>
> standalone.py:
> # -*- coding: utf-8 -
> *-
> def unicodestring():
>   blah blah
>   an_unicode_string  = "%s %s %s"%(s1,s2,s3)
>   return an_unicode_string

an_unicode_string is not a unicode string. unicode strings are defined
like this: u"foo".

>
> if __name__=="__main__":
>    print unicodestring()
>
> ---
> somedjangoapp/models.py:
> # -*- coding: utf-8 -*-
> from django.db import
> models
> class SomeModel(models.Model)
>    blahblah
>    def update(self)
>         foo = unicodestring()
>         return
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Data error

2010-10-28 Thread Karen Tracey
On Thu, Oct 28, 2010 at 5:45 AM, Hussain Deikna  wrote:

> Hi, I am newbe in django and I have got this Error
>
> '
>
> coercing to Unicode: need string or buffer, Product found '
>
> what's that mean? thank you for your attention
>
>
It means the __unicode__ method for some model is returning a Product
object, not unicode. __unicode__ methods must return unicode (or string or
buffer, which Python can coerce to unicode).

Karen

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



Re: ATTRIBUTE ERROR

2010-10-28 Thread yu xue
Hi, I feel there are some places which need to modify:
1. urlpatterns should be  (r"^wap/di/sub/$", current_datetime),
2. It seems that the view function is endless loop...


2010/10/28 sami nathan 

> My occured Error is
>
> Exception Value:
>
> 'str' object has no attribute 'resolve'
>
> Exception Location:
>C:\Python25\Lib\site-packages\django\core\urlresolvers.py in
> resolve,
> line 217
>
> ~
> MY URLS.PY LOOKS LIKE THIS
> from django.conf.urls.defaults import *
> from flip.view import current_datetime
>
> urlpatterns = ('',
># Example:
>
>   (r"^wap/di/sub",current_datetime)
>
> )
># Uncomment the admin/doc line below to enable admin documentation:
># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
># Uncomment the next line to enable the admin:
># (r'^admin/', include(admin.site.urls))
> My view .py Looks like this
> from django.http import *
> import urllib
>
> def current_datetime(request):
>word = request.GET['word']
>message = urllib.urlopen('
> http://m.broov.com/wap/di/sub?word='+word+'=00submit=Submit
> ',)
>return HttpResponse (message)
>
> Please help me i dont na what happens it was running succesfully but
> noow its not
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
 此致
敬礼!
   薛宇

   身前身后
   是时间的深渊

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



Re: 'str' object has no attribute 'resolve' Exception Location: C:\Python25\Lib\site-packages\django\core\urlresolvers.py in resolve,

2010-10-28 Thread Suraj Jacob
change it from
(r"wap/di/sub",current_datetime)

to
(r'^wap/di/sub','current_datetime')


On Thu, Oct 28, 2010 at 15:52, sami nathan  wrote:

> (r"^wap/di/sub",current_datetime)
>

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



Re: Data error

2010-10-28 Thread Suraj Jacob
means your object cannot be converted into string. You have to either
provide a __unicode__ or __str__ for your model, or pick a particular field
that you are trying to coerce with the rest of the string

On Thu, Oct 28, 2010 at 15:15, Hussain Deikna  wrote:

> Hi, I am newbe in django and I have got this Error
>
> '
>
> coercing to Unicode: need string or buffer, Product found '
>
> what's that mean? thank you for your attention
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Famous 'ascii' codec can't decode byte 0xc3 error

2010-10-28 Thread Duong Dang
Hi,

I am having the following unicode error with django 1.2:

./standalone.py print the string out just fine. But in in my app, when
ever mymodel.update() is called I get this famous error: 'ascii' codec
can't decode byte 0xc3

Thanks


standalone.py:
# -*- coding: utf-8 -
*-
def unicodestring():
   blah blah
   an_unicode_string  = "%s %s %s"%(s1,s2,s3)
   return an_unicode_string

if __name__=="__main__":
print unicodestring()

---
somedjangoapp/models.py:
# -*- coding: utf-8 -*-
from django.db import
models
class SomeModel(models.Model)
blahblah
def update(self)
 foo = unicodestring()
 return

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



How will you query?

2010-10-28 Thread MintX
Hi, all.

I want to increase some integer value until limit.

And.. all instance would have different increasing value and different
limit.

I modeled like this:

class Foo( models.Model ):
value = models.IntegerField(default=0)
delta = models.IntegerField(default=1)
limit = models.IntegerField(default=100)

#1: with raw SQL query
cursor.execute(
"UPDATE foo SET value = CASE WHEN value + delta < limit THEN value
+ delta ELSE limit END"
)

#2: with django's ORM (is there more elegant way?)

@transaction.commit_on_success()
def update_foo():
foo.objects.all().update( value= F("value") + F("delta") )
foo.objects.filter(value__gt=F("limit")).update( value=
F("limit")  )

#1 is faster than #2 in my case and environment.

I want to know which is better Django's design. Or some another good
way?

How do you code it? :)

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



Re: DatabaseError: (1146, "Table 'test_XXX.django_content_type' doesn't exist")

2010-10-28 Thread Suraj Jacob
I took a look at http://code.djangoproject.com/wiki/AlterModelOnSyncDB

here's the code in it:


for model in created_models:
db_table=model._meta.db_table
if db_table not in skip:
skip.add(db_table)
engine = storage.get(model._meta.db_table,default_storage)
stmt = 'ALTER TABLE %s ENGINE=%s' % (db_table,engine)


I think that maybe because youve defined tests in your apps, the test models
are also returned in created models.
Add some debug statements to see which tables are actually being altered. If
its trying to alter the test_* tables, they obviously wont be there, because
theyre created only while running the tests...

The fix mite be as simple as putting the test_ tables in the skip set.

-
Suraj Jacob
On Thu, Oct 28, 2010 at 14:56, girish shabadimath
wrote:

>
> Hi all,
>
> im re-sending this mail, am i missing any thing here?
>
>
> im using django 1.2
> there are two databases involved in my project (default and XYZ (used only
> for migration))
>
> i use a consistant MySQL storage type for all apps, all models (including
> m2m).
> This is done by registering a post-syncdb  signal in management.py
> file which converts all tables to innodb.
> (code partially taken from:
> http://code.djangoproject.com/wiki/AlterModelOnSyncDB )
>
> (Description of management.py magic is at
> http://code.djangoproject.com/wiki/Signals)
>
>
> i wrote few tests for one of my application,
>
> when i run ./manage.py test following error occurs:
>
> DatabaseError: (1146, "Table 'test_XXX.django_content_type' doesn't exist")
>
> any clues?
> --
> Girish M S
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



form.htm division

2010-10-28 Thread tariq
HI
I want to divide form.html of satchmo into separate parts. I mean I
want to separate Billing information and shipping information on two
separate templates in satchmo. Is there anyone which can help me.

is it possible or not??

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



'str' object has no attribute 'resolve' Exception Location: C:\Python25\Lib\site-packages\django\core\urlresolvers.py in resolve,

2010-10-28 Thread sami nathan
-- Forwarded message --
From: sami nathan 
Date: Thu, Oct 28, 2010 at 3:41 PM
Subject: ATTRIBUTE ERROR
To: django-users@googlegroups.com


My occured Error is

Exception Value:

'str' object has no attribute 'resolve'

Exception Location:
       C:\Python25\Lib\site-packages\django\core\urlresolvers.py in resolve,
line 217
~
MY URLS.PY LOOKS LIKE THIS
from django.conf.urls.defaults import *
from flip.view import current_datetime

urlpatterns = ('',
   # Example:

      (r"^wap/di/sub",current_datetime)

)
   # Uncomment the admin/doc line below to enable admin documentation:
   # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
   # Uncomment the next line to enable the admin:
   # (r'^admin/', include(admin.site.urls))
My view .py Looks like this
from django.http import *
import urllib

def current_datetime(request):
   word = request.GET['word']
   message = 
urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'=00submit=Submit',)
   return HttpResponse (message)

Please help me i dont na what happens it was running succesfully but
noow its not

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



ATTRIBUTE ERROR

2010-10-28 Thread sami nathan
My occured Error is

Exception Value:

'str' object has no attribute 'resolve'

Exception Location:
C:\Python25\Lib\site-packages\django\core\urlresolvers.py in resolve,
line 217
~
MY URLS.PY LOOKS LIKE THIS
from django.conf.urls.defaults import *
from flip.view import current_datetime

urlpatterns = ('',
# Example:

   (r"^wap/di/sub",current_datetime)

)
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls))
My view .py Looks like this
from django.http import *
import urllib

def current_datetime(request):
word = request.GET['word']
message = 
urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'=00submit=Submit',)
return HttpResponse (message)

Please help me i dont na what happens it was running succesfully but
noow its not

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



Data error

2010-10-28 Thread Hussain Deikna
Hi, I am newbe in django and I have got this Error

'

coercing to Unicode: need string or buffer, Product found '

what's that mean? thank you for your attention

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



DatabaseError: (1146, "Table 'test_XXX.django_content_type' doesn't exist")

2010-10-28 Thread girish shabadimath
Hi all,

im re-sending this mail, am i missing any thing here?


im using django 1.2
there are two databases involved in my project (default and XYZ (used only
for migration))

i use a consistant MySQL storage type for all apps, all models (including
m2m).
This is done by registering a post-syncdb  signal in management.py
file which converts all tables to innodb.
(code partially taken from:
http://code.djangoproject.com/wiki/AlterModelOnSyncDB )

(Description of management.py magic is at
http://code.djangoproject.com/wiki/Signals)


i wrote few tests for one of my application,

when i run ./manage.py test following error occurs:

DatabaseError: (1146, "Table 'test_XXX.django_content_type' doesn't exist")

any clues?
-- 
Girish M S

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



Re: Import csv file in admin

2010-10-28 Thread Daniel Roseman
On Oct 28, 5:08 am, Jorge  wrote:
> Shame on me!
> I forgot to make some changes inside the for loop.
> So now it is:
>
>  def save(self, commit=True, *args, **kwargs):
>          form_input = super(DataInput, self).save(commit=False, *args,
>  **kwargs)
>          form_input.place = self.cleaned_data['place']
>          form_input.file = self.cleaned_data['file']
>          records = csv.reader(form_input.file)
>          for line in records:
>              form_input.time = datetime.strptime(line[1], "%m/%d/%y %H:
> %M:
>  %S")
>              form_input.data_1 = line[2]
>              form_input.data_2 = line[3]
>              form_input.data_3 = line[4]
>              form_input.save()
>
> But, i've got a new error message! an attribute error: 'NoneType'
> object has no attribute 'save'.
> What can it be?

Hang on, what you're doing here is repeatedly setting the data values
for each line to the *same* form_input model. Presumably what you
actually want to do is to create new Data instances for each line in
the CSV, with the place set to the value of the form.

In this case, I'd recommend not to bother with a ModelForm at all.
Instead, just use a standard Form, and create new Data instances in
your for loop:

class DataInput(forms.Form):
file = forms.FileField()
place = forms.ModelChoiceField(queryset=Places.objects.all())

def save(self):
 records = csv.reader(self.cleaned_data[file])
 for line in records:
 data_obj = Data()
 data_obj.time = datetime.strptime(line[1],
   "%m/%d/%y %H: %M: %S")
 data_obj.data_1 = line[2]
 data_obj.data_2 = line[3]
 data_obj.data_3 = line[4]
 data_obj.save()

--
DR.

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



Re: Displaying Profile model in a form

2010-10-28 Thread Venkatraman S
Also. check this : http://streamhacker.com/2010/03/01/django-model-formsets/

-V-
http://twitter.com/venkasub

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



Database error: Table 'test_XXX.django_content_type' doesn't exist

2010-10-28 Thread girish shabadimath
Hi all,

im using django 1.2
there are two databases involved in my project (default and XYZ (used only
for migration))

i use a consistant MySQL storage type for all apps, all models (including
m2m).
This is done by registering a post-syncdb  signal in management.py
file which converts all tables to innodb.
(code partially taken from:
http://code.djangoproject.com/wiki/AlterModelOnSyncDB )

(Description of management.py magic is at
http://code.djangoproject.com/wiki/Signals)


i wrote few tests for one of my application,

when i run ./manage.py test following error occurs:

DatabaseError: (1146, "Table 'test_XXX.django_content_type' doesn't exist")

any clues?

-- 
Girish M S

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