[no subject]

2019-09-17 Thread Shakil Ahmmed
How to select all field but group by one field
-- 

Shakil Ahmmed
about.me/shakilahmmed


-- 
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/CA%2BEpJfzNPZ_vRqyHan92VsDY9MAjsxogKVh4FEBdwXWLd%3DHXtQ%40mail.gmail.com.


how to use sql select query with pyodbc and django ?

2019-09-17 Thread leb dev
i have a django code that connect to sql server database and i am trying to 
select values using *like *but once i try it it crash and the system 
display the below error:

('The SQL contains 0 parameter markers, but 1 parameters were supplied', 
'HY000')


views.py




from django.shortcuts import render
import pyodbc
# from .models import Artist
# Create your views here.


def connect(request):
 
conn = pyodbc.connect(
'Driver={ODBC Driver 17 for SQL Server};'
'Server=DESKTOP-LPD1575\\SQLEXPRESS;'
'Database=testDB;'
'UID=test;'
'PWD=*;'

)
query = 'jhon'
cursor = conn.cursor()
 
c = cursor.execute('SELECT * FROM Artist where artistName like "%?%"',query)
print(c)
return render (request,'connect.html',{"c":c})



connect.html
==


id
FolderNumber
Folderdate
   

{% for row in c %}
 
{{ row.0 }}
{{ row.1 }}
{{ row.2 }}


{% endfor %}


-- 
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/485f0fc0-c340-460c-aef3-00177c8a2ef7%40googlegroups.com.


Re: Raju | ITC Infotech - Looking for Backend Developers (Python/Django ORM - New York City )

2019-09-17 Thread Preetham Varanasi
Hi Raju,
I m interested but can remote possible as currently, I m in India?


Thank you
Regards
Preetham

On Wed, Sep 18, 2019 at 8:05 AM Sipum  wrote:

> Hi Raju,
>
> I m interested but can remote possible as currently I m in India?
>
> Thank you
> Regards
> Sipum
>
> On Wed, 18 Sep, 2019, 2:06 AM Raju N Somanna,  wrote:
>
>> Hi All
>>
>> I've an immediate need for Backend Developers (*Python/Django ORM* - New
>> York City) with my client in NYC. As the title suggests my team is looking
>> for Python/Django specialist, someone who is good experience on ORM.
>>
>> Please do let me know if you have any from your contacts/references who
>> might be interested in this opportunity.
>>
>> *PS: ABOUT US*
>> ITC Infotech is a Global IT Consulting Organization with $200 mil+ in
>> revenues, 8000+ resources footprint across Americas, Europe, South Africa,
>> Asia Pacific and India.
>> Presence in the US from the past 17 years, with resources working in over
>> 24 states. Our US innovation labs are in San Jose, CA and we also have
>> offices in NJ, MI, AR.
>> We have plenty of successful use cases across diversified verticals
>> including: Banking & Financial Services, Healthcare, Mfg, CPG-Retail,
>> Hi-Tech.
>> Our technology footprint encompasses: IoT, ML, AI, AR, RPA, Blockchain,
>> Big Data, Product Engineering (we own a technology agnostic DevOps
>> product), App Dev, Infra, PTC - PLM, ERP, BI, DW, Data Science…
>> We are backed by a parent company with over $50 billion market cap and
>> over 26,000 employees world-wide.
>>
>> Regards
>> Raju NS
>>  raju...@itcinfotech.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/4a35e21e-fef7-46b9-bdc5-72767c3e3196%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/CAGHZBzzY-Rx86JdSQouF%2B6y__rnFkiFDVJrP%3DDvQOsp4kNYpvQ%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/CANFgYc4_VH%2BLLNtpxH4o7ZNOkd8Q_s_40mC1r7nHWKBPNa3LoQ%40mail.gmail.com.


Re: Error while trying to connect latest Dango with MSSQL

2019-09-17 Thread 'Amitesh Sahay' via Django users
What is the error message? If the subject line you are talking about, its very 
generic. please be specific.


Regards,
Amitesh 

On Wednesday, 18 September, 2019, 02:06:03 am IST, Praveen Kumar 
 wrote:  
 
 Hi All,

Just I have updated the latest version of Dango. But now I'm getting error 
message. Please suggest me.

-- 
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/cf2ca49b-738e-457e-9d13-8a2df09a3a8f%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/329456698.7041138.1568784512666%40mail.yahoo.com.


Re: Raju | ITC Infotech - Looking for Backend Developers (Python/Django ORM - New York City )

2019-09-17 Thread Sipum
Hi Raju,

I m interested but can remote possible as currently I m in India?

Thank you
Regards
Sipum

On Wed, 18 Sep, 2019, 2:06 AM Raju N Somanna,  wrote:

> Hi All
>
> I've an immediate need for Backend Developers (*Python/Django ORM* - New
> York City) with my client in NYC. As the title suggests my team is looking
> for Python/Django specialist, someone who is good experience on ORM.
>
> Please do let me know if you have any from your contacts/references who
> might be interested in this opportunity.
>
> *PS: ABOUT US*
> ITC Infotech is a Global IT Consulting Organization with $200 mil+ in
> revenues, 8000+ resources footprint across Americas, Europe, South Africa,
> Asia Pacific and India.
> Presence in the US from the past 17 years, with resources working in over
> 24 states. Our US innovation labs are in San Jose, CA and we also have
> offices in NJ, MI, AR.
> We have plenty of successful use cases across diversified verticals
> including: Banking & Financial Services, Healthcare, Mfg, CPG-Retail,
> Hi-Tech.
> Our technology footprint encompasses: IoT, ML, AI, AR, RPA, Blockchain,
> Big Data, Product Engineering (we own a technology agnostic DevOps
> product), App Dev, Infra, PTC - PLM, ERP, BI, DW, Data Science…
> We are backed by a parent company with over $50 billion market cap and
> over 26,000 employees world-wide.
>
> Regards
> Raju NS
>  raju...@itcinfotech.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/4a35e21e-fef7-46b9-bdc5-72767c3e3196%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/CAGHZBzzY-Rx86JdSQouF%2B6y__rnFkiFDVJrP%3DDvQOsp4kNYpvQ%40mail.gmail.com.


Excluding Directories from the autoreloader

2019-09-17 Thread J.D. Corbin
Is it possible in Django>=2.2 to exclude directories (unwatch) from the 
autoreloader?

I have some python modules that are being created in the file system and 
want to be able to exclude the directories those are in so they don't 
trigger the Application to reload when in dev/debug mode.

Thanks,
J.D.

-- 
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/b89d48be-6a39-4b5b-96ed-b95b8af6381b%40googlegroups.com.


Raju | ITC Infotech - Looking for Backend Developers (Python/Django ORM - New York City )

2019-09-17 Thread Raju N Somanna
Hi All

I've an immediate need for Backend Developers (*Python/Django ORM* - New 
York City) with my client in NYC. As the title suggests my team is looking 
for Python/Django specialist, someone who is good experience on ORM. 

Please do let me know if you have any from your contacts/references who 
might be interested in this opportunity. 

*PS: ABOUT US*
ITC Infotech is a Global IT Consulting Organization with $200 mil+ in 
revenues, 8000+ resources footprint across Americas, Europe, South Africa, 
Asia Pacific and India. 
Presence in the US from the past 17 years, with resources working in over 
24 states. Our US innovation labs are in San Jose, CA and we also have 
offices in NJ, MI, AR. 
We have plenty of successful use cases across diversified verticals 
including: Banking & Financial Services, Healthcare, Mfg, CPG-Retail, 
Hi-Tech.
Our technology footprint encompasses: IoT, ML, AI, AR, RPA, Blockchain, Big 
Data, Product Engineering (we own a technology agnostic DevOps product), 
App Dev, Infra, PTC - PLM, ERP, BI, DW, Data Science…
We are backed by a parent company with over $50 billion market cap and over 
26,000 employees world-wide.

Regards
Raju NS
 raju...@itcinfotech.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/4a35e21e-fef7-46b9-bdc5-72767c3e3196%40googlegroups.com.


Error while trying to connect latest Dango with MSSQL

2019-09-17 Thread Praveen Kumar
Hi All,

Just I have updated the latest version of Dango. But now I'm getting error 
message. Please suggest me.

-- 
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/cf2ca49b-738e-457e-9d13-8a2df09a3a8f%40googlegroups.com.


Re: reg: Issue while rendering the page

2019-09-17 Thread 'Amitesh Sahay' via Django users
Below is the snippet of my project tree::





Regards,
Amitesh Sahay91-750 797 8619 

On Wednesday, 18 September, 2019, 12:58:57 am IST, Amitesh Sahay 
 wrote:  
 
 Hello Users, 
I am building an app called "SHOP". For some very wired reason I am getting 
below error:
ValueError at /shop/
The 'image' attribute has no file associated with it.
| Request Method: | GET |
| Request URL: | http://localhost:8000/shop/ |
| Django Version: | 2.2.5 |
| Exception Type: | ValueError |
| Exception Value: | The 'image' attribute has no file associated with it. |
| Exception Location: | 
/home/amitesh/PycharmProjects/myvenv/lib/python3.6/site-packages/django/db/models/fields/files.py
 in _require_file, line 38 |
| Python Executable: | /home/amitesh/PycharmProjects/myvenv/bin/python |
| Python Version: | 3.6.8 |
| Python Path: | ['/home/amitesh/PycharmProjects/perfectcushion',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/home/amitesh/PycharmProjects/myvenv/lib/python3.6/site-packages'] |
| Server time: | Tue, 17 Sep 2019 18:59:22 + |

 When I see 
the debug page further I see that my base.html is complaining, below is the 
error:
Error during template rendering

In template 
/home/amitesh/PycharmProjects/perfectcushion/SHOP/templates/base.html, error at 
line 0

The 'image' attribute has no file associated with it.

| 1 | {% load staticfiles %} |
| 2 |  |
| 3 |  |
| 4 |  |
| 5 |   |
| 6 |   |
| 7 |  {% block title %}{% endblock %} |
| 8 |  |
| 9 |  |



base.html
{% load staticfiles %}





{% block title %}{% endblock %}



{% include 'header.html' %}
{% include 'navbar.html' %}
{% block content %}
{% endblock %}

{% include 'footer.html' %}


headers.html
{% load staticfiles %}




navbar.html
{% load staticfiles %}


All Products
Your Cart()


category.html
{% extends 'base.html' %}
{% load staticfiles %}
{%  block metadescription %}
{% if category %}
{{ category.description|truncatewords:125 }}
{% else %}
Welcome to the cushion store where you can buy comfy and awesome 
cushions.
{% endif %}
{% endblock %}

{% block title %}
{% if category %}
{{ category.name }} - Perfect Cushion Store
 {% else %}
See our Cushion Collection - Perfect Cushion Store
{% endif %}
{% endblock %}

{% block content %}

{%  if category %}


Our Product 
Collection | {{ category.name }}


{% endif %}

{% if category %}





{{ category.name }}
{{ category.description }}

{% else %}

 
 
 
Our Products collection

Lorem Ipsum is simply dummy text of the printing and typesetting 
industry. Lorem Ipsum has been the industry's standard dummy text 
ever since the 1500s, when an unknown printer took a galley of type 
and.
 
{% endif %}


{% for product in products %}




{{ product.name }}
{{ product.price }}



{% endfor %}


{% endblock %}SHOP/urls.py
from django.urls import path
from . import views

app_name = 'shop'

urlpatterns = [
path('', views.allProdCat, name='allProdCat'),
path('/', views.allProdCat, name='products_by_category'),
]project/urls.py
from django.contrib import admin
from django.urls import path, include
from SHOP import views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('shop/', include('SHOP.urls')),
]

# We need to map the static and the media URLS with the below settings
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, 
document_root=settings.MEDIA_ROOT)views.py
from django.shortcuts import render, get_object_or_404
from .models import Category, Product


def allProdCat(request, c_slug=None):
c_page = None
products = None
if c_slug is not None:
c_page = get_object_or_404(Category, c_slug=c_slug)
products = Product.objects.filter(category=c_page, available=True)
else:
products = Product.objects.all().filter(available=True)
return render(request, 'shop/category.html', {'category': c_page, 
'products': products})Please help me figure out my mistake.



Regards,
Amitesh Sahay  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop r

reg: Issue while rendering the page

2019-09-17 Thread 'Amitesh Sahay' via Django users
Hello Users, 
I am building an app called "SHOP". For some very wired reason I am getting 
below error:
ValueError at /shop/
The 'image' attribute has no file associated with it.
| Request Method: | GET |
| Request URL: | http://localhost:8000/shop/ |
| Django Version: | 2.2.5 |
| Exception Type: | ValueError |
| Exception Value: | The 'image' attribute has no file associated with it. |
| Exception Location: | 
/home/amitesh/PycharmProjects/myvenv/lib/python3.6/site-packages/django/db/models/fields/files.py
 in _require_file, line 38 |
| Python Executable: | /home/amitesh/PycharmProjects/myvenv/bin/python |
| Python Version: | 3.6.8 |
| Python Path: | ['/home/amitesh/PycharmProjects/perfectcushion',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/home/amitesh/PycharmProjects/myvenv/lib/python3.6/site-packages'] |
| Server time: | Tue, 17 Sep 2019 18:59:22 + |

 When I see 
the debug page further I see that my base.html is complaining, below is the 
error:
Error during template rendering

In template 
/home/amitesh/PycharmProjects/perfectcushion/SHOP/templates/base.html, error at 
line 0

The 'image' attribute has no file associated with it.

| 1 | {% load staticfiles %} |
| 2 |  |
| 3 |  |
| 4 |  |
| 5 |   |
| 6 |   |
| 7 |  {% block title %}{% endblock %} |
| 8 |  |
| 9 |  |



base.html
{% load staticfiles %}





{% block title %}{% endblock %}



{% include 'header.html' %}
{% include 'navbar.html' %}
{% block content %}
{% endblock %}

{% include 'footer.html' %}


headers.html
{% load staticfiles %}




navbar.html
{% load staticfiles %}


All Products
Your Cart()


category.html
{% extends 'base.html' %}
{% load staticfiles %}
{%  block metadescription %}
{% if category %}
{{ category.description|truncatewords:125 }}
{% else %}
Welcome to the cushion store where you can buy comfy and awesome 
cushions.
{% endif %}
{% endblock %}

{% block title %}
{% if category %}
{{ category.name }} - Perfect Cushion Store
 {% else %}
See our Cushion Collection - Perfect Cushion Store
{% endif %}
{% endblock %}

{% block content %}

{%  if category %}


Our Product 
Collection | {{ category.name }}


{% endif %}

{% if category %}





{{ category.name }}
{{ category.description }}

{% else %}

 
 
 
Our Products collection

Lorem Ipsum is simply dummy text of the printing and typesetting 
industry. Lorem Ipsum has been the industry's standard dummy text 
ever since the 1500s, when an unknown printer took a galley of type 
and.
 
{% endif %}


{% for product in products %}




{{ product.name }}
{{ product.price }}



{% endfor %}


{% endblock %}SHOP/urls.py
from django.urls import path
from . import views

app_name = 'shop'

urlpatterns = [
path('', views.allProdCat, name='allProdCat'),
path('/', views.allProdCat, name='products_by_category'),
]project/urls.py
from django.contrib import admin
from django.urls import path, include
from SHOP import views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('shop/', include('SHOP.urls')),
]

# We need to map the static and the media URLS with the below settings
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, 
document_root=settings.MEDIA_ROOT)views.py
from django.shortcuts import render, get_object_or_404
from .models import Category, Product


def allProdCat(request, c_slug=None):
c_page = None
products = None
if c_slug is not None:
c_page = get_object_or_404(Category, c_slug=c_slug)
products = Product.objects.filter(category=c_page, available=True)
else:
products = Product.objects.all().filter(available=True)
return render(request, 'shop/category.html', {'category': c_page, 
'products': products})Please help me figure out my mistake.



Regards,
Amitesh Sahay

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

Re: Django FastCGI and static files

2019-09-17 Thread Martin Jaan Leesment
It works by moving static directory but was wondering about a more 
intelligent solution, that is, if it exists with fastcgi.

-- 
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/b241f908-24d6-4098-8aed-95b08201418f%40googlegroups.com.


Django FastCGI and static files

2019-09-17 Thread Martin Jaan Leesment
Hey

I'm new to serving Django website on a shared server as well as using 
fastcgi and .htaccess so this might be a basic question. Namely I'm having 
difficulties serving static content. I've tried playing with htaccess 
rules, but no luck yet. My project structure:

myproject/
├── myapp
│   ├── admin.py
│   ├── apps.py
│   ├── models.py
│   ├── static
│   │   └── myapp
│   │   ├── css
│   │   │   ├── bootstrap.min.css
│   │   │   ├── bootstrap.min.min_myproject.css
│   │   │   └── proj.css
│   │   ├── fonts
│   │   ├── images
│   │   │   ├── logo.png
│   │   └── scripts
│   │   ├── bootstrap.bundle.min.js
│   │   └── bootstrap.min.js
│   ├── templates
│   │   └── myapp
│   │   ├── base.html
│   │   ├── footer.html
│   │   ├── header.html
│   │   ├── index.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── manage.py
├── myproject
│   ├── __init__.py
│   ├── locale
│   ├── media
│   ├── settings
│   │   ├── base.py
│   │   ├── dev.py
│   │   ├── __init__.py
│   │   ├── prod.py
│   ├── static
│   ├── templates
│   │   └── base.html
│   ├── urls.py
│   └── wsgi.py
├── requirements
└── test.py

My htaccess

Options +ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteRule ^(/static.*)$ /static//$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ cgi-bin/mydjangapp.fcgi/$1 [QSA,L]


If anybody can help me figure out how to solve it, would really appreciate.

Thanks!

Best
MJ

-- 
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/80c1e98b-8a0a-482c-a20f-29b4c7afdcab%40googlegroups.com.


Re: ORM

2019-09-17 Thread Jani Tiainen
Most tools are capable of exporting uml to code format. A little googlin
should help.

ma 16. syysk. 2019 klo 18.57 Yann Mbella 
kirjoitti:

> I needed the contrary having uml diagrams and generating models from
> does diagram
>
> Le lun. 16 sept. 2019 à 16:43, Yann Mbella  a
> écrit :
>
>> Thanx for the information
>>
>> Le ven. 13 sept. 2019 à 06:24, Jani Tiainen  a écrit :
>>
>>> Hi.
>>>
>>> There exists django-extensions package that has management command to
>>> make UML diagram for your models.
>>>
>>>
>>> pe 13. syysk. 2019 klo 5.22 Yann Mbella 
>>> kirjoitti:
>>>
 Got little problem is it possible to have a plugin which mapps or
 reproduce my class diagrams drawn in an IDE of UML in my models app

 --
 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/13525e44-e176-409a-a55e-0595834c780f%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/CAHn91odRe_26%3DuuAwCQOOapK_UeKPE1tOtmXQP-df8%3Dnxf4k3g%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/CAEaFv0FoE4D8_zNNv%2B3T3HUx1AzF%3DgGFPjUFLVL0sqQzc6Vtsg%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/CAHn91odykqZaVd6jup5Di7R_P1Fp0%2BFS2UWDRrKVJfavZRWm0g%40mail.gmail.com.


Problem with on_delete=models.CASCADE and MariaDB

2019-09-17 Thread Jan Marquardt
Hi everyone,

I am relatively new to Django and struggeling with on_delete=models.CASCADE and
MariaDB. I have two simple models which are associated to each other through a
ForeignKey. If I delete one parent object, I would expect the child objects to 
be deleted,
but I get an IntegrityError exception instead.

models.py: https://pastebin.com/xhfKmSAY
views.py: https://pastebin.com/gB5utyv7
urls.py: https://pastebin.com/9L90VKwh

Exception: https://pastebin.com/WspvLiiR

MySQL `show create table`: https://pastebin.com/yT1sjx9P

I was not yet able to test it with MySQL. With Postgres everything works as 
intended.

Any help/hints/advices would be appreciated.

Best Regards

Jan

-- 
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/55B7FDC4-0080-40AF-ACD9-33240530CB61%40artfiles.de.


signature.asc
Description: Message signed with OpenPGP


Re: DRF

2019-09-17 Thread Soumen Khatua
Thank you, It really helps me a lot.

Regards,
Soumen

On Tue, 17 Sep 2019, 12:50 Andréas Kühne, 
wrote:

> Hi Soumen,
>
> So let's look at your questions:
> 1. super(UserLoginSerializer, self).__init__(*args, **kwargs) - this means
> that it gets the parent of the UserLoginSerializer - which is
> serializers.Serializer. You can force python to choose another parent if
> you want to do something different, by changing the first parameter to
> super(). However, running on python 3, you don't need to add any parameters
> to the super call at all (unless you want to change which parent should be
> used).
> 2. validate is not called by you directly. You are calling the
> "is_valid()" method. This method in it's turn calls the validate method
> with the correct parameters - so you don't need to worry about it. However
> the parameter name is a bit strange - see here for examples and a
> description:
> https://www.django-rest-framework.org/api-guide/serializers/#validation
>
> https://www.django-rest-framework.org/api-guide/serializers/#object-level-validation
>
> Med vänliga hälsningar,
>
> Andréas
>
>
> Den tors 12 sep. 2019 kl 12:55 skrev Soumen Khatua <
> soumenkhatua...@gmail.com>:
>
>> Hi Folks,
>> I didn't understand this code, Cab you guys please explain me about this
>> code:
>>
>> *views.py:*
>> *-*
>>
>>
>>
>>
>>
>>
>>
>> *class UserLoginAPIView(GenericAPIView): authentication_classes = ()
>> permission_classes = () serializer_class = UserLoginSerializer ()def
>> post(self, request, *args, **kwargs): serializer =
>> self.get_serializer(data=request.data) if serializer.is_valid(): user =
>> serializer.user *
>>
>>
>>
>> *token, _ = Token.objects.get_or_create(user=user) return
>> Response(data=TokenSerializer(token).data, status=status.HTTP_200_OK) else:
>> return Response(data=serializer.errors,status=status.HTTP_400_BAD_REQUEST,)*
>>
>> *seralizers.py*
>> *-*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *class UserLoginSerializer(serializers.Serializer):username =
>> serializers.CharField(required=True)password =
>> serializers.CharField(required=True)default_error_messages = {
>> 'inactive_account': _('User account is disabled.'),
>> 'invalid_credentials': _('Unable to login with provided credentials.')
>> }def __init__(self, *args, **kwargs):super(UserLoginSerializer,
>> self).__init__(*args, **kwargs)self.user = Nonedef
>> validate(self, attrs):self.user =
>> authenticate(username=attrs.get("username"),
>> password=attrs.get('password'))if self.user:if not
>> self.user.is_active:raise
>> serializers.ValidationError(self.error_messages['inactive_account'])
>> return attrselse:raise
>> serializers.ValidationError(self.error_messages['invalid_credentials']*
>>
>> Here ,
>> 1)  super(UserLoginSerializer, self).__init__(*args, **kwargs)
>>  what  value  parent will get by using line *super(UserLoginSerializer,
>> self).__init__(*args, **kwargs) *
>> 2) Validate is one method which take attrs as a argument but If I didn;t
>> pass value of attrs then how it will be work?
>>
>> Guys please help me to understand this code.
>>
>> Thank You
>>
>> Regards,
>> Soumen
>>
>> --
>> 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/CAPUw6WZ3BGiHoZXmQRYiU%3DxCYdbPg%2BonCmwGSX0B%2B8VBb76aZw%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/CAK4qSCcLBzREDuTaz%2BGYX2yABadOnmAD6pw%3DVJcP6z3ULKk3WQ%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/CAPUw6WYonMdDzNT3TCq3LH5Dd-wAS311P_vzyet56cueuj798g%40mail.gmail.com.


Re: DRF

2019-09-17 Thread Andréas Kühne
Hi Soumen,

So let's look at your questions:
1. super(UserLoginSerializer, self).__init__(*args, **kwargs) - this means
that it gets the parent of the UserLoginSerializer - which is
serializers.Serializer. You can force python to choose another parent if
you want to do something different, by changing the first parameter to
super(). However, running on python 3, you don't need to add any parameters
to the super call at all (unless you want to change which parent should be
used).
2. validate is not called by you directly. You are calling the "is_valid()"
method. This method in it's turn calls the validate method with the correct
parameters - so you don't need to worry about it. However the parameter
name is a bit strange - see here for examples and a description:
https://www.django-rest-framework.org/api-guide/serializers/#validation
https://www.django-rest-framework.org/api-guide/serializers/#object-level-validation

Med vänliga hälsningar,

Andréas


Den tors 12 sep. 2019 kl 12:55 skrev Soumen Khatua <
soumenkhatua...@gmail.com>:

> Hi Folks,
> I didn't understand this code, Cab you guys please explain me about this
> code:
>
> *views.py:*
> *-*
>
>
>
>
>
>
>
> *class UserLoginAPIView(GenericAPIView): authentication_classes = ()
> permission_classes = () serializer_class = UserLoginSerializer ()def
> post(self, request, *args, **kwargs): serializer =
> self.get_serializer(data=request.data) if serializer.is_valid(): user =
> serializer.user *
>
>
>
> *token, _ = Token.objects.get_or_create(user=user) return
> Response(data=TokenSerializer(token).data, status=status.HTTP_200_OK) else:
> return Response(data=serializer.errors,status=status.HTTP_400_BAD_REQUEST,)*
>
> *seralizers.py*
> *-*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *class UserLoginSerializer(serializers.Serializer):username =
> serializers.CharField(required=True)password =
> serializers.CharField(required=True)default_error_messages = {
> 'inactive_account': _('User account is disabled.'),
> 'invalid_credentials': _('Unable to login with provided credentials.')
> }def __init__(self, *args, **kwargs):super(UserLoginSerializer,
> self).__init__(*args, **kwargs)self.user = Nonedef
> validate(self, attrs):self.user =
> authenticate(username=attrs.get("username"),
> password=attrs.get('password'))if self.user:if not
> self.user.is_active:raise
> serializers.ValidationError(self.error_messages['inactive_account'])
> return attrselse:raise
> serializers.ValidationError(self.error_messages['invalid_credentials']*
>
> Here ,
> 1)  super(UserLoginSerializer, self).__init__(*args, **kwargs)
>  what  value  parent will get by using line *super(UserLoginSerializer,
> self).__init__(*args, **kwargs) *
> 2) Validate is one method which take attrs as a argument but If I didn;t
> pass value of attrs then how it will be work?
>
> Guys please help me to understand this code.
>
> Thank You
>
> Regards,
> Soumen
>
> --
> 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/CAPUw6WZ3BGiHoZXmQRYiU%3DxCYdbPg%2BonCmwGSX0B%2B8VBb76aZw%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/CAK4qSCcLBzREDuTaz%2BGYX2yABadOnmAD6pw%3DVJcP6z3ULKk3WQ%40mail.gmail.com.