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

2018-01-07 Thread Jani Tiainen
Hi. __within is probably correct lookup. You can find all lookups at: https://docs.djangoproject.com/en/2.0/ref/contrib/gis/geoquerysets/ 8.1.2018 2.36 "Tom Tanner" kirjoitti: > I get this error when trying Jani's example: "FieldError: Unsupported > lookup

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

2018-01-07 Thread Matemática A3K
On Sun, Jan 7, 2018 at 7:44 PM, Ronnie Raney wrote: > > def random_post(request): > posts_ids = Post.objects.all().values_list("id", flat=True) > random_obj = Post.objects.get(id=random.choice(posts_ids)) > context = {'random_obj': random_obj,} > return

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

2018-01-07 Thread Tom Tanner
I get this error when trying Jani's example: "FieldError: Unsupported lookup 'inside' for MultiPolygonField or join on the field not permitted." On Sunday, January 7, 2018 at 7:33:51 PM UTC-5, Tom Tanner wrote: > > Thanks for replying, Jani. I should mention My `geom` field is a > MultiPolygon,

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

2018-01-07 Thread Tom Tanner
Thanks for replying, Jani. I should mention My `geom` field is a MultiPolygon, so I can't use `from_bbox` it seems... On Sunday, January 7, 2018 at 3:45:55 AM UTC-5, Jani Tiainen wrote: > > Something like following should work. Didn't checked if that actually > works. > >

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

2018-01-07 Thread Ronnie Raney
def random_post(request): posts_ids = Post.objects.all().values_list("id", flat=True) random_obj = Post.objects.get(id=random.choice(posts_ids)) context = {'random_obj': random_obj,} return render(request, 'blog/random_post.html', context) Is “”id”” actually post_id in my case?

Re: does the tutorial django 2.0 works?

2018-01-07 Thread Egor Smolyakov
Hello, Danilo. Can you post your code and getting issues (stacktrace) to pastebin or so on? On 7 January 2018 at 23:05, danilo talamonti wrote: > hellò people, > i'm learning django 2.0 from the tutorial > and until part 3 everything went ok > > In part 4 i have a

does the tutorial django 2.0 works?

2018-01-07 Thread danilo talamonti
hellò people, i'm learning django 2.0 from the tutorial and until part 3 everything went ok In part 4 i have a problem in detail.html with the form. As a conseguence, in the function vote at views.py, i always get the KeyError. has anybody tried it, to confirm the tutorial works? And if it

Re: Disallowed User Agents | Force To upgrade

2018-01-07 Thread Jason
Agreed. Blocking users from accessing the site seems counterproductive. Just do a feature detection and raise an alert warning if css-grid. Modernizr will let you do this easily -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Using Django create() on a time.field

2018-01-07 Thread Daniel Roseman
On Sunday, 7 January 2018 21:03:05 UTC, Malik Rumi wrote: > > -- > > As a string that evaluates to the past *** > > (lifeandtimes) malikarumi@Tetuoan2:~/Projects/lifeandtimes/chronicle$ > python django_textract_9.py > > Traceback (most recent call last): > > File "django_textract_9.py", line 17,

Using Django create() on a time.field

2018-01-07 Thread Malik Rumi
I am trying to process some text files and feed the result directly into a django model using create(). As so often seems to happen with me, this turns out to not be as simple as I thought it would be. Specifically, I can’t seem to get any data into ‘clock’, the time field in my model. When I

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

2018-01-07 Thread Matemática A3K
Hi! This may be better suited for the django-pandas community, as it involves its internals. It is also very hard to debug without errors or stack traces. HTH On Sun, Jan 7, 2018 at 3:51 PM, asilver wrote: > I'm trying to build a small website, using django, that stores

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

2018-01-07 Thread Matemática A3K
def random_post(request): posts_ids = Post.objects.all().values_list("id", flat=True) random_obj = Post.objects.get(id=random.choice(posts_ids)) context = {'random_obj': random_obj,} return render(request, 'blog/random_post.html', context) -- You received this message because you

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

2018-01-07 Thread asilver
I'm trying to build a small website, using django, that stores network performance data. The user will be able to use filters to retrieve the exact data he/she wants and then have the option to graph that data. I'm using django-pandas to convert filtered queryset to a dataframe and from

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

2018-01-07 Thread Ronnie Raney
I am familiar with this from searching all over for a solution. The accepted solution is to create a manager. from django.db.models.aggregates import Count > > from random import randint > > > class PaintingManager(models.Manager): > def random(self): > count =

Re: django URL pattern for an unusual address

2018-01-07 Thread Dylan Reinhold
Hit send while typing ;( page = request.GET.get('page', 1) Would give you the page number, and default to 1 if nothing was passed. Dylan On Sun, Jan 7, 2018 at 8:06 AM, Dylan Reinhold wrote: > You will just match that to / > The ?page=1 you will deal with in the view you

Re: django URL pattern for an unusual address

2018-01-07 Thread Dylan Reinhold
You will just match that to / The ?page=1 you will deal with in the view you point / to. In you view you retrive the page value from the request object Somthing like page = request.GET.get('order', 'name') Dylan On Sun, Jan 7, 2018 at 2:18 AM, christopher okoro wrote:

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

2018-01-07 Thread Jason
Actually, using order_by('?') is the worst thing possible, especially in a largish db in production. Why? That query generated is SELECT FROM WHERE ORDER BY RAND() LIMIT N where the random function is executed for every row in the result set which is ordered by the generated

Re: Disallowed User Agents | Force To upgrade

2018-01-07 Thread Andréas Kühne
Include something like this: https://browser-update.org/ It'll add a warning on your site that says that they should upgrade their browser to get the best experience. Regards, Andréas 2018-01-06 6:11 GMT+01:00 Ruchit Bhatt : > In my new Django project, i am

django URL pattern for an unusual address

2018-01-07 Thread christopher okoro
Which regular expression do I write in my URLs to give me this 'host:8000/?page=1' in my browser address -- 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

Re: Can you people explain why the def _str_() method is used below?

2018-01-07 Thread project . wsms
That is returning a string expression for your model. I will explain with an example. Consider you were to pull the list of authors in one of your template in a *choice field*. If you do not have a string method your choice field options by default will look like: - author.objects(1) -

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

2018-01-07 Thread Jani Tiainen
Hi, Something like this: post_id = Post.objects.values_list ('id', flat=True).order_by('?').first() return redirect('postview', id=post_id) 7.1.2018 15.33 "Ronnie Raney" kirjoitti: > If I understand you, you suggest using my existing DetailView url which > shows the

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

2018-01-07 Thread m712
What you need is actually very simple. Create a 'random_post' URL, which points to a view doing the shuffle logic and returns a redirect to the proper page, say '/post/$id', then make that a valid URL and use a DetailView. On January 7, 2018 4:32:11 PM GMT+03:00, Ronnie Raney

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

2018-01-07 Thread Ronnie Raney
If I understand you, you suggest using my existing DetailView url which shows the detailed Post, but create a view which selects a random pk. I thought of this but I don’t know how to go about creeating a view that selects a random pk, then applies to the existing urlpattern. My guess is to

Re: MongoDB and Django

2018-01-07 Thread Etienne Robillard
Hi, My recommendation is to check out libschevo. [1] It is compatible with Durus and ZODB databases and support schema migrations in Pure python. cheers, Etienne 1. https://www.isotopesoftware.ca/documentation/libschevo/ Le 2018-01-07 à 03:34, Jani Tiainen a écrit : Hi, You can use

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

2018-01-07 Thread Jani Tiainen
Something like following should work. Didn't checked if that actually works. Mymodel.objects.filter(geom__inside=Polygon.from_bbox((x1,y1,x2,y2), srid=1234)) On Sun, Jan 7, 2018 at 10:41 AM, Jani Tiainen wrote: > Hi, > > I didn't realize what you were asking for. :D > >

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

2018-01-07 Thread Jani Tiainen
Hi, I didn't realize what you were asking for. :D Django has bunch of spatial queries, so you're looking some of those __inside, __within lookups. Coordinate transformations do happen automatically so you just need to provide srid for you "envelope". On Sun, Jan 7, 2018 at 1:48 AM, Tom Tanner

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

2018-01-07 Thread Jani Tiainen
Hi, I'm not sure is there already such expression/aggregation available, but you can always create your own expression/aggregate that does whatever you want to. Check Django sources to check how GIS lookups/aggregates are made. On Sun, Jan 7, 2018 at 1:48 AM, Tom Tanner

Re: MongoDB and Django

2018-01-07 Thread Jani Tiainen
Hi, You can use MongoDB with Django just fine. Though, you won't get any ORM integration. If you're not bound to MongoDB yet personally I would suggest to take a look at ArangoDB. It doesn't have ORM integration either but in my opinion it's much better than MongoDB. It has many SQL-like

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

2018-01-07 Thread Jani Tiainen
Hi. Since you do have show post url, I would create random view just to redirect to show post view with random post id. 7.1.2018 5.49 ap. "Ronnie Raney" kirjoitti: > Greetings! My first time using this forum. Using Django 2.0 for a project. > I'm a beginner so I