Mr
No
What about file encryption, but if I do that will django be able to access it
Charly
What about file encryption, but if I do that will django be able to access it
Think about it, python is an interpreted language, so the interpreter needs to read it to execute it, so if you encrypt it, interpreter won't be able to read it.
Charly
Or if you encrypt and decrypt before the interpreter does it then it will be accessible for anyone wanting to look it
Charly
So basically I f**ked up
You can obfuscate, something like pyarmor but you fucked it by using python if you wanted to have closed source
Charly
Pyinstaller will be almost fine to hide it a certain level
Mr
Pyinstaller will be almost fine to hide it a certain level
I see. But can it still get decrypted by someone
Mr
What if I sell it with a mini pc with the hdd bit locked .. will it still run on their internal network
Charly
What if I sell it with a mini pc with the hdd bit locked .. will it still run on their internal network
If they have access to the server it doesn't matter if it has bit locker
Charly
So it means bit locker can be removed
No, it means bit locker does encrypt on disk but once you start the machine you have access to files
Mr
Oh I see
Anthony
Any Ideas on how to get any similar results
Is it not possible to stand up the application as a cloud hosted web service and give them access to a subdomain? It's still their software running on their own instance. They can even have access to the admin page but it would keep the source code out of their hands.
Charly
Any Ideas on how to get any similar results
Why you want to hide the code? The best way to protect you is legally. I mean if you are not already charging by the software then offer it as a SaaS
Mr
So again, why you need to protect the code?
To prevent copy, or someone changing things and claiming it
Mr
But aren't they buying it?
They are buying a copy , but some may rework on the open source they bought and resell
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
https://iamshammas.pythonanywhere.com/
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
https://iamshammas.pythonanywhere.com/
anyone know solution for this error?
Samor
anyone know solution for this error?
No one can tell you without looking at the code
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
No one can tell you without looking at the code
import uuid from itertools import product from django.shortcuts import render, redirect, get_object_or_404 from shop.models import * from .models import * from django.core.exceptions import ObjectDoesNotExist def get_cart_id(request): cart_id = request.session.get('cart_id') if not cart_id: cart_id = str(uuid.uuid4()) request.session['cart_id'] = cart_id return cart_id def cart_details(request, tot=0, count=0, cart_items=None): c_id_val = get_cart_id(request) ct_items = [] try: ct = cartlist.objects.get(cart_id=c_id_val) ct_items = items.objects.filter(cart=ct, active=True) print(ct_items) for i in ct_items: tot += (i.prodt.price*i.qty) count += i.qty except ObjectDoesNotExist: pass return render(request, 'cart.html', {'ci': ct_items, 't': tot, 'cn': count}) def c_id(request): ct_id = request.session.session_key if not ct_id: request.session.cycle_key() ct_id = request.session.session_key return ct_id def add_cart(request,product_id): prod = products.objects.get(id=product_id) c_id_val = get_cart_id(request) # use get_cart_id function to get the cart ID try: ct = cartlist.objects.get(cart_id=c_id_val) except cartlist.DoesNotExist: ct = cartlist.objects.create(cart_id=c_id_val) ct.save() try: c_items = items.objects.get(prodt=prod,cart=ct) if c_items.qty < c_items.prodt.stock: c_items.qty += 1 # increment the quantity correctly c_items.save() except items.DoesNotExist: c_items=items.objects.create(prodt=prod,qty=1,cart=ct) c_items.save() return redirect('cartDetails') def min_cart(request,product_id): ct = cartlist.objects.get(cart_id=get_cart_id(request)) prod = get_object_or_404(products,id=product_id) c_items = items.objects.get(prodt=prod,cart=ct) if c_items.qty > 1: c_items.qty -=1 c_items.save() else: c_items.delete() return redirect('cartDetails') def cart_delete(request,product_id): ct = cartlist.objects.get(cart_id=get_cart_id(request)) prod = get_object_or_404(products,id=product_id) c_items = items.objects.get(prodt=prod,cart=ct) c_items.delete() return redirect('cartDetails')
Amir
Hello and I hope you are well. I am looking for a good book for Django. If you know, let me know
Mr
anyone know solution for this error?
It's the dictionary you are passing, assigne the dictionary to a variable and pass that variable
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
Mr
can u tell me wht do i need to change in views py
In the line that returns the homepage .. fix 1 : create a variable and assign the dictionary you are passing to it and pass the variable
Mr
can u tell me wht do i need to change in views py
Context ={'pr': prodt, 'ct': cat} return render(request, 'index.html',Context )
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
def home(request, c_slug=None): c_page = None prodt = None if c_slug != None: c_page = get_object_or_404(categ, slug=c_slug) prodt = products.objects.filter(category=c_page, available=True) else: prodt = products.objects.all().filter(available=True) paginator = Paginator(prodt,3) try: page = int(request.GET.get('page','1')) except: page = 1 try: prodt = paginator.page(page) except (InvalidPage,EmptyPage): prodt = paginator.page(paginator.num_pages) cat = categ.objects.all() Context ={'pr': prodt, 'ct': cat} return render(request, 'index.html',Context )
Mr
changed but still same error
Exclude the product "pr":prodt you are passing and see if it gets an error
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
still error
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
i tried someways before by searching on google, but even though i change something, always same type error
Mr
You did this ct = cartlist.objects.filter(c_id(request))
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
def count(request): item_count=0 if 'admin' in request.path: return {} else: try: ct = cartlist.objects.filter(c_id(request)) cti = items.objects.all().filter(cart=ct[:1]) for c in cti: item_count += c.qty except cartlist.DoesNotExist: item_count=0 return dict(itc=item_count)
Mr
You are supposed to add =
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
i was learning , i did like the video said, they said it is for counting how many items in cart and showing on index page , near to cart button
Mr
Don't return the context
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
Then in the home function do return anything
i didnt did anything related to count on home function
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
i did on base html only
Mr
I mean don't pass the context in the return statement
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
Mr
i didnt
def home(request, c_slug=None): # Get the category if a slug is provided, otherwise set to None category = get_object_or_404(Category, slug=c_slug) if c_slug else None # Fetch products based on category filter, if category exists products_qs = Product.objects.filter(category=category, available=True) if category else Product.objects.filter(available=True) # Paginate the products queryset paginator = Paginator(products_qs, 3) # Show 3 products per page page_number = request.GET.get('page', 1) try: products_page = paginator.page(page_number) except PageNotAnInteger: # If the page number is not an integer, deliver the first page products_page = paginator.page(1) except EmptyPage: # If the page is out of range, deliver the last page products_page = paginator.page(paginator.num_pages) # Get all categories to show in the context categories = Category.objects.all() context = { 'products': products_page, # Renamed for clarity 'categories': categories, # Renamed for clarity 'selected_category': category, # Optional: to track which category is selected } return render(request, 'index.html', context)
Mr
i didnt
Try replacing you home with this
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
not working now
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
it worked for a sec and when i refresh, not working
Mr
not working now
Which error
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
NameError at / name 'Product' is not defined Request Method: GET Request URL: https://iamshammas.pythonanywhere.com/ Django Version: 4.0.6 Exception Type: NameError Exception Value: name 'Product' is not defined Exception Location: /home/iamshammas/avodhashop/shop/views.py, line 17, in home Python Executable: /usr/local/bin/uwsgi Python Version: 3.9.13
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
NameError at / name 'Category' is not defined Request Method: GET Request URL: https://iamshammas.pythonanywhere.com/ Django Version: 4.0.6 Exception Type: NameError Exception Value: name 'Category' is not defined
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
it should be the function name in model.py?
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
Mr
worked
That's great
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
thanks, it is not showing images now
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
i have to add new database, right?
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
earlier i added from my pc, now i am running on pythonanywhere. com
Mr
i have to add new database, right?
How do you upload your images
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
Where are the images supposed to show
i added some place photos fruits, etc and filter option to show places only
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
Are the images added dynamically
there was option from admin panel
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
there was 2 categories,
Mr
there was option from admin panel
So which folder is holding the images, show me the path
𝚂 𝙷 𝙰 𝙼 𝙼 𝙰 𝚂
So which folder is holding the images, show me the path
in home directory, there is a directory named "media" inside that product direct, inside that images