Anonymous
Hey guys how exactly can we add profile pic in our django admin pannel
Roman
Hi , how do I serailizer FK so that I can read it as serialize but write it as id
Manav
Books
Name?
Roman
I don't want alow creating FK on foreign key but assign it
Roman
To the model
Shery
"apps.User"
thanks for reply. it returned 'apps.User' that has not been installed, cause model User is in apps/profiles. did I forget something?
Shery
Hi Niko. That's is my actual configuration and it works well, but i have too much apps in that project and i want to move them to an apps folder
Shery
I readed that is apps folder is a good practice in a blog, but looks like it dont work with this case
Nikolay
Hi Niko. That's is my actual configuration and it works well, but i have too much apps in that project and i want to move them to an apps folder
I understand that) Did you try to use ‘profiles.User’ after you had moved apps inside this folder? If it doesn’t work, you could try to specify appname in apps.py file of application
Shery
yeah, that is exactly what i tried. this is my apps.py: from django.apps import AppConfig class ProfilesConfig(AppConfig): name = 'profiles' May im missing how Im calling the profiles app in settings? cause I just changed it from profiles to apps.profiles at the INSTALLED_APPS variable.
Shery
I should return to the docs I think 😅
Nikolay
I should return to the docs I think 😅
Try to import model in shell and print User._meta.app_label
Roman
Is it possible to adjust to show some fields to serializer based on some custom input ? So that I have auth user and not and I want to show some fields of serialized only to some routers ?
Rhythm
hi
Anonymous
Do you know about django rest api and how to use on django template
Baku
Hello everyone! In my project users can give a feedback, how i can send notifications to admin panel if user give a feedback? My project working on Django
Anonymous
templates in rest api?
I have register API on views which i use to register in my phone APP and i want the same API to register in my Django template(HTML part)
Nikolay
Hello everyone! In my project users can give a feedback, how i can send notifications to admin panel if user give a feedback? My project working on Django
What do you mean by notification to admin panel? You can use signals to do something before or after creating/updating/deleting some instances
Baku
What do you mean by notification to admin panel? You can use signals to do something before or after creating/updating/deleting some instances
I mean Message that someone left a review or new reviews appeared so that the administrator can distinguish new reviews from previously submitted
Nikolay
I mean Message that someone left a review or new reviews appeared so that the administrator can distinguish new reviews from previously submitted
I don’t know anything about messages in Django admin-panel. But you can overwrite save method in model, or use signals to send your message after creating new review :)
Baku
Yes =)
Круто👍
deadspy
How can i render from views to templates and return again in views for futher condition
Shery
I readed that is apps folder is a good practice in a blog, but looks like it dont work with this case
Returned "profiles" (that's good, I guess) This is getting a bit complex because I'm writing the docker's files for my development team, so I think I'm going to research the function of applications. thanks for your help @NikolayCherniy
deadspy
Use Ajax
<okay Thanx>
Nikolay
Returned "profiles" (that's good, I guess) This is getting a bit complex because I'm writing the docker's files for my development team, so I think I'm going to research the function of applications. thanks for your help @NikolayCherniy
Not at all =) It should work in theory, cause Django use only app label and model name to find model. But I’ve never used this structure with apps folder, and I don’t think it’s a good practice.
Anonymous
In django if we r using static image file and index htma file inside an app ....what all changes needed anyone?
Anonymous
What is the superclass of django form
Enlighting-man
Hi, I need generate auto unique slug, could you help me, thank you.
Baku
Hi, I need generate auto unique slug, could you help me, thank you.
slug will be Django SlugField with unique=True
Nikolay
Hi, I need generate auto unique slug, could you help me, thank you.
Import slugify, make method with while loop, like : while ModelName.objects.filter(slug=self.slug).exists(): and here some logic to change slug
Rajesh
SMTP server
Yes i used it
Enlighting-man
Yep, that is the best way to do it :)
I was tried in the admin, and it's not making the auto copy, in the slug field :/ , is there anything missing?
Enlighting-man
Nikolay
I was tried in the admin, and it's not making the auto copy, in the slug field :/ , is there anything missing?
And try slug = models.SlugField(max_length=140, blank=True ) if there is an error with saving it empty
Enlighting-man
And try slug = models.SlugField(max_length=140, blank=True ) if there is an error with saving it empty
It is working!, but it repeats the slugs, it is not concatenating, I will review the code, to see where it is wrong, thanks! 👍
Alvi
hello everyone, i want to ask about how to get foreign key level... like binary tree lets say i have models like this.... class Food(models.Model): <-- this should be level 0 name = models.CharField(max_length=255) class RegionalFood(models.Model): <-- this should be level 1 food = models.ForeignKey(Food, on_delete=models.CASCADE) region = models.CharField(max_length=255) class FoodProduct(models.Model): <-- this should be level 2 region = models.ForeignKey(RegionalFood, on_delete=models.CASCADE) food_name = models.CharField(max_length=255) could you suggest some method for me to achieve this i already found module called django-mptt, but i think its overkill for my project... and the documentation is not clear thank you for your answer...
Bhavdeep Singh
hey everyone
can anyone help me with this?
Nikolay
It is working!, but it repeats the slugs, it is not concatenating, I will review the code, to see where it is wrong, thanks! 👍
check that everything rigth in this line while Article.objects.filter(slug=unique_slug).exists():
Alvi
related_name
how to count foreign key level with related_name? can you suggest me the logic? from what i know related_name is for accessing related model with foreign key...
Alvi
you wanna count foreign key objects?
i want to count chaining level... like binary tree class Food(models.Model): <-- this should be level 0 name = models.CharField(max_length=255) class RegionalFood(models.Model): <-- this should be level 1 food = models.ForeignKey(Food, on_delete=models.CASCADE) region = models.CharField(max_length=255) class FoodProduct(models.Model): <-- this should be level 2 region = models.ForeignKey(RegionalFood, on_delete=models.CASCADE) food_name = models.CharField(max_length=255)
Alvi
Food is the root node like this Food<- this should lvl 0 because its the root / \ western japanese <-this lvl 1 because its child of / \ / \ the Food burger hotdog ramen sushi < - this should be lvl 2 because it is the child of a japanese food
Mr
Which database is best for django.. MySQL or postgresSQL
Anonymous
hi guys ineed little help
Anonymous
<form action="{% url 'set_language'%}" method="post"> {% csrf_token %} <input type="hidden" name="next" value="{{ redirect_to }}"> <select name="language" id=""> {% get_available_languages as LANGUAGES %} {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} <option value="{{ language.code}}" {% if language.code == LANGUAGE_CODE %} selected {% endif %}> {{language.name.local}} {{language.name}} </option> {% endfor %} </select> <input type="submit" value="Go"> </form>
Anonymous
ı wanna change its css how can ı do ?
Anonymous
not offtopic how u can css
Anonymous
to django forms ??
Abdul
What do ypu mean by how?.....Add classes or id to the tags and link the style sheet.... If you are asking how to link css then add css files to static
Abdul
For example...... address = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'}))
Abdul
form-control field is added to that particular formd field then edit the class in linked css file that will be fine
Abdul
Hello, is there a UML tool I can use to plan my Django app?
Anonymous
For example...... address = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'}))
The the thing he is asking is not exact, the form he sent was made manually, look it wasnt made by django
Abdul
The the thing he is asking is not exact, the form he sent was made manually, look it wasnt made by django
"Add classes or id to the tags and link the style sheet.... If you are asking how to link css then add css files to static...... " Then go with this...
Anonymous
i'm facing this error https://pastebin.com/91dRb8sU
Roman
https://pastebin.com/4CbzJFN7 https://pastebin.com/29rux7AW Page not found (404) Request Method: POST Request URL: http://127.0.0.1:8000/bboard/add/%7B%25%20url%20'add_save'%20%25) Using the URLconf defined in samplesite.urls, Django tried these URL patterns, in this order: bboard/ add/save/ [name='add'] bboard/ add/ [name='add'] bboard/ <int:rubric_id>/ [name='by_rubric'] bboard/ [name='index'] admin/ The current path, bboard/add/{% url 'add_save' %), didn't match any of these.
Roman
where is my mistake?
Roman
PLS
Roman
https://pastebin.com/enanZSX2