TypeError __init__() takes 1 positional argument but 2 were given

2021-10-18 Thread Jose Cabrera
hello everyone, please help me with this error that is generated in the 
views.py, in class registro(CreateView):
Thank you
form.py
class RegistrationForm(forms.ModelForm):
password = forms.CharField(label='Password', widget=forms.PasswordInput)
class Meta:
model = UserProfile
fields = ('email','password')

def save(self, commit=True):
# Save the provided password in hashed format
user = super().save(commit=False)
user.set_password(self.cleaned_data["password"])
if commit:
user.save()
return user

views.py
from .models import UserProfile
from .forms import RegistrationForm
from django.views.generic.edit import CreateView, UpdateView
from django.urls import reverse

class registro(CreateView):
template_name = 'registration/registro.html'
form_class = RegistrationForm

def get_context_data(self, *args, **kwargs):
context = super(registro, self).get_context_data(*args, **kwargs)
context['next'] = self.request.GET.get('next')
return context

def get_success_url(self):
next_url = self.request.POST.get('next')
success_url = reverse('home')
if next_url:
success_url += '?next={}'.format(next_url)

return success_url

-- 
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/070868ce-cd4a-4231-9685-38144e2cd417n%40googlegroups.com.


Re: cannot get value(foreign key) after using distinct()

2021-10-18 Thread Lalit Suthar
since you are using .first() in the query, it will return only 1 object so
I don't think using a for loop our 'category' in template will work

On Mon, 18 Oct 2021 at 18:04, Katharine Wong 
wrote:

> Hi all,
>
> There is a question when I use distinct().
> When I try to use the ORM(distinct & value), I cannot get the value of the
> attribute(foreign key).
>
> models.py
>
>  class Category(models.Model):
>  category = models.CharField(max_length=20)
>
> class Article(models.Model):
>  category = models.ForeignKey(Category, on_delete=models.CASCADE)
>
>
> views.py
>   category =
> Article.objects.filter(visible=True).values('category').distinct().first()
>   return_result.update({'category': category})
>
> template/xxx.html
>
>  {% if category %}
>  {% for name in category %}
> {{ name.category }}
> ...
>
> the result is 4. (int) and there is no result if I type {{
> name.category.category }}
>
> I hope the result is Work which is the 4(category_id) refs.
>
> Thanks,
> Kath
>
> --
> 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/CALUcQhHOQ7rcg_xLgJocyubWCN8pFOLmvrsnDqbkSWAWF-_Y2A%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/CAGp2JVEG%2Bk8fnseW4Tr_iME-dN_%3DTbojM%2BnL5kcwzFgyUdbjtQ%40mail.gmail.com.


Custom User error

2021-10-18 Thread Jose Cabrera
Greetings, I am starting in the world of django and I have some problems 
with a custom user, for the registration of users to the database, the 
example that I have works 100% with the user that comes by default allows 
me to render the registration form user without any inconvenience, but when 
I create a custom user the same screen for registration no longer works for 
me, it no longer works for me, I have read a lot of the web but nothing 
works for me. It should be something very simple, but I can't find what I 
should do.

To make the change to a custom user, delete the database and the migration 
that I had to create a clean database with the new model, but I have not 
been able to do it.

models.py
from django.contrib.auth.models import AbstractUser


class UserProfile (AbstractBaseUser, PermissionsMixin):
# table template for system login users with E-mail
email = models.EmailField (max_length = 255, unique = True, 
verbose_name = 'E-mail')
name = models.CharField (max_length = 200)
is_active = models.BooleanField (default = True)
is_staff = models.BooleanField (default = False)



form.py
from django import forms
from .models import Contact
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import get_user_model
User = get_user_model ()


class CustomCreationForm (UserCreationForm):
pass





views.py
from django.shortcuts import render
from .forms import UserCreationForm
from .forms import ContactForm
from django.shortcuts import get_object_or_404, render, redirect, 
get_object_or_404
# import courier
from django.contrib import messages
from django.contrib.auth.decorators import login_required, 
permission_required, permission_required
from django.contrib.auth import authenticate, login
from .forms import ContactForm, CustomCreationForm

# **
from django.contrib.auth import get_user_model
User = get_user_model ()


def record (request):
#def record (request):
data = {
'form': CustomCreationForm ()
}
form = CustomCreationForm (data = request.POST)
if form.is_valid ():
form.save ()
#authentic at once
user = authenticate (username = form.cleaned_data ["email"], 
password = form.cleaned_data ["password1"])
# I log in here
login (request, user)
#redirect home
messages.success (request, "Registered successfully")
return redirect (to = "home")
data ["form"] = form
return render (request, 'registration / registration.html', data)

setting.py
AUTH_USER_MODEL = 'profiles.UserProfile'
I repeat with the user model that comes by default from django, it works 
100%

When running the server it throws me this error
AttributeError at / record /
Manager isn't available; 'auth.User' has been swapped for 
'profiles.UserProfile'

-- 
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/aa3cc9d6-8085-4713-ad10-266dc62b6aa3n%40googlegroups.com.


Custom User error

2021-10-18 Thread Jose Cabrera
Greetings, I am starting in the world of django and I have some problems 
with a custom user, for the registration of users to the database, the 
example that I have works 100% with the user that comes by default allows 
me to render the registration form user without any inconvenience, but when 
I create a custom user the same screen for registration no longer works for 
me, it no longer works for me, I have read a lot of the web but nothing 
works for me. It should be something very simple, but I can't find what I 
should do.

To make the change to a custom user, delete the database and the migration 
that I had to create a clean database with the new model, but I have not 
been able to do it.

models.py
from django.contrib.auth.models import AbstractUser


class UserProfile (AbstractBaseUser, PermissionsMixin):
# table template for system login users with E-mail
email = models.EmailField (max_length = 255, unique = True, 
verbose_name = 'E-mail')
name = models.CharField (max_length = 200)
is_active = models.BooleanField (default = True)
is_staff = models.BooleanField (default = False)


views.py

from .forms import UserProfile


def record (request):
data = {
'form': UserProfile ()
}
form = UserProfile (data = request.POST)
if form.is_valid ():
form.save ()
#authentic at once
user = authenticate (username = form.cleaned_data ["email"], 
password = form.cleaned_data ["password1"])
# I log in here
login (request, user)
#redirect home
messages.success (request, "Registered successfully")
return redirect (to = "home")
data ["form"] = form
return render (request, 'registration / registration.html', data)


setting.py
AUTH_USER_MODEL = 'profiles.UserProfile'
I repeat with the user model that comes by default from django, it works 
100%

When running the server it throws me this error
TypeError at / record /
UserProfile () got an unexpected keyword argument 'data'

-- 
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/abe66834-8959-424a-bab4-ac4fdc3243c2n%40googlegroups.com.


Custom User error

2021-10-18 Thread Jose Cabrera
Saludos, me estoy iniciando en el mundo de django y tengo algunos problemas 
con un usuario personalizado, para el registro de usuarios a la base de 
datos, el ejemplo que tengo funciona al 100% con el usuario que viene por 
defecto me permite renderizar el formulario de registro de usuario sin 
ningún inconveniente, pero cuando creo un usuario personalizado la misma 
pantalla para el registro ya no funciona para mí, ya no funciona para mí, 
he leído mucho de la web pero nada funciona para mí. Debería ser algo muy 
simple, pero no puedo encontrar lo que debo hacer.

Para realizar el cambio a un usuario personalizado, borra la base de datos 
y la migración que tuve para crear una base de datos limpia con el nuevo 
modelo, pero no he podido hacerlo.

models.py
desde django.contrib.auth.models importar AbstractUser


clase UserProfile (AbstractBaseUser, PermissionsMixin):
# plantilla de tabla para usuarios de inicio de sesión del sistema con 
correo electrónico
correo electrónico = modelos. EmailField (max_length = 255, unique = True, 
verbose_name = 'E-mail')
nombre = modelos. CharField (max_length = 200)
is_active = modelos. BooleanField (predeterminado = Verdadero)
is_staff = modelos. BooleanField (predeterminado = False)


views.py

desde .forms importar UserProfile


def record (solicitud):
datos = {
'formulario': UserProfile ()
}
form = UserProfile (datos = solicitud. POST)
si form.is_valid ():
form.save ()
#authentic a la vez
usuario = autenticar (nombre de usuario = form.cleaned_data ["correo 
electrónico"], contraseña = form.cleaned_data ["contraseña1"])
# Inicio sesión aquí
login (solicitud, usuario)
#redirect inicio
messages.success (solicitud, "Registrado correctamente")
redirigir de retorno (a = "inicio")
data ["form"] = formulario
devolución (solicitud, 'registro / registro.html', datos)


setting.py
AUTH_USER_MODEL = 'perfiles. UserProfile'
Repito con el modelo de usuario que viene por defecto de django, funciona 
al 100%

Al ejecutar el servidor me arroja este error
TypeError at / record /
UserProfile () obtuvo un argumento de palabra clave inesperado 'data'

-- 
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/020aaad4-5595-4dfd-94d6-60d05d08d47an%40googlegroups.com.


Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread Shaheed Haque
On Mon, 18 Oct 2021 at 15:41, Sebastian Jung 
wrote:

> When u use SelectMultiple then you get a select widget where you can
> select many options Your code are wrong in forms.py in widgets=
>
> Am Mo., 18. Okt. 2021 um 16:22 Uhr schrieb 'Maryam Yousaf' via Django
> users :
>
>> It is already selectmultiple . I need dropdown where I can select
>> multiple values .
>> currently, it is coming like this:
>>
>
Apologies if this is stating the obvious, but to select more than one item,
are you using "shift+click" or "ctrl+click" or just "click"?

You need to use the modifier key with "click", not just "click".


>
>> On Mon, 18 Oct 2021 at 16:07, Sebastian Jung 
>> wrote:
>>
>>> Hello,
>>>
>>> then change in widgets Select() to SelectMultiple().
>>>
>>> https://docs.djangoproject.com/en/3.2/ref/forms/widgets/#selectmultiple
>>>
>>> Regards
>>>
>>> Am Mo., 18. Okt. 2021 um 15:51 Uhr schrieb 'Maryam Yousaf' via Django
>>> users :
>>>
 Hi,

 I have one manytomany field in one of my model which is currently
 coming as Multiselect but I need a dropdown where user can select multiple
 values as I have huge data to show.

 I am trying this in forms.py but it is not showing dropdown field.

 Kindly help me out.

 *Model.py:*

 class Chain(models.Model):
 chain_id = models.AutoField(primary_key=True)
 chain_name = models.CharField(max_length=255, unique=True)
 chain_type = models.ForeignKey(ChainType, on_delete=models.CASCADE)
 history = HistoricalRecords()

 def __str__(self):
 return self.chain_name

 class Meta:
 ordering = ('chain_name',)


 class Brg(models.Model):
 brg_campaign_id = models.AutoField(primary_key=True)
 campaign_tracking = models.ForeignKey(CampaignTracking,
 on_delete=models.CASCADE)
 brg_name = models.ForeignKey(Chain, on_delete=models.CASCADE,
 related_name="primary_brg",
 help_text='Add Brgs/chain names for these above campaign has run')
 brg_benchmark = models.ManyToManyField(Chain,
 related_name="competitor_brg", null=True,
 blank=True, help_text='Add max.5 other benchmarks brgs to check overall
 impact')
 history = HistoricalRecords()

 def __str__(self):
 return "Brg names list"

 class Meta:
 verbose_name = 'Brg Campaign Tracking'

 *forms.py:*
 class ChainForm(forms.ModelForm):
 class Meta:
 model: Chain
 # fields = ('campaign_tracking', 'brg_name', 'brg_benchmark',)
 widgets = {
 'chain_name': Select(),
 }

 Regards,
 maryam


 --
 This email and any files transmitted with it contain confidential
 information and/or privileged or personal advice. This email is intended
 for the addressee(s) stated above only. If you are not the addressee of the
 email please do not copy or forward it or otherwise use it or any part of
 it in any form whatsoever. If you have received this email in error please
 notify the sender and remove the e-mail from your system. Thank you.

 This is an email from the company Just Eat Takeaway.com N.V., a public
 limited liability company with corporate seat in Amsterdam, the
 Netherlands, and address at Oosterdoksstraat 80, 1011 DK Amsterdam,
 registered with the Dutch Chamber of Commerce with number 08142836 and
 where the context requires, includes its subsidiaries and associated
 undertakings.

 --
 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/ac59ba2a-5baa-4302-88c9-0dd17606fdaen%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/CAKGT9mwXNTc2638qv-vScbHZW2uRq3utmu%2BbfM5Mz06WERmt2g%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>> This email and any files transmitted with it contain confidential
>> information and/or privileged or personal advice. This email is intended
>> for the addressee(s) stated above only. If you are not the addressee of the
>> email please do not copy or forward it or otherwise use it or any part of
>> 

Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread Sebastian Jung
When u use SelectMultiple then you get a select widget where you can select
many options Your code are wrong in forms.py in widgets=

Am Mo., 18. Okt. 2021 um 16:22 Uhr schrieb 'Maryam Yousaf' via Django users
:

> It is already selectmultiple . I need dropdown where I can select multiple
> values .
> currently, it is coming like this:
>
> On Mon, 18 Oct 2021 at 16:07, Sebastian Jung 
> wrote:
>
>> Hello,
>>
>> then change in widgets Select() to SelectMultiple().
>>
>> https://docs.djangoproject.com/en/3.2/ref/forms/widgets/#selectmultiple
>>
>> Regards
>>
>> Am Mo., 18. Okt. 2021 um 15:51 Uhr schrieb 'Maryam Yousaf' via Django
>> users :
>>
>>> Hi,
>>>
>>> I have one manytomany field in one of my model which is currently coming
>>> as Multiselect but I need a dropdown where user can select multiple values
>>> as I have huge data to show.
>>>
>>> I am trying this in forms.py but it is not showing dropdown field.
>>>
>>> Kindly help me out.
>>>
>>> *Model.py:*
>>>
>>> class Chain(models.Model):
>>> chain_id = models.AutoField(primary_key=True)
>>> chain_name = models.CharField(max_length=255, unique=True)
>>> chain_type = models.ForeignKey(ChainType, on_delete=models.CASCADE)
>>> history = HistoricalRecords()
>>>
>>> def __str__(self):
>>> return self.chain_name
>>>
>>> class Meta:
>>> ordering = ('chain_name',)
>>>
>>>
>>> class Brg(models.Model):
>>> brg_campaign_id = models.AutoField(primary_key=True)
>>> campaign_tracking = models.ForeignKey(CampaignTracking,
>>> on_delete=models.CASCADE)
>>> brg_name = models.ForeignKey(Chain, on_delete=models.CASCADE,
>>> related_name="primary_brg",
>>> help_text='Add Brgs/chain names for these above campaign has run')
>>> brg_benchmark = models.ManyToManyField(Chain,
>>> related_name="competitor_brg", null=True,
>>> blank=True, help_text='Add max.5 other benchmarks brgs to check overall
>>> impact')
>>> history = HistoricalRecords()
>>>
>>> def __str__(self):
>>> return "Brg names list"
>>>
>>> class Meta:
>>> verbose_name = 'Brg Campaign Tracking'
>>>
>>> *forms.py:*
>>> class ChainForm(forms.ModelForm):
>>> class Meta:
>>> model: Chain
>>> # fields = ('campaign_tracking', 'brg_name', 'brg_benchmark',)
>>> widgets = {
>>> 'chain_name': Select(),
>>> }
>>>
>>> Regards,
>>> maryam
>>>
>>>
>>> --
>>> This email and any files transmitted with it contain confidential
>>> information and/or privileged or personal advice. This email is intended
>>> for the addressee(s) stated above only. If you are not the addressee of the
>>> email please do not copy or forward it or otherwise use it or any part of
>>> it in any form whatsoever. If you have received this email in error please
>>> notify the sender and remove the e-mail from your system. Thank you.
>>>
>>> This is an email from the company Just Eat Takeaway.com N.V., a public
>>> limited liability company with corporate seat in Amsterdam, the
>>> Netherlands, and address at Oosterdoksstraat 80, 1011 DK Amsterdam,
>>> registered with the Dutch Chamber of Commerce with number 08142836 and
>>> where the context requires, includes its subsidiaries and associated
>>> undertakings.
>>>
>>> --
>>> 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/ac59ba2a-5baa-4302-88c9-0dd17606fdaen%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/CAKGT9mwXNTc2638qv-vScbHZW2uRq3utmu%2BbfM5Mz06WERmt2g%40mail.gmail.com
>> 
>> .
>>
>
>
> --
> This email and any files transmitted with it contain confidential
> information and/or privileged or personal advice. This email is intended
> for the addressee(s) stated above only. If you are not the addressee of the
> email please do not copy or forward it or otherwise use it or any part of
> it in any form whatsoever. If you have received this email in error please
> notify the sender and remove the e-mail from your system. Thank you.
>
> This is an email from the company Just Eat Takeaway.com N.V., a public
> limited liability company with corporate seat in Amsterdam, the
> Netherlands, and address at Oosterdoksstraat 80, 1011 DK Amsterdam,
> registered with the Dutch 

Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread Sebastian Jung
Hello,

then change in widgets Select() to SelectMultiple().

https://docs.djangoproject.com/en/3.2/ref/forms/widgets/#selectmultiple

Regards

Am Mo., 18. Okt. 2021 um 15:51 Uhr schrieb 'Maryam Yousaf' via Django users
:

> Hi,
>
> I have one manytomany field in one of my model which is currently coming
> as Multiselect but I need a dropdown where user can select multiple values
> as I have huge data to show.
>
> I am trying this in forms.py but it is not showing dropdown field.
>
> Kindly help me out.
>
> *Model.py:*
>
> class Chain(models.Model):
> chain_id = models.AutoField(primary_key=True)
> chain_name = models.CharField(max_length=255, unique=True)
> chain_type = models.ForeignKey(ChainType, on_delete=models.CASCADE)
> history = HistoricalRecords()
>
> def __str__(self):
> return self.chain_name
>
> class Meta:
> ordering = ('chain_name',)
>
>
> class Brg(models.Model):
> brg_campaign_id = models.AutoField(primary_key=True)
> campaign_tracking = models.ForeignKey(CampaignTracking,
> on_delete=models.CASCADE)
> brg_name = models.ForeignKey(Chain, on_delete=models.CASCADE,
> related_name="primary_brg",
> help_text='Add Brgs/chain names for these above campaign has run')
> brg_benchmark = models.ManyToManyField(Chain,
> related_name="competitor_brg", null=True,
> blank=True, help_text='Add max.5 other benchmarks brgs to check overall
> impact')
> history = HistoricalRecords()
>
> def __str__(self):
> return "Brg names list"
>
> class Meta:
> verbose_name = 'Brg Campaign Tracking'
>
> *forms.py:*
> class ChainForm(forms.ModelForm):
> class Meta:
> model: Chain
> # fields = ('campaign_tracking', 'brg_name', 'brg_benchmark',)
> widgets = {
> 'chain_name': Select(),
> }
>
> Regards,
> maryam
>
>
> --
> This email and any files transmitted with it contain confidential
> information and/or privileged or personal advice. This email is intended
> for the addressee(s) stated above only. If you are not the addressee of the
> email please do not copy or forward it or otherwise use it or any part of
> it in any form whatsoever. If you have received this email in error please
> notify the sender and remove the e-mail from your system. Thank you.
>
> This is an email from the company Just Eat Takeaway.com N.V., a public
> limited liability company with corporate seat in Amsterdam, the
> Netherlands, and address at Oosterdoksstraat 80, 1011 DK Amsterdam,
> registered with the Dutch Chamber of Commerce with number 08142836 and
> where the context requires, includes its subsidiaries and associated
> undertakings.
>
> --
> 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/ac59ba2a-5baa-4302-88c9-0dd17606fdaen%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/CAKGT9mwXNTc2638qv-vScbHZW2uRq3utmu%2BbfM5Mz06WERmt2g%40mail.gmail.com.


DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread 'Maryam Yousaf' via Django users
Hi,  

I have one manytomany field in one of my model which is currently coming as 
Multiselect but I need a dropdown where user can select multiple values as 
I have huge data to show.

I am trying this in forms.py but it is not showing dropdown field.

Kindly help me out.

*Model.py:*

class Chain(models.Model):
chain_id = models.AutoField(primary_key=True)
chain_name = models.CharField(max_length=255, unique=True)
chain_type = models.ForeignKey(ChainType, on_delete=models.CASCADE)
history = HistoricalRecords()

def __str__(self):
return self.chain_name

class Meta:
ordering = ('chain_name',)


class Brg(models.Model):
brg_campaign_id = models.AutoField(primary_key=True)
campaign_tracking = models.ForeignKey(CampaignTracking, 
on_delete=models.CASCADE)
brg_name = models.ForeignKey(Chain, on_delete=models.CASCADE, 
related_name="primary_brg",
help_text='Add Brgs/chain names for these above campaign has run')
brg_benchmark = models.ManyToManyField(Chain, 
related_name="competitor_brg", null=True,
blank=True, help_text='Add max.5 other benchmarks brgs to check overall 
impact')
history = HistoricalRecords()

def __str__(self):
return "Brg names list"

class Meta:
verbose_name = 'Brg Campaign Tracking'

*forms.py:*
class ChainForm(forms.ModelForm):
class Meta:
model: Chain
# fields = ('campaign_tracking', 'brg_name', 'brg_benchmark',)
widgets = {
'chain_name': Select(),
}

Regards,
maryam

-- 



This email and any files transmitted with it contain confidential 
information and/or privileged or personal advice. This email is intended 
for the addressee(s) stated above only. If you are not the addressee of the 
email please do not copy or forward it or otherwise use it or any part of 
it in any form whatsoever. If you have received this email in error please 
notify the sender and remove the e-mail from your system. Thank you.


This 
is an email from the company Just Eat Takeaway.com N.V., a public limited 
liability company with corporate seat in Amsterdam, the Netherlands, and 
address at Oosterdoksstraat 80, 1011 DK Amsterdam, registered with the 
Dutch Chamber of Commerce with number 08142836 and where the context 
requires, includes its subsidiaries and associated undertakings.

-- 
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/ac59ba2a-5baa-4302-88c9-0dd17606fdaen%40googlegroups.com.


cannot get value(foreign key) after using distinct()

2021-10-18 Thread Katharine Wong
Hi all,

There is a question when I use distinct().
When I try to use the ORM(distinct & value), I cannot get the value of the
attribute(foreign key).

models.py

 class Category(models.Model):
 category = models.CharField(max_length=20)

class Article(models.Model):
 category = models.ForeignKey(Category, on_delete=models.CASCADE)


views.py
  category =
Article.objects.filter(visible=True).values('category').distinct().first()
  return_result.update({'category': category})

template/xxx.html

 {% if category %}
 {% for name in category %}
{{ name.category }}
...

the result is 4. (int) and there is no result if I type {{
name.category.category }}

I hope the result is Work which is the 4(category_id) refs.

Thanks,
Kath

-- 
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/CALUcQhHOQ7rcg_xLgJocyubWCN8pFOLmvrsnDqbkSWAWF-_Y2A%40mail.gmail.com.


Re: User matching query does not exist.

2021-10-18 Thread Nicholas Bartlett
Hi all, I have a similar issue on my DB. 

Internal Server Error: /ms_app/customers/19

Traceback (most recent call last):

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/core/handlers/exception.py",
 
line 47, in inner

response = get_response(request)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/core/handlers/base.py",
 
line 204, in _get_response

response = response.render()

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/response.py",
 
line 105, in render

self.content = self.rendered_content

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/response.py",
 
line 83, in rendered_content

return template.render(context, self._request)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/backends/django.py",
 
line 61, in render

return self.template.render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 170, in render

return self._render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 162, in _render

return self.nodelist.render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 938, in render

bit = node.render_annotated(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 905, in render_annotated

return self.render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/loader_tags.py",
 
line 150, in render

return compiled_parent._render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 162, in _render

return self.nodelist.render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 938, in render

bit = node.render_annotated(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 905, in render_annotated

return self.render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/loader_tags.py",
 
line 62, in render

result = block.nodelist.render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 938, in render

bit = node.render_annotated(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 905, in render_annotated

return self.render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/defaulttags.py",
 
line 211, in render

nodelist.append(node.render_annotated(context))

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 905, in render_annotated

return self.render(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/defaulttags.py",
 
line 305, in render

match = condition.eval(context)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/defaulttags.py",
 
line 889, in eval

return self.value.resolve(context, ignore_failures=True)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/template/base.py",
 
line 698, in resolve

new_obj = func(obj, *arg_vals)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/MSNDashboard/msCentral/mscentral_project/ms_app/templatetags/custom_tags.py",
 
line 8, in is_group

group = Group.objects.get(name=group_name)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/db/models/manager.py",
 
line 85, in manager_method

return getattr(self.get_queryset(), name)(*args, **kwargs)

  File 
"/Users/nicholasbartlett/Documents/Dashboard/djangodash/djenv/lib/python3.8/site-packages/django/db/models/query.py",
 
line 435, in get

raise self.model.DoesNotExist(

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

[18/Oct/2021 09:40:29] "GET /ms_app/customers/19 HTTP/1.1" 500 182022


The group is accessible from the admin 

How to get a chinese django tutorial

2021-10-18 Thread 银色配色
Dear Team,
I recently learned django tutorials on django's website, which has 
tutorials in Chinese, but it's not convenient to visit django's website in 
my work environment. Is there any way to download the Chinese version of 
Django tutorial PDF file or epub file?

-- 
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/90cf68fd-aa6e-43af-b3ca-0f96cce26629n%40googlegroups.com.