Re: How to send e-mail asynchronously

2016-05-28 Thread Luis Zárate
I wrote something for send async notification that works with celery

https://github.com/luisza/async_notifications

There is a demo project and some ideas about how to implement it.

If you like you can use it and if you want to extend do it and let me know
for incorporate you're code.

El sábado, 28 de mayo de 2016, Akhil Lawrence 
escribió:
> You can create a celery task fro this. See this link for more details.
>
http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
>
>
>
> On Saturday, 28 May 2016 19:51:49 UTC+5:30, 2me wrote:
>>
>> I have to implement a thread in order to test if (temperature>maximmum)
it sends an email .
>> I have done a python file which reads temperature and as  a begining I
have tested an aplication that  sends email when I access to its URL .
>> BUt I have no idea how to this into a thread !!! please 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/b1b51b16-2318-4022-9b20-495547931635%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyPV_E8Q9S_y9f%2BCGjUhVih-c%2BUcn1m-kEWi63ZA9Z5%2BKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: UpdateView - problem with change model

2016-05-28 Thread Akhil Lawrence
Check the primary key you are passing in the URL while calling the view. 
Key of PersonalInfo need not to be the same as that of MySiteUser



On Saturday, 28 May 2016 23:44:00 UTC+5:30, Dariusz Mysior wrote:
>
> I have that problem when I change model in view class EditView on 
> PersonalInfo I have response that "Not found personal info that meet your 
> criteria" when I have model = MysiteUser than it is ok but when I change on 
> model = PersonalInfo than it's a problem.
>
> views.py
>
> from django.contrib.messages.views import SuccessMessageMixin
> from django.views.generic import TemplateView, UpdateView
> from users.models import MysiteUser, PersonalInfo
>
> class ProfileView(TemplateView):
> template_name = 'profile.html'
>
> class EditView(SuccessMessageMixin, UpdateView):
> model = PersonalInfo
> fields = ['age']
> pk_url_kwarg = 'pk'
> template_name = 'update_form.html'
> success_url = '/myprofile/'
> success_message = "Zmiany zostały wprowadzone."
>
>
> models.py
>
> from django.db import models
> from django.contrib.auth.models import AbstractUser
>
> ##
>
> class MysiteUser(AbstractUser):
> avatar = models.ImageField(upload_to="avatar")
> #age = models.IntegerField()
>
> def __str__(self):
> return self.username
>
> class PersonalInfo(models.Model):
> mysiteuser = models.OneToOneField(MysiteUser)
> age = models.IntegerField()
>
>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/280bd4ac-c84e-458a-935f-275922bac542%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to send e-mail asynchronously

2016-05-28 Thread Akhil Lawrence
You can create a celery task fro this. See this link for more details.

http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html



On Saturday, 28 May 2016 19:51:49 UTC+5:30, 2me wrote:
>
> I have to implement a thread in order to test if (temperature>maximmum) it 
> sends an email . 
> I have done a python file which reads temperature and as  a begining I 
> have tested an aplication that  sends email when I access to its URL . 
> BUt I have no idea how to this into a thread !!! please 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1b51b16-2318-4022-9b20-495547931635%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


UpdateView - problem with change model

2016-05-28 Thread Dariusz Mysior
I have that problem when I change model in view class EditView on 
PersonalInfo I have response that "Not found personal info that meet your 
criteria" when I have model = MysiteUser than it is ok but when I change on 
model = PersonalInfo than it's a problem.

views.py

from django.contrib.messages.views import SuccessMessageMixin
from django.views.generic import TemplateView, UpdateView
from users.models import MysiteUser, PersonalInfo

class ProfileView(TemplateView):
template_name = 'profile.html'

class EditView(SuccessMessageMixin, UpdateView):
model = PersonalInfo
fields = ['age']
pk_url_kwarg = 'pk'
template_name = 'update_form.html'
success_url = '/myprofile/'
success_message = "Zmiany zostały wprowadzone."


models.py

from django.db import models
from django.contrib.auth.models import AbstractUser

##

class MysiteUser(AbstractUser):
avatar = models.ImageField(upload_to="avatar")
#age = models.IntegerField()

def __str__(self):
return self.username

class PersonalInfo(models.Model):
mysiteuser = models.OneToOneField(MysiteUser)
age = models.IntegerField()



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3c4c78d8-d35c-44dd-a76a-180bd7e80dd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model inheritance with constraints

2016-05-28 Thread Akhil Lawrence
Its already addressed.

You can simply run ./manage.py makemigrations and ./manage.py migrate

it will create migrations only for MyAnotherFunModel





On Thursday, 26 May 2016 01:02:08 UTC+5:30, Arnab Banerji wrote:
>
> Hi all,
>
> I currently have a set of models associated with my Django app, with the 
> database already containing data with respect to these tables (models). 
>
> What I have
> =
>
> class MyFunModel(models.Model):
> my_foo_field = 
>
> What I am attempting to add
> =
>
> class MyAnotherFunModel(MyFunModel):
> my_another_foo_field = 
>
> Such that the migration gives me *only* _myanotherfunmodel table with 
> fields "my_foo_field" and "my_another_foo_field", *without* touching any 
> data in the _myfunmodel table. 
>
> None of the options in 
> https://docs.djangoproject.com/en/dev/topics/db/models/#model-inheritance 
> seem to address this case, or maybe I am missing something?
>
> Thanks,
> AB
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fbc77543-ee22-4b61-a295-b5f1870b1648%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I am not able to run the following code

2016-05-28 Thread Akhil Lawrence
Hi Madhusudhana,

When you try to create the instance of Template, its looking for settings 
that is why you are getting error.

*You cannot play in python shell without creating django project*

Create the project and use django shell. The following code snippets may 
help you in creating project (execute following in terminal),

django-admin startproject madhu
cd madhu
./manage.py shell







On Thursday, 26 May 2016 17:14:02 UTC+5:30, Madhusudhana H V wrote:
>
> I am trying to execute the following code. But I am getting error at step 2, 
> namely ">>> t = template.Template('My name is {{ name }}.')"
> Kindly help me out of this.
>
> >>> from django import template>>> t = template.Template('My name is {{ name 
> >>> }}.')>>> c = template.Context({'name': 'Adrian'})>>> print t.render(c)My 
> >>> name is Adrian.>>> c = template.Context({'name': 'Fred'})>>> print 
> >>> t.render(c)My name is Fred.
>
> Thanks and Regards,
> Madhusudhana H V
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fe41438c-ed6b-4396-a4f4-a7a26e398732%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why blank page when load a list or dictionary into web to display a list

2016-05-28 Thread Akhil Lawrence
Dude,

You need to make the following changes.

1. you need to pass a dictionary as the context in your views

 return render(request, 'approval.html', {'posts': posts})

2. the prefer the posts to be list of dict

change 

posts = {}
...
LL = [(1,eachbracket)]
posts.update(LL)

to

posts = []
..
posts.append(eachbracket)

 3. you templates syntax is wrong correct it, use {{ }}

{% block content %}

{% for post in posts %}
  

  {{ post.project }}


  {{ post.company }}


  {{ post.name }}


  {{ post.businessType }}


  {{ post.userType }}

  
{% endfor %}

{% endblock %}
 



On Friday, 27 May 2016 15:27:32 UTC+5:30, meInvent bbird wrote:
>
>
> https://drive.google.com/file/d/0Bxs_ao6uuBDUYkRIdlZfbEFLV3c/view?usp=sharing
>
> http://x.x.x.x/reg/approval.html
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bae31a2e-d8b8-4c1b-b8d6-7091bfa0927f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to send e-mail asynchronously

2016-05-28 Thread 2me
I have to implement a thread in order to test if (temperature>maximmum) it 
sends an email . 
I have done a python file which reads temperature and as  a begining I have 
tested an aplication that  sends email when I access to its URL . 
BUt I have no idea how to this into a thread !!! please 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c4589ba1-597a-4d22-bf5b-86b62b28067b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: EDMS (Electronic Document Management System )

2016-05-28 Thread Akhil Lawrence
If you are going to work with documents try mongodb

On Saturday, 28 May 2016 01:44:57 UTC+5:30, Jorge Maciel wrote:
>
> Hi, I'm developing a EDMS (Electronic Document Management System ) for 
> small business. I am in doubt about the infrastructure should I use to 
> create this system . I think he should be SAAS , Each company has several 
> departments and multiple users and they can share documents with each 
> other. I need to limit the disk quota by company hall example "A" is 
> entitled to 1 GB . How to do this? What is the best database for this 
> type of application ?
>
> I know there are many things to consider but if you can help me 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75390690-890f-47dc-b730-e84b3b8fbe49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to implement a ManyToManyField with a View

2016-05-28 Thread Akhil Lawrence
Hi Bruce,

You need to call `contact.relationship.all` instead of 
`contact.relationship_set.all`

We use `_set.all` when we want to retrieve the related items from the 
master/parent object (Relationship in your case). So if you want to 
retrieve all contacts under a relationship you can use 
`.resource_set.all`



On Thursday, 26 May 2016 23:13:00 UTC+5:30, Bruce Whealton wrote:
>
> Hello all,
>  I started a similar thread but couldn't find it.
> I was creating a Personal Information Management Project, with Project 
> name mypim.  My first app was a contacts app.
> This has two Class based Models in the models.py in the contacts 
> directory.  My first view works fine, where I display 
> a list of contacts.  It seemed that the Django Admin got confused unless I 
> put the Relationship model prior to the Resource model.
> Ok, so, I call a Relationship model instead of Contact model for reasons 
> unimportant to my question.  Here is what my models.py looks like
> with some fields snipped to show only what is important.
>
> class Relationship(models.Model):
> category = models.CharField(max_length=60)
>
> def __str__(self):
> return self.category
>
>
> class Resource(models.Model):
> first_name = models.CharField(max_length=80)
> last_name = models.CharField(max_length=80)
> organization = models.CharField(max_length=100, null=True, blank=True)
> [snip]
> relationship = models.ManyToManyField(Relationship)
>
> class Meta:
> ordering = ['last_name',]
>
> def __str__(self):
> return self.first_name +  " " + self.last_name
>
> And my views.py for the app:
>
> def contact_list(request):
> contacts = Resource.objects.all()
> return render(request, 'contacts/contact_list.html', {'contacts': 
> contacts })
>
>
> def contact_detail(request, pk):
> contact = get_object_or_404(Resource, pk=pk)
> return render(request, 'contacts/contact_detail.html', {'contact': 
> contact})
>
> End of File.
> Ok, so when I display the list of contacts/resources, things look fine and 
> I can click on a contact and see
> the details, aka full listing of the contact, minus the categories which 
> come from the Resource.  I know things cannot be 
> correct in that the view doesn't seem to query for the categories assigned 
> to the Contact, aka Resource.  My contact_detail.html
> template has this section for displaying the category in the Relationship 
> model and I do have defined relationships.
>
> 
>   {% for relationship in contact.relationship_set.all %}
> {{ relationship.category }}
>   {% endfor %}
> 
>
> Can someone guide me here, please?  I'd actually like to display the 
> categories separated by commas on the same line.  However, I am not seeing
> anything in this area.
>
> Thanks in advance for any help,
> Bruce
>
>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ae562e90-a310-4940-9c88-dfb3855a975b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to implement a ManyToManyField with a View

2016-05-28 Thread Daniel Roseman
On Thursday, 26 May 2016 18:43:00 UTC+1, Bruce Whealton wrote:
>
> Hello all,
>  I started a similar thread but couldn't find it.
> I was creating a Personal Information Management Project, with Project 
> name mypim.  My first app was a contacts app.
> This has two Class based Models in the models.py in the contacts 
> directory.  My first view works fine, where I display 
> a list of contacts.  It seemed that the Django Admin got confused unless I 
> put the Relationship model prior to the Resource model.
> Ok, so, I call a Relationship model instead of Contact model for reasons 
> unimportant to my question.  Here is what my models.py looks like
> with some fields snipped to show only what is important.
>
> class Relationship(models.Model):
> category = models.CharField(max_length=60)
>
> def __str__(self):
> return self.category
>
>
> class Resource(models.Model):
> first_name = models.CharField(max_length=80)
> last_name = models.CharField(max_length=80)
> organization = models.CharField(max_length=100, null=True, blank=True)
> [snip]
> relationship = models.ManyToManyField(Relationship)
>
> class Meta:
> ordering = ['last_name',]
>
> def __str__(self):
> return self.first_name +  " " + self.last_name
>
> And my views.py for the app:
>
> def contact_list(request):
> contacts = Resource.objects.all()
> return render(request, 'contacts/contact_list.html', {'contacts': 
> contacts })
>
>
> def contact_detail(request, pk):
> contact = get_object_or_404(Resource, pk=pk)
> return render(request, 'contacts/contact_detail.html', {'contact': 
> contact})
>
> End of File.
> Ok, so when I display the list of contacts/resources, things look fine and 
> I can click on a contact and see
> the details, aka full listing of the contact, minus the categories which 
> come from the Resource.  I know things cannot be 
> correct in that the view doesn't seem to query for the categories assigned 
> to the Contact, aka Resource.  My contact_detail.html
> template has this section for displaying the category in the Relationship 
> model and I do have defined relationships.
>
> 
>   {% for relationship in contact.relationship_set.all %}
> {{ relationship.category }}
>   {% endfor %}
> 
>
> Can someone guide me here, please?  I'd actually like to display the 
> categories separated by commas on the same line.  However, I am not seeing
> anything in this area.
>
> Thanks in advance for any help,
> Bruce
>
>

The many-to-many field is defined on the Resource model itself, so you use 
that field itself, rather than any "reverse" relationship syntax.

 {% for relationship in contact.relationship.all %}

(Since that field refers to many objects, you may want to call it 
"relationships" instead.)
-- 
DR.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/76c120d5-f07f-480b-aacd-0786e41f7386%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Errors in runserver command: Django 1.9.6

2016-05-28 Thread palansh agarwal
Hello all,

I was trying to setup my django project on amazon ec2 instance. When I do 
"python manage.py runserver 0.0.0.0:8000" and try to access the website 
from my browser, I get the following stack trace:

Traceback (most recent call last):
>   File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run
> self.finish_response()
>   File "/usr/lib/python2.7/wsgiref/handlers.py", line 131, in 
> finish_response
> self.close()
>   File "/usr/lib/python2.7/wsgiref/simple_server.py", line 33, in close
> self.status.split(' ',1)[0], self.bytes_sent
> AttributeError: 'NoneType' object has no attribute 'split'
>
>
Any hep would be appreciated.

Thanks
Palansh Agarwal 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9d0d9ce3-1d3d-4cfe-9c0f-797120f27dfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.