inchidi
but am not sure until you try it 😁
Audacious Tux
umm ok.. lemme try
Audacious Tux
Audacious Tux
but i think that's not the real reason... exactly same code i used for my ModUserCreationForm... just overwride the Meta class with the same code in django.forms UserCreationForm...
Audacious Tux
i didn't explicitly said email field here... but it's working as it should
inchidi
yeah, looks like i was wrong. btw why you are not using UserCreationForm directly?
inchidi
ah, it will still using username right?
Audacious Tux
just wanted to inherit classes from django and overwrite some code and let my work done... but... i was just curious why this happening
inchidi
will it using username instead email?
Audacious Tux
nope... email.... username random generated
inchidi
well thats weird
Audacious Tux
i want email instead of username
Audacious Tux
yape wierd 😐
Audacious Tux
i may switch to other solution... but just want to know why this happening
inchidi
from this info if you use UserCreationForm directly for your views it should using username, but you said the result is using email and username randomly generated
inchidi
am sure you missplaced something tho. but i cant find out what it is
Audacious Tux
no no... i'm not even taking username input from user.... it's randomly generated in usermodel field with default= value....
inchidi
Audacious Tux
this is the expected result
Audacious Tux
of this code
inchidi
and if you use UserCreationForm directly?
inchidi
will it produce same result like this?
Django Bot
>> Links
- shell_plus — django-extensions 1.9.9 documentation
- PDFs in Django: The essential guide — /var/
- My essential django package list — /var/
- Using Werkzeug debugger with Django — /var/
inchidi
am curious, can you tell me which user called by get_user_model() now if you access it via shell?
Audacious Tux
umm... wait... most probably the default user model comes with django.... coz it's showing the username field of that model... with charecter limit 150... in my custom user model that set to 50... lemme check
Audacious Tux
in shell it's showing my usermodel
inchidi
and its USERNAME_FIELD ?
inchidi
user.USERNAME_FIELD
inchidi
yeah its really weird, UserModel value must be your custom user which is ModUser tho
Audacious Tux
probably it's bug.... i can't find any other possible answer 😩
Audacious Tux
even UserModel in django forms.py gets my usermodel
inchidi
lol
inchidi
submit it as bug maybe, at least if its not a bug more ppl will help you find out where is the mistake
Audacious Tux
yah.... i will .... thanks btw.. ❤️
inchidi
alright your welcome
Audacious Tux
https://code.djangoproject.com/ticket/29042#no1
Django Bot
>> Links
- QueraTeam/django-qsessions: Extends Django's cached_db session backend
Someone
Hi all, I am using ListCreateAPIView ..
class CandidateList(generics.ListCreateAPIView):
queryset = Candidate.objects.all()
serializer_class = CandidateSerializer
Is it possible to apply authentication for GET method alone.. bcz anyone can POST only admin needs to GET
inchidi
inchidi
then... check if its a get then change it to another permission that fit with your needs in get_queryset
inchidi
Permissions - Django REST framework
Someone
Okies Thanks
Django Bot
>> Blogs
- Handling CORS in Django REST Framework
Someone
inchidi
oh wait
inchidi
i forgot, do APIView have get_queryset?
Someone
No i guess not sure
inchidi
ah its not, (if am correct then) get_queryset you defined there not gonna be called so its not working
Someone
I am unable to find any relevant answer in google .. thats why am asking in group.. sorry if questions are silly .. and thanks for your wonderful help.. you are very patient
Someone
inchidi
but i will prefer using generics and differentiate between single or many objects (or split them again by the request method) and resulting more than one api endpoint (urls)
inchidi
its easier to maintain imho
Someone
Okies ... i will try that
inchidi
for example:
# urls.py
path('candidate/list/', CList.as_view()),
path('canditate/register/',CRegister.as_view())
and
#views.py
class CList(ListView):
permission_classes=(IsSuperUser,)
...
class CRegister(CreateView):
... (allow any)
inchidi
something like that
Someone
Yes this looks great and neat ... thanks a lot
mλdcodez
Hello Everyone.
harisai | హరి సాయి
Hi, I'm setting my datetimefield default value to timezone. Now. When I'm opening my MySQL database and trying to add a record it is showing that date field default value is date field dosent have default value how to solve this problem. I want datefield column to be filled automatically by today's date.
Anonymous
Can you share your model class?
harisai | హరి సాయి
i used timezone from django.utils
inchidi
it should be timezone.now() but models.DateTimeField(auto_now_add=True) will fit with your need too
inchidi
oh wait, maybe not.
Anonymous
Maybe it's just auto_now=true
Anonymous
Were Migrations successful
Anonymous
?
harisai | హరి సాయి
Yes
Anonymous
inchidi
Yes
did you know the differences between auto_now_add, auto_now and default=timezone.now()?
Anonymous
blank=none?
Anonymous
null=None?
harisai | హరి సాయి
harisai | హరి సాయి
But when I executed the timezone. Now() it gave me false
Callable(timezone.now()) this is the command
inchidi
null=None?
^set blank=True, null=True also
inchidi
harisai | హరి సాయి
inchidi
Nope
for DateTimeFields
set default=timezone.now() means you set the field value to added row timestamp if not provided, but you can also set it to another timestamp or change saved value later
inchidi
set auto_now_add=True similar with above but you cant pass other value, and its uneditable (the cell will always store timestamp when the row created)
inchidi
auto_now means the value will be changed when you update the row and it will equals with auto_now_add if row never updated