Re: Django says a modification was made to Auth user when I didn't, and migration has a timestamp from the future. Help?

2018-06-21 Thread JJ Zolper
It's Jun 21 at 11:30 pm in my world fyi.

On Thursday, June 21, 2018 at 11:34:50 PM UTC-4, JJ Zolper wrote:
>
> Hey everyone,
>
> So I did inherit this from someone else but I cannot phanthom how a change 
> to the django auth user would be maintained by git between developers.
>
> For some reason when I run makemigrations it thinks the django auth user 
> email field needs to be altered via migration?
>
> I'm so lost and I've tried resetting every scenario I could think of to 
> resolve this. Does anyone have any brilliant ideas?
>
> You'll see the timestamp on this post and here's the migration it thinks 
> it needs to make:
>
> # -*- coding: utf-8 -*-
>
> # Generated by Django 1.10.3 on 2018-06-22 03:29
>
> from __future__ import unicode_literals
>
>
> from django.db import migrations, models
>
>
>
> class Migration(migrations.Migration):
>
>
> dependencies = [
>
> ('auth', '0008_alter_user_username_max_length'),
>
> ]
>
>
> operations = [
>
> migrations.AlterField(
>
> model_name='user',
>
> name='email',
>
> field=models.EmailField(blank=True, max_length=254, 
> unique=True, verbose_name='email address'),
>
> ),
>
> ]
>
>
>  Yet I'll remove all of Django in python site packages and it still comes 
> back as something to migrate after it's been wiped clean.
>
>
> Thanks for your help. I'm out of ideas.
>
>
> Best,
>
>
> JJ
>

-- 
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/14059aeb-5d0d-411b-b339-455073ade64b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django says a modification was made to Auth user when I didn't, and migration has a timestamp from the future. Help?

2018-06-21 Thread JJ Zolper
Hey everyone,

So I did inherit this from someone else but I cannot phanthom how a change 
to the django auth user would be maintained by git between developers.

For some reason when I run makemigrations it thinks the django auth user 
email field needs to be altered via migration?

I'm so lost and I've tried resetting every scenario I could think of to 
resolve this. Does anyone have any brilliant ideas?

You'll see the timestamp on this post and here's the migration it thinks it 
needs to make:

# -*- coding: utf-8 -*-

# Generated by Django 1.10.3 on 2018-06-22 03:29

from __future__ import unicode_literals


from django.db import migrations, models



class Migration(migrations.Migration):


dependencies = [

('auth', '0008_alter_user_username_max_length'),

]


operations = [

migrations.AlterField(

model_name='user',

name='email',

field=models.EmailField(blank=True, max_length=254, 
unique=True, verbose_name='email address'),

),

]


 Yet I'll remove all of Django in python site packages and it still comes 
back as something to migrate after it's been wiped clean.


Thanks for your help. I'm out of ideas.


Best,


JJ

-- 
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/17b4e9c6-5e94-43d9-8061-c41cbe8f6a67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Invalid URLs passing validation by URLValidator

2018-06-21 Thread Tim Bell
Hi,

I've come across some strings which I think aren't valid URLs that 
nevertheless pass validation by django.core.validators.URLValidator in 
Django 2.0.6 and 1.11.13. I know URL validation is very tricky, but these 
seemed to me that they should obviously fail.

http://#FOO#/b...@example.com

I believe that this is passing validation because "#FOO#/bar" is being 
treated as a username, with "example.com" as the hostname. However, 
"#FOO#/bar" shouldn't be valid as a username because the "#" and "/" 
characters aren't percent-encoded.

http://FOO/b...@example.com

Similarly, I think this passes validation not because "FOO" is being 
treated as a valid hostname, but because "FOO/bar" is considered a 
username, even though "/" isn't percent-encoded.

Should this be considered a bug? (Sure, it's pretty obscure, but this has 
actually come up in my particular use case.)

Thanks,

Tim Bell

-- 
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/1166dac3-8c2b-4191-8130-5d9c146e4390%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Channels 2.0, How can I configure the channels 2.0 to use with the default django's views

2018-06-21 Thread Franklin Sarmiento
Hi everyone!,

I'm new with the channels topic, I'm learing the version 2.0, I have a 
doubt, How can I configure the channels 2.0 to use with the default 
django's views

Thanks a lot

-- 
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/afd5ac18-7f8b-4973-a3d8-a5df2a382b5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Channels 2.0 close code and http response status

2018-06-21 Thread Kirill Tyushchakov
Hello everyone!
I'm new in Django Channels. I'm using Channels 2.0 and I have few questions 
about it.
I'm using JsonWebsocketConsumer class for my consumer and I wrote my 
definition of connect method like this: 

def connect(self):
user = self.scope.get('user')
if user.is_anonymous:
super(NotificationsConsumer, self).connect()
else:
self.close(code=4003)


On client side I'm using native JS Websocket. 
But when I try to connect to this socket as unauthorzied user I get 
code 1006 and HTTP response status code 403.

My questions is:
1) How can I send custom close code to client?
2) Can I send another HTTP response status code? In my case 401 

-- 
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/446d3be6-438b-4e59-ad4f-7841895f4fcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to run python script by clicking a HTML button?

2018-06-21 Thread Jani Tiainen
Hi,

Django doesn't exactly work that way.

Please do the official tutorial from Django docs to get grasp of basics how
things works and are tied together.

to 21. kesäk. 2018 klo 23.15 SUBHENDU PANDA 
kirjoitti:

> Below is my HTML code...
>
> 
> 
> 
>
> HTML Forms
>
> 
>   First name:
>   
>   
>   
>   
> 
>
> I want is : If you I the "Submit" button, the form-data will be sent to
> a page called "/myscript.py and will perform the operation".
>
> 
> 
>
>
>
>
>
>
> myscript.py:
>
> import os
>
> def  f1():
>print ("Below are the files present in your Directory { }"
> .format(os.listdir("C:\MyDir "))
>
> --
> 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/a4fd2aa4-b28a-465f-aaab-dc279c4647d3%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/CAHn91of8RnW3t3AyhZnDB_QRBMQYAMAOWmhGVS6YQ8W1M50tag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to run python script by clicking a HTML button?

2018-06-21 Thread SUBHENDU PANDA
Below is my HTML code...





HTML Forms


  First name:
  
  
  
  
 

I want is : If you I the "Submit" button, the form-data will be sent to 
a page called "/myscript.py and will perform the operation".









myscript.py:

import os

def  f1():
   print ("Below are the files present in your Directory { }" 
.format(os.listdir("C:\MyDir "))

-- 
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/a4fd2aa4-b28a-465f-aaab-dc279c4647d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


prevent AppConfig.ready() from running twice

2018-06-21 Thread clavierplayer
Hello, I am still new to Django, so I apologize if this seems like a silly 
question. I've not been able to find what I need on Google, StackOverflow, 
or the Django Docs. 

I am using Django 2.0.5.

I understand that the correct way to run startup code is to subclass 
AppConfig and override ready(). I also understand that Django launches two 
separate instances of the application--one to check the models, and the 
other to launch the server--on separate processes. The official 
recommendation to prevent startup code from being run more than once is to 
implement a flag--which can't work if there are multiple instances of the 
application being created. The docs also say that ready() will be re-called 
only rarely; but this doesn't help at all if all of the instances are 
calling ready() only once. 

I have found the manage.py runserver --noreload command, but this won't be 
enough to prevent multiple instances on a production server. What can I do 
to enforce one and only one instance of my application being run at a time? 

If it helps, here is the reason I need to override this multi-instantiation 
behavior: my application launches a multiprocessing.Process at startup to 
monitor and run background tasks. Having more than one background Process 
running at once is going to wreak havoc on the application. I've looked at 
other options to accomplish similar purposes, but those would all be 
instantiated multiple times, also. 

Any suggestions?

Thank you,
Heather

-- 
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/6d8729fe-18c4-4e53-8479-c2b9dd178b89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels 2.0 - How to init and persist/communicate with only one instance of background worker for every channel_layer.send?

2018-06-21 Thread Andrew Godwin
The worker server tries to keep one application instance open per incoming
channel name, but that's no guarantee. It will always make a new instance
for different channel names. What kind of behaviour are you expecting?

Andrew

On Tue, Jun 19, 2018 at 6:45 AM itsnate_b  wrote:

> I am using Django 2.0.5, Python 3.6.2, Django Channels 2.1.1, aiohttp
> 3.1.3.
>
> I have created a background worker class which is initialized on a route
> to the appropriate event/function. Problem is that it initializes a *new*
> instance of the class on every triggered call, meaning that I cannot access
> contextual variables (they don't persist). Is there a way to trigger the
> same (i.e. first) and only class repeatedly on each routed call? I can
> change it all to function calls with global variables stored for the
> relevant asyncio futures and/or booleans, but would really prefer not to do
> thatany suggestions?
>
> My (simplified) code:
>
> *consumers.py*
>
> from channels.generic.websocket import AsyncWebsocketConsumer
> from channels.consumer import AsyncConsumer
> from channels.layers import get_channel_layer
> import json
> import asyncio
> import aiohttp
> import datetime
>
>
> class mainConsumer(AsyncWebsocketConsumer):
>
> async def connect(self):
> await self.channel_layer.group_add('myGroup', self.channel_name)
> await self.accept()
>
> async def disconnect(self, closeCode):
> await self.channel_layer.group_discard('myGroup',
> self.channel_name)
>
> async def receive(self, text_data):
> eventData = json.loads(text_data)
> print(eventData)
> if eventData['toggle'] == 'on':
> await self.channel_layer.send('myToggle',{"type":
> "openConnection"})
> elif eventData['toggle'] == 'off':
> await self.channel_layer.send('myToggle',{"type":
> "closeConnection"})
>
> async def myUpdate(self, data):
> updateMsg = #some data processing here
> await self.send(text_data=json.dumps(updateMsg))
>
>
> class backgroundConsumer(AsyncConsumer):
>
> def __init__(self, scope):
> self.scope = scope
> self.turnOnListener = True
> self.channelLayer = get_channel_layer()
> self.t1 = None
> print('inside init') # this will print init on every
> channel_layer.send to 'myToggle' in mainConsumer
>
> async def listen(self):
>
> async with aiohttp.ClientSession() as session:
> async with session.ws_connect('...streaming url...',
> ssl=False) as ws:
> await ws.send_str('...some string...')
> async for msg in ws:
> if msg.type == aiohttp.WSMsgType.TEXT:
> if msg.data.startswith('2'):
> await ws.send_str('3')
> else:
> await self.parseListenData(msg)
>
> async def parseListenData(self, msgContent):
>  # process and create updateMsg dict with type: 'myUpdate' (so
> that it gets to the myUpdate function in main Consumer)
>  await self.channelLayer.group_send('myGroup', updateMsg)
>
> async def openConnection(self, event):
> if(self.turnOnListener): *# THIS IS ALWAYS TRUE BECAUSE THE ROUTE
> INITIALIZES A NEW INSTANCE OF THIS CLASS!!*
> await self.channelLayer.group_add(
> 'myGroup',
> self.channel_name,
> )
> self.turnOnListener = False # This only changes it for the
> current instance (obviously)
> loop = asyncio.get_event_loop()
> self.t1 = asyncio.run_coroutine_threadsafe(self.listen(),
> loop=loop)
> else:
> print('already turned on listener')
>
> async def closeConnection(self, event):
> loop = asyncio.get_event_loop()
> loop.call_soon_threadsafe(self.t1.cancel) *# t1 is always None
> because the route initialized a new instance of this class!!*
>
> *routing.py*
> from channels.auth import AuthMiddlewareStack
> from channels.routing import ProtocolTypeRouter, URLRouter,
> ChannelNameRouter
> import dashboard.routing
> from dashboard.consumers import backgroundConsumer
>
> application = ProtocolTypeRouter({
> # (http->django views is added by default)
> 'websocket': AuthMiddlewareStack(
> URLRouter(
> dashboard.routing.websocket_urlpatterns
> )
> ),
> 'channel': ChannelNameRouter({
> "myToggle": backgroundConsumer,
> }),
> })
>
>
> --
> 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/431ada5

Re: Forms in Bootstrap 4 Modals?

2018-06-21 Thread Alexander Joseph
So I changed the link to the button as you suggested, and put the static 
modal in the gaas_wafer_design_list.html file, and commented out the 
javascript at the bottom, and the modal is showing up as it should now. 
Heres my gaas_wafer_design_list.html file, highlighted with the changes


{% extends "pages/list_template.html" %}{% load static from staticfiles %}
{% load widget_tweaks %}

{% block title %}GaAs Wafer Design List{% endblock %}
{% block list_title %}GaAs Wafer Designs{% endblock %}
{% block list_title_2 %}Design Inventory{% endblock %}

{% block extra_js%}
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js";>

http://malsup.github.com/jquery.form.js";>
{% endblock %}

{% block buttons %}
  
Create a new wafer design

  
  View
  
  
  Recycling Bin
  

  

{% endblock %}

{% block table %}

  
  {% csrf_token %}
  
  
  Add Wafer Design
  
  ×
  Close
  
  
  
  Test
  
  
  Close
  
  
  
  
  

  
  
  
  Wafer Design UI
  
  
  Emitting Type
  
  
  Contact Location
  
  
  Optical Power
  
  
  Design Date
  
  
  Designer
  
  
  Designer UI
  
  
  Created At
  
  
  
  
  
  
  Wafer Design UI
  
  
  Emitting Type
  
  
  Contact Location
  
  
  Optical Power
  
  
  Design Date
  
  
  Designer
  
  
  Designer UI
  
  
  Created At
  
  
  
  
  {% for gaas_wafer_design in gaas_wafer_designs %}
  
  {{ gaas_wafer_design.design_ui }}
  {{ gaas_wafer_design.get_emitting_display }}
  {{ gaas_wafer_design.contact_location }}
  {{ gaas_wafer_design.optical_power }}
  {{ gaas_wafer_design.design_date|date:"m/d/y" }}
  {{ gaas_wafer_design.designer }}
  {{ gaas_wafer_design.designer_ui }}
  {{ gaas_wafer_design.created_at }}
  
  {% endfor %}
  

  /*
  $('#modal').on('show.bs.modal', function (event) {
var modal = $(this)
$.ajax({
  url: "create/",
  context: document.body
}).done(function(response) {
  modal.html(response);
});
  })
  
{% endblock %}

And a screenshot of what I'm seeing





So at least we know the modal itself works now. Thanks!



On Thursday, June 21, 2018 at 10:12:41 AM UTC-6, C. Kirby wrote:
>
> Ok, this is good to work with. Let us tackle this issue by issue. The 
> first issue is that your modal is not showing up. I see several possible 
> issues:
>
> Replace 
>   Click here to show the modal
>  with
>
> Create a new wafer 
> design
>
> Having the href in the a tag makes it want to load to a new page, but also 
> load the modal, I think. Since you reference the form url in the ajax call 
> you don't need it in an a tag. Also in the bootstrap4 api reference it only 
> launches modals from buttons, not from  tags
>
> Next/if that doesn't get you a further I would check to make sure teh 
> modal structure is correct before worrying about the ajax call.
>  
> Put the contents of the gaas_wafer_design_form.html into the modal in 
> gaas_wafer_design_list.html. Remove the form elements and just have a 
> complete, static bootstrap modal on the page. Also comment out the 
> on(show.bs.modal). Noting the date on the tutorial it looks like it might 
> be using an alpha or beta version of bootstrap4. If you can't get a static 
> modal to show up this way then you will have to go take a look at the 
> bootstrap4 api and match the modal structure.
>
> If you have the same/new issues after trying those we can tackle them next
>
> Kirby
>

-- 
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/debfd785-16b6-4542-ab0b-ce8a16623373%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Forms in Bootstrap 4 Modals?

2018-06-21 Thread Alexander Joseph
Thanks Melvyn! I will definitely take a look at that. From some of the
tutorials it sounds like there are some differences between Bootstrap3/4 in
how the ajax calls would need to be structured but I'm interesting in
seeing your approach

On Thu, Jun 21, 2018 at 1:03 PM, Melvyn Sopacua 
wrote:

> I have a lot of this stuff worked out, but for Bootstrap 3. I've done this
> in a UX library I've used for various projects, so it's kinda of a
> need-driven collection of widgets, CBV's and form components - not exactly
> something for general use.
>
>
>
> I've made it available on Gitlab, so you can see how you add various
> modals to a single view. In my case I mostly used a context menu to launch
> the modals, but I never bothered with the Ajax part, instead the forms get
> submitted normally, generating a page reload. That part you have to do
> yourself, but there's a lot in there you can build on:
>
>
>
> - Wrapper for a Form
> 
>
> - Mixins to handle addtional forms
> 
>
> - Template tags to render a bootstrap 3 modal
> 
>
> - etcetera...
>
>
>
>
>
> And here's an example of a view from a project management tool that I
> wrote with it:
>
>
>
> class ProjectDetailView(DefaultPageMixin, AdditionalFormsMixin,
>
> ContextMenuMixin, generic.DetailView):
>
> model = models.Project
>
> context_object_name = 'project'
>
> template_name = 'view/project.html'
>
>
>
> def generate_context_menu(self) -> None:
>
> self.add_active_menu_link('view_project', _('View Project'), icon='eye')
>
> self.add_context_menu_modal(
>
> 'edit_project', _('Edit Project'), 'edit-project', icon='pencil',
>
> title=_('Edit current project')
>
> )
>
> self.add_context_menu_modal(
>
> 'add_task', _('Add Milestone'), 'add-task', icon='plus-square',
>
> )
>
>
>
> def generate_additional_forms(self):
>
> proj_update_url = reverse('core:project_edit',
>
> kwargs={'slug': self.object.slug})
>
> task_create_url = reverse('core:project_task_create')
>
> self.add_additional_form(
>
> 'project_update_form', forms.ProjectForm, proj_update_url,
>
> model_instance=self.object,
>
> )
>
> self.add_additional_form(
>
> 'add_milestone_form', forms.NewProjectTaskForm, task_create_url,
>
> initial={'project': self.object, 'is_milestone': True},
>
> )
>
>
>
> def get_context_data(self, **kwargs):
>
> context = super().get_context_data(**kwargs)
>
> del context['object']
>
> project = self.object # type: models.Project
>
> context['has_milestones'] = project.has_milestones
>
> context['milestones'] = project.milestones.order_by('sequence', 'title')
>
>
>
> return context
>
>
>
> I may clean up the library for more general use, but in the mean time,
> hope this helps you along with your quest.
>
>
>
> On donderdag 21 juni 2018 18:23:26 CEST Alexander Joseph wrote:
>
> > Awesome! Thanks Kirby, I will try that out and let you know
>
> >
>
> > On Thu, Jun 21, 2018 at 10:12 AM, C. Kirby  wrote:
>
> > > Ok, this is good to work with. Let us tackle this issue by issue. The
>
> > > first issue is that your modal is not showing up. I see several
> possible
>
> > > issues:
>
> > >
>
> > > Replace
>
> > >
>
> > > Click here to show the
> modal
>
> > >
>
> > > with
>
> > >
>
> > > Create a new wafer
>
> > > design
>
> > >
>
> > > Having the href in the a tag makes it want to load to a new page, but
> also
>
> > > load the modal, I think. Since you reference the form url in the ajax
> call
>
> > > you don't need it in an a tag. Also in the bootstrap4 api reference it
>
> > > only
>
> > > launches modals from buttons, not from  tags
>
> > >
>
> > > Next/if that doesn't get you a further I would check to make sure teh
>
> > > modal structure is correct before worrying about the ajax call.
>
> > >
>
> > > Put the contents of the gaas_wafer_design_form.html into the modal in
>
> > > gaas_wafer_design_list.html. Remove the form elements and just have a
>
> > > complete, static bootstrap modal on the page. Also comment out the
>
> > > on(show.bs.modal). Noting the date on the tutorial it looks like it
> might
>
> > > be using an alpha or beta version of bootstrap4. If you can't get a
> static
>
> > > modal to show up this way then you will have to go take a look at the
>
> > > bootstrap4 api and match the modal structure.
>
> > >
>
> > > If you have the same/new issues after trying those we can tackle them
> next
>
> > >
>
> > > Kirby
>
> > >
>
> > > --
>
> > > 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/CPspzgE33Dk/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

Re: Forms in Bootstrap 4 Modals?

2018-06-21 Thread Melvyn Sopacua
I have a lot of this stuff worked out, but for Bootstrap 3. I've done this in a 
UX library I've 
used for various projects, so it's kinda of a need-driven collection of 
widgets, CBV's and 
form components - not exactly something for general use.

I've made it available on Gitlab, so you can see how you add various modals to 
a single 
view. In my case I mostly used a context menu to launch the modals, but I never 
bothered 
with the Ajax part, instead the forms get submitted normally, generating a page 
reload. 
That part you have to do yourself, but there's a lot in there you can build on:

- Wrapper for a Form[1] 
- Mixins to handle addtional forms[2] 
- Template tags to render a bootstrap 3 modal[3] 
- etcetera...


And here's an example of a view from a project management tool that I wrote 
with it:

class ProjectDetailView(DefaultPageMixin, AdditionalFormsMixin,
ContextMenuMixin, generic.DetailView):
model = models.Project
context_object_name = 'project'
template_name = 'view/project.html'

def generate_context_menu(self) -> None:
self.add_active_menu_link('view_project', _('View Project'), icon='eye')
self.add_context_menu_modal(
'edit_project', _('Edit Project'), 'edit-project', icon='pencil',
title=_('Edit current project')
)
self.add_context_menu_modal(
'add_task', _('Add Milestone'), 'add-task', icon='plus-square',
)

def generate_additional_forms(self):
proj_update_url = reverse('core:project_edit',
  kwargs={'slug': self.object.slug})
task_create_url = reverse('core:project_task_create')
self.add_additional_form(
'project_update_form', forms.ProjectForm, proj_update_url,
model_instance=self.object,
)
self.add_additional_form(
'add_milestone_form', forms.NewProjectTaskForm, task_create_url,
initial={'project': self.object, 'is_milestone': True},
)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
del context['object']
project = self.object  # type: models.Project
context['has_milestones'] = project.has_milestones
context['milestones'] = project.milestones.order_by('sequence', 'title')

return context

I may clean up the library for more general use, but in the mean time, hope 
this helps you 
along with your quest.

On donderdag 21 juni 2018 18:23:26 CEST Alexander Joseph wrote:
> Awesome! Thanks Kirby, I will try that out and let you know
> 
> On Thu, Jun 21, 2018 at 10:12 AM, C. Kirby  wrote:
> > Ok, this is good to work with. Let us tackle this issue by issue. The
> > first issue is that your modal is not showing up. I see several possible
> > issues:
> > 
> > Replace
> > 
> >   Click here to show the modal
> > 
> >  with
> > 
> > Create a new wafer
> > design
> > 
> > Having the href in the a tag makes it want to load to a new page, but also
> > load the modal, I think. Since you reference the form url in the ajax call
> > you don't need it in an a tag. Also in the bootstrap4 api reference it
> > only
> > launches modals from buttons, not from  tags
> > 
> > Next/if that doesn't get you a further I would check to make sure teh
> > modal structure is correct before worrying about the ajax call.
> > 
> > Put the contents of the gaas_wafer_design_form.html into the modal in
> > gaas_wafer_design_list.html. Remove the form elements and just have a
> > complete, static bootstrap modal on the page. Also comment out the
> > on(show.bs.modal). Noting the date on the tutorial it looks like it might
> > be using an alpha or beta version of bootstrap4. If you can't get a static
> > modal to show up this way then you will have to go take a look at the
> > bootstrap4 api and match the modal structure.
> > 
> > If you have the same/new issues after trying those we can tackle them next
> > 
> > Kirby
> > 
> > --
> > 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/CPspzgE33Dk/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/53d50894-98f7-4d92-a1c2-0a9d61e19fea%40googlegroups.com
> >  > 9d61e19fea%40googlegroups.com?utm_medium=email&utm_source=footer> .
> > 

-- 
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 ema

RE: How to fill latitude and longitude values from an existinglocation field in Django+Python?

2018-06-21 Thread Himanshu Gamit
Prateek,

Have you tried this module? http://django-map-widgets.readthedocs.io/en/latest/

Thanks
Himanshu
Sent from Mail for Windows 10

From: prateek gupta
Sent: Thursday, June 21, 2018 10:32 AM
To: Django users
Subject: Re: How to fill latitude and longitude values from an existinglocation 
field in Django+Python?

I am using Django 2.0.6 and yes I am able to use this package .
This package is currently showing a map below the address and once I enter the 
address; it fill the location field and changes the map according.

On Thursday, June 21, 2018 at 7:41:22 PM UTC+5:30, Matthew Pava wrote:
Based on the information of that project, it does not support Django passed 
version 1.10.  What version are you using?
Saving of the location should be automatic based on my understanding of that 
package.
You may want to contact the author of that package to get more help.
 
From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf 
Of prateek gupta
Sent: Thursday, June 21, 2018 8:54 AM
To: Django users
Subject: Re: How to fill latitude and longitude values from an existing 
location field in Django+Python?
 
Thanks for your reply.
I was trying to first use in built django library for that 
https://github.com/caioariede/django-location-field
It is showing me a map with location field(conaining latitude,longitude)
But I want to save the latitude/longitude values in DB so I am not seeing any 
way in this inbuild library.
 
Now I will try Google API.

On Thursday, June 21, 2018 at 6:04:32 PM UTC+5:30, Julio Biason wrote:
Hi Prateek.
 
You're using Google Maps for the lat/long, right?
 
In this case, I'd suggest that, on the function you receive the data and update 
the field, you also make a request to some URL to update the lat/long of the 
current displayed object.
 
On Thu, Jun 21, 2018 at 9:29 AM, prateek gupta  wrote:
Got it Jason, I will not post anymore now.

On Thursday, June 21, 2018 at 5:31:13 PM UTC+5:30, Jason wrote:
You've been posting here about this regularly (at least four times) with no 
responses.  I don't think anyone here knows how to solve your problem.  what 
else have you looked at?  eg, have you asked on stack overflow or other places?
-- 
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/2c6cc9f6-1455-439c-ad78-459fcc1828ab%40googlegroups.com.

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



-- 
Julio Biason, Sofware Engineer
AZION  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101  |  Mobile: +55 51 99907 0554
-- 
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 djang...@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/b4c346b2-1032-485e-8b96-d1131dcfcc06%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/fd219fe9-892c-4061-930b-6e8b22849b32%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/5b2becce.1c69fb81.d902c.0953%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: saving django session data for anonymous user

2018-06-21 Thread Melvyn Sopacua
On woensdag 13 juni 2018 14:40:05 CEST Siddharth Srivastava wrote:
> Thanks  Anthony for your prompt reply. current implementation is that i am
> using django orm query to pull the user cart details and cart id(session
> key) is the key so when user switch from anonymous
> user to actual user then i loses the data came from the query.
> 
> so when user gets authenticated then it create new session id then previous
> session data we lose. I am not finding much help in google:(.

This is a very bad design. Why don't simply store the cart ID in the session, 
rather then using a session ID for a cart's ID? This is just one of the 
problems you're going to face.
For example, implementing abandoned cart reminders is going to be no joyride 
and pretty much standard functionality in e-commerce these days. Sessions are 
there to store data and Django automatically copies the data in the session 
from anonymous user to logged in user. It's what sessions are made for.

-- 
Melvyn Sopacua

-- 
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/3751359.ac4gruEBS1%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: Forms in Bootstrap 4 Modals?

2018-06-21 Thread Alexander Joseph
Awesome! Thanks Kirby, I will try that out and let you know

On Thu, Jun 21, 2018 at 10:12 AM, C. Kirby  wrote:

> Ok, this is good to work with. Let us tackle this issue by issue. The
> first issue is that your modal is not showing up. I see several possible
> issues:
>
> Replace
>   Click here to show the modal
>  with
>
> Create a new wafer
> design
>
> Having the href in the a tag makes it want to load to a new page, but also
> load the modal, I think. Since you reference the form url in the ajax call
> you don't need it in an a tag. Also in the bootstrap4 api reference it only
> launches modals from buttons, not from  tags
>
> Next/if that doesn't get you a further I would check to make sure teh
> modal structure is correct before worrying about the ajax call.
>
> Put the contents of the gaas_wafer_design_form.html into the modal in
> gaas_wafer_design_list.html. Remove the form elements and just have a
> complete, static bootstrap modal on the page. Also comment out the
> on(show.bs.modal). Noting the date on the tutorial it looks like it might
> be using an alpha or beta version of bootstrap4. If you can't get a static
> modal to show up this way then you will have to go take a look at the
> bootstrap4 api and match the modal structure.
>
> If you have the same/new issues after trying those we can tackle them next
>
> Kirby
>
> --
> 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/CPspzgE33Dk/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/53d50894-98f7-4d92-a1c2-0a9d61e19fea%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Best Regards,

Alexander Joseph

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


Re: Forms in Bootstrap 4 Modals?

2018-06-21 Thread C. Kirby
Ok, this is good to work with. Let us tackle this issue by issue. The first 
issue is that your modal is not showing up. I see several possible issues:

Replace 
  Click here to show the modal
 with

Create a new wafer 
design

Having the href in the a tag makes it want to load to a new page, but also 
load the modal, I think. Since you reference the form url in the ajax call 
you don't need it in an a tag. Also in the bootstrap4 api reference it only 
launches modals from buttons, not from  tags

Next/if that doesn't get you a further I would check to make sure teh modal 
structure is correct before worrying about the ajax call.
 
Put the contents of the gaas_wafer_design_form.html into the modal in 
gaas_wafer_design_list.html. Remove the form elements and just have a 
complete, static bootstrap modal on the page. Also comment out the 
on(show.bs.modal). Noting the date on the tutorial it looks like it might 
be using an alpha or beta version of bootstrap4. If you can't get a static 
modal to show up this way then you will have to go take a look at the 
bootstrap4 api and match the modal structure.

If you have the same/new issues after trying those we can tackle them next

Kirby

-- 
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/53d50894-98f7-4d92-a1c2-0a9d61e19fea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread prateek gupta
I am using Django 2.0.6 and yes I am able to use this package .
This package is currently showing a map below the address and once I enter 
the address; it fill the location field and changes the map according.

On Thursday, June 21, 2018 at 7:41:22 PM UTC+5:30, Matthew Pava wrote:
>
> Based on the information of that project, it does not support Django 
> passed version 1.10.  What version are you using?
>
> Saving of the location should be automatic based on my understanding of 
> that package.
>
> You may want to contact the author of that package to get more help.
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *prateek gupta
> *Sent:* Thursday, June 21, 2018 8:54 AM
> *To:* Django users
> *Subject:* Re: How to fill latitude and longitude values from an existing 
> location field in Django+Python?
>
>  
>
> Thanks for your reply.
>
> I was trying to first use in built django library for that 
> https://github.com/caioariede/django-location-field
>
> It is showing me a map with location field(conaining latitude,longitude)
>
> But I want to save the latitude/longitude values in DB so I am not seeing 
> any way in this inbuild library.
>
>  
>
> Now I will try Google API.
>
> On Thursday, June 21, 2018 at 6:04:32 PM UTC+5:30, Julio Biason wrote:
>
> Hi Prateek.
>
>  
>
> You're using Google Maps for the lat/long, right?
>
>  
>
> In this case, I'd suggest that, on the function you receive the data and 
> update the field, you also make a request to some URL to update the 
> lat/long of the current displayed object.
>
>  
>
> On Thu, Jun 21, 2018 at 9:29 AM, prateek gupta  wrote:
>
> Got it Jason, I will not post anymore now.
>
> On Thursday, June 21, 2018 at 5:31:13 PM UTC+5:30, Jason wrote:
>
> You've been posting here about this regularly (at least four times) with 
> no responses.  I don't think anyone here knows how to solve your problem.  
> what else have you looked at?  eg, have you asked on stack overflow or 
> other places?
>
> -- 
> 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/2c6cc9f6-1455-439c-ad78-459fcc1828ab%40googlegroups.com
>  
> 
> .
>
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> -- 
>
> *Julio Biason*, Sofware Engineer
>
> *AZION*  |  Deliver. Accelerate. Protect.
>
> Office: +55 51 3083 8101  |  Mobile: +55 51 *99907 0554*
>
> -- 
> 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 djang...@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/b4c346b2-1032-485e-8b96-d1131dcfcc06%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/fd219fe9-892c-4061-930b-6e8b22849b32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread Jani Tiainen
Hi,

First I really suggest you to take a look at Django GIS functionality. It
requires few libs to be installed but gives you tons of functionality.
Including fields that can show geometry on map.

Next problem is that you want to convert physical address to coordinates.
Process is called geocoding and there exists several services and libraries
you can use.

Finally the hard part - just combine those two and you get what you're
asking for.


to 21. kesäk. 2018 klo 13.44 prateek gupta  kirjoitti:

> Hi All,
>
> I need your help in one task.
> I have created a address form in Django 2.0.6 + Python3.6.
> In this form once user entered the address, the location field is auto
> filled with latitude,longitude as below screen shot-
>
>
> 
>
> Now I want to write a python function which can fetch Latitude and
> Longitude values from the Location field and can save them in respective
> Latitude/Longitude fields.
>
> My models.py code is as below:
> class Store(models.Model):
> postal_code = models.CharField(max_length=6)
> address = models.TextField()
> location = PlainLocationField(based_fields=['address'], zoom=7,
> null=True)
> phone = models.CharField(max_length=60, blank=True, null=True)
> latitude = models.FloatField()
> longitude = models.FloatField()
> class Meta:
> managed = False
> db_table = 'store'
>
> admin.py:
>
> class StoreAdmin(admin.ModelAdmin):
> list_display = ('postal_code', 'address','phone', 'latitude', 'longitude')
>
>
> Can anyone help me to achieve this functionality?
>
> --
> 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/c453ba82-7e0a-4fc1-8c8e-0a588b857627%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/CAHn91ocDijwVPxXZ-ynGd%2BFK%3D%2B%3DF4Hbcqaeci-hbYRQQGwhD-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread Matthew Pava
Based on the information of that project, it does not support Django passed 
version 1.10.  What version are you using?
Saving of the location should be automatic based on my understanding of that 
package.
You may want to contact the author of that package to get more help.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of prateek gupta
Sent: Thursday, June 21, 2018 8:54 AM
To: Django users
Subject: Re: How to fill latitude and longitude values from an existing 
location field in Django+Python?

Thanks for your reply.
I was trying to first use in built django library for that 
https://github.com/caioariede/django-location-field
It is showing me a map with location field(conaining latitude,longitude)
But I want to save the latitude/longitude values in DB so I am not seeing any 
way in this inbuild library.

Now I will try Google API.

On Thursday, June 21, 2018 at 6:04:32 PM UTC+5:30, Julio Biason wrote:
Hi Prateek.

You're using Google Maps for the lat/long, right?

In this case, I'd suggest that, on the function you receive the data and update 
the field, you also make a request to some URL to update the lat/long of the 
current displayed object.

On Thu, Jun 21, 2018 at 9:29 AM, prateek gupta > 
wrote:
Got it Jason, I will not post anymore now.

On Thursday, June 21, 2018 at 5:31:13 PM UTC+5:30, Jason wrote:
You've been posting here about this regularly (at least four times) with no 
responses.  I don't think anyone here knows how to solve your problem.  what 
else have you looked at?  eg, have you asked on stack overflow or other places?
--
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/2c6cc9f6-1455-439c-ad78-459fcc1828ab%40googlegroups.com.

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



--
Julio Biason, Sofware Engineer
AZION  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101  |  Mobile: +55 51 99907 0554
--
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/b4c346b2-1032-485e-8b96-d1131dcfcc06%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/93fc8671d4084469ac8446a08379f977%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread prateek gupta
Thanks for your reply.
I was trying to first use in built django library for that 
https://github.com/caioariede/django-location-field
It is showing me a map with location field(conaining latitude,longitude)
But I want to save the latitude/longitude values in DB so I am not seeing 
any way in this inbuild library.

Now I will try Google API.

On Thursday, June 21, 2018 at 6:04:32 PM UTC+5:30, Julio Biason wrote:
>
> Hi Prateek.
>
> You're using Google Maps for the lat/long, right?
>
> In this case, I'd suggest that, on the function you receive the data and 
> update the field, you also make a request to some URL to update the 
> lat/long of the current displayed object.
>
> On Thu, Jun 21, 2018 at 9:29 AM, prateek gupta  > wrote:
>
>> Got it Jason, I will not post anymore now.
>>
>> On Thursday, June 21, 2018 at 5:31:13 PM UTC+5:30, Jason wrote:
>>>
>>> You've been posting here about this regularly (at least four times) with 
>>> no responses.  I don't think anyone here knows how to solve your problem.  
>>> what else have you looked at?  eg, have you asked on stack overflow or 
>>> other places?
>>>
>> -- 
>> 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/2c6cc9f6-1455-439c-ad78-459fcc1828ab%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> *Julio Biason*, Sofware Engineer
> *AZION*  |  Deliver. Accelerate. Protect.
> Office: +55 51 3083 8101  |  Mobile: +55 51 *99907 0554*
>

-- 
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/b4c346b2-1032-485e-8b96-d1131dcfcc06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread Jason
Uh, that's not what I mean.  You had asked this question multiple times and 
gotten no response back.  If you're relying on this group for your only 
source of help, that means you lost quite a bit of time getting this done.  
Where else were you looking?  What other options did you try to use?

On Thursday, June 21, 2018 at 8:29:17 AM UTC-4, prateek gupta wrote:
>
> Got it Jason, I will not post anymore now.
>
> On Thursday, June 21, 2018 at 5:31:13 PM UTC+5:30, Jason wrote:
>>
>> You've been posting here about this regularly (at least four times) with 
>> no responses.  I don't think anyone here knows how to solve your problem.  
>> what else have you looked at?  eg, have you asked on stack overflow or 
>> other places?
>>
>

-- 
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/d97722e7-15e4-4847-be4d-a2236d99ca37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running a celery worker as a windows service

2018-06-21 Thread Mohammed Noor
Thanks.

I solved it by writing a batch file to run the celery worker and creating a
windows task to run the batch file.

On Thu, Jun 21, 2018 at 4:03 PM, Jason  wrote:

> there's documentation on this http://docs.celeryproject.org/en/latest/
> userguide/daemonizing.html
>
> but not sure if they're compatible with windows.
>
>
> On Thursday, June 21, 2018 at 3:50:03 AM UTC-4, Mohammed Noor wrote:
>>
>> Hello guys,
>>
>> I have a celery worker that I need to be running on a server 24/7.
>> Currently, I am running it in a cmd window. But I need to convert this to a
>> background windows service  so that it can run always without the danger of
>> being closed by anyone.
>>
>> Any ideas how this can be done?
>>
>> Regards,
>> Mohammed Noor
>>
> --
> 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/710953fa-2e11-432e-9cee-7c86a46755f8%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/CABANScTVbzHR%3DJtx9rJAw1mp-p8%2BoY%2Bwze4qZzrBZQhemu-YxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread Melvyn Sopacua
On donderdag 21 juni 2018 14:29:17 CEST prateek gupta wrote:
> Got it Jason, I will not post anymore now.

Well, not the same question at least. The second one was better, since it was 
specific. What you're asking with this question is too broad and doing it on 
stackoverflow will yield the same results.

You're basically asking us to code it for you, because you have a  deadline 
and not enough understanding of Django or it's eco system. There are a lot of 
helpful people on this list, but if you want this done on the short term, you 
can enlist someone to tutor you or cooperate on the project with you. 
Naturally, you should offer some incentive to people as this isn't a simple 
Question & Answer problem.

-- 
Melvyn Sopacua

-- 
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/2859111.WbdiAzZ8Y1%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread Julio Biason
Hi Prateek.

You're using Google Maps for the lat/long, right?

In this case, I'd suggest that, on the function you receive the data and
update the field, you also make a request to some URL to update the
lat/long of the current displayed object.

On Thu, Jun 21, 2018 at 9:29 AM, prateek gupta  wrote:

> Got it Jason, I will not post anymore now.
>
> On Thursday, June 21, 2018 at 5:31:13 PM UTC+5:30, Jason wrote:
>>
>> You've been posting here about this regularly (at least four times) with
>> no responses.  I don't think anyone here knows how to solve your problem.
>> what else have you looked at?  eg, have you asked on stack overflow or
>> other places?
>>
> --
> 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/2c6cc9f6-1455-439c-ad78-459fcc1828ab%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Julio Biason*, Sofware Engineer
*AZION*  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101   |  Mobile: +55 51
*99907 0554*

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


Re: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread prateek gupta
Got it Jason, I will not post anymore now.

On Thursday, June 21, 2018 at 5:31:13 PM UTC+5:30, Jason wrote:
>
> You've been posting here about this regularly (at least four times) with 
> no responses.  I don't think anyone here knows how to solve your problem.  
> what else have you looked at?  eg, have you asked on stack overflow or 
> other places?
>

-- 
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/2c6cc9f6-1455-439c-ad78-459fcc1828ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why some Django fields are not saved in database?

2018-06-21 Thread prateek gupta
Thanks for sharing this, I will do the same first.

On Thursday, June 21, 2018 at 5:55:42 PM UTC+5:30, Melvyn Sopacua wrote:
>
> On donderdag 21 juni 2018 11:31:26 CEST prateek gupta wrote:
>
>  
>
> > Thanks for reviewing the code.
>
> > 
>
> > I am new to Django and just tried to put logic from googling to achieve 
> my
>
> > goal.
>
> > That's why I don't understand my code completely.
>
>  
>
> Try to understand it before applying. The main issue you're facing is the 
> difference between class attributes and model fields.
>
>  
>
> A model field is a special class attribute that Django stores in the 
> database. You have to declare them using one of the field types 
>  that Django 
> supports.
>
> Everything else is not saved in the database.
>
>  
>
> You're using a custom model field 
>  for 
> the location in your model. Part of that field is that it stores in the 
> lon/lat information for you, so that you don't have to worry about it. What 
> it doesn't provide is a solid way for you to get the location data from the 
> field. As you've figured out, it is stored as a string, which makes it 
> difficult to make queries on lon/lat coordinates.
>
>  
>
> So it's probably not the right tool for the job. But before you go looking 
> for a different package, you should really learn more about Django, for 
> example complete the tutorial and in your case it'll be helpful to go 
> through the GIS tutorial 
>  as 
> well. Cause then you'd discover that other then support for Mapbox and 
> Google maps, Django already has built in most of what the DJango Location 
> Field package is offering you.
>
>  
>
> -- 
>
> Melvyn Sopacua
>

-- 
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/dc6fb244-13b7-446c-8a9a-7e4a7c09b122%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why some Django fields are not saved in database?

2018-06-21 Thread Melvyn Sopacua
On donderdag 21 juni 2018 11:31:26 CEST prateek gupta wrote:

> Thanks for reviewing the code.
> 
> I am new to Django and just tried to put logic from googling to achieve my
> goal.
> That's why I don't understand my code completely.

Try to understand it before applying. The main issue you're facing is the 
difference 
between class attributes and model fields.

A model field is a special class attribute that Django stores in the database. 
You have to 
declare them using one of the field types[1] that Django supports.
Everything else is not saved in the database.

You're using a custom model field[2] for the location in your model. Part of 
that field is 
that it stores in the lon/lat information for you, so that you don't have to 
worry about it. 
What it doesn't provide is a solid way for you to get the location data from 
the field. As 
you've figured out, it is stored as a string, which makes it difficult to make 
queries on lon/
lat coordinates.

So it's probably not the right tool for the job. But before you go looking for 
a different 
package, you should really learn more about Django, for example complete the 
tutorial 
and in your case it'll be helpful to go through the GIS tutorial[3] as well. 
Cause then you'd 
discover that other then support for Mapbox and Google maps, Django already has 
built 
in most of what the DJango Location Field package is offering you.

-- 
Melvyn Sopacua


[1] https://docs.djangoproject.com/en/2.0/ref/models/fields/
[2] https://docs.djangoproject.com/en/2.0/howto/custom-model-fields/
[3] https://docs.djangoproject.com/en/2.0/ref/contrib/gis/tutorial/

-- 
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/4665207.94lpJElZK9%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread Jason
You've been posting here about this regularly (at least four times) with no 
responses.  I don't think anyone here knows how to solve your problem.  
what else have you looked at?  eg, have you asked on stack overflow or 
other places?

-- 
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/578e878c-967e-45ac-b2b8-ad209424b4ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to select one checkbox at one time DJANGO.

2018-06-21 Thread Jason
If you want dynamic behavior on a page as a result of interaction, you're 
going to have to use javascript.  

-- 
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/9fdf61ab-3fa8-4330-85cc-f3ee3ec4f9b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to select one checkbox at one time DJANGO.

2018-06-21 Thread Sunil Kothiyal
Thank You. Its worked for me.
But i am not able to show hide text input on radio button click.

Can you help me?

On Thu, Jun 21, 2018 at 4:00 PM Jason  wrote:

> use a radio.
> https://docs.djangoproject.com/en/2.0/ref/forms/widgets/#radioselect
>
> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio
>
> Only one radio button in a given group can be selected at the same time
>
>
>
>
> On Thursday, June 21, 2018 at 6:15:34 AM UTC-4, Sunil Kothiyal wrote:
>>
>> I want to show and hide text input box on checkbox selection. If someone
>> select business should show textbox. Otherwise hide it.
>>
>>
>> TWO_CHOICES = (
>> ('1', 'Business'),
>> ('2', 'Indivitual'),
>> )
>>
>> business_or_individual = forms.ChoiceField(required=True,
>> widget=forms.CheckboxSelectMultiple,choices=TWO_CHOICES)
>>
>> I and i am showing on the HTML form is
>> 
>> {{form.contactInformation.business_or_individual}}
>> 
>> 
>> Its showing--
>>
>>
>> 
>>
>> --
> 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/cc986b50-899c-466b-a39a-2b1ffcfa8bfc%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Thanks & Regards,*

*Sunil Kothiyal*

-- 
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/CAB%3DWnGdvkQPLNfL1qYQ8NKZ70n_-%3DPQWpSzP%3DvVe2TAb2Xo%2BGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread prateek gupta
Hi All,

I need your help in one task.
I have created a address form in Django 2.0.6 + Python3.6.
In this form once user entered the address, the location field is auto 
filled with latitude,longitude as below screen shot-



Now I want to write a python function which can fetch Latitude and 
Longitude values from the Location field and can save them in respective 
Latitude/Longitude fields.

My models.py code is as below:
class Store(models.Model):
postal_code = models.CharField(max_length=6)
address = models.TextField()
location = PlainLocationField(based_fields=['address'], zoom=7, 
null=True)
phone = models.CharField(max_length=60, blank=True, null=True)
latitude = models.FloatField()
longitude = models.FloatField()
class Meta:
managed = False
db_table = 'store'

admin.py:

class StoreAdmin(admin.ModelAdmin):
list_display = ('postal_code', 'address','phone', 'latitude', 'longitude')


Can anyone help me to achieve this functionality?

-- 
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/c453ba82-7e0a-4fc1-8c8e-0a588b857627%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running a celery worker as a windows service

2018-06-21 Thread Jason
there's documentation on this 
http://docs.celeryproject.org/en/latest/userguide/daemonizing.html

but not sure if they're compatible with windows.

On Thursday, June 21, 2018 at 3:50:03 AM UTC-4, Mohammed Noor wrote:
>
> Hello guys,
>
> I have a celery worker that I need to be running on a server 24/7. 
> Currently, I am running it in a cmd window. But I need to convert this to a 
> background windows service  so that it can run always without the danger of 
> being closed by anyone. 
>
> Any ideas how this can be done? 
>
> Regards,
> Mohammed Noor
>

-- 
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/710953fa-2e11-432e-9cee-7c86a46755f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to select one checkbox at one time DJANGO.

2018-06-21 Thread Jason
use a radio.  
https://docs.djangoproject.com/en/2.0/ref/forms/widgets/#radioselect

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio

Only one radio button in a given group can be selected at the same time


 

On Thursday, June 21, 2018 at 6:15:34 AM UTC-4, Sunil Kothiyal wrote:
>
> I want to show and hide text input box on checkbox selection. If someone 
> select business should show textbox. Otherwise hide it.
>
>
> TWO_CHOICES = (
> ('1', 'Business'),
> ('2', 'Indivitual'),
> )
>
> business_or_individual = forms.ChoiceField(required=True, 
> widget=forms.CheckboxSelectMultiple,choices=TWO_CHOICES)
>
> I and i am showing on the HTML form is
> 
> {{form.contactInformation.business_or_individual}}
> 
> 
> Its showing--
>
>
> 
>
>

-- 
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/cc986b50-899c-466b-a39a-2b1ffcfa8bfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to select one checkbox at one time DJANGO.

2018-06-21 Thread Sunil Kothiyal
I want to show and hide text input box on checkbox selection. If someone 
select business should show textbox. Otherwise hide it.


TWO_CHOICES = (
('1', 'Business'),
('2', 'Indivitual'),
)

business_or_individual = forms.ChoiceField(required=True, 
widget=forms.CheckboxSelectMultiple,choices=TWO_CHOICES)

I and i am showing on the HTML form is

{{form.contactInformation.business_or_individual}}


Its showing--



-- 
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/c8be6c36-ad07-40c3-ae3d-43476a775158%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why some Django fields are not saved in database?

2018-06-21 Thread prateek gupta
Thanks for reviewing the code.

I am new to Django and just tried to put logic from googling to achieve my 
goal.
That's why I don't understand my code completely.

Can you please point out where I am doing this and how can I change this 
behaviour?


On Thursday, June 21, 2018 at 2:48:46 PM UTC+5:30, Melvyn Sopacua wrote:
>
> On donderdag 21 juni 2018 10:42:09 CEST prateek gupta wrote: 
>
> > Issue is in database , latitude/longitude values are blank. 
> > 
> > What I am doing wrong here? 
>
> Why do you not understand your own code? How did you get that code - you 
> explicitly code it so that it they do NOT end up in the database. So why 
> are 
> you asking why? 
>
> -- 
> Melvyn Sopacua 
>

-- 
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/3cbfcc76-dca5-4cfe-860c-23a407dc21d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why some Django fields are not saved in database?

2018-06-21 Thread Melvyn Sopacua
On donderdag 21 juni 2018 10:42:09 CEST prateek gupta wrote:

> Issue is in database , latitude/longitude values are blank.
> 
> What I am doing wrong here?

Why do you not understand your own code? How did you get that code - you 
explicitly code it so that it they do NOT end up in the database. So why are 
you asking why?

-- 
Melvyn Sopacua

-- 
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/117666335.BCEecK4HXi%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-21 Thread Melvyn Sopacua
On donderdag 21 juni 2018 10:19:08 CEST Mikkel Kromann wrote:

> However, I'd really like to give all my urls names so that they can be
> easily reversed (e.g. success links).
> urlpatterns = [
> path('list//',ItemListView.as_view(),  name=
> mName+'_list'),
> ]
> 
> From what I can see, my model name mName is passed only to the view and
> apparently not to the name constructor inside urls.py
> Also, while I do not entirely understand the reverse naming process, I
> sense that it might not be too easy to reverse the url name if it is not
> spelled out directly.
> 
> Are there any options for handling this in urls.py?

Take a look at crudlfap's Router class to see how to generate dynamic urls. In 
short: let a router who generates views for models generate the urlpatterns. 
All django is looking for is an iterable that is named 'urlpatterns' in a urls 
module.

https://github.com/yourlabs/crudlfap/blob/master/src/crudlfap/router.py#L274
-- 
Melvyn Sopacua

-- 
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/7023284.eSgYguR0o7%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Why some Django fields are not saved in database?

2018-06-21 Thread prateek gupta
Hi All,

I have a store address form in Django which have fields like- name, 
address, location, latitude, longitude etc.

I am autofilling the latitude, longitude fields based on address with the 
help of django package-https://github.com/caioariede/django-location-field


In django view after the form submisson I am able to see both fields values-





Issue is in database , latitude/longitude values are blank.

What I am doing wrong here?


models.py-

from location_field.models.plain import PlainLocationFieldclass 
Store(OwnedModel):
  address = models.TextField(default='Mumbai')
  location = PlainLocationField(based_fields=['address'], zoom=7, null=True)

  @property
  def latitude(self):
  if not self.location:
  return
  latitude, _ = self.location.split(',')
  return latitude

  @property
  def longitude(self):
  if not self.location:
  return
  _, longitude = self.location.split(',')
  return longitude

  class Meta:
  managed = False
  db_table = 'store'


admin.py-

class StoreAdmin(admin.ModelAdmin):
  list_display = ( 'address', 'latitude','longitude')
  readonly_fields = ('latitude', 'longitude',)


I am using Django2.0.6,Python3.6,Mysql

-- 
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/e4d3a1f7-c618-4f2b-979c-3e258f0c5bec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-21 Thread Mikkel Kromann
I have a lot of models (say 30 or 40) which are so similar, that I have 
handled them using slightly modified class based views.

In urls.py:
urlpatterns = [
path('list//',ItemListView.as_view()),
path('create//',  ItemCreateView.as_view()),
path('update//',  ItemUpdateView.as_view()),
path('delete//',  ItemDeleteView.as_view()),
]

However, I'd really like to give all my urls names so that they can be 
easily reversed (e.g. success links).
urlpatterns = [
path('list//',ItemListView.as_view(),  name=
mName+'_list'),
]

>From what I can see, my model name mName is passed only to the view and 
apparently not to the name constructor inside urls.py
Also, while I do not entirely understand the reverse naming process, I 
sense that it might not be too easy to reverse the url name if it is not 
spelled out directly.

Are there any options for handling this in urls.py?
Or should I make a filter that will transform the model name and operation 
name to an url and accept that I have to code url logic outside urls.py
Or could I reprogram the path() function to make this possible?
Or should I violate DRY and simply write 4 path lines for each of my 40 
models?


cheers + thanks, Mikkel

-- 
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/9cc50a2b-b613-4427-a8e4-101f9bf394d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: python inspectdb got "The error was: function unnest(smallint[]) does not exist"

2018-06-21 Thread Melvyn Sopacua
On woensdag 20 juni 2018 19:12:00 CEST weiwei.hs...@keeptruckin.com wrote:

> When I run "python3 manage.py inspectdb", I got below error messages:
> 
> 
> # Unable to inspect table 'eld_messages'
> 
> # The error was: function unnest(smallint[]) does not exist
> 
> HINT:  No function matches the given name and argument types. You may need
> to add explicit type casts.

Unnest is a PostgreSQL specific array function, that doesn't have a counterpart 
in Django's ORM, so Django does not know how to handle that.

In most cases I'd say, try to write a function for it, but in this case it may 
be better to refactor the table. Do you know the function of the table and why 
it would need an array of small ints stored? Can it be refactored to use 
another table?
-- 
Melvyn Sopacua

-- 
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/2071092.vFfFbuVlZb%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Running a celery worker as a windows service

2018-06-21 Thread Mohammed Noor
Hello guys,

I have a celery worker that I need to be running on a server 24/7.
Currently, I am running it in a cmd window. But I need to convert this to a
background windows service  so that it can run always without the danger of
being closed by anyone.

Any ideas how this can be done?

Regards,
Mohammed Noor

-- 
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/CABANScS-vGLuRBOoLdojJiVWPvN0UTjCCJsAxsj5e%2Bcc%3DBzC8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.