Re: Unidirectional association

2020-02-27 Thread Manos Zeakis
Thank you

I finally made it. I was afraid about circular references and DB possible 
corruptions, but Django seems to be resilient and surprises me all the time.

What I did was

1. Declared three different ForeignKeys from class A to B
2. Chose PROTECT instead of CASCADE for on_delete
3. Let blank/null True
4. Of course chose three different related_names


On Thursday, 27 February 2020 07:55:52 UTC+2, Naveen Arora wrote:
>
> Hi Manos,
>
> Kindly explain the scenario appropriately, What exactly are you trying to 
> achieve? Also read - 
> https://docs.djangoproject.com/en/3.0/topics/db/examples/many_to_many/
>
> Cheers,
> Naveen Arora
>
>
> On Wednesday, 26 February 2020 20:05:00 UTC+5:30, Manos Zeakis wrote:
>>
>> Hi all
>>
>> I have created two classes. Instances of class A are timeless and 
>> instances of class B are different each year. Each instance of class B is 
>> associated with an instance of class A.
>>
>> So I suppose I should do something like this
>>
>> class A(models.Model):
>> name = models.CharField(max_length=20, default = 'null')
>>
>> class B(models.Model):
>> A = models.ForeignKey('A', on_delete=models.CASCADE, related_name = 
>> "bs")
>> 
>> Now I need to declare three fields on class A that point to a different 
>> instance of class B for current, past and next year
>> current_B
>> previous_B
>> next_B
>>
>> I cannot find a way to declare such an association. Could you help me?
>>
>> Thank you
>>
>

-- 
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/341c0a15-e8c8-4bf5-b834-c80c15eafbb2%40googlegroups.com.


production setup

2020-02-27 Thread Soumen Khatua
Hi Folks,

I'm storing users images and documents inside media folder during
development. but I don't how to serve this files for production level.Any
one have any idea, actually I read the documentation but I'm still confuse.

Thank You in advance


regards,
soumen

-- 
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/CAPUw6WZwP%3Dv_wFE71UzU3jYEBXo8wNR9Yf20QFymFkizg2QpjA%40mail.gmail.com.


How to trigger system check while running development server?

2020-02-27 Thread One Above All
I am updating a settings in my test which should raise exception on illegal 
entries, but merely updating settings does not make django perform system 
checks. Is there any method which I can call to trigger those checks? 

-- 
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/7e9b4e35-0b4a-4c2b-864a-8631ff83ac8b%40googlegroups.com.


Re: Django Image and File

2020-02-27 Thread Robert Rajendra
Store only the path in DB and image file in server folder this is the best
practice,  save the file in some folder and forward the path to DB Object
so that your DB can remember the path of the file and you can load it in
the frontend,

here is a snippet that you can use


import  FileSystemStorage()
from django.core.files.storage import FileSystemStorage
function that will store the file
profile_pic_upload = request.FILES.get('profile_pic_upload', 'false')
if user:
if profile_pic_upload != 'false':
fs = FileSystemStorage()
profile_pic = compress_image(profile_pic_upload)
filename = fs.save(profile_pic_upload.name, profile_pic)
uploaded_file_url = fs.url(filename)
uploaded_file_url = uploaded_file_url.split("/")
original_url= uploaded_file_url[-1]
user_profile.profile_pic = original_url Here fs is the object of the
FileSystemStorege() class compress_image() is my custom function no need to
add that, you can directly pass the image object that you are getting from
request. then the origina_url will go to DB user_profile.profile_pic =
original_url
 also, it will add a randomly
generated value at the end of the file that will be very useful if you have
2 images with the same name NOTE make sure that you have a media folder
added to you your settings.py file or you can pass the path to where to
save the image like this fs = FileSystemStorage(location=
'media/rent_pictures/') Hope this helps another thing is that image is also
a file and treated the same way in the backend regards,

On Thu, 27 Feb 2020 at 11:56, Soumen Khatua 
wrote:

> Hi Folks,
>
> Actually I have one image filed called profile_pic and another is file
> field called  documents but I don't know what is best practise to store it.
> Most importantly how I can make each user details is unique.
>
> Thank you in advance
>
> Regards,
> Soumen
>
> --
> 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/CAPUw6WabzCG%2B4ARdyzdn-3DCckud%3D871RtOSxqRiRMLo6zbQuQ%40mail.gmail.com
> 
> .
>


-- 

*Robert Rajendra*

Associate Network/Server Support Engineer

IT Hands

P: +91 863.087.3094 <+91%2086308%2073094>

W: www.ITHands.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/CABbC_KHUHtuJRsGUFNqf%2BXK5CZy9oewdueTdjZ6r7A%3DQTTNDQg%40mail.gmail.com.


Is it possible to extend the model in another application without explicitly changing firs-one?

2020-02-27 Thread Ol P
Imagen we have *app-A* and *app-B* with *model-A* and *model-B* accordingly.
And we want to extend *model-A* in *app-B*.
What should be written in *model-B* to implement it?

In other words, is it possible to implement the same-table extension?

-- 
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/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.com.


Re: Is it possible to extend the model in another application without explicitly changing firs-one?

2020-02-27 Thread wanbao jin
Not sure if I understand the question correctly, but are you trying to use
model-A in app-B?

On Fri, Feb 28, 2020 at 12:33 AM Ol P  wrote:

> Imagen we have *app-A* and *app-B* with *model-A* and *model-B*
> accordingly.
> And we want to extend *model-A* in *app-B*.
> What should be written in *model-B* to implement it?
>
> In other words, is it possible to implement the same-table extension?
>
> --
> 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/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.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/CAM82qv1UHy5YHYwd-LXS4bgapRN1%2Bh7h9RABhK1sA52AcUmfwg%40mail.gmail.com.


Re: Is it possible to extend the model in another application without explicitly changing firs-one?

2020-02-27 Thread Ol P
I want to extend model-A from app-B without modification of app-A
For example, add a field or new methods or override existing.

On Thursday, February 27, 2020 at 6:54:37 PM UTC+2, Jin wrote:
>
> Not sure if I understand the question correctly, but are you trying to use 
> model-A in app-B?
>
> On Fri, Feb 28, 2020 at 12:33 AM Ol P  > wrote:
>
>> Imagen we have *app-A* and *app-B* with *model-A* and *model-B* 
>> accordingly.
>> And we want to extend *model-A* in *app-B*.
>> What should be written in *model-B* to implement it?
>>
>> In other words, is it possible to implement the same-table extension?
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.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/9e98c0dc-547c-4b99-8bc3-f31187444f98%40googlegroups.com.


Re: Is it possible to extend the model in another application without explicitly changing firs-one?

2020-02-27 Thread wanbao jin
One-time class definition is always good choice, I won't do it like that.
But can you share the detailed scenario you are gonna implement?

On Fri, Feb 28, 2020 at 1:03 AM Ol P  wrote:

> I want to extend model-A from app-B without modification of app-A
> For example, add a field or new methods or override existing.
>
> On Thursday, February 27, 2020 at 6:54:37 PM UTC+2, Jin wrote:
>>
>> Not sure if I understand the question correctly, but are you trying to
>> use model-A in app-B?
>>
>> On Fri, Feb 28, 2020 at 12:33 AM Ol P  wrote:
>>
>>> Imagen we have *app-A* and *app-B* with *model-A* and *model-B*
>>> accordingly.
>>> And we want to extend *model-A* in *app-B*.
>>> What should be written in *model-B* to implement it?
>>>
>>> In other words, is it possible to implement the same-table extension?
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.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/9e98c0dc-547c-4b99-8bc3-f31187444f98%40googlegroups.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/CAM82qv2_Sue6Ck0GfTo%3DdpVoiWJjuPwhhG-mU3mADmSYzgMLpg%40mail.gmail.com.


Re: Is it possible to extend the model in another application without explicitly changing firs-one?

2020-02-27 Thread Ol P
I try to figure out if it possible to implement the next scenario:

garage (app-A)
 models
   class Vehicle(models.Model)
 vin=models.CharField(max_length=50)
 ...

 def import_data(self):
...
# import vehicals


external integration (app-B)
 models
   class ExtendedVehicle(Vehicle)
 external_field=models.CharField(max_length=50)

 def import_data(self):
super(ExtendedVehicle, self).import_data()
self.import_external_field()

 def import_external_field(self):
...
# import external_field


Something like this.


On Thursday, February 27, 2020 at 7:11:20 PM UTC+2, Jin wrote:
>
> One-time class definition is always good choice, I won't do it like that.
> But can you share the detailed scenario you are gonna implement?
>
> On Fri, Feb 28, 2020 at 1:03 AM Ol P  > wrote:
>
>> I want to extend model-A from app-B without modification of app-A
>> For example, add a field or new methods or override existing.
>>
>> On Thursday, February 27, 2020 at 6:54:37 PM UTC+2, Jin wrote:
>>>
>>> Not sure if I understand the question correctly, but are you trying to 
>>> use model-A in app-B?
>>>
>>> On Fri, Feb 28, 2020 at 12:33 AM Ol P  wrote:
>>>
 Imagen we have *app-A* and *app-B* with *model-A* and *model-B* 
 accordingly.
 And we want to extend *model-A* in *app-B*.
 What should be written in *model-B* to implement it?

 In other words, is it possible to implement the same-table extension?

 -- 
 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...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9e98c0dc-547c-4b99-8bc3-f31187444f98%40googlegroups.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/d3dce9e3-bd95-495e-85b3-a359c21dc95e%40googlegroups.com.


Re: Is it possible to extend the model in another application without explicitly changing firs-one?

2020-02-27 Thread One Above All
I am not sure if this is the right way.

On Thu, Feb 27, 2020 at 11:24 PM One Above All <
the.one.above.all.ti...@gmail.com> wrote:

> It is indeed possible, but I am not sure whether it should be done this
> way.
>
> On Thu, Feb 27, 2020 at 11:04 PM Ol P  wrote:
>
>> I try to figure out if it possible to implement the next scenario:
>>
>> garage (app-A)
>>  models
>>class Vehicle(models.Model)
>>  vin=models.CharField(max_length=50)
>>  ...
>>
>>  def import_data(self):
>> ...
>> # import vehicals
>>
>>
>> external integration (app-B)
>>  models
>>class ExtendedVehicle(Vehicle)
>>  external_field=models.CharField(max_length=50)
>>
>>  def import_data(self):
>> super(ExtendedVehicle, self).import_data()
>> self.import_external_field()
>>
>>  def import_external_field(self):
>> ...
>> # import external_field
>>
>>
>> Something like this.
>>
>>
>> On Thursday, February 27, 2020 at 7:11:20 PM UTC+2, Jin wrote:
>>>
>>> One-time class definition is always good choice, I won't do it like that.
>>> But can you share the detailed scenario you are gonna implement?
>>>
>>> On Fri, Feb 28, 2020 at 1:03 AM Ol P  wrote:
>>>
 I want to extend model-A from app-B without modification of app-A
 For example, add a field or new methods or override existing.

 On Thursday, February 27, 2020 at 6:54:37 PM UTC+2, Jin wrote:
>
> Not sure if I understand the question correctly, but are you trying to
> use model-A in app-B?
>
> On Fri, Feb 28, 2020 at 12:33 AM Ol P 
> wrote:
>
>> Imagen we have *app-A* and *app-B* with *model-A* and *model-B*
>> accordingly.
>> And we want to extend *model-A* in *app-B*.
>> What should be written in *model-B* to implement it?
>>
>> In other words, is it possible to implement the same-table extension?
>>
>> --
>> 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...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/9e98c0dc-547c-4b99-8bc3-f31187444f98%40googlegroups.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/d3dce9e3-bd95-495e-85b3-a359c21dc95e%40googlegroups.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/CAOX69xrCceNRCv5YgVcqSubhsnYXy34NWXjAzUK_L9fjASjZoQ%40mail.gmail.com.


Re: Is it possible to extend the model in another application without explicitly changing firs-one?

2020-02-27 Thread One Above All
It is indeed possible, but I am not sure whether it should be done this
way.

On Thu, Feb 27, 2020 at 11:04 PM Ol P  wrote:

> I try to figure out if it possible to implement the next scenario:
>
> garage (app-A)
>  models
>class Vehicle(models.Model)
>  vin=models.CharField(max_length=50)
>  ...
>
>  def import_data(self):
> ...
> # import vehicals
>
>
> external integration (app-B)
>  models
>class ExtendedVehicle(Vehicle)
>  external_field=models.CharField(max_length=50)
>
>  def import_data(self):
> super(ExtendedVehicle, self).import_data()
> self.import_external_field()
>
>  def import_external_field(self):
> ...
> # import external_field
>
>
> Something like this.
>
>
> On Thursday, February 27, 2020 at 7:11:20 PM UTC+2, Jin wrote:
>>
>> One-time class definition is always good choice, I won't do it like that.
>> But can you share the detailed scenario you are gonna implement?
>>
>> On Fri, Feb 28, 2020 at 1:03 AM Ol P  wrote:
>>
>>> I want to extend model-A from app-B without modification of app-A
>>> For example, add a field or new methods or override existing.
>>>
>>> On Thursday, February 27, 2020 at 6:54:37 PM UTC+2, Jin wrote:

 Not sure if I understand the question correctly, but are you trying to
 use model-A in app-B?

 On Fri, Feb 28, 2020 at 12:33 AM Ol P  wrote:

> Imagen we have *app-A* and *app-B* with *model-A* and *model-B*
> accordingly.
> And we want to extend *model-A* in *app-B*.
> What should be written in *model-B* to implement it?
>
> In other words, is it possible to implement the same-table extension?
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/9e98c0dc-547c-4b99-8bc3-f31187444f98%40googlegroups.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/d3dce9e3-bd95-495e-85b3-a359c21dc95e%40googlegroups.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/CAOX69xrux_rM1vJYHy-6CFYc5fFQPndWK_wn1EMiH%2BY%3DGP9q%2BA%40mail.gmail.com.


Re: Is it possible to extend the model in another application without explicitly changing firs-one?

2020-02-27 Thread Ol P
This is definitely not correct implementation. Only for illustration 
purposes.

On Thursday, February 27, 2020 at 7:55:51 PM UTC+2, One Above All wrote:
>
> It is indeed possible, but I am not sure whether it should be done this 
> way. 
>
> On Thu, Feb 27, 2020 at 11:04 PM Ol P  > wrote:
>
>> I try to figure out if it possible to implement the next scenario:
>>
>> garage (app-A)
>>  models
>>class Vehicle(models.Model)
>>  vin=models.CharField(max_length=50)
>>  ...
>>
>>  def import_data(self):
>> ...
>> # import vehicals
>>
>>
>> external integration (app-B)
>>  models
>>class ExtendedVehicle(Vehicle)
>>  external_field=models.CharField(max_length=50)
>>
>>  def import_data(self):
>> super(ExtendedVehicle, self).import_data()
>> self.import_external_field()
>>
>>  def import_external_field(self):
>> ...
>> # import external_field
>>
>>
>> Something like this.
>>
>>
>> On Thursday, February 27, 2020 at 7:11:20 PM UTC+2, Jin wrote:
>>>
>>> One-time class definition is always good choice, I won't do it like that.
>>> But can you share the detailed scenario you are gonna implement?
>>>
>>> On Fri, Feb 28, 2020 at 1:03 AM Ol P  wrote:
>>>
 I want to extend model-A from app-B without modification of app-A
 For example, add a field or new methods or override existing.

 On Thursday, February 27, 2020 at 6:54:37 PM UTC+2, Jin wrote:
>
> Not sure if I understand the question correctly, but are you trying to 
> use model-A in app-B?
>
> On Fri, Feb 28, 2020 at 12:33 AM Ol P  
> wrote:
>
>> Imagen we have *app-A* and *app-B* with *model-A* and *model-B* 
>> accordingly.
>> And we want to extend *model-A* in *app-B*.
>> What should be written in *model-B* to implement it?
>>
>> In other words, is it possible to implement the same-table extension?
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.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...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/9e98c0dc-547c-4b99-8bc3-f31187444f98%40googlegroups.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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/d3dce9e3-bd95-495e-85b3-a359c21dc95e%40googlegroups.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/4e3d1372-165e-4110-975c-3c758a2394c0%40googlegroups.com.


Re: How to trigger system check while running development server?

2020-02-27 Thread Integr@te System
Hi Fr,

If you have not yet found out module/method for you, so let try git action
as on your dev phase with git repo.

On Thu, Feb 27, 2020, 21:32 One Above All 
wrote:

> I am updating a settings in my test which should raise exception on
> illegal entries, but merely updating settings does not make django perform
> system checks. Is there any method which I can call to trigger those
> checks?
>
> --
> 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/7e9b4e35-0b4a-4c2b-864a-8631ff83ac8b%40googlegroups.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/CAP5HUWobOzYhCsN%3DSnSy9wonExWdBxubRXGwueCgPJvHb1dcJQ%40mail.gmail.com.


Re: Django Image and File

2020-02-27 Thread Soumen Khatua
Thanks for your response.

On Thu 27 Feb, 2020, 10:03 PM Robert Rajendra, 
wrote:

> Store only the path in DB and image file in server folder this is the best
> practice,  save the file in some folder and forward the path to DB Object
> so that your DB can remember the path of the file and you can load it in
> the frontend,
>
> here is a snippet that you can use
>
>
> import  FileSystemStorage()
> from django.core.files.storage import FileSystemStorage
> function that will store the file
> profile_pic_upload = request.FILES.get('profile_pic_upload', 'false')
> if user:
> if profile_pic_upload != 'false':
> fs = FileSystemStorage()
> profile_pic = compress_image(profile_pic_upload)
> filename = fs.save(profile_pic_upload.name, profile_pic)
> uploaded_file_url = fs.url(filename)
> uploaded_file_url = uploaded_file_url.split("/")
> original_url= uploaded_file_url[-1]
> user_profile.profile_pic = original_url Here fs is the object of the
> FileSystemStorege() class compress_image() is my custom function no need to
> add that, you can directly pass the image object that you are getting from
> request. then the origina_url will go to DB user_profile.profile_pic = 
> original_url
>  the URL that we get from FileSystemStorage()> also, it will add a
> randomly generated value at the end of the file that will be very useful if
> you have 2 images with the same name NOTE make sure that you have a media
> folder added to you your settings.py file or you can pass the path to where
> to save the image like this fs = FileSystemStorage(location=
> 'media/rent_pictures/') Hope this helps another thing is that image is
> also a file and treated the same way in the backend regards,
>
> On Thu, 27 Feb 2020 at 11:56, Soumen Khatua 
> wrote:
>
>> Hi Folks,
>>
>> Actually I have one image filed called profile_pic and another is file
>> field called  documents but I don't know what is best practise to store it.
>> Most importantly how I can make each user details is unique.
>>
>> Thank you in advance
>>
>> Regards,
>> Soumen
>>
>> --
>> 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/CAPUw6WabzCG%2B4ARdyzdn-3DCckud%3D871RtOSxqRiRMLo6zbQuQ%40mail.gmail.com
>> 
>> .
>>
>
>
> --
>
> *Robert Rajendra*
>
> Associate Network/Server Support Engineer
>
> IT Hands
>
> P: +91 863.087.3094 <+91%2086308%2073094>
>
> W: www.ITHands.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/CABbC_KHUHtuJRsGUFNqf%2BXK5CZy9oewdueTdjZ6r7A%3DQTTNDQg%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/CAPUw6WYq%3D1XXyU6q1QxhqgNg%3D1s-y6pFry6WtfmcwVZYY5-Ovg%40mail.gmail.com.


How to do validation on a form which is opened by clicking a button

2020-02-27 Thread Sunil BK
Hello community

I am trying to build a simple form which can be opened using a button. It 
should offer some fields which should be further process after validation. 
And there is exactly my issue. When I write some data into the fields and 
click the submit button. the validation error is NOT displayed below the 
screen like in this screeshot:

[image: 2020-02-27_21-52-30.png]


but is displayed in the log.

Can somebody give me a hint what I am missing here?
Thanks a lot!!
Sunil


This is the code I am using:

my HTML Code for presenting the form.

{% extends 'base.html' %}
{% load crispy_forms_tags %}
{%block content%}

Add System to Organization



{% csrf_token %}
{{form|crispy}}




{%endblock content%}


the view:

def chr_add_system_view(request):
if request.method == 'POST':
form = AddChrSystemForm(request.POST)
if form.is_valid():
print('add_system>valid')
# TODO: do something
return redirect(chr_systems_view)
else:
print('form.errors ' + str(form.errors))
form = AddChrSystemForm()
context = {'form': form}
return render(request=request, template_name='chr/add_system.html', 
context=context)


the form:

class AddSystemForm(ModelForm):

def __init__(self, *args, **kwargs):
super(AddSystemForm, self).__init__(*args, **kwargs)
self.fields['profile_name'].widget.attrs['readonly'] = True

class Meta:
model = System
fields = '__all__'

def clean_system_id(self):
print('validating oid of system..')

system_id = self.cleaned_data['system_id']
print('system_id: ' + system_id)

if "2.16" not in system_id:
print('oid of system id is invalid')

raise forms.ValidationError(
"Your submissionset source oid seems to be invalid. ==> it has 
to be a valid oid and must start with: 2.16")
print('oid of system id is valid')
return system_id


the button where the form is called:


SourceId

{% csrf_token %}
[WIP] Add System





my class

class System(models.Model):
system_id = models.CharField(max_length=100)
abbreviation = models.CharField(max_length=100, default="SRC-")
software_name = models.CharField(max_length=100, default="Portal")
vendor = models.CharField(max_length=100, default="vendor")
profile_name = models.CharField(max_length=100, default="Source")





-- 
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/28c122d0-72b9-4367-9f07-ce1939ad3b78%40googlegroups.com.


Re: How to do validation on a form which is opened by clicking a button

2020-02-27 Thread 'rossm6' via Django users
If the form is not valid you are creating a new form and returning this to
the user.  So you need to remove the line where you create this second form
object within the else clause of the view and it will work.

On Thu, Feb 27, 2020 at 9:10 PM Sunil BK  wrote:

> Hello community
>
> I am trying to build a simple form which can be opened using a button. It
> should offer some fields which should be further process after validation.
> And there is exactly my issue. When I write some data into the fields and
> click the submit button. the validation error is NOT displayed below the
> screen like in this screeshot:
>
> [image: 2020-02-27_21-52-30.png]
>
>
> but is displayed in the log.
>
> Can somebody give me a hint what I am missing here?
> Thanks a lot!!
> Sunil
>
>
> This is the code I am using:
>
> my HTML Code for presenting the form.
>
> {% extends 'base.html' %}
> {% load crispy_forms_tags %}
> {%block content%}
> 
> Add System to Organization
> 
> 
> 
> {% csrf_token %}
> {{form|crispy}}
> 
> 
> 
> 
> {%endblock content%}
>
>
> the view:
>
> def chr_add_system_view(request):
> if request.method == 'POST':
> form = AddChrSystemForm(request.POST)
> if form.is_valid():
> print('add_system>valid')
> # TODO: do something
> return redirect(chr_systems_view)
> else:
> print('form.errors ' + str(form.errors))
> form = AddChrSystemForm()
> context = {'form': form}
> return render(request=request, 
> template_name='chr/add_system.html', context=context)
>
>
> the form:
>
> class AddSystemForm(ModelForm):
>
> def __init__(self, *args, **kwargs):
> super(AddSystemForm, self).__init__(*args, **kwargs)
> self.fields['profile_name'].widget.attrs['readonly'] = True
>
> class Meta:
> model = System
> fields = '__all__'
>
> def clean_system_id(self):
> print('validating oid of system..')
>
> system_id = self.cleaned_data['system_id']
> print('system_id: ' + system_id)
>
> if "2.16" not in system_id:
> print('oid of system id is invalid')
>
> raise forms.ValidationError(
> "Your submissionset source oid seems to be invalid. ==> it 
> has to be a valid oid and must start with: 2.16")
> print('oid of system id is valid')
> return system_id
>
>
> the button where the form is called:
>
> 
> SourceId
> 
> {% csrf_token %}
>  class="btn btn-warning btn-sm float-right" 
> value="{{item0}}">[WIP] Add System
> 
> 
> 
>
>
> my class
>
> class System(models.Model):
> system_id = models.CharField(max_length=100)
> abbreviation = models.CharField(max_length=100, default="SRC-")
> software_name = models.CharField(max_length=100, default="Portal")
> vendor = models.CharField(max_length=100, default="vendor")
> profile_name = models.CharField(max_length=100, default="Source")
>
>
>
>
>
> --
> 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/28c122d0-72b9-4367-9f07-ce1939ad3b78%40googlegroups.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/CAJXS7_McJftTiy_2hjJ9oxANXbxisYFUSFmSF2%2B_zr32Bb%2BxcA%40mail.gmail.com.


Re: How to trigger system check while running development server?

2020-02-27 Thread Mike Dewhirst

On 28/02/2020 1:31 am, One Above All wrote:
I am updating a settings in my test which should raise exception on 
illegal entries, but merely updating settings does not make django 
perform system checks. Is there any method which I can call to trigger 
those checks?


https://docs.djangoproject.com/en/2.2/topics/settings/#using-settings-without-setting-django-settings-module

Look at the configure() method. In particular, you might want to save 
one or more settings values, change them for some of the tests and then 
switch them back. I would probably isolate such tests in a separate 
module and use the setUP and tearDown methods to fix the adjusted settings.


Good luck

Mike


--
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/7e9b4e35-0b4a-4c2b-864a-8631ff83ac8b%40googlegroups.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/cc721f99-5791-21df-d5a8-ca1fa0cd078c%40dewhirst.com.au.


Many to Many relationships in template

2020-02-27 Thread Robb Rodirguez Jr.
Good day guys, im new to django im having in many to many relationship 
display in template

How can display this into a normal list..

from . 
, , , , 
]>

to.
webadmin
kim
sem
quinito
user1

Here's my code

model.py 

class ListOfUser(models.Model):
users = models.ManyToManyField(User, verbose_name='List of User')



views.py

def listofusers(request):
userlist = ListOfUser.objects.get(id=1)

form = ListofUserForms()

context = {
'form': form,
'userlist': userlist
}
return render(request, 'listofusers.html', context)


template

{{userlist.users.all}}


-- 
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/f3e604a7-5613-4f12-8aa6-526b19ae0fc7%40googlegroups.com.


Re: Many to Many relationships in template

2020-02-27 Thread Gil Obradors
Hi!

https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#modeladmin-objects
or
https://docs.djangoproject.com/en/3.0/intro/tutorial07/#writing-your-first-django-app-part-7

Missatge de Robb Rodirguez Jr.  del dia dv.,
28 de febr. 2020 a les 1:14:

> Good day guys, im new to django im having in many to many relationship
> display in template
>
> How can display this into a normal list..
>
> from .
> , , , ,
> ]>
>
> to.
> webadmin
> kim
> sem
> quinito
> user1
>
> Here's my code
>
> model.py
>
> class ListOfUser(models.Model):
> users = models.ManyToManyField(User, verbose_name='List of User')
>
>
>
> views.py
>
> def listofusers(request):
> userlist = ListOfUser.objects.get(id=1)
>
> form = ListofUserForms()
>
> context = {
> 'form': form,
> 'userlist': userlist
> }
> return render(request, 'listofusers.html', context)
>
>
> template
>
> {{userlist.users.all}}
>
>
> --
> 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/f3e604a7-5613-4f12-8aa6-526b19ae0fc7%40googlegroups.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/CAK-JoTQQr%2BQODZoqWfJLNcdFsrkvLWXmUOqES0wcxSfCSHO59A%40mail.gmail.com.


How to create entire basic of website design without using django-admin panel

2020-02-27 Thread nrupesh08


login page based on roles (user, admin). insert data, update data, delete 
data in (entire rows). only particular update data in table
display forms in css class.  the entire page without using django 
admin. only access front-end. 
any reference complete project for learning. please help me. i am 
intersted to earn django

-- 
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/c8d610c0-9386-424c-ad42-45849c519ab9%40googlegroups.com.


Re: How to create entire basic of website design without using django-admin panel

2020-02-27 Thread nrupesh08


On Friday, February 28, 2020 at 12:19:55 PM UTC+5:30, nrupesh08 wrote:
>
>
>
> login page based on roles (user, admin). insert data, update data, delete 
> data in (entire rows). only particular update data in table
> display forms in css class.  the entire page without using django 
> admin. only access front-end. 
>
   User registration also. how to link User table to User registration 
in models. 

> any reference complete project for learning. please help me. i am 
> intersted to earn django
>

-- 
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/8ef8646f-129f-4ec6-a658-a6f846debc85%40googlegroups.com.


Api

2020-02-27 Thread Tosin Ayoola
Good morning guyz,
I need help on this one,  it on writing api that will Shows the product
count for each manufacturer as users add products real time.
I have no idea how to solve this problem,  i will any suggestion
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/CAHLKn731GXi2A2i3-7DkVaPrD1Ta%2Bu%2B-ccjK7bA0uW4gdsHjJA%40mail.gmail.com.