sqlite3 backend error

2010-05-04 Thread mf
Hi, before installing Ubunto 10.04 all of my projects worked pretty
well. Now I'm getting an error and I don't know how to solve it.

This is the result of running the python manage.py runserver command:

django.core.exceptions.ImproperlyConfigured:
'django.db.backends.sqlite3' 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: No module named _md5

 python version : 2.6.4
 django version: 1.2.0.'beta'.1

Thanks in advance for your time.

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



Change variable value after a click

2010-09-10 Thread mf
I'm working in a django view and I'd like to duplicate the
items_rating value of myview when I click to "see more categories" in
the template. All of this without refreshing the web.

I think that I have to use jquery and Ajax to perform this action but
I don't know how to do it. The examples I read about were about form
submissions and I couldn't find a way to use it.

views.py:

def myview(request):
items_rating = 5
html:

See more categories

-- 
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: Change variable value after a click

2010-09-13 Thread mf
What about using request.is_ajax() inside my view?.

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



Implementing accounts

2010-09-28 Thread mf
After finishing the core functionalities of my project it's time to
begin with other secundary but important things.

I've something like the following models.py file:

class Category(models.Model):
   name = models.CharField(max_length=30)

class Transaction(models.Model):
name = models.CharField(max_length=30)
description = models.TextField(blank=True)
amount = models.DecimalField(max_digits=12, decimal_places=2)
category = models.ForeignKey(Category,
related_name='transacciones', blank=True, null=True)

And this is what I want to do:

 Accounts: Each user can create different accounts.Example: the user A
have a home account with categories car and house, and a work account
with categories salary and bonuses. I don't know how to explain it
well, I'd like to have a "group of rows" for each account.

It seems pretty easy to do but I can't find the solution.


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



Language problem with date based generic views

2010-10-12 Thread mf
I've changed the language-code from en-us to es-ar and the url's began
to fail.
Example: When I click in "Agosto 2010" the URL is "http://mysite.com/
weblog/2010/**ago**/" and the server couldn't finde the page. But if I
browse "http://mysite.com/weblog/2010/**aug**/ the server finds and
shows the page.

urls.py:

urlpatterns = patterns('django.views.generic.date_based',
 (r'^$', 'archive_index', entry_info_dict,
'coltrane_entry_archive_index'),
 (r'^(?P\d{4})/$', 'archive_year', entry_info_dict,
  'coltrane_entry_archive_year'),
 (r'^(?P\d{4})/(?P\w{3})/$', 'archive_month',
entry_info_dict,
  'coltrane_entry_archive_month'),
)

templatetags.py:

@register.inclusion_tag('coltrane/month_links_snippet.html')
def render_month_links():
return {
'dates': Entry.objects.dates('pub_date', 'month'),
}

month_links_snippet.html:


  {% for d in dates reversed %}
{{ d|date:"F Y" }}
  {% endfor %}


-- 
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: Language problem with date based generic views

2010-10-12 Thread mf
Thanks Tom!, it worked perfectly fine.

On 12 oct, 12:00, Tom Evans  wrote:
> On Tue, Oct 12, 2010 at 3:32 PM, smallfish  wrote:
> > \w not include *, try use (.*)
> > --
> > blog:http://chenxiaoyu.org twitter: @nnfish
>
> I'm pretty sure he was just highlighting the differences between the
> two URLs; I don't think either actually have '*' in them.
>
> To the OP:
>
> Patient: 'It hurts when I do this'
> Doctor: 'Dont do that then!'
>
> Your issue is that your month names are generated in your URL using
> one localization, activated by the Request-Language sent by the user's
> browser, and another in your urlspec using your default localization.
>
> The blindingly obvious solution is to not use month names as part of
> the URL. The docs[1] say that you can configure
> django.views.generic.date_based.archive_month to use numeric indices
> by passing a month_format parameter.
>
> Cheers
>
> Tom
>
> [1]http://docs.djangoproject.com/en/1.2/ref/generic-views/#django-views-...

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



Add a create button for foreign keys(ModelForms)

2010-11-11 Thread mf
I have the following models.py file:

class Account(models.Model):
name = models.CharField(max_length=30)
user = models.ForeignKey(User, related_name='account_creator')

class Category(models.Model):
name = models.CharField(max_length=30)
account = models.ForeignKey(Account, related_name='categories')

class Transaction(models.Model):
name = models.CharField(max_length=30)
...
category = models.ForeignKey(Category,
related_name='transactions', blank=True, null=True)
account = models.ForeignKey(Account, related_name='transactions')

In a view I've a modelform for the Transaction class, but the problem
with it is that I can't add a category or an account from this form.
I'd like to know how to add a "create button" to the view/form. The
django admin does this pretty well but I can't find how to use 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.



How to except a TranslationError

2010-02-01 Thread mf
I'm translating a db from english to spanish with the Google
translator API. The problem is when a TranslationError occurs. I can
except the first one, but I don't know how to except again. It must be
a pythonic way to solve this, but I failed to find it.

Here's a snippet from the code:

english_field = oldDb[i].fieldData[0]
try:
spanish_field = translate(english_field, lang_to='es',
lang_from='en')
except TranslationError:
spanish_field = translate(english_field, lang_to='es',
lang_from='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.



[MODELS] Default value depending on other table field

2010-02-05 Thread mf
I have a table named service with a type field. The amount of the
service depends on the type field. The price of the type of service
could change. But the amount could sometimes be a different value,
because of special clients, discounts, etc...

I would like to fill the amount field with the default value of the
type.

http://pastebin.com/m674b51f2

Can this be done?

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



Utilization of get_FOO_display()

2010-02-08 Thread mf
I want to show the human-readable name for the type selected but I
keep getting the stored value.

TYPE_CHOICES = (
('0', 'Basic'),
('1', 'Full'),
('2', 'Intermediate'),
)

class ServiceType(models.Model):
type = models.IntegerField(max_length=1, choices=TYPE_CHOICES)
amount = models.DecimalField(max_digits=10, decimal_places=2)

def __unicode__(self):
return '%s' % (self.get_type_display())

http://pastebin.com/m7ff5a1de

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



Stock trading app

2010-02-09 Thread mf
Someone knows about an open source stock trading application?. I'm not
talking about a professional app, I mean a simple app where the
different stock holders of a company can sell/buy stocks between them.

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



Building a financial app with Django

2010-04-06 Thread mf
Hi guys, I'm building an app for a small business so I've to work with
currencies, decimal numbers, etc... My goal is to create something
like pulseapp.com.

I've searched for opensource projects to look and the only thing I had
found was django-cashflow. This app uses python-money.

I've read some of the code and the ways it's coded seems a bit weird
to me and it's not fully complete.

Is the app worth to take a deep look?

Does anyone know about another similar app?

Is the task difficult or a begginer like me could find a way to code
it himself?

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



Serializing a model with a pickefield field

2011-11-09 Thread mf
I need to serialize a django model which contains a pickefield. The
problem with this is that if I do the following:

python manage.py dumpdata myapp --indent=4 > data.json

I end up getting a data.json file with the following information in
each picklefield field:

"picklefield_field": "gAJ9cQEoVQZjb3BwZXJxAn1xAyh..."

Is there a simple way to solve this or I'd have to write a script
iterating over the models?

Thanks for your help.

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



Multiple access to static data

2011-12-03 Thread mf
I'm building an application and I'm having trouble making a choice
about how is the best way to access multiple times to static data in a
django app. My experience in the field is close to zero so I could use
some help.

The app basically consists in a drag & drop of foods. When you drag a
food to a determined place(breakfast for example) differents values
gets updated: total breakfast calories, total day nutrients(Micro/
Macro), total day calories, ...That's why I think the way I store and
access the data it's pretty important performance speaking.

This is an excerpt of the json file I'm currently using:

foods.json

{
"112": {
"type": "Vegetables",
"description": "Mushrooms",
"nutrients": {
"Niacin": {
"unit": "mg",
"group": "Vitamins",
"value": 3.79
},
"Lysine": {
"units": "g",
"group": "Amino Acids",
"value": 0.123
},
... (+40 nutrients)
"amount": 1,
"unit": "cup whole",
"grams": 87.0 }
 }

I've thought about different options:

1) JSON(The one I'm currently using):

Every time I drag a food to a "droppable" place, I call a getJSON
function to access the food data and then update the corresponding
values. This file has a 2mb size, but it surely will increase as I add
more foods to it. I'm using this option because it was the most
quickest to begin to build the app but I don't think it's a good
choice for the live app.

2) RDBMS with normalized fields:

I could create two models: Food and Nutrient, each food has 40+
nutrients related by a FK. The problem I see with this is that every
time a food data request is made, the app will hit the db a lot of
times to retrieve it.

3) RDBMS with picklefield:

This is the option I'm actually considering. I could create a Food
models and put the nutrients in a picklefield.

4) Something with Redis/Django Cache system:

I'll dive more deeply into this option. I've read some things about
them but I don't clearly know if there's some way to use them to solve
the problem I have.


Thanks in advance, Mariano.

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



Add custom html between two model fields in Django admin's change_form

2011-06-07 Thread mf
Let's say I've two models:

class Book(models.Model):
name = models.CharField(max_length=50)
library = models.ForeignKeyField('Library')

class Library(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=50)
tel = models.CharField(max_length=50)

Is there a nice way to add some html(a readonly input field) between
name and address in the Library change_form template?. I'm doing it
overriding [admin/includes/fieldset.html][1] but it's getting messy
and I can't find a way to display the html exactly where I want to.
For example, if I want to add html displaying the amount of books that
the library has below the name field I woul do this:

{% for field in line %}
...
{% if field.field.name == 'name' %}
{{ field.field }}


Total books:


   
{% else %}
{{ field.field }}
{% endif %}
...
{% endfor %}


  [1]: 
https://code.djangoproject.com/browser/django/trunk/django/contrib/admin/templates/admin/includes/fieldset.html

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



Re: Add custom html between two model fields in Django admin's change_form

2011-06-07 Thread mf
Thanks christian. I've followed your good advice but I don't know why
am I getting  this error: "PresupuestoAdmin.readonly_fields[1], 'name'
is not a callable or an attribute of 'PresupuestoAdmin' or found in
the model 'Presupuesto' ". It seems that the 'name' field is not added
to the form used by the admin.

class PresupuestoAdminForm(forms.ModelForm):
name = models.CharField(max_length=100)

class Meta:
model = Presupuesto

class PresupuestoAdmin(admin.ModelAdmin):
form = PresupuestoAdminForm

fieldsets = (
(None, {
'fields': (('id', 'fecha_emision', ), ('obra',
'num_pres_ext',),
'proveedor', 'descripcion', 'observaciones',
'importe_contratado',)
}),
)
readonly_fields = ('id', 'name',)

admin.site.register(Presupuesto, PresupuestoAdmin)



On 7 jun, 11:11, "christian.posta"  wrote:
> Create a different ModelForm that contains your readonly fields (and
> populate them however you want) and set this on your ModelAdmin form.
>
> See the ModelAdmin.form option in the 
> docs.https://docs.djangoproject.com/en/1.2/ref/contrib/admin/#modeladmin-o...
>
> On Jun 7, 6:01 am, mf  wrote:
>
>
>
>
>
>
>
> > Let's say I've two models:
>
> >     class Book(models.Model):
> >         name = models.CharField(max_length=50)
> >         library = models.ForeignKeyField('Library')
>
> >     class Library(models.Model):
> >         name = models.CharField(max_length=50)
> >         address = models.CharField(max_length=50)
> >         tel = models.CharField(max_length=50)
>
> > Is there a nice way to add some html(a readonly input field) between
> > name and address in the Library change_form template?. I'm doing it
> > overriding [admin/includes/fieldset.html][1] but it's getting messy
> > and I can't find a way to display the html exactly where I want to.
> > For example, if I want to add html displaying the amount of books that
> > the library has below the name field I woul do this:
>
> >     {% for field in line %}
> >         ...
> >         {% if field.field.name == 'name' %}
> >             {{ field.field }}
> >             
> >                 
> >                     Total books:
> >                      > id="totbooks" readonly="readonly">
> >                 
> >            
> >         {% else %}
> >             {{ field.field }}
> >         {% endif %}
> >         ...
> >     {% endfor %}
>
> >   
> > [1]:https://code.djangoproject.com/browser/django/trunk/django/contrib/ad...

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



Re: Add custom html between two model fields in Django admin's change_form

2011-06-09 Thread mf
Thanks christian, it worked!!.

On 8 jun, 12:21, "christian.posta"  wrote:
> Well, there are a couple things you could do:
>
> for the PresupuestoAdminForm, you could do this to the CharField:
> name = forms.CharField(max_length=100,
> widget=forms.TextInput(attrs={'readonly': 'readonly'}))
> (note the CharField is from the 'forms' package, not the 'models'
> you'll also need to remove the 'name' entry from the readonly_fields
> tuple)
>
> Alternatively, you could ignore using the custom ModelForm, and add
> the 'name' field directly to the PresupuestoAdmin class. In that case
> you can use the readonly_fields tuple.
>
> I would probably go with the first choice since it will allow you to
> write a custom query to populate the field in the constructor.
>
> Example:
>
> class StoreAdminForm(forms.ModelForm):
>     test = forms.CharField(max_length=100,
> widget=forms.TextInput(attrs={'readonly': 'readonly'}))
>
>     def __init__(self, *args, **kwargs):
>         super(StoreAdminForm, self).__init__(*args, **kwargs)
>
>         if kwargs.has_key('instance'):
>             instance = kwargs['instance']
>             # do something with the instance here, like use it to
> calculate something,
>             # then set the value on the 'test' field using
> self.fields['test']
>
>     class Meta:
>         model = Store
>
> Good luck!
>
> On Jun 7, 9:16 am, mf  wrote:
>
>
>
>
>
>
>
> > Thanks christian. I've followed your good advice but I don't know why
> > am I getting  this error: "PresupuestoAdmin.readonly_fields[1], 'name'
> > is not a callable or an attribute of 'PresupuestoAdmin' or found in
> > the model 'Presupuesto' ". It seems that the 'name' field is not added
> > to the form used by the admin.
>
> > class PresupuestoAdminForm(forms.ModelForm):
> >     name = models.CharField(max_length=100)
>
> >     class Meta:
> >         model = Presupuesto
>
> > class PresupuestoAdmin(admin.ModelAdmin):
> >     form = PresupuestoAdminForm
>
> >     fieldsets = (
> >         (None, {
> >             'fields': (('id', 'fecha_emision', ), ('obra',
> > 'num_pres_ext',),
> >             'proveedor', 'descripcion', 'observaciones',
> > 'importe_contratado',)
> >         }),
> >     )
> >     readonly_fields = ('id', 'name',)
>
> > admin.site.register(Presupuesto, PresupuestoAdmin)
>
> > On 7 jun, 11:11, "christian.posta"  wrote:
>
> > > Create a different ModelForm that contains your readonly fields (and
> > > populate them however you want) and set this on your ModelAdmin form.
>
> > > See the ModelAdmin.form option in the 
> > > docs.https://docs.djangoproject.com/en/1.2/ref/contrib/admin/#modeladmin-o...
>
> > > On Jun 7, 6:01 am, mf  wrote:
>
> > > > Let's say I've two models:
>
> > > >     class Book(models.Model):
> > > >         name = models.CharField(max_length=50)
> > > >         library = models.ForeignKeyField('Library')
>
> > > >     class Library(models.Model):
> > > >         name = models.CharField(max_length=50)
> > > >         address = models.CharField(max_length=50)
> > > >         tel = models.CharField(max_length=50)
>
> > > > Is there a nice way to add some html(a readonly input field) between
> > > > name and address in the Library change_form template?. I'm doing it
> > > > overriding [admin/includes/fieldset.html][1] but it's getting messy
> > > > and I can't find a way to display the html exactly where I want to.
> > > > For example, if I want to add html displaying the amount of books that
> > > > the library has below the name field I woul do this:
>
> > > >     {% for field in line %}
> > > >         ...
> > > >         {% if field.field.name == 'name' %}
> > > >             {{ field.field }}
> > > >             
> > > >                 
> > > >                     Total books:
> > > >                      > > > id="totbooks" readonly="readonly">
> > > >                 
> > > >            
> > > >         {% else %}
> > > >             {{ field.field }}
> > > >         {% endif %}
> > > >         ...
> > > >     {% endfor %}
>
> > > >   
> > > > [1]:https://code.djangoproject.com/browser/django/trunk/django/contrib/ad...

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



NoReverseMatch in django production server

2011-07-07 Thread mf
The project is working fine in the dev server but when I try to use it
in the production sv(Gunicorn + Nginx), NoReverseMatch error appears.
I checked the code several times and I can't find the error.

urls.py:

from django.conf.urls.defaults import patterns, include, url
from django.conf import settings

urlpatterns = patterns('',
(r'^obras/', include('obras.urls')),
)
obras urls.py:

from django.conf.urls.defaults import *
from obras import views

urlpatterns = patterns('',
url(r'^presobra/$', views.pres_obra, name='pres_obra'),
)
Error message:

Request URL: http://127.0.0.1:/admin/

Python Path:
['/srv/www/antingprojects.com.ar/gobras', ... ']

Exception Value:
Caught NoReverseMatch while rendering: Reverse for 'pres_obra' with
arguments '()' and keyword arguments '{}' not found.

Template error

In template /srv/www/antingprojects.com.ar/gobras/templates/admin/
index.html, error at line 75 Caught NoReverseMatch while rendering:
Reverse for 'pres_obra' with arguments '()' and keyword arguments '{}'
not found.

75  Presupuestos-Obras
settings.py:

import os.path
PROJECT_DIR = os.path.dirname(__file__)
ROOT_URLCONF = 'gobras.urls'
Project structure:

-gobras
--obras
--media

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



Problem loading admin static files

2011-07-11 Thread mf
I'm trying to upload my project to the production server but it fails
to load the admin static files.

settings.py:

import os

PROJECT_DIR = os.path.dirname(__file__)

MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')

MEDIA_URL = '/media/'

STATIC_ROOT ='/srv/www/antingprojects.com.ar/gobras/static'

STATIC_URL = '/static/'

ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

STATICFILES_DIRS = (
os.path.join(PROJECT_DIR, 'static'),
)

main urls.py:

from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
(r'^media/(?P.*)$', 'django.views.static.serve',
 {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
url(r'^admin/', include(admin.site.urls)),
(r'^static/admin/(?P.*)$', 'django.views.static.serve'),
(r'^obras/', include('obras.urls')),
)

nginx.conf(I use nginx with gunicorn):

server {
listen 80;
server_name antingprojects.com.ar;

access_log /srv/www/antingprojects.com.ar/gobras/access.log;
error_log /srv/www/antingprojects.com.ar/gobras/error.log;

location /media {
root /srv/www/antingprojects.com.ar/gobras;
}

location /static {
root /srv/www/antingprojects.com.ar/gobras;
}

location / {
proxy_pass http://127.0.0.1:;
}
}

Project folder: /srv/www/antingprojects.com.ar/gobras/static/admin/
media

access.log(snippet):

 "GET /srv/www/antingprojects.com.ar/gobras/static/admin/css/base.css
HTTP/1.1" 404 1116 "http://antingprojects.com.ar/admin/obras/cliente/?
localidad=CAPITAL+FEDERAL" "Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1)
Gecko/20100101 Firefox/4.0.1"

"GET /srv/www/antingprojects.com.ar/gobras/static/admin/css/
changelists.css HTTP/1.1" 404 1119 "http://antingprojects.com.ar/admin/
obras/cliente/?localidad=CAPITAL+FEDERAL" "Mozilla/5.0 (X11; Linux
x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"

online site(antingprojects.com.ar):





When I inspect those links with Firebug I can see the css files
correctly loaded. I don't know why it doesn't work.

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



Django open source cashflow management app

2011-07-24 Thread mf
Does anyone knows about an open source cashflow management app like
this one[0], built with django?.

[0] http://pulseapp.com/

Thanks for your help.

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



Thinking to change my db schema

2011-01-16 Thread mf
I'm building a web app with django. It uses postgresql. The app code
is getting really messy and I'd like to improve it(my begginer skills
being a big factor too).

This is an excerpt of my models.py file:

REPEATS_CHOICES = (
(NEVER, 'Never'),
(DAILY, 'Daily'),
(WEEKLY, 'Weekly'),
(MONTHLY, 'Monthly'),
...some more...
)

class Transaction(models.Model):
name = models.CharField(max_length=30)
type = models.IntegerField(max_length=1, choices=TYPE_CHOICES) # 0
= 'Income' , 1 = 'Expense'
amount = models.DecimalField(max_digits=12, decimal_places=2)
date = models.DateField(default=date.today)
frequency = models.IntegerField(max_length=2,
choices=REPEATS_CHOICES)
ends = models.DateField(blank=True, null=True)
active = models.BooleanField(default=True)
category = models.ForeignKey(Category,
related_name='transactions', blank=True, null=True)
account = models.ForeignKey(Account, related_name='transactions')

The problem is with date, frequency and ends. With this info I can
know all the dates in which transactions occurs and use it to fill a
cashflow table. Doing things this way involves creating a lot of
structures(dictionaries, lists and tuples) and iterating them a lot.
Maybe there is a very simple way of solving this with the actual
schema, but I couldn't realize how.

I think that the app would be easier to code if, at the creation of a
transaction, I could save all the dates in the db. I don't know if
it's possible or if it's a good idea.

Possible solutions:

-I'm reading a book about google app engine and the datastore's
multivalued properties. What do you think about this for solving my
problem?.

-I didn't know about the PickleField. I'm now reading about it, maybe
I could use it to store all the transaction's datetime objects.

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



Submitting Django forms with AJAX

2011-02-03 Thread mf
I want to have a little feedback form in one of my views but I can't
get it to work. I put a pdb.set_trace() to debug the views but when I
click submit the view reloads and never gets into the if
request.method == 'POST' and... code section. I'm very confused about
how to approach ajax forms submission with django. When I want to make
somthing like update a db value clicking in a button(i.e: votes) I can
create another view for handling the ajax call, but in this case I've
to generate the empty form in the original view, so I guess I can't
create another one to handle the ajax call.

views.py:

def results(request, query):
# View code outside the form
ipcs_selected = request.session['ipcs_requested']
query2 = ' | '.join(query.split())
base_query = '@title (%s)' % (query2)

# code that I want to run when the user submit's the form
results = {'success': False }
if request.method == u'POST' and request.is_ajax():
form = FeedBackForm(request.POST)
POST = request.POST
# work with the form
if form.is_valid():
results = {'success':True}
json = simplejson.dumps(results)
return HttpResponse(json, mimetype='application/json')
else:
form = FeedBackForm()


return render_to_response('results.html',
{'patents': patents, 'query': query, 'bq': base_query,
'form':
form},
context_instance=RequestContext(request))

results.html:


function submit_form() {
$.post("/results/{{query}}/", { query:{{ query }}, full:
{{full_query }} }, function(json){
alert("Success?: " + json['success']);
});
}
function addClickHandlers() {
$("#submit").click( function() { submit_form() });
}
$(document).ready(addClickHandlers);
  

  
  Relevant results?
  {{ form.relevance }}
  Up to which page?
  {{ form.rel_pages }}
  
  

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



Re: Submitting Django forms with AJAX

2011-02-04 Thread mf
Thanks Daniel, I made the change but I see no different results.

On Feb 4, 6:29 am, Daniel Roseman  wrote:
> On Friday, February 4, 2011 1:41:36 AM UTC, mf wrote:
>
> > I want to have a little feedback form in one of my views but I can't
> > get it to work. I put a pdb.set_trace() to debug the views but when I
> > click submit the view reloads and never gets into the if
> > request.method == 'POST' and... code section. I'm very confused about
> > how to approach ajax forms submission with django. When I want to make
> > somthing like update a db value clicking in a button(i.e: votes) I can
> > create another view for handling the ajax call, but in this case I've
> > to generate the empty form in the original view, so I guess I can't
> > create another one to handle the ajax call.
>
> > views.py:
>
> > def results(request, query):
> >     # View code outside the form
> >     ipcs_selected = request.session['ipcs_requested']
> >     query2 = ' | '.join(query.split())
> >     base_query = '@title (%s)' % (query2)
>
> >     # code that I want to run when the user submit's the form
> >     results = {'success': False }
> >     if request.method == u'POST' and request.is_ajax():
> >         form = FeedBackForm(request.POST)
> >         POST = request.POST
> >         # work with the form
> >         if form.is_valid():
> >             results = {'success':True}
> >         json = simplejson.dumps(results)
> >         return HttpResponse(json, mimetype='application/json')
> >     else:
> >         form = FeedBackForm()
>
> >     return render_to_response('results.html',
> >                 {'patents': patents, 'query': query, 'bq': base_query,
> > 'form':
> >                 form},
> >                 context_instance=RequestContext(request))
>
> > results.html:
>
> > 
> >         function submit_form() {
> >             $.post("/results/{{query}}/", { query:{{ query }}, full:
> > {{full_query }} }, function(json){
> >                 alert("Success?: " + json['success']);
> >             });
> >         }
> >         function addClickHandlers() {
> >             $("#submit").click( function() { submit_form() });
> >         }
> >         $(document).ready(addClickHandlers);
> >   
>
> >   
> >       Relevant results?
> >       {{ form.relevance }}
> >       Up to which page?
> >       {{ form.rel_pages }}
> >       
> >   
>
> Couple of issues here.
>
> Do you really want the entire 'query' variable inside your URL? That seems
> weird, especially as you're also submitting it as one of the POST variables.
>
> But the main problem is that your JS submit function doesn't return false,
> so it doesn't cancel the default submission action: so your JS starts to
> run, then the form submits via the normal HTTP POST, and the page is
> refreshed.
>
>         function addClickHandlers() {
>             $("#submit").click( function() {
>                 submit_form();
>                 return false;
>             });
>         }
> --
> 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-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.



Ajax form in django

2011-02-16 Thread mf
Hi, the problem I'm having is that, when I submit the form, the
response is placed in a new url(/feedback) instead of placing it in
the actual(/results) url. The alert never gets executed.

I guess I'm doing something wrong in the template but I can't find
views.py:
def ajax_feedback(request):
success = False
if request.method == "POST":
post = request.POST.copy()
if post.has_key('rel') and post.has_key('relp'):
rel = post['rel']
relp = post['relp']
q = post['query']
fq = post['full_query']
fq = fq[:350]
ip = request.META['REMOTE_ADDR']
feedback = FeedBack(q=q, ip_address=ip,
user=request.user,
relevance=rel, rel_pages=relp,
full_query=fq)
feedback.save()
success = True
if success == True:
return HttpResponse("Success")
else:
return HttpResponse("Error")
results.html:

   Yes
   No

   1-5 
   6-10
  
  
  


var create_note = function() {
  var rel = $("#rel").val()
  var relp = $("#relp").val()
  var query = {{ query }}
  var full_query = {{ bq }}
   var data = { rel:rel, relp:relp, query:query,
full_query:full_query };
   var args = {
type: "POST",
url: "/feedback/",
data: data,
success: function(msg){
 alert(msg);
}
  $.ajax(args);
  return false;
};
$("#create").click(create_note);

urls.py:
...
(r'^feedback/$', views.ajax_feedback),
(r'^results/(?P.+)/$', views.results),
...

Thank you in advance for your answers,

Mariano.

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



Re: __unicode__ and return.self

2012-03-24 Thread MF-DOS
Thanks for the reply.

If my model has 5 fields, why am I only returning one or two?
Shouldn't I return all 5?

On Mar 24, 9:19 pm, Jonathan Baker 
wrote:
> The __unicode__ method allows models to return a more usable representation
> of a record instead of a unicode object. This is useful in a variety of
> places, from the Django admin to using the manage.py shell on the command
> line.
>
> The return statement effectively ends the execution of a particular
> function or method by returning something (an object, string, whatever you
> may need to return for the task at hand).
>
>
>
>
>
>
>
>
>
> On Sat, Mar 24, 2012 at 10:10 PM, spike  wrote:
> > Running the tut here:
> >https://docs.djangoproject.com/en/1.1/intro/tutorial01/ but I'm having
> > trouble understanding what the point of __unicode__ is. Also, what is the
> > point of the return statements? I've read the docs over and over but don't
> > get it.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To view this discussion on the web visit
> >https://groups.google.com/d/msg/django-users/-/jKgyKR2iRdgJ.
> > 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.
>
> --
> Jonathan D. Baker
> Web Developerhttp://jonathandbaker.com
> 303.257.4144

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



all(), get(), create(), count(). More info?

2012-03-24 Thread MF-DOS
Running this tut: https://docs.djangoproject.com/en/1.1/intro/tutorial01/

Here is a list of shell commands I'm asked to issue, but I don't
understand where the commands are coming from? Are these Django or
Python commands? I've attempted to query help and read the docs but
can't find them anywhere.

Poll.objects.all()
Poll.objects.filter()
Poll.objects.get()
p.choice_set.all()
p.choice_set.create()
p.choice_set.count()

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