Nikhil
but email field is default provided by all auth package, i have not created it in model..
are you using an admin panal or are you calling an html page?
Patience
Nikhil
that means you must have miss typed the name of function
Patience
that means you must have miss typed the name of function
No, this error is showing only when I play it in middle, it is pointing to internal python & Django libraries.
fon_atic
Hello, Everyone. Could you please tell me is it possible to pass the initial data to the form in the class-based view?
sarth
are you using an admin panal or are you calling an html page?
inbuilt html page of all auth like account/ login or account/signup
Nikhil
inbuilt html page is the admin one ig and you can create admin use using createsuprruser command
fon_atic
Hello, Everyone. Could you please tell me is it possible to pass the initial data to the form in the class-based view?
I found the solution. If someone need it here's the link: https://docs.djangoproject.com/en/3.2/topics/class-based-views/intro/#handling-forms-with-class-based-views
Anonymous
Hey there how can i manipulate data from data base(mysql) without using OMR
Anonymous
If anyone know please reply
Anonymous
Use mysql apps like postgresql in pg4
Do you have any STUDYMETERIAL or tutorial?
Samson Davidoff
Hi everyone I started a project with the latest version of Django. The admin panel has a dark theme in this version. How can I set the former light color for the admin panel theme?
Anonymous
Rup
Is there anyone who will help me in file download api in django. I will really appreciate.
Anonymous
Is that much simple ?
Rup
Some study material Also will be good for reference. If you know that will helpful please provide it.
cj
it's exactly the same ¯\_(ツ)_/¯ what makes you think it's gonna be different?
cj
Django is just a Python framework that helps you develop web applications... everything you know at Python level is gonna work ¯\_(ツ)_/¯ there's no reason to think things won't work
mr.vip
cj
Then after django what should we learn ?
whether you want 🤷🏻‍♂ nothing stops you to learn whatever other things you want/like
Unathi
Hi, How do I add a search field in a model with choices like cities in the Django restful api, for example a user needs to choice their city now when they start to search it it appears and they select it and POST?
Anonymous
Hello I need need help I am using digital ocean vas my hosting provider I want to add my environment variable to it. How can I set it
Ghorz
I am using ubuntu 20
Do you know how to use Linux?
Tapdiq
Hello everyone, can anyone have experience in creating authorization and registration using django and ajax of django itself, I can't use it because my front is separated from the backend?
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ‌‌ㅤㅤ‌‌ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ‌‌ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ
I used Windows IIS server to run Django Websockt I wanted to know if it has this feature because I got an error?
Ash
How does one scale their skill in Django. Or rather what is the road map
âshîsh
How does one scale their skill in Django. Or rather what is the road map
Roadmap starts with python (the more you know, the more complicated tasks can be handled). You should have basic knowledge of HTML CSS. After those skills, you can start learning Django with video lectures (available for free on internet) and consider official documents side by side. Also practice in meantime. Once you get command in Django, you can move further to deal with APIs using DRF.
Atlas
How does one scale their skill in Django. Or rather what is the road map
I think, doing projects is the best way. It force you to find real solutions and by the way, such projects are great for the portfolio
WhiteKing007
Path error after inputing path in url pattern
Raj
I want to implement Signup/Signin/password reset using Djoser How can i do?
Doragonsureiyā
I want to implement Signup/Signin/password reset using Djoser How can i do?
Step 1: Open a browser Step 2: Write down https://google.com or https://duck.com and press Enter Step 3: In the search box, write down the same words you asked here Step 4: Read the first results
Michael ✨
Hello, can someone help me with this error
Michael ✨
https://pastebin.com/QhP2K4WW
Michael ✨
I am trying to upload my online store project to Heroku, but it gives me that error, I already integrated the favicon.ico, in local server it works perfectly, but in heroku, it gives me that error
S🤓
can i create multiple models in a single app in djnago
Anonymous
how to configuration open api for DRF
Anonymous
how to configuration open api for DRF
Use cors headers to allow all domain
Neo
i am using aggregate max and default values for a id field to make it auto increment, is there any better way to do this. def row_count(): """Designation counter """ no = RoleMaster.objects.aggregate(Max('id')) if no['id__max'] is None: return 1 else: return no['id__max'] + 1 id = models.IntegerField(default=row_count)
kuzmich
models.AutoField(primary_key=False) then
Neo
models.AutoField(primary_key=False) then
got this ERRORS: RecomAdmin.RoleMaster.id: (fields.E100) AutoFields must set primary_key=True.
kuzmich
ok, then look at the F func
kuzmich
you can have an int with default set to 0 when you add a record you can do something like this: model.field = F('custom_not_primary_key_id') + 1
kuzmich
https://docs.djangoproject.com/en/3.2/ref/models/expressions/#:~:text=An%20F()%20object%20represents,the%20database%20into%20Python%20memory.
Kayode 🦅
ONLY SHOW THE LOGGED IN USER’S PROFILE Hi, i started DRF few days ago, now i built an api that simulates a private bank account. I was able to prevent users from viewing the database if not logged in, how do i implement “users can only view the profile they logged in with? like if you log in as abc@example.com, you would only see abd@example.com, thanks!
kuzmich
ONLY SHOW THE LOGGED IN USER’S PROFILE Hi, i started DRF few days ago, now i built an api that simulates a private bank account. I was able to prevent users from viewing the database if not logged in, how do i implement “users can only view the profile they logged in with? like if you log in as abc@example.com, you would only see abd@example.com, thanks!
def reset_password(self, request, pk): instance = self.get_object() if instance == request.user: serializer = self.get_serializer(data=request.data, context={'request': self.request}) if serializer.is_valid(): password = serializer.initial_data.get('new_password') instance.set_password(password) instance.save() send_email_with_credentials.delay(instance.id, password, is_updated=True) return Response(status=status.HTTP_202_ACCEPTED) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) return Response(status=status.HTTP_403_FORBIDDEN)
Kayode 🦅
😳😳😳
Kayode 🦅
thanks!!
kuzmich
glad it helped! :)
Kayode 🦅
can you also recommend resources aside the official documentation? 🙏🏾
kuzmich
can you also recommend resources aside the official documentation? 🙏🏾
I just search what I need and add 'medium' at the end =D
Kayode 🦅
smart 😄
Kayode 🦅
thanks again!
kuzmich
you mean in def save(self) method
yes, or in pre_save/post_save hook
Neo
yes, or in pre_save/post_save hook
i have tried this , but got error ERROR: Manager isn't accessible via RoleMaster instances def save(self, *args, **kwargs): # This means that the model isn't saved to the database yet if self._state.adding: # Get the maximum display_id value from the database last_id = self.objects.all().aggregate(largest=models.Max('display_id'))['largest'] # aggregate can return None! Check it first. # If it isn't none, just use the last ID specified (which should be the greatest) and add one to it if last_id is not None: self.display_id = last_id + 1 super(MyModel, self).save(*args, **kwargs)
sarth
Need django developer, direct msg me, minimum experience 2 yr. Location Bhopal
Neo
there is another example below on that thread, i'd go with that one
this one? class Counter(models.Model): count = models.PositiveIntegerField(default=0) @classmethod def get_next(cls): with transaction.atomic(): cls.objects.update(count=models.F('count') + 1) return cls.objects.values_list('count', flat=True)[0]
Neo
It is
but it is not changing every time it is showing 0 while creating in admin
kuzmich
Put it in pre_save
Neo
Put it in pre_save
in signals? i think using default function is better than all these