Deploying django in plesk

2021-08-25 Thread frank galan
Hi everybody.
I've already deployed my app in Plesk, but the process is incomplete, .
The static files not working, I mean the app can not read them.
I know I need put them in the right position, but I can not achieve.
Any help is welcome
thanks a lot in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/181a730e-2157-42f6-b540-d1b1dc19c640n%40googlegroups.com.


Re: Hi group am new here

2021-04-04 Thread frank galan
It is not a translation from spanish at all, may be  should came from
another language, or it is an incomplete question and he was mean machine
learning, could be?

El dom, 4 abr 2021 a las 21:24, Kasper Laudrup ()
escribió:

> On 04/04/2021 12.08, believeme mum007 wrote:
> >
> > Please i will be happy to see who will explain well for me concerning
> > the machine
> >
>
> This has to be one of the funniest things I've read here so far.
>
> Would anyone happen to know if this is a case of bad machine translation
> and if so from which language?
>
> Just curious.
>
> Best regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6e5af770-7f43-1205-f5e1-bac7eabc48a9%40stacktrace.dk
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPedvKWUMWXZnD%2BocGyxgZykqpsLYtTcJOVyyaV-tmoNzJBR3Q%40mail.gmail.com.


Re: ListView , Need Help !

2021-04-04 Thread frank galan
Could you show your html and css code ?

El dom, 4 abr 2021 a las 16:57, ICT Giants Uganda ()
escribió:

> You can also look into using bootstrap css.
>
> On Sun, Apr 4, 2021 at 8:01 AM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
>> This is related to front-end coding mi amigo
>>
>> Regards,
>> Amitesh
>>
>>
>> On Sunday, 4 April, 2021, 07:59:53 am IST, Ryan Nowakowski <
>> tuba...@fattuba.com> wrote:
>>
>>
>> Take a look at CSS to change how your blog posts are laid out.
>>
>> On April 3, 2021 4:19:49 PM CDT, Mustafa Burhani <
>> mustafaburhan...@gmail.com> wrote:
>>
>> When i create blog post they are aligned vertical i want align be
>> horizontal how i can do ?
>>
>>
>>
>> For Example :
>> #  Vertical Post
>> # Vertical Post
>> #  Vertical Post
>> # Vertical Post
>>
>>
>> I want be :
>>
>> # horizontal Post # horizontal Post # horizontal Post # horizontal Post
>>
>>
>> I hope if you understand me
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>>
>> https://groups.google.com/d/msgid/django-users/53B9E421-4459-4437-BE76-B485A17D1C93%40fattuba.com
>> 
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/1714866023.2573794.1617512474859%40mail.yahoo.com
>> 
>> .
>>
>
>
> --
>
>
> *ICT Giants*
>
> *P.O. Box 9454 Kampala Uganda*
>
> *Email: ictgia...@gmail.com  / info@i
> ctgiants.xyz *
>
> *Website: http://www.i ctgiants.xyz
> *
>
> *Whatsapp: +256750 644 449*
> *Phone: +256774 644 449*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAP2fLWQFY_yOdkVgr54w_eVefJC4aNQwkdc5ww9jKVsN5eMapA%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPedvKVN7qjm8Exu%3DVVVgyra1SD3M-GvTnzzzAwR2VESHNwtuA%40mail.gmail.com.


Hello mates

2021-03-29 Thread frank galan
Im catching a model in a select, using ajax to request, so Im receiving an 
error I can,t solve
Im get an empty dict, the error is :
error: "'str' object has no attribute 'toJSON'".
Its occurrs when  I try to print  the data in console
I created a function into the model to convert this in dict, late I define 
the view  and create the ajax function. You will see the code below:
Thanks in advance

*MODEL*
*from django.forms import model_to_dict*

class Item(models.Model):
"""Items Product model"""
operation = models.ForeignKey(Operation, on_delete=models.CASCADE)
brand = models.ForeignKey(Brand, on_delete=models.CASCADE)
subcategory = models.ForeignKey(SubcategoryItem, 
on_delete=models.CASCADE)
categ = models.ForeignKey(CategItem, on_delete=models.CASCADE)
section = models.ForeignKey(Section, on_delete=models.CASCADE)
currency = models.ForeignKey(Currency, on_delete=models.CASCADE)
item_name = models.CharField(max_length=255, verbose_name='item')
item_description = models.TextField(null=True)
item_SKU = models.CharField(max_length=100, null=False, blank=True)
ean = models.CharField(max_length=100, unique=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=100, null=True)
is_active = models.BooleanField()
price = models.PositiveIntegerField(null=True)
purchase_price = models.PositiveIntegerField(null=True, blank=True)
tax = models.PositiveIntegerField(null=True)
color = models.CharField(max_length=30, null=True)
size = models.CharField(max_length=3, null=True, blank=True)
weight = models.CharField(max_length=5, null=True, blank=True)
height = models.CharField(max_length=5, null=True, blank=True)

image = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_1 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_2 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_3 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_4 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_5 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)

class Meta:
ordering = ('item_name',)

def __str__(self):
return self.item_name

def toJSON(self):
item = model_to_dict(self)
item['item_name'] = self.item_name.toJSON()
item['item_description'] = self.item_description.toJSON()
item['item_SKU'] = self.item_SKU.toJSON()
item['operation'] = self.operation.toJSON()
item['brand'] = self.brand.toJSON()
item['subcategory'] = self.subcategory.toJSON()
item['categ'] = self.categ.toJSON()
item['section'] = self.section.toJSON()
item['price'] = format(self.price, '.2f')
item['purchase_price'] = format(self.purchase_price, '.2f')
item['tax'] = format(self.tax, '.2f')
item['weight'] = format(self.weight, '.2f')
item['height'] = format(self.height, '.2f')
return item

def get_absolute_url(self):
return reverse('all_items.html', kwargs={'pk':self.id})


*VIEW*
class SoldCreate(LoginRequiredMixin, CreateView):
model = Sold
form_class = SoldForm
template_name = 'solds/add_invoice.html'

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['tittle'] = 'Sold Forms'
context['table_tittle'] = 'New sold'
context['table_subtittle'] = 'Add here your new solds'
return context

@method_decorator(csrf_exempt)
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)

@method_decorator(csrf_exempt)
def post(self, request, *args,**kwargs):
data={}
try:
action = request.POST['action']
if action == 'search_item':

#data=[]
prods = 
Item.objects.filter(item_name__icontains=request.POST['term'])
  
for i in prods:
item = i.toJSON()
item['value'] = i.item_name
data.append(item)

else:
data['error']='no ha ingresado una opcion'
except Exception as e:
data['error'] = str(e)

return JsonResponse(data, safe=False)

def get_success_url(self):
return reverse('all_sold')



*AJAX*

$('#search_box').autocomplete({
source:function(request, response){
alert(request.term);

$.ajax({
url:window.location.pathname,
type: 'POST',
data: {
'action':'search_it

Re: hi mates trouble with ajax 500 error server

2021-03-28 Thread frank galan
Thanks a lot, you're right. I solved it. Thanks


El dom, 28 mar 2021 a las 0:57, Kasper Laudrup ()
escribió:

> On 27/03/2021 21.41, frank galan wrote:
> > thanks, here is the server error response
> >
> > NameError: name 'JsonResponse' is not defined
> >
>
> That error message should be fairly obvious. You haven't defined
> anything called JsonResponse.
>
> You most likely just need to import the correct module. I don't know
> what that would be, but it would probably be from the library you use to
> generate JSON responses whatever that might be.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f6eff0e2-5eb2-5225-78ca-5f80d4827ee7%40stacktrace.dk
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPedvKXzMWM3aSoPq86VjS6yBeUhJ_ARPWdX4jAEGkm7KesrOQ%40mail.gmail.com.


Re: hi mates trouble with ajax 500 error server

2021-03-27 Thread frank galan
thanks, here is the server error response

Traceback (most recent call last):

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/exception.py",
line 47, in inner

response = get_response(request)

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py",
line 179, in _get_response

response = wrapped_callback(request, *callback_args, **callback_kwargs)

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/views/generic/base.py",
line 70, in view

return self.dispatch(request, *args, **kwargs)

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/utils/decorators.py",
line 43, in _wrapper

return bound_method(*args, **kwargs)

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/views/decorators/csrf.py",
line 54, in wrapped_view

return view_func(*args, **kwargs)

  File
"/Users/blackmaster/Documents/programacion/proyectos_django/localsys/backoffice/views/sold.py",
line 49, in dispatch

return super().dispatch(*args, **kwargs)

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/contrib/auth/mixins.py",
line 52, in dispatch

return super().dispatch(request, *args, **kwargs)

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/views/generic/base.py",
line 98, in dispatch

return handler(request, *args, **kwargs)

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/utils/decorators.py",
line 43, in _wrapper

return bound_method(*args, **kwargs)

  File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/views/decorators/csrf.py",
line 54, in wrapped_view

return view_func(*args, **kwargs)

  File
"/Users/blackmaster/Documents/programacion/proyectos_django/localsys/backoffice/views/sold.py",
line 72, in post

return JsonResponse(data, safe=False)

NameError: name 'JsonResponse' is not defined

[27/Mar/2021 20:39:37] *"POST /dashboard/backoffice/new_sold HTTP/1.1" 500
96481*

El sáb, 27 mar 2021 a las 18:48, Kasper Laudrup ()
escribió:

> On 27/03/2021 15.13, frank galan wrote:
> > Im receiving a 500 server error,  when I trying  to obtain data wiith
> > ajax from my model.
>
> You should look at the server logs or the output from the console. That
> should hopefully provide some details on the reason behind the "Internal
> Server Error".
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b3540a30-7ece-f675-c3eb-710e74065686%40stacktrace.dk
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPedvKX-fEz5S9QJHLvMfKLuv-HuHi1ztnd8%3Dz_y9_cJ3LgPAQ%40mail.gmail.com.


hi mates trouble with ajax 500 error server

2021-03-27 Thread frank galan
Im receiving a 500 server error,  when I trying  to obtain data wiith ajax 
from my model. 
 My details are as follows:
*Model:*
class Item(models.Model):
"""Items Product model"""
operation = models.ForeignKey(Operation, on_delete=models.CASCADE)
brand = models.ForeignKey(Brand, on_delete=models.CASCADE)
subcategory = models.ForeignKey(SubcategoryItem, 
on_delete=models.CASCADE)
categ = models.ForeignKey(CategItem, on_delete=models.CASCADE)
section = models.ForeignKey(Section, on_delete=models.CASCADE)
currency = models.ForeignKey(Currency, on_delete=models.CASCADE)
item_name = models.CharField(max_length=255, verbose_name='item')
item_description = models.TextField(null=True)
item_SKU = models.CharField(max_length=100, null=False, blank=True)
ean = models.CharField(max_length=100, unique=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=100, null=True)
is_active = models.BooleanField()
price = models.PositiveIntegerField(null=True)
purchase_price = models.PositiveIntegerField(null=True, blank=True)
tax = models.PositiveIntegerField(null=True)
color = models.CharField(max_length=30, null=True)
size = models.CharField(max_length=3, null=True, blank=True)
weight = models.CharField(max_length=5, null=True, blank=True)
height = models.CharField(max_length=5, null=True, blank=True)

image = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_1 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_2 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_3 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_4 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)
image_5 = models.ImageField(
upload_to='backoffice/static/images',
blank=True,
null=True
)

class Meta:
ordering = ('item_name',)

def __str__(self):
return self.item_name

def toJson(self):
item = model_to_dict(self)
item['item_name'] = self.item_name.toJson()
item['item_description'] = self.item_description.toJson()
item['item_SKU'] = self.item_SKU.toJson()
item['operation'] = self.operation.toJson()
item['brand'] = self.brand.toJson()
item['subcategory'] = self.subcategory.toJson()
item['categ'] = self.categ.toJson()
item['section'] = self.section.toJson()
item['price'] = format(self.price, '.2f')
item['purchase_price'] = format(self.purchase_price, '.2f')
item['tax'] = format(self.tax, '.2f')
item['weight'] = format(self.weight, '.2f')
item['height'] = format(self.height, '.2f')
return item
   
def get_absolute_url(self):
return reverse('all_items.html', kwargs={'pk':self.id})


*HTML :*


  
  

  
  

*Ajax*
$('#search_box').autocomplete({
source:function(request, response){
alert(request.term);

$.ajax({
url:window.location.pathname,
type: 'POST',
data: {
'action':'search_item',
'term': request.term
},
dataType:'json',
}).done(function(data){
response(data);
alert('hola');
}).fail(function (jqXHR,textStatus, errorTrown){
alert( errorTrown);
}).always(function(data){

});

},
delay: 500,
minLength: 1,
select: function(event, ui){
console.log(ui.item);

}
});

*Sold.py View*

#Creating an invoice instance
class SoldCreate(LoginRequiredMixin, CreateView):
model = Sold
form_class = SoldForm
template_name = 'solds/add_invoice.html'

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['tittle'] = 'Sold Forms'
context['table_tittle'] = 'New sold'
context['table_subtittle'] = 'Add here your new solds'
return context

@method_decorator(csrf_exempt)
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)

@method_decorator(csrf_exempt)
def post(self, request, *args,**kwargs):
data={}
try:
action == request.POST['action']
if action == 'search_item':
data = []

prods = 
Item.objects.filter(name__icontains=request.POST['term'])
  

for i in prods:
item = i.item_description
item['value'] = i.item_name
data.append(item)

else:
data['error']='no ha ingresad