Re: How do I make a Django model from a tab-delimited data file?

2018-01-08 Thread Andréas Kühne
Hi, You will have to parse the CSV file manually with a custom management command (at least that is what I would do). All you need to do is open the file, split each row with a "," and then import the correct columns to the model. You can also use something like pandas to convert the CSV file

Re: Django rest framework Version

2018-01-08 Thread Xavier Ordoquy
Hi, Out of curiosity, is there anything wrong with the latest version ? Regards, Xavier. > Le 9 janv. 2018 à 04:59, Rakhee Menon a écrit : > > Hey!!! > Please can anyone tell whats the stable version of django rest framework to > be used for production. > Thanks in

Re: urlopen error [Errno 110] Connection timed out

2018-01-08 Thread suase9303
yes, i use a urlopen to crawl the some site. like this: html = urlopen(page) bs0bj = BeautifulSoup(html, "html.parser") and error happen in " /usr/lib/python3.5/urllib/request.py in do_open, " when i open 'the site', the loading time is longer than others. then others which i crawl dont

How do I make a Django model from a tab-delimited data file?

2018-01-08 Thread Tom Tanner
I have a tab-delimited data file that looks something like this: NAME S1903_C02_001E state county tract State-County-Tract-ID Census Tract 201, Autauga County, Alabama 66000 01 001 020100 01001020100 Census Tract 202, Autauga County, Alabama 41107 01 001 020200 01001020200 Census Tract 203,

Re: Django rest framework Version

2018-01-08 Thread Andréas Kühne
Hi, Just get the latest version of DRF (currently 3.7.7) - as long as the version of django you are running is supported by the DRF version. Regards, Andréas 2018-01-09 4:59 GMT+01:00 Rakhee Menon : > Hey!!! > Please can anyone tell whats the stable version of django

Re: Upload file to a dynamically generated location

2018-01-08 Thread Andréas Kühne
Hi, If you look at the documentation for the upload_to parameter, you can see that you can do exactly what you want: https://docs.djangoproject.com/en/2.0/ref/models/fields/#django.db.models.FileField.upload_to The upload_to method (in your case "get_user_document_directory") can take 2

Re: Managing a process from Django

2018-01-08 Thread Antonis Christofides
Ah, OK, sorry I didn't read all the discussion. So I guess that if you keep that in a global variable, it won't work if your Django app is running in many processes. (Besides, global variables are rarely a good idea.) If I understand the problem correctly, what I would do would probably be to

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Ronnie Raney
Thanks - for clarification. Yes! good advice on remaining calm. Apologies if I seemed intense. If I use this urlpattern, it takes me to the correct template. *path('post/random/', views.random_post, name='random_post'),* But there is no data. I really wanted to include the pk in the URL, to

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 2:11 PM, Ronnie Raney wrote: > Thanks - for clarification. Yes! good advice on remaining calm. Apologies > if I seemed intense. > > If I use this urlpattern, it takes me to the correct template. > > *path('post/random/', views.random_post,

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Ronnie Raney
*You can't change the of a user from a view unless you do a redirect. You can issue a redirect to /post/ where the id is what you picked at random at the "random_post" view* I can't change the *what *of a user from the view? Also, what user? I've tried putting in there and it causes errors.

Re: Managing a process from Django

2018-01-08 Thread Kasper Laudrup
Hi Matemática A3K, On 2018-01-08 17:58, Matemática A3K wrote: With this https://stackoverflow.com/questions/89228/calling-an-external-command-in-python you can find out which distribution is using, then for each distribution there's a different command for restarting DHCP (systemctl,

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread matthew . pava
Check this out for how to redirect: https://docs.djangoproject.com/en/2.0/topics/http/shortcuts/#redirect Check this out for how Django determines the name of primary key fields: https://docs.djangoproject.com/en/2.0/topics/db/models/#automatic-primary-key-fields The best advice has already been

Re: Managing a process from Django

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 2:41 PM, Kasper Laudrup wrote: > Hi Matemática A3K, > > On 2018-01-08 17:58, Matemática A3K wrote: > >> >> With this https://stackoverflow.com/questions/89228/calling-an-externa >> l-command-in-python >> you can find out which distribution is using,

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 2:51 PM, Ronnie Raney wrote: > *You can't change the of a user from a view unless you do a redirect. You > can issue a redirect to /post/ where the id is what you picked at > random at the "random_post" view* > > I can't change the *what *of a user

Re: Simple file uploading app

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 9:16 AM, guettli wrote: > Just for the records: Since I found no matching solution I wrote a generic > http upload tool: https://pypi.python.org/pypi/tbzuploader/ > > For ftp there are thousands of clients, for automated upload via http I > found none.

Re: Managing a process from Django

2018-01-08 Thread Kasper Laudrup
Hi again, So my question is more related to any kind of process that should be managed from a Django app. Django does not manages processes, Django is a web framework. Python can manage processes. What kind? Any :) I am fully aware of that, thank you :-) I guess my question is

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Ronnie Raney
Here's a view that works, in case someone in the future wants cares about this def random_post(request): post_count = Post.objects.all().count() random_val = random.randint(0, post_count-1) post_id = Post.objects.values_list('post_id', flat=True)[random_val]

Upload file to a dynamically generated location

2018-01-08 Thread pieceofkayk2718
Hey Friends, I'm having trouble figuring out how to upload a document model to a dynamically generated location. The following models.py file contains two models and a helper function views.py # I would like the string inputs to be self.bundle.user, and self.bundle.name where self is the

Re: Managing a process from Django

2018-01-08 Thread Antonis Christofides
Hello, When you say "call [an instance of an object]", what exactly do you mean? Could you tell us more about what this class/object is and why you need to "call" (access?) it in an unusual way? Regards, Antonis Antonis Christofides http://djangodeployment.com On 2018-01-08 22:02, Kasper

Re: Django local development server hangs after calling pandas df.plot a second time

2018-01-08 Thread asilver
I looked around for a django-pandas forum/group but could not find one... I didnt' provide any errors or stack traces because there are none... The web server just hangs and I have to go into Windows task manager and kill the cmd window and sometime even that is not enough (I need to also

Re: Django local development server hangs after calling pandas df.plot a second time

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 2:07 PM, asilver wrote: > I looked around for a django-pandas forum/group but could not find one... > I didnt' provide any errors or stack traces because there are none... The > web server just hangs and I have to go into Windows task manager and

RE: Django 2.0.1 admin

2018-01-08 Thread Matthew Pava
I found the problem. I had a third-party app, django-audit-log, that I incorporated into the project since it was not working with Django 2.0. I needed to list ‘audit_log’ in the APPS list before django.contrib.admin in my Django settings module. Problem solved! Thank you! From: Matthew

Re: urlopen error [Errno 110] Connection timed out

2018-01-08 Thread Julio Biason
Hello, Where does this happen? Do you do urlopen somewhere? (IIRC, changing Django settings doesn't affect internal Python objects). urllib.request has a timeout, it's the second parameter after the data:

Re: Managing a process from Django

2018-01-08 Thread Joakim Hove
Sounds to me that what you want is a `singleton` implemented in Python . The fact that Django is involved does not seem to be very relevant? 8. jan. 2018 22:43 skrev "Kasper Laudrup" : > Hi Antonis, > > On 2018-01-08 22:10, Antonis Christofides wrote: > >> Hello, >> >>

Re: Managing a process from Django

2018-01-08 Thread Kasper Laudrup
Hi Antonis, On 2018-01-08 22:46, Antonis Christofides wrote: OK, but why do you need this? What functionality is this going to have? As I wrote in my original question, I'm attempting to write a Django application for managing DHCP leases and DNS entries. So, if a user changes an entry by

Re: Managing a process from Django

2018-01-08 Thread Kasper Laudrup
Hi Joakim, On 2018-01-08 22:50, Joakim Hove wrote: Sounds to me that what you want is a `singleton` implemented in Python . The fact that Django is involved does not seem to be very relevant? Indeed, that has crossed my mind and I'm sorry if this is in fact not very Django related. But I'm

Re: Managing a process from Django

2018-01-08 Thread Kasper Laudrup
Hi Antonis, On 2018-01-08 22:10, Antonis Christofides wrote: Hello, When you say "call [an instance of an object]", what exactly do you mean? Sorry, I meant an instance of a class or just an object. Could you tell us more about what this class/object is and why you need to "call"

Re: Managing a process from Django

2018-01-08 Thread Antonis Christofides
OK, but why do you need this? What functionality is this going to have? Antonis Christofides http://djangodeployment.com On 2018-01-08 23:43, Kasper Laudrup wrote: > Hi Antonis, > > On 2018-01-08 22:10, Antonis Christofides wrote: >> Hello, >> >> When you say "call [an instance of an object]",

Django rest framework Version

2018-01-08 Thread Rakhee Menon
Hey!!! Please can anyone tell whats the stable version of django rest framework to be used for production. 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,

Django rest framework foreign key display details from table 1 to table 2

2018-01-08 Thread cherngyorng
I have 2 model, MyUser, Family. What i want to do is display users details in Family table based on the MyUser table. It is like adding friends or family in other social media and display them In my current Family table, there are these 3 field. userId , familyId and relationship

Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-08 Thread Tom Tanner
Nah, didn't seem to work either. I ended up going with `.execute()`: https://docs.djangoproject.com/en/2.0/topics/db/sql/#executing-custom-sql-directly On Sunday, January 7, 2018 at 11:49:16 PM UTC-5, Jani Tiainen wrote: > > Hi. > > __within is probably correct lookup. > > You can find all

Re: Simple file uploading app

2018-01-08 Thread Mike Morris
Though it is not a Drupal app, there is an excellent drop box type app in PHP called "Download Ticket Service"... simple, no frills, entirely cross-platform and open: http://www.thregr.org/~wavexx/software/dl/ I have no idea if it could be readily incorporated into your app, but just FYI

Re: Simple file uploading app

2018-01-08 Thread guettli
Just for the records: Since I found no matching solution I wrote a generic http upload tool: https://pypi.python.org/pypi/tbzuploader/ For ftp there are thousands of clients, for automated upload via http I found none. That's why I wrote above tool. Regards, Thomas Am Mittwoch, 25. Oktober

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Ronnie Raney
Thanks Mat-A3K Here's what I have so far... *models.py* class Post(models.Model): post_id = models.AutoField(primary_key=True) all the other fields... *views.py* #Normal (not random) post detail view class PostDetailView(DetailView): model = Post template_name =

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Ronnie Raney
Also, would something like this work, and would it be a way to create the view? class RandomDetailView(DetailView): model = Post def random_post(request): post_ids = Post.objects.all().values_list('post_id', flat=True) random_obj =

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 11:30 AM, Ronnie Raney wrote: > Thanks Mat-A3K > > Here's what I have so far... > > *models.py* > class Post(models.Model): > post_id = models.AutoField(primary_key=True) > all the other fields... > > *views.py* > > #Normal (not random)

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 11:50 AM, Ronnie Raney wrote: > Also, would something like this work, and would it be a way to create the > view? > No, it won't work, you should read https://docs.djangoproject.com/en/2.0/topics/class-based-views/intro/ > > class

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Ronnie Raney
Ugh. Sorry for the confusion. Here again are the pieces where I need suggestions. Please suggest actual code. I can't decipher things written in plain language on forums. Code is key for me. path('post//', views.PostDetailView.as_view(), name='post_detail'), path('post/*random/???*',

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Ronnie Raney
Please give me code. Sorry, I can't decipher plain language in forums very well, when talking about code. My urlpattern: path('post//', views.PostDetailView.as_view(), name='post_detail'), path('post/*random*/*???*', views.random_post, name='random_post'), *### What do I put here?* My

Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 1:37 PM, Ronnie Raney wrote: > Ugh. Sorry for the confusion. Here again are the pieces where I need > suggestions. Please suggest actual code. I can't decipher things written in > plain language on forums. Code is key for me. > OK, first, calm down,

urlopen error [Errno 110] Connection timed out

2018-01-08 Thread suase9303
I use pythonanywhere. At this time, "urlopen error [Errno 110] Connection timed out" occurs. So I set CACHES TIMEOUT to None in Django settings.py. However, error 110 still occurs. Do I need to change the timeout value in urllib / request.py? I would really appreciate your help in this matter.

How to filter choices in Django2's autocomplete_fields?

2018-01-08 Thread Oren
In Django 2.0, autocomplete_fields was added, which is great. Without autocomplete_fields, I can change the queryset of a ForeignKeyField using formfield_for_foreignkey

Managing a process from Django

2018-01-08 Thread Kasper Laudrup
Hi fellow Django users, I'm working on creating a Django application for managing DHCP leases and DNS entries and for that I would like to be able to (re)start the DHCP daemon from Djano. I think it would be best to simply use a popen object from pythons subprocess module (most likely

Re: Managing a process from Django

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 12:48 PM, Kasper Laudrup wrote: > Hi fellow Django users, > > I'm working on creating a Django application for managing DHCP leases and > DNS entries and for that I would like to be able to (re)start the DHCP > daemon from Djano. > > I think it would