Re: 'NoneType' object has no attribute 'datetime' bug?

2012-07-14 Thread Ernesto Guevara
Try this:

from datetime import datetime, time, date

current_date = datetime.now()

today = datetime.combine(date.today(), time(19,30))

Look:

>>> from datetime import datetime, time, date
>>> print datetime.now()
2012-07-14 14:14:17.897023
>>> print datetime.combine(date.today(),time(19,30))
2012-07-14 19:30:00
>>>

o/


2012/7/14 dobrysmak 

> Hi guys,
> i have run into this.
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
> in get_response
> 111. response = callback(request, *callback_args, **callback_kwargs)
> File
> "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py"
> in _wrapped_view
> 20. return view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py"
> in _wrapped_view
> 91. response = view_func(request, *args, **kwargs)
> File "/home/user/dev/xyz/coupon/views.py" in enter_game
> 69. Coupon(coupon=coupon, player=player, credicts=credicts).save()
> File "/home/user/dev/xyz/coupon/models.py" in save
> 253. self.coupon.close_coupon()
> File "/home/user/dev/xyz/coupon/models.py" in close_coupon
> 78. current_date = datetime.datetime.now()
>
> Exception Type: AttributeError at /wejdz-do-gry/49/
> Exception Value: 'NoneType' object has no attribute 'datetime'
> Request information:
> GET: No GET data
>
> and the cuntion "close_coupon" looks like this
>
> class Coupon(models.Model): .
> .
> . end_date = models.DateTimeField(default=None, null=True, blank=True)
> def close_coupon(self):
> current_date = datetime.datetime.now() today =
> datetime.datetime.combine(datetime.date.today(), datetime.time(19,30))
> .
>   .
> end_date = current_date
>
> Don't know if that's a bug. Does anyone know how to deal with this issue?
> Cheers!
>
> --
> 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/-/iH-0-noK-zkJ.
> 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.



Re: Extend user model: class inheritance or OneToOneField?

2012-07-13 Thread Ernesto Guevara
Hi!

I prefer using OnetoOne with a pre_delete signal to remove user from a
pirncipal object instance:

from django.contrib.auth.models import User
from django.db.models.signals import pre_delete
from django.dispatch import receiver

class Customer(User):
user = models.OneToOneField(User)

@receiver(pre_delete, sender=Customer)
def delete_user_customer(sender, instance, **kwargs):
user = User.objects.filter(pk=instance.user.id)
if user:
user.delete()

class Seller(User):
user = models.OneToOneField(User)

@receiver(pre_delete, sender=Seller)
def delete_user_seller(sender, instance, **kwargs):
user = User.objects.filter(pk=instance.user.id)
if user:
user.delete()



2012/7/13 sdonk 

> Hi,
> I'm starting a new project and for the first time I need to extend the
> User model.
> I read the documentation and I googled a lot to try to figure out what is
> the best approach but I got confused.
>
> What's the the best approach?
>
> Class inheritance:
>
> from django.contrib.gis.db import models
> from django.contrib.auth.models import User, UserManager
>
> class myUser(User):
> birthday = models.DateField(null=True, blank=True)
> address = models.CharField(max_length=255, null=True, blank=True)
>
> objects = UserManager()
>
> Or OneToOneField (as doc suggests)
>
>
> from django.contrib.gis.db import models
> from django.contrib.auth.models import User
> from django.db.models.signals import post_save
>
> class myUser(User):
> user = models.OneToOneField(User)
> birthday = models.DateField(null=True, blank=True)
> address = models.CharField(max_length=255, null=True, blank=True)
>
> def __unicode__(self):
>   return u'%s' % self.user
>
> def create_user_profile(sender, instance, created, **kwargs):
> if created:
> myUser.objects.create(user=instance)
>
> post_save.connect(create_user_profile, sender=User)
>
> Thanks,
>
> Alex
>
>  --
> 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/-/KtEPwiHoWbUJ.
> 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.



Re: Where to delete model image?

2012-07-13 Thread Ernesto Guevara
Hi!

I have this old code here.

# forms.py

class UploadFileForm(ModelForm):
title = forms.CharField(max_length=250 ,label="Nome:")
original_image = forms.ImageField(label="Imagem:")

class Meta:
model = Photo

# models.py

from django.dispatch import receiver
from django.db.models.signals import pre_delete

class Photo(models.Model):
title = models.CharField(max_length=255)
pub_date = models.DateField(auto_now = True)
original_image = models.ImageField(upload_to='photos')
slug_photo = AutoSlugField(populate_from=('title'), unique=True,
max_length=255, overwrite=True)
model = models.ForeignKey(Model, blank=True, null=True)

@receiver(pre_delete, sender=Photo)
def delete_image(sender, instance, **kwargs):
os.remove(unicode(instance.original_image.path)) # remove the image
from folder "photos"


# views.py

def upload_photo(request):
if request.method == 'POST':
model = get_object_or_404(Model,
pk=request.POST.get("model"))
form = UploadForm(request.POST, request.FILES)
photo_exist = Photo.objects.filter(model__id = model.id)
if not photo_exist:
if form.is_valid():
form.save()
messages.add_message(request, messages.SUCCESS, 'Image save
succesfull!')
return HttpResponseRedirect(reverse('detail_model',
args=[model.slug]))
else:
return
render_to_response('project/app/detail.html',locals(),context_instance=RequestContext(request))

else:
if form.is_valid():
photo_exist.delete()
form.save()
messages.add_message(request, messages.SUCCESS, 'Image
update succesfull!')
return HttpResponseRedirect(reverse('detail_model',
args=[model.slug]))
else:
photo = Photo.objects.get(model__id = model.id)  # send the
photo to detail page
return
render_to_response('project/app/detail.html',locals(),context_instance=RequestContext(request))



2012/7/13 m.paul 

> Hi All,
>
> I have a Model with an image field and I want to be able to change the
> image using a ModelForm. When changing the image, the old image should be
> deleted and replaced by the new image.
>
> I have tried to do this in the clean method of the ModelForm like this:
>
> def clean(self):
> cleaned_data = super(ModelForm, self).clean()
>
> old_profile_image = self.instance.image
> if old_profile_image:
> old_profile_image.delete(save=False)
> return cleaned_data
>
> This works fine unless the file indicated by the user is not correct (for
> example if its not an image), which result in the image being deleted
> without any new images being saved. I would like to know where is the best
> place to delete the old image? By this I mean where can I be sure that the
> new image is correct before deleting the old one? I prefer to do this in my
> ModelForm class if possible but doing it in the Model class would also be
> acceptable.
>
> --
> 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/-/kB0VSrr9O1MJ.
> 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.



Re: Custom Tags and Includes, invalid block !

2012-06-18 Thread Ernesto Guevara
Hi!
Try {% load name_of_custom_tag %} after the extends tag in template.



2012/6/18 upmauro 

> Hello, sorry my english !
>
> I have one question, i create one custom tag and this works fine.
>
> But i have a situation :
>
> *site.html*
> *
> *
> {% include "header.html" %}
>
> Django looks the best framework for web !
>
> {% include "footer.html" %}
>
> If, i use {% load %} in site.html, tag works, but if i {% load %} tag in
> "header.html", when i try use custom tag in site.html raise Invalid block
> tag.
>
> In short, if I load the page included a tag on it is not recognized in the
> current page.
>
> Meant to be?
>
> --
> 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/-/E7i9EQSjhCoJ.
> 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.



Re: no module named books found

2012-06-17 Thread Ernesto Guevara
"Do we have to create a database with that name before."

Yes, you need create the database "xam" (from mysql query browser) before
running syncb.

2012/6/17 Sabbineni Navneet 

> I have Mysqldb installed.
> It still shows the same error.
>
>
>
>  --
> 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.



Re: Django 1.4 and google app engine

2012-06-17 Thread Ernesto Guevara
In GAE only using django-norel, a fork of django with no join's queryset.

https://developers.google.com/appengine/articles/django-nonrel

Or using in Google Cloud SQL:

https://developers.google.com/appengine/docs/python/cloud-sql/django

But is a paying service.


2012/6/17 Gebriel Abebe 

> Please I want to know the same thing?
>
>  --
> 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/-/bU3CTr2hjmQJ.
>
> 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.



Re: no module named books found

2012-06-16 Thread Ernesto Guevara
The problem now is the database configuration:

raise ImproperlyConfigured("
settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is
improperly configured. Please supply the ENGINE value. Check settings
documentation for more details.

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

You have the python-mysqldb package installed in your system?


2012/6/16 Satvir Toor 

> On Sat, Jun 16, 2012 at 4:58 PM, Sabbineni Navneet
>  wrote:
>
> > DATABASES = {
> > 'default': {
> > 'ENGINE': 'django.db.backends.mysql', # Add
> 'postgresql_psycopg2',
> > 'mysql', 'sqlite3' or 'oracle'.
> > 'NAME': 'xam',  # Or path to database file if
> > using sqlite3.
> > 'USER': 'root',  # Not used with sqlite3.
> > 'PASSWORD':'',  # Not used with sqlite3.
> what is your password here???
>
>
>
> --
> Satvir Kaur
> satveerkaur.blogspot.in
>
> --
> 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.



Re: no module named books found

2012-06-16 Thread Ernesto Guevara
Check the structure of project:

Here I use Eclipse, and my project have this structure:

myproject>myproject>app

In your case:

djangotest2>djangotest2>books

Or:

djangotest2>books

And in installed_apps:

INSTALLED_APPS = (
'books',
)


2012/6/16 Sabbineni Navneet 

> project name is djangotest2 and app name is books
> settings.py
> INSTALLED_APPS = (
> 'djangotest2.books',
>
>
>
> )
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2',
> 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': 'xam',  # Or path to database file if
> using sqlite3.
> 'USER': 'root',  # Not used with sqlite3.
> 'PASSWORD':'',  # Not used with sqlite3.
> 'HOST':'',  # Set to empty string for
> localhost. Not used with sqlite3.
> 'PORT':'',  # Set to empty string for default.
> Not used with sqlite3.
> }
> }
>
>
> It shows an error :no module named books found when i use syncdb.
> so anyone can please help...
>
>  --
> 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/-/yQ3f-LdGKrEJ.
> 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.



Re: Problem with a clean in inline formset

2012-05-01 Thread Ernesto Guevara
Solution:

def clean(self):
   if any(self.errors):
   # Don't bother validating the formset unless each form is
valid on its own
   return
   for i in range(0, self.total_form_count()):
   form = self.forms[i]
   cleaned_data = form.clean()
   display = cleaned_data.get('display', None)
   if cleaned_data['DELETE'] == False:
 if display.max_windows() >= display.windows:
   raise forms.ValidationError("The display have all
windows occupied.")

Put the line if cleaned_data['DELETE'] == False:  to check if the inline
have the attribute DELETE and if is false, to ignore deleted rows in
formset that have true in this attribute. =)

2012/4/30 Guevara 

> Hello!
>
> The (if display.max_windows() >= display.windows) works fine to
> prevent insert. Behaves as expected.
> But is raised even when the row is REMOVED from the edit formset. =/
>
> ## Models
>
> class Display(models.Model):
>windows = models.IntegerField()
>
> def max_windows(self):
>total = self.window_set.all().count() #window is a
> intermediary class to campaign
>if total:
>return total
>
> ## Clean method in CampaignInlineFormSet
>
> def clean(self):
>if any(self.errors):
># Don't bother validating the formset unless each form is
> valid on its own
>return
>for i in range(0, self.total_form_count()):
>form = self.forms[i]
>cleaned_data = form.clean()
>display = cleaned_data.get('display', None)
>if display.max_windows() >= display.windows:
>raise forms.ValidationError("The display have all
> windows occupied.")
>
> This "if" can not stop me remove a row in inline formset. How can I
> fix this?
> 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-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.



Re: Does django 1.3 has a ubuntu deb package released!

2011-05-31 Thread Ernesto Guevara
In Ubuntu 10.04 repository stlll 1.1 version. =/

2011/5/31 Tobias Quinn 

> You can always install the debian package from:
>
> http://packages.debian.org/wheezy/python-django
>
> which seems to work fine...
>
> On Apr 30, 3:29 am, Korobase  wrote:
> > Does django 1.3 has a ubuntu deb package released !
> > I have googled but get none,Any one have done this?
> > 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-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.



Re: django raw_id_fields patch

2011-05-25 Thread Ernesto Guevara
I need change the FK id value in raw_id to

Thanks!

2011/5/25 epic2005 

> who have the raw_id_fields patch url.. or some sugguest for modify
> raw_id_fields pop id back in the textbox  , please give me , thanks a
> lot.
>
> --
> 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.



Re: specify Postgres encoding as unicode

2011-05-18 Thread Ernesto Guevara
Hello!
Open your pdAdminIII and create a database using UTF-8.
For aplication this is setting for your settings.py:
DEFAULT_CHARSET = 'utf-8'
FILE_CHARSET = 'utf-8'

Regards!


2011/5/18 Thin Rhino 

> Hello,
>
> I am wondering if it is possible for me to specify the encoding to use for
> a postgresql database in the settings.py
>
> Going through the django documentation I could find how I could specify it
> for mysql. (http://docs.djangoproject.com/en/dev/ref/databases/)
>
> Tried google, but... !!
>
> My issue is when I try and save a unicode string into the database it is
> converted to \u where X is the unicode code points.
> Because of this, say a VARCHAR field I need to multiply the required length
> by 4, to fit in a unicode string. Hence I need to change the
> database encoding to Unicode. Since django auto creates my database, I am
> looking for a way to specify the same in the settings.py file.
>
> Cheers
> ThinRhino
>
> --
> 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.



Re: Change select to a form in a ForeignKey relationship

2011-05-13 Thread Ernesto Guevara
Very good, I edited here.

Thank You!

2011/5/13 Shawn Milochik 

> On 05/13/2011 04:22 PM, Guevara wrote:
>
>> Thank you shaw!
>>
>>  You're welcome. Note that there's no reason to add 'commit = True' when
> saving the address -- that's the default.
>
>
> 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-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.



Re: Using composition in Django

2011-04-29 Thread Ernesto Guevara
Thanks for the clarification, I put in the ForeignKey in employee class and is
working.
Regards!

2011/4/27 Tom Evans 

> On Sun, Apr 17, 2011 at 9:21 PM, W Craig Trader 
> wrote:
> > If your goal is to have an employee object that has direct access to all
> of
> > its related person object, and whose only new data field is a reference
> to
> > an address object, then you should change the Employee model to this:
> >
> > class Address(models.Model):
> >pass
> >
> > class Person(models.Model):
> >name = models.CharField(max_length=50)
> >date_inclusion = models.DateField()
> >
> > class Employee(models.Model):
> >person = models.OneToOneField(Person)
> >address = models.ForeignKey(Address)
> >
>
> Just to point out, this is MTI reinvented, without any of the Django
> syntactic magic sprinkled on top. It is exactly equivalent to this:
>
> class Address(models.Model):
>pass
>
> class Person(models.Model):
>name = models.CharField(max_length=50)
>date_inclusion = models.DateField()
>
> class Employee(Person):
>address = models.ForeignKey(Address)
>
> """
> The second type of model inheritance supported by Django is when each
> model in the hierarchy is a model all by itself. Each model
> corresponds to its own database table and can be queried and created
> individually. The inheritance relationship introduces links between
> the child model and each of its parents (via an automatically-created
> OneToOneField).
> """
>
>
> http://docs.djangoproject.com/en/1.3/topics/db/models/#multi-table-inheritance
>
> 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-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.



Re: Does django 1.3 has a ubuntu deb package released!

2011-04-29 Thread Ernesto Guevara
In the repository of ubuntu 10.04.2 the version 1.1.1 is available, better
download version 1.3 of the Django site and install. Is very easy.
Regards!


2011/4/29 Korobase 

> Does django 1.3 has a ubuntu deb package released !
> I have googled but get none,Any one have done this?
> 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-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.



Re: Need advice on ecommerce app direction

2011-04-25 Thread Ernesto Guevara
I find for download "Beginning Django E-Commerce" in webmasterresourceskit
site. Look that.

Regards.

2011/4/25 Shant Parseghian 

> Hi all, I'm aware of the choices out there for Django ecommerce apps but im
> confused about which to use. I need a simple shop that will do delivery only
> so no shipping needs to be calculated. I'm thinking that Satchmo will be
> overkill for this. Does anyone have any suggestions?
>
> --
> 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.



Re: {{ STATIC_URL }} and RequestContext()

2011-04-25 Thread Ernesto Guevara
Hello!

You need create a "static" folder in your project and inside in this folder
you create a "css" folder.
I use this configuration and works.

settings.py

import os.path

STATIC_ROOT = ''

# URL prefix for static files.
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'

TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)

And call a css for example, in base.html in this way:



Regards.



2011/4/25 Joakim Hove 

> Hello,
>
> I have just started using the {{ STATIC_URL }} template tag to insert
> proper url's to static resources in my templates. To use this tag I
> need to create the context for rendering as RequestContext() instance,
> which takes the request as a parameter for the initialisation.
>
> In my code I have several methods attached to models which create a
> suitable context for rendering that model instance in a specfied way:
>
> class MyModel( models.Model ):
>
>
>
>def create_xxx_context( self , **kwargs):
> 
>
>def create_yyy_context( self, ,**kwargs):
> 
>
> (Maybe that is a horrific design in the first place ???).
>
>
> Anyway - the methods create_???_context() do not have natural access
> to the request object (and I am reluctant to pass that argument on) -
> so I was wondering if I could achieve exactly the same by just
> "manually" adding the context variable STATIC_URL like:
>
> from django.conf import settings
> 
>
> def view(request, args):
>context = .
>context["STATIC_URL"] = settings.STATIC_URL
>return render_to_response( template , context )
>
> Or is there more magic to the {{ STATIC_URL }} tag when it comes as a
> RequestContext()?
>
>
> Joakim
>
> --
> 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.



Re: How to register EmployeeAdmin using atributes in Person class

2011-04-24 Thread Ernesto Guevara
I still having a little problem using OneToOne relationship and Edit form.
The forms are created with combobox and get all address in database, i need
the address of the specific Employee only.

Anybody know fix this problem?

Thanks!

2011/4/23 Guevara 

> I got put in the form of employee the form of Houses using
> StackedInline:
>
>
> class HouseInline(admin.StackedInline):
>model = House
>max_num = 1
>
> class EmployeeAdmin(admin.ModelAdmin):
>search_fields = ['person__name','person__cpf']
>list_display = ("name","cpf","date_born","date_inclusion")
>ordering = ["-name"]
> list_filter = ("date_inclusion",)
>list_per_page = 10
> inlines = [HouseInline]
>
> admin.site.register(Employee, EmployeeAdmin)
>
> Now I need collapse the forms of Houses in edit form of Employee, if I
> register mora than 2 houses, I have two forms of Houses in edit form
> employee. =/
> And the address combobox still showing all address register in
> database, i need show olnly adress of employee or adress of the house.
>
> Thanks.
>
>
>
>
> On 23 abr, 12:46, Guevara  wrote:
> > Thank you Ramiro!
> >
> > Now i have the atributes Person in form Employee. =)
> >
> > I added the attribute address and house in Employee class:
> >
> > models.py
> >
> > class Employee(Person):
> > person = models.OneToOneField(Person, parent_link=True)
> > # Relationship OneToOne with Address
> > address = models.OneToOneField(Address)
> > # Relationship with Houses
> > house = models.ForeignKey(Houses)
> >
> > def __unicode__(self):
> > if self.person:
> > return "%s %s (%s)" % (self.name, self.tel, self.address)
> > else:
> > return "%s (%s)" % (self.name, self.address)
> >
> > admin.py
> >
> > from django.contrib import admin
> > from imobiliaria.employee.models import Employee
> > admin.site.register(Employee)
> >
> > But when registering a new Employee, the form show in the combobox
> > others addresses and other houses of other entries, you know how I can
> > fix?
> >
> > Thanks!!
> >
> > On 23 abr, 00:22, Ramiro Morales  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Fri, Apr 22, 2011 at 11:55 PM, Guevara 
> wrote:
> > > > [...]
> >
> > > > class Person(models.Model):
> > > >name = models.CharField(max_length=50)
> > > >date_inclusion = models.DateField()
> >
> > > > class Employee(models.Model):
> > > >person = models.OneToOneField(Pessoa)
> >
> > > > I reed this dochttp://
> docs.djangoproject.com/en/dev/ref/contrib/admin/
> > > > but could not find this information.
> >
> > > Try with
> >
> > > class Employee(Person):
> > > person = models.OneToOneField(Person, parent_link=True)
> >
> > > or simply with
> >
> > > class Employee(Person):
> > > pass
> >
> > > It you don't want/need control of the name of the 1to1 relationship
> > > between Employee and Person.
> >
> > > Also, see
> >
> > >
> http://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield
> ..
> >
> > > --
> > > Ramiro Morales
>
> --
> 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.



Re: The import staticfiles_urlpatterns is not working in django 1.3

2011-04-21 Thread Ernesto Guevara
Hello Brian!
This right, in fact that word "import" I inadvertently pasted, but the
import does not work.

from django.contrib.staticfiles.urls import staticfiles_urlpatterns

The problem was that when doing the import, it does not appear available by
pressing ctrl + backspace in Eclipse, that is, the import does not exist.

In fact, not need it, and even configure the urls.py.
With the configuration that I have informed the css work

Thanks!


2011/4/21 Brian Neal 

> On Apr 21, 12:48 pm, Guevara  wrote:
> > Hello!
> > My project is failing to import the staticfiles_urlpatterns, using
> > Eclipse Helios:
> >
> > urls.py
> >
> > import from django.contrib.staticfiles.urls staticfiles_urlpatterns
> >
> > In django 1.3 I already have:
> >
> > INSTALLED_APPS = (
> > 'django.contrib.staticfiles'
> > )
> >
> > In the folder:
> > / usr/local/lib/python2.6/dist-packages/django/contrib/staticfiles
> >
> > Why do not you think the staticfiles_urlpatterns?
> >
> > Thanks!
>
> Please post your code and the exact error. For one thing, your import
> statement isn't valid Python. It should be:
>
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>
> Best,
> BN
>
> --
> 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.



Re: admin login fails

2011-04-19 Thread Ernesto Guevara
Or you can delete database and execute again syncdb. The aplication ask
again the password, warning for capslock. =)

2011/4/19 pfc 

> I'm new to Django and am following the tutorials, specifically:
> http://docs.djangoproject.com/en/dev/intro/tutorial02/
> I followed the instructions on adding admin to the INSTALLED_APPS, I
> also added it to the urls, did syncdb and created the superuser.  When
> trying to login with the superuser(username test, password test) I
> then get the message "Please enter a correct username and password.
> Note that both fields are case-sensitive."
> I decided to create a second superuser and restarted the test server,
> and still have the same issue.
>
> A few days ago I had no problems getting this to work, but now even
> when trying to create a new project I still get the same error.
> Any ideas as to what I'm missing or what might be happening?
>
> Thanks in advance for any 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.
>
>

-- 
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: populating a field based on selection of foreign key

2011-04-09 Thread Ernesto Guevara
Hello!
I think you need something like this in your admin.py:

class SystemAdmin(admin.ModelAdmin):
list_display = ("generation", "system", "cog_E")
ordering = ["-cog_E"]
search_fields = ("system")
list_filter = ("generation")
list_per_page = 10

admin.site.register(System, SystemAdmin)


Try this. =)

2011/4/9 Aref 

> I am working on a database project and I am facing a little challenge.
> Here it is.
>
> I have three tables defined as below:
>
> class Generation(models.Model):
>generation = models.CharField(max_length = 25)
>
>def __unicode__(self):
>return self.generation
>
> class CogE(models.Model):
>first_name = models.CharField(max_length=30)
>last_name = models.CharField(max_length=30)
>office_phone = models.CharField(max_length=15, blank=True)
>mobile_phone = models.CharField(max_length=15, blank=True)
>email = models.EmailField(blank=True)
>
>def __unicode__(self):
>return u'%s %s' % (self.first_name, self.last_name)
>
> class System(models.Model):
>system = models.CharField(max_length=30)
>cog_E = models.ForeignKey(CogE)
>project = models.ForeignKey(Project)
>generation = models.ForeignKey(Generation)
>
>def __unicode__(self):
>return self.system
>
>
> class Board(models.Model):
>board = models.CharField(max_length=30)
>sch_number = models.CharField(max_length=20, blank = True)
>PWA_number = models.CharField(max_length=20, blank = True)
>PWB_number = models.CharField(max_length=20, blank = True)
>system = models.ForeignKey(System)
>cog_E = models.ForeignKey(CogE)
>generation = models.ForeignKey(Generation)
>
> In the admin view I would like to the board generation field to be
> populated based on the system entry (since generation is also a field
> in the system table). Is this possible to do in django? Is the schema
> correct (I know this is not really a django issue)? Any help is
> greatly appreciated.
>
> --
> 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.