The Inspired
U have other way
Another way is to make another field in your model and not make that unique
Juaco
Have you seen the future? It is always better to put stuff for future, even if you might not need it.
By following this logic you can end with arbitrary amounts of code that does nothing, "just in case" you might need it in the future. Not good advice
Hello everyone How can I customize my gunicorn logging with django? By default when I run gunicorn It's not logging any request in console and I want to see my logs in console with gunicorn, how can I fix this? EDIT: When Debug is True, my django logging working correctly. but when I set Debug to False and run gunicorn it log nothing in console.
Kareem
If I want to practice writing more models.. i should write html forms first then map it to the models Right??
Ravikumar
Hi Everyone , HOW TO KEEP MODEL DATA UPDATE HISTORY IN DJANGO
.
If I want to practice writing more models.. i should write html forms first then map it to the models Right??
No, write models first. And then just load it in admin panel to see and edit them.
Adithya
Hello everyone i am getting error as : AttributeError: 'Manager' object has no attribute 'create_user' but I have defined create_user function class CustomUserManager(BaseUserManager): def create_user(self, email, password= None, **extra_fields): if not email: raise ValueError('Email is require') email = self.normalize_email(email) user = self.model(email = email, **extra_fields) user.set_password(password) user.save() return user
Adithya
though i defined why i am getting error
Adithya
please help me anyone
Adithya
class Users(AbstractUser): username = None id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) email = models.EmailField(unique=True) #password = models.CharField(max_length=20) objects = CustomUserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] def str(self): return f"{self.email}"
Adithya
please help
Adithya
Error: user= Library.objects.create_user( AttributeError: 'Manager' object has no attribute 'create_user'
Jeet
What is integrity error
Meme
A model instance (model 1) been saved and a function is called to create a instance on another model (model 2) with the ID of the model created (model 1) . If I access the model instance of model 1 by , Model1.objects.latest('id') Then create a new instance to model 2 . Question : will any id mistach occurs if multiple users access the same functionality at the same time ?
DeViL
Any good YouTube channel to learn django
Maxim
Any good YouTube channel to learn django
use YT searchbar or google or other search engines
DeViL
Is searched a lot
DeViL
But you all are experienced person So that's why I'm asking
Anonymous
Is searched a lot
You haven't searched enough
Maxim
Is searched a lot
so you already got what you wanted
DeViL
I only want to know any good paid or unpaid Good course
Doragonsureiyā
I only want to know any good paid or unpaid Good course
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Maxim
But you all are experienced person So that's why I'm asking
experienced people will tell you that you're looking in the wrong place: 1. don't use YouTube as your primary source of knowledge 2. don't trust course sellers
DeViL
So I'm asking you to guide me
Meme
So I'm asking you to guide me
Better to go through official documentation along with any yt videos that you choose
Igor
I have a ManyToMany relationship between two models A and B, and a model AB that is a table through which ManyToMany relationship is working. (let's say, model A have field bs = ManyToManyField('B', through='AB')) I need to drop all entries in AB for a certain id from A. What is the best way to do it? Django docs propose doing it like this: some_a.bs.clear() but I am not sure if it is the best way, wouldn't it be better to do it like this: AB.objects.filter(id=some_a.id).delete() And if not, why not?
Reis_969
Hi help me please why the form is not valid my cod
Reis_969
``` PRODUCT_QUANTITY_CHOICES = [(i, str(i)) for i in range(1, 21)] class CartAddProductForm(forms.Form): quantity = forms.TypedChoiceField(choices=PRODUCT_QUANTITY_CHOICES, coerce=int) update = forms.BooleanField(required=False, initial=False, widget=forms.HiddenInput) ```
Doragonsureiyā
Hi help me please why the form is not valid my cod
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://linkode.org, https://nekobin.com (or your favorite one)
S
Can anyone help me, I'm writing query to get most bookmarked objects in django but when I'm trying to use serializer it's throwing error. How can I retrieve only required fields from django model instead all fields
S
ok tq i try that
S
With django orm you can filter objects to the ones you need Just use filter() method
The issue is coming only when I'm using serializer, if I try to return data directly it's working fine but when I'm trying to return serializer. data it's not working
S
https://dpaste.org/LdhX9 here is my code can anyone guide me where im doing wrong
Nazir
How to make a graph in graph
Anonymous
im getting this error : "Key 'slug' not found in 'CustomUserForm'. Choices are: date_joined, email, first_name, groups, is_active, is_staff, is_superuser, last_login, last_name, password, user_permissions, username." while using slug . but couldnt find any reason i just added slug field to model and prepopulated_field to admin site prepopulated_fields = {"slug":['username']} model:slug = models.SlugField(default='',null=True) but models is based on abstactuser , i thought maybe that is problem
Anonymous
can you hlp?
GoodOne
HI even though base dir is mentioned interpreter is looking static file under template
Anonymous
HI even though base dir is mentioned interpreter is looking static file under template
Because you need to declare your static files in settings.py
Shrey
Hello Everyone, By default django servers run on http urls or IP Addresses. Currently my project is running on hosted ip_address How do we make the project run on https !? I tried using django-sslserver, even have SSL Certificates and key. What are the other modifications required inside settings.py file !?
S
Hello, can anyone guide me... how can i get recently viewed objects in django ? is there any reference plz help me
Miriam
Good morning, I am getting the following error and I do not know why, I have looked for possible reasons but none of the ones I have found seem to have to do with my case.. —> A server error occurred. Please contact the administrator. my settings.py it is: https://pastecode.io/s/4tapmw4y
Miriam
it is too generic an error for too many possibilities, it would have to be corrected because it does not disclose information and no error appeared in the terminal
Muبaّşir
How to write transaction history model for product and money Help me pls
Anonymous
How to write transaction history model for product and money Help me pls
Write something, when You encounter a difficulty then ask for help
Anonymous
Your project is yours to handle
Shrey
The common way is to use s reverse proxy (nginx is a popular option) and set up there the SSL certificates
Our company already has done reverse proxy onto the IP and installed SSL Certificates for use !! When I used django-sslserver to run django project, the project url showed https:// but could access the same !!
Adithya
Hii everyone I have created AbstractUser for 3 users in project while i am trying to create a user by running this command Library.objects.create_user(username='adithya', password='adi') i am getting following error raise TypeError("%s() got an unexpected keyword argument '%s'" % (cls.name, kwarg)) TypeError: Library() got an unexpected keyword argument 'username' please help me guys
SantiU
Hello! How to associate two Django users to the same data? one with write permission, and the other with read permission? Thankss
Adithya
ohh then how to create brother could you please explain
Meme
You could create users using django built in user model or a custom model that inherits from abstractuser
Adithya
https://linkode.org/#JpJGwSZX8EhVJ6CbOHG0L
Meme
https://linkode.org/#JpJGwSZX8EhVJ6CbOHG0L
The library model is a proxy model that inherits from the users model. Which means library doesn't have its own table in database .
Meme
But iam able to see table in admin page!
Library model doesn't not create a new table in the database
Meme
Instead it inherits from users
Adithya
okay but why iam getting error bro, how to solve it
Meme
To create a Library user right ?
Meme
It's hard for me to go back and forth with code 😜 .
Meme
I think you need to modify create user method of the customusermanager
Adithya
Ohh okay bro
Adithya
Tq
Meme
Ohh okay bro
Try the below code .
Meme
def create_user(self, email, password=None, role=None, **extra_fields): if not email: raise ValueError('Email is required') email = self.normalize_email(email) user = self.model(email=email, role=role, **extra_fields) user.set_password(password) user.save() if user.role == Users.Role.LIBRARY: LibraryProfile.objects.create(user=user)
Meme
?
Pls lemme know if it works or not
Krishna
Hi I want learn django Can any one teach me please
Doragonsureiyā
Hi I want learn django Can any one teach me please
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls