django project avoid reload page where work algorithm

2017-10-07 Thread Xristos Xristoou


I have a website where the user can be put three numbers on my html 
template and get some results from my personal mathematical algorithm. the 
result save at user personal table on my database and can see in specific 
tab in my website.

my problem is where the algorithm to calculate result maybe take time 
between 5-10 minutes in this time the browser stay on reload. if user 
change tab or close browser or maybe have problem with internet connection 
then loose that request and need again to put the numbers and again wait 
for results.

I want after the user request from my form in html to keep this request and 
work my algorithm without reload the page and where the algorithm finish 
then to send the user some email or message or just need the user visit the 
tab of results to see new results.

that I want to avoid the problems where the algorithm is in running and 
user loose data or request or time.

is easy to do that using suproccess,celery or RabbitMQ ?

any idea ?

here the code

views.py

def math_alg(request):
if request.method == "POST":
test = request.POST.get('no1')
test = request.POST.get('no3')
test = request.POST.get('no3')
#start algorith
calc_math(no1,no1,no3,result)
instance = rmodel.objects.create(user=request.user,rfield=result)
instance.save
return render(request, 'page.html', {'result': result})

html :

{% csrf_token %}
  op math calculate:
  
  
  
  {{result }}

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/937d9c18-85e2-4077-a1fe-06ef992ce47e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


take select request from django from

2017-04-16 Thread Xristos Xristoou
 

hello i have create a select django form with list of images for per user.

How to take that select request in my views.py ?

i have success only to create correct that select list but i need take that 
select request but i dont know how.

models.py

class MyModel(models.Model):
user = models.ForeignKey(User, unique=True)
upload = models.ImageField(upload_to='upload')

views.py

   @login_required(login_url="login/")
def carlist(request):
Myform = MyModelForm(user=request.user)
return render(request,'about.html',{'Myform':Myform})

select django form :

class MyModelForm(ModelForm):
def __init__(self, *args, **kwargs):
# extract "user" from kwrags (passed upon form init)
if 'user' in kwargs:
self.user = kwargs.pop('user')
super(MyModelForm, self).__init__(*args, **kwargs)
# generate the choices as (display, value). 
# Display is the one that'll be shown to user, value is 
# the one that'll be sent upon submitting 
# (the "value" attribute of )
choices = MyModel.objects.filter(user=self.user).values_list('upload', 
'id')
self.fields['upload'].widget = Select(choices=choices)

class Meta:
model = MyModel
fields = ('upload',)

html :

{% 
csrf_token %}
  {{ Myform}}

for example Myform now have a list of user images that is correct but after 
from that i need the select images from the form.

can do it that with my code or not ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/42c47fb1-c0ff-445e-b052-48ea87ba0fe9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.