Linking an Image detection Project to Django

2020-11-03 Thread ahmed.he...@gmail.com
Hi,

I am working on a colour detection project and I am trying to link it to my 
Django Project, but I don't know where to start.

In my Django project, I have a Post CreateView where users can upload 
images.

Here is the function that I am trying to link the colours in the image to 
Post.colors but I don't know how to make it generated directly once the 
image is uploaded

Here is the models.py:
```
class Post(models.Model):
title = models.TextField(max_length=100)
design = models.ImageField(
blank=False, null=True, upload_to='new designs')
date_posted = models.DateTimeField(default=timezone.now)
colors= models.TextField(max_length=10,blank=True, null=True)

def __str__(self):
return self.title

def imagecolors(self, *args, **kwargs):
img = Image.open(self.design)
size = w, h = img.size
data = img.load()

colors = []
for x in range(w):
for y in range(h):
color = data[x, y]
hex_color_lower = ''.join([hex(c)[2:].rjust(2, '0') for c 
in color])
hex_color = hex_color_lower.upper()
colors.append(hex_color)

total = w * h

color_hex = []
color_count = []
color_percent = []

df = pd.DataFrame()
for color, count in Counter(colors).items():
percent = count / total * \
  100  # Do not make it int. Majority of colors are < 
1%, unless you want >= 1%
if percent > 1:
color_hex.append(color)
color_count.append(count)
color_percent.append(percent)
Post.colors=color_hex
print(Post.colors)
```
with the above it showing none in the template:
```
{{ post.colors }}
```

-- 
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/fbdef2f2-f417-47fb-a967-bcaf3a862ffcn%40googlegroups.com.


Submitting form not Working for Django Project showing `This field is required.`

2020-11-02 Thread ahmed.he...@gmail.com
Hi,

I have a very basic and beginner's question, I have created a new 
`CreateView` for my project where you can submit an image with a title but 
it is not working although an image is attached. I am not getting any error 
the only thing I am receiving is `This field is required.` next to the 
`design`

Here is my models:
```
class Post(models.Model):
title = models.TextField(max_length=100)
design = models.ImageField(
blank=False, null=True, upload_to='new designs')
date_posted = models.DateTimeField(default=timezone.now)

def __str__(self):
return self.title
```
Here is the views.py:
```
class PostCreateView(CreateView):
model = Post
fields = ['title', 'design']
success_url = 'post/post_list'
```
Here is the template:
```
{% extends "post/base.html" %} 
{% load crispy_forms_tags %} 
{% block content %}

  
{% csrf_token %}

  Post
  {{ form|crispy }}


  Submit

  

{% endblock content %}
```

-- 
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/5a65187b-709d-4c54-a554-3cdec987d281n%40googlegroups.com.


Submitting form not Working for Django Project showing `This field is required.`

2020-11-02 Thread ahmed.he...@gmail.com
Hi,

I have a very basic and beginner's question, I have created a new 
`CreateView` for my project where you can submit an image with a title but 
it is not working although an image is attached. I am not getting any error 
the only thing I am receiving is `This field is required.` next to the 
`design`

Here is my models:
```
class Post(models.Model):
title = models.TextField(max_length=100)
design = models.ImageField(
blank=False, null=True, upload_to='new designs')
date_posted = models.DateTimeField(default=timezone.now)

def __str__(self):
return self.title
```
Here is the views.py:
```
class PostCreateView(CreateView):
model = Post
fields = ['title', 'design']
success_url = 'post/post_list'
```
Here is the template:
```
{% extends "post/base.html" %} 
{% load crispy_forms_tags %} 
{% block content %}

  
{% csrf_token %}

  Post
  {{ form|crispy }}


  Submit

  

{% endblock content %}
```

-- 
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/8f18c719-0888-435b-bd89-8170e055ef11n%40googlegroups.com.


Looking to join a team in a Django Project to gain Experience

2020-09-21 Thread ahmed.he...@gmail.com
Hi all,

I am looking for a team of developers to join them in a project to enhance 
my skills and add to my portfolio.  I am available part time.

Thanks

-- 
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/6e15411d-b25d-40c8-a987-e65da9b3c297n%40googlegroups.com.