Re: sending email

2015-02-02 Thread monoBOT
2015-02-02 6:51 GMT+01:00 sum abiut :

>
> to_emails = [a.admins.all()]


​You are asking for item admins here:


to_emails = [a.admins.all()]
​



-- 
*monoBOT*
Visite mi sitio(Visit my site): monobotsoft.es/blog/

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


Re: Django Auth\Auth

2015-02-02 Thread Mario Gudelj
Here's the link to docs
https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#specifying-a-custom-user-model
which will guide you through that.

On 2 February 2015 at 14:30, Ajay M  wrote:

> Hi,
> I'm a new bee to Django, I need to use signup/login facilities in my
> project
> How do I customize and use django Auth/Auth feature? On sign up I have to
> store many details than just first_name, last_name, email and password. Can
> any one help me :) ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9206cffd-c423-4699-adf5-9376b7f09f62%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Save one to one field manually

2015-02-02 Thread Paul Royik
I solved the problem.
See 
http://stackoverflow.com/questions/28262236/saving-onetoone-field-manually-in-django

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/16fc6f58-8260-48c8-bb46-7f5ec5092f34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Possible bug in prefetch_related used with Reverse generic relations

2015-02-02 Thread Todor Velichkov
Hi, guys.
About a week ago i asked the same question 

 
on stackoverflow. Since i got no response there i started to read how to 
report a bug 

 
(because I've never done it before), and this article took me here ;). I 
need more advanced opinion if this is truly a bug which should be reported 
or i just want too much from the ORM. So i will repeat myself from 
stackoverflow and explain what is all about.  

Here is some example model structure:

from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey, 
GenericRelation
from django.contrib.contenttypes.models import ContentType


class TaggedItem(models.Model):
 tag = models.SlugField()
 content_type = models.ForeignKey(ContentType)
 object_id = models.PositiveIntegerField()
 content_object = GenericForeignKey('content_type', 'object_id')

 def __unicode__(self):
 return self.tag

class Movie(models.Model):
 name = models.CharField(max_length=100)

 def __unicode__(self):
 return self.name


class Author(models.Model):
 name = models.CharField(max_length=100)

 def __unicode__(self):
 return self.name


class Book(models.Model):
 name = models.CharField(max_length=100)
 author = models.ForeignKey(Author)
 tags = GenericRelation(TaggedItem, related_query_name='books')

 def __unicode__(self):
 return self.name


Now, lets create some initial data:

>>> from tags.models import Book, Movie, Author, TaggedItem 
> >>> a = Author(name='E L James') 
> >>> a.save() 
> >>> b1 = Book(name='Fifty Shades of Grey', author=a) 
> >>> b1.save() 
> >>> b2 = Book(name='Fifty Shades Darker', author=a) 
> >>> b2.save() 
> >>> b3 = Book(name='Fifty Shades Freed', author=a) 
> >>> b3.save() 
> >>> t1 = TaggedItem(content_object=b1, tag='roman') 
> >>> t1.save() 
> >>> t2 = TaggedItem(content_object=b2, tag='roman') 
> >>> t2.save() 
> >>> t3 = TaggedItem(content_object=b3, tag='roman') 
> >>> t3.save() 
> >>> m1 = Movie(name='Guardians of the Galaxy') 
> >>> m1.save() 
> >>> t4 = TaggedItem(content_object=m1, tag='action movie') 
> >>> t4.save()
>

Now we can make a query like this:

> >>> TaggedItem.objects.filter(books__author__name='E L James')
> [, , ]
>

But we cant do this:

>>> TaggedItem.objects.filter(books__author__name='E L James').
> prefetch_related('books')
> Traceback (most recent call last):
> ...
> AttributeError: 'Book' object has no attribute 'object_id'
>

*Why i think this may be a bug?* 
Because of the error. Normally if *prefech_related* can't resolve a relation it 
complains like that:

AttributeError: Cannot find 'some_field' on TaggedItem object, 'some_field' 
> is an invalid parameter to prefetch_related()
>
But in the example above, Django actually tries to resolve the relation and 
fails because the ORM is searching for *object_id* inside the *Book* model 
instead of the *TaggedItem* model. 

*Why i don't use the forward relation (the `content_type` field).*
Yes, this actually will work:

>>> TaggedItem.objects.filter(books__author__name='E L James').
> prefetch_related('content_object')
> [, , ]
>
 

But this way u can't go further with the relations *against* a queryset 
containing different types of content types. 

>>> TaggedItem.objects.all().prefetch_related('content_object__author')Traceback
>>>  (most recent call last):
>   ...AttributeError: 'Movie' object has no attribute 'author_id'
>
>
 While the reversed API kind of a give me hope that it's the right way to 
go. I mean the ORM don't need to guess the author of which content types 
need  to be prefetched.

> TaggedItem.objects.all().prefetch_related('books__author')
>
We clearly show that we want the authors of all book models. nothing more, 
nothing less.

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/557ff1af-41d2-4676-90b9-cb19b2478730%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


PermissionError with open()

2015-02-02 Thread John
Hello everyone,

I am trying to run this code inside view.py, to make PDF file able to be 
downloaded :

> import os
> BASE_DIR = os.path.dirname(os.path.dirname(__file__))def 
> download(request, file_name = 'article1'):
> file = open(os.path.join(BASE_DIR, 
> 'media').replace('\\','/').format(file_name), 'rb')
> response = HttpResponse(file, content_type='application/pdf')
> response['Content-Disposition'] = "attachment; 
> filename={}".format(file_name)
> return response
>
>
The problem with line 4. I will get *PermissionError *on windows

PermissionError at /download/
> [Errno 13] Permission denied: 'C:/Users/Oana/Desktop/tutela-net/media'
>
>
 

and *IsADirectoryError* on linux.

Even though, if I will use 'wb' instead of 'rb' or any other options. or the 
absolute path, I will get the same error. 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/25e64be7-ed56-43bb-862e-76eeb3ecdfba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ListView and Deleteview

2015-02-02 Thread elcaiaimar
Hello everybody,

I'm working in a website using django. I would like that users could select 
and delete data introduced for them. I've found some information on the web 
and it seems that the ListView and DeleteView is what I need. However, when 
I try to do a ListView, it doesn't work and I don't know why.

Here my code:

*models.py:*

class Pozo(models.Model):
# gid_pozo = models.IntegerField(primary_key=True)
# gid_colector = models.ForeignKey(Colector)
codpozo = models.CharField(max_length=20)
coorx = models.DecimalField(max_digits=13, decimal_places=5)
coory = models.DecimalField(max_digits=13, decimal_places=5)
tipo = models.CharField(max_length=20)
cotatrapa = models.DecimalField(max_digits=6, decimal_places=2, 
default=None, blank=True, null=True)
profundidad = models.DecimalField(max_digits=6, decimal_places=2, 
default=None, blank=True, null=True)
cotafondo = models.DecimalField(max_digits=6, decimal_places=2, 
default=None, blank=True, null=True)
material = models.CharField(max_length=20)
materialpates = models.CharField(max_length=20)
diametro = models.DecimalField(max_digits=20, decimal_places=2, 
default=None, blank=True, null=True)
largotrapa = models.DecimalField(max_digits=20, decimal_places=2, 
default=None, blank=True, null=True)
seccionmayor = models.DecimalField(max_digits=5, decimal_places=0, 
default=None, blank=True, null=True)
seccionmenor = models.DecimalField(max_digits=5, decimal_places=0, 
default=None, blank=True, null=True)
numacometidas = models.DecimalField(max_digits=2, decimal_places=0, 
default=None, blank=True, null=True)
origen = models.CharField(max_length=20)
observaciones = models.CharField(max_length=255)  
geom = models.PointField(srid=25830)
objects = models.GeoManager()

*views.py:*

def PozoList(ListView):   
model = Pozo
template_name = 'cuencas/edicioncuenca.html'

*template:*


  {% for pozo in object_list %}
  {{ pozo.codpozo }}
  {% endfor %}


And the result is a field without options. Does anybody know what I'm doing 
wrong? 
Thank you very much!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9492aae7-31bf-4283-9399-5c50f04dfcfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: PermissionError with open()

2015-02-02 Thread Vijay Khemlani
Your call to

".format(file_name)"

does nothing as the original string does not have the positional arguments
("{0}" for example)

You could just append the filename with "+".

On Mon, Feb 2, 2015 at 3:32 AM, John  wrote:

> Hello everyone,
>
> I am trying to run this code inside view.py, to make PDF file able to be
> downloaded :
>
>> import os
>> BASE_DIR = os.path.dirname(os.path.dirname(__file__))def 
>> download(request, file_name = 'article1'):
>> file = open(os.path.join(BASE_DIR, 
>> 'media').replace('\\','/').format(file_name), 'rb')
>> response = HttpResponse(file, content_type='application/pdf')
>> response['Content-Disposition'] = "attachment; 
>> filename={}".format(file_name)
>> return response
>>
>>
> The problem with line 4. I will get *PermissionError *on windows
>
> PermissionError at /download/
>> [Errno 13] Permission denied: 'C:/Users/Oana/Desktop/tutela-net/media'
>>
>>
>
>
> and *IsADirectoryError* on linux.
>
> Even though, if I will use 'wb' instead of 'rb' or any other options. or the
> absolute path, I will get the same error.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/25e64be7-ed56-43bb-862e-76eeb3ecdfba%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Securing Browseable API & Mocking Models

2015-02-02 Thread Ari King
Hi,

In the last couple of days I started experimenting with Django and Django 
Rest Framework. Using the excellent documentation and ViewSets I was able 
to create a PoC API in a very short time. I was also able to add Django 
Rest Swagger  for 
documentation of the API. However, at this point I'd like to secure access 
to the Swagger API documentation, but I'm unclear on how to limit access to 
Django 'superusers.' I'd appreciate clarification on how to do so. 

Also, in unit tests (particularly of views) I'd like to mock the model, 
rather than have the models call against the database. Are there any Django 
"conventions" or best practices for doing so?

Thanks.

Best,
Ari

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65270a6c-eee4-44a0-b58c-ffad78e864c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ListView and Deleteview

2015-02-02 Thread Giuseppe Saviano
> views.py:
>
> def PozoList(ListView):
> model = Pozo
> template_name = 'cuencas/edicioncuenca.html'
>

Is your view a function or a class?

-- 
$ gpg --recv-key da5098a7

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG_-i2%3DE%2BuX%2Bj3EFAQpej%3D805te%3DHkiEQG0S7ROzO%2BPb4fJ4YQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Securing Browseable API & Mocking Models

2015-02-02 Thread Tom Christie
Hi Ari,

It looks like Django REST swagger has an `is_admin` flag you can use...

http://django-rest-swagger.readthedocs.org/en/latest/settings.html#is-superuser

You'll probably also want to disable the browsable API by removing it from 
the 'DEFAULT_RENDERER_CLASSES' key in the 'REST_FRAMEWORK' settings 
dictionary.

> Also, in unit tests (particularly of views) I'd like to mock the model, 
rather than have the models call against the database.

That's an interesting one. I've actually started to more properly consider 
doing this throughout the REST framework codebase, and probably also 
introduce some supported API for mock objects and mock querysets.

There's actually very little you need to do for this...

* Querysets should be any list-like structure. If you're mocking a detail 
view, they'll also need to implement a `.get(...)` method.
* Some of the filter classes require the queryset to expose a 
`.filter(...)` or `.order_by(...)` method. If you're not testing that you 
probably won't need it.

Also if you've any ModelSerializers or Serializer.save() code that's under 
test you'd need to mock those method to prevent any actual database saves, 
that's probably a bit more awkward, but for many test cases you could 
probably avoid that (eg pass a different serializer class to the view under 
test)

Couple of places we do similar things in the REST framework tests:

https://github.com/tomchristie/django-rest-framework/blob/master/tests/utils.py#L5-30
https://github.com/tomchristie/django-rest-framework/blob/version-3.1/tests/test_pagination.py#L454-481
 
(version-3.1 branch)

Nothing very consistent there yet, but probably worth a look.

Hope that helps!

On Monday, 2 February 2015 14:21:22 UTC, Ari King wrote:
>
> Hi,
>
> In the last couple of days I started experimenting with Django and Django 
> Rest Framework. Using the excellent documentation and ViewSets I was able 
> to create a PoC API in a very short time. I was also able to add Django 
> Rest Swagger  for 
> documentation of the API. However, at this point I'd like to secure access 
> to the Swagger API documentation, but I'm unclear on how to limit access to 
> Django 'superusers.' I'd appreciate clarification on how to do so. 
>
> Also, in unit tests (particularly of views) I'd like to mock the model, 
> rather than have the models call against the database. Are there any Django 
> "conventions" or best practices for doing so?
>
> Thanks.
>
> Best,
> Ari
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1175785d-dc78-4c81-9bfb-99bf8953e846%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ListView and Deleteview

2015-02-02 Thread elcaiaimar
Soory, it's a class, but it doesn't work properly neither. Do I have to 
introduce anything in urls.py? I haven't put anything because I want the 
listview in a url already created.

El lunes, 2 de febrero de 2015, 13:29:53 (UTC+1), elcaiaimar escribió:
>
> Hello everybody,
>
> I'm working in a website using django. I would like that users could 
> select and delete data introduced for them. I've found some information on 
> the web and it seems that the ListView and DeleteView is what I need. 
> However, when I try to do a ListView, it doesn't work and I don't know why.
>
> Here my code:
>
> *models.py:*
>
> class Pozo(models.Model):
> # gid_pozo = models.IntegerField(primary_key=True)
> # gid_colector = models.ForeignKey(Colector)
> codpozo = models.CharField(max_length=20)
> coorx = models.DecimalField(max_digits=13, decimal_places=5)
> coory = models.DecimalField(max_digits=13, decimal_places=5)
> tipo = models.CharField(max_length=20)
> cotatrapa = models.DecimalField(max_digits=6, decimal_places=2, 
> default=None, blank=True, null=True)
> profundidad = models.DecimalField(max_digits=6, decimal_places=2, 
> default=None, blank=True, null=True)
> cotafondo = models.DecimalField(max_digits=6, decimal_places=2, 
> default=None, blank=True, null=True)
> material = models.CharField(max_length=20)
> materialpates = models.CharField(max_length=20)
> diametro = models.DecimalField(max_digits=20, decimal_places=2, 
> default=None, blank=True, null=True)
> largotrapa = models.DecimalField(max_digits=20, decimal_places=2, 
> default=None, blank=True, null=True)
> seccionmayor = models.DecimalField(max_digits=5, decimal_places=0, 
> default=None, blank=True, null=True)
> seccionmenor = models.DecimalField(max_digits=5, decimal_places=0, 
> default=None, blank=True, null=True)
> numacometidas = models.DecimalField(max_digits=2, decimal_places=0, 
> default=None, blank=True, null=True)
> origen = models.CharField(max_length=20)
> observaciones = models.CharField(max_length=255)  
> geom = models.PointField(srid=25830)
> objects = models.GeoManager()
>
> *views.py:*
>
> def PozoList(ListView):   
> model = Pozo
> template_name = 'cuencas/edicioncuenca.html'
>
> *template:*
>
> 
>   {% for pozo in object_list %}
>   {{ pozo.codpozo }}
>   {% endfor %}
> 
>
> And the result is a field without options. Does anybody know what I'm 
> doing wrong? 
> Thank you very much!
>

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


funciton GDALAllRegister not found, django 1.8a release on windows

2015-02-02 Thread mattxbart
Hi all,
I had a working 1.7.4 (using geodjango) on windows 7 install, no issues. 
I'm using osgeo4w to manage all the gdal/gis libraries. When I install the 
django 1.8a release or off git master, I get the following traceback:

$ ./manage.py shell
Traceback (most recent call last):
  File "./manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", 
line
338, in execute_from_command_line
utility.execute()
  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", 
line
312, in execute
django.setup()
  File "c:\Python27\lib\site-packages\django\__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
  File "c:\Python27\lib\site-packages\django\apps\registry.py", line 108, 
in pop
ulate
app_config.import_models(all_models)
  File "c:\Python27\lib\site-packages\django\apps\config.py", line 202, in 
impor
t_models
self.models_module = import_module(models_module_name)
  File "c:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
  File "c:\Python27\lib\site-packages\django\contrib\auth\models.py", line 
42, i
n 
class Permission(models.Model):
  File "c:\Python27\lib\site-packages\django\db\models\base.py", line 126, 
in __
new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "c:\Python27\lib\site-packages\django\db\models\base.py", line 310, 
in ad
d_to_class
value.contribute_to_class(cls, name)
  File "c:\Python27\lib\site-packages\django\db\models\options.py", line 
246, in
 contribute_to_class
self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length(
))
  File "c:\Python27\lib\site-packages\django\db\__init__.py", line 36, in 
__geta
ttr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 238, in 
__getite
m__
backend = load_backend(db['ENGINE'])
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 109, in 
load_bac
kend
return import_module('%s.base' % backend_name)
  File "c:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
  File 
"c:\Python27\lib\site-packages\django\contrib\gis\db\backends\postgis\bas
e.py", line 9, in 
from .features import DatabaseFeatures
  File 
"c:\Python27\lib\site-packages\django\contrib\gis\db\backends\postgis\fea
tures.py", line 1, in 
from django.contrib.gis.db.backends.base.features import 
BaseSpatialFeatures

  File 
"c:\Python27\lib\site-packages\django\contrib\gis\db\backends\base\featur
es.py", line 3, in 
from django.contrib.gis.db.models import aggregates
  File 
"c:\Python27\lib\site-packages\django\contrib\gis\db\models\__init__.py",
 line 7, in 
from django.contrib.gis.geos import HAS_GEOS
  File "c:\Python27\lib\site-packages\django\contrib\gis\geos\__init__.py", 
line
 16, in 
from .geometry import GEOSGeometry, wkt_regex, hex_regex
  File "c:\Python27\lib\site-packages\django\contrib\gis\geos\geometry.py", 
line
 13, in 
from django.contrib.gis.gdal.error import SRSException
  File "c:\Python27\lib\site-packages\django\contrib\gis\gdal\__init__.py", 
line
 47, in 
from django.contrib.gis.gdal.driver import Driver  # NOQA
  File "c:\Python27\lib\site-packages\django\contrib\gis\gdal\driver.py", 
line 4
, in 
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as 
rcapi
  File 
"c:\Python27\lib\site-packages\django\contrib\gis\gdal\prototypes\raster.
py", line 22, in 
register_all = void_output(lgdal.GDALAllRegister, [])
  File "c:\Python27\lib\ctypes\__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
  File "c:\Python27\lib\ctypes\__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'GDALAllRegister' not found

I've installed all 32bit libs, looks like something in the new raster 
functionality? How can I get this working?

Thanks,
Matt

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


Re: ListView and Deleteview

2015-02-02 Thread Dan Gentry
This is a bit of a stumper!

I don't see any big glaring issues.  A couple of housekeeping things:  Is 
there data in the table? Are you certain that you are using the correct 
template?

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


Re: ListView and Deleteview

2015-02-02 Thread Vijay Khemlani
Hmmm... Try and post your urls.py and views.py (the correct one)

On Mon, Feb 2, 2015 at 5:20 PM, Dan Gentry  wrote:

> This is a bit of a stumper!
>
> I don't see any big glaring issues.  A couple of housekeeping things:  Is
> there data in the table? Are you certain that you are using the correct
> template?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b84e3f59-d0da-40c4-a942-81f43861a6f1%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: ListView and Deleteview

2015-02-02 Thread James Schneider
You've defined your class-based view as a function:

def PozoList(ListView):

You should be defining it as a class:

class PozoList(ListView):

And you should be calling the to_view() method for the PozoList class from
your urls.py.

Please post your urls.py and any traceback and error messages you are
receiving.

-James
On Feb 2, 2015 12:35 PM, "Vijay Khemlani"  wrote:

> Hmmm... Try and post your urls.py and views.py (the correct one)
>
> On Mon, Feb 2, 2015 at 5:20 PM, Dan Gentry  wrote:
>
>> This is a bit of a stumper!
>>
>> I don't see any big glaring issues.  A couple of housekeeping things:  Is
>> there data in the table? Are you certain that you are using the correct
>> template?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/b84e3f59-d0da-40c4-a942-81f43861a6f1%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei2yLaOBAc1MMocYCs21kbM1dES6HTZxm-nBs3kUDQ-Hhw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciW74k8O3DbRMF5GXfLqwKYYCc7jvYdVf2Q%2BgUE5%2B7kUXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Migrating to initial migration: "ORA-00955: name is already used by an existing object"

2015-02-02 Thread Carsten Fuchs

Dear Django developers,

in a Django project that was created pre-1.7, did not use South before, 
and was recently upgraded to Django 1.7 and is otherwise fine, I'm now 
trying to convert it to use migrations, following the docs at 
.


It seems that creating the initial migrations with `makemigrations` 
works well, but the first run of `migrate` aborts with error 
"django.db.utils.DatabaseError: ORA-00955: name is already used by an 
existing object". Please see the full output below.


Unfortunately, I don't know enough about migrations to be able to debug 
this myself, or to understand what the problem is.


What are good next steps, or where should I look for the cause of this 
problem?


Best regards,
Carsten



(Zeiterfassung)carsten@blue-ring-ubuntu:~/Zeiterfassung$ rm -rf 
Lori/migrations/


(Zeiterfassung)carsten@blue-ring-ubuntu:~/Zeiterfassung$ ./manage.py 
makemigrations Lori

Migrations for 'Lori':
  0001_initial.py:
- Create model AUB
- Create model Ausbezahlt
- Create model Aushilfslohn
- Create model Bereich
- Create model Code
- Create model Erfasst
- Create model KalenderEintrag
- Create model Kostenstelle
- Create model Mitarbeiter
- Create model MonatsSalden
- Create model Oeffnungszeiten
- Create model PekoBenchmarkCache
- Create model PekoGewichte
- Create model Region
- Create model Schicht
- Create model Status
- Create model SystemEmailEmpfaenger
- Create model TempMaBereichZuordnung
- Create model Termin
- Create model Umsatzgruppe
- Create model UserProfile
- Create model Vertragsverlauf
- Create model Vorblendplan
- Create model Vortraege
- Alter unique_together for schicht (1 constraint(s))
- Add field region to pekogewichte
- Add field fil_gruppe to pekobenchmarkcache
- Alter unique_together for pekobenchmarkcache (1 constraint(s))
- Alter unique_together for monatssalden (1 constraint(s))
- Add field tmp_bereiche to mitarbeiter
- Add field vbp_neu to mitarbeiter
- Add field fil_gruppe to kostenstelle
- Add field parent to kostenstelle
- Add field region to kostenstelle
- Add field kstellen to kalendereintrag
- Add field regionen to kalendereintrag
- Add field key to erfasst
- Add field last_user to erfasst
- Add field status to erfasst
- Alter unique_together for erfasst (1 constraint(s))
- Add field region to bereich
- Add field key to ausbezahlt
- Alter unique_together for ausbezahlt (1 constraint(s))
- Add field ma to aub

(Zeiterfassung)carsten@blue-ring-ubuntu:~/Zeiterfassung$ ./manage.py migrate
Operations to perform:
  Apply all migrations: admin, contenttypes, Lori, auth, sessions
Running migrations:
  Applying Lori.0001_initial...Traceback (most recent call last):
  File "./manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 385, in execute_from_command_line

utility.execute()
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 377, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/base.py", 
line 288, in run_from_argv

self.execute(*args, **options.__dict__)
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/base.py", 
line 338, in execute

output = self.handle(*args, **options)
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", 
line 161, in handle

executor.migrate(targets, plan, fake=options.get("fake", False))
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/db/migrations/executor.py", 
line 68, in migrate

self.apply_migration(migration, fake=fake)
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/db/migrations/executor.py", 
line 102, in apply_migration

migration.apply(project_state, schema_editor)
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/db/migrations/migration.py", 
line 108, in apply
operation.database_forwards(self.app_label, schema_editor, 
project_state, new_state)
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/db/migrations/operations/models.py", 
line 36, in database_forwards

schema_editor.create_model(model)
  File 
"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/db/backends/schema.py", 
line 261, in create_model

self.execute(sql, params)
  File 
"/home/carsten/.virtualenvs/Zeiter

Re: Migrating to initial migration: "ORA-00955: name is already used by an existing object"

2015-02-02 Thread Markus Holtermann
Hey Carsten,

Did you see the chapter at the end of the page you linked to: Upgrading from 
South: 
https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-south

1. Make sure the database schema defined by your models (and Django migrations) 
exactly matches the one in the database (this includes null constraints, 
indexes, etc.) to prevent errors in the future

2. Run "manage.py migrate --fake"

/Markus

On February 2, 2015 10:50:14 PM GMT+01:00, Carsten Fuchs 
 wrote:
>Dear Django developers,
>
>in a Django project that was created pre-1.7, did not use South before,
>
>and was recently upgraded to Django 1.7 and is otherwise fine, I'm now 
>trying to convert it to use migrations, following the docs at 
>.
>
>It seems that creating the initial migrations with `makemigrations` 
>works well, but the first run of `migrate` aborts with error 
>"django.db.utils.DatabaseError: ORA-00955: name is already used by an 
>existing object". Please see the full output below.
>
>Unfortunately, I don't know enough about migrations to be able to debug
>
>this myself, or to understand what the problem is.
>
>What are good next steps, or where should I look for the cause of this 
>problem?
>
>Best regards,
>Carsten
>
>
>
>(Zeiterfassung)carsten@blue-ring-ubuntu:~/Zeiterfassung$ rm -rf 
>Lori/migrations/
>
>(Zeiterfassung)carsten@blue-ring-ubuntu:~/Zeiterfassung$ ./manage.py 
>makemigrations Lori
>Migrations for 'Lori':
>   0001_initial.py:
> - Create model AUB
> - Create model Ausbezahlt
> - Create model Aushilfslohn
> - Create model Bereich
> - Create model Code
> - Create model Erfasst
> - Create model KalenderEintrag
> - Create model Kostenstelle
> - Create model Mitarbeiter
> - Create model MonatsSalden
> - Create model Oeffnungszeiten
> - Create model PekoBenchmarkCache
> - Create model PekoGewichte
> - Create model Region
> - Create model Schicht
> - Create model Status
> - Create model SystemEmailEmpfaenger
> - Create model TempMaBereichZuordnung
> - Create model Termin
> - Create model Umsatzgruppe
> - Create model UserProfile
> - Create model Vertragsverlauf
> - Create model Vorblendplan
> - Create model Vortraege
> - Alter unique_together for schicht (1 constraint(s))
> - Add field region to pekogewichte
> - Add field fil_gruppe to pekobenchmarkcache
> - Alter unique_together for pekobenchmarkcache (1 constraint(s))
> - Alter unique_together for monatssalden (1 constraint(s))
> - Add field tmp_bereiche to mitarbeiter
> - Add field vbp_neu to mitarbeiter
> - Add field fil_gruppe to kostenstelle
> - Add field parent to kostenstelle
> - Add field region to kostenstelle
> - Add field kstellen to kalendereintrag
> - Add field regionen to kalendereintrag
> - Add field key to erfasst
> - Add field last_user to erfasst
> - Add field status to erfasst
> - Alter unique_together for erfasst (1 constraint(s))
> - Add field region to bereich
> - Add field key to ausbezahlt
> - Alter unique_together for ausbezahlt (1 constraint(s))
> - Add field ma to aub
>
>(Zeiterfassung)carsten@blue-ring-ubuntu:~/Zeiterfassung$ ./manage.py
>migrate
>Operations to perform:
>   Apply all migrations: admin, contenttypes, Lori, auth, sessions
>Running migrations:
>   Applying Lori.0001_initial...Traceback (most recent call last):
>   File "./manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
>"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>
>line 385, in execute_from_command_line
> utility.execute()
>   File 
>"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>
>line 377, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
>"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/base.py",
>
>line 288, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
>"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/base.py",
>
>line 338, in execute
> output = self.handle(*args, **options)
>   File 
>"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>
>line 161, in handle
> executor.migrate(targets, plan, fake=options.get("fake", False))
>   File 
>"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/db/migrations/executor.py",
>
>line 68, in migrate
> self.apply_migration(migration, fake=fake)
>   File 
>"/home/carsten/.virtualenvs/Zeiterfassung/local/lib/python2.7/site-packages/django/db/migrations/executor.py",
>
>line 102, in apply_migration
> migration.apply(project_stat

JOB: Django backend dev for awesome Internet of Things project

2015-02-02 Thread Abraxas Entirely
Hi all,

I'm looking for an experienced Django dev to help work on our backend for a 
really interesting hardware+software platform.  The company is RAB 
Lighting, sorry the link says "stealth," the product is not launched yet 
and there's only so much I can say publicly now.  I know that's sort of 
against the rules so I apologize, but it really is a cool project. 
 Full-time, very competitive salary, great benefits, onsite in Manhattan, 
NYC.  This is a long-term product and position.

Responsibilities: extending and maintaining our existing Django app, 
consulting on other components of the system if possible.  This is pretty 
much a 100% python job, but if you love Javascript too, hey, even better. 
 The app involves lots of networking, realtime messaging with websockets, 
RBAC, Postgres and some Mongo, Redis, RabbitMQ, Celery.  Bonus points for 
AWS deployment experience.

Please have a look and apply here:
https://www.ziprecruiter.com/jobs/stealth-iot-company-6af9372d/software-engineer-backend-12e723ea

Thanks in advance and apologies if I left anything out!

Sincerely,
—T3db0t

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/94337a9d-1ea3-4b39-9d51-82f61900ce5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: simple friends template help

2015-02-02 Thread Pawan Kumar
Hi Justin, 

I'm relatively new to django and while using the django simple friend app i 
have bumped into the same issue as you. 
I do not know how to tie back the views to templates so the results are 
visually appreciated. 

would you be able to help me out?

I want to see a template or page saying "you have sent a friend request to 
X" when i use http://127.0.0.8800/add/x...@gmail.com url

Please let me know what you think.

Thanks,
Pawan

On Monday, March 28, 2011 at 6:02:52 AM UTC+5:30, justin jools wrote:
>
> need some help setting up templates for friends list: 
>
> how do I iterate a list of invited friends and are friends? I have 
> tried: 
>
>
>   {% for friends in Friendship.objects.are_friends %} 
>
>  target_user: {{ friends.target_user}} 
>  current_user:{{ friends.current_user}} 
>  are_friends: {{ friends.are_friends}} 
>  is_invited: {{ friends.is_invited}} 
>
>   {% endfor %} 
>
> gives me nothing but: 
>
> {{ is_invited }} 
> {{ are_friends }} 
> {{ target_user }} 
> {{ current_user }} 
>
>
> output: 
>
> false 
> false 
> name 
> name 
>
> I have been trying to figure this out for months. Please help.

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


Re: Migrating to initial migration: "ORA-00955: name is already used by an existing object"

2015-02-02 Thread Carsten Fuchs

Hi Markus,

thanks for your reply!

Am 02.02.2015 um 22:59 schrieb Markus Holtermann:

Did you see the chapter at the end of the page you linked to: Upgrading from 
South: 
https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-south


Well, yes, but I'm *not* upgrading from South, the project did not use 
any migrations at all before.


However, in its very beginnings, it started with a legacy database that 
was used with a PHP application that many years ago was replaced with 
this Django project.



1. Make sure the database schema defined by your models (and Django migrations) 
exactly matches the one in the database (this includes null constraints, 
indexes, etc.) to prevent errors in the future


If this is the problem, I'm not sure how to figure out what the 
differences actually are, or what mismatch it is that brings the 
`migrate` command to abort. Can I somehow have Django provide more 
details on the matter?


Best regards,
Carsten

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


Re: sending email

2015-02-02 Thread sum abiut
Hi James,

if you have a look at my view.py code below. i am trying to send email to a
selected user that i have select to update that particular user using a
form. The updated part is working fine now, i can update the particular row
that i have selected. what i want to do next is to email that particular
user that his data has been updated. i am still very confuse about the
email part.

view.py

def coporateservices_authorized_Leave(request, id):
if request.method == 'POST':
a=newleave.objects.get(id=id)
form = coporateservices_authoriseleave(request.POST, instance=a)
if form.is_valid():
   form.save()
to_emails = [a.admins.all()]
send_mail("RBV Leave Application Email Testing", "Your Leave have
been approved",
"RBV eLeave ", [to_emails])
return render_to_response('thankyou.html')
else:
a=newleave.objects.get(id=id)
form =  coporateservices_authoriseleave(instance=a)
return render_to_response('coporate_services_leave_approvial.html',
{'form': form}, context_instance=RequestContext(request))



model.py

class newleave(models.Model):
first_name = models.CharField(max_length=45)
last_name =models.CharField(max_length=45)
department=models.CharField(max_length =45)
position=models.CharField(max_length =45)
leave_type =models.CharField(max_length=45)
specify_details=models.TextField(default="")
start_date =models.DateField(null=True)
end_date=models.DateField(null=True)
total_working_days=models.IntegerField(null=True)
department_head_authorization =models.CharField(max_length=45, default ="")
authorized_by=models.CharField(max_length=45,  default ="")
remarks=models.TextField()
authorization_date =models.DateField(null=True)
corporate_services_authorization =models.CharField(max_length=45)
authorized_by1=models.CharField(max_length=45)
remarks1=models.TextField(default ="")
authoriztaion1_date =models.DateField(null=True)
total_Leave_Left =models.IntegerField(default=20)
username  =models.ForeignKey(User,  default =1)











On Mon, Feb 2, 2015 at 8:44 PM, monoBOT  wrote:

>
> 2015-02-02 6:51 GMT+01:00 sum abiut :
>
>>
>> to_emails = [a.admins.all()]
>
>
> You are asking for item admins here:
>
>
> to_emails = [a.admins.all()]
> 
>
>
>
> --
> *monoBOT*
> Visite mi sitio(Visit my site): monobotsoft.es/blog/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BxOsGBHGrjKgDV7ZvS%2Bs1EUm571bpQzdGPEn6MGyRKvUqYh2w%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y48H8FahyqnxD00fA2g%3Dw8OTRQyn7LkN4%2BRhaVbUL1SWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: sending email

2015-02-02 Thread sum abiut
Hi James,
I manage to fixe my email issue. Basically what i am trying to do here is
to get the app to send an email to the a leave applicant when his/her leave
is approved by the department director and at the same time update the data
on the databases.

Here is my working view.py code for future referencing.

def coporateservices_authorized_Leave(request, id):
if request.method == 'POST':
a=newleave.objects.get(id=id)
form = coporateservices_authoriseleave(request.POST, instance=a)
if form.is_valid():
 form.save()
to_emails = [u.email for u in
User.objects.filter(username__in=[a.username])]
send_mail("RBV Leave Application Email Testing", "Your Leave
Application have been approved by"+" "+a.authorized_by1,
"RBV eLeave ", to_emails)
return render_to_response('thankyou.html')
else:
a=newleave.objects.get(id=id)
form =  coporateservices_authoriseleave(instance=a)
return render_to_response('coporate_services_leave_approvial.html',
{'form': form}, context_instance=RequestContext(request))

once again thank you very much for your help.


 Cheers.




On Tue, Feb 3, 2015 at 2:38 PM, sum abiut  wrote:

> Hi James,
>
> if you have a look at my view.py code below. i am trying to send email to
> a selected user that i have select to update that particular user using a
> form. The updated part is working fine now, i can update the particular row
> that i have selected. what i want to do next is to email that particular
> user that his data has been updated. i am still very confuse about the
> email part.
>
> view.py
>
> def coporateservices_authorized_Leave(request, id):
> if request.method == 'POST':
> a=newleave.objects.get(id=id)
> form = coporateservices_authoriseleave(request.POST, instance=a)
> if form.is_valid():
>form.save()
> to_emails = [a.admins.all()]
> send_mail("RBV Leave Application Email Testing", "Your Leave have been 
> approved",
> "RBV eLeave ", [to_emails])
> return render_to_response('thankyou.html')
> else:
> a=newleave.objects.get(id=id)
> form =  coporateservices_authoriseleave(instance=a)
> return render_to_response('coporate_services_leave_approvial.html', {'form': 
> form}, context_instance=RequestContext(request))
>
>
>
> model.py
>
> class newleave(models.Model):
> first_name = models.CharField(max_length=45)
> last_name =models.CharField(max_length=45)
> department=models.CharField(max_length =45)
> position=models.CharField(max_length =45)
> leave_type =models.CharField(max_length=45)
> specify_details=models.TextField(default="")
> start_date =models.DateField(null=True)
> end_date=models.DateField(null=True)
> total_working_days=models.IntegerField(null=True)
> department_head_authorization =models.CharField(max_length=45, default 
> ="")
> authorized_by=models.CharField(max_length=45,  default ="")
> remarks=models.TextField()
> authorization_date =models.DateField(null=True)
> corporate_services_authorization =models.CharField(max_length=45)
> authorized_by1=models.CharField(max_length=45)
> remarks1=models.TextField(default ="")
> authoriztaion1_date =models.DateField(null=True)
> total_Leave_Left =models.IntegerField(default=20)
> username  =models.ForeignKey(User,  default =1)
>
>
>
>
>
>
>
>
>
>
>
> On Mon, Feb 2, 2015 at 8:44 PM, monoBOT  wrote:
>
>>
>> 2015-02-02 6:51 GMT+01:00 sum abiut :
>>
>>>
>>> to_emails = [a.admins.all()]
>>
>>
>> You are asking for item admins here:
>>
>>
>> to_emails = [a.admins.all()]
>>
>>
>>
>> --
>> *monoBOT*
>> Visite mi sitio(Visit my site): monobotsoft.es/blog/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2BxOsGBHGrjKgDV7ZvS%2Bs1EUm571bpQzdGPEn6MGyRKvUqYh2w%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y4aJYmh1zS--w5vdi6dPJpW_acruQY-JfWbtWUwFgOw

Create User method for Custom Manager Django

2015-02-02 Thread Max Nathaniel Ho


Hi all,

I am following this tutorial (
http://musings.tinbrain.net/blog/2014/sep/21/registration-django-easy-way/) 
to create a user registration model in Django.

I understand that the class UserManager is overwriting the default User 
model. However, I do not understand this particular part.

The official Django Documentation doesn't explain what this means - It 
merely shows the full code.

https://docs.djangoproject.com/en/1.7/topics/auth/customizing/

Need some clarification as to what's going on here. What is self.model in 
this example and what does it do?

def create_user(self, email, password, **kwargs):
user = self.model(email=self.normalize_email(email), 
is_active=True, **kwargs)
user.set_password(password)
user.save(using=self._db)
return user

This is the entire code. 



> class UserManager(BaseUserManager):
> def create_user(self, email, password, **kwargs):
> user = self.model(email=self.normalize_email(email), 
> is_active=True, **kwargs)
> user.set_password(password)
> user.save(using=self._db)
> return user
> 
> def create_superuser(self, email, password, **kwargs):
> user = self.model(email=email, is_staff=True, is_superuser=True, 
> is_active=True, **kwargs)
> user.set_password(password)
> user.save(using=self._db)
> return user
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3bd8dc94-0a6f-4363-98ca-9baf7b504e97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: sending email

2015-02-02 Thread James Schneider
Oh, I see what you are trying to do. It looks like you are running needless
queries though.

Your newleave model has this:

username  =models.ForeignKey(User,  default =1)

That's an FK to User, which means this line in your view:

to_emails = [u.email for u in
User.objects.filter(username__in=[a.username])]

is only querying for information that you already have, and trying to use
list comprehension for a query that should only ever return a single
result. The line above should be shortened to the following:

to_emails = [ a.username.email ]

I was previously assuming that you wanted to email the admins of the leave,
hence the funny query with a.admins, etc (which was a pure guess since I
hadn't seen the model). Now I can see that you want to email the user that
is directly attached to the leave. To make it even more slick, in addition
to the change above, you can also add a select_related('username') to the
original newleave query so that you'll only run a single query, which is
much more efficient, like this:


def coporateservices_authorized_Leave(request, id):
if request.method == 'POST':
a=newleave.objects.select_related('username').get(id=id)
form = coporateservices_authoriseleave(request.POST, instance=a)

if form.is_valid():
form.save()
to_emails = [ a.username.email ]
send_mail("RBV Leave Application Email Testing", "Your Leave
Application have been approved by"+" "+a.authorized_by1,
"RBV eLeave ", to_emails)
return render_to_response('thankyou.html')
else:
a=newleave.objects.get(id=id)
form =  coporateservices_authoriseleave(instance=a)
return render_to_response('coporate_services_leave_approvial.html',
{'form': form}, context_instance=RequestContext(request))


Other musings:

Try to be more consistent with your naming conventions for your classes and
function/view names. For example, I would have named your newleave class as
NewLeave, using CamelCase (aka CapCase) for all class names. Check out
Python's PEP8 for more style guidelines:
https://www.python.org/dev/peps/pep-0008/

I would also recommend using string token replacement to fill in strings
using data from variables rather than concatenating them using the +
notation. For example:

"Your Leave Application have been approved by {}".format(a.authorized_by1)

It is more conventional and will make it easier to start passing in strings
for translation later, if needed.


Glad you got it working though.

-James


On Feb 2, 2015 9:03 PM, "sum abiut"  wrote:

> Hi James,
> I manage to fixe my email issue. Basically what i am trying to do here is
> to get the app to send an email to the a leave applicant when his/her leave
> is approved by the department director and at the same time update the data
> on the databases.
>
> Here is my working view.py code for future referencing.
>
> def coporateservices_authorized_Leave(request, id):
> if request.method == 'POST':
> a=newleave.objects.get(id=id)
> form = coporateservices_authoriseleave(request.POST, instance=a)
> if form.is_valid():
>  form.save()
> to_emails = [u.email for u in
> User.objects.filter(username__in=[a.username])]
> send_mail("RBV Leave Application Email Testing", "Your Leave
> Application have been approved by"+" "+a.authorized_by1,
> "RBV eLeave ", to_emails)
> return render_to_response('thankyou.html')
> else:
> a=newleave.objects.get(id=id)
> form =  coporateservices_authoriseleave(instance=a)
> return
> render_to_response('coporate_services_leave_approvial.html', {'form':
> form}, context_instance=RequestContext(request))
>
> once again thank you very much for your help.
>
>
>  Cheers.
>
>
>
>
> On Tue, Feb 3, 2015 at 2:38 PM, sum abiut  wrote:
>
>> Hi James,
>>
>> if you have a look at my view.py code below. i am trying to send email to
>> a selected user that i have select to update that particular user using a
>> form. The updated part is working fine now, i can update the particular row
>> that i have selected. what i want to do next is to email that particular
>> user that his data has been updated. i am still very confuse about the
>> email part.
>>
>> view.py
>>
>> def coporateservices_authorized_Leave(request, id):
>> if request.method == 'POST':
>> a=newleave.objects.get(id=id)
>> form = coporateservices_authoriseleave(request.POST, instance=a)
>> if form.is_valid():
>>form.save()
>> to_emails = [a.admins.all()]
>> send_mail("RBV Leave Application Email Testing", "Your Leave have been 
>> approved",
>> "RBV eLeave ", [to_emails])
>> return render_to_response('thankyou.html')
>> else:
>> a=newleave.objects.get(id=id)
>> form =  coporateservices_authoriseleave(instance=a)
>> return render_to_response('coporate_services_leave_approvial.html', {'form': 
>> form}, context_instance=RequestContext(request))
>>
>>
>>
>> 

Re: sending email

2015-02-02 Thread sum abiut
Hi James,
Thanks very much for clearing things up. I appreciate every bit of
information and help from you. I have learn a lot since i have join this
mailing list. I am pretty much new to Django and i appreciate every help
and support that you guys are giving. It helps heaps. i will follow your
direction.

Cheers

On Tue, Feb 3, 2015 at 5:38 PM, James Schneider 
wrote:

> Oh, I see what you are trying to do. It looks like you are running
> needless queries though.
>
> Your newleave model has this:
>
> username  =models.ForeignKey(User,  default =1)
>
> That's an FK to User, which means this line in your view:
>
> to_emails = [u.email for u in
> User.objects.filter(username__in=[a.username])]
>
> is only querying for information that you already have, and trying to use
> list comprehension for a query that should only ever return a single
> result. The line above should be shortened to the following:
>
> to_emails = [ a.username.email ]
>
> I was previously assuming that you wanted to email the admins of the
> leave, hence the funny query with a.admins, etc (which was a pure guess
> since I hadn't seen the model). Now I can see that you want to email the
> user that is directly attached to the leave. To make it even more slick, in
> addition to the change above, you can also add a select_related('username')
> to the original newleave query so that you'll only run a single query,
> which is much more efficient, like this:
>
>
> def coporateservices_authorized_Leave(request, id):
> if request.method == 'POST':
> a=newleave.objects.select_related('username').get(id=id)
> form = coporateservices_authoriseleave(request.POST, instance=a)
>
> if form.is_valid():
> form.save()
> to_emails = [ a.username.email ]
> send_mail("RBV Leave Application Email Testing", "Your Leave
> Application have been approved by"+" "+a.authorized_by1,
> "RBV eLeave ", to_emails)
> return render_to_response('thankyou.html')
> else:
> a=newleave.objects.get(id=id)
> form =  coporateservices_authoriseleave(instance=a)
> return render_to_response('coporate_services_leave_approvial.html',
> {'form': form}, context_instance=RequestContext(request))
>
>
> Other musings:
>
> Try to be more consistent with your naming conventions for your classes
> and function/view names. For example, I would have named your newleave
> class as NewLeave, using CamelCase (aka CapCase) for all class names. Check
> out Python's PEP8 for more style guidelines:
> https://www.python.org/dev/peps/pep-0008/
>
> I would also recommend using string token replacement to fill in strings
> using data from variables rather than concatenating them using the +
> notation. For example:
>
> "Your Leave Application have been approved by {}".format(a.authorized_by1)
>
> It is more conventional and will make it easier to start passing in
> strings for translation later, if needed.
>
>
> Glad you got it working though.
>
> -James
>
>
> On Feb 2, 2015 9:03 PM, "sum abiut"  wrote:
>
>> Hi James,
>> I manage to fixe my email issue. Basically what i am trying to do here is
>> to get the app to send an email to the a leave applicant when his/her leave
>> is approved by the department director and at the same time update the data
>> on the databases.
>>
>> Here is my working view.py code for future referencing.
>>
>> def coporateservices_authorized_Leave(request, id):
>> if request.method == 'POST':
>> a=newleave.objects.get(id=id)
>> form = coporateservices_authoriseleave(request.POST, instance=a)
>> if form.is_valid():
>>  form.save()
>> to_emails = [u.email for u in
>> User.objects.filter(username__in=[a.username])]
>> send_mail("RBV Leave Application Email Testing", "Your Leave
>> Application have been approved by"+" "+a.authorized_by1,
>> "RBV eLeave ", to_emails)
>> return render_to_response('thankyou.html')
>> else:
>> a=newleave.objects.get(id=id)
>> form =  coporateservices_authoriseleave(instance=a)
>> return
>> render_to_response('coporate_services_leave_approvial.html', {'form':
>> form}, context_instance=RequestContext(request))
>>
>> once again thank you very much for your help.
>>
>>
>>  Cheers.
>>
>>
>>
>>
>> On Tue, Feb 3, 2015 at 2:38 PM, sum abiut  wrote:
>>
>>> Hi James,
>>>
>>> if you have a look at my view.py code below. i am trying to send email
>>> to a selected user that i have select to update that particular user using
>>> a form. The updated part is working fine now, i can update the particular
>>> row that i have selected. what i want to do next is to email that
>>> particular user that his data has been updated. i am still very confuse
>>> about the email part.
>>>
>>> view.py
>>>
>>> def coporateservices_authorized_Leave(request, id):
>>> if request.method == 'POST':
>>> a=newleave.objects.get(id=id)
>>> form = coporateservices_authorise

Re: upload_to for ImageField changes name of file being uploaded

2015-02-02 Thread bradford li
There is bounty on this stackoverflow question is anyone is interested

On Thursday, January 29, 2015 at 12:35:22 AM UTC-8, bradford li wrote:
>
> I posted a question on stackoverflow regarding my issue:
>
>
> http://stackoverflow.com/questions/28205560/upload-to-value-changes-photo-name-attribute
>
> Basically upload_to value will change my ImageField.name to the upload_to 
> value
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2d1109a8-31a7-41ac-8639-acb4a413643d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


two django sites at different revisions with apache

2015-02-02 Thread Mike Dewhirst
Is it possible to run two virtual hosts on the same machine for Django 
sites where one is 1.7 and the other 1.6?


Thanks

Mike

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