DB queries in django scripts

2019-04-09 Thread Web Architect
Hi,

We have a Django 1.11 based ecommerce web site. 

We use django management scripts and django extension of runscript heavily 
for DB operations - running under cron. 

There's a tool - django-debugtoolbar to check the DB queries on the web. 
But is there a tool to monitor/check the DB queries for scripts? This would 
be really helpful in our script optimisation.

Looking forward to the info.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/904bf95e-4fff-40e1-88af-19c62994e1b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Set user permission via python

2019-04-09 Thread matt
Hi,

I'm trying to set a permission for a user that I'm creating with a python 
script. I've tested and found that the codename for the permission is 
"display_data.settings" using the following:

python manage.py shell
from django.contrib.auth.models import User
user_name = User.objects.get(username="user_name")
user_name.get_all_permissions()
set([u'display_data.settings']) 


I'm trying to set this permission for the user with the following:

from django.contrib.auth import get_user_model
from django.contrib.auth.models import User, Permission

User = get_user_model()

#check to see if user exists, create it if it doesn't
User.objects.filter(username="user_name").exists() or\
User.objects.create_user(username='user_name', 
email='usern...@example.com', password='blah')
 

#add permissions to user
u = User.objects.get(username="user_name")
permission = Permission.objects.get(name='display_data.settings')
u.user_permissions.add(permission)

 
When I run this, I get the following error:


django.contrib.auth.models.DoesNotExist: Permission matching query does not 
exist.


Can anybody tell me what I'm missing? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c039cb7b-fd33-4b41-9e2a-b94e3f2d628f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.2 and custom media in the admin

2019-04-09 Thread Simon Charette
Hello Thorsten, this is a change document in the 2.2 release notes[0].

There's even a resolution example for a django.jQuery dependency like you 
have

> For example, widgets depending on django.jQuery must specify
> js=['admin/js/jquery.init.js', ...] when declaring form media assets. [1]

Cheers,
Simon

[0] 
https://docs.djangoproject.com/en/2.2/releases/2.2/#merging-of-form-media-assets
[1] 
https://docs.djangoproject.com/en/2.2/topics/forms/media/#assets-as-a-static-definition

Le mardi 9 avril 2019 11:02:35 UTC-4, Thorsten Sanders a écrit :
>
> Hello,
>
> I insert a custom javascript inside the admin and do use the 
> "django.jquery" this worked fine until updating to Django 2.2.
>
> With 2.2 the order in which the javascripts are loaded changed and the 
> jquery.init.js is now loaded after my custom javascript, is that considered 
> a bug or a change?
>
> Regards,
> Thorsten
>

-- 
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/018ab123-2b22-4425-bb6d-efeb1c4f12cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: fesherstructural error

2019-04-09 Thread Julio Cojom
If you're using virtualenv, then u need to activate before running
manage.py, to activate, use workon .

Maybe you only installed Django in your virtualenv and not in your system.

Regards!

El mar., 9 abr. 2019 a las 13:20, sachin thakur (<
sachin.thakur9...@gmail.com>) escribió:

> Create your virtual machine  in any or directory
>
>
>  Then install the django in that virtual machine n create your project
>
> Regards
> Sachin Thakur
>
> On Wed 10 Apr, 2019, 12:47 AM Joseph Jones,  wrote:
>
>> Hello fellow Django community members,
>> I seem to be having quite a bit of trouble fixing my error in calling the
>> manage.py directory in my project. I've received of a hint in that my code
>> launcher  indicates that "Django is not importable into this environment"
>> so it would appear as well as the error in the structure I have made an
>> additional error to give an picture of the structure of my project. it is
>> C:/users/Joseph
>> C:/users/Joseph/Anaconda3
>> C:/users/Joseph/Anaconda3 /lib
>> C:/users/Joseph/Anaconda3 /lib/site-packages
>> Any advice on the step I seem to be missing would be  appreciated. Thank
>> you, 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/CAJGsC5Oy9HdXqHSe4qj2mShPjktyV2GsM2rY9qsQ4NZeKw_g8g%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BLmcYtMi3wsgGVtDpDmV19bAUJHDS3TNfX5Z5gyQgELAsy8xw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: fesherstructural error

2019-04-09 Thread sachin thakur
Create your virtual machine  in any or directory


 Then install the django in that virtual machine n create your project

Regards
Sachin Thakur

On Wed 10 Apr, 2019, 12:47 AM Joseph Jones,  wrote:

> Hello fellow Django community members,
> I seem to be having quite a bit of trouble fixing my error in calling the
> manage.py directory in my project. I've received of a hint in that my code
> launcher  indicates that "Django is not importable into this environment"
> so it would appear as well as the error in the structure I have made an
> additional error to give an picture of the structure of my project. it is
> C:/users/Joseph
> C:/users/Joseph/Anaconda3
> C:/users/Joseph/Anaconda3 /lib
> C:/users/Joseph/Anaconda3 /lib/site-packages
> Any advice on the step I seem to be missing would be  appreciated. Thank
> you, 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/CAJGsC5Oy9HdXqHSe4qj2mShPjktyV2GsM2rY9qsQ4NZeKw_g8g%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


fesherstructural error

2019-04-09 Thread Joseph Jones
Hello fellow Django community members,
I seem to be having quite a bit of trouble fixing my error in calling the
manage.py directory in my project. I've received of a hint in that my code
launcher  indicates that "Django is not importable into this environment"
so it would appear as well as the error in the structure I have made an
additional error to give an picture of the structure of my project. it is
C:/users/Joseph
C:/users/Joseph/Anaconda3
C:/users/Joseph/Anaconda3 /lib
C:/users/Joseph/Anaconda3 /lib/site-packages
Any advice on the step I seem to be missing would be  appreciated. Thank
you, 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/CAJGsC5Oy9HdXqHSe4qj2mShPjktyV2GsM2rY9qsQ4NZeKw_g8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic display views / DetailView

2019-04-09 Thread Sithembewena L. Dube
The slug must be descriptive of the record. It is often derived from a
value such as a blog title. A good slug is useful for SEO purposes as it
can contain descriptive keywords.

I just sent more reading on slugs from the official Django docs.

Kind regards,
Sithu


*Sent with Shift
*

On Tue, Apr 9, 2019 at 8:51 PM John  wrote:

> Hello maybe someone could help me, Im working on an example similar to the
> DetailView for Generic Display Views
>
>
> https://docs.djangoproject.com/en/2.2/ref/class-based-views/generic-display/#detailview
>
> In the example below taken from the djangoproject website Im stuck as to
> what url I should be visiting in the browser to view this? What replaces
>  in the browser?
>
> *Example myapp/urls.py*:
>
> from django.urls import path
> from article.views import ArticleDetailView
> urlpatterns = [
> path('/', ArticleDetailView.as_view(), name='article-detail'),]
>
> Many thanks :)
>
> John
>
> --
> 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/60259376-A376-4D4B-8F12-8D506C43C8AB%40gmail.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/CAH-SnCDC9VNJfV9no41%2BLNvsor64wUi%3DEOOfywizOqhofk1YEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic display views / DetailView

2019-04-09 Thread Sithembewena L. Dube
The slug would be the part of the url that points to a specific blog entry
or article.

https://docs.djangoproject.com/en/2.2/glossary/#term-slug
https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.SlugField

Kind regards,
Sithu


*Sent with Shift
*

On Tue, Apr 9, 2019 at 8:51 PM John  wrote:

> Hello maybe someone could help me, Im working on an example similar to the
> DetailView for Generic Display Views
>
>
> https://docs.djangoproject.com/en/2.2/ref/class-based-views/generic-display/#detailview
>
> In the example below taken from the djangoproject website Im stuck as to
> what url I should be visiting in the browser to view this? What replaces
>  in the browser?
>
> *Example myapp/urls.py*:
>
> from django.urls import path
> from article.views import ArticleDetailView
> urlpatterns = [
> path('/', ArticleDetailView.as_view(), name='article-detail'),]
>
> Many thanks :)
>
> John
>
> --
> 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/60259376-A376-4D4B-8F12-8D506C43C8AB%40gmail.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/CAH-SnCC3E0WBaPp5_qxbs1Juo7ddhQoMOcfi1axuixjcP4RwcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Generic display views / DetailView

2019-04-09 Thread John
Hello maybe someone could help me, Im working on an example similar to the 
DetailView for Generic Display Views

https://docs.djangoproject.com/en/2.2/ref/class-based-views/generic-display/#detailview
 

In the example below taken from the djangoproject website Im stuck as to what 
url I should be visiting in the browser to view this? What replaces  
in the browser?

Example myapp/urls.py:

from django.urls import path

from article.views import ArticleDetailView

urlpatterns = [
path('/', ArticleDetailView.as_view(), name='article-detail'),
]
Many thanks :)

John 

-- 
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/60259376-A376-4D4B-8F12-8D506C43C8AB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I have created a Django App, How to create a Django App Launcher?

2019-04-09 Thread Test Bot
The issue here is you have a web app and you expect a desktop application.
This should be asked on a GUI-Framework mailing list.

You can call your APIs from that desktop app instead of writing the same
code again(DRY).

On Tue, Apr 9, 2019, 8:42 PM Julio Cojom  wrote:

> Django Is a web application, I guess if you create a shortcut of your
> browser with the URL of your app, that will be fine. Even you can change
> the icon to make a distinction between your app and the real browser.
>
>
> If you want to those scripts run every n hours or minutes to maintain your
> app feed , then create a crontab :)
>
>
>
> On Tue, Apr 9, 2019, 9:02 AM jaidev joshi  wrote:
>
>>
>> Hello all,
>>
>>
>> I have created a Django application, specifically, a dashboard
>> application, python scripts that collect data from sensors running in the
>> background will feed that data to Django app for live data plotting.
>>
>> I want to build this application in a more user-friendly way, and rather
>> launching it with the help of terminal I want to create an Icon on Desktop
>> by clicking that icon one can start this dashboard application to manage
>> sensor related data.
>>
>> Please suggest me a way through which I can do it.
>>
>> Thanks.
>>
>>
>> Jay
>>
>> --
>> 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/a9c28f8f-c28e-4268-87d3-afe7ccded5bc%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/CAHRQUH%3D%2BD331Q7EQxh%3DNshBUpMk1sGDLCBX2rbk04R2O7%2BheDw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to run ORM commands in Javascript DOM?

2019-04-09 Thread Ing.Daniel Bojorge
[image: image.png]

https://debsconsultores.blogspot.com/2019/04/ventanas-modales-con-django-usando.html


I hope be useful for you.  In this tutorial (in spanish) I work with
bootstrap modal window.  May be give you ideas.

Dios L@s Bendiga

Saludos,



[image: --]

daniel.bojorge
[image: http://]about.me/daniel.bojorge

 *Curso Desarrollo Web con Python usando Django 2.1 Para Principiantes*

*WebService RestFul API con Python usando Django RestFrameWork*

*Fácil Replicación de Cualquier Base de Datos y/o Sistema Operativo*

*Programación en Capas (Web y Escritorio)* 
Mi Blog 
Nicaragua

"Si ustedes permanecen unidos a mí, y si permanecen fieles a mis
enseñanzas, pidan lo que quieran y se les dará.
(Juan 15:7 DHH)
Bendito el varón que se fía en el SEÑOR, y cuya confianza es el SEÑOR.
(Jeremías 17:7 RV2000)



El mar., 9 abr. 2019 a las 9:02, sairanganadh Narayana (<
ssaaii4...@gmail.com>) escribió:

> I am trying to run model.objects.filter(id=2) through javascript and show
> results in popup. I am unable to find the solution. Please guide me with
> solution or any alternative to get this.
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d949ec4b-9caa-42ac-8c63-50a9315a9cfc%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/CAMQeQjaGtQpttu2ixwMYtCAepmyGPp74L-P2Xus23S6G%2BtjjfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Server Error (500)

2019-04-09 Thread Julio Cojom
If it's development servers or localhost , allow DEBUG=True, that will help
you a lot every time that you found this issues.

Assuming that you use git, if you use localhost before push your changes,
then the shell where you run "manage.py runserver" will show you specific
data about your problem.


On Tue, Apr 9, 2019, 4:46 AM tribhuvan kishor 
wrote:

> first of all, allow debugging that will help you to show server errors and
> their specific reasons.
> setting.py
> DEBUG=true
> then run make migration command
> python manage makemigrations
> then migrate the model
> by using
> python manage migrate
> then let us know if there is any error
>
>
> On Tue, Apr 9, 2019 at 3:14 AM Roger Gammans 
> wrote:
>
>> Did you run 'python manage.py migrate' ?
>>
>> Did it come back with any errors?
>>
>> I ask because specifying price field for values up to 10^9998 strikes me
>> as extreme an likely to causes problems; perhaps you meant max_digits=7 not
>> 1 .
>>
>>
>> On Mon, 2019-04-08 at 04:26 -0700, fazal rehman wrote:
>>
>> Hello,
>> I am a beginner in django.I am getting Server error(500) whenever I am
>> trying to open the server have made some objects, I can see them but when i
>> am trying to open it I get error 500. I have one DEBUG=false.I have
>> attached models.py and settings.py.
>>
>> --
>> 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/922704da-519c-4503-8753-a631949ba9a7%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/1554727878.3451.6.camel%40gammascience.co.uk
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> regards
> Tribhuvan Kishor Bhaskar
>
> --
> 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/CACiphSUVyUOQ0G-td6gMXfks5X0U5vPHP4PuCGA_YH-3%2Bvsy-g%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to run ORM commands in Javascript DOM?

2019-04-09 Thread Shashank Singh
Get the data in the current screen before opening the popup or hit a ajax
request to the server to get the said data.

On Tue, 9 Apr, 2019, 8:32 PM sairanganadh Narayana, 
wrote:

> I am trying to run model.objects.filter(id=2) through javascript and show
> results in popup. I am unable to find the solution. Please guide me with
> solution or any alternative to get this.
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d949ec4b-9caa-42ac-8c63-50a9315a9cfc%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/CAD-d1sZ%2BH1t2woWw79hA%3DnUK9%3DE51Pti8FhCej9Ne%3D5vzGGcaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I have created a Django App, How to create a Django App Launcher?

2019-04-09 Thread Julio Cojom
Django Is a web application, I guess if you create a shortcut of your
browser with the URL of your app, that will be fine. Even you can change
the icon to make a distinction between your app and the real browser.


If you want to those scripts run every n hours or minutes to maintain your
app feed , then create a crontab :)



On Tue, Apr 9, 2019, 9:02 AM jaidev joshi  wrote:

>
> Hello all,
>
>
> I have created a Django application, specifically, a dashboard
> application, python scripts that collect data from sensors running in the
> background will feed that data to Django app for live data plotting.
>
> I want to build this application in a more user-friendly way, and rather
> launching it with the help of terminal I want to create an Icon on Desktop
> by clicking that icon one can start this dashboard application to manage
> sensor related data.
>
> Please suggest me a way through which I can do it.
>
> Thanks.
>
>
> Jay
>
> --
> 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/a9c28f8f-c28e-4268-87d3-afe7ccded5bc%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/CAHRQUH%3D%2BD331Q7EQxh%3DNshBUpMk1sGDLCBX2rbk04R2O7%2BheDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


I have created a Django App, How to create a Django App Launcher?

2019-04-09 Thread jaidev joshi



Hello all, 


I have created a Django application, specifically, a dashboard application, 
python scripts that collect data from sensors running in the background 
will feed that data to Django app for live data plotting.

I want to build this application in a more user-friendly way, and rather 
launching it with the help of terminal I want to create an Icon on Desktop 
by clicking that icon one can start this dashboard application to manage 
sensor related data.

Please suggest me a way through which I can do it.

Thanks.


Jay

-- 
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/a9c28f8f-c28e-4268-87d3-afe7ccded5bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to run ORM commands in Javascript DOM?

2019-04-09 Thread sairanganadh Narayana
I am trying to run model.objects.filter(id=2) through javascript and show 
results in popup. I am unable to find the solution. Please guide me with 
solution or any alternative to get this. 

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d949ec4b-9caa-42ac-8c63-50a9315a9cfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 2.2 and custom media in the admin

2019-04-09 Thread Thorsten Sanders
Hello,

I insert a custom javascript inside the admin and do use the 
"django.jquery" this worked fine until updating to Django 2.2.

With 2.2 the order in which the javascripts are loaded changed and the 
jquery.init.js is now loaded after my custom javascript, is that considered 
a bug or a change?

Regards,
Thorsten

-- 
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/0265b762-fc32-4e5a-beb2-efa98b3d02c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Update many to many django

2019-04-09 Thread Luis Zárate
Vamos a ver si entiendo ya que sus modelos no describen una relacion many
to many, voy a intentar decirlo con palabras y luego con código.

Un articulo puede tener varios articulos consolidados y un articulo
consolidado puede estar asociado a varios articulos.

Si esto es así sus modelos no representan eso.

Podrias pensar en algo como

Class Articulo:
   ...
   consolidados = models.ManyToManyField(Articulo_consolidado)

Ahora si lo que quieres es hacer una es insertar en la relación puedes
hacer algo como

articulo = Articulo(...)
articulo.save()
articulo.consolidados.add(instancia de articulo consolidado)

Saludos



El lunes, 8 de abril de 2019, Tatiana Mesa 
escribió:
> Hola Luis, eres muy amable en responderme tan rápido, mi pregunta puntual
es de que manera puedo hacer un update en una tabla de muchos a muchos.
>
> Estos son mis dos modelos
>
> class Articulo(models.Model):
> titulo = models.CharField(max_length=255, blank=True)
> texto = models.TextField()
> url = models.CharField(max_length=255)
> fuente = models.ForeignKey(Fuente, on_delete=models.CASCADE) #
> fecha = models.DateTimeField(null=True)
> created_at = models.DateTimeField(auto_now_add=True, auto_now=False,
verbose_name=u'Fecha de creación')
> ubicacion = models.CharField(max_length=255)
> tipo_facebook = models.CharField(max_length=255)
> id_articulo_facebook = models.CharField(max_length=255,blank=True,
null=True)
> 
>
> class Articulo_Consolidacion(models.Model):
> articulo =  models.ForeignKey(Articulo, on_delete=models.CASCADE)
> tag = models.ForeignKey(Tag, on_delete=models.CASCADE)
> tono = models.ForeignKey(Tono, on_delete=models.CASCADE)
> tema = models.ForeignKey(Tema, on_delete=models.CASCADE)
> quedo muy atenta a tu respuesta.
> Muchas gracias
>
> El lun., 8 de abr. de 2019 a la(s) 21:11, Luis Zárate (luisz...@gmail.com)
escribió:
>>
>> Hola,
>>
>> Las relaciones M2M pueden trabajarse de diferentes formas, acá está la
doc de django
>> https://docs.djangoproject.com/en/2.2/topics/db/examples/many_to_many/
>> Si lo que quieres es hacer algo rápido puedes usar un model form factory
>>
>>
https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/#modelform-factory-function
>> del  modelo que desear y luego relacionarlo con el objeto que quieras
por ejemplo
>>
>> Si lo único que necesita es relacionarlos porque los tiene ya creados
entonces puede hacer  un formulario y usar un campo como
ModelMultipleChoiceField (
https://docs.djangoproject.com/en/2.2/ref/forms/fields/#django.forms.ModelMultipleChoiceField
)
>>
>> Si puedes dar un mejor ejemplo de lo que quieres hacer le podemos ayudar
más.
>> Saludos.
>>
>>
>>
>>
>>
>> El lun., 8 abr. 2019 a las 17:40,  escribió:
>>>
>>> Hola, me gustaría saber de que manera se hace un update cuando tengo
una relación de muchos a muchos en django, apreciaría mucho sus ayudas :)
>>>
>>> --
>>> 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/64971258-aa7b-4a4b-9532-94f0272e94a3%40googlegroups.com
.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> "La utopía sirve para caminar" Fernando Birri
>>
>> <
https://ci3.googleusercontent.com/proxy/WdPtbUbeH_L4c__ddaOFaZN4KCPNu6PQbuGhVEbv2LEWA5AIuSpogax1BPPdwm7Y8d4gGqUtvXP2UyHT43Tpv7GDJ51fTZ3J_ndcwZFSnAgAF3vML7osyFtBZlU9weSVsJ1eV3K06I3nH1QnTj4L-nhYBv3uPs0zj3OzSiLW77J-VXUqalBUpU8mG3-RIUx6v6NJGxnxuDQ=s0-d-e1-ft#https://docs.google.com/uc?export=download=0B4-s_Bgz_-NSN0V3b24zU25fMW8=0B4-s_Bgz_-NSdy9OTkYzcDN6RGZITWl5amdqT3JxVnNVVSswPQ
>
>>
>> --
>> 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/CAG%2B5VyM2J5y9WrUC9YPwJ6PeH6zNboJK%3D4hAScVDFAB%2B6vsMjA%40mail.gmail.com
.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit

Re: Django REST in Docker

2019-04-09 Thread PASCUAL Eric
It seems right.

I suppose that requirements.txt contains the rest_framework package too.

You can check the image content by executing the "pip freeze" command on it 
(docker run  pip freeze). This will tell you of all the packages 
you nee are there.

Eric


From: django-users@googlegroups.com  on behalf 
of Shubham Joshi 
Sent: Tuesday, April 9, 2019 10:54
To: django-users@googlegroups.com
Subject: Re: Django REST in Docker


FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

On Tue, Apr 9, 2019 at 1:30 PM PASCUAL Eric 
mailto:eric.pasc...@cstb.fr>> wrote:
Hi,

Working in contenerized context does not change anything from other modes.

You just need to include the appropriate pip install command in the Dockerfile, 
so that all the dependencies are installed in the image. They will then 
available to your app the same way they are on you dev machine.

Could you show the content of your Dockerfile to check if there would not be 
some other problem ?

Eric


From: django-users@googlegroups.com 
mailto:django-users@googlegroups.com>> on behalf 
of Shubham Joshi mailto:shub...@tersesoft.com>>
Sent: Tuesday, April 9, 2019 07:30
To: Django users
Subject: Django REST in Docker

I had set up django in Docker, now I am trying to install pip packages , like 
rest_framework and added in installed apps too.
but it throws ModuleNotFoundError: No module named 'rest_framework' , whats the 
generic way of installing the pip packages in existing dockerized django project

--
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/656cff9e-50f9-4d5a-bafc-05eaa99778d7%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/AM0P193MB030871AA27CDB1B3923B785E8C2D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


--

Shubham Joshi
Business Developer | Terse Software
M: 8390246938


E: shub...@tersesoft.com
www.tersesoft.com
[linkedin] [github] 





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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/AM0P193MB03086659923CA5B0A3C832A98C2D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django REST in Docker

2019-04-09 Thread Alessandro Madruga Correia
You can use https://github.com/pydanny/cookiecutter-django as a start point.

On Tue, Apr 9, 2019 at 5:54 AM Shubham Joshi  wrote:

> FROM python:3
> ENV PYTHONUNBUFFERED 1
> RUN mkdir /code
> WORKDIR /code
> COPY requirements.txt /code/
> RUN pip install -r requirements.txt
> COPY . /code/
>
>
> On Tue, Apr 9, 2019 at 1:30 PM PASCUAL Eric  wrote:
>
>> Hi,
>>
>> Working in contenerized context does not change anything from other
>> modes.
>>
>> You just need to include the appropriate pip install command in the
>> Dockerfile, so that all the dependencies are installed in the image. They
>> will then available to your app the same way they are on you dev machine.
>>
>> Could you show the content of your Dockerfile to check if there would not
>> be some other problem ?
>>
>> Eric
>>
>> --
>> *From:* django-users@googlegroups.com  on
>> behalf of Shubham Joshi 
>> *Sent:* Tuesday, April 9, 2019 07:30
>> *To:* Django users
>> *Subject:* Django REST in Docker
>>
>> I had set up django in Docker, now I am trying to install pip packages ,
>> like rest_framework and added in installed apps too.
>> but it throws ModuleNotFoundError: No module named 'rest_framework' ,
>> whats the generic way of installing the pip packages in existing dockerized
>> django project
>>
>> --
>> 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/656cff9e-50f9-4d5a-bafc-05eaa99778d7%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/AM0P193MB030871AA27CDB1B3923B785E8C2D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> *Shubham Joshi*
> Business Developer | Terse Software
> M: 8390246938
>
> E: shub...@tersesoft.com 
> www.tersesoft.com
> [image: linkedin]  [image:
> github] 
>
> --
> 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/CAGJdmX63xQ1kS1z_i5MhkXS0hKkno1_fGnfx5344ShpY-aZv3Q%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
  ,= ,-_-. =.   [] Alessandro Madruga Correia
 ((_/)o o(\_))  [http://counter.li.org]   Debian User# 342751
   `-'(. .)`-'"O fanatismo é a única forma de força de vontade
   \_/acessível aos fracos." (Friedrich Nietzsche)

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


Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-04-09 Thread Simon Charette
No form validation is implemented for UniqueConstraint(condition) yet as 
that would require
a non-trivial refactor of how it's performed. It was discussed during the 
feature development[0].

I'd suggest you override you form or your model's clean() method to perform 
the validation
yourself until built-in support is added.

Submitting a new Trac ticket so we don't loose track of the issue would 
also be appreciated.

Cheers,
Simon

[0] https://github.com/django/django/pull/10796#discussion_r244216763

Le mardi 9 avril 2019 07:29:53 UTC-4, Ryan Jarvis a écrit :
>
> Hey there,
>
> I'm trying out the new UniqueConstraint functionality in Django 2.2 and 
> seem to be misunderstanding something.  When adding a Constraint to the 
> model I am getting an uncaught IntegrityError in the admin.  
> I've got the following sample code:
>
> *models.py*
>
> class Seminar(models.Model):
> seminar_id = models.CharField(max_length=255, unique=True)
> members = models.ManyToManyField(User, through='SeminarRole', 
> related_name="studies")
>
> class SeminarRole(models.Model):
> LEAD = 1  # Only 1 Lead permitted per seminar
> SUPPORT = 2
> ROLE_CHOICES = (
> (LEAD, 'Lead'),
> (SUPPORT, 'Support'),
> )
>
> user = models.ForeignKey(User, related_name='seminar_roles', 
> on_delete=models.CASCADE)
> seminar = models.ForeignKey('seminar', related_name='roles', 
> on_delete=models.CASCADE)
>
> role = models.IntegerField(choices=ROLE_CHOICES)
>
> class Meta:
> constraints = [
> models.UniqueConstraint(fields=['seminar'], 
> condition=Q(role=1), name="only_one_lead"),
> ]
>
>
>
> For the code above in the Django Admin I can successfully add a 
> SeminarRole with User1 as the Lead for SeminarA, User2 as the Lead for 
> SeminarB, and User1 as Support for SeminarB but if I try and add User2 as 
> another Lead to SeminarA it gives me an Exception.  Should I be seeing the 
> Django Admin catch this before hand?
>
> IntegrityError at /admin/study_management/seminarrole/add/
> duplicate key value violates unique constraint "only_one_lead"
> DETAIL:  Key (seminar_id)=(1) already exists.
>
>
> I'm on Django 2.2, Python 3.7 and Postgres 11.2
>
>

-- 
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/12fba4e5-7f07-4491-afb6-b969e73252da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to run ORM commands from DOM Javascript?

2019-04-09 Thread Robin Riis
in models.py you can define a 'as_json' function

def as_json(self):
return dict(
identification_number = self.id
awesome_picture = self.picture
)

in views.py:

class My_View(View):
def get(self, request):
if request.is_ajax():
q = request.GET.get('q', '')
answer = model.objects.get(pk=q)
if not answer:
this_answer = dict()
this_answer['results'] = 'did not find anything'
return JsonResponse(this_answer)
this_answer = [d.as_json() for d in answer]
return HttpResponse(json.dumps(this_answer,
content_type='application/json')
else:
this_answer = dict()
this_answer['not_allowed'] = 'you are not allowed here.'
return HttpResponse(this_answer,
content_type='application/json')

hope this helps!

Den tis 9 apr. 2019 kl 13:30 skrev sairanganadh Narayana <
ssaaii4...@gmail.com>:

> I'm trying to get run model.objects.filter(id=2) from javascript and show
> on database. I am unable to get solution for this. Please guide me solution
> for this or alternative for 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 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/569ce414-b717-4348-a688-b92904036864%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/CAPLZMbMaB%3Dus-q3X%2BHQJNuQyL-74MdjpPUDJ1Mt8wOCcPrH-_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-04-09 Thread Robin Riis
The Integrity error means that there is a row in the database with role = 1
So another row with role=1 would break the unique constraint and is not
allowed.

So either remove the unique constraint or make sure it will be unique.

Den tis 9 apr. 2019 13:29Ryan Jarvis  skrev:

> Hey there,
>
> I'm trying out the new UniqueConstraint functionality in Django 2.2 and
> seem to be misunderstanding something.  When adding a Constraint to the
> model I am getting an uncaught IntegrityError in the admin.
> I've got the following sample code:
>
> *models.py*
>
> class Seminar(models.Model):
> seminar_id = models.CharField(max_length=255, unique=True)
> members = models.ManyToManyField(User, through='SeminarRole',
> related_name="studies")
>
> class SeminarRole(models.Model):
> LEAD = 1  # Only 1 Lead permitted per seminar
> SUPPORT = 2
> ROLE_CHOICES = (
> (LEAD, 'Lead'),
> (SUPPORT, 'Support'),
> )
>
> user = models.ForeignKey(User, related_name='seminar_roles',
> on_delete=models.CASCADE)
> seminar = models.ForeignKey('seminar', related_name='roles',
> on_delete=models.CASCADE)
>
> role = models.IntegerField(choices=ROLE_CHOICES)
>
> class Meta:
> constraints = [
> models.UniqueConstraint(fields=['seminar'],
> condition=Q(role=1), name="only_one_lead"),
> ]
>
>
>
> For the code above in the Django Admin I can successfully add a
> SeminarRole with User1 as the Lead for SeminarA, User2 as the Lead for
> SeminarB, and User1 as Support for SeminarB but if I try and add User2 as
> another Lead to SeminarA it gives me an Exception.  Should I be seeing the
> Django Admin catch this before hand?
>
> IntegrityError at /admin/study_management/seminarrole/add/
> duplicate key value violates unique constraint "only_one_lead"
> DETAIL:  Key (seminar_id)=(1) already exists.
>
>
> I'm on Django 2.2, Python 3.7 and Postgres 11.2
>
> --
> 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/fb2ab520-178d-4a0c-acf7-8cb0498936e4%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/CAPLZMbPxNN%3DCa6GqjcR_kXDO_a2VyzKxgVNfTgzAdtnfhhYqgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to run ORM commands from DOM Javascript?

2019-04-09 Thread sairanganadh Narayana
I'm trying to get run model.objects.filter(id=2) from javascript and show 
on database. I am unable to get solution for this. Please guide me solution 
for this or alternative for 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 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/569ce414-b717-4348-a688-b92904036864%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom multiuser login, registration in DRF

2019-04-09 Thread mazz ahmed
Hi,
I am running celery using nohup in the background on the server but not
able to run properly. Sometimes it start a task or sometimes it skip tasks
in queue.
Thanks


On Tue, Apr 9, 2019 at 4:20 PM Shubham Joshi  wrote:

> I am developing a school website in DRF, in which admin, student teacher,
> and student are 3 users.
>
> So for admin only username and password is Okay, but for student and
> teacher, when they visit the website, they have to fill up a form which
> will be having custom fields DOb, roll no etc of respected users,
> teacher/students. once they fill up a form, they should be able to log in
> only when the registration form is approved by admin which s/he receives at
> the inbox of the email.
>
> for how I should create apps and all? any suggestions? can anyone explain?
>
> --
> 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/6d009731-e144-407b-b484-ba7e3951bf4c%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/CABuXbh_DJ3Rvpzbm4vZL-VYcbxX6NfHrtxMpXhzycXiULnyC4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


UniqueConstraint raises uncaught IntegrityError in Admin

2019-04-09 Thread Ryan Jarvis
Hey there,

I'm trying out the new UniqueConstraint functionality in Django 2.2 and 
seem to be misunderstanding something.  When adding a Constraint to the 
model I am getting an uncaught IntegrityError in the admin.  
I've got the following sample code:

*models.py*

class Seminar(models.Model):
seminar_id = models.CharField(max_length=255, unique=True)
members = models.ManyToManyField(User, through='SeminarRole', 
related_name="studies")

class SeminarRole(models.Model):
LEAD = 1  # Only 1 Lead permitted per seminar
SUPPORT = 2
ROLE_CHOICES = (
(LEAD, 'Lead'),
(SUPPORT, 'Support'),
)

user = models.ForeignKey(User, related_name='seminar_roles', 
on_delete=models.CASCADE)
seminar = models.ForeignKey('seminar', related_name='roles', 
on_delete=models.CASCADE)

role = models.IntegerField(choices=ROLE_CHOICES)

class Meta:
constraints = [
models.UniqueConstraint(fields=['seminar'], 
condition=Q(role=1), name="only_one_lead"),
]



For the code above in the Django Admin I can successfully add a SeminarRole 
with User1 as the Lead for SeminarA, User2 as the Lead for SeminarB, and 
User1 as Support for SeminarB but if I try and add User2 as another Lead to 
SeminarA it gives me an Exception.  Should I be seeing the Django Admin 
catch this before hand?

IntegrityError at /admin/study_management/seminarrole/add/
duplicate key value violates unique constraint "only_one_lead"
DETAIL:  Key (seminar_id)=(1) already exists.


I'm on Django 2.2, Python 3.7 and Postgres 11.2

-- 
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/fb2ab520-178d-4a0c-acf7-8cb0498936e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Feedback regarding Django-Suit for Django Admin Panel Customization - Need to add New Menu for Report Generations

2019-04-09 Thread Balaji Shetty
Dear Sir,

I am developing one web based application Django. I could understand Simple
Web application as well as entire Django Admin Panel working upto this
time.

My requirement is
I want to add new menu in existing Admin Panel. I have been searching a lot
from many days but could not get any proper solution. I got some code on
github like Django-Admin-Plus and django-Admin-Menu but when i installed on
my machine, it could not execute and giving lots of error. Any link or
video is available for this.

One solution may be view creation .

One more solution is to purchase Django Suit in around 3 to 4K rupees.
Features of Django Suit is
FEATURES


   - Modern and professional design
   - Improved list filters
   - Sorting for list and inlines
   - Menu configuration & search
   - Useful CSS/JS addons
   - Based on Twitter Bootstrap
   - Simple installation
   - No 3rd-party requirements
   - 3rd-party app support: django-cms, django-filer and others.

Single
$45
Single commercial project
Use Django Suit in one
commercial project

So can anybody suggest me the BEST solution.

-- 
*Mr. Shetty Balaji S.*

*balajishe...@gmail.com *
*9270696267*

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


Re: Caltech Pedestrian Detection Annotations

2019-04-09 Thread Balaji Shetty
Please refer kaggle web site. It contains all data set with Classification
algorithm and results also.
You may get ideas.
https://www.kaggle.com/c/state-farm-distracted-driver-detection/discussion/22018


Shetty Balaji


On Mon, Apr 8, 2019 at 4:37 PM Aakash Baranwal 
wrote:

> Hi Everybody,
>
> This is not exactly a Django related question, but I need help.
>
> I am working on a project, and I have to use Caltech Pedestrian Detection
>  data
> set. However, I am not able to get the output as desired as the files are
> in VBB format and moreover I am not able to interpret the matrix.
>
> If anyone happens to have any kind of documentation which will help in
> using the data set for training the model and correctly interpreting the
> data, or are aware how to correctly use it, please help me.
>
> I shall be extremely thankful.
>
> Thanks in advance.
>
> With Kind Regards
>
> Aakash
>
> --
> 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/CALr9hQ2hzN6NPCaV_nx0%2Bj4F6CB3N25fyzA1d3S1UfkyA5t80Q%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: bsshe...@sggs.ac.in  *
*  Mobile: +91-9270696267*

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


Is there a way to extend Django Admin to normal user/staff? If so, how?

2019-04-09 Thread Chaitanya Vankadaru
I am looking to extend Django Admin to normal user/staff? If so, how?

Please reply with your ideas/solutions.

-- 
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/f31d966f-16b2-4571-af47-c1d02467d2df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Update many to many django

2019-04-09 Thread Tatiana Mesa
Hola Luis, eres muy amable en responderme tan rápido, mi pregunta puntual
es de que manera puedo hacer un update en una tabla de muchos a muchos.


Estos son mis dos modelos


class Articulo(models.Model):
titulo = models.CharField(max_length=255, blank=True)
texto = models.TextField()
url = models.CharField(max_length=255)
fuente = models.ForeignKey(Fuente, on_delete=models.CASCADE) #
fecha = models.DateTimeField(null=True)
created_at = models.DateTimeField(auto_now_add=True, auto_now=False,
verbose_name=u'Fecha de creación')
ubicacion = models.CharField(max_length=255)
tipo_facebook = models.CharField(max_length=255)
id_articulo_facebook = models.CharField(max_length=255,blank=True,
null=True)




class Articulo_Consolidacion(models.Model):
articulo =  models.ForeignKey(Articulo, on_delete=models.CASCADE)
tag = models.ForeignKey(Tag, on_delete=models.CASCADE)
tono = models.ForeignKey(Tono, on_delete=models.CASCADE)
tema = models.ForeignKey(Tema, on_delete=models.CASCADE)

quedo muy atenta a tu respuesta.

Muchas gracias


El lun., 8 de abr. de 2019 a la(s) 21:11, Luis Zárate (luisz...@gmail.com)
escribió:

> Hola,
>
> Las relaciones M2M pueden trabajarse de diferentes formas, acá está la doc
> de django
> https://docs.djangoproject.com/en/2.2/topics/db/examples/many_to_many/
>
> Si lo que quieres es hacer algo rápido puedes usar un model form factory
>
>
> https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/#modelform-factory-function
> del  modelo que desear y luego relacionarlo con el objeto que quieras por
> ejemplo
>
> Si lo único que necesita es relacionarlos porque los tiene ya creados
> entonces puede hacer  un formulario y usar un campo como 
> ModelMultipleChoiceField
> (
> https://docs.djangoproject.com/en/2.2/ref/forms/fields/#django.forms.ModelMultipleChoiceField
> )
>
> Si puedes dar un mejor ejemplo de lo que quieres hacer le podemos ayudar
> más.
> Saludos.
>
>
>
>
>
> El lun., 8 abr. 2019 a las 17:40,  escribió:
>
>> Hola, me gustaría saber de que manera se hace un update cuando tengo una
>> relación de muchos a muchos en django, apreciaría mucho sus ayudas :)
>>
>> --
>> 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/64971258-aa7b-4a4b-9532-94f0272e94a3%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> 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/CAG%2B5VyM2J5y9WrUC9YPwJ6PeH6zNboJK%3D4hAScVDFAB%2B6vsMjA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHAr%3D_21PiVzQD%2B_q5D-ynGmYffZB4YQjAaGmGJdPeNEvhKoUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Celery running in server by nohup Isuue

2019-04-09 Thread mazz ahmed
Hi,
I am running celery using nohup in the background on the server but not
able to run properly. Sometimes it start a task or sometimes it skip tasks
in queue.
Thanks

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


Custom multiuser login, registration in DRF

2019-04-09 Thread Shubham Joshi
I am developing a school website in DRF, in which admin, student teacher, 
and student are 3 users.

So for admin only username and password is Okay, but for student and 
teacher, when they visit the website, they have to fill up a form which 
will be having custom fields DOb, roll no etc of respected users, 
teacher/students. once they fill up a form, they should be able to log in 
only when the registration form is approved by admin which s/he receives at 
the inbox of the email.

for how I should create apps and all? any suggestions? can anyone explain?

-- 
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/6d009731-e144-407b-b484-ba7e3951bf4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Server Error (500)

2019-04-09 Thread tribhuvan kishor
first of all, allow debugging that will help you to show server errors and
their specific reasons.
setting.py
DEBUG=true
then run make migration command
python manage makemigrations
then migrate the model
by using
python manage migrate
then let us know if there is any error


On Tue, Apr 9, 2019 at 3:14 AM Roger Gammans 
wrote:

> Did you run 'python manage.py migrate' ?
>
> Did it come back with any errors?
>
> I ask because specifying price field for values up to 10^9998 strikes me
> as extreme an likely to causes problems; perhaps you meant max_digits=7 not
> 1 .
>
>
> On Mon, 2019-04-08 at 04:26 -0700, fazal rehman wrote:
>
> Hello,
> I am a beginner in django.I am getting Server error(500) whenever I am
> trying to open the server have made some objects, I can see them but when i
> am trying to open it I get error 500. I have one DEBUG=false.I have
> attached models.py and settings.py.
>
> --
> 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/922704da-519c-4503-8753-a631949ba9a7%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/1554727878.3451.6.camel%40gammascience.co.uk
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
regards
Tribhuvan Kishor Bhaskar

-- 
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/CACiphSUVyUOQ0G-td6gMXfks5X0U5vPHP4PuCGA_YH-3%2Bvsy-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how do I create a slug in Django 2.2

2019-04-09 Thread Robin Riis
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super(name, self).save(*args, **kwargs)

Den tis 9 apr. 2019 12:24AMI FIDELE  skrev:

> I have tried to create a slug watch here and please tell the problem
>
> this is model.py
>
> from django.db import models
>
> # this is my models
> class Article(models.Model):
> title = models.CharField(max_length=100)
> slug = models.SlugField()
> body = models.TextField()
> date = models.DateTimeField(auto_now_add=True)
>
>
> def __str__(self):
> return self.title
> def snippet(self):
>
> return self.body[:90] + '...''
>
>
>
> --
> 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/aa159472-fb87-44aa-8da1-d1058ccecd5d%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/CAPLZMbOebd%2B_FJCpEmfdiyXzJ%3Dc4C2Kp9bvNfEWXEdfPqHSuSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migration auth.0011_update_proxy_permissions from Django 2.2 fails to apply

2019-04-09 Thread Julien Enselme
@Arpit Singh: I am in a single database setup and we don't use database
routers. As far as I know, the migration was never applied before. But from
what I understand from you answer, I can --fake it and I should be fine.

@אורי רודברג I tried to update directly from 2.0 to 2.2. Since we switched
to 2.1, I just retried to update  to 2.2 and I hit the same issue. The
error occurs in the auth_permission table.

> Also, try to install a new - either local or remote - environment with
your code and then try to upgrade Django there. There might be a problem
specific with this deployment. This exception, on which environment did you
receive it? Local or remote?

I happened in my local env. I tried to delete the venv and recreate it from
scratch but it didn't help.

I'll try to report the bug.

Thanks for you help!

Julien Enselme
Développeur chez BureauxLocaux


Le lun. 8 avr. 2019 à 13:23, Arpit Singh  a
écrit :

> Hi Julien,
>
> We faced a similar issue, thought it's probably a bug in Django but
> realised that our unique setup of multiple databases is the reason we are
> facing this issue unlike many others (except you ofcourse)
> It turned out that this data integrity issue will pop up if you run this
> migration file more than once.
> .
> So the thing to keep in mind is that a datamigration files
> (0011_update_proxy_permissions is a datamigration file) isn't associated
> with any django model, so a faulty router might make it run on all
> databases.
> We hadn't thought of this scenario in our custom django router either.
> Once we fixed our django router to run only on our target database in case
> of a migration file, this problem was resolved.
>
> For now, forward migrations in auth app are working fine. Reverse
> migrations are still broken though (something to do with apps.get_models()
> returning inconsistent results, but that's a problem for another day)
>
> P.S: It would have helped if Django had provided routers with proper hints
> though. (
> https://docs.djangoproject.com/en/2.2/howto/writing-migrations/#data-migrations-and-multiple-databases
> )
>
> On Thursday, April 4, 2019 at 4:38:04 PM UTC+5:30, Julien Enselme wrote:
>>
>> Hi,
>>
>> I am trying to update my project to Django 2.2 (we are currently on
>> 2.0.13). When I launch `python manage.py migrate`, I get this error message
>> when migration auth.0011_update_proxy_permissions is applying (full
>> stacktrace is available here ):
>> django.db.utils.IntegrityError: duplicate key value violates unique
>> constraint "idx_18141_auth_permission_content_type_id_01ab375a_uniq"
>> DETAIL:  Key (content_type_id, codename)=(12, add_agency) already exists.
>>
>> It looks like the migration is trying to re-create already existing
>> entries in the auth_permission table. At first I though it cloud because
>> we recently renamed a model. But after digging and deleting the entries
>> associated with the renamed model from our database in the
>> auth_permission table, the problem still occurs with other proxy models.
>>
>> I search for a ticket about this on the bug tracker but found nothing.
>>
>> Can someone help me on this? I guess I can keep deleting problematic
>> entries from our database one by one but it will take a long time and it
>> doesn't look right.
>>
>> Regards,
>> Julien Enselme
>>
> --
> 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/c684e1fc-5fe4-419a-8202-064a25bb5943%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/CAL%3D_h24w7b7N0J2%2B1Ym-J-jqXtVnD-PpmLpB7Hp5iOofc_XCiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how do I create a slug in Django 2.2

2019-04-09 Thread AMI FIDELE
I have tried to create a slug watch here and please tell the problem

this is model.py

from django.db import models

# this is my models
class Article(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField()
body = models.TextField()
date = models.DateTimeField(auto_now_add=True)


def __str__(self):
return self.title
def snippet(self):

return self.body[:90] + '...''

 

-- 
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/aa159472-fb87-44aa-8da1-d1058ccecd5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django REST in Docker

2019-04-09 Thread Shubham Joshi
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/


On Tue, Apr 9, 2019 at 1:30 PM PASCUAL Eric  wrote:

> Hi,
>
> Working in contenerized context does not change anything from other modes.
>
> You just need to include the appropriate pip install command in the
> Dockerfile, so that all the dependencies are installed in the image. They
> will then available to your app the same way they are on you dev machine.
>
> Could you show the content of your Dockerfile to check if there would not
> be some other problem ?
>
> Eric
>
> --
> *From:* django-users@googlegroups.com  on
> behalf of Shubham Joshi 
> *Sent:* Tuesday, April 9, 2019 07:30
> *To:* Django users
> *Subject:* Django REST in Docker
>
> I had set up django in Docker, now I am trying to install pip packages ,
> like rest_framework and added in installed apps too.
> but it throws ModuleNotFoundError: No module named 'rest_framework' ,
> whats the generic way of installing the pip packages in existing dockerized
> django project
>
> --
> 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/656cff9e-50f9-4d5a-bafc-05eaa99778d7%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/AM0P193MB030871AA27CDB1B3923B785E8C2D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Shubham Joshi*
Business Developer | Terse Software
M: 8390246938

E: shub...@tersesoft.com 
www.tersesoft.com
[image: linkedin]  [image:
github] 

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


Re: Django REST in Docker

2019-04-09 Thread PASCUAL Eric
Hi,

Working in contenerized context does not change anything from other modes.

You just need to include the appropriate pip install command in the Dockerfile, 
so that all the dependencies are installed in the image. They will then 
available to your app the same way they are on you dev machine.

Could you show the content of your Dockerfile to check if there would not be 
some other problem ?

Eric


From: django-users@googlegroups.com  on behalf 
of Shubham Joshi 
Sent: Tuesday, April 9, 2019 07:30
To: Django users
Subject: Django REST in Docker

I had set up django in Docker, now I am trying to install pip packages , like 
rest_framework and added in installed apps too.
but it throws ModuleNotFoundError: No module named 'rest_framework' , whats the 
generic way of installing the pip packages in existing dockerized django project

--
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/656cff9e-50f9-4d5a-bafc-05eaa99778d7%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/AM0P193MB030871AA27CDB1B3923B785E8C2D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: HTML form filled, proposes a download link for the data filled in a json file

2019-04-09 Thread Robin Riis
Hello!

well in the form is there anything that will be saved in a database?
if so you can start by looking at models.py in your application.

if not you can jump directly to forms.py.

an example of a model and form:

*** in models.py
from django.db import models

class Company(models.Model):
"""This is your database model with the fields you want to store and
fetch!
"""
name = models.CharField(max_length=60)
telephone = models.CharField(max_length=15, null=True, blank=True)
info = models.TextField(blank=True, null=True)
is_awesome = models.BooleanField(default=False)

*** in forms.py
from django import forms
from .models import Company

class CompanyForm(forms.ModelForm):
class Meta:
model = Company
fields = '__all__'
widgets = {
'is_awesome': forms.HiddenInput(),
}

then when you have a form and model you can use the generic views like this:

*** in views.py
from django.urls import reverse_lazy
from django.views.generic import CreateView
from django.contrib.messages.views import SuccessMessageMixin

from .models import Company
from .forms import CompanyForm

class Add_Company(SuccessMessageMixin, CreateView):
template_name = 'company/add_a_new.html'
success_message = 'a new company was added!'
success_url = reverse_lazy('home')
form_class = CompanyForm

thats it!


Den tis 9 apr. 2019 kl 00:20 skrev Bassem Boulfarkat <
bassem.boulfar...@gmail.com>:

> I am working on creating a website based on the django framework with
> python. The aim is to have a simple HTML form that will build around where
> the user fills in the form and when it is done can submit it. When
> submitted, he will have a json file downloaded.
>
> After looking around, I found that serializer would be the best way but I
> am still really confused. Would appreciate any kind of help.
>
> --
> 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/3bd76a23-e5d8-4597-8fc1-3e9f2fc7cb90%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/CAPLZMbNnCxVTa%2BXkpGHYSrwYjYPMyvfhtrsTMpkY0E_dxvT16A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[formset] ManyToMany

2019-04-09 Thread Robin Riis
if i have the following models:

class Wiggs_Filter(models.Model):
wiggs_nr = models.CharField(max_length=30, unique=True, blank=True,
null=True)
picture = models.ImageField(upload_to='filter/',
default='filter/saknas.jpg')
description = models.CharField(max_length=100, blank=True, null=True)
outer_diameter = models.CharField(max_length=25, blank=True, null=True)
inner_diameter = models.CharField(max_length=25, blank=True, null=True)
use_with = models.ManyToManyField("self", blank=True)

class Cross_Filter(models.Model):
wiggs = models.ManyToManyField(Wiggs_Filter, related_name='cross_ref')
manufacture = models.CharField(max_length=25, choices=TILLVERKARE)
name = models.CharField(max_length=25)


and i would like to be able to open a modal window in Wiggs_Filter
DetailView
with a formset to Cross_Filter but i cannot get it to work
have the following form:

class FilterCrossForm(forms.ModelForm):
class Meta:
model = Filter_Cross
fields = '__all__'

CrossFormset = forms.formset_factory(FilterCrossForm)

class AddFilterAjaxForm(forms.ModelForm):
class Meta:
model = Wiggs_Filter
exclude = ('picture', 'use_with')

and this is my DetailView:

class Wiggs_Filtret(DetailView):
template_name = 'lager/detta_filter.html'
model = Wiggs_Filter

def get_object(self):
return get_object_or_404(Wiggs_Filter,
wiggs_nr=self.kwargs['wiggs_nr'])

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['cross_options'] = self.get_cross_manufacturer()
context['cross_refs'] = self.object.cross_ref.all()
return context

def get_cross_manufacturer(self):
cross = [obj.manufacture for obj in self.object.cross_ref.all()]
return list(dict.fromkeys(cross))

any tips on how to open a bootstrap modal with the CrossFormset formset?

thanks in advance

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