Re: Django TCP Socket Communication

2016-06-16 Thread Anil reddy reddy M
How i can store gps output in django model, how django will communicate 
 with micro controllar


On Thursday, June 16, 2016 at 5:08:12 PM UTC+5:30, Jani Tiainen wrote:
>
> Oops, apparently you hijacked over year old thread... 
>
> On 16.06.2016 13:45, Anil reddy reddy M wrote:
>
> Hi, 
>
>  I made a TCP Server Socket  programming in python, it's nicely 
> communicating with micro controller, and also i can store latitude 
> ,longitude values in MySqldb from GPS output. Now I want develop a web 
> application for vechile  tracking. How can i do this stuff in django.  I 
> would be thankful   for all  the help i can get! 
>
>
>
> Just make models to match tables and then use Django as you wish. There 
> isn't nothing magical there. 
>
> For starting point you can use inspectdb to create initial models from 
> your database which you then can refine to suit your needs.
>
>
>
> On Saturday, March 28, 2015 at 7:21:24 PM UTC+5:30, Gergely Polonkai 
> wrote: 
>>
>> Hello,
>>
>> it's a bit hard to understand what you exactly want to achieve. How can 
>> you communicate with the microcontroller? Do you connect to one of its TCP 
>> ports, and send it data, I assume. Is it done with a well-known protocol, 
>> like HTTP, or some custom one?
>>
>> You say that it opens a port every 5 seconds to a server. Where is that 
>> server? Is it on the same machine as you Django based application? How does 
>> the microcontroller and the server communicate with each other?
>>
>> There are so many architectural questions here before you get to a web 
>> application, and I'm afraid you original question cannot be answered before 
>> we see the whole picture.
>>
>> Best,
>> Gergely
>> On 28 Mar 2015 11:06, "bobdxcool"  wrote:
>>
>>> But is that compatible with django ?
>>>
>>> On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via Python] 
>>> <[hidden 
>>> email] > wrote:
>>>
 Have you looked at the ‘socket’ python library ? 

 François 

 > On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email] 
 > wrote: 
 > 
 > I am new to TCP socket programming. I have a django based server 
 > communicating with a microcontroller. Now, I want to implement TCP 
 based 
 > socket on the server side in order to communicate with the TCP socket 
 on the 
 > microcontroller. Can anyone give me an idea on how to do this ? What 
 > libraries should I use on my django server The microprocessor 
 basically 
 > opens the socket every 5 seconds and sends a notification to the 
 server. I 
 > on the server side should be able to read this and pump data back to 
 the 
 > microprocessor using this socket which was opened by the 
 microprocessor. 
 > 
 > 
 > 
 > -- 
 > View this message in context: 
 
 http://python.6.x6.nabble.com/
 Django-TCP-Socket-Communication-tp5090792.html
 > Sent from the django-users mailing list archive at Nabble.com. 
 > 
 > -- 
 > 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 [hidden email] 
 . 
 > To post to this group, send email to [hidden email] 
 . 
 > 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/1427483125637-5090792.post%40n6.nabble.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 [hidden email] 
 . 
 To post to this group, send email to [hidden email] 
 . 
 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/DAE16363-2EEE-4E0F-A230-A31BB270E2F9%40gmail.com.
  

 For more options, visit 
 https://groups.google.com/d/optout. 


 --
 If you reply to this email, your message will be added to the 
 discussion below:

 

Re: Absolute beginner step by step

2016-06-16 Thread M. Kholid
How about the quick way to make a dashboard and example of populating and
showing  a  select query result from a table to a form, may ne it will make
me more understand and quickly keep the basic prinsip off database
application with django.

Thanks
Kholid

On Wednesday, 15 June 2016, Mc. Holid  wrote:

> Dear All
>
> It seem this is the best starting guide for me,
>
> Just one to ask about the tips and trick how do you deal with the so many
> "unknown syntax", some time we have to use this ' character some time use
> ", then mention the name of a database field followed with array. Could
> anyone suggest for me the suitable and comprehensive exercise for fluent in
> Django syntax, May be i have to try and try again with
> learningpyhtonthehardway ?
>
> As my background try to deciding django is  seeing the motto "The web
> framework for perfectionists with deadlines.
> I got a little social project, is there a forum for mentoring or exchange
> any experience and knowledge for project based discussion.
>
>
> Thanks for any kind help.
> Best Regards
> Kholid
>
> On Tuesday, June 14, 2016 at 1:51:07 AM UTC+7, gary719_list1 wrote:
>>
>> I stand corrected. There is a new Tango With Django tutorial out. It uses
>> Python 3.5 and Django 1.9. Try /
>> media.readthedocs.org/pdf/tango-with-django/latest/tango-with-django.pdf
>>
>> Gary R
>>
>> On 06/11/2016 02:07 PM, Gary Roach wrote:
>>
>> If you don't mind working with Python2.7 and Django 1.7 you might try
>> "Tango With Django" . It is out of date but still is a good place to start.
>> Too bad that the author hasn't updated it. I have had some success with
>> running three projects in parallel. Tango along with the official Django
>> howto and another with your own project if you have one. I saw a reference
>> to "Learning Python The  Hard Way". It's a good choice.
>>
>> One nasty thing you may run into if you run parallel programs is the use
>> of multiple version of Python and Django. If you use virtualenv and pyvenv
>> to set up multiple virtual environments and then point your IDE at the one
>> needed for a particular project, you should be ok. You don't even have to
>> activate the environments because you are using them for storage of python
>> and django versions only.
>>
>> Good luck
>>
>> Gary R.
>>
>>
>> On 06/10/2016 07:32 PM, Mc. Holid wrote:
>>
>> Dear All,
>>
>> Could anyone help  to share the point for absolute beginner guide.
>>
>> I have already know a little bit about html, and having strong background
>> in vb6.
>>
>> Thanks for any kind help.
>>
>> Best Regards
>> Mchoud
>> --
>> 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...@googlegroups.com.
>> To post to this group, send email to django...@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/d2fa7fd5-2673-4292-a14e-482e148587bb%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...@googlegroups.com.
>> To post to this group, send email to django...@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/575C7D80.7060206%40verizon.net
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/cryoIzZ7p-o/unsubscribe.
> To unsubscribe from this group and all its topics, 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/0288bc9f-168b-4de8-95d3-ae59a74c4383%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message 

Re: geodjango error

2016-06-16 Thread Xristos Xristoou


Τη Πέμπτη, 16 Ιουνίου 2016 - 11:52:55 μ.μ. UTC+3, ο χρήστης Xristos 
Xristoou έγραψε:
>
> hello i want to use geos for one project.
> i have install successful gdal and leaflet and djgeojson.
> i try to open manage.py and show me that error :
>
> point import sqlite3_create_function_v2 not
> find in library dynamic connection c:programs files 
> (x86)\GDAL\spatialite.dll
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.gis',
> 'leaflet',
> 'djgeojson'
>
>
>
> any idea ?
>

-- 
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/2e1228b3-aac3-486b-8d50-9fc295e5a7e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


geodjango error

2016-06-16 Thread Xristos Xristoou
hello i want to use geos for one project.
i have install successful gdal and leaflet and djgeojson.
i try to open manage.py and show me that error :

point import sqlite3_create_function_v2 not
find in library dynamic connection c:programs files 
(x86)\GDAL\spatialite.dll



any idea ?

-- 
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/64fe1229-5007-4ddf-a47c-9b570eb7e609%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django TCP Socket Communication

2016-06-16 Thread CLIFFORD ILKAY

On 16/06/16 07:34 AM, Jani Tiainen wrote:
But there is no easy way to push arbitrary data through TCP socket to 
Django server directly - Django is mainly build around HTTP request - 
response cycle.


That is no longer true. Django Channels 
 makes this dead easy.


We're using Django Channels in a control panel for Debian virtual 
machines. The user provides some basic configuration options for the 
AngularJS/Node.js application running within the VM, such as database 
auth info, networking info, etc. On save of the singleton MachineConfig 
object, we also save the same key/value pairs into a YAML file. There is 
a daemon that is running inotifywait monitoring that YAML file for 
changes and when it detects a change, it kicks off "salt-call --local 
..." to have SaltStack configure the VM as per the key/value pairs in 
the YAML file. As Salt progresses through the various states, it sends a 
progress message on a WebSocket. Django is listening for those messages 
and displays them in an overlay that masks the page content below it on 
the control panel to provide an indication to the user what is happening 
inside the VM. When Salt has run through all the states and configured 
the VM, it sends a "Finished Configuring Machine" which is displayed for 
a few seconds and then hidden. The user then has access to the control 
panel again in case they want to change something later or restart the VM.


You can read more about Django Channels in a blog post 
 
by Jacob Kaplan-Moss. My understanding is that Channels will be 
integrated in Django core at some point.


--
Regards,

Clifford Ilkay

+ 1 647-778-8696

--
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/73ff8744-4ea1-67f0-6bda-08d025526c03%40dinamis.com.
For more options, visit https://groups.google.com/d/optout.


Stripe Not Returning Token (test mode)

2016-06-16 Thread Chris Kavanagh
*Stripe Not Returning Token (test mode)*

I'm trying out Stripe in test mode on a site I'm building, and for some 
reason Stripe won't return a token as it's supposed to.
I can tell it's not returning a token, because I get a 
MultiValueDictKeyError when submitting the form. Plus, it won't print
the token out to the console, so it's obviously not returning one.

If I change the line (* token = request.POST['stripeToken']*)  to  (*token 
= request.POST.get('stripeToken*')), I get the error  "

Request req_8eOcfP3bw2bzDd: Must provide source or customer." This way will 
actually create
a customer I can see in the Stripe Dashboard but won't create a charge, and of 
course
I get the error "must provide a source or customer."

Here's the link to Stripe form documentation along with javascript. . .
https://stripe.com/docs/custom-form


I've double checked the keys to make sure they are correct, and it's 
definitely in test mode. From the examples &
tutorials I've looked at, I don't see a reason it shouldn't be working. Any 
help is greatly appreciated, thanks Chris.

Anyway, here's the code:



*#views.py*def checkout(request):
publishable_key = settings.STRIPE_PUBLISHABLE_KEY
stripe.api_key = settings.STRIPE_SECRET_KEY
if request.method == "POST":
#token = request.POST.get('stripeToken')
token = request.POST['stripeToken']
print token
customer = stripe.Customer.create(description='test', source=token)
print customer
stripe.Charge.create(amount=500, currency='usd', source=token, 
description='test')
#stripe.Charge.create(amount=500, currency='usd', 
customer=customer, description=customer_data['description'])
return redirect('orders:thanks.html')
context = {'publishable_key': publishable_key}
return render(request, 'orders/checkout.html', context)







*#template checkout,html*{% extends "base.html" %}

 {% block jQuery %}
 https://js.stripe.com/v2/";>


Stripe.setPublishableKey('{{ publishable_key }}');

$(function() {
  var $form = $('#payment-form');
  $form.submit(function(event) {
// Disable the submit button to prevent repeated clicks:
$form.find('.submit').prop('disabled', true);

// Request a token from Stripe:
Stripe.card.createToken($form, stripeResponseHandler);

// Prevent the form from being submitted:
return false;
  });
});

function stripeResponseHandler(status, response) {
  // Grab the form:
  var $form = $('#payment-form');

  if (response.error) { // Problem!

// Show the errors on the form:
$form.find('.payment-errors').text(response.error.message);
$form.find('.submit').prop('disabled', false); // Re-enable submission

  } else { // Token was created!

// Get the token ID:
var token = response.id;

// Insert the token ID into the form so it gets submitted to the server:
$form.append($('').val(token));

// Submit the form:
$form.get(0).submit();
  }
};


{% endblock %}


 {% block content %}
 Credit Card Payment
 


{% csrf_token %}



  Card
  
  
  


Expiration (MM/)










CVC












{% endblock %}



Request req_8eOcfP3bw2bzDd: Must provide source or customer.


MultiValueDictKeyError at /orders/checkout/

"'stripeToken'"

-- 
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/8596d735-c697-4734-a2a3-a6bbec0ee2e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why in Django the field IntegerRangeField not worked with None?

2016-06-16 Thread Sergiy Khohlov
Look like it is expected behaviour.
filter builds sql, any sql should have sence. What is sence with broken sql
?

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Wed, Jun 15, 2016 at 1:09 PM, Seti Volkylany 
wrote:

> The model next:
>
> class Writter(models.Model):
> """
> Model for writters of books
> """
>
> id = models.UUIDField(primary_key=True, editable=False, default=uuid.
> uuid4)
> name = models.CharField(
> _('Name'),
> max_length=200,
> validators=[MinLengthValidator(settings.
> MIN_LENGTH_FOR_NAME_OR_TITLE_OBJECT)],
> unique=True,
> error_messages={'unique': _('The such writter already is here.')}
> )
> slug = ConfiguredAutoSlugField(_('Slug'), populate_from='name', unique
> =True)
> #
> # basic trends of books
> #
> about = models.TextField(
> _('About writter'),
> validators=[MinLengthValidator(100)],
> help_text=_('Give brief character of the writter and his books.')
> )
> years_life = IntegerRangeField(
> _('years life'),
> null=True,
> blank=True,
> help_text='Enter year birth and year death, if have.'
> )
>
>
>
> I am tried next:
>
>  Writter.objects.filter(years_life__endswith=None)
>
> but found error:
>
> allow_joins)
> 998 if value is None:
> 999 if lookups[-1] not in ('exact', 'iexact'):
> -> 1000 raise ValueError("Cannot use None as a query
> value")
>1001 lookups[-1] = 'isnull'
>1002 value = True
>
> ValueError: Cannot use None as a query 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/72566fb6-79ba-416c-9e3f-7b07a7df6e3f%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJP9y65d712bs-yNECGtcB6L1e49cy8MS6Yb75ZeF%3DtKew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: LoginRequiredMixin ignored

2016-06-16 Thread Sergiy Khohlov
please send  your http header. Look like auth header is present by  browser
default


Вірусів
немає. www.avast.com

<#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Thu, Jun 16, 2016 at 8:29 PM, Lee Hinde  wrote:

> I always assume it's me. That was some errant copy and paste.
>
> Thanks!
>
> On Wed, Jun 15, 2016 at 11:51 PM, Babatunde Akinyanmi <
> tundeba...@gmail.com> wrote:
>
>> Actually it's you. Please see inline:
>>
>> On Jun 15, 2016 11:56 PM, "Lee Hinde"  wrote:
>> >
>> > Using Django 1.9.7.
>> >
>> > I have the following class:
>> >
>> > class AddView(LoginRequiredMixin, CreateView):
>> > template_name = "entry.html"
>> > model = Property
>> > form_class = AddPropertyForm
>> > success_url = "/buy/"
>> > login_url = '/account/login/'
>> >
>>
>> Consider your code for `dispatch`
>> > def dispatch(self, request, *args, **kwargs):
>> > print request.user
>> > print request.user.is_authenticated()
>> > return super(AddView, self).post(request, *args, **kwargs)
>> >
>> You have bypassed `LoginRequiredMixin` implementation of `dispatch` and
>> there's where the login logic is done. You should be returning a super call
>> to `dispatch` not `post`. If you are actually trying to force all requests
>> into POSTs (which I doubt), you are better off doing it in the `get`
>> method.
>>
>> > def form_valid(self, form):
>> > ls_property = form.save(commit=False)
>> > ls_property.user = get_user(self.request)
>> > ls_property.latitude = form.cleaned_data['latitude']
>> > ls_property.longitude = form.cleaned_data['longitude']
>> > submit =  form.cleaned_data['submit']
>> > ls_property.visible = (submit != 'draft')
>> > ls_property.save()
>> > return super(AddView, self).form_valid(form)
>> >
>> >
>> > The LoginRequiredMixin is ignored, i.e, I can get to the page without
>> being logged in.
>> >
>> > request.user reports: AnonymousUser
>> > request.user.is_authenticated() reports: False
>> >
>> > If I wrap the url:
>> >
>> > url(r'^sell', user_passes_test(user_is_active)(AddView.as_view()),
>> name="add"),
>> >
>> > the page is protected, so I have a work around.
>> >
>> > This seems basic and I don't find other reports of LoginRequiredMixin
>> not working, so I assume it's me.
>> >
>> > What am I missing?
>> >
>>
> --
> 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%2BePoMwMHRW6cEbzPypBhTnGCRJ7W0nGE%2BvaQ_ytmA_D2WhiSg%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJMCA8NRG9hVtg%3DMDXiwCLrcwfeuw3tUXFqbenrxqwqdTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Absolute beginner step by step

2016-06-16 Thread Gary Roach
I missed the use of Django 1.5.4,  but Django is supposed to be 
completely backward compatible. So using 1.9 shouldn't cause any 
problems. The switch from python 2.7 to 3.5, on the other hand, can be a 
mess.


Gary R.

On 06/15/2016 05:24 PM, M. Kholid wrote:
I tried to downloan the tutorial from the given 
link /media.readthedocs.org/pdf/tango-with-django/latest/tango-with-django.pdf 
 



It stil using django version 1.5.4

On Wed, Jun 15, 2016 at 10:44 PM, Shaylee Hansen 
> wrote:


Thanks for the update on the new Tango With Django.   Everyone
highly recommends this tutorial so I'm excited to see its recently
been updated :)

On Monday, June 13, 2016 at 12:51:07 PM UTC-6, gary719_list1 wrote:

I stand corrected. There is a new Tango With Django tutorial
out. It uses Python 3.5 and Django 1.9. Try

/media.readthedocs.org/pdf/tango-with-django/latest/tango-with-django.pdf



Gary R

On 06/11/2016 02:07 PM, Gary Roach wrote:

If you don't mind working with Python2.7 and Django 1.7 you
might try "Tango With Django" . It is out of date but still
is a good place to start. Too bad that the author hasn't
updated it. I have had some success with running three
projects in parallel. Tango along with the official Django
howto and another with your own project if you have one. I
saw a reference to "Learning Python The Hard Way". It's a
good choice.

One nasty thing you may run into if you run parallel programs
is the use of multiple version of Python and Django. If you
use virtualenv and pyvenv to set up multiple virtual
environments and then point your IDE at the one needed for a
particular project, you should be ok. You don't even have to
activate the environments because you are using them for
storage of python and django versions only.

Good luck

Gary R.


On 06/10/2016 07:32 PM, Mc. Holid wrote:

Dear All,

Could anyone help  to share the point for absolute beginner
guide.

I have already know a little bit about html, and having
strong background in vb6.

Thanks for any kind help.

Best Regards
Mchoud
-- 
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...@googlegroups.com.
To post to this group, send email to django...@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/d2fa7fd5-2673-4292-a14e-482e148587bb%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...@googlegroups.com.
To post to this group, send email to django...@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/575C7D80.7060206%40verizon.net.
For more options, visit https://groups.google.com/d/optout.




NOTICE: This email and attached file(s) contain Gcommerce
Solutions, LLC confidential information intended for the exclusive
use of the individual(s) to whom addressed. If you are not the
intended recipient, please immediately delete this Email (and
attached files) and treat the information as confidential.

-- 
You received this message because you are subscribed to a topic in

the Google Groups "Django users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/django-users/cryoIzZ7p-o/unsubscribe.
To unsubscribe from this group and all its topics, 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/b4c64c46-02a6-4237-bbff-b4b3fbd0d6e8%40googlegroups.com


Re: LoginRequiredMixin ignored

2016-06-16 Thread Lee Hinde
I always assume it's me. That was some errant copy and paste.

Thanks!

On Wed, Jun 15, 2016 at 11:51 PM, Babatunde Akinyanmi 
wrote:

> Actually it's you. Please see inline:
>
> On Jun 15, 2016 11:56 PM, "Lee Hinde"  wrote:
> >
> > Using Django 1.9.7.
> >
> > I have the following class:
> >
> > class AddView(LoginRequiredMixin, CreateView):
> > template_name = "entry.html"
> > model = Property
> > form_class = AddPropertyForm
> > success_url = "/buy/"
> > login_url = '/account/login/'
> >
>
> Consider your code for `dispatch`
> > def dispatch(self, request, *args, **kwargs):
> > print request.user
> > print request.user.is_authenticated()
> > return super(AddView, self).post(request, *args, **kwargs)
> >
> You have bypassed `LoginRequiredMixin` implementation of `dispatch` and
> there's where the login logic is done. You should be returning a super call
> to `dispatch` not `post`. If you are actually trying to force all requests
> into POSTs (which I doubt), you are better off doing it in the `get`
> method.
>
> > def form_valid(self, form):
> > ls_property = form.save(commit=False)
> > ls_property.user = get_user(self.request)
> > ls_property.latitude = form.cleaned_data['latitude']
> > ls_property.longitude = form.cleaned_data['longitude']
> > submit =  form.cleaned_data['submit']
> > ls_property.visible = (submit != 'draft')
> > ls_property.save()
> > return super(AddView, self).form_valid(form)
> >
> >
> > The LoginRequiredMixin is ignored, i.e, I can get to the page without
> being logged in.
> >
> > request.user reports: AnonymousUser
> > request.user.is_authenticated() reports: False
> >
> > If I wrap the url:
> >
> > url(r'^sell', user_passes_test(user_is_active)(AddView.as_view()),
> name="add"),
> >
> > the page is protected, so I have a work around.
> >
> > This seems basic and I don't find other reports of LoginRequiredMixin
> not working, so I assume it's me.
> >
> > What am I missing?
> >
>

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


Re: Making queries with custom SQL

2016-06-16 Thread Javier Guerra Giraldez
On 16 June 2016 at 16:21, TheBeardedTemplar  wrote:
> I'm using postgreSQL and have found that recursive queries are exactly what
> I need


In most cases it's much better to use a more efficient form of tree.
A common one is called MPTT, for which there are Django packages.

-- 
Javier

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


Making queries with custom SQL

2016-06-16 Thread TheBeardedTemplar
Hey everyone,

The bulk of my database consists of a tree of models (called Node), more 
than 200,000 of them, and I very regularly need to make large queries to 
get subtrees which I'm finding is causing a significant slowdown. I'm using 
postgreSQL and have found that recursive queries 
 are exactly 
what I need, but I'd like to use them nicely from within Django. Is there 
an accepted way to do this, or something I could override? Basically I'd 
like to have something similar to `Node.filter()` like 
`Node.getSubtree(root=)` which executes the following:

WITH RECURSIVE nodes(id, label, parent_id) AS (
 SELECT tn.id, tn.label, tn.parent_id FROM assets_asset AS tn WHERE tn.id = 

  UNION ALL
SELECT p.id, p.label, p.parent_id 
 FROM nodes as c, assets_asset AS p 
 WHERE c.parent_id = p.id
)
SELECT * FROM nodes AS n ORDER BY n.id ASC;


I'd appreciate any advice on how to go about this. I'm not afraid to dive 
into the source, I'm just not sure where to look.

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/aee479c2-c052-48b7-96b3-71d1c7029312%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Breaking internal app out into reusable app, migration question

2016-06-16 Thread Doug Donaldson
Further, my reading of the source seems to indicate that the migrations are 
loaded all at once for all INSTALLED_APPS as part of the MigrationLoader 
init and the decision about whether or not to run them made at this time as 
well in the migration_plan which leads me to believe that the change in the 
django_migrations table I made earlier in the sequence of migrations won't 
affect the decision to run the  migrations as that decision has 
already been made earlier in plan creation.

On Thursday, June 16, 2016 at 4:06:39 AM UTC-7, Doug Donaldson wrote:
>
> I have a website with a number of smaller internal apps. I want to break 
> some of them out into reusable apps and I'm starting with a simple one. It 
> has a single model and a single initial migration representing it. Very 
> simple, no foreign keys etc.
>
> I did this: http://stackoverflow.com/a/8408131 and, as part of that, 
> updated django_migrations table to change old app label to new app label. I 
> did all these steps in a single RunSQL data migration in my core app which 
> is listed first in my APPS settings list:
>
> operations = [
> migrations.RunSQL(
> [("UPDATE django_content_type SET app_label=%s WHERE 
> app_label=%s", [NEW_APP, OLD_APP])],
> [("UPDATE django_content_type SET app_label=%s WHERE 
> app_label=%s", [OLD_APP, NEW_APP])],
> ),
> migrations.RunSQL(
> "ALTER TABLE " + OLD_APP + "_contact RENAME TO " + NEW_APP + 
> "_contact",
> "ALTER TABLE " + NEW_APP + "_contact RENAME TO " + OLD_APP + 
> "_contact"
> ),
> migrations.RunSQL(
> [("UPDATE django_migrations SET app=%s WHERE app=%s", 
> [NEW_APP, OLD_APP])],
> [("UPDATE django_migrations SET app=%s WHERE app=%s", 
> [OLD_APP, NEW_APP])],
> )
> ]
>
> The console output seems to suggest the core migration is indeed running 
> before the  migration tries.
>
> Even though the django_migrations table seems to be updating the app_label 
> properly (step 3) the 0001_initial migration in the newly renamed app still 
> tries to run. It fails since it's just a create and the table it wants to 
> create already exists since the earlier table rename (step 2) made it so.
>
> I guess my general question is on the isolation level of the RunSQL 
> migrations. Should I expect the migration for  to see it doesn't 
> need to run because django_migrations was updated one step earlier which 
> should now say  has already run 0001_initial?
>
> Doug
>

-- 
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/450007ee-7a98-4cfd-bb74-f57e54ddaed2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Breaking out internal app into reusable app, migration question

2016-06-16 Thread Doug Donaldson
 

I have a website with a number of smaller internal apps. I want to break 
some of them out into reusable apps and I'm starting with a simple one. It 
has a single model and a single initial migration representing it. Very 
simple, no foreign keys etc.


I did this: http://stackoverflow.com/a/8408131 and, as part of that, 
updated django_migrations table to change old app label to new app label. I 
did all these steps in a single RunSQL data migration in my core app which 
is listed first in my APPS settings list:


operations = [

migrations.RunSQL(

[("UPDATE django_content_type SET app_label=%s WHERE 
app_label=%s", [NEW_APP, OLD_APP])],

[("UPDATE django_content_type SET app_label=%s WHERE 
app_label=%s", [OLD_APP, NEW_APP])],

),

migrations.RunSQL(

"ALTER TABLE " + OLD_APP + "_contact RENAME TO " + NEW_APP + 
"_contact",

"ALTER TABLE " + NEW_APP + "_contact RENAME TO " + OLD_APP + 
"_contact"

),

migrations.RunSQL(

[("UPDATE django_migrations SET app=%s WHERE app=%s", [NEW_APP, 
OLD_APP])],

[("UPDATE django_migrations SET app=%s WHERE app=%s", [OLD_APP, 
NEW_APP])],

)

]


The console output seems to suggest the core migration is indeed running 
before the  migration tries.


Even though the django_migrations table seems to be updating the app_label 
properly (step 3) the 0001_initial migration in the newly renamed app still 
tries to run. It fails since it's just a create and the table it wants to 
create already exists since the earlier table rename (step 2) made it so.


I guess my general question is on the isolation level of the RunSQL 
migrations. Should I expect the migration for  to see it doesn't 
need to run because django_migrations was updated one step earlier which 
should now say  has already run 0001_initial?


Doug

-- 
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/b89ebfb6-0554-43ff-9232-1e38bf09b76f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Absolute beginner step by step

2016-06-16 Thread Marlysson Silva
It's missing to map the url to "/" in file "untitled.urls" . I think , too 
I am beginner

Em quinta-feira, 16 de junho de 2016 08:06:25 UTC-3, Tushar Shukla escreveu:
>
> iam doing this tutorial and i cant get the final result no matter what i 
> do 
>
> iam using pycharm. please help i have attached the error page
>
> On Saturday, 11 June 2016 23:57:33 UTC+5:30, Derek wrote:
>>
>> The Django tutorial - 
>> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>>
>> But if you have no Python experience at all, then 
>> http://learnpythonthehardway.org/book/ (otherwise you'l get lost quickly)
>>
>> And for both sets of learning, bear in mind the key advice from Zed Shaw:
>>
>> *"You must type each of these exercises in, manually. If you copy and 
>> paste, you might as well not even do them."*
>>
>> On Saturday, 11 June 2016 14:36:31 UTC+2, Mc. Holid wrote:
>>>
>>> Dear All,
>>>
>>> Could anyone help  to share the point for absolute beginner guide.
>>>
>>> I have already know a little bit about html, and having strong 
>>> background in vb6.
>>>
>>> Thanks for any kind help.
>>>
>>> Best Regards
>>> Mchoud
>>>
>>

-- 
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/e3662bb1-12d3-4289-991d-9adc66a2b8c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Absolute beginner step by step

2016-06-16 Thread ludovic coues
that's the expected result at this point.

2016-06-16 7:43 GMT+02:00 Tushar Shukla :
> iam doing this tutorial and i cant get the final result no matter what i do
>
> iam using pycharm. please help i have attached the error page
>
> On Saturday, 11 June 2016 23:57:33 UTC+5:30, Derek wrote:
>>
>> The Django tutorial -
>> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>>
>> But if you have no Python experience at all, then
>> http://learnpythonthehardway.org/book/ (otherwise you'l get lost quickly)
>>
>> And for both sets of learning, bear in mind the key advice from Zed Shaw:
>>
>> "You must type each of these exercises in, manually. If you copy and
>> paste, you might as well not even do them."
>>
>> On Saturday, 11 June 2016 14:36:31 UTC+2, Mc. Holid wrote:
>>>
>>> Dear All,
>>>
>>> Could anyone help  to share the point for absolute beginner guide.
>>>
>>> I have already know a little bit about html, and having strong background
>>> in vb6.
>>>
>>> Thanks for any kind help.
>>>
>>> Best Regards
>>> Mchoud
>
> --
> 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/7b0edf8e-1fc9-4394-b3b8-70b674f47ee9%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTbWNXFxO%2Bif4fcg4Z13Nn3XRE56g3yXfxE5w%3DA42Pjzbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django TCP Socket Communication

2016-06-16 Thread Sergiy Khohlov
Have ready  this kind of application  using  django + postgis. At this
moment protocols Cabon and teltronika are supported. Are you interested ?

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Thu, Jun 16, 2016 at 2:37 PM, Jani Tiainen  wrote:

> Oops, apparently you hijacked over year old thread...
>
> On 16.06.2016 13:45, Anil reddy reddy M wrote:
>
> Hi,
>
>  I made a TCP Server Socket  programming in python, it's nicely
> communicating with micro controller, and also i can store latitude
> ,longitude values in MySqldb from GPS output. Now I want develop a web
> application for vechile  tracking. How can i do this stuff in django.  I
> would be thankful   for all  the help i can get!
>
>
>
> Just make models to match tables and then use Django as you wish. There
> isn't nothing magical there.
>
> For starting point you can use inspectdb to create initial models from
> your database which you then can refine to suit your needs.
>
>
>
>
> On Saturday, March 28, 2015 at 7:21:24 PM UTC+5:30, Gergely Polonkai
> wrote:
>>
>> Hello,
>>
>> it's a bit hard to understand what you exactly want to achieve. How can
>> you communicate with the microcontroller? Do you connect to one of its TCP
>> ports, and send it data, I assume. Is it done with a well-known protocol,
>> like HTTP, or some custom one?
>>
>> You say that it opens a port every 5 seconds to a server. Where is that
>> server? Is it on the same machine as you Django based application? How does
>> the microcontroller and the server communicate with each other?
>>
>> There are so many architectural questions here before you get to a web
>> application, and I'm afraid you original question cannot be answered before
>> we see the whole picture.
>>
>> Best,
>> Gergely
>> On 28 Mar 2015 11:06, "bobdxcool"  wrote:
>>
>>> But is that compatible with django ?
>>>
>>> On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via Python] 
>>> <[hidden
>>> email] > wrote:
>>>
 Have you looked at the ‘socket’ python library ?

 François

 > On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email]
 > wrote:
 >
 > I am new to TCP socket programming. I have a django based server
 > communicating with a microcontroller. Now, I want to implement TCP
 based
 > socket on the server side in order to communicate with the TCP socket
 on the
 > microcontroller. Can anyone give me an idea on how to do this ? What
 > libraries should I use on my django server The microprocessor
 basically
 > opens the socket every 5 seconds and sends a notification to the
 server. I
 > on the server side should be able to read this and pump data back to
 the
 > microprocessor using this socket which was opened by the
 microprocessor.
 >
 >
 >
 > --
 > View this message in context:
 
 http://python.6.x6.nabble.com/
 Django-TCP-Socket-Communication-tp5090792.html
 > Sent from the django-users mailing list archive at Nabble.com.
 >
 > --
 > 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 [hidden email]
 .
 > To post to this group, send email to [hidden email]
 .
 > 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/1427483125637-5090792.post%40n6.nabble.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 [hidden email]
 .
 To post to this group, send email to [hidden email]
 .
 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/DAE16363-2EEE-4E0F-A230-A31BB270E2F9%40gmail.com.
 For more options, visit 
 https://groups.google.com/d/optout.


 --
 If you reply to this email, your message will be added to the
 discussion below:

 

Re: Django TCP Socket Communication

2016-06-16 Thread Jani Tiainen

Oops, apparently you hijacked over year old thread...

On 16.06.2016 13:45, Anil reddy reddy M wrote:

Hi,

 I made a TCP Server Socket  programming in python, it's nicely 
communicating with micro controller, and also i can store latitude 
,longitude values in MySqldb from GPS output. Now I want develop a web 
application for vechile  tracking. How can i do this stuff in django. 
 I would be thankful   for all  the help i can get!





Just make models to match tables and then use Django as you wish. There 
isn't nothing magical there.


For starting point you can use inspectdb to create initial models from 
your database which you then can refine to suit your needs.





On Saturday, March 28, 2015 at 7:21:24 PM UTC+5:30, Gergely Polonkai 
wrote:


Hello,

it's a bit hard to understand what you exactly want to achieve.
How can you communicate with the microcontroller? Do you connect
to one of its TCP ports, and send it data, I assume. Is it done
with a well-known protocol, like HTTP, or some custom one?

You say that it opens a port every 5 seconds to a server. Where is
that server? Is it on the same machine as you Django based
application? How does the microcontroller and the server
communicate with each other?

There are so many architectural questions here before you get to a
web application, and I'm afraid you original question cannot be
answered before we see the whole picture.

Best,
Gergely

On 28 Mar 2015 11:06, "bobdxcool"  wrote:

But is that compatible with django ?

On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via
Python] <[hidden email]
> wrote:

Have you looked at the ‘socket’ python library ?

François

> On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email]
>
wrote:
>
> I am new to TCP socket programming. I have a django
based server
> communicating with a microcontroller. Now, I want to
implement TCP based
> socket on the server side in order to communicate with
the TCP socket on the
> microcontroller. Can anyone give me an idea on how to do
this ? What
> libraries should I use on my django server The
microprocessor basically
> opens the socket every 5 seconds and sends a
notification to the server. I
> on the server side should be able to read this and pump
data back to the
> microprocessor using this socket which was opened by the
microprocessor.
>
>
>
> --
> View this message in context:

http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792.html


> Sent from the django-users mailing list archive at
Nabble.com.
>
> --
> 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 [hidden email]
.
> To post to this group, send email to [hidden email]
.
> 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/1427483125637-5090792.post%40n6.nabble.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 [hidden email]
.
To post to this group, send email to [hidden email]
.
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/DAE16363-2EEE-4E0F-A230-A31BB270E2F9%40gmail.com


Re: Django TCP Socket Communication

2016-06-16 Thread Jani Tiainen

Hi,

So if I understood correctly you want to use microcontroller to connect 
Django web-app periodically.


One "easy" option would be using HTTP protocol to talk to Django and 
then use simple RESTful calls to push your data.


Of course that all depends what kind of libraries your microcontroller 
does have for communication.


If you do not have HTTP protocol luxury but something more primitive, 
you need to build some kind of middleware server that can understand 
incoming data from your microcontroller and then push it to Django server.


But there is no easy way to push arbitrary data through TCP socket to 
Django server directly - Django is mainly build around HTTP request - 
response cycle.


On 28.03.2015 16:11, bobdxcool wrote:


it's a bit hard to understand what you exactly want to achieve. How 
can you communicate with the microcontroller? Do you connect to one of 
its TCP ports, and send it data, I assume. Is it done with a 
well-known protocol, like HTTP, or some custom one?



*Yes, one of the TCP port on the micro-controller is connected to and 
data is sent via this to the server.*


You say that it opens a port every 5 seconds to a server. Where is 
that server? Is it on the same machine as you Django based 
application? How does the microcontroller and the server communicate 
with each other?


The server is django based one. I still need to implement the 
communication part on the server side. Need suggestion on how to do 
this using TCP sockets.





On Sat, Mar 28, 2015 at 7:20 PM, Gergely Polonkai [via Python] 
<[hidden email] > wrote:


Hello,

it's a bit hard to understand what you exactly want to achieve.
How can you communicate with the microcontroller? Do you connect
to one of its TCP ports, and send it data, I assume. Is it done
with a well-known protocol, like HTTP, or some custom one?

You say that it opens a port every 5 seconds to a server. Where is
that server? Is it on the same machine as you Django based
application? How does the microcontroller and the server
communicate with each other?

There are so many architectural questions here before you get to a
web application, and I'm afraid you original question cannot be
answered before we see the whole picture.

Best,
Gergely

On 28 Mar 2015 11:06, "bobdxcool" <[hidden email]
> wrote:

But is that compatible with django ?

On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via
Python] <[hidden email]
> wrote:

Have you looked at the ‘socket’ python library ?

François

> On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email]
>
wrote:
>
> I am new to TCP socket programming. I have a django
based server
> communicating with a microcontroller. Now, I want to
implement TCP based
> socket on the server side in order to communicate with
the TCP socket on the
> microcontroller. Can anyone give me an idea on how to do
this ? What
> libraries should I use on my django server The
microprocessor basically
> opens the socket every 5 seconds and sends a
notification to the server. I
> on the server side should be able to read this and pump
data back to the
> microprocessor using this socket which was opened by the
microprocessor.
>
>
>
> --
> View this message in context:

http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792.html
> Sent from the django-users mailing list archive at
Nabble.com.
>
> --
> 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 [hidden email]
.
> To post to this group, send email to [hidden email]
.
> 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/1427483125637-5090792.post%40n6.nabble.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 [hidden 

Re: Dynamic code analyzer for Django

2016-06-16 Thread Avraham Serour
you can run the code with coverage
usually tests are run with coverage, not sure how this will impact on
performance,

other than that you can just check your logs and see what requests are
being made and which aren't

On Wed, Jun 15, 2016 at 11:41 PM, Raúl Quesada Pegalajar 
wrote:

> Hello!!
>
> We have a big Django application in production since a few years. We want
> to refactor it, but before that, we want to study the real status about our
> code. We want to do static and dynamics analisys to discover: Errors,
> duplicities, dead code, unused features...
>
> We have found some tools for static analysis, but we can not find a good
> tool for a dynamic analsys. We want to discover what pieces of our
> application are not being used by our clients and remove it.
>
> Do you know any tool to do this kind of analysis?
>
> Thanks in advance,
>
> --
> 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/4dcd6f0c-39f9-4608-9aa9-3450cb1c47ef%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6t%2B-U2EWp%3DsW7c3vhbNCt7CqTZw2f83jT_1_Ce6qSL86zA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to use view function in another function of view in django

2016-06-16 Thread 'Abraham Varricatt' via Django users
I'm going to go out and make a random guess that when you say "use a view 
inside another view" with respect to the code you posted, you want all 
calls to index() or list() to render the base view. In that case just use 
return. i.e.

def index(request):
  return base(request)

Yours,
Abraham V.




On Wednesday, June 15, 2016 at 11:24:18 PM UTC+5:30, hossein wrote:
>
> def base(request):
> j=Job.objects.all()
> a=Ab.objects.all()
> return render(request,'base.html',{'j':j, 'a':a})
>
> def index(request):
> base(request)
> x=X.objects.all()
> return render(request, 'index.html',{'x':x})
>
> def list(request):
> base(request)
> z=Z.objects.all()
> return render(request, 'list.html',{'z':z})
>
>

-- 
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/8330c99d-59ba-45da-b500-b2c40ed95daa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Create admin/superuser for each tenant/schema, while using Django-Tenant-Schema

2016-06-16 Thread Sayantan Ganguly
I am using Django-Tenant-Schemas for my multi tenant app.

Now, I have come to face a huge problem.

I need to use @login-required for views. But how to have an admin (the 
creator & owner of the schema) to only create/register user. If a "register 
yourself" page is available to all, then anyone can register.

If I can have an admin for each tenant, then I can easily use 
@required-permission decorator for the "register" view.

Hence, my question is how to create admin/super user for each tenant.


I cannot create the admin from the "create database"/"register your firm" 
(which is getting dynamically created from the register page, linked to the 
landing page) view as it is in the public schema.

-- 
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/962cf79a-f1ad-4709-8f07-5888429450a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Absolute beginner step by step

2016-06-16 Thread Tushar Shukla
iam doing this tutorial and i cant get the final result no matter what i do 

iam using pycharm. please help i have attached the error page

On Saturday, 11 June 2016 23:57:33 UTC+5:30, Derek wrote:
>
> The Django tutorial - 
> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>
> But if you have no Python experience at all, then 
> http://learnpythonthehardway.org/book/ (otherwise you'l get lost quickly)
>
> And for both sets of learning, bear in mind the key advice from Zed Shaw:
>
> *"You must type each of these exercises in, manually. If you copy and 
> paste, you might as well not even do them."*
>
> On Saturday, 11 June 2016 14:36:31 UTC+2, Mc. Holid wrote:
>>
>> Dear All,
>>
>> Could anyone help  to share the point for absolute beginner guide.
>>
>> I have already know a little bit about html, and having strong background 
>> in vb6.
>>
>> Thanks for any kind help.
>>
>> Best Regards
>> Mchoud
>>
>

-- 
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/7b0edf8e-1fc9-4394-b3b8-70b674f47ee9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Breaking internal app out into reusable app, migration question

2016-06-16 Thread Doug Donaldson
I have a website with a number of smaller internal apps. I want to break 
some of them out into reusable apps and I'm starting with a simple one. It 
has a single model and a single initial migration representing it. Very 
simple, no foreign keys etc.

I did this: http://stackoverflow.com/a/8408131 and, as part of that, 
updated django_migrations table to change old app label to new app label. I 
did all these steps in a single RunSQL data migration in my core app which 
is listed first in my APPS settings list:

operations = [
migrations.RunSQL(
[("UPDATE django_content_type SET app_label=%s WHERE 
app_label=%s", [NEW_APP, OLD_APP])],
[("UPDATE django_content_type SET app_label=%s WHERE 
app_label=%s", [OLD_APP, NEW_APP])],
),
migrations.RunSQL(
"ALTER TABLE " + OLD_APP + "_contact RENAME TO " + NEW_APP + 
"_contact",
"ALTER TABLE " + NEW_APP + "_contact RENAME TO " + OLD_APP + 
"_contact"
),
migrations.RunSQL(
[("UPDATE django_migrations SET app=%s WHERE app=%s", [NEW_APP, 
OLD_APP])],
[("UPDATE django_migrations SET app=%s WHERE app=%s", [OLD_APP, 
NEW_APP])],
)
]

The console output seems to suggest the core migration is indeed running 
before the  migration tries.

Even though the django_migrations table seems to be updating the app_label 
properly (step 3) the 0001_initial migration in the newly renamed app still 
tries to run. It fails since it's just a create and the table it wants to 
create already exists since the earlier table rename (step 2) made it so.

I guess my general question is on the isolation level of the RunSQL 
migrations. Should I expect the migration for  to see it doesn't 
need to run because django_migrations was updated one step earlier which 
should now say  has already run 0001_initial?

Doug

-- 
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/d71d3881-b10d-45a5-9568-54dc59052f19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django TCP Socket Communication

2016-06-16 Thread Anil reddy reddy M
Hi,

 I made a TCP Server Socket  programming in python, it's nicely 
communicating with micro controller, and also i can store latitude 
,longitude values in MySqldb from GPS output. Now I want develop a web 
application for vechile  tracking. How can i do this stuff in django.  I 
would be thankful   for all  the help i can get! 




On Saturday, March 28, 2015 at 7:21:24 PM UTC+5:30, Gergely Polonkai wrote:
>
> Hello,
>
> it's a bit hard to understand what you exactly want to achieve. How can 
> you communicate with the microcontroller? Do you connect to one of its TCP 
> ports, and send it data, I assume. Is it done with a well-known protocol, 
> like HTTP, or some custom one?
>
> You say that it opens a port every 5 seconds to a server. Where is that 
> server? Is it on the same machine as you Django based application? How does 
> the microcontroller and the server communicate with each other?
>
> There are so many architectural questions here before you get to a web 
> application, and I'm afraid you original question cannot be answered before 
> we see the whole picture.
>
> Best,
> Gergely
> On 28 Mar 2015 11:06, "bobdxcool"  wrote:
>
>> But is that compatible with django ?
>>
>> On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via Python] 
>> <[hidden 
>> email] > wrote:
>>
>>> Have you looked at the ‘socket’ python library ? 
>>>
>>> François 
>>>
>>> > On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email] 
>>> > wrote: 
>>> > 
>>> > I am new to TCP socket programming. I have a django based server 
>>> > communicating with a microcontroller. Now, I want to implement TCP 
>>> based 
>>> > socket on the server side in order to communicate with the TCP socket 
>>> on the 
>>> > microcontroller. Can anyone give me an idea on how to do this ? What 
>>> > libraries should I use on my django server The microprocessor 
>>> basically 
>>> > opens the socket every 5 seconds and sends a notification to the 
>>> server. I 
>>> > on the server side should be able to read this and pump data back to 
>>> the 
>>> > microprocessor using this socket which was opened by the 
>>> microprocessor. 
>>> > 
>>> > 
>>> > 
>>> > -- 
>>> > View this message in context: 
>>> http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792.html
>>> > Sent from the django-users mailing list archive at Nabble.com. 
>>> > 
>>> > -- 
>>> > 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 [hidden email] 
>>> . 
>>> > To post to this group, send email to [hidden email] 
>>> . 
>>> > 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/1427483125637-5090792.post%40n6.nabble.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 [hidden email] 
>>> . 
>>> To post to this group, send email to [hidden email] 
>>> . 
>>> 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/DAE16363-2EEE-4E0F-A230-A31BB270E2F9%40gmail.com.
>>>  
>>>
>>> For more options, visit https://groups.google.com/d/optout. 
>>>
>>>
>>> --
>>> If you reply to this email, your message will be added to the discussion 
>>> below:
>>>
>>> http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792p5090799.html
>>>  
>>> To unsubscribe from Django TCP Socket Communication, click here.
>>> NAML 
>>> 
>>>  
>>>
>>
>>
>> --
>> View this message in context: Re: Django TCP Socket Communication 
>> 
>> Sent from the django-users mailing list archive 
>>  at Nabble.com.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and 

Re: How change returned value after annotation queryset of model?

2016-06-16 Thread Jani Tiainen

On option could be using choices on a field definition.

On 16.06.2016 12:51, Seti Volkylany wrote:
If I used annotation for get rating an object, I had new field 
'rating' (is number). How change values field rating through SQl for 
return:

if rating = 0 return '0'
if rating = 1 return '+1'
if rating = -1 return '-1'
--
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/16b9bdbc-a292-4162-9809-59a55d63ff34%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--

Jani Tiainen

--
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/576283C0.8070308%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


How change returned value after annotation queryset of model?

2016-06-16 Thread Seti Volkylany
If I used annotation for get rating an object, I had new field 'rating' (is 
number). How change values field rating through SQl for return:
if rating = 0 return '0'
if rating = 1 return '+1'
if rating = -1 return '-1'

-- 
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/16b9bdbc-a292-4162-9809-59a55d63ff34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to use view function in another function of view in django

2016-06-16 Thread ludovic coues
I don't understand what you are trying to do.
base(request) create a response for the browser using j and a to
render base.html.
If you want to have access to j and a in both index.html and
list.html, try this:

def base(request):
j = Job.objects.all()
a = Ab.objects.all()
return {'j':j, 'a':a}

def index(request):
context = base(request)
context['x'] = X.objects.all()
return render(request, 'index.html', context)


2016-06-16 2:22 GMT+02:00 hossein :
> More Explain Please
>
>
> On Thursday, June 16, 2016 at 3:13:38 AM UTC+4:30, Gergely Polonkai wrote:
>>
>> Just like this. Unless you have a specific use case you forgot to share in
>> your mail.
>>
>> Views are mere functions that get called with a request az a parameter.
>> You shouldn’t treat them as special/holy/uncallable.
>>
>> Best,
>> Gergely
>>
>> On Jun 15, 2016 19:56, "hossein"  wrote:
>>>
>>> def base(request):
>>> j=Job.objects.all()
>>> a=Ab.objects.all()
>>> return render(request,'base.html',{'j':j, 'a':a})
>>>
>>> def index(request):
>>> base(request)
>>> x=X.objects.all()
>>> return render(request, 'index.html',{'x':x})
>>>
>>> def list(request):
>>> base(request)
>>> z=Z.objects.all()
>>> return render(request, 'list.html',{'z':z})
>>>
>>> --
>>> 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/3cc2651c-35df-4eaf-bab6-b1ae936f73d4%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/72d16e93-10b7-4465-b116-68bf054a89d4%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTasQ6AxFrTvYjCcv5hz5S%2BEGx2Gy%3DmBu7C%3Db44mAk3T8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recommended courses/materials for Python/Django course...

2016-06-16 Thread ludovic coues
The "Python Crash Course" aim to teach python from nothing in the
first half and to put that knowledge in application in the second half
through 3 projects. These are a 2D game, some data visualization
technique from diverse source and a django application.

Some people have some difficulty with the official django tutorial.
https://tutorial.djangogirls.org/en/ offer a really nice alternative,
more accessible to beginner and more complete too, with a section on
handling form in django for exemple.

I have also head of tango with django but I can't comment on this one.

-- 
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/CAEuG%2BTZ9X_7hq1bLp8B_-YmrZoff-b-UEB7-rArxwOpJ-cjnRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: LoginRequiredMixin ignored

2016-06-16 Thread Babatunde Akinyanmi
Actually it's you. Please see inline:

On Jun 15, 2016 11:56 PM, "Lee Hinde"  wrote:
>
> Using Django 1.9.7.
>
> I have the following class:
>
> class AddView(LoginRequiredMixin, CreateView):
> template_name = "entry.html"
> model = Property
> form_class = AddPropertyForm
> success_url = "/buy/"
> login_url = '/account/login/'
>

Consider your code for `dispatch`
> def dispatch(self, request, *args, **kwargs):
> print request.user
> print request.user.is_authenticated()
> return super(AddView, self).post(request, *args, **kwargs)
>
You have bypassed `LoginRequiredMixin` implementation of `dispatch` and
there's where the login logic is done. You should be returning a super call
to `dispatch` not `post`. If you are actually trying to force all requests
into POSTs (which I doubt), you are better off doing it in the `get`
method.

> def form_valid(self, form):
> ls_property = form.save(commit=False)
> ls_property.user = get_user(self.request)
> ls_property.latitude = form.cleaned_data['latitude']
> ls_property.longitude = form.cleaned_data['longitude']
> submit =  form.cleaned_data['submit']
> ls_property.visible = (submit != 'draft')
> ls_property.save()
> return super(AddView, self).form_valid(form)
>
>
> The LoginRequiredMixin is ignored, i.e, I can get to the page without
being logged in.
>
> request.user reports: AnonymousUser
> request.user.is_authenticated() reports: False
>
> If I wrap the url:
>
> url(r'^sell', user_passes_test(user_is_active)(AddView.as_view()),
name="add"),
>
> the page is protected, so I have a work around.
>
> This seems basic and I don't find other reports of LoginRequiredMixin not
working, so I assume it's me.
>
> What am I missing?
>
>
>
>
> --
> 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%2BePoMzApQGdzZ9AW47CjF3yhT0Smnc1AZw%2BOQ8uTcH1G3%3Dasg%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BWjgXNti-vrtJdkTsTTf-D-c6B6MmGjYYGM8yLx7sFkDi7fvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.