Вячеслав
If you need to migrate to other db you need the migrate command
Вячеслав
"python manage.py migrate"
Akash
Ok
Akash
Thank you
Rahul
Can any one help me to create mws token for Amazon seller api
Michael ✨
.
Zerat
How can i implement "related products" or "simmilar books " for my django bookstore
Charly
have you tried it?
Shubham
There is no model given to filter kn
Shubham
You are filter on parent status, that's correct right?
Peppe
https://stackoverflow.com/questions/67286037/why-the-platform-create-a-new-wallet Anyone?
Zoro
yes. sure. if order is a foreign key, with order__ you can access the order fields for each product row.
Peppe
Thanks!
Zoro
https://stackoverflow.com/questions/67286037/why-the-platform-create-a-new-wallet Anyone?
well. first of all. never create something and then delete it later based on a condition. this is bad practice that leads to overcomplications and its hard to debug. first, rewrite your code that only when your condition is met, you create the wallet. and then, lets see if the problem still exists.
Peppe
okok
Zoro
How can i implement "related products" or "simmilar books " for my django bookstore
you can create a middle table for similar books, or if you have a column in your book table that defines the genre, you can search similar books by filtering genre
Peppe
@login_required def wallet_new(request): wallets = Wallet.objects.all() if request.method == "POST": form = WalletForm(request.POST) if form.is_valid(): new_wallet = form.save(commit=False) new_wallet.profile = request.user new_wallet.save() return render(request, 'app/response_wallet_executed.html') form = WalletForm() contex = {'form': form} return render(request, 'app/wallet_new.html', contex)
Peppe
ok
Zoro
good luck😁
Peppe
Thanks!
Peppe
wait, i don't understand
Peppe
@login_required def wallet_new(request): wallets = Wallet.objects.filter(profile=request.user) if request.method == "POST": form = WalletForm(request.POST) if form.is_valid(): new_wallet = form.save(commit=False) new_wallet.profile = request.user new_wallet.save() return render(request, 'app/response_wallet_executed.html') form = WalletForm() contex = {'form': form} return render(request, 'app/wallet_new.html', contex)
Peppe
right?
Peppe
i want to check if the user has a wallet, if user not has a wallet,it create, but if the user has a wallet, return page: 'you have a wallet'
Peppe
and if i use the variable 'wallets' and compare with new_wallet,profile return an error, i can't compare new_wallet.profile with 'nonetype', because the user has not a wallet, don't exists
Zey
Hii,I am sending email template using send_mail but when I am receiving mail it is not showing images which are in template?
Zerat
you can create a middle table for similar books, or if you have a column in your book table that defines the genre, you can search similar books by filtering genre
thanks for your reply, I do have a genre, but i had troubles using select_related since i use manyToMany field
Zoro
thanks for your reply, I do have a genre, but i had troubles using select_related since i use manyToMany field
aha. i think it would be resolved by the django orm, but i never use them myself, because they tend to get more complicated and controlling them gets hard over time, unless you are absolutely sure that they dont change. and btw, you dont need many to many. just put a foreign key in books.
Zerat
aha. yes. that makes sense
class Book(models.Model): authors = models.ManyToManyField('Author', help_text="Add authors that contributed the this book.", related_name="authors") isbn = models.CharField('ISBN 13', max_length=13, unique=True, help_text='13 Character <a href="https://www.isbn-international.org/content/what-isbn">ISBN number</a>') ... genre = models.ManyToManyField(Genre, help_text='Select a genre for this book') ...
Zerat
well in this case, if im not mistaken, filtering by genre__title or something, would result in similar genres
I really don't want to bother, but I'm getting stuck 'ManyToManyDescriptor' object is not subscriptable
Elii
Hi guys. How can I serialize when I have multi models that have relationships? For exp: I have these tables that related each other with FK Account -> Product ->Attribute->Attribute value
Zerat
Hi guys. How can I serialize when I have multi models that have relationships? For exp: I have these tables that related each other with FK Account -> Product ->Attribute->Attribute value
I'll show you what I've done with my books to serialize multiple models class BookSerializer(serializers.ModelSerializer): author = AuthorSerializer(many=False) genre = serializers.StringRelatedField(many=True) language = serializers.StringRelatedField(many=True)
Zerat
and then, you need to make serializer for each model, like class GenreSerializer(serializers.ModelSerializer): class Meta: model = Genre fields = ('name',) class LanguageSerializer(serializers.ModelSerializer): ... class AuthorSerializer(serializers.ModelSerializer): ...
Rup
i deleted all database and freshly start to create database table. i deleted all migrations from all app. and make new migrations now i am getting this error at the time of migrationg
Rup
error: psycopg2.errors.UndefinedTable: relation "sales_creditnote" does not exist.
Rup
i used "sales_creditnote" as foreignkey
Rup
please help me i am struglling from morning still unable to solve.
noneofurfuckinbusiness
noneofurfuckinbusiness
Into database
noneofurfuckinbusiness
Delete ur database, create a new one, then makemigrations, then migrate
Rup
Yes, but when I am applying python manage.py makemigrations It shows no migrations to apply and python manage.py migrate it shows error
noneofurfuckinbusiness
Y don't need to delete migration files, if u delete database
Rup
Y don't need to delete migration files, if u delete database
Files was present in my app it shows error so I deleted all migrations also
noneofurfuckinbusiness
noneofurfuckinbusiness
Delete migrations of all apps
Rup
I deleted all migrations from all app and database also
noneofurfuckinbusiness
Hmm. Do u have git repository of ur project
Rup
No
noneofurfuckinbusiness
Send me clone url, will check ur code
noneofurfuckinbusiness
Upload to git.
Rup
I don't have git yet
noneofurfuckinbusiness
Is it showing no migrations to apply even after deleting all migrations?
Rup
Yes
Rup
No changes detected
noneofurfuckinbusiness
How did u delete database?
Sumit
Hi, I have very strange error , I am using nginx with django, when I am using debug =True , it is working fine, but when I am using debug =False, it is throwing Server Error(500).Please help me.
Rup
In postgres I drop the database and create new one
noneofurfuckinbusiness
If u deleted all migrations, then it should not show no changes detected
Rup
Yes but it's showing. Where I am doing wrong. Not getting it
noneofurfuckinbusiness
How did u delete migrations
Rup
In vs code select folder migrations right click delete
noneofurfuckinbusiness
Ok, go to sales app folder, open migrations folder
noneofurfuckinbusiness
Remove pycache too
noneofurfuckinbusiness
Rup
Okay
Sumit
I am just refreshing
noneofurfuckinbusiness
yes
Write a try except statement for every line in view of that url with some message in print(), find out which line is causing error
Rup
I deleted pycashe too. And run makemigrations. It says no changes detected
Rup
Pycache