Connecting gcp cloud SQL instance with django project

2020-05-25 Thread Anirudh choudhary
Hello

I am trying to connect gcp SQL instance with my django project I am
connecting it as

DATABASES = {
   'default':env.db()
}

I am following this guide

https://codelabs.developers.google.com/codelabs/cloud-run-django/index.html?index=..%2F..index#0


It is showing me error that


no such file or directory is the server running locally and accepting
connections on unix domain socket

Can any one help


Thanks you

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL8_rkHEWWCzWrYtEpkh3D5RHN_Z2DVkNyBb8-QZhtmfz49KpQ%40mail.gmail.com.


How to create a function like Count

2020-05-25 Thread Saurabh Adhikary
I want to create a custom function which will get modified into a sql 
querry and will work like Count ...i.e. for every row of the queryset

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a301d3e-d690-4b49-b6da-02d00c97758e%40googlegroups.com.


Re: Can we use Database with Django without creating models

2020-05-25 Thread Dylan Reinhold
Inspectdb is the way to go.
Nothing is stopping you from just running sql queries though your DB python
package like mysql-connector.
You will loose much of the extras django provides with using the django-orm
like admin connections to your database.

Maybe flask would suit your use case better?

Dylan



On Mon, May 25, 2020 at 7:49 PM _M_A_Y_A_N_K_ 
wrote:

> Adding more details...
> I did tried *inspectdb, *but having other different issues with this.
> Here i want to purely use the legacy / existing database.
>
> Thanks & Regards,
> -
> Mayank Tripathi
> Mo. +1 615 962 2128
> "Do what you can, with what you have, where you are -by Theodore
> Roosevelt"
>
>
> On Mon, May 25, 2020 at 7:28 PM Mayank Tripathi <
> mayanktripath...@gmail.com> wrote:
>
>> Hi Team,
>>
>> I am trying to get options to connect to Database from Python-Django App.
>> But here the requirement is I already have a Database setup (MySQL) with
>> all required tables and fields.
>> So am not willing to use models.py and create tables.
>> Is there a way still i can use the tables... and still be able to do
>> similar query which is done using ORM (i mean Django default querysets).
>>
>> Please suggest.
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/ea4fdb96-0462-40ad-aec1-6bf1318cb0fd%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALQo0B-%3DH5wNd6KDp6TprZLDxLXBVX8gTo8EstQ7EGRkLcqvZA%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHtg44CF2vbqrtR88OuhcmuF50f02jKwB5By--Za9NoFG3a1tw%40mail.gmail.com.


Re: Can we use Database with Django without creating models

2020-05-25 Thread _M_A_Y_A_N_K_
Adding more details...
I did tried *inspectdb, *but having other different issues with this. Here
i want to purely use the legacy / existing database.

Thanks & Regards,
-
Mayank Tripathi
Mo. +1 615 962 2128
"Do what you can, with what you have, where you are -by Theodore Roosevelt"


On Mon, May 25, 2020 at 7:28 PM Mayank Tripathi 
wrote:

> Hi Team,
>
> I am trying to get options to connect to Database from Python-Django App.
> But here the requirement is I already have a Database setup (MySQL) with
> all required tables and fields.
> So am not willing to use models.py and create tables.
> Is there a way still i can use the tables... and still be able to do
> similar query which is done using ORM (i mean Django default querysets).
>
> Please suggest.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ea4fdb96-0462-40ad-aec1-6bf1318cb0fd%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALQo0B-%3DH5wNd6KDp6TprZLDxLXBVX8gTo8EstQ7EGRkLcqvZA%40mail.gmail.com.


Re: Regarding opening Google docs

2020-05-25 Thread VenkataSivaRamiReddy
Use iframe or object tag in template...

On Tue, May 26, 2020, 07:58 akshay bardiya 
wrote:

> I want to create a button on a webpage . After clicking on that button it
> should redirect to open Google docs where we can create, update ,delete
> document so how can I do this
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a871bd76-d08a-46a0-96cc-5de549692d37%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGiJVX3o-LCtJ9fO2OfFGQVgbVxfEmsF_5vVH0%3DZis8jVZ%3DU%3Dw%40mail.gmail.com.


Regarding opening Google docs

2020-05-25 Thread akshay bardiya
I want to create a button on a webpage . After clicking on that button it 
should redirect to open Google docs where we can create, update ,delete 
document so how can I do this 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a871bd76-d08a-46a0-96cc-5de549692d37%40googlegroups.com.


regular expression in an url showing post details

2020-05-25 Thread Tiempo
Hi,
my name is Tiempo and I'm new with  Django. currently, I'm using django 3.0 
and i want to display each article of a blog app ( like when I click on 
article 1, it should display it full details on page show with the 
following link http://127.0.0.1:8000/blog/posts/1/)

containing a parameter named id (of an article) but the path is not 
recognized : 

urlpatterns = [

path('', views.index, name='Blog'),
path('posts/?P[0-9]+', views.show),



This is how I called the function show in views:

def show(request, id):
return render(request, 'blog/show.html', {'id': id})



This is what happens when I execute the local server

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/blog/posts/1/

Using the URLconf defined in monsite.urls, Django tried these URL patterns, 
in this order:

   1. admin/
   2. [name='Home']
   3. about/ [name='About']
   4. contact/ [name='Contact']
   5. blog/ [name='Blog']
   6. blog/ posts/?P[0-9]+

The current path, blog/posts/1/, didn't match any of these.

can someone help me with how to write the regular expression in Django 3.0, 
please?




-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a526cfaf-c177-44f3-b6a3-68d241063aec%40googlegroups.com.


Can we use Database with Django without creating models

2020-05-25 Thread Mayank Tripathi
Hi Team,

I am trying to get options to connect to Database from Python-Django App.
But here the requirement is I already have a Database setup (MySQL) with 
all required tables and fields.
So am not willing to use models.py and create tables.
Is there a way still i can use the tables... and still be able to do 
similar query which is done using ORM (i mean Django default querysets).

Please suggest.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ea4fdb96-0462-40ad-aec1-6bf1318cb0fd%40googlegroups.com.


Re: convert Date to milliseconds

2020-05-25 Thread HJ
thank you so much for your ideas , I am gonna fix this ^^

Le mardi 26 mai 2020 01:01:17 UTC+1, Samuel Nogueira a écrit :
>
> Hi! before answer you question I would recomend you to give a little fix 
> in your model and your function names. Try to follow the PEP8 style guide 
> for Python, in the guide is recommended using only capitalized words for 
> naming classes with composite names, and function names should be lowercase 
> with words separated by underscore. Thereby, would be more appropriate 
> naming your function and class this way: *class 
> MailItemCountDeliveriesPerDate()* and *def json_deliv()*. Fell free to 
> accept or ignore this tip.
>
> Now, back to the question, the DateTimeField() is a implementation of the 
> python datetime.datetime for storage in the database, so after you get the 
> Date from the database you can use the timestamp() method in the related 
> Date field. This will deliver the date in seconds format, then you just 
> multiply by 1000 to get your Date in milliseconds.
>
>  
>
> Hope this helps. Sorry if it got a little confusing.
>
>  
>
> *De: *HJ 
> *Enviado:*segunda-feira, 25 de maio de 2020 19:17
> *Para: *Django users 
> *Assunto: *convert Date to milliseconds
>
>  
>
> Hello everyone I want to convert my Date from string to *milliseconds*
>
>  
>
> this is my *models.py class *
>
>  
>
> *class* mail_item_count_deliveries_perDate(*models*.*Model*):
>
>countDeliveries = models.IntegerField(*default*=0)
>
>Date = models.DateTimeField()
>
>  
>
> this is my *views.py *
>
>  
>
> *def* jsonDeliv(*request*):
>
>  
>
>  dataset = mail_item_count_deliveries_perDate.objects.all().values_list(
> 'Date','countDeliveries')
>
>  data = *list*(dataset)
>
>  
>
>  return JsonResponse(data, *safe*=False)
>
>
> this is how the data looks like 
>
>  
>
> [["2020-05-21T00:00:00Z", 5], ["2019-05-21T00:00:00Z", 1], 
> ["2020-04-06T00:00:00Z", 3], ["2020-02-10T00:00:00Z", 2], 
> ["2020-01-23T00:00:00Z", 4],
>
>
> I want to convert the Date to milliseconds I want to use it in stock 
> highchart , and I don't know how to do it here can you guys help me please 
>
> -- 
> 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...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/de8d3e67-2a68-45be-a9c9-fb06fbb206a6%40googlegroups.com
>  
> 
> .
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9ea6d735-c752-4572-9f55-e0de4bdf3439%40googlegroups.com.


Re: EmptyDataError at /upload_reading while reading csv file using pandas

2020-05-25 Thread Jason Turner
Are you sure the file is coma delimited? This error is usually because the
file is not coma separated.

On Mon, May 25, 2020, 5:04 PM jakote lejaha  wrote:

> Ideally I would have wanted to use the "csv.reader" function, but in this
> case it becomes complicated as I would like to load the cvs file to my web
> template before I decide if I want to save it to the database or not. So I
> opt for reading the file using pandas as it's easy to display the records
> to the HTML tags. But however, I keep getting the error below.
>
>
> File "pandas\_libs\parsers.pyx", line 532, in
> pandas._libs.parsers.TextReader.__cinit__
> 
>
> Exception Type: EmptyDataError at /upload_reading
> Exception Value: No columns to parse from file
>
>
>
> How do I fix this?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/72b3aabd-3930-43ab-821f-e43bc23568e4%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADoyC17y9MA4Q5J8VZPNsbZ%3D-eShPD_iYHAtNehd%3DeKEypi48A%40mail.gmail.com.


Re: Regarding rendering templates query

2020-05-25 Thread Karthiki Chowdary
Okay I will try thankyou

On Mon, 25 May, 2020, 10:51 pm Joe Leger,  wrote:

> Where you are rendering a single image, instead use a for loop to render
> all of your images like so:
> {% for image in images %}
> 
> {% endfor %}
>
>
> On Monday, May 25, 2020 at 11:10:47 AM UTC-4, Karthiki Chowdary wrote:
>>
>> Hi,
>>
>>  I have a query in in templates i was a beginner in django and python.
>> Please help me out in this query .
>>
>> For suppose i have a buttons on client browser like SKINCARE or HAIR CARE
>> products if i click on that buttons it should display the logos of skin
>> care products or hair care products. Rendering a single image is very easy
>> if i want to render so many images how can i do that if yes with
>> dictionaries how can i do that?? is this possible to render such huge
>> amount of images or logos ?
>>
>> thanks
>>
>> Kartheeki.
>>
>> Please help me out .
>>
> --
> 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/v00ENJFujtY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/079939dd-0c8d-460a-862c-c8f5b2cf7494%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOFEE40NvXGF08KSCssOkqM45bnej40_y_66qGiYJKEEZZaPPg%40mail.gmail.com.


RES: convert Date to milliseconds

2020-05-25 Thread Samuel Nogueira
Hi! before answer you question I would recomend you to give a little fix in your model and your function names. Try to follow the PEP8 style guide for Python, in the guide is recommended using only capitalized words for naming classes with composite names, and function names should be lowercase with words separated by underscore. Thereby, would be more appropriate naming your function and class this way: class MailItemCountDeliveriesPerDate() and def json_deliv(). Fell free to accept or ignore this tip.Now, back to the question, the DateTimeField() is a implementation of the python datetime.datetime for storage in the database, so after you get the Date from the database you can use the timestamp() method in the related Date field. This will deliver the date in seconds format, then you just multiply by 1000 to get your Date in milliseconds. Hope this helps. Sorry if it got a little confusing. De: HJEnviado:segunda-feira, 25 de maio de 2020 19:17Para: Django usersAssunto: convert Date to milliseconds Hello everyone I want to convert my Date from string to milliseconds this is my models.py class  class mail_item_count_deliveries_perDate(models.Model):   countDeliveries = models.IntegerField(default=0)   Date = models.DateTimeField() this is my views.py  def jsonDeliv(request):  dataset = mail_item_count_deliveries_perDate.objects.all().values_list('Date','countDeliveries') data = list(dataset)  return JsonResponse(data, safe=False)this is how the data looks like  [["2020-05-21T00:00:00Z", 5], ["2019-05-21T00:00:00Z", 1], ["2020-04-06T00:00:00Z", 3], ["2020-02-10T00:00:00Z", 2], ["2020-01-23T00:00:00Z", 4],I want to convert the Date to milliseconds I want to use it in stock highchart , and I don't know how to do it here can you guys help me please -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/de8d3e67-2a68-45be-a9c9-fb06fbb206a6%40googlegroups.com. 



-- 
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5ecc57de.1c69fb81.bf9ff.ac87%40mx.google.com.


convert Date to milliseconds

2020-05-25 Thread HJ
Hello everyone I want to convert my Date from string to *milliseconds*

this is my *models.py class *

*class mail_item_count_deliveries_perDate(models.Model):countDeliveries 
= models.IntegerField(default=0)Date = models.DateTimeField()*

this is my *views.py *

def jsonDeliv(request):
 
 dataset = mail_item_count_deliveries_perDate.objects.all().values_list(
'Date','countDeliveries')
 data = list(dataset)
 
 return JsonResponse(data, safe=False)

this is how the data looks like 

[["2020-05-21T00:00:00Z", 5], ["2019-05-21T00:00:00Z", 1], 
["2020-04-06T00:00:00Z", 3], ["2020-02-10T00:00:00Z", 2], 
["2020-01-23T00:00:00Z", 4],


I want to convert the Date to milliseconds I want to use it in stock 
highchart , and I don't know how to do it here can you guys help me please 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/de8d3e67-2a68-45be-a9c9-fb06fbb206a6%40googlegroups.com.


EmptyDataError at /upload_reading while reading csv file using pandas

2020-05-25 Thread jakote lejaha
Ideally I would have wanted to use the "csv.reader" function, but in this 
case it becomes complicated as I would like to load the cvs file to my web 
template before I decide if I want to save it to the database or not. So I 
opt for reading the file using pandas as it's easy to display the records 
to the HTML tags. But however, I keep getting the error below. 


File "pandas\_libs\parsers.pyx", line 532, in 
pandas._libs.parsers.TextReader.__cinit__


Exception Type: EmptyDataError at /upload_reading
Exception Value: No columns to parse from file



How do I fix this?



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/72b3aabd-3930-43ab-821f-e43bc23568e4%40googlegroups.com.


Re: GeoDjango with MySQL8

2020-05-25 Thread Tim Graham
Hi, you might have better luck getting an answer on the GeoDjango mailing 
list: https://groups.google.com/forum/#!forum/geodjango

On Monday, May 25, 2020 at 11:06:26 AM UTC-4, Utkarsh Bansal wrote:
>
> I am facing problems while trying to use GeoDjango (v2.2) with MySQL 8.0.19
>
> I created a new PointField and ran makemigrations
> geo_code = PointField(srid=4326)
>
> On running sqlmigrate on the generated migration - I notice that the 
> column does not have a SRID constrain
> BEGIN;
> --
> -- Create model Location
> --
> CREATE TABLE `locations_location` (`id` integer AUTO_INCREMENT NOT NULL 
> PRIMARY KEY, `geo_code` POINT NOT NULL);
> CREATE SPATIAL INDEX `locations_location_geo_code_id` ON 
> `locations_location`(`geo_code`);
> COMMIT;
>
> Now anything I add to the column is saved with SRID 0, which is incorrect.
>
> Next, I tried creating the column with the correct SRID by using 
> migrations.SeparateDatabaseAndState to generate the column.
> ALTER TABLE backend_userprofile ADD COLUMN geocode_point POINT NULL SRID 
> 4326;
>
> Now if I try to insert data in this new column, I get and error because 
> Django is still trying to insert with SRID 0 and MySQL does not allow that
> django.db.utils.OperationalError: (3643, "The SRID of the geometry does 
> not match the SRID of the column 'geo_code'. The SRID of the geometry is 0, 
> but the SRID of the column is 4326. Consider changing the SRID of the 
> geometry or the SRID property of the column.")
>
> Is there a way to make Django use correct SRIDs with MySQL? I also found a 
> ticket on the issue tracker which seems related 
> https://code.djangoproject.com/ticket/27464
>
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c9d4a387-de7e-42d5-897f-88cbd540fc1d%40googlegroups.com.


Re: function model which generate a code for model field

2020-05-25 Thread Anselme SERI
hello,
I am trying to create a function which will recover the last id of my model
which I will increment and add to a character string, and I would like to
add this new value (x = last id incremented + string) be added to the
"code" field "of my model when I make a new recording.
How else could we use the id field which automatically increments to
perform such an action?

Anselme S.

Le dim. 24 mai 2020 à 20:12, Kasper Laudrup  a
écrit :

> Hi Anselme,
>
> On 24/05/2020 17.48, Anselme SERI wrote:
> >
> > I try  to to write a correct function for my model which  generate a str
> > + incremental number according last id model.
> >
>
> Your code is obviously wrong for quite a few reasons, but I at least
> simply cannot understand what you are trying to achieve.
>
> What should the "correct function" do?
>
> The id field of a model is already incremental. Do you simply want to
> append that to a string and what do you want to do with that string?
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/65ffe493-1190-619a-f904-fbe35b60e3e3%40stacktrace.dk
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACbA33p-1tYWbECsa9j7R82%3DAwTQBNOGuYvMcpmUHb0GPrfQDA%40mail.gmail.com.


Re: Django select list

2020-05-25 Thread Luqman Shofuleji
Little adjustment,


$.ajax({
url: '{% url "" %}',
data: {
'x': ,
},
dataType: 'json',
success: function (data) {
if (data.added_item) {
item = ""
 + data.added_item + "";
$("#selectListID").append(item);
}
}
});



On Mon, May 25, 2020 at 7:56 PM Luqman Shofuleji 
wrote:

> Yes that's possible since you are using Ajax. It should be something like
> this:
>
> $.ajax({
> url: '{% url "" %}',
> data: {
> 'x': ,
> },
> dataType: 'json',
> success: function (data) {
> if (data.added_item) {
> item = data.added_item
> $("#selectListID").append(item);
>
> }
> }
> });
>
>
>
>
>
> On Mon, May 25, 2020, 4:12 PM Sherif Adigun 
> wrote:
>
>> I have a form which has a select field (your color). In front of the
>> select field, I have a button that produces a popup which allows users to
>> create new color before they submit. I am submitting that color form via
>> Ajax. After adding a new color to the database, the popup closes.
>> I want the newly added color to show in the select list without reloading
>> the page.
>>
>> Is this possible?
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/9f176d90-93e3-40f8-b02f-4d27b6b55a75%40googlegroups.com
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHyB84pUQW48GvSL%2BHdQ3hzVRW9Bh4a6wtA0Tprz0bPkHXns_A%40mail.gmail.com.


Re: Django select list

2020-05-25 Thread Luqman Shofuleji
Yes that's possible since you are using Ajax. It should be something like
this:

$.ajax({
url: '{% url "" %}',
data: {
'x': ,
},
dataType: 'json',
success: function (data) {
if (data.added_item) {
item = data.added_item
$("#selectListID").append(item);

}
}
});





On Mon, May 25, 2020, 4:12 PM Sherif Adigun  wrote:

> I have a form which has a select field (your color). In front of the
> select field, I have a button that produces a popup which allows users to
> create new color before they submit. I am submitting that color form via
> Ajax. After adding a new color to the database, the popup closes.
> I want the newly added color to show in the select list without reloading
> the page.
>
> Is this possible?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9f176d90-93e3-40f8-b02f-4d27b6b55a75%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHyB84oZYZPeaokwWduQDJsnVXxSE4HYumAMGw1%3DgmVTPgyhWA%40mail.gmail.com.


Re: Regarding rendering templates query

2020-05-25 Thread Joe Leger
Where you are rendering a single image, instead use a for loop to render 
all of your images like so:
{% for image in images %}

{% endfor %}


On Monday, May 25, 2020 at 11:10:47 AM UTC-4, Karthiki Chowdary wrote:
>
> Hi,
>  
>  I have a query in in templates i was a beginner in django and python. 
> Please help me out in this query .
>  
> For suppose i have a buttons on client browser like SKINCARE or HAIR CARE 
> products if i click on that buttons it should display the logos of skin 
> care products or hair care products. Rendering a single image is very easy 
> if i want to render so many images how can i do that if yes with 
> dictionaries how can i do that?? is this possible to render such huge 
> amount of images or logos ?
>
> thanks 
>
> Kartheeki. 
>
> Please help me out .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/079939dd-0c8d-460a-862c-c8f5b2cf7494%40googlegroups.com.


Regarding rendering templates query

2020-05-25 Thread Karthiki Chowdary
Hi,
 
 I have a query in in templates i was a beginner in django and python. 
Please help me out in this query .
 
For suppose i have a buttons on client browser like SKINCARE or HAIR CARE 
products if i click on that buttons it should display the logos of skin 
care products or hair care products. Rendering a single image is very easy 
if i want to render so many images how can i do that if yes with 
dictionaries how can i do that?? is this possible to render such huge 
amount of images or logos ?

thanks 

Kartheeki. 

Please help me out .

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ed7f5ca1-36cc-471a-8f78-614e738cd772%40googlegroups.com.


Django select list

2020-05-25 Thread Sherif Adigun
I have a form which has a select field (your color). In front of the select 
field, I have a button that produces a popup which allows users to create new 
color before they submit. I am submitting that color form via Ajax. After 
adding a new color to the database, the popup closes.
I want the newly added color to show in the select list without reloading the 
page.

Is this possible? 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9f176d90-93e3-40f8-b02f-4d27b6b55a75%40googlegroups.com.


GeoDjango with MySQL8

2020-05-25 Thread Utkarsh Bansal
I am facing problems while trying to use GeoDjango (v2.2) with MySQL 8.0.19

I created a new PointField and ran makemigrations
geo_code = PointField(srid=4326)

On running sqlmigrate on the generated migration - I notice that the column 
does not have a SRID constrain
BEGIN;
--
-- Create model Location
--
CREATE TABLE `locations_location` (`id` integer AUTO_INCREMENT NOT NULL 
PRIMARY KEY, `geo_code` POINT NOT NULL);
CREATE SPATIAL INDEX `locations_location_geo_code_id` ON 
`locations_location`(`geo_code`);
COMMIT;

Now anything I add to the column is saved with SRID 0, which is incorrect.

Next, I tried creating the column with the correct SRID by using 
migrations.SeparateDatabaseAndState to generate the column.
ALTER TABLE backend_userprofile ADD COLUMN geocode_point POINT NULL SRID 
4326;

Now if I try to insert data in this new column, I get and error because 
Django is still trying to insert with SRID 0 and MySQL does not allow that
django.db.utils.OperationalError: (3643, "The SRID of the geometry does not 
match the SRID of the column 'geo_code'. The SRID of the geometry is 0, but 
the SRID of the column is 4326. Consider changing the SRID of the geometry 
or the SRID property of the column.")

Is there a way to make Django use correct SRIDs with MySQL? I also found a 
ticket on the issue tracker which seems related 
https://code.djangoproject.com/ticket/27464



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4765854e-2ea8-4c51-a54f-667985688412%40googlegroups.com.


Regarding redering data in html templates

2020-05-25 Thread Karthiki Chowdary
Hi i was beginner in django and i have a small query in templates. 
For suppose in the home page of any client browser if we have a button like 
SKINCARE or HEALTH CARE and if we click on that buttons we need to get the 
data of all skin care products companies logos/ health care companies 
logos. For that how i can render data in dictionaries suppose i want to 
render a static data how can i or i want or render a dynamic data how can i 
do that with dictionaries so other better option. Please help me out in this

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f2306e60-f48f-4e47-959c-763e9659182b%40googlegroups.com.


SRID issues with GeoDjango on MySQL 8

2020-05-25 Thread Utkarsh Bansal
GeoDjango is not respecting SRIDs with MySQL 8.


I created a new column

geo_code = PointField(srid=4326)

and ran makemigrations. Running sqlmigrate on the generated migration gives


BEGIN;
--
-- Create model Location
--
CREATE TABLE `locations_location` (`id` integer AUTO_INCREMENT NOT NULL 
PRIMARY KEY, `geo_code` POINT NOT NULL);
CREATE SPATIAL INDEX `locations_location_geo_code_id` ON 
`locations_location`(`geo_code`);
COMMIT;


See how the SRID was ignored.

Now anything I add to this column is using SRID 0 - which is incorrect. I 
get wrong results if I use the `ST_DISTANCE` function with SRID 0.

 
I tried using `migrations.SeparateDatabaseAndState` to create the column 
with the correct SRID constraint with the following SQL

ALTER TABLE backend_userprofile ADD COLUMN geocode_point POINT NULL SRID 
4326;


Now if I try inserting data into this column I get the following error

django.db.utils.OperationalError: (3643, "The SRID of the geometry does not 
match the SRID of the
column 'geocode_point'. The SRID of the geometry is 0, but the SRID of the 
column is 4326. 
Consider changing the SRID of the geometry or the SRID property of the 
column.")


Django is still trying to insert data with SRID 0 and MySQL raises and 
error because the column has a constrain on SRID.

Is there a way to make Django work with correct SRIDs?


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c36ebcd-8618-4357-a88f-5d29ca2ddf49%40googlegroups.com.


Re: What is considered copyright when it comes to building a website?

2020-05-25 Thread David Swarbrick
Copyright varies a little from jurisdition to jurisdiction.
The essence of it is that copyright arises automatically when a person
records a creative element. Nothing more is required. Copyright opeates
then to give to the creator the right to control the making of copies of
that creation.

Necessarily on the web, an implied licence is given so that the computers
of visitors to a site copy all sort of files in order to make the web page
visible. That is an implied licence, but the licence need go no further
than that.

To copy and then amend is in essence a breach of copyright.

Much of this is dealt with in different ways by the assorted licensing
systems.


David Swarbrick da...@swarb.co.uk - dsw...@gmail.com - swarb.co.uk Tel 0795
457 9992 / +44(0)1484 380326



On Mon, 25 May 2020 at 00:30, Adam Scerra  wrote:

> I understand that many CSS style sheets are passed around and shared
> frequently across the web. My question is when does leveraging someone
> else's web page code become illegal?
>
> Example here is:
> Finding a website that I would like to emulate.
> Copying their HTML files and CSS files.
> Editing the HTML file to replace their content with my content
> Leaving the CSS files exactly as they are since I like the style and
> format of the page.
>
> Is this copyright and is it illegal?
>
> If it is at what point does the problem arise, and how would you best
> recommend I go about this if I am a beginner?
>
> Thank you all for your time!
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bc099c5c-637b-4c17-9e18-031d0039eb99%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADqNiN1khECTZfrYa8guaqMVDf7u5tPBv6Sfa6sbXboeY4BEEw%40mail.gmail.com.


Re: JSON file

2020-05-25 Thread Derek
I am not sure about the field names part, but you could probably create 
that manually very easily.

For the data section, you need a list of lists, which you can get from code 
like:

import json
data_ready_for_json = 
list(mail_item_count_deliveries_perDate.objects.values_list('countDeliveries','Dates'))
json_string = json.dumps(data_ready_for_json)

(P.S. you may want to consider giving your classes more Python-like names 
e.g. class MailDelivery )


On Friday, 22 May 2020 19:48:36 UTC+2, HJ wrote:
>
> hello django users hope you are doing well 
>
> I want to do a highchart using a json file , and that's the problem I am 
> facing , I want to create a json file in my views.py based on my columns 
> below "countDeliveries"and "Dates"
>
> class mail_item_count_deliveries_perDate(models.Model):
>countDeliveries = models.IntegerField(default=0)
>Dates = models.DateTimeField()
>
>
> myJSON file should be something like that:
>  
>
> [
> [
> Dates,
> countDeliveries
> ],
> [
> 116769600,
> 5
> ],
>
>
>  
> - can you guys help me out 
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/19830969-d813-4e51-9016-b9b820945b92%40googlegroups.com.


403 serving static files

2020-05-25 Thread みやうち`
Hi,

I'm trying to serve static files using nginx, but nginx gives following 
error.
- [error] 8202#8202: *10 open() "/home/user/myproject/media/xxx.jpg" failed 
(13: Permission denied)

I've tried giving all users permission to this directory and it didn't 
change.
What is the cause?

I'm using mod_wsgi 4.7.1 and apache 2.4.
my apache setting is here.

WSGIPythonHome /home/user/mypythonenv
WSGIScriptAlias / /home/user/myproject/myproject/wsgi.py
WSGIPythonPath 
/home/user/myproject/myproject:/home/user/mypythonenv/lib/python3.6/site-packages
WSGIApplicationGroup %{GLOBAL}


 
  Require all granted
 


Alias /static/ /home/user/myproject/collected_static/

 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted


Alias /media/ /home/user/myproject/media/

 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23624e5b-2701-45fb-9672-c179cb979403%40googlegroups.com.


Re: Database audit fields in Django

2020-05-25 Thread Derek
There are many things available "by default" in other frameworks; but 
Django has chose to keep the core focused on doing key things well (I won't 
say "simple").  For everything else, the plugin/app approach can be used to 
support your project's specific needs.

So "auditing" is actually a complex issue and no one person or organisation 
will define this the same way.  However, there are some good apps out there 
that might support at least some of what you need; for example:

https://github.com/treyhunner/django-simple-history

https://github.com/jjkester/django-auditlog

I'd look at those before considering writing any code yourself.
 

On Friday, 22 May 2020 23:40:02 UTC+2, Sujata Aghor wrote:
>
> I am looking to create a database audit fields such as 'created by' , ' 
> modified by', 'created on time', ' modified on time' and Archive table 
> where i can see the changes over the time about perticular row.
>
> this was possible in web2py automatically. Does anyone knows any such 
> thing exist in Django?
> Any idea will be a gr8 help.
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54620e24-43d5-4609-9198-92db29ee53a4%40googlegroups.com.