Alex
There is ofcourse a bit of mess with it in django admin, but you should not rely on it.
Luis
In django templates are representation layer.
I just liked what I see on the admin
Luis
Ok I think I got it
Alex
I just liked what I see on the admin
You should not rely on __str__ in your app.
Alex
At least if it's (your app) for someone other than you.
Luis
Another thing, not related: if I want to create more User fields
Luis
should this be done by relating another model to the User or by creating a custom User model?
Luis
or, how would you go if you wanted to create a user comments model
Luis
It depends on your database design
I want each user to post one comment per product but they can post comments in many products.
Luis
How do I identify the User?
Luis
sorry for my bad question
Luis
where can I read more about example django database designs?
Alex
I want each user to post one comment per product but they can post comments in many products.
> I want each user to post one comment per product Sounds more like a review, than a comment. So there are 3 entities - Users, Products and Reviews. User may have many reviews, but a review has only single user. Therefore we make: class Review: user = ForeignKey(User) A review can be dedicated only for single product. So we add there one more fk - to a product. I'm ommiting here fields like text, rate and other.
Alex
I see
We also can add it unique_togther constraint to the Review model so a user could not review the same product multiple times. https://docs.djangoproject.com/en/3.1/ref/models/options/#unique-together like unique_together = [['user', 'product']]
Luis
But you helped me a lot.
Alex
But you helped me a lot.
U r welcome, kiddo.
Alex
where can I read more about example django database designs?
Database design is a separate topic in software development and has nothing to do with django. Here's a book I learned about database design myself. "Beginning Database Design" by Clare Churcher
Creator
Hey How Can I Create Quiz with Next Button . i.e ; After Hitting Next Button it should render next Question From Dictionary passed in context
Creator
Hey How Can I Create Quiz with Next Button . i.e ; After Hitting Next Button it should render next Question From Dictionary passed in context
Богдан
I got ”message": "Select a valid choice. That choice is not one of the available choices.", "code": "invalid_choice" in insurance_company field However i got valid queryset Please tell me what's wrong? from django import forms from .models import Contract, Insurance ​ class InsuranceContractForm(forms.ModelForm): class Meta: model = Contract fields = "__all__" ​ def __init__(self, *args, **kwargs): insurance_company = kwargs.pop('insurance_company', '') super(InsuranceContractForm, self).__init__(*args, **kwargs) self.fields['insurance_company'] = forms.ModelChoiceField( queryset=Insurance.objects.filter(code=str(insurance_company)),)
Haleem
I have a Client model where I need relationship to multiple users from User Model. I am using OneToMany relationship field. I can able to select only one user in Admin Panel from drop down list. I want to select multiple users instead of one. Should I have to use ManyToMany relationship or there is anyway to select multiple users in dropdown list in admin panel.
Богдан
Anonymous
In this case you are using ur own custom class. The built in User object is inherited from django.contrib.auth.models library
So how can I use this class to generate a token using signals as it showing some errors
Anonymous
Ajay Bansal: My custom user model is not able to generate tokens. Users are registered to database but token is not generated can anyone help Showing error : <user: mike> token. User must be a user instance
Anonymous
https://pastebin.com/0vM4KNup
Anonymous
Here is the code
Raazu
Hello All, Any one giving training on Django real-time projects and scenario's. Thanks in advance
Mirco
https://pastebin.com/0vM4KNup
Wait you are not overriding the Django user
Anonymous
Wait you are not overriding the Django user
For that will I have to change my user model name?
Mirco
For that will I have to change my user model name?
It's not the correct way to create your custom user model
ken
hi. is it possible to show user profile in django using built-in functions (and some bootstrap in templates, of course)
Anonymous
I have basic knowledge of django framework, so how much time does it take to learn rest framework , api
Anonymous
Anonymous
Any suggestions for study materials
Anonymous
??
âshîsh
Official documents are best
Anonymous
Official documents are best
I hate reading documentation
Anonymous
:(
Alex
I hate reading documentation
No one will read it for you
âshîsh
I hate reading documentation
then pls don't be a developer ! that would be safe for all of us 😛
âshîsh
Rude, but this.
take this as sarcasm ! not rude
Anonymous
Ok I won't then
Anonymous
Thanks for your help guys
âshîsh
Ok I won't then
😂 lol... i was kidding ! documents are for our help.
Anonymous
You guys love reading documentation?
Doragonsureiyā
Any suggestions for study materials
Are you looking for Django REST Framework documentation? Here you have it: https://www.django-rest-framework.org/
Anonymous
Yikes
Anonymous
I'm in the wrong business
Mirco
âshîsh
Don't read like a theory book to pass the semester ! Read like you have a query and want to find the answer
âshîsh
Yeah I do this when I have to and stackoverflow can't help 🤣
irony when you find 'Read official document' comment in answers 🤓
Anonymous
1st take it practically from youtube.. then again read documents.. u can get it Easyly😂..but 1st read dovumnets then do practically its like why i am coder?😀
Valentine ✙
Hi there! Speaking about DRF, I found myself being throttled on localhost after I tried to test anon throttling settings. Tried to cache.clear(), clear LockMemCache, restart server, cleared browser caches and data. Still being throttled by my own django code. Is it smth like land mine for begginers? I looked at DRF throttling code, they do use default cache to store/check client . What else it can be?
Anonymous
Chatbot project which one is good Django signals Django channels Socket.io
Богдан
How to fix validation error in ModelForm: “Select a valid choice. That choice is not one of the available choices.”? https://dpaste.org/Enfy
Богдан
Why are u keeping stringify the foreign key ? It's an integer
I have an int, by which I need to find a model for saving in foreign key field
Harsh
Any suggestions for implementing particular time stop and after that start on particular time django website
Harsh
I have website in django which is based on HRMS. I want to implement a service which can can Stop all services on particular time without stop server