Re: how to implement lazy settings as django setting

2016-03-03 Thread Daniel Chimeno
Hello,

https://www.djangopackages.com/grids/g/live-setting/



El miércoles, 2 de marzo de 2016, 16:53:09 (UTC+1), luisza14 escribió:
>
> I need to implement a lazy setting like django setting that could be call 
> globally in several apps but get his values from a model in database.
>
> I have some settings that need to be change by the admin user, so my apps 
> expect that settings but can not loaded on django setup because needs 
> populate with fields in db or something that user can change without 
> touching code.  So I thing I can implement a lazy setting that use database 
> in request process time and cached the result.
>
> So do you have some idea how to implement that.
>
> -- 
> "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/ff317794-8928-4610-9dbe-2d480f986956%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


blog base on django!

2016-03-03 Thread 徐帅


I create a mini blog base on python + django.

repo : https://github.com/xushvai/io



-- 
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/4b49ec80-e744-4e76-a878-397e737425e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GROUP BY without using aggregate function

2016-03-03 Thread Michal Petrucha
On Wed, Mar 02, 2016 at 09:21:03AM -0800, marcin.j.no...@gmail.com wrote:
> 
> 
> On Wednesday, March 2, 2016 at 6:11:32 PM UTC+1, Dan Tagg wrote:
> >
> > if your aren't counting or averaging then why are you grouping?
> >
> >
> >
> To fast find distinct values within big dataset - some queries on some 
> engines may be faster when using grouping. 
> It was known technique years ago and I'm still using it.

As far as I know, reasonable SQL engines require that every selected
column is either in GROUP BY, or wrapped in an aggregation function
(and on those that don't enforce this rule, the result contains
arbitrary values). I fail to see how a query like this could map to
model instances.

Perhaps if you could provide a more specific example of what kind of
query you're trying to build here?

Merely based on your vague description, it seems to me that this is
one of the cases where you might be better off writing your SQL query
manually.

Cheers,

Michal

-- 
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/20160303132736.GD960%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: GROUP BY without using aggregate function

2016-03-03 Thread marcin . j . nowak


On Thursday, March 3, 2016 at 2:28:58 PM UTC+1, Michal Petrucha wrote:
>
>
> Merely based on your vague description, it seems to me that this is 
> one of the cases where you might be better off writing your SQL query 
> manually. 
>
>
Narrowing results by `filter()` is very handy, in contrast to writing raw 
sql. I need to add GROUP BY clause only.
To be honest I'm waiting for official support for SQLAlchemy in Django, 
because Django ORM is very limited.

But after a while I realized that I should verify performance differences 
between DISTINCT and GROUP BY.  Maybe today query planners are smart 
enough, so the "group by" trick can be abadoned.

The example of query is `select rel_id from some_table group by rel_id` 
(versus select distinct rel_id from some_table) 

Marcin


-- 
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/2a3a9fdb-d899-42a3-971d-315504351f6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Error using Django 1.9 with Postgres

2016-03-03 Thread Fellipe Henrique
Hello,

I`m start to using Django 1.9 with PostgreSQL, and when I try to add a
record  using Admin, show me these error:

IntegrityError at /admin/cadastro/mercadoria/add/

insert or update on table "django_admin_log" violates foreign key
constraint "django_admin_log_user_id_c564eba6_fk_accounts_webconflexuser_id"
DETAIL:  Key (user_id)=(1) is not present in table
"accounts_webconflexuser".

Here is my traceback [1]

I`m using a custom user model. And yes! I have a admin user and logged with
them...

Any ideia what's going on?

[1] - http://pastebin.com/2LAhmd40

T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh *
*Twitter: @fh_bash*

-- 
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/CAF1jwZE%3Djn7zXLwkT8AyiSSOrMVjtGDUw9Cvq25DevtwUTQ9HQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Add model item with AJAX pop up

2016-03-03 Thread guettli
The comparison grid of autocomplete inputs has a feature called 
"Add-another outside the admin":

These libraries support adding new instances. I don't know if they use an 
ajay pop-up or an other solution:

https://www.djangopackages.com/grids/g/auto-complete/



Am Montag, 8. Februar 2016 21:12:47 UTC+1 schrieb guettli:
>
> There many auto-complete fields. Adding an item in a popup is needed very 
> often. The django-admin does it, too.
>
> For me it is strange that there is no reusable widget for this.
>
> Am Montag, 8. Februar 2016 09:17:48 UTC+1 schrieb pa xapy:
>>
>> hi
>> easiest way is to write separate view which will handle ajax requests 
>> (get and post) and render html (as a json field) and success status as 
>> response.
>> on frontend you will handle this response to show modal with form and 
>> submit it until model will successfully saved
>> once it happens, you can refetch your users list in select field
>>
>> but I don't know any application which implement all this stack. I think 
>> you should handle this modal by yourself
>>
>> On Saturday, February 6, 2016 at 4:12:48 PM UTC+3, guettli wrote:
>>>
>>> I use django-select2  for 
>>> easy ForeignKey picking. Works nice.
>>>
>>>
>>> But how can I add a new item in the ForeignKey table?
>>>
>>>
>>> I would like to have a big [+] button near the select2 field and then a 
>>> (ajax) modal dialog should open (like in the admin interface).
>>>
>>>
>>> AFAIK django-select2 does not help here. Is there a different library 
>>> which can help here?
>>>
>>>
>>> I would like to re-use and not to re-invent. Maybe I was blind, but I 
>>> could not
>>>
>>> find a matching comparison grid on djangopackages.com.
>>>
>>>
>>> I would like to avoid a "old-school" browser-window-pop-up :-)
>>>
>>>
>>> Regards,
>>>
>>>   Thomas Güttler
>>>
>>

-- 
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/c2f38545-9b22-42f2-9d7a-81b615ffc41a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to implement lazy settings as django setting

2016-03-03 Thread Luis Zárate
Thanks,

El jueves, 3 de marzo de 2016, Daniel Chimeno  escribió:
> Hello,
> https://www.djangopackages.com/grids/g/live-setting/
>
>
> El miércoles, 2 de marzo de 2016, 16:53:09 (UTC+1), luisza14 escribió:
>>
>> I need to implement a lazy setting like django setting that could be
call globally in several apps but get his values from a model in database.
>>
>> I have some settings that need to be change by the admin user, so my
apps expect that settings but can not loaded on django setup because needs
populate with fields in db or something that user can change without
touching code.  So I thing I can implement a lazy setting that use database
in request process time and cached the result.
>>
>> So do you have some idea how to implement that.
>>
>> --
>> "La utopía sirve para caminar" Fernando Birri
>>
>> <
https://lh6.googleusercontent.com/proxy/8iqZANA8T-JlL2wQi5lEHRd-whdN6RJo8n0XbyX8BoycJFMGbhH6T-bhP0QOm-Q4oV4TE9rQPrATwAa1cO3rIb1FLPUUY_r5iM3pGkti34V9FaUp7Frah009olDr7HyrCUPdAny_5tnzwv9cvpqOxJoU7WphUmkSzvLoWRE4VWkYSvbkDrc0j0uPPhE92REFBYU8Vsdx0AQ=w5000-h5000
>
>>
> --
> 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/ff317794-8928-4610-9dbe-2d480f986956%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%2B5VyPJ3xhWFAGRUPv6gkEKMJX7xHiWArjyqkaH7uLuNE-Z4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Development of web based image processing package

2016-03-03 Thread Neha Chhattani
hello
i want to create a website that will do image processing in real time. i 
want to load large tiff images i.e. images used in remote sensing and 
satellite images. I want to do processing on satellite images. is it 
possible to do this processing in website using django? If yes, how to 
start with? what are the requirements for this? 

-- 
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/30e3a8bf-6c2c-40fe-aa7a-43bbc980ac7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to create groups for users in Django

2016-03-03 Thread dszczesniak


Hello! 

I have a problem, like in topic, with creating groups in django. I was 
searching everywhere and nothing was so interested.

What i want from this section: I would like to by filling a column with the 
name of the group, formed a quite new group, on the occasion of adding me 
as one of the members and preferably, as a leader, who can add other users 
to the group.

My problem: I did one form for name, and when i sending a request, i got 
nothing, only the stie is re-loaded. I have some code but don;t know what 
to do next..


My code:


models.py:


class Person(models.Model):

name = models.CharField(max_length=128)
def __str__(self):  # __unicode__ on Python 2
return self.name

class Group(models.Model):
name = models.CharField(max_length=128)
leader = models.CharField(max_length=50)
members = models.ManyToManyField(Person, through='Membership')

def __str__(self):  # __unicode__ on Python 2
return self.name

class Membership(models.Model):
person = models.ForeignKey(Person)
group = models.ForeignKey(Group)
date_joined = models.DateField()
invite_reason = models.CharField(max_length=64)



forms.py:



class GroupForm(forms.ModelForm):
class Meta:
model = Group
fields = ('name',)



views.py:


@login_requireddef groups(request):
if request.method == "POST":
form = GroupForm(request.POST)
if form.is_valid():

grupa = Group.objects.create(name="grupa")
per = Person.objects.create(name=request.user)
m1 = Membership(person=per, group=grupa, date_joined=(1999, 8, 8), 
invite_reason="Needed programmer.")
form.save()


return render(request, 'groups.html', {'form':form})
else:
form = GroupForm()
return render(request, 'groups.html', {'form': form})



groups.html:


{% block profile %}

 
  
Create your new group !

{% csrf_token %}
{{ form|crispy }}
Go!

  
{% endblock %}



This is it... Can anyone could help me with that? I spend few days with it 
and 0 progress.


Thanks for any help!

Damian

-- 
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/b71b3e7e-a168-4f1c-aaf7-655bdee86212%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Show labels next to ManyToMany raw_id_fields

2016-03-03 Thread Tim Graham
ticket is: https://code.djangoproject.com/ticket/26313

On Tuesday, February 17, 2009 at 4:52:25 PM UTC-5, Alex Gaynor wrote:
>
>
>
> On Tue, Feb 17, 2009 at 4:50 PM, João Olavo Baião de Vasconcelos <
> joao...@gmail.com > wrote:
>
>> On Tue, Feb 17, 2009 at 5:15 PM, Alex Gaynor > > wrote:
>>
>>> Sure, what you're doing will be similar to the way it works for a 
>>> foreign key, but you're dealing with multiple values, so it'll be something 
>>> like this:
>>> http://dpaste.com/121833/
>>> You'll need to test this out to make sure it works, but it should :).
>>
>>
>> Great, Alex!! =D
>> It was almost correct! It was missing just 1 line:
>>
>> """
>> def label_for_value(self, value):
>> *value = [int(v) for v in value.split(',')]*
>> objs = self.rel.to._default_manager.filter(pk__in=value)
>> return ' %s' % 
>> ', '.join(truncate_words(obj, 14) for obj in objs)
>> """
>>
>> Now i think it's perfect!
>>
>> Does it worth a new ticket? ;D
>>
>> -- 
>> João Olavo Baião de Vasconcelos
>> Bacharel em Ciência da Computação
>> Analista de Sistemas - Infraestrutura
>> joaoolavo.wordpress.com
>>
>>
>>
> Feel free to file one, the worst thing that could happen is it will get 
> closed :) .
>
> Alex
>
> -- 
> "I disapprove of what you say, but I will defend to the death your right 
> to say it." --Voltaire
> "The people's good is the highest law."--Cicero
>

-- 
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/a7788aa3-741f-4b79-a5ed-69d9511ca230%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mathematical function and django connect

2016-03-03 Thread Xristos Xristoou
update my code khow i feel so close but not work again hahaha to many 
problems

. I want to write a django code which takes a number and a list of numbers 
from the website as user input and and then export a list with results. but 
if i run my app don't show me results from the progress in html template, i 
can only input details if i push second button just reload the page and not 
show me results.

I have written following code but it doesn't show me the results:

views.py

def calc(request):
NList=[]
num=0
a=[]
y=0
c=0
total=0
num = request.POST.get ('num', False)
if request.method=='POST' and 'btnform1' in request.POST:
b='1'.zfill(int(num))
e=b[::-1]
c=int(e)
#num=int(num)
if request.method=='POST' and 'btnform2' in request.POST:
 for i in range(int(num)):
 total = request.POST.get ('total', False)
 NList.append(int(total))
 for k in NList:
if k == 1:
y=1
elif (k > 1) and (k < 5):
y = k+1000
a.append(y)

return render_to_response ('blog/calc.html', {'a' 
:a,'num':num,'c':c,'y':y,'total':total,'NList':NList},context_instance=RequestContext(request))

html form

form id="form1" action="" method="POST">{% csrf_token %}
  Number of number: 

count


{{num}}
{% csrf_token %}
{% for i in c|make_list %}
  Enter a value: 
{% endfor %}
final

 {{ a}}or full info{% for sm in a %}
{{ sm }}{% endfor %}

urls.py

url(r'^$',views.calc, name='calc'),

this is a example if if the first input is num=4 then the script create 4 
html inputs field(to user input second number list total) but if i click 
final button dont show me resust(a=output).





Τη Τρίτη, 9 Φεβρουαρίου 2016 - 9:47:30 μ.μ. UTC+2, ο χρήστης Xristos 
Xristoou έγραψε:
>
> hello,
>
>
> i create some python mathematical function on python idle,
> i want to create website where the user import value numbers on the 
> function
> and take the results from that.
> question one,how to connect my mathematical function on the django?
> question two,how to connect input and output from the scipts in the 
> website ?
> the second question i ask because input and output from the function is a 
> dynamic define from the 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d64a4f0a-6c20-48c8-ab4e-930fcb3c0d08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Development of web based image processing package

2016-03-03 Thread James Schneider
On Thu, Mar 3, 2016 at 6:25 AM, Neha Chhattani 
wrote:

> hello
> i want to create a website that will do image processing in real time. i
> want to load large tiff images i.e. images used in remote sensing and
> satellite images. I want to do processing on satellite images. is it
> possible to do this processing in website using django? If yes, how to
> start with? what are the requirements for this?
>

Not sure what you are intending with 'real-time'. Django can easily handle
the front-end operations for collecting the images, etc., but I doubt you
would use it directly for the image manipulation. That would be better
suited for a set of purpose-built libraries and a background batch
processor such as Celery. A user would submit a set of images to Django,
who would store them and pass the job information off to Celery for
processing. Once the job is finished, Django can manage the other tasks
associated with the processed images.

https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/
http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

You may not need a background processor if the image manipulation can be
done quickly within Django (sub-second), but if it takes any longer than
that, you'll likely need to implement something like Celery, otherwise your
site will crumble if you have any sort of substantial traffic to your site.
If Django is directly responsible for manipulating the images, the
threads/processes used by Django will be held in use and will not be
available for processing other incoming requests. Celery will keep the jobs
in a queue and is not dependent on the request/response cycle and end-user
expectations for responsiveness. ;-)

-James

-- 
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/CA%2Be%2BciXpYhFJoomEeAu97kh9o5jxgOvHp6-TH-J0Z-u7YzrKFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django: ajax simple loading gif not working/ over-riding render to output page

2016-03-03 Thread clarksonchris81


Hoping that this network can help me out even though this is not strictly 
django-related, otherwise can someone recommend a group other than stack 
overflow that could help here?

I have a functioning upload function implemented in django. The files being 
handled are large making for a long waiting time and so I would like to 
provide a "Please Wait/ Loading.../ GIF" on the page while the files are 
loading.

The HTML/Django that begins the uploading function is as follows:

   

The upload button is as follows (accompanied by a hidden div):

 
   
 

I took some example code and tried to adapt it to the above HTML but it's 
not showing up on the page at all during the loading time... and I have no 
errors to follow.

The ajax:

function showMessage() {
$('.up').show()// document.getElementById("up").innerHTML = "please 
wait";}

However my ajax code is not having any effect as the hidden div does not 
appear after clicking "Upload".

I am not at all familiar with Ajax/javascript and so while I understand 
that I can see that I am able to set a function "showMessage" and then upon 
clicking "Upload" the function will be called should render the hidden div 
to the page until the output is complete and rendered to the output page.

I should also mention that before I decided to use a GIF I successfully 
managed to get a "Please wait" message to appear after clicking the 
"Upload" button (this code is silenced in the "showMessage" function above.

The problem is that the "Please Wait" message actually over-rides the 
rendering to the output page and hence the results of the upload do not 
display when processed.

Hence overall I just want a hidden div to render to the input page until 
the output is complete and in a way that will not conflict with the more 
important, subsequent rendering to the output page.

The syntax I'm using is not having any effect on the page so I'm hoping 
someone can correct my misguided code.

Thanks

-- 
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/d37f2142-33c8-4957-bb1d-40af62aa4236%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem Django.19 upgrade and circular imports

2016-03-03 Thread Andres Osinski
Hi everyone! I'm having an issue with circular imports in Django 1.9 that I
have not seen in my app, which had been running 1.7 before.

I have a Django app in apps.common, which has its associated
apps.common.models too. No imports on __init__.py or anything of the sort.
When I my app in apps.account.models attempts to import apps.common.models,
it complains that said module does not exist.

Putting a pdb set_trace() call at the top of apps.common.models and
apps.account.models shows that the former executes *before*
apps.account.models, so I fail to see how this could result in the posted
error.

For the record, both apps use the new AppConfig scheme in their
corresponding apps.py file, and the import order in INSTALLED_APPS is:

'apps.common.CommonConfig',
'apps.account.AccountConfig',
...

Has anyone else had a similar issue in this upgrade? Is there anything I
can do to diagnose the source of this?

Thanks!

-- 
Andrés Osinski

-- 
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/CA%2BxF-Pzmr2ikH5_UhC7jM50giVxftQ5%2BwihZkyR93TbbtWoyEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Development of web based image processing package

2016-03-03 Thread Xristos Xristoou
@james celeny support .grid raster image type  ?

Τη Πέμπτη, 3 Μαρτίου 2016 - 7:47:56 μ.μ. UTC+2, ο χρήστης Neha Chhattani 
έγραψε:
>
> hello
> i want to create a website that will do image processing in real time. i 
> want to load large tiff images i.e. images used in remote sensing and 
> satellite images. I want to do processing on satellite images. is it 
> possible to do this processing in website using django? If yes, how to 
> start with? what are the requirements for this? 
>

-- 
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/eaa61a5d-f048-444b-8526-81ca9bb90992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


help with django-guardian

2016-03-03 Thread Joshua Chan
First off, I am new to both django and python.

I am working on an existing project that is using django-guardian 1.3.2

There are existing admin.py files, which load just fine.

#!/usr/bin/env python
# coding: utf-8
from guardian.admin import GuardedModelAdmin
from django.contrib import admin


from devices import models




class SomeModelAdmin(GuardedModelAdmin):
  pass


admin.site.register(models.SomeModel, SomeModelAdmin)


I added mine, and this also works (on my machine).

#!/usr/bin/env python
# coding: utf-8
from guardian.admin import GuardedModelAdmin


from django.contrib import admin
from common import models




class MyModel1Admin(GuardedModelAdmin):
pass




admin.site.register(models.Model, MyModel1Admin)




class MyModel2Admin(GuardedModelAdmin):
pass




admin.site.register(models.Model2, MyModel2Admin)



We deployed the app, and now it fails to start with the following exception:

Traceback (most recent call last):
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
>  
> line 187, in __call__
> self.load_middleware()
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/handlers/base.py",
>  
> line 47, in load_middleware
> mw_instance = mw_class()
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/middleware/locale.py",
>  
> line 24, in __init__
> for url_pattern in get_resolver(None).url_patterns:
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/urlresolvers.py",
>  
> line 365, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns", 
> self.urlconf_module)
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/urlresolvers.py",
>  
> line 360, in urlconf_module
> self._urlconf_module = import_module(self.urlconf_name)
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/utils/importlib.py",
>  
> line 40, in import_module
> __import__(name)
>   File "./sites/zpanel/urls.py", line 19, in 
> admin.autodiscover()
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
>  
> line 29, in autodiscover
> import_module('%s.admin' % app)
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/utils/importlib.py",
>  
> line 40, in import_module
> __import__(name)
>   File "./common/admin.py", line 3, in 
> from guardian.admin import GuardedModelAdmin
> ImportError: No module named admin



The server is running python 2.7.6, and I am using 2.7.10. I wouldn't think 
this is an issue since other admin.py files import from guardina.admin just 
fine.



 

-- 
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/3b338659-3ba3-4e66-8a19-6831efec7de8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


help with django-guardian

2016-03-03 Thread Joshua Chan
First off, I am new to both django and python.

I am extending an existing app. We have several admin.py files

They all look like this:

#!/usr/bin/env python
# coding: utf-8
from guardian.admin import GuardedModelAdmin
from django.contrib import admin


from devices import models


class SomeModelAdmin(GuardedModelAdmin):
pass


admin.site.register(models.SomeModel, SomeModelAdmin)

Everything has been working.

I added my classes

#!/usr/bin/env python
# coding: utf-8
from guardian.admin import GuardedModelAdmin


from django.contrib import admin
from common import models


class MyModel1Admin(GuardedModelAdmin):
pass


admin.site.register(models.Model, MyModel1Admin)


class MyModel2Admin(GuardedModelAdmin):
pass


admin.site.register(models.Model2, MyModel2Admin)

This also works fine locally, but when we deploy it, it blows up on the 
import:

Traceback (most recent call last):
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
>  
> line 187, in __call__
> self.load_middleware()
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/handlers/base.py",
>  
> line 47, in load_middleware
> mw_instance = mw_class()
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/middleware/locale.py",
>  
> line 24, in __init__
> for url_pattern in get_resolver(None).url_patterns:
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/urlresolvers.py",
>  
> line 365, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns", 
> self.urlconf_module)
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/urlresolvers.py",
>  
> line 360, in urlconf_module
> self._urlconf_module = import_module(self.urlconf_name)
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/utils/importlib.py",
>  
> line 40, in import_module
> __import__(name)
>   File "./sites/zpanel/urls.py", line 19, in 
> admin.autodiscover()
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
>  
> line 29, in autodiscover
> import_module('%s.admin' % app)
>   File 
> "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/utils/importlib.py",
>  
> line 40, in import_module
> __import__(name)
>   File "./common/admin.py", line 3, in 
> from guardian.admin import GuardedModelAdmin
> ImportError: No module named admin



I am running 2.7.10 locally. The failing machine is running 2.7.6. I'm not 
sure how to switch my env around, but why would other admin.py files import 
guardian.admin correctly?
 

-- 
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/171b4b5e-e6b6-4695-889d-c0ed35ae0ebe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem Django.19 upgrade and circular imports

2016-03-03 Thread Tim Graham
No ideas off the top of my head. You could try bisecting to find the commit 
in Django where the behavior changed.

https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#bisecting-a-regression

On Thursday, March 3, 2016 at 6:29:38 PM UTC-5, Andres Osinski wrote:
>
> Hi everyone! I'm having an issue with circular imports in Django 1.9 that 
> I have not seen in my app, which had been running 1.7 before.
>
> I have a Django app in apps.common, which has its associated 
> apps.common.models too. No imports on __init__.py or anything of the sort.
> When I my app in apps.account.models attempts to import 
> apps.common.models, it complains that said module does not exist.
>
> Putting a pdb set_trace() call at the top of apps.common.models and 
> apps.account.models shows that the former executes *before* 
> apps.account.models, so I fail to see how this could result in the posted 
> error.
>
> For the record, both apps use the new AppConfig scheme in their 
> corresponding apps.py file, and the import order in INSTALLED_APPS is:
>
> 'apps.common.CommonConfig',
> 'apps.account.AccountConfig',
> ...
>
> Has anyone else had a similar issue in this upgrade? Is there anything I 
> can do to diagnose the source of this?
>
> Thanks!
>
> -- 
> Andrés Osinski
>

-- 
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/44f5f6e6-771b-4ec2-8b29-91da0cc737cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mathematical function and django connect

2016-03-03 Thread James Schneider
On Thu, Mar 3, 2016 at 10:48 AM, Xristos Xristoou  wrote:

> update my code khow i feel so close but not work again hahaha to many
> problems
>
> . I want to write a django code which takes a number and a list of numbers
> from the website as user input and and then export a list with results. but
> if i run my app don't show me results from the progress in html template, i
> can only input details if i push second button just reload the page and not
> show me results.
>
> I have written following code but it doesn't show me the results:
>
> views.py
>
> def calc(request):
> NList=[]
> num=0
> a=[]
> y=0
> c=0
> total=0
> num = request.POST.get ('num', False)
> if request.method=='POST' and 'btnform1' in request.POST:
> b='1'.zfill(int(num))
> e=b[::-1]
> c=int(e)
> #num=int(num)
> if request.method=='POST' and 'btnform2' in request.POST:
>  for i in range(int(num)):
>  total = request.POST.get ('total', False)
>  NList.append(int(total))
>  for k in NList:
> if k == 1:
> y=1
> elif (k > 1) and (k < 5):
> y = k+1000
> a.append(y)
>
> return render_to_response ('blog/calc.html', {'a' 
> :a,'num':num,'c':c,'y':y,'total':total,'NList':NList},context_instance=RequestContext(request))
>
> html form
>
> form id="form1" action="" method="POST">{% csrf_token %}
>   Number of number: 
> 
> count
> 
> 
> {{num}}
> {% csrf_token %}
> {% for i in c|make_list %}
>   Enter a value: 
> {% endfor %}
> final
> 
>  {{ a}}or full info{% for sm in a %}
> {{ sm }}{% endfor %}
>
> urls.py
>
> url(r'^$',views.calc, name='calc'),
>
> this is a example if if the first input is num=4 then the script create 4
> html inputs field(to user input second number list total) but if i click
> final button dont show me resust(a=output).
>

It appears to me that the problem is with the fact that you have two forms
on your page, but your view function is expecting values from both forms in
order to generate the results you want.

You can either a) only have a single form that is rebuilt per each step
with the additional fields you need or b) refactor your view code.

 for i in range(int(num)):
 total = request.POST.get ('total', False)
 NList.append(int(total))


Your problem in the view is that your loop relies on int(num), but the
'num' variable will be set to False when you click the 'final' button,
because it is not sent as part of that form (ie request.POST.get('num')
returns False), and so your loop will never run. In reality, you don't even
need the 'num' variable, just query the 'total' fields:

for total in request.POST.getlist('total'):
NList.append(int(total))

getlist() should return an empty list if 'total' is not available, so it
should still work on initial page loads before the user specifies the
number of fields they need, etc.

Also keep in mind that you are dealing with POST variables directly, with
no validation that you would get from a true Django Form() object, and
there is no error checking in your code either, so someone submitted 'four'
instead of '4' would cause your code to throw an exception. Using a real
Django form would help validate that case and provide error-handling to
re-display the form in the users' browser.

-James

-- 
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/CA%2Be%2BciVQp2%2BfTMrCWWdQiqKMkRviy%2BXQ0DnKW%2BgYbjh6njCktQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem Django.19 upgrade and circular imports

2016-03-03 Thread James Schneider
On Thu, Mar 3, 2016 at 3:28 PM, Andres Osinski 
wrote:

> Hi everyone! I'm having an issue with circular imports in Django 1.9 that
> I have not seen in my app, which had been running 1.7 before.
>
> I have a Django app in apps.common, which has its associated
> apps.common.models too. No imports on __init__.py or anything of the sort.
> When I my app in apps.account.models attempts to import
> apps.common.models, it complains that said module does not exist.
>
> Putting a pdb set_trace() call at the top of apps.common.models and
> apps.account.models shows that the former executes *before*
> apps.account.models, so I fail to see how this could result in the posted
> error.
>
> For the record, both apps use the new AppConfig scheme in their
> corresponding apps.py file, and the import order in INSTALLED_APPS is:
>
> 'apps.common.CommonConfig',
> 'apps.account.AccountConfig',
> ...
>
> Has anyone else had a similar issue in this upgrade? Is there anything I
> can do to diagnose the source of this?
>

Are you bringing in other functions in as part of your imports, or just
other models? If you are only bringing in models for use with FK's and
M2M's, then I would suggest referring to those models via their text path
rather than using the Python class object directly. It avoids needing the
import statement during the initial load (which avoids the circular import
issue). See the end of this section about referring to models in other
applications using a string rather than the real Python object (and make
sure to remove the related import statements):

https://docs.djangoproject.com/en/1.9/ref/models/fields/#foreignkey

-James

-- 
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/CA%2Be%2BciUWHXr6axqA5drrsMnR3%2B9d0D1wBHSK9wQwSmqs52xFAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.