Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

2023-03-02 Thread Boris Pérez
One way could be  latest_action=ActionGame.obje
cts.filter(published=published).order_by('-id')[:1]

El jue, 2 mar 2023 a las 17:29, Sandip Bhattacharya (<
sand...@showmethesource.org>) escribió:

> Your problem is still about where the 'published’ value is coming from in
> the call to filter(published=published).
>
> Is it coming from a form? A Get parameter? A post parameter? Extract it
> appropriately before calling filter()
>
>
> > On Mar 2, 2023, at 3:46 AM, Byansi Samuel 
> wrote:
> >
> > def action (request):
> > latest_action=ActionGame.objects.filter(published=published).
> latest()
>
>
> --
> 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/A09FDF66-9845-4B93-854D-8BBFC4F5A03D%40showmethesource.org
> .
>

-- 
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/CAObPVPCuT-XfUWxYXk54urTXbCBgHEe0WDjBrrkXJzcTdHO-jg%40mail.gmail.com.


Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

2023-03-02 Thread Sandip Bhattacharya
Your problem is still about where the 'published’ value is coming from in the 
call to filter(published=published).

Is it coming from a form? A Get parameter? A post parameter? Extract it 
appropriately before calling filter()


> On Mar 2, 2023, at 3:46 AM, Byansi Samuel  wrote:
> 
> def action (request):
> latest_action=ActionGame.objects.filter(published=published). latest()


-- 
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/A09FDF66-9845-4B93-854D-8BBFC4F5A03D%40showmethesource.org.


Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

2023-03-02 Thread Byansi Samuel
Hey thanks, but l tried to use ordering=('-published')

On Feb 28, 2023 5:04 PM, "Dev Femi Badmus"  wrote:

all_action=ActionGame.objects.all()
my_action = []
for action in all_action:
my_action.append(action)
last_action = my_action[-1]


On Tue, Feb 28, 2023 at 1:05 PM Andréas Kühne 
wrote:

> Se comments below.
>
>
> Den fre 24 feb. 2023 kl 12:14 skrev Byansi Samuel <
> samuelbyans...@gmail.com>:
>
>> Hey everyone, l got a problem. Am trying to retrieve a single latest
>> object added everytime, and display it in the template.
>> Below is my codes but;
>>
>> Help me figure it out the source of the problem in these different
>> instances below 
>>
>> ___ issue number 1___
>>
>> #Action/models.py
>> class ActionGame(models.Model):
>> name=models.Charfield()
>> published=models.DateTimeField()
>>
>> #Action/views.py
>> from Action.models import ActionGame
>>
>> def action (request):
>> latest_action=ActionGame.objects.filter(published=published).
>> latest()
>> Context={ 'latest_action': latest_action }
>> return
>>
>> But it returns *error* :
>> name 'published' is not defined
>>
>
> You haven't defined what the value of published is. If you want to get the
> last created one the query should be:
> latest_action=ActionGame.objects.latest("published") - that would give
> you the last published item. Another way would be:
> latest_action=ActionGame.objects.order_by("published").last()
>
>
>>  issue number 2
>>
>> #Action/models.py
>> class ActionGame(models.Model):
>> name=models.Charfield()
>> published=models.DateTimeField()
>> class Meta:
>>   get_latest_by='published'
>>
>> #Action/views.py
>> 
>> latest_action=ActionGame.objects. latest()
>> ...
>>
>> #but it returns *error* :
>> 'ActionGame' object is not iterable
>>
>> Even if I try this:
>> 
>> latest_action=ActionGame.objects. latest('published')
>> ...
>>
>> #it returns the Same error:
>> 'ActionGame' object is not iterable
>>
>> But this second issue, the error is referred in #action.html
>>
>> {% for x in latest _action %}
>> {{ x.game_name }}
>> {% endfor %}
>>
>>
> So the latest_action variable that you have sent to the template is an
> instance of ActionGame - and not a list or anything. You can only access
> variables in the ActionGame class. For example:
>
>  {{ lastest_action.name }}
>
> would print out the value of the name of the ActionGame instance.
>
> Please l need your assistance.
>>
>> I'm Samuel,
>> 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/CAGQoQ3wMUno6hLAO-1FtN0Nn7VtkCn4qf-O4U%
>> 3DpeJ4JzY%2B%3DcAQ%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/CAK4qSCeBCST7o-5WZx%2BmhGO2yH-
> Msdse%3DKusk9UOyW8XZBXRBw%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/CAD9bWYwtxjinYmeNWZvBdCdQB5zAa
3je1bwMjUhmzEjzF0Q_bg%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/CAGQoQ3weh-AXngh579cMv7j15knboG1M7BVLHJBDvc%3DVAa4uyQ%40mail.gmail.com.


Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

2023-02-28 Thread Andréas Kühne
I'm sorry Dev, but that is really bad practice.

You are doing in python what can be done by the database. That type of code
would create a memory error and be very slow to run. It's much better to
get the last item from the database. In your example it would just be:
last_action = ActionGame.objects.last()


Den tis 28 feb. 2023 kl 15:04 skrev Dev Femi Badmus :

> all_action=ActionGame.objects.all()
> my_action = []
> for action in all_action:
> my_action.append(action)
> last_action = my_action[-1]
>
>
> On Tue, Feb 28, 2023 at 1:05 PM Andréas Kühne 
> wrote:
>
>> Se comments below.
>>
>>
>> Den fre 24 feb. 2023 kl 12:14 skrev Byansi Samuel <
>> samuelbyans...@gmail.com>:
>>
>>> Hey everyone, l got a problem. Am trying to retrieve a single latest
>>> object added everytime, and display it in the template.
>>> Below is my codes but;
>>>
>>> Help me figure it out the source of the problem in these different
>>> instances below 
>>>
>>> ___ issue number 1___
>>>
>>> #Action/models.py
>>> class ActionGame(models.Model):
>>> name=models.Charfield()
>>> published=models.DateTimeField()
>>>
>>> #Action/views.py
>>> from Action.models import ActionGame
>>>
>>> def action (request):
>>> latest_action=ActionGame.objects.filter(published=published).
>>> latest()
>>> Context={ 'latest_action': latest_action }
>>> return
>>>
>>> But it returns *error* :
>>> name 'published' is not defined
>>>
>>
>> You haven't defined what the value of published is. If you want to get
>> the last created one the query should be:
>> latest_action=ActionGame.objects.latest("published") - that would give
>> you the last published item. Another way would be:
>> latest_action=ActionGame.objects.order_by("published").last()
>>
>>
>>>  issue number 2
>>>
>>> #Action/models.py
>>> class ActionGame(models.Model):
>>> name=models.Charfield()
>>> published=models.DateTimeField()
>>> class Meta:
>>>   get_latest_by='published'
>>>
>>> #Action/views.py
>>> 
>>> latest_action=ActionGame.objects. latest()
>>> ...
>>>
>>> #but it returns *error* :
>>> 'ActionGame' object is not iterable
>>>
>>> Even if I try this:
>>> 
>>> latest_action=ActionGame.objects. latest('published')
>>> ...
>>>
>>> #it returns the Same error:
>>> 'ActionGame' object is not iterable
>>>
>>> But this second issue, the error is referred in #action.html
>>>
>>> {% for x in latest _action %}
>>> {{ x.game_name }}
>>> {% endfor %}
>>>
>>>
>> So the latest_action variable that you have sent to the template is an
>> instance of ActionGame - and not a list or anything. You can only access
>> variables in the ActionGame class. For example:
>>
>>  {{ lastest_action.name }}
>>
>> would print out the value of the name of the ActionGame instance.
>>
>> Please l need your assistance.
>>>
>>> I'm Samuel,
>>> 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/CAGQoQ3wMUno6hLAO-1FtN0Nn7VtkCn4qf-O4U%3DpeJ4JzY%2B%3DcAQ%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/CAK4qSCeBCST7o-5WZx%2BmhGO2yH-Msdse%3DKusk9UOyW8XZBXRBw%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/CAD9bWYwtxjinYmeNWZvBdCdQB5zAa3je1bwMjUhmzEjzF0Q_bg%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 

Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

2023-02-28 Thread Dev Femi Badmus
all_action=ActionGame.objects.all()
my_action = []
for action in all_action:
my_action.append(action)
last_action = my_action[-1]


On Tue, Feb 28, 2023 at 1:05 PM Andréas Kühne 
wrote:

> Se comments below.
>
>
> Den fre 24 feb. 2023 kl 12:14 skrev Byansi Samuel <
> samuelbyans...@gmail.com>:
>
>> Hey everyone, l got a problem. Am trying to retrieve a single latest
>> object added everytime, and display it in the template.
>> Below is my codes but;
>>
>> Help me figure it out the source of the problem in these different
>> instances below 
>>
>> ___ issue number 1___
>>
>> #Action/models.py
>> class ActionGame(models.Model):
>> name=models.Charfield()
>> published=models.DateTimeField()
>>
>> #Action/views.py
>> from Action.models import ActionGame
>>
>> def action (request):
>> latest_action=ActionGame.objects.filter(published=published).
>> latest()
>> Context={ 'latest_action': latest_action }
>> return
>>
>> But it returns *error* :
>> name 'published' is not defined
>>
>
> You haven't defined what the value of published is. If you want to get the
> last created one the query should be:
> latest_action=ActionGame.objects.latest("published") - that would give you
> the last published item. Another way would be:
> latest_action=ActionGame.objects.order_by("published").last()
>
>
>>  issue number 2
>>
>> #Action/models.py
>> class ActionGame(models.Model):
>> name=models.Charfield()
>> published=models.DateTimeField()
>> class Meta:
>>   get_latest_by='published'
>>
>> #Action/views.py
>> 
>> latest_action=ActionGame.objects. latest()
>> ...
>>
>> #but it returns *error* :
>> 'ActionGame' object is not iterable
>>
>> Even if I try this:
>> 
>> latest_action=ActionGame.objects. latest('published')
>> ...
>>
>> #it returns the Same error:
>> 'ActionGame' object is not iterable
>>
>> But this second issue, the error is referred in #action.html
>>
>> {% for x in latest _action %}
>> {{ x.game_name }}
>> {% endfor %}
>>
>>
> So the latest_action variable that you have sent to the template is an
> instance of ActionGame - and not a list or anything. You can only access
> variables in the ActionGame class. For example:
>
>  {{ lastest_action.name }}
>
> would print out the value of the name of the ActionGame instance.
>
> Please l need your assistance.
>>
>> I'm Samuel,
>> 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/CAGQoQ3wMUno6hLAO-1FtN0Nn7VtkCn4qf-O4U%3DpeJ4JzY%2B%3DcAQ%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/CAK4qSCeBCST7o-5WZx%2BmhGO2yH-Msdse%3DKusk9UOyW8XZBXRBw%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/CAD9bWYwtxjinYmeNWZvBdCdQB5zAa3je1bwMjUhmzEjzF0Q_bg%40mail.gmail.com.


Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

2023-02-28 Thread Andréas Kühne
Se comments below.


Den fre 24 feb. 2023 kl 12:14 skrev Byansi Samuel :

> Hey everyone, l got a problem. Am trying to retrieve a single latest
> object added everytime, and display it in the template.
> Below is my codes but;
>
> Help me figure it out the source of the problem in these different
> instances below 
>
> ___ issue number 1___
>
> #Action/models.py
> class ActionGame(models.Model):
> name=models.Charfield()
> published=models.DateTimeField()
>
> #Action/views.py
> from Action.models import ActionGame
>
> def action (request):
> latest_action=ActionGame.objects.filter(published=published).
> latest()
> Context={ 'latest_action': latest_action }
> return
>
> But it returns *error* :
> name 'published' is not defined
>

You haven't defined what the value of published is. If you want to get the
last created one the query should be:
latest_action=ActionGame.objects.latest("published") - that would give you
the last published item. Another way would be:
latest_action=ActionGame.objects.order_by("published").last()


>  issue number 2
>
> #Action/models.py
> class ActionGame(models.Model):
> name=models.Charfield()
> published=models.DateTimeField()
> class Meta:
>   get_latest_by='published'
>
> #Action/views.py
> 
> latest_action=ActionGame.objects. latest()
> ...
>
> #but it returns *error* :
> 'ActionGame' object is not iterable
>
> Even if I try this:
> 
> latest_action=ActionGame.objects. latest('published')
> ...
>
> #it returns the Same error:
> 'ActionGame' object is not iterable
>
> But this second issue, the error is referred in #action.html
>
> {% for x in latest _action %}
> {{ x.game_name }}
> {% endfor %}
>
>
So the latest_action variable that you have sent to the template is an
instance of ActionGame - and not a list or anything. You can only access
variables in the ActionGame class. For example:

 {{ lastest_action.name }}

would print out the value of the name of the ActionGame instance.

Please l need your assistance.
>
> I'm Samuel,
> 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/CAGQoQ3wMUno6hLAO-1FtN0Nn7VtkCn4qf-O4U%3DpeJ4JzY%2B%3DcAQ%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/CAK4qSCeBCST7o-5WZx%2BmhGO2yH-Msdse%3DKusk9UOyW8XZBXRBw%40mail.gmail.com.


How to retrieve the latest object added (new one) in Django models and display it in the template?

2023-02-24 Thread Byansi Samuel
Hey everyone, l got a problem. Am trying to retrieve a single latest object
added everytime, and display it in the template.
Below is my codes but;

Help me figure it out the source of the problem in these different
instances below 

___ issue number 1___

#Action/models.py
class ActionGame(models.Model):
name=models.Charfield()
published=models.DateTimeField()

#Action/views.py
from Action.models import ActionGame

def action (request):
latest_action=ActionGame.objects.filter(published=published).
latest()
Context={ 'latest_action': latest_action }
return

But it returns *error* :
name 'published' is not defined

 issue number 2

#Action/models.py
class ActionGame(models.Model):
name=models.Charfield()
published=models.DateTimeField()
class Meta:
  get_latest_by='published'

#Action/views.py

latest_action=ActionGame.objects. latest()
...

#but it returns *error* :
'ActionGame' object is not iterable

Even if I try this:

latest_action=ActionGame.objects. latest('published')
...

#it returns the Same error:
'ActionGame' object is not iterable

But this second issue, the error is referred in #action.html

{% for x in latest _action %}
{{ x.game_name }}
{% endfor %}

Please l need your assistance.

I'm Samuel,
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/CAGQoQ3wMUno6hLAO-1FtN0Nn7VtkCn4qf-O4U%3DpeJ4JzY%2B%3DcAQ%40mail.gmail.com.


Re: HOW TO GET DJANGO MODELS FIELD VALUE FROM MODEL OBJECT IN TEMPLATE TAGS-DJANGO

2022-11-07 Thread James
Hi;

There's a method you're supposed to override in your views (inherit from 
Views) to do what you want, it's called "get_context_data". This method 
will pump whatever data you send to it into your template tags.


On Sunday, November 6, 2022 at 4:15:35 AM UTC-7 rani...@gmail.com wrote:

> my models.py
>
> class Locations(models.Model):
> region = models.ForeignKey(Regions, 
> on_delete=models.CASCADE,blank=True,null=True)
> name = models.CharField(max_length=255)
> active_flag = models.BooleanField(default=True)
> created_at = models.DateTimeField(auto_now_add = True)
> updated_at = models.DateTimeField(auto_now=True)
>
> def __str__(self):
> return self.name
>
>
> class Regions(models.Model):
> region_name = models.CharField(max_length=255)
> working_hours_per_day = models.CharField(max_length=255,null=True)
> days_per_week = models.CharField(max_length=255,null=True)
> hours_per_week = models.CharField(max_length=255,null=True)
> week_per_month = models.CharField(max_length=255,null=True)
> hours_per_month = models.CharField(max_length=255,null=True)
> days_per_year = models.CharField(max_length=255,null=True)
> weeks_per_year = models.CharField(max_length=255,null=True)
> active_flag = models.BooleanField(default=True)
> show_flag = models.BooleanField(default=True)
> created_at = models.DateTimeField(auto_now_add = True)
> updated_at = models.DateTimeField(auto_now=True)
>
> def __str__(self):
> return self.region_name
>
>
> views.py
>
> def center(request):
> locations = Locations.objects.select_related('region')
> td_serializer = LocationSerializer(locations,many=True)
> x=td_serializer.data
> data = {
> 'td':td_serializer.data,
> #'centers':center_serializer.data,
> } 
> return response.Response(data,status.HTTP_200_OK)
>
>
>
>
> template:
>
> fetchLocationsList(){
> this.$axios.$post('/projects/chcenter',config).then(response => {
> if(response){
> this.locations =response.td;
> for(let i=0;i  this.x=this.locations[i].name
> this.y=this.locations[i].region
> this.z=this.y + "-" +this.x
> this.result.push(this.z)
>
>
> How to get region_name ?
>
>
>
>
>

-- 
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/be86acab-55f2-4ce2-a1b5-930b1b5c77aen%40googlegroups.com.


Re: HOW TO GET DJANGO MODELS FIELD VALUE FROM MODEL OBJECT IN TEMPLATE TAGS-DJANGO

2022-11-06 Thread Kala Rani
I want to get region_name field values in my template.its .giving null value

On Sunday, November 6, 2022 at 8:31:42 PM UTC+5:30 sebasti...@gmail.com 
wrote:

> Pls write us your aim with this code...
>
> Kala Rani  schrieb am So., 6. Nov. 2022, 12:15:
>
>> my models.py
>>
>> class Locations(models.Model):
>> region = models.ForeignKey(Regions, 
>> on_delete=models.CASCADE,blank=True,null=True)
>> name = models.CharField(max_length=255)
>> active_flag = models.BooleanField(default=True)
>> created_at = models.DateTimeField(auto_now_add = True)
>> updated_at = models.DateTimeField(auto_now=True)
>>
>> def __str__(self):
>> return self.name
>>
>>
>> class Regions(models.Model):
>> region_name = models.CharField(max_length=255)
>> working_hours_per_day = models.CharField(max_length=255,null=True)
>> days_per_week = models.CharField(max_length=255,null=True)
>> hours_per_week = models.CharField(max_length=255,null=True)
>> week_per_month = models.CharField(max_length=255,null=True)
>> hours_per_month = models.CharField(max_length=255,null=True)
>> days_per_year = models.CharField(max_length=255,null=True)
>> weeks_per_year = models.CharField(max_length=255,null=True)
>> active_flag = models.BooleanField(default=True)
>> show_flag = models.BooleanField(default=True)
>> created_at = models.DateTimeField(auto_now_add = True)
>> updated_at = models.DateTimeField(auto_now=True)
>>
>> def __str__(self):
>> return self.region_name
>>
>>
>> views.py
>>
>> def center(request):
>> locations = Locations.objects.select_related('region')
>> td_serializer = LocationSerializer(locations,many=True)
>> x=td_serializer.data
>> data = {
>> 'td':td_serializer.data,
>> #'centers':center_serializer.data,
>> } 
>> return response.Response(data,status.HTTP_200_OK)
>>
>>
>>
>>
>> template:
>>
>> fetchLocationsList(){
>> this.$axios.$post('/projects/chcenter',config).then(response => {
>> if(response){
>> this.locations =response.td;
>> for(let i=0;i > this.x=this.locations[i].name
>> this.y=this.locations[i].region
>> this.z=this.y + "-" +this.x
>> this.result.push(this.z)
>>
>>
>> How to get region_name ?
>>
>>
>>
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3a93ef8a-4fc6-48a8-83d7-cc4ea65ae649n%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/18a95ad8-854a-4efb-bb2f-9ae3bda4ebe0n%40googlegroups.com.


Re: HOW TO GET DJANGO MODELS FIELD VALUE FROM MODEL OBJECT IN TEMPLATE TAGS-DJANGO

2022-11-06 Thread Sebastian Jung
Pls write us your aim with this code...

Kala Rani  schrieb am So., 6. Nov. 2022, 12:15:

> my models.py
>
> class Locations(models.Model):
> region = models.ForeignKey(Regions,
> on_delete=models.CASCADE,blank=True,null=True)
> name = models.CharField(max_length=255)
> active_flag = models.BooleanField(default=True)
> created_at = models.DateTimeField(auto_now_add = True)
> updated_at = models.DateTimeField(auto_now=True)
>
> def __str__(self):
> return self.name
>
>
> class Regions(models.Model):
> region_name = models.CharField(max_length=255)
> working_hours_per_day = models.CharField(max_length=255,null=True)
> days_per_week = models.CharField(max_length=255,null=True)
> hours_per_week = models.CharField(max_length=255,null=True)
> week_per_month = models.CharField(max_length=255,null=True)
> hours_per_month = models.CharField(max_length=255,null=True)
> days_per_year = models.CharField(max_length=255,null=True)
> weeks_per_year = models.CharField(max_length=255,null=True)
> active_flag = models.BooleanField(default=True)
> show_flag = models.BooleanField(default=True)
> created_at = models.DateTimeField(auto_now_add = True)
> updated_at = models.DateTimeField(auto_now=True)
>
> def __str__(self):
> return self.region_name
>
>
> views.py
>
> def center(request):
> locations = Locations.objects.select_related('region')
> td_serializer = LocationSerializer(locations,many=True)
> x=td_serializer.data
> data = {
> 'td':td_serializer.data,
> #'centers':center_serializer.data,
> }
> return response.Response(data,status.HTTP_200_OK)
>
>
>
>
> template:
>
> fetchLocationsList(){
> this.$axios.$post('/projects/chcenter',config).then(response => {
> if(response){
> this.locations =response.td;
> for(let i=0;i  this.x=this.locations[i].name
> this.y=this.locations[i].region
> this.z=this.y + "-" +this.x
> this.result.push(this.z)
>
>
> How to get region_name ?
>
>
>
>
> --
> 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/3a93ef8a-4fc6-48a8-83d7-cc4ea65ae649n%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/CAKGT9mx36UHjRWOTJcg586ph6JHMRmFxZ_8mSrtCw%2B0fMdoPyA%40mail.gmail.com.


HOW TO GET DJANGO MODELS FIELD VALUE FROM MODEL OBJECT IN TEMPLATE TAGS-DJANGO

2022-11-06 Thread Kala Rani
my models.py

class Locations(models.Model):
region = models.ForeignKey(Regions, 
on_delete=models.CASCADE,blank=True,null=True)
name = models.CharField(max_length=255)
active_flag = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add = True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return self.name


class Regions(models.Model):
region_name = models.CharField(max_length=255)
working_hours_per_day = models.CharField(max_length=255,null=True)
days_per_week = models.CharField(max_length=255,null=True)
hours_per_week = models.CharField(max_length=255,null=True)
week_per_month = models.CharField(max_length=255,null=True)
hours_per_month = models.CharField(max_length=255,null=True)
days_per_year = models.CharField(max_length=255,null=True)
weeks_per_year = models.CharField(max_length=255,null=True)
active_flag = models.BooleanField(default=True)
show_flag = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add = True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return self.region_name


views.py

def center(request):
locations = Locations.objects.select_related('region')
td_serializer = LocationSerializer(locations,many=True)
x=td_serializer.data
data = {
'td':td_serializer.data,
#'centers':center_serializer.data,
} 
return response.Response(data,status.HTTP_200_OK)




template:

fetchLocationsList(){
this.$axios.$post('/projects/chcenter',config).then(response => {
if(response){
this.locations =response.td;
for(let i=0;i https://groups.google.com/d/msgid/django-users/3a93ef8a-4fc6-48a8-83d7-cc4ea65ae649n%40googlegroups.com.


Customise Django Models

2022-09-11 Thread Jishnu C K
Hi,

Some blogs I have written,

hope someone find it useful :)

https://jishnuck.medium.com/customizing-django-models-to-facilitate-user-restricted-data-768fe8206f82
 
<https://jishnuck.medium.com/customizing-django-models-to-facilitate-user-restricted-data-768fe8206f82>


Jishnu C K
jishnuc...@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/A9597799-908E-4B2E-90C2-35581EE1AACF%40gmail.com.


Re: Sanitize field from xss attacks in django models

2021-11-06 Thread omar ahmed
My final solution :
[image: bb.png]

On Saturday, November 6, 2021 at 6:03:59 PM UTC+2 st...@jigsawtech.co.uk 
wrote:

> Are you using the safe filter in your templates as otherwise that "attack" 
> won't do anything but you are right that other XSS attack vectors can be 
> used as per the example in the docs - 
> https://docs.djangoproject.com/en/3.2/topics/security/#cross-site-scripting-xss-protection
>
> If you are using safe then you could put a clean method on the form you 
> are using to store the data in the first place to perform the 
> validation/cleaning and if you wanted to go a step further and have places 
> that update outside of forms then overload the save method of the class, 
> put the custom validation in, then call super afterwards.
>
> You could also look at django-bleach - 
> https://pypi.org/project/django-bleach/
>
> On Saturday, 6 November 2021 at 12:44:05 UTC omark...@gmail.com wrote:
>
>> hi all
>> i want to sanitize 'content' field from XSS attacks in django models
>> so i installed 'bleach' and used but script like "an 
>> evil() example" store as is (without sanitize script)
>> Note: i need bleach via function in models
>> Any idea ?
>> Thanks
>> [image: bleach-Models.png]
>>
>

-- 
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/6da70f02-17ab-4e3f-8595-c6d492208abdn%40googlegroups.com.


Re: Sanitize field from xss attacks in django models

2021-11-06 Thread Steven Mapes
Are you using the safe filter in your templates as otherwise that "attack" 
won't do anything but you are right that other XSS attack vectors can be 
used as per the example in the docs 
- 
https://docs.djangoproject.com/en/3.2/topics/security/#cross-site-scripting-xss-protection

If you are using safe then you could put a clean method on the form you are 
using to store the data in the first place to perform the 
validation/cleaning and if you wanted to go a step further and have places 
that update outside of forms then overload the save method of the class, 
put the custom validation in, then call super afterwards.

You could also look at django-bleach - 
https://pypi.org/project/django-bleach/

On Saturday, 6 November 2021 at 12:44:05 UTC omark...@gmail.com wrote:

> hi all
> i want to sanitize 'content' field from XSS attacks in django models
> so i installed 'bleach' and used but script like "an 
> evil() example" store as is (without sanitize script)
> Note: i need bleach via function in models
> Any idea ?
> Thanks
> [image: bleach-Models.png]
>

-- 
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/ba551e69-e4be-4f96-9aee-01c58c54c09en%40googlegroups.com.


Sanitize field from xss attacks in django models

2021-11-06 Thread omar ahmed
hi all
i want to sanitize 'content' field from XSS attacks in django models
so i installed 'bleach' and used but script like "an 
evil() example" store as is (without sanitize script)
Note: i need bleach via function in models
Any idea ?
Thanks
[image: bleach-Models.png]

-- 
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/65df3eee-f389-45cf-bb80-432fbcee40dbn%40googlegroups.com.


Re: UML to Django models

2021-08-27 Thread Ahmet Faruk Yılmaz

I think there are some missing parts on your uml diagram. As Nigel said, 
Product should have features.
26 Ağustos 2021 Perşembe tarihinde saat 20:01:53 UTC+3 itibarıyla 
abubak...@gmail.com şunları yazdı:

> Hi, Cale thanks for the reply. but in uml diagram Product Feature doesn't 
> have any relation with the product. so why did you made a relation with the 
> product model? can you please guide me on how to do this?
>
> On Thu, Aug 26, 2021 at 8:44 PM Cale Roco  wrote:
>
>> theres a lot of different ways you can do this, depending on your desired 
>> functionality, the amount of data you intend to store etc,
>>
>> // Simple Example
>> class Product(models.Model):
>>name = models.Charfield(max_length=255)
>>
>>
>> class ProductFeature(models.Model):
>> product = models.ForeignKey(Product, on_delete=models.CASCADE)
>> feature = models.ForeignKey("Feature", on_delete=models.CASCADE)
>>
>> class Feature(models.Model):
>> name = models.CharField(max_length=60)
>> value = models.CharField(max_length=60)
>>
>> On Thursday, 26 August 2021 at 16:14:04 UTC+1 abubak...@gmail.com wrote:
>>
>>> Hi Derek it is not difficult for me to write the model for the product 
>>> entity. but there are also other diagrams that I want to convert into 
>>> models. so I was just wanted to clear my concept.
>>> I am confused in Super types and sub types as you can see an entity 
>>> within the entity. how should I convert them into models?
>>>
>>> On Thu, Aug 26, 2021 at 6:50 PM Derek  wrote:
>>>
>>>> There is not sufficient data in that image to create models.  You don't 
>>>> know the field types, for example.
>>>>
>>>> Once you have those, it should not be too hard e.g.:
>>>>
>>>> from django.db import models
>>>>
>>>> class Product(models.Model):
>>>> product_id = models.AutoField()
>>>> name = models.CharField( max_length=255)
>>>> date_introduction = models.DateField()
>>>> comment = models.TextField()
>>>>
>>>> #etc.
>>>>
>>>> You'll need to use ForeignKey fields to link related tables, of course.
>>>>
>>>> HTH.
>>>>
>>>> On Thursday, 26 August 2021 at 10:28:23 UTC+2 abubak...@gmail.com 
>>>> wrote:
>>>>
>>>>> can anyone help me?
>>>>>
>>>>> On Thu, Aug 26, 2021 at 9:32 AM DJANGO DEVELOPER  
>>>>> wrote:
>>>>>
>>>>>> Currently, I am working on an inventory management system and I have 
>>>>>> got some UML diagrams and want to convert those uml diagrams into django 
>>>>>> models. So can anyone guide me on how to convert those UML diagrams into 
>>>>>> django models?
>>>>>> an example is below of uml diagram
>>>>>>
>>>>>> -- 
>>>>>> 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...@googlegroups.com.
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com?utm_medium=email_source=footer>
>>>>>> .
>>>>>>
>>>>> -- 
>>>> 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...@googlegroups.com.
>>>>
>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> -- 
>> 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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/dbc1bde9-06d9-440d-95ea-1c9c55d1c698n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/dbc1bde9-06d9-440d-95ea-1c9c55d1c698n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/6bbf766c-a27f-4fc8-914f-b6a67b7416dcn%40googlegroups.com.


Re: UML to Django models

2021-08-26 Thread DJANGO DEVELOPER
Hi, Cale thanks for the reply. but in uml diagram Product Feature doesn't
have any relation with the product. so why did you made a relation with the
product model? can you please guide me on how to do this?

On Thu, Aug 26, 2021 at 8:44 PM Cale Roco  wrote:

> theres a lot of different ways you can do this, depending on your desired
> functionality, the amount of data you intend to store etc,
>
> // Simple Example
> class Product(models.Model):
>name = models.Charfield(max_length=255)
>
>
> class ProductFeature(models.Model):
> product = models.ForeignKey(Product, on_delete=models.CASCADE)
> feature = models.ForeignKey("Feature", on_delete=models.CASCADE)
>
> class Feature(models.Model):
> name = models.CharField(max_length=60)
> value = models.CharField(max_length=60)
>
> On Thursday, 26 August 2021 at 16:14:04 UTC+1 abubak...@gmail.com wrote:
>
>> Hi Derek it is not difficult for me to write the model for the product
>> entity. but there are also other diagrams that I want to convert into
>> models. so I was just wanted to clear my concept.
>> I am confused in Super types and sub types as you can see an entity
>> within the entity. how should I convert them into models?
>>
>> On Thu, Aug 26, 2021 at 6:50 PM Derek  wrote:
>>
>>> There is not sufficient data in that image to create models.  You don't
>>> know the field types, for example.
>>>
>>> Once you have those, it should not be too hard e.g.:
>>>
>>> from django.db import models
>>>
>>> class Product(models.Model):
>>> product_id = models.AutoField()
>>> name = models.CharField( max_length=255)
>>> date_introduction = models.DateField()
>>> comment = models.TextField()
>>>
>>> #etc.
>>>
>>> You'll need to use ForeignKey fields to link related tables, of course.
>>>
>>> HTH.
>>>
>>> On Thursday, 26 August 2021 at 10:28:23 UTC+2 abubak...@gmail.com wrote:
>>>
>>>> can anyone help me?
>>>>
>>>> On Thu, Aug 26, 2021 at 9:32 AM DJANGO DEVELOPER 
>>>> wrote:
>>>>
>>>>> Currently, I am working on an inventory management system and I have
>>>>> got some UML diagrams and want to convert those uml diagrams into django
>>>>> models. So can anyone guide me on how to convert those UML diagrams into
>>>>> django models?
>>>>> an example is below of uml diagram
>>>>>
>>>>> --
>>>>> 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...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>> --
>>> 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...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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/dbc1bde9-06d9-440d-95ea-1c9c55d1c698n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/dbc1bde9-06d9-440d-95ea-1c9c55d1c698n%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAKPY9pndwiaa8qv5b55e%2BOtvzb0pERSgQZ0xUv8saff%2BW8-hKQ%40mail.gmail.com.


Re: UML to Django models

2021-08-26 Thread Cale Roco
theres a lot of different ways you can do this, depending on your desired 
functionality, the amount of data you intend to store etc,

// Simple Example
class Product(models.Model):
   name = models.Charfield(max_length=255)


class ProductFeature(models.Model):
product = models.ForeignKey(Product, on_delete=models.CASCADE)
feature = models.ForeignKey("Feature", on_delete=models.CASCADE)

class Feature(models.Model):
name = models.CharField(max_length=60)
value = models.CharField(max_length=60)

On Thursday, 26 August 2021 at 16:14:04 UTC+1 abubak...@gmail.com wrote:

> Hi Derek it is not difficult for me to write the model for the product 
> entity. but there are also other diagrams that I want to convert into 
> models. so I was just wanted to clear my concept.
> I am confused in Super types and sub types as you can see an entity within 
> the entity. how should I convert them into models?
>
> On Thu, Aug 26, 2021 at 6:50 PM Derek  wrote:
>
>> There is not sufficient data in that image to create models.  You don't 
>> know the field types, for example.
>>
>> Once you have those, it should not be too hard e.g.:
>>
>> from django.db import models
>>
>> class Product(models.Model):
>> product_id = models.AutoField()
>> name = models.CharField( max_length=255)
>> date_introduction = models.DateField()
>> comment = models.TextField()
>>
>> #etc.
>>
>> You'll need to use ForeignKey fields to link related tables, of course.
>>
>> HTH.
>>
>> On Thursday, 26 August 2021 at 10:28:23 UTC+2 abubak...@gmail.com wrote:
>>
>>> can anyone help me?
>>>
>>> On Thu, Aug 26, 2021 at 9:32 AM DJANGO DEVELOPER  
>>> wrote:
>>>
>>>> Currently, I am working on an inventory management system and I have 
>>>> got some UML diagrams and want to convert those uml diagrams into django 
>>>> models. So can anyone guide me on how to convert those UML diagrams into 
>>>> django models?
>>>> an example is below of uml diagram
>>>>
>>>> -- 
>>>> 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...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> -- 
>> 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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/dbc1bde9-06d9-440d-95ea-1c9c55d1c698n%40googlegroups.com.


Re: UML to Django models

2021-08-26 Thread DJANGO DEVELOPER
Hi Derek it is not difficult for me to write the model for the product
entity. but there are also other diagrams that I want to convert into
models. so I was just wanted to clear my concept.
I am confused in Super types and sub types as you can see an entity within
the entity. how should I convert them into models?

On Thu, Aug 26, 2021 at 6:50 PM Derek  wrote:

> There is not sufficient data in that image to create models.  You don't
> know the field types, for example.
>
> Once you have those, it should not be too hard e.g.:
>
> from django.db import models
>
> class Product(models.Model):
> product_id = models.AutoField()
> name = models.CharField( max_length=255)
> date_introduction = models.DateField()
> comment = models.TextField()
>
> #etc.
>
> You'll need to use ForeignKey fields to link related tables, of course.
>
> HTH.
>
> On Thursday, 26 August 2021 at 10:28:23 UTC+2 abubak...@gmail.com wrote:
>
>> can anyone help me?
>>
>> On Thu, Aug 26, 2021 at 9:32 AM DJANGO DEVELOPER 
>> wrote:
>>
>>> Currently, I am working on an inventory management system and I have got
>>> some UML diagrams and want to convert those uml diagrams into django
>>> models. So can anyone guide me on how to convert those UML diagrams into
>>> django models?
>>> an example is below of uml diagram
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAKPY9pne-RqvLjtELHR-%2BK4RXPnhsPyAMBzcfbzfUjLZKXwqeQ%40mail.gmail.com.


Re: UML to Django models

2021-08-26 Thread Derek
There is not sufficient data in that image to create models.  You don't 
know the field types, for example.

Once you have those, it should not be too hard e.g.:

from django.db import models

class Product(models.Model):
product_id = models.AutoField()
name = models.CharField( max_length=255)
date_introduction = models.DateField()
comment = models.TextField()

#etc.

You'll need to use ForeignKey fields to link related tables, of course.

HTH.

On Thursday, 26 August 2021 at 10:28:23 UTC+2 abubak...@gmail.com wrote:

> can anyone help me?
>
> On Thu, Aug 26, 2021 at 9:32 AM DJANGO DEVELOPER  
> wrote:
>
>> Currently, I am working on an inventory management system and I have got 
>> some UML diagrams and want to convert those uml diagrams into django 
>> models. So can anyone guide me on how to convert those UML diagrams into 
>> django models?
>> an example is below of uml diagram
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/74f7d899-ceb8-42a4-8809-fdd5aac48625n%40googlegroups.com.


Re: UML to Django models

2021-08-26 Thread DJANGO DEVELOPER
can anyone help me?

On Thu, Aug 26, 2021 at 9:32 AM DJANGO DEVELOPER 
wrote:

> Currently, I am working on an inventory management system and I have got
> some UML diagrams and want to convert those uml diagrams into django
> models. So can anyone guide me on how to convert those UML diagrams into
> django models?
> an example is below of uml diagram
>
> --
> 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/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAKPY9pnF%3DrgdNm9EjDBXWLYQjs%2Bv%2BrtTxkbf8seumtSRvK-ing%40mail.gmail.com.


UML to Django models

2021-08-25 Thread DJANGO DEVELOPER
Currently, I am working on an inventory management system and I have got 
some UML diagrams and want to convert those uml diagrams into django 
models. So can anyone guide me on how to convert those UML diagrams into 
django models?
an example is below of uml diagram

-- 
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/d7cc08c3-cb88-422b-8cb3-a15130abeba1n%40googlegroups.com.


HOW TO ADD SKIP LOGIG TO DJANGO MODELS

2021-07-29 Thread Winstone Makwesheni
Hello guys,can anyone help me to add skip logic to django models,
i feel too lazy to use Django Forms and then add javascript and jquery,
is there a way to add them directly to models?

Cheers

Winstone

-- 
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/CABhUtB%2B8hdhy7auEHUxN7bFX%2B3XGMNAh6j5NYvu6MdBxXNkZ9Q%40mail.gmail.com.


How to make relationship in django models in such scenario

2020-12-31 Thread Dhruvil Shah
*models.py* So,here i want to make Invoicemgmt model in which i can have
multiple entries for Invoice table having customer,project and
Invoice_amount.

Basically,requirement is that whenever i see 'view_Invoice' of some
id,first i will see all data of that specific id on that page and then i
want to have small table below for invoice_mgmt,where i can add amount
received for that specific id invoice.

*so,i want to know what fields should i add in invoice_mgmt model for
relationship "


"models.py"

class Invoice(models.Model):
company_choice = (
('VT_India', 'VT_India'),
('VT_USA', 'VT_USA'),
)
company = models.CharField(
max_length=30, blank=True, null=True, choices=company_choice)
customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
project = models.ForeignKey(Allproject, on_delete=models.CASCADE)

invoice_title = models.CharField(max_length=15)

invoice_id = models.IntegerField(primary_key=True)
invoice_amount = models.IntegerField()
invoice_date = models.DateField(
blank=True, null=True)
invoice_duedate = models.DateField(
blank=True, null=True)

invoice_description = models.TextField()

def __str__(self):
return self.invoice_title

class Paymentmethod(models.Model):
paymentmethod_id = models.IntegerField(primary_key=True)
paymentmethod_name = models.CharField(max_length=15)

def __str__(self):
return self.paymentmethod_name

class Invoicemgmt(models.Model):
invoicemanagement_id = models.IntegerField(primary_key=True)
invoice_received = models.IntegerField()
date = models.DateField(
blank=True, null=True)
payment_method = models.ForeignKey(Paymentmethod, on_delete=models.CASCADE)


"So, basically i want to have multiple entries in invoice mgmt table
for one specific invoice table id(one specific data)"

-- 
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/CADsP_iz2TOzNc%2BShAH-SU4xhVu_mxE1xaa1uVHdDy6Vi3mOciw%40mail.gmail.com.


Cryptography in Django Models

2020-12-09 Thread Shahprogrammer
Hi Everybody,
I have just created a package for bi-directional cryptography in Django 
Models.
It has following features:-

   1. *Supports data **retrieval*
   2. *Supports custom query*
   3. *Supports Q() queries*
   4. *Supports Ordering data through python functions*
   5. *Supports Sorting data through python functions*
   6. *Supports 'startswith' lookups for all String Based Fields*
   7. *Supports 'date' lookup for Date,DateTime Fields*
   8. *Supports 'time' lookup for TimeField*

Django-CryptographicFields 
<https://pypi.org/project/Django-CryptographicFields/>
Docs for Django-CryptographicFields 
<https://django-cryptographicfields.readthedocs.io/en/latest/>

-- 
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/7fa6b286-3bc2-419f-9d1b-c09dd28bdf06n%40googlegroups.com.


Custom attributes on Django models through mixins

2020-10-23 Thread Umang Sharan
Hi,

Stackoverflow link for all the details: https://stackoverflow.com/
questions/64485888/add-custom-attributes-to-django-models-through-mixins

Tl;dr - dynamically setting method attributes on models through mixin 
classes doesn't work as expected. Appreciate any help.

-- 
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/65da9010-6bfe-4d12-8613-ad9fd5026031n%40googlegroups.com.


Re: Need the create statements for my Django models

2020-08-11 Thread Derek
"I was recently porting a legacy DB to Django by using the inspectdb 
command" - is there any reason why you cannot just stop here?  Why do you 
think the "inspectdb" would fail?  I would just go on creating the app and 
if any issues arise, I'd look at the specific model and see if it is 
because of a DB mismatch.  You have no control over the DB, so you'll need 
to keep adjusting your code as you go on.

On Friday, 7 August 2020 23:20:03 UTC+2, Saahitya E wrote:
>
> Hi,
>
> I was recently porting a legacy DB to Django by using the inspectdb 
> command and then manually comparing the model to the corresponding table 
> description. I want to confirm that I have not made any mistakes by getting 
> the corresponding SQL create commands that migrate would have used to 
> create the model and then comparing it to the original SQL create queries 
> in my DB. I saw that there was a python3 manage.py sql  to do 
> exactly that, but it seems to be depreciated. 
>
> Thanks and regards
> Saahitya
>
>
> PS: Using migrations is not possible as other services are using the DB.
>

-- 
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/997f639c-5298-4856-a765-026588df61aao%40googlegroups.com.


Need the create statements for my Django models

2020-08-07 Thread Saahitya E
Hi,

I was recently porting a legacy DB to Django by using the inspectdb command 
and then manually comparing the model to the corresponding table 
description. I want to confirm that I have not made any mistakes by getting 
the corresponding SQL create commands that migrate would have used to 
create the model and then comparing it to the original SQL create queries 
in my DB. I saw that there was a python3 manage.py sql  to do 
exactly that, but it seems to be depreciated. 

Thanks and regards
Saahitya


PS: Using migrations is not possible as other services are using the DB.

-- 
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/d9560bc8-aef5-4e1b-b31f-c63c72e3d268n%40googlegroups.com.


Re: Regarding Django models.

2020-06-18 Thread MANISH YADAV
But if I use SQL Alchemy, can I use django admin panel. Because need that. 

-- 
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/d24e9e30-08d1-4082-ba3b-58555aebca68o%40googlegroups.com.


Re: Regarding Django models.

2020-06-18 Thread DOT. py
Use SQL Alchemy ORM , Django ORM has foreign key policy , if u can solve it
using that it's on u ..

On Fri, Jun 19, 2020, 01:23 MANISH YADAV  wrote:

> hello community members,
> I am a student and interested in Django. can you please help me.
> I am designing a project in Django. For that, I have my database schema
> which consists of the composite primary key and composite foreign key. But
> Django does not support any type of composite key.
> I have tried out but unable to solve it. I am giving a sample of the
> database schema so you can understand better.
>
> DATABASE SCHEMA
>
> Department (*deptId*, dept_name, head_id, dept_exe_id)   > * deptId*
> is primary key
>
> AcademicYear (*deptId, year*)
>  ->  *deptId*s references from Department and *(deptId, year)*
> composite primary key
>
> Semester (*deptId, year, sem*)
> --> *deptId, year *is references from AcademicYear and *(deptId,
> year, sem)* composite primary key
>
> Division (*deptId, year, sem, div, batch*)
>  ---> *deptId, year, sem *is references from semester and *(deptId,
> year, sem, div, batch)* composite primary key.
>
>
> Regards,
>
> Manish Yadav
>
> --
> 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/8681de2d-977e-4817-be8d-2d1e865e93a6o%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/CABCeVgwV3ybXZ4DK6TirifTEDUzfO5h%3DJ%3D3U22PxJZO9AsST1A%40mail.gmail.com.


Regarding Django models.

2020-06-18 Thread MANISH YADAV
hello community members,
I am a student and interested in Django. can you please help me.
I am designing a project in Django. For that, I have my database schema 
which consists of the composite primary key and composite foreign key. But 
Django does not support any type of composite key.
I have tried out but unable to solve it. I am giving a sample of the 
database schema so you can understand better.

DATABASE SCHEMA

Department (*deptId*, dept_name, head_id, dept_exe_id)   > * deptId* is 
primary key

AcademicYear (*deptId, year*)
 ->  *deptId*s references from Department and *(deptId, year)* 
composite primary key

Semester (*deptId, year, sem*)
--> *deptId, year *is references from AcademicYear and *(deptId, year, 
sem)* composite primary key

Division (*deptId, year, sem, div, batch*) ---> 
*deptId, 
year, sem *is references from semester and *(deptId, year, sem, div, batch)* 
composite 
primary key.


Regards,

Manish Yadav

-- 
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/8681de2d-977e-4817-be8d-2d1e865e93a6o%40googlegroups.com.


Django models for user

2020-05-09 Thread Irfan Khan
i am working on a LMS project, so if a tutor signed up and he can upload
his tutorials from his account.
And  when rendering to template each user should have their list of
tutorials. as well as he will upload new tutorials.

How to design it dynamically. Please guide me.

Thank you 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/CALKGVirPguVcOZpy6Y5xgFo5j9rzrCnD-P_p0YPYY32ZgFeO0A%40mail.gmail.com.


Django models and multiprocessing: "no results to fetch"

2020-02-24 Thread Rainer Hihn
Hi all,

in my project, I'm traversing through a huge directory with millions of files, 
parse them and write the results into a Postgres database.
Unfortunately, I'm facing erros when I'm using multiprocessing.Pool with more 
than one processes.

This is how I'm inserting new values into the database:

obj, created = MyModel.objects.get_or_create(foo=foo, defaults={'foo': foo,}) # 
foo is unique


And this is the error message I'm getting: 


[ERROR] no results to fetch
Traceback (most recent call last):
  File "~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/utils.py", 
line 97, in inner
return func(*args, **kwargs)
psycopg2.ProgrammingError: no results to fetch

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "~/develop/myApp/web/service/ais.py", line 94, in save
db_foo = utils.create_foo(obj.get("foo"), obj.get("source"))
  File "~/develop/myApp/web/utils.py", line 85, in create_foo
obj = MyModel.objects.get(foo=foo)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/manager.py", 
line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 411, in get
num = len(clone)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 258, in __len__
self._fetch_all()
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 1261, in _fetch_all
self._result_cache = list(self._iterable_class(self))
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 57, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
chunk_size=self.chunk_size)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/sql/compiler.py",
 line 1177, in execute_sql
return list(result)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/sql/compiler.py",
 line 1576, in cursor_iter
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/sql/compiler.py",
 line 1576, in 
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
  File "~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/utils.py", 
line 97, in inner
return func(*args, **kwargs)
  File "~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/utils.py", 
line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
  File "~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/utils.py", 
line 97, in inner
return func(*args, **kwargs)
django.db.utils.ProgrammingError: no results to fetch
[ERROR] error with status PGRES_TUPLES_OK and no message from the libpq
Traceback (most recent call last):
  File "~/develop/myApp/web/utils.py", line 85, in create_foo
obj = MyModel.objects.get(foo=foo)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/manager.py", 
line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 415, in get
raise self.model.DoesNotExist(
web.models.MyModel.DoesNotExist: MyModel matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/backends/utils.py", 
line 86, in _execute
return self.cursor.execute(sql, params)
psycopg2.DatabaseError: error with status PGRES_TUPLES_OK and no message from 
the libpq

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "~/develop/myApp/web/service/ais.py", line 94, in save
db_foo = utils.create_foo(obj.get("foo"), obj.get("source"))
  File "~/develop/myApp/web/utils.py", line 89, in create_foo
obj = MyModel.objects.create(foo=foo)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/manager.py", 
line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 433, in create
obj.save(force_insert=True, using=self.db)
  File "~/develop/myApp/web/models.py", line 34, in save
return super().save(*args, **kwargs)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/base.py", 
line 745, in save
self.save_base(using=using, force_insert=force_insert,
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/base.py", 
line 782, in save_base
updated = self._save_table(
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/base.py", 
line 887, in _save_table
results = 

Re: How to Extract values of diffrent from foreign key in django models

2020-01-11 Thread Integr@te System
Hi Manas,

What about User model!? (Because of ForeignKey you declared)

This is where Friend.object.get() come from Friend model of current user.




On Sun, Jan 12, 2020, 11:50 manas srivastava 
wrote:

>
>
>
> I have made a model to make friends using Django model. Now I am unable to
> get the friend id through the model. The model is as follows
>
> class Friend(models.Model):
>
> users = models.ManyToManyField(User) #following users
>
> current_user = models.ForeignKey(User, related_name='owner', 
> null=True,on_delete=models.CASCADE)  #followers
>
> @classmethod
>
> def make_friend(cls, current_user, new_friend):
>
> friend, created = cls.objects.get_or_create(
>
> current_user = current_user
>
> )
>
> friend.users.add(new_friend)
>
>
>
> @classmethod
>
> def lose_friend(cls, current_user, new_friend):
>
> friend, created = cls.objects.get_or_create( style="border-bottom-color: currentColor; border-bottom-style: none; 
> border-bottom-width: 0px; border-image-outset: 0; border-image-repeat: 
> stretch; border-image-slice: 100%; border-image-source: none; 
> border-image-width: 1; border-left-color: currentColor; border-left-style: 
> none; border-left-width: 0px; border-right-color: currentColor; 
> border-right-style: none; border-right-width: 0px; border-top-color: 
> currentColor; border-top-style: none; border-top-width: 0px; box-sizing: 
> inherit; color: rgb(48, 51, 54); font-family: inherit; font
>
>

-- 
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/CAP5HUWrJ-RYKnX0WS9saEEKJ%3DBU1VpedQn19h9X%3D4AWURQ66dQ%40mail.gmail.com.


How to Extract values of diffrent from foreign key in django models

2020-01-11 Thread manas srivastava



I have made a model to make friends using Django model. Now I am unable to 
get the friend id through the model. The model is as follows

class Friend(models.Model):

users = models.ManyToManyField(User) #following users

current_user = models.ForeignKey(User, related_name='owner', 
null=True,on_delete=models.CASCADE)  #followers

@classmethod

def make_friend(cls, current_user, new_friend):

friend, created = cls.objects.get_or_create(

current_user = current_user

)

friend.users.add(new_friend)



@classmethod

def lose_friend(cls, current_user, new_friend):

friend, created = cls.objects.get_or_create(

current_user = current_user

)

friend.users.remove(new_friend)

How can I extract the friend id

-- 
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/a221fa4d-6c0a-487c-8514-2b2fdcf397e2%40googlegroups.com.


Re: Creating Django models dynamically

2019-12-29 Thread Integr@te System
Hi,

Look at Django CMS features as it is in your purpose.


On Sun, Dec 29, 2019, 20:35 Meet Vasani  wrote:

> Is there any way to create model for the database using form input from
> the end user ?
>
> Scenario: There is authority for the particular company. Authority wants
> to create HTML form schema according to company which he's affiliated with.
> There are many Authorities with diffrent companies they're affiliated with.
>
> Any solution is highly Appreciated.
>
> 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/7b403af4-9ab4-412b-92e9-0a91e239ed0d%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/CAP5HUWpUwFP-j7gJTMf0kL28fmbVyG8H4N63j%2BhFv3x%2B7w31dA%40mail.gmail.com.


Creating Django models dynamically

2019-12-29 Thread Meet Vasani
Is there any way to create model for the database using form input from the 
end user ?

Scenario: There is authority for the particular company. Authority wants to 
create HTML form schema according to company which he's affiliated with. 
There are many Authorities with diffrent companies they're affiliated with.

Any solution is highly Appreciated.

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/7b403af4-9ab4-412b-92e9-0a91e239ed0d%40googlegroups.com.


Re: FieldError at / Django models how to reslove this issue....

2019-12-19 Thread Jack Lin
FYI, you can check this documentation

for
double underscore in Django.

-- 
Jack Lin

在 2019年12月20日 於 上午1:28:29, Simon Charette (charett...@gmail.com) 寫下:

You are missing an underscore here.

It should be published_date__lte and not published_date_lte.

Cheers,
Simon

Le jeudi 19 décembre 2019 11:40:05 UTC-5, MEGA NATHAN a écrit :
>
> Hi all.
>
> Cannot resolve keyword 'published_date_lte' into field. Choices are: author, 
> author_id, comments, create_date, id, published_date, text, title
>
>
>
> this are models:
> from django.db import models
> from django.utils import timezone
> from django.urls import reverse
>
> # Create your models here.
>
> class Post(models.Model):
> author = models.ForeignKey('auth.User', on_delete=models.CASCADE,)
> title = models.CharField(max_length=200)
> text = models.TextField()
> create_date = models.DateTimeField(default=timezone.now())
> published_date = models.DateTimeField(blank=True, null=True)
>
> def publish(self):
> self.published_date = timezone.now()
> self.save()
>
> #def approve_comments(self):
> #return self.comments.filter(approved_comments=True)
>
> def approved_comments(self):
> return self.comments.filter(approved_comment=True)
>
> #def get_absolute_url(self):
> #return reverse("post_detail", kwargs={"pk": self.pk})
>
> def __str__self():
> return self.title
>
> class Comment(models.Model):
> post = models.ForeignKey('blog.post',related_name='comments'
> , on_delete=models.CASCADE,)
> title = models.CharField(max_length=200)
> text = models.TextField()
> create_date = models.DateTimeField(default=timezone.now())
> published_date = models.DateTimeField(blank=True, null=True)
> approved_comment = models.BooleanField(default=False)
>
> def approve(self):
> self.approved_comment = True
> self.save()
>
> def get_absolute_url(self):
> return reverse('post_list')
>
> def __str__(self):
> return self.text
>
> And views:
>
> from django.shortcuts import render, get_object_or_404, redirect
> from django.utils import timezone
> #from django.utils.timezone.now`
> from blog.models import Post, Comment
> from .forms import PostForm,CommentForm
> from django.urls import reverse_lazy
> from django.contrib.auth.decorators import login_required
> from django.contrib.auth.mixins import LoginRequiredMixin
> from django.views.generic import (TemplateView, ListView,
> DetailView, CreateView,
> UpdateView, DeleteView)
>
> # Create your views here.
>
> class Aboutview(TemplateView):
> template_name = 'about.html'
>
> class PostListView(ListView):
> model = Post
>
> def get_queryset(self):
> return Post.objects.filter(published_date_lte=
> timezone.now()).order_by('-published_date')
>
> class PostDetailView(DetailView):
> model = Post
>
> class CreatePostView(LoginRequiredMixin,CreateView):
> Login_url = '/Login/'
> redirect_field_name = 'blog/post_detail.html'
> from_class = PostForm
> model = Post
>
> class PostUpdateView(LoginRequiredMixin, UpdateView):
> Login_url = '/Login/'
> redirect_field_name = 'blog/post_detail.html'
> from_class = PostForm
> model = Post
>
> #class PostDeleteView(loginrequiredMixin, DeleteView):
> class PostDeleteView(LoginRequiredMixin,DeleteView):
> model = Post
> success_url = reverse_lazy('post_list')
>
> class DraftListView(LoginRequiredMixin, ListView):
> login_url = '/Login/'
> redirect_field_name = 'blog/post_list.html'
> model = Post
>
> def get__queryset(self):
> return Post.objects.filter(published_date_isnull=True).order_by(
> 'created_date')
>
>
> #
> ##
> def add_comment_to_post(request, pk):
> post = get_object_or_404(Post, pk=pk)
> if request.method == "POST":
> form = CommentForm(request.POST)
> if form.is_valid():
> comment = form.save(commit=False)
> comment.post = post
> comment.save()
> return redirect('post_detail', pk=post.pk)
> else:
> form = CommentForm()
> return render(request, 'blog/comment_form.html', {'form': form})
>
> @login_required
> def post_publish(request, pk):
> post = get_object_or_404(Post, pk=pk)
> post.publish
> return redirect('blog/post_detail.html', pk=pk)
>
> #@login_required
> def comment_approve(request,pk):
> comment = get_object_or_404(comment,pk=pk)
> comment.approve()
> return redirect('post_detail',pk=comment.post.pk)
>
> #@login_required
> def comment_remove(request,pk):
> #comment = get_object_or_404(comment, pk=pk)
> #comment.remove()
> #return redirect('post_detail',pk=comment.post.pk)
> comment = get_object_or_404(comment, pk=pk)
> post_pk = comment.post.pk
> 

Re: FieldError at / Django models how to reslove this issue....

2019-12-19 Thread Simon Charette
You are missing an underscore here.

It should be published_date__lte and not published_date_lte.

Cheers,
Simon

Le jeudi 19 décembre 2019 11:40:05 UTC-5, MEGA NATHAN a écrit :
>
> Hi all.
>
> Cannot resolve keyword 'published_date_lte' into field. Choices are: author, 
> author_id, comments, create_date, id, published_date, text, title
>
>   
>
> this are models:
> from django.db import models
> from django.utils import timezone
> from django.urls import reverse
>
> # Create your models here.
>
> class Post(models.Model):
> author = models.ForeignKey('auth.User', on_delete=models.CASCADE,)
> title = models.CharField(max_length=200)
> text = models.TextField()
> create_date = models.DateTimeField(default=timezone.now())
> published_date = models.DateTimeField(blank=True, null=True) 
>
> def publish(self):
> self.published_date = timezone.now()
> self.save()
>
> #def approve_comments(self):
> #return self.comments.filter(approved_comments=True)
> 
> def approved_comments(self):
> return self.comments.filter(approved_comment=True)
>
> #def get_absolute_url(self):
> #return reverse("post_detail", kwargs={"pk": self.pk})
>
> def __str__self():
> return self.title
>
> class Comment(models.Model):
> post = models.ForeignKey('blog.post',related_name='comments'
> , on_delete=models.CASCADE,)
> title = models.CharField(max_length=200)
> text = models.TextField()
> create_date = models.DateTimeField(default=timezone.now())
> published_date = models.DateTimeField(blank=True, null=True) 
> approved_comment = models.BooleanField(default=False)
>
> def approve(self):
> self.approved_comment = True
> self.save()
> 
> def get_absolute_url(self):
> return reverse('post_list')
>  
> def __str__(self):
> return self.text
>
> And views:
>
> from django.shortcuts import render, get_object_or_404, redirect
> from django.utils import timezone
> #from django.utils.timezone.now`
> from blog.models import Post, Comment
> from .forms import PostForm,CommentForm
> from django.urls import reverse_lazy
> from django.contrib.auth.decorators import login_required
> from django.contrib.auth.mixins import LoginRequiredMixin 
> from django.views.generic import
>  (TemplateView, ListView, DetailView, CreateView,
> UpdateView, DeleteView)
> 
> # Create your views here.
>
> class Aboutview(TemplateView):
> template_name = 'about.html'
>
> class PostListView(ListView):
> model = Post
>
> def get_queryset(self):
> return
>  Post.objects.filter(published_date_lte=timezone.now()).order_by(
> '-published_date')
>
> class PostDetailView(DetailView):
> model = Post
>
> class CreatePostView(LoginRequiredMixin,CreateView):
> Login_url = '/Login/'
> redirect_field_name = 'blog/post_detail.html'
> from_class = PostForm
> model = Post
>
> class PostUpdateView(LoginRequiredMixin, UpdateView):
> Login_url = '/Login/'
> redirect_field_name = 'blog/post_detail.html'
> from_class = PostForm
> model = Post
>
> #class PostDeleteView(loginrequiredMixin, DeleteView):
> class PostDeleteView(LoginRequiredMixin,DeleteView):
> model = Post
> success_url = reverse_lazy('post_list')
>
> class DraftListView(LoginRequiredMixin, ListView):
> login_url = '/Login/'
> redirect_field_name = 'blog/post_list.html'
> model = Post
>
> def get__queryset(self):
> return Post.objects.filter(published_date_isnull=True).order_by(
> 'created_date')
>
>
> #
> ##
> def add_comment_to_post(request, pk):
> post = get_object_or_404(Post, pk=pk)
> if request.method == "POST":
> form = CommentForm(request.POST)
> if form.is_valid():
> comment = form.save(commit=False)
> comment.post = post
> comment.save()
> return redirect('post_detail', pk=post.pk)
> else:
> form = CommentForm()
> return render(request, 'blog/comment_form.html', {'form': form})
>
> @login_required
> def post_publish(request, pk):
> post = get_object_or_404(Post, pk=pk)
> post.publish
> return redirect('blog/post_detail.html', pk=pk)
>
> #@login_required
> def comment_approve(request,pk):
> comment = get_object_or_404(comment,pk=pk)
> comment.approve()
> return redirect('post_detail',pk=comment.post.pk)
>
> #@login_required
> def comment_remove(request,pk):
> #comment = get_object_or_404(comment, pk=pk)
> #comment.remove()
> #return redirect('post_detail',pk=comment.post.pk)
> comment = get_object_or_404(comment, pk=pk)
> post_pk = comment.post.pk
> comment_delete()
> return redirect('post_detail',pk=comment.post.pk)
>
> *blog urls:*
>
> #from django.conf.urls import path
> from django.urls import include, path
>
> from 

FieldError at / Django models how to reslove this issue....

2019-12-19 Thread MEGA NATHAN
Hi all.

Cannot resolve keyword 'published_date_lte' into field. Choices are: author, 
author_id, comments, create_date, id, published_date, text, title

  

this are models:
from django.db import models
from django.utils import timezone
from django.urls import reverse

# Create your models here.

class Post(models.Model):
author = models.ForeignKey('auth.User', on_delete=models.CASCADE,)
title = models.CharField(max_length=200)
text = models.TextField()
create_date = models.DateTimeField(default=timezone.now())
published_date = models.DateTimeField(blank=True, null=True) 

def publish(self):
self.published_date = timezone.now()
self.save()

#def approve_comments(self):
#return self.comments.filter(approved_comments=True)

def approved_comments(self):
return self.comments.filter(approved_comment=True)

#def get_absolute_url(self):
#return reverse("post_detail", kwargs={"pk": self.pk})

def __str__self():
return self.title

class Comment(models.Model):
post = models.ForeignKey('blog.post',related_name='comments'
, on_delete=models.CASCADE,)
title = models.CharField(max_length=200)
text = models.TextField()
create_date = models.DateTimeField(default=timezone.now())
published_date = models.DateTimeField(blank=True, null=True) 
approved_comment = models.BooleanField(default=False)

def approve(self):
self.approved_comment = True
self.save()

def get_absolute_url(self):
return reverse('post_list')
 
def __str__(self):
return self.text

And views:

from django.shortcuts import render, get_object_or_404, redirect
from django.utils import timezone
#from django.utils.timezone.now`
from blog.models import Post, Comment
from .forms import PostForm,CommentForm
from django.urls import reverse_lazy
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin 
from django.views.generic import
 (TemplateView, ListView, DetailView, CreateView,
UpdateView, DeleteView)

# Create your views here.

class Aboutview(TemplateView):
template_name = 'about.html'

class PostListView(ListView):
model = Post

def get_queryset(self):
return
 Post.objects.filter(published_date_lte=timezone.now()).order_by(
'-published_date')

class PostDetailView(DetailView):
model = Post

class CreatePostView(LoginRequiredMixin,CreateView):
Login_url = '/Login/'
redirect_field_name = 'blog/post_detail.html'
from_class = PostForm
model = Post

class PostUpdateView(LoginRequiredMixin, UpdateView):
Login_url = '/Login/'
redirect_field_name = 'blog/post_detail.html'
from_class = PostForm
model = Post
   
#class PostDeleteView(loginrequiredMixin, DeleteView):
class PostDeleteView(LoginRequiredMixin,DeleteView):
model = Post
success_url = reverse_lazy('post_list')

class DraftListView(LoginRequiredMixin, ListView):
login_url = '/Login/'
redirect_field_name = 'blog/post_list.html'
model = Post

def get__queryset(self):
return Post.objects.filter(published_date_isnull=True).order_by(
'created_date')


#
##
def add_comment_to_post(request, pk):
post = get_object_or_404(Post, pk=pk)
if request.method == "POST":
form = CommentForm(request.POST)
if form.is_valid():
comment = form.save(commit=False)
comment.post = post
comment.save()
return redirect('post_detail', pk=post.pk)
else:
form = CommentForm()
return render(request, 'blog/comment_form.html', {'form': form})

@login_required
def post_publish(request, pk):
post = get_object_or_404(Post, pk=pk)
post.publish
return redirect('blog/post_detail.html', pk=pk)

#@login_required
def comment_approve(request,pk):
comment = get_object_or_404(comment,pk=pk)
comment.approve()
return redirect('post_detail',pk=comment.post.pk)

#@login_required
def comment_remove(request,pk):
#comment = get_object_or_404(comment, pk=pk)
#comment.remove()
#return redirect('post_detail',pk=comment.post.pk)
comment = get_object_or_404(comment, pk=pk)
post_pk = comment.post.pk
comment_delete()
return redirect('post_detail',pk=comment.post.pk)

*blog urls:*

#from django.conf.urls import path
from django.urls import include, path

from blog import views

urlpatterns = [
path('',views.PostListView.as_view(), name='Post_list'),
path('about', views.Aboutview.as_view, name='about'),
path('Post/(?P\d+)', views.PostDetailView.as_view(), name=
'post_detail'),
path('Post/new/', views.CreatePostView.as_view(), name='post_new'),
path('Post/(?P\d+)/edit/', views.PostUpdateView.as_view(), name=
'post_edit'),
path('Post/(?P\d+)/remove/', views.PostDeleteView.as_view(), name=

Re: Django models and json integration

2019-08-10 Thread Suraj Thapa FC
Can  you pls elaborate or have any working code

On Sat, 10 Aug, 2019, 9:40 PM Andrew C.,  wrote:

> Two options:
>
> 1) Save the JSON files and link it with a FileField
>
> 2) Use PostgreSQL’s Django-specific JSONField.
>
> On Sat, Aug 10, 2019 at 9:46 AM Suraj Thapa FC 
> wrote:
>
>> How can I linked a JSON file with my db... Json files contains the key
>> value pair of the user data..
>> If the id in the db and the id in the json files matches i can fetch and
>> read it..
>>
>> --
>> 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/CAPjsHcFbqtWJmDXrbafemf8TQkX9gROW-TxOvirvjsFut%3D5A1w%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/CAJVmkNkTkjYFOvwPO%3DRrdtephow%2BH4rJNk0KQNriWmO%2Bm3hEmw%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/CAPjsHcECRvr3sPTPt06CZwcVpWWKTbJ%3DYHorvco49M2_B%2BNwJw%40mail.gmail.com.


Re: Django models and json integration

2019-08-10 Thread Andrew C.
Two options:

1) Save the JSON files and link it with a FileField

2) Use PostgreSQL’s Django-specific JSONField.

On Sat, Aug 10, 2019 at 9:46 AM Suraj Thapa FC 
wrote:

> How can I linked a JSON file with my db... Json files contains the key
> value pair of the user data..
> If the id in the db and the id in the json files matches i can fetch and
> read it..
>
> --
> 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/CAPjsHcFbqtWJmDXrbafemf8TQkX9gROW-TxOvirvjsFut%3D5A1w%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/CAJVmkNkTkjYFOvwPO%3DRrdtephow%2BH4rJNk0KQNriWmO%2Bm3hEmw%40mail.gmail.com.


Django models and json integration

2019-08-10 Thread Suraj Thapa FC
How can I linked a JSON file with my db... Json files contains the key
value pair of the user data..
If the id in the db and the id in the json files matches i can fetch and
read it..

-- 
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/CAPjsHcFbqtWJmDXrbafemf8TQkX9gROW-TxOvirvjsFut%3D5A1w%40mail.gmail.com.


Re: django models

2019-05-07 Thread sachinbg sachin
On Tue, May 7, 2019, 12:35 PM Soumen Khatua  Hi Folks,
>
> I didn't  understand this code please help me to understand this code.
>
> class AddressQueryset(models.QuerySet):
> def annotate_default(self, user):
> # Set default shipping/billing address pk to None
> # if default shipping/billing address doesn't exist
> default_shipping_address_pk, default_billing_address_pk = None,
> None
> if user.default_shipping_address:
> default_shipping_address_pk = user.default_shipping_address.pk
> if user.default_billing_address:
> default_billing_address_pk = user.default_billing_address.pk
> return user.addresses.annotate(
> user_default_shipping_address_pk=Value(
> default_shipping_address_pk, models.IntegerField()),
> user_default_billing_address_pk=Value(
> default_billing_address_pk, models.IntegerField()))
>
>
> default_shipping_address & default_billing_address_pk is available in my
> User table it is a foreignkey of Address table  and  addresses is also
> avialable in my User table as ManytoManytoField refering to same Address
> Table and the last i'm using this inside Address table just like this :
> objects = AddressQueryset.as_manager()
>
>
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPUw6Wbb9Emmq0aODhK9GmT9Z8X0TMQtSOsPJ-SA-99mpdT6sg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOs61rwsOdXyWTi%2BxhWO%3DybO2sLF77dmris_Au0Q1gsrUMhuCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django models

2019-05-07 Thread Soumen Khatua
Hi Folks,

I didn't  understand this code please help me to understand this code.

class AddressQueryset(models.QuerySet):
def annotate_default(self, user):
# Set default shipping/billing address pk to None
# if default shipping/billing address doesn't exist
default_shipping_address_pk, default_billing_address_pk = None, None
if user.default_shipping_address:
default_shipping_address_pk = user.default_shipping_address.pk
if user.default_billing_address:
default_billing_address_pk = user.default_billing_address.pk
return user.addresses.annotate(
user_default_shipping_address_pk=Value(
default_shipping_address_pk, models.IntegerField()),
user_default_billing_address_pk=Value(
default_billing_address_pk, models.IntegerField()))


default_shipping_address & default_billing_address_pk is available in my
User table it is a foreignkey of Address table  and  addresses is also
avialable in my User table as ManytoManytoField refering to same Address
Table and the last i'm using this inside Address table just like this :
objects = AddressQueryset.as_manager()



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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPUw6Wbb9Emmq0aODhK9GmT9Z8X0TMQtSOsPJ-SA-99mpdT6sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2019-05-07 Thread Soumen Khatua
Yes,You are right as_data is custom made function inside the same
class,here is the code:



def as_data(self):
"""Return the address as a dict suitable for passing as
kwargs.Result does not contain the primary key or an associated user."""
data = model_to_dict(self,exclude=['id','user'])
if isinstance(data['country'], Country):
data['country'] = data['country'].code
if isinstance(data['phone'], PhoneNumber):
#as_e164 is a phonenumber format information
data['phone'] = data['phone'].as_e164
return data


But here other is an argument so we need to pass it then without passing
how we can compare with self.as_data varibale?

Thank you for your response.

On Tue, May 7, 2019 at 2:19 AM Skyisblue  wrote:

> Soumen,
>
> The function looks to compare two Address objects. The as_data() call is
> custom made. I saw it documented in your other post. It removes the Primary
> Key and User from the Address object. I presume this is so they can compare
> the hash of one address to the hash of another.
>
> Regards,
> Joe
>
> On Mon, May 6, 2019 at 6:03 AM Soumen Khatua 
> wrote:
>
>> Hi Folks,
>>
>> How this underline code works?
>>
>>
>> models.py
>>
>> class Address(models.Model):
>> first_name = models.CharField(max_length=256, blank=True)
>> last_name = models.CharField(max_length=256, blank=True)
>> company_name = models.CharField(max_length=256, blank=True)
>> street_address_1 = models.CharField(max_length=256, blank=True)
>> street_address_2 = models.CharField(max_length=256, blank=True)
>> city = models.CharField(max_length=256, blank=True)
>> city_area = models.CharField(max_length=128, blank=True)
>> postal_code = models.CharField(max_length=20, blank=True)
>> country = CountryField()
>> country_area = models.CharField(max_length=128, blank=True)
>> phone = PossiblePhoneNumberField(blank=True, default='')
>>
>>
>> *def __eq__(self, other):*
>> *   return self.as_data() == other.as_data()*
>> * __hash__ = models.Model.__hash__*
>>
>>
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAPUw6WY-pNGnPBHzDA%3DiRZUHY7NrmK30_dMbKiQpe%2B1n%2ByW%2BQQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGgUuiuun1NebT1V5r2v3GGjSCJ4RybUw9Fsn1g4M6x1ei2VQw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPUw6Wbdko08d210HbV5uv8EBeWiC6Q%3D8LKdfyyYKHN--7__pA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2019-05-06 Thread Skyisblue
Soumen,

The function looks to compare two Address objects. The as_data() call is
custom made. I saw it documented in your other post. It removes the Primary
Key and User from the Address object. I presume this is so they can compare
the hash of one address to the hash of another.

Regards,
Joe

On Mon, May 6, 2019 at 6:03 AM Soumen Khatua 
wrote:

> Hi Folks,
>
> How this underline code works?
>
>
> models.py
>
> class Address(models.Model):
> first_name = models.CharField(max_length=256, blank=True)
> last_name = models.CharField(max_length=256, blank=True)
> company_name = models.CharField(max_length=256, blank=True)
> street_address_1 = models.CharField(max_length=256, blank=True)
> street_address_2 = models.CharField(max_length=256, blank=True)
> city = models.CharField(max_length=256, blank=True)
> city_area = models.CharField(max_length=128, blank=True)
> postal_code = models.CharField(max_length=20, blank=True)
> country = CountryField()
> country_area = models.CharField(max_length=128, blank=True)
> phone = PossiblePhoneNumberField(blank=True, default='')
>
>
> *def __eq__(self, other):*
> *   return self.as_data() == other.as_data()*
> * __hash__ = models.Model.__hash__*
>
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPUw6WY-pNGnPBHzDA%3DiRZUHY7NrmK30_dMbKiQpe%2B1n%2ByW%2BQQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGgUuiuun1NebT1V5r2v3GGjSCJ4RybUw9Fsn1g4M6x1ei2VQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django models

2019-05-06 Thread Soumen Khatua
Hi Folks,

How this underline code works?


models.py

class Address(models.Model):
first_name = models.CharField(max_length=256, blank=True)
last_name = models.CharField(max_length=256, blank=True)
company_name = models.CharField(max_length=256, blank=True)
street_address_1 = models.CharField(max_length=256, blank=True)
street_address_2 = models.CharField(max_length=256, blank=True)
city = models.CharField(max_length=256, blank=True)
city_area = models.CharField(max_length=128, blank=True)
postal_code = models.CharField(max_length=20, blank=True)
country = CountryField()
country_area = models.CharField(max_length=128, blank=True)
phone = PossiblePhoneNumberField(blank=True, default='')


*def __eq__(self, other):*
*   return self.as_data() == other.as_data()*
* __hash__ = models.Model.__hash__*


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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPUw6WY-pNGnPBHzDA%3DiRZUHY7NrmK30_dMbKiQpe%2B1n%2ByW%2BQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: passing django models data to python script

2019-02-20 Thread Mike Dewhirst

On 20/02/2019 6:39 pm, Ousmane Baricisse wrote:

Hi,
I would like to implement a web app using reactjs and django. I have a 
python script which does some sort of optimization and stores the 
final output in a list and returns it. Right now everything is static 
in the python script and I would like to make it dynamic so that i can 
get a user input (from a web browser) and with that, run the python 
script internally, and pass back the data to the django models, which 
will update the values in the API.

so far, I know how to:
build a REST API with django,
get user input using reactjs,
make post and get request to get data from the API or update the API 
data from user input,
However, I do not know how to access the models values in my python 
script, run the python script with django, and update the API with so 
that it contains the output in order for me to be able fetch the 
output with react.


I am not sure if im doing this the easiest way, as it sounds so 
complicated, but I am open to suggestions on better ways of doing this.


I would probably take my python script and convert it into one or more 
model methods. In principle, if the data needs to be manipulated the 
model should do the heavy lifting. It can be argued that database 
procedures should do it but that is a rare art and the Django ORM (and 
model methods) make it much easier to maintain.


At some point it needs to be saved to the database so the broad idea is 
to put the user input into a model field then override the model's 
save() method to call model methods to do the manipulation and perhaps 
fill up some other fields before or add child records after the save 
actually happens.


My typical pattern for such a save is ...

    def save(self, *args, **kwargs):
    # need to pass links across the super boundary
    links = self.make_useful_links()
    super(Substance, self).save(*args, **kwargs)
    self.create_child_records(links)

... where Substance is the model name and 'links' is returned from a 
model method. The call to super() triggers the normal Substance.save() 
method. Because child records need the substance id for their FK, they 
cannot be created until after the actual save() beyond which we can 
guarantee the substance.id is not None.


There are also pre_save and post_save signals available but I prefer the 
above because I find it easier to see what the code is doing.


Your question about how to access the model values in your script is 
solved if you embed the script in a model method. Every model method 
should have 'self' as the first arg. 'self' is the model instance so 
every field is available via self.field. For example if the Substance 
name is used to generate a bunch of URLs pointing to a bunch of public 
databases containing information on that substance ...


    def make_useful_links(self):
        links = list()
    for database in databases:
            links.append(self.assemble_url())
            # self.assemble_url() has access to self.name and 
self.cas_no fields

    return links

As it happens this could be done after the super() call but if you want 
to save anything on the model, those fields have to be complete before 
the save()


hth



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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto:django-users@googlegroups.com>.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/394fd1d7-a2e2-4c59-ba9f-ba35d7eba9cd%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/394fd1d7-a2e2-4c59-ba9f-ba35d7eba9cd%40googlegroups.com?utm_medium=email_source=footer>.

For more options, visit https://groups.google.com/d/optout.


--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/48fd56c6-3636-149e-f942-3c96ff02933c%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


passing django models data to python script

2019-02-20 Thread Ousmane Baricisse
Hi,
I would like to implement a web app using reactjs and django. I have a 
python script which does some sort of optimization and stores the final 
output in a list and returns it. Right now everything is static in the 
python script and I would like to make it dynamic so that i can get a user 
input (from a web browser) and with that, run the python script internally, 
and pass back the data to the django models, which will update the values 
in the API. 
so far, I know how to: 
build a REST API with django, 
get user input using reactjs, 
make post and get request to get data from the API or update the API data 
from user input, 
However, I do not know how to access the models values in my python script, 
run the python script with django, and update the API with so that it 
contains the output in order for me to be able fetch the output with react.

I am not sure if im doing this the easiest way, as it sounds so 
complicated, but I am open to suggestions on better ways of doing this.
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/394fd1d7-a2e2-4c59-ba9f-ba35d7eba9cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using reflection with Django models to determine module containing the choices?

2018-12-10 Thread Stodge
Thanks Simon. It's for an offline tool so high performance isn't the top 
priority.

On Monday, 10 December 2018 11:56:53 UTC-5, Simon Charette wrote:
>
> Given choices are defined at the module level I guess you could
> iterate over objects defined in each `sys.modules` (or the ones
> likely to define choices) and use the `is` operator to compare all
> of them to the field choices.
>
> This will perform badly and shouldn't be used for anything else
> than one off debugging reflection though.
>
> Best,
> Simon
>
> Le lundi 10 décembre 2018 10:33:35 UTC-5, Stodge a écrit :
>>
>> Let's say I take the following code from the Django documentatation:
>>
>>
>> class Student(models.Model):
>> FRESHMAN = 'FR'
>> SOPHOMORE = 'SO'
>> JUNIOR = 'JR'
>> SENIOR = 'SR'
>> YEAR_IN_SCHOOL_CHOICES = (
>> (FRESHMAN, 'Freshman'),
>> (SOPHOMORE, 'Sophomore'),
>> (JUNIOR, 'Junior'),
>> (SENIOR, 'Senior'),
>> )
>> year_in_school = models.CharField(
>> max_length=2,
>> choices=YEAR_IN_SCHOOL_CHOICES,
>> default=FRESHMAN,
>> )
>>
>>
>> But instead I want to do:
>>
>> from student_app import choices
>> class Student(models.Model):
>> year_in_school = models.CharField(
>> max_length=2,
>> choices=choices.YEAR_IN_SCHOOL_CHOICES,
>> default=choices.FRESHMAN,
>> )
>>
>>
>> Is there anyway using reflection to determine which module the choices 
>> are imported from?
>>
>> For example:
>>
>> field = Student._meta.fields.get_field_by_name('year_in_school')
>> choices_source = some_clever_function(field)
>> print("Choices imported from %s." % choices_source)
>>
>> I want the output to be:
>>
>> Choices imported from student_app.
>>
>> Obviously the clever function does not exist but hopefully clarifies what 
>> I'm trying to do.
>>
>> 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8293ea73-1eae-4dcf-880a-64c55f051a12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using reflection with Django models to determine module containing the choices?

2018-12-10 Thread Simon Charette
Given choices are defined at the module level I guess you could
iterate over objects defined in each `sys.modules` (or the ones
likely to define choices) and use the `is` operator to compare all
of them to the field choices.

This will perform badly and shouldn't be used for anything else
than one off debugging reflection though.

Best,
Simon

Le lundi 10 décembre 2018 10:33:35 UTC-5, Stodge a écrit :
>
> Let's say I take the following code from the Django documentatation:
>
>
> class Student(models.Model):
> FRESHMAN = 'FR'
> SOPHOMORE = 'SO'
> JUNIOR = 'JR'
> SENIOR = 'SR'
> YEAR_IN_SCHOOL_CHOICES = (
> (FRESHMAN, 'Freshman'),
> (SOPHOMORE, 'Sophomore'),
> (JUNIOR, 'Junior'),
> (SENIOR, 'Senior'),
> )
> year_in_school = models.CharField(
> max_length=2,
> choices=YEAR_IN_SCHOOL_CHOICES,
> default=FRESHMAN,
> )
>
>
> But instead I want to do:
>
> from student_app import choices
> class Student(models.Model):
> year_in_school = models.CharField(
> max_length=2,
> choices=choices.YEAR_IN_SCHOOL_CHOICES,
> default=choices.FRESHMAN,
> )
>
>
> Is there anyway using reflection to determine which module the choices are 
> imported from?
>
> For example:
>
> field = Student._meta.fields.get_field_by_name('year_in_school')
> choices_source = some_clever_function(field)
> print("Choices imported from %s." % choices_source)
>
> I want the output to be:
>
> Choices imported from student_app.
>
> Obviously the clever function does not exist but hopefully clarifies what 
> I'm trying to do.
>
> 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4e74fd89-715a-4b93-bbe9-7d0bcd50fe98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using reflection with Django models to determine module containing the choices?

2018-12-10 Thread Stodge
Let's say I take the following code from the Django documentatation:


class Student(models.Model):
FRESHMAN = 'FR'
SOPHOMORE = 'SO'
JUNIOR = 'JR'
SENIOR = 'SR'
YEAR_IN_SCHOOL_CHOICES = (
(FRESHMAN, 'Freshman'),
(SOPHOMORE, 'Sophomore'),
(JUNIOR, 'Junior'),
(SENIOR, 'Senior'),
)
year_in_school = models.CharField(
max_length=2,
choices=YEAR_IN_SCHOOL_CHOICES,
default=FRESHMAN,
)


But instead I want to do:

from student_app import choices
class Student(models.Model):
year_in_school = models.CharField(
max_length=2,
choices=choices.YEAR_IN_SCHOOL_CHOICES,
default=choices.FRESHMAN,
)


Is there anyway using reflection to determine which module the choices are 
imported from?

For example:

field = Student._meta.fields.get_field_by_name('year_in_school')
choices_source = some_clever_function(field)
print("Choices imported from %s." % choices_source)

I want the output to be:

Choices imported from student_app.

Obviously the clever function does not exist but hopefully clarifies what 
I'm trying to do.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/78f7dcc2-c822-42cc-a06a-860ae080e5b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Create data from django models from .csv file using pandas library

2018-10-15 Thread Gaurav Toshniwal
import pandas as pd

df = pd.read_csv(RESOURCE_ROOT + '/data_files/102018_core_business.csv')

for index, row in df.iterrows():
   business_instance, created = 
Business.objects.get_or_create(business_id=row['id'], 
business_name=row['name'])




On Monday, October 15, 2018 at 3:12:45 PM UTC+4, Mohammad Aqib wrote:
>
> I have multiple .csv files to create data from django models into a 
> database using python pandas library. Can anyone suggest me how to do 
> perform this task.
>
> import pandas as pd
>
> df = pd.read_csv(RESOURCE_ROOT + '/data_files/102018_core_business.csv')
>
> business_instance, created = 
> Business.objects.get_or_create(business_id=df['id'], business_name=df['name'])
>
>
> -- 
> Mohd Aqib
> Software Engineer
> 9873141865
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2a230c66-5723-4c9d-a1c7-63f86711f8ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Create data from django models from .csv file using pandas library

2018-10-15 Thread Mohammad Aqib
Myslq database

On Mon, 15 Oct 2018, 5:05 pm ansh srivastav, 
wrote:

> Which database are you referring to?
>
>
> [image: Mailtrack]
> <https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality6;>
>  Sender
> notified by
> Mailtrack
> <https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality6;>
>  10/15/18,
> 5:03:59 PM
>
> On Mon, Oct 15, 2018 at 4:42 PM Mohammad Aqib 
> wrote:
>
>> I have multiple .csv files to create data from django models into a
>> database using python pandas library. Can anyone suggest me how to do
>> perform this task.
>>
>> import pandas as pd
>>
>> df = pd.read_csv(RESOURCE_ROOT + '/data_files/102018_core_business.csv')
>>
>> business_instance, created = 
>> Business.objects.get_or_create(business_id=df['id'], 
>> business_name=df['name'])
>>
>>
>> --
>> Mohd Aqib
>> Software Engineer
>> 9873141865
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAOh93neQTfW0CoepiyhQ57ziGDuw4fN0OTV6w-rJ%2BaXo0aUL%2Bg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAOh93neQTfW0CoepiyhQ57ziGDuw4fN0OTV6w-rJ%2BaXo0aUL%2Bg%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHMQ5333D_uPvsK-WqJgZ83_aKBUAkxt-DWDEJqT7Z0BOszTzw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHMQ5333D_uPvsK-WqJgZ83_aKBUAkxt-DWDEJqT7Z0BOszTzw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOh93ncQi3r5gA7FcOMvHkJvMzFpis7kyyhmWrab44wnn2t%3DLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Create data from django models from .csv file using pandas library

2018-10-15 Thread ansh srivastav
Which database are you referring to?


[image: Mailtrack]
<https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality6;>
Sender
notified by
Mailtrack
<https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality6;>
10/15/18,
5:03:59 PM

On Mon, Oct 15, 2018 at 4:42 PM Mohammad Aqib 
wrote:

> I have multiple .csv files to create data from django models into a
> database using python pandas library. Can anyone suggest me how to do
> perform this task.
>
> import pandas as pd
>
> df = pd.read_csv(RESOURCE_ROOT + '/data_files/102018_core_business.csv')
>
> business_instance, created = 
> Business.objects.get_or_create(business_id=df['id'], business_name=df['name'])
>
>
> --
> Mohd Aqib
> Software Engineer
> 9873141865
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAOh93neQTfW0CoepiyhQ57ziGDuw4fN0OTV6w-rJ%2BaXo0aUL%2Bg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAOh93neQTfW0CoepiyhQ57ziGDuw4fN0OTV6w-rJ%2BaXo0aUL%2Bg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHMQ5333D_uPvsK-WqJgZ83_aKBUAkxt-DWDEJqT7Z0BOszTzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Create data from django models from .csv file using pandas library

2018-10-15 Thread Mohammad Aqib
I have multiple .csv files to create data from django models into a
database using python pandas library. Can anyone suggest me how to do
perform this task.

import pandas as pd

df = pd.read_csv(RESOURCE_ROOT + '/data_files/102018_core_business.csv')

business_instance, created =
Business.objects.get_or_create(business_id=df['id'],
business_name=df['name'])


-- 
Mohd Aqib
Software Engineer
9873141865

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOh93neQTfW0CoepiyhQ57ziGDuw4fN0OTV6w-rJ%2BaXo0aUL%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-14 Thread Andréas Kühne
Hi,

The error is pretty self explanatory.

There is a missing migration file:
 (u'training_kits', u'0003_auto_20160914_0722')

So check your training_kits app for a migration that is called
0003_auto_20160914_0722.py.

This migration is a dependency for the migration:
0004_tasktype_training_kit.py in the task_types app.

Regards,

Andréas

2018-08-14 8:26 GMT+02:00 Ramandeep Kaur :

> hi guys, i need your help
> when i run makemigrations command,  i got error:
> django.db.migrations.exceptions.NodeNotFoundError: Migration
> task_types.0004_tasktype_training_kit dependencies reference nonexistent
> parent node (u'training_kits', u'0003_auto_20160914_0722')
>
> On Fri, Aug 10, 2018 at 8:21 PM Kasper Laudrup 
> wrote:
>
>> Hi Ramandeep,
>>
>> The problem is pretty much the same as before: Mismatched parentheses,
>> but I'll leave to you to figure out where. It's pretty easy to spot.
>>
>> Did you find an editor that helps you syntax check python code?
>>
>> It'll make your life a lot easier.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> On August 10, 2018 3:42:56 PM GMT+02:00, Ramandeep Kaur <
>> hpramandeepkau...@gmail.com> wrote:
>>>
>>> thanks i got my  mistake but now again i am getting an error.
>>> my urls.py:
>>> from django.conf.urls import patterns, include, url
>>> from django.contrib import admin
>>> from django.views.generic import TemplateView
>>>
>>> from rest_framework_nested import routers
>>>
>>> from rest_auth.views import LogoutView
>>>
>>> from locations.views import LocationViewSet
>>>
>>> from tasks.views import TaskViewSet, BeneficiaryTasksView,
>>> AssignedTasksView, CreatedTasksView, tasks_assign, tasks_smart_assign,
>>> FilterTasksView, PaginatedTaskViewSet, get_tasks_length,
>>> get_tasks_page_size, export_tasks_view, create_bulk_tasks,
>>> import_data_view, get_filtered_tasks_length, PledgedTasksView,create_task
>>> from task_types.views import TaskTypeViewSet
>>> from task_status.views import TaskStatusViewSet
>>> from feedback_types.views import FeedbackTypeViewSet
>>> from organisations.views import OrganisationViewSet
>>> from authentication.views import UserViewSet
>>> from user_profiles.views import *
>>> from forms.views import FormViewSet, FormDataViewSet, DataByFormView,
>>> PersistentFormViewSet, PersistentFormDataView,export_filtered_form_data
>>> from training_kits.views import *
>>> from stages.views import StageViewSet
>>> from notes.views import NoteViewSet, BeneficiaryNotesView,
>>> CreatedNotesView
>>> from user_messages.views import MessageViewSet,
>>> BeneficiaryMessagesView, SentMessagesView
>>> from todos.views import TodoViewSet, AssignedTodosView,
>>> CreatedTodosView, BeneficiaryTodosView
>>> from tags.views import (TagViewSet, LightTagViewSet, UserTagsView,
>>> UserLightTagsView,
>>> RemoveUserFromTag, RemoveExclusiveTagFromTag,
>>> AddTagToUser, AddTagsToUser, AddExclusiveTagToTag)
>>> from message_templates.views import MessageTemplateViewSet
>>> #from calls.views import CallViewSet, BeneficiaryCallsView,
>>> CallerCallsView
>>> from task_status_categories.views import TaskStatusCategoryViewSet,
>>> CreatedTaskStatusCategoriesView, getTaskCompletedFlagChoices
>>> #from actions.views import get_action_classes, ActionViewSet
>>> from events.views import EventViewSet
>>> from event_conditions.views import EventConditionViewSet,
>>> getEventConditionTypes, HelplineEventConditionsView,
>>> NormalEventConditionsView
>>> from hooks.views import HookViewSet
>>> from ivrs.views import IVRViewSet, BeneficiaryIVRsView, SentIVRsView,
>>> FeedbackIVRView
>>> from ivr_templates.views import IVRTemplateViewSet
>>> from exotel.views import MissedCall, ExotelViewSet, IncSMS, Lottery,
>>> DostPaid, DostMother, DostFather
>>> from guilds.views import GuildViewSet, add_users_to_guild
>>> from notices.views import NoticeViewSet
>>> from spaces.views import SpaceViewSet
>>> from space_types.views import SpaceTypeViewSet, add_spaces
>>> from interests.views import InterestViewSet, LightInterestViewSet,
>>> AddInterestsToUser, RemoveInterestsFromUser, UserInterestsView
>>> from pledges.views import PledgeViewSet, TaskPledgesView,
>>> UserPledgesView
>>> from party_invitations.views import PartyInvitationViewSet,
>>> SentPartyInvitationsView, ReceivedPartyInvitationsView
>>> from task_comments.views import TaskCommentViewSet,
>>> TaskCommentDetailedViewSet, TaskCommentsView, CommentedCommentsView
>>> from follows.views import FollowViewSet, FollowerFollowsView,
>>> FollowedFollowsView, get_follow
>>> #from centers.views import CenterViewSet
>>> from locations.views import LocationViewSet
>>> from kits.views import KitViewSet
>>> from parents.views import ParentViewSet,ParentWorkerListViewSet
>>> from worker.views import WorkerViewSet
>>> from child.views import ChildViewSet
>>> from payments.views import PaymentViewSet,PaymentWorkerListViewSet,
>>> PaymentDateListViewSet
>>> #from assessments.views import AssessmentViewSet
>>> from questions.views import QuestionViewSet
>>> 

Re: django models

2018-08-14 Thread Ramandeep Kaur
hi guys, i need your help
when i run makemigrations command,  i got error:
django.db.migrations.exceptions.NodeNotFoundError: Migration
task_types.0004_tasktype_training_kit dependencies reference nonexistent
parent node (u'training_kits', u'0003_auto_20160914_0722')

On Fri, Aug 10, 2018 at 8:21 PM Kasper Laudrup 
wrote:

> Hi Ramandeep,
>
> The problem is pretty much the same as before: Mismatched parentheses, but
> I'll leave to you to figure out where. It's pretty easy to spot.
>
> Did you find an editor that helps you syntax check python code?
>
> It'll make your life a lot easier.
>
> Kind regards,
>
> Kasper Laudrup
>
> On August 10, 2018 3:42:56 PM GMT+02:00, Ramandeep Kaur <
> hpramandeepkau...@gmail.com> wrote:
>>
>> thanks i got my  mistake but now again i am getting an error.
>> my urls.py:
>> from django.conf.urls import patterns, include, url
>> from django.contrib import admin
>> from django.views.generic import TemplateView
>>
>> from rest_framework_nested import routers
>>
>> from rest_auth.views import LogoutView
>>
>> from locations.views import LocationViewSet
>>
>> from tasks.views import TaskViewSet, BeneficiaryTasksView,
>> AssignedTasksView, CreatedTasksView, tasks_assign, tasks_smart_assign,
>> FilterTasksView, PaginatedTaskViewSet, get_tasks_length,
>> get_tasks_page_size, export_tasks_view, create_bulk_tasks,
>> import_data_view, get_filtered_tasks_length, PledgedTasksView,create_task
>> from task_types.views import TaskTypeViewSet
>> from task_status.views import TaskStatusViewSet
>> from feedback_types.views import FeedbackTypeViewSet
>> from organisations.views import OrganisationViewSet
>> from authentication.views import UserViewSet
>> from user_profiles.views import *
>> from forms.views import FormViewSet, FormDataViewSet, DataByFormView,
>> PersistentFormViewSet, PersistentFormDataView,export_filtered_form_data
>> from training_kits.views import *
>> from stages.views import StageViewSet
>> from notes.views import NoteViewSet, BeneficiaryNotesView,
>> CreatedNotesView
>> from user_messages.views import MessageViewSet, BeneficiaryMessagesView,
>> SentMessagesView
>> from todos.views import TodoViewSet, AssignedTodosView,
>> CreatedTodosView, BeneficiaryTodosView
>> from tags.views import (TagViewSet, LightTagViewSet, UserTagsView,
>> UserLightTagsView,
>> RemoveUserFromTag, RemoveExclusiveTagFromTag,
>> AddTagToUser, AddTagsToUser, AddExclusiveTagToTag)
>> from message_templates.views import MessageTemplateViewSet
>> #from calls.views import CallViewSet, BeneficiaryCallsView,
>> CallerCallsView
>> from task_status_categories.views import TaskStatusCategoryViewSet,
>> CreatedTaskStatusCategoriesView, getTaskCompletedFlagChoices
>> #from actions.views import get_action_classes, ActionViewSet
>> from events.views import EventViewSet
>> from event_conditions.views import EventConditionViewSet,
>> getEventConditionTypes, HelplineEventConditionsView,
>> NormalEventConditionsView
>> from hooks.views import HookViewSet
>> from ivrs.views import IVRViewSet, BeneficiaryIVRsView, SentIVRsView,
>> FeedbackIVRView
>> from ivr_templates.views import IVRTemplateViewSet
>> from exotel.views import MissedCall, ExotelViewSet, IncSMS, Lottery,
>> DostPaid, DostMother, DostFather
>> from guilds.views import GuildViewSet, add_users_to_guild
>> from notices.views import NoticeViewSet
>> from spaces.views import SpaceViewSet
>> from space_types.views import SpaceTypeViewSet, add_spaces
>> from interests.views import InterestViewSet, LightInterestViewSet,
>> AddInterestsToUser, RemoveInterestsFromUser, UserInterestsView
>> from pledges.views import PledgeViewSet, TaskPledgesView, UserPledgesView
>> from party_invitations.views import PartyInvitationViewSet,
>> SentPartyInvitationsView, ReceivedPartyInvitationsView
>> from task_comments.views import TaskCommentViewSet,
>> TaskCommentDetailedViewSet, TaskCommentsView, CommentedCommentsView
>> from follows.views import FollowViewSet, FollowerFollowsView,
>> FollowedFollowsView, get_follow
>> #from centers.views import CenterViewSet
>> from locations.views import LocationViewSet
>> from kits.views import KitViewSet
>> from parents.views import ParentViewSet,ParentWorkerListViewSet
>> from worker.views import WorkerViewSet
>> from child.views import ChildViewSet
>> from payments.views import
>> PaymentViewSet,PaymentWorkerListViewSet,PaymentDateListViewSet
>> #from assessments.views import AssessmentViewSet
>> from questions.views import QuestionViewSet
>> #from assessmentreports.views import AssessmentItemViewSet
>>
>> router = routers.SimpleRouter()
>>
>> #router.register(r'centers',CenterViewSet)
>> router.register(r'kits',KitViewSet)
>> router.register(r'parents',ParentViewSet)
>> router.register(r'workers',WorkerViewSet)
>> router.register(r'child',ChildViewSet)
>> #router.register(r'assessments',AssessmentViewSet)
>> router.register(r'questions',QuestionViewSet)
>> #router.register(r'assessmentitems',AssessmentItemViewSet)
>> 

Re: django models

2018-08-10 Thread Kasper Laudrup
Hi Ramandeep,

The problem is pretty much the same as before: Mismatched parentheses, but I'll 
leave to you to figure out where. It's pretty easy to spot.

Did you find an editor that helps you syntax check python code?

It'll make your life a lot easier.

Kind regards,

Kasper Laudrup

On August 10, 2018 3:42:56 PM GMT+02:00, Ramandeep Kaur 
 wrote:
>thanks i got my  mistake but now again i am getting an error.
>my urls.py:
>from django.conf.urls import patterns, include, url
>from django.contrib import admin
>from django.views.generic import TemplateView
>
>from rest_framework_nested import routers
>
>from rest_auth.views import LogoutView
>
>from locations.views import LocationViewSet
>
>from tasks.views import TaskViewSet, BeneficiaryTasksView,
>AssignedTasksView, CreatedTasksView, tasks_assign, tasks_smart_assign,
>FilterTasksView, PaginatedTaskViewSet, get_tasks_length,
>get_tasks_page_size, export_tasks_view, create_bulk_tasks,
>import_data_view, get_filtered_tasks_length,
>PledgedTasksView,create_task
>from task_types.views import TaskTypeViewSet
>from task_status.views import TaskStatusViewSet
>from feedback_types.views import FeedbackTypeViewSet
>from organisations.views import OrganisationViewSet
>from authentication.views import UserViewSet
>from user_profiles.views import *
>from forms.views import FormViewSet, FormDataViewSet, DataByFormView,
>PersistentFormViewSet, PersistentFormDataView,export_filtered_form_data
>from training_kits.views import *
>from stages.views import StageViewSet
>from notes.views import NoteViewSet, BeneficiaryNotesView,
>CreatedNotesView
>from user_messages.views import MessageViewSet,
>BeneficiaryMessagesView,
>SentMessagesView
>from todos.views import TodoViewSet, AssignedTodosView,
>CreatedTodosView,
>BeneficiaryTodosView
>from tags.views import (TagViewSet, LightTagViewSet, UserTagsView,
>UserLightTagsView,
>RemoveUserFromTag, RemoveExclusiveTagFromTag,
>AddTagToUser, AddTagsToUser, AddExclusiveTagToTag)
>from message_templates.views import MessageTemplateViewSet
>#from calls.views import CallViewSet, BeneficiaryCallsView,
>CallerCallsView
>from task_status_categories.views import TaskStatusCategoryViewSet,
>CreatedTaskStatusCategoriesView, getTaskCompletedFlagChoices
>#from actions.views import get_action_classes, ActionViewSet
>from events.views import EventViewSet
>from event_conditions.views import EventConditionViewSet,
>getEventConditionTypes, HelplineEventConditionsView,
>NormalEventConditionsView
>from hooks.views import HookViewSet
>from ivrs.views import IVRViewSet, BeneficiaryIVRsView, SentIVRsView,
>FeedbackIVRView
>from ivr_templates.views import IVRTemplateViewSet
>from exotel.views import MissedCall, ExotelViewSet, IncSMS, Lottery,
>DostPaid, DostMother, DostFather
>from guilds.views import GuildViewSet, add_users_to_guild
>from notices.views import NoticeViewSet
>from spaces.views import SpaceViewSet
>from space_types.views import SpaceTypeViewSet, add_spaces
>from interests.views import InterestViewSet, LightInterestViewSet,
>AddInterestsToUser, RemoveInterestsFromUser, UserInterestsView
>from pledges.views import PledgeViewSet, TaskPledgesView,
>UserPledgesView
>from party_invitations.views import PartyInvitationViewSet,
>SentPartyInvitationsView, ReceivedPartyInvitationsView
>from task_comments.views import TaskCommentViewSet,
>TaskCommentDetailedViewSet, TaskCommentsView, CommentedCommentsView
>from follows.views import FollowViewSet, FollowerFollowsView,
>FollowedFollowsView, get_follow
>#from centers.views import CenterViewSet
>from locations.views import LocationViewSet
>from kits.views import KitViewSet
>from parents.views import ParentViewSet,ParentWorkerListViewSet
>from worker.views import WorkerViewSet
>from child.views import ChildViewSet
>from payments.views import
>PaymentViewSet,PaymentWorkerListViewSet,PaymentDateListViewSet
>#from assessments.views import AssessmentViewSet
>from questions.views import QuestionViewSet
>#from assessmentreports.views import AssessmentItemViewSet
>
>router = routers.SimpleRouter()
>
>#router.register(r'centers',CenterViewSet)
>router.register(r'kits',KitViewSet)
>router.register(r'parents',ParentViewSet)
>router.register(r'workers',WorkerViewSet)
>router.register(r'child',ChildViewSet)
>#router.register(r'assessments',AssessmentViewSet)
>router.register(r'questions',QuestionViewSet)
>#router.register(r'assessmentitems',AssessmentItemViewSet)
>router.register(r'payments',PaymentViewSet)
>router.register(r'locations', LocationViewSet)
>router.register(r'tasks', TaskViewSet)
>router.register(r'task_types', TaskTypeViewSet)
>router.register(r'task_status', TaskStatusViewSet)
>router.register(r'feedback_types', FeedbackTypeViewSet)
>router.register(r'stages', StageViewSet)
>router.register(r'organisations', OrganisationViewSet)
>router.register(r'users_model', UserViewSet)
>router.register(r'users', UserDetailViewSet)
>router.register(r'forms', FormViewSet)
>router.register(r'forms-data', 

Re: django models

2018-08-10 Thread Ramandeep Kaur
thanks i got my  mistake but now again i am getting an error.
my urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.views.generic import TemplateView

from rest_framework_nested import routers

from rest_auth.views import LogoutView

from locations.views import LocationViewSet

from tasks.views import TaskViewSet, BeneficiaryTasksView,
AssignedTasksView, CreatedTasksView, tasks_assign, tasks_smart_assign,
FilterTasksView, PaginatedTaskViewSet, get_tasks_length,
get_tasks_page_size, export_tasks_view, create_bulk_tasks,
import_data_view, get_filtered_tasks_length, PledgedTasksView,create_task
from task_types.views import TaskTypeViewSet
from task_status.views import TaskStatusViewSet
from feedback_types.views import FeedbackTypeViewSet
from organisations.views import OrganisationViewSet
from authentication.views import UserViewSet
from user_profiles.views import *
from forms.views import FormViewSet, FormDataViewSet, DataByFormView,
PersistentFormViewSet, PersistentFormDataView,export_filtered_form_data
from training_kits.views import *
from stages.views import StageViewSet
from notes.views import NoteViewSet, BeneficiaryNotesView, CreatedNotesView
from user_messages.views import MessageViewSet, BeneficiaryMessagesView,
SentMessagesView
from todos.views import TodoViewSet, AssignedTodosView, CreatedTodosView,
BeneficiaryTodosView
from tags.views import (TagViewSet, LightTagViewSet, UserTagsView,
UserLightTagsView,
RemoveUserFromTag, RemoveExclusiveTagFromTag,
AddTagToUser, AddTagsToUser, AddExclusiveTagToTag)
from message_templates.views import MessageTemplateViewSet
#from calls.views import CallViewSet, BeneficiaryCallsView, CallerCallsView
from task_status_categories.views import TaskStatusCategoryViewSet,
CreatedTaskStatusCategoriesView, getTaskCompletedFlagChoices
#from actions.views import get_action_classes, ActionViewSet
from events.views import EventViewSet
from event_conditions.views import EventConditionViewSet,
getEventConditionTypes, HelplineEventConditionsView,
NormalEventConditionsView
from hooks.views import HookViewSet
from ivrs.views import IVRViewSet, BeneficiaryIVRsView, SentIVRsView,
FeedbackIVRView
from ivr_templates.views import IVRTemplateViewSet
from exotel.views import MissedCall, ExotelViewSet, IncSMS, Lottery,
DostPaid, DostMother, DostFather
from guilds.views import GuildViewSet, add_users_to_guild
from notices.views import NoticeViewSet
from spaces.views import SpaceViewSet
from space_types.views import SpaceTypeViewSet, add_spaces
from interests.views import InterestViewSet, LightInterestViewSet,
AddInterestsToUser, RemoveInterestsFromUser, UserInterestsView
from pledges.views import PledgeViewSet, TaskPledgesView, UserPledgesView
from party_invitations.views import PartyInvitationViewSet,
SentPartyInvitationsView, ReceivedPartyInvitationsView
from task_comments.views import TaskCommentViewSet,
TaskCommentDetailedViewSet, TaskCommentsView, CommentedCommentsView
from follows.views import FollowViewSet, FollowerFollowsView,
FollowedFollowsView, get_follow
#from centers.views import CenterViewSet
from locations.views import LocationViewSet
from kits.views import KitViewSet
from parents.views import ParentViewSet,ParentWorkerListViewSet
from worker.views import WorkerViewSet
from child.views import ChildViewSet
from payments.views import
PaymentViewSet,PaymentWorkerListViewSet,PaymentDateListViewSet
#from assessments.views import AssessmentViewSet
from questions.views import QuestionViewSet
#from assessmentreports.views import AssessmentItemViewSet

router = routers.SimpleRouter()

#router.register(r'centers',CenterViewSet)
router.register(r'kits',KitViewSet)
router.register(r'parents',ParentViewSet)
router.register(r'workers',WorkerViewSet)
router.register(r'child',ChildViewSet)
#router.register(r'assessments',AssessmentViewSet)
router.register(r'questions',QuestionViewSet)
#router.register(r'assessmentitems',AssessmentItemViewSet)
router.register(r'payments',PaymentViewSet)
router.register(r'locations', LocationViewSet)
router.register(r'tasks', TaskViewSet)
router.register(r'task_types', TaskTypeViewSet)
router.register(r'task_status', TaskStatusViewSet)
router.register(r'feedback_types', FeedbackTypeViewSet)
router.register(r'stages', StageViewSet)
router.register(r'organisations', OrganisationViewSet)
router.register(r'users_model', UserViewSet)
router.register(r'users', UserDetailViewSet)
router.register(r'forms', FormViewSet)
router.register(r'forms-data', FormDataViewSet)
router.register(r'trainingkits', TrainingKitViewSet)
router.register(r'trainingkitpages', TrainingKitPagesViewSet)
router.register(r'pages', PageViewSet)
router.register(r'notes', NoteViewSet)
router.register(r'messages', MessageViewSet)
router.register(r'todos', TodoViewSet)
router.register(r'tags', TagViewSet)
router.register(r'light_tags', LightTagViewSet)
router.register(r'message_templates', MessageTemplateViewSet)
#router.register(r'calls', 

Re: django models

2018-08-10 Thread Kasper Laudrup

Hi Ramandeep,
On 08/10/2018 07:36 AM, Ramandeep Kaur wrote:

> strange thing is that it indicates the error in line 395 which is in
> the end where i dont write any code.

It looks like your error is not closing the call to url() here:


url('^api/v1/calls/beneficiary/(?P\w+)/$',
# BeneficiaryCallsView.as_view(),
# name='beneficiary_calls'),
url('^api/v1/calls/caller/(?P\w+)/$',
# CallerCallsView.as_view(),
# name='caller_calls'),


The interpreter will try to look for the matching end ')' and give error 
out when it doesn't find that at the end of the file.


Errors like these can indeed be a bit hard to track down. Which editor 
are you using?


If you use an editor that understands Python, it can be quite a lot 
easier to debug these things in my experience or even avoid them in the 
first place.


I heard good things about pycharm, but I don't have any experience with 
that myself (I use emacs).


Don't know if that would have helped you here. Just a suggestion.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/556bdf45-8daf-4b4d-4657-de696b8e5d2f%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-09 Thread Mike Dewhirst
 db_tablespace or
settings.DEFAULT_INDEX_TABLESPACE
  File
"C:\Python27\lib\site-packages\django\conf\__init__.py",
line 55, in __getattr__
    self._setup(name)
  File
"C:\Python27\lib\site-packages\django\conf\__init__.py",
line 43, in _setup
    self._wrapped = Settings(settings_module)
  File
"C:\Python27\lib\site-packages\django\conf\__init__.py",
line 120, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting
must not be empty.")
django.core.exceptions.ImproperlyConfigured: The
SECRET_KEY setting must not be empty.

On Thu, Aug 9, 2018 at 11:13 AM, Mike Dewhirst
mailto:mi...@dewhirst.com.au>
<mailto:mi...@dewhirst.com.au
<mailto:mi...@dewhirst.com.au>>> wrote:

    On 9/08/2018 3:11 PM, Ramandeep Kaur wrote:

    i set the secret key but its again giving me the
same errror.
    django.core.exceptions.ImproperlyConfigured: The
SECRET_KEY
    setting must not be empty.


    Try running the migrations command with the settings
option so
    manage.py can find them.

    python manage.py makemigrations
--settings=



    On Wed, Aug 8, 2018 at 7:24 PM, Matthew Pava
    mailto:matthew.p...@iss.com>
<mailto:matthew.p...@iss.com
<mailto:matthew.p...@iss.com>>> wrote:

        Well, you could generate a SECRET KEY here:

https://www.miniwebtool.com/django-secret-key-generator/
<https://www.miniwebtool.com/django-secret-key-generator/>
       
<https://www.miniwebtool.com/django-secret-key-generator/
<https://www.miniwebtool.com/django-secret-key-generator/>>

        Then in your settings.py file you need to add
this line:

        SECRET_KEY = “[insert secret key here]”

https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
<https://docs.djangoproject.com/en/dev/ref/settings/#secret-key>
       
<https://docs.djangoproject.com/en/dev/ref/settings/#secret-key

<https://docs.djangoproject.com/en/dev/ref/settings/#secret-key>>

        *From:*django-users@googlegroups.com
<mailto:django-users@googlegroups.com>
        <mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>>
        [mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>
            <mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>>] *On Behalf Of
        *Ramandeep Kaur
        *Sent:* Wednesday, August 8, 2018 8:50 AM
        *To:* django-users@googlegroups.com
<mailto:django-users@googlegroups.com>
        <mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>>
        *Subject:* Re: django models

        I am new at Django so I don't know how to
create secret key.
        please explain me.

        On Wed, Aug 8, 2018, 1:20 PM Gerald Brown
      mailto:gsbrow...@gmail.com>
<mailto:gsbrow...@gmail.com
<mailto:gsbrow...@gmail.com>>> wrote:

            The last line of the error message tells
you what to do.
            Create a Secret Key in your settings.py
file because it
            says it is now empty.

            On Wednesday, 08 August, 2018 02:43 PM,
Ramandeep Kaur wrote:

                when i run this ./manage.py
makemigrations it gives
                some error. Don't know what to do.

                Traceback (most recent call last):

                  File "manage.py", line 10, in 

execute_from_command_line(sys.argv)

                  File

"C:\Python27\lib\site-packages\django\core\management\__init__.py",
                line 353, in execute_from_command_line

                    utility.execute()

                  File
   

Re: django models

2018-08-09 Thread Mike Dewhirst
    Try running the migrations command with the settings option so
    manage.py can find them.

    python manage.py makemigrations --settings=



    On Wed, Aug 8, 2018 at 7:24 PM, Matthew Pava
    mailto:matthew.p...@iss.com>
<mailto:matthew.p...@iss.com
<mailto:matthew.p...@iss.com>>> wrote:

        Well, you could generate a SECRET KEY here:

https://www.miniwebtool.com/django-secret-key-generator/
<https://www.miniwebtool.com/django-secret-key-generator/>
       
<https://www.miniwebtool.com/django-secret-key-generator/
<https://www.miniwebtool.com/django-secret-key-generator/>>

        Then in your settings.py file you need to add this
line:

        SECRET_KEY = “[insert secret key here]”

https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
<https://docs.djangoproject.com/en/dev/ref/settings/#secret-key>
       
<https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
<https://docs.djangoproject.com/en/dev/ref/settings/#secret-key>>

        *From:*django-users@googlegroups.com
<mailto:django-users@googlegroups.com>
        <mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>>
        [mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>
        <mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>>] *On Behalf Of
        *Ramandeep Kaur
        *Sent:* Wednesday, August 8, 2018 8:50 AM
        *To:* django-users@googlegroups.com
<mailto:django-users@googlegroups.com>
        <mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>>
        *Subject:* Re: django models

        I am new at Django so I don't know how to create
secret key.
        please explain me.

        On Wed, Aug 8, 2018, 1:20 PM Gerald Brown
        mailto:gsbrow...@gmail.com>
<mailto:gsbrow...@gmail.com <mailto:gsbrow...@gmail.com>>>
wrote:

            The last line of the error message tells you
what to do.
            Create a Secret Key in your settings.py file
because it
            says it is now empty.

            On Wednesday, 08 August, 2018 02:43 PM,
Ramandeep Kaur wrote:

                when i run this ./manage.py
makemigrations it gives
                some error. Don't know what to do.

                Traceback (most recent call last):

                  File "manage.py", line 10, in 

                    execute_from_command_line(sys.argv)

                  File
               
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
                line 353, in execute_from_command_line

                    utility.execute()

                  File
               
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
                line 345, in execute


               
self.fetch_command(subcommand).run_from_argv(self.argv)

                  File
               
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
                line 195, in fetch_command

                    klass = load_command_class(app_name,
subcommand)

                  File
               
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
                line 39, in load_command_class

                    module =
                import_module('%s.management.commands.%s' %
                (app_name, name))

                  File
"C:\Python27\lib\importlib\__init__.py", line
                37, in import_module

                    __import__(name)

                  File
               

"C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
                line 8, in 

                    from django.db.migrations.autodetector
import
                Migrati

Re: django models

2018-08-09 Thread Kasper Laudrup

Hi Ramandeep,

On 08/09/2018 09:57 AM, Ramandeep Kaur wrote:


hi kasper,this is my settings.py



What you have added to your settings.py doesn't make any sense. It is 
not valid Python code as your Python interpreter correctly tells you. I 
have no idea what you tried to achieve by writing that.


Read up on Python and modules here:

https://docs.python.org/3/tutorial/modules.html

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4a0710dc-e191-f4f2-659e-9038b9b0f49f%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-09 Thread Ramandeep Kaur
 import os
import sys

from django.core.exceptions import ImproperlyConfigured
from .base import *pip install django-generate-secret-key

def get_env_variable(var_name):
try:
return os.environ[var_name]
except KeyError:
error_msg = "Set the %s environment variable" % var_name
raise ImproperlyConfigured(error_msg)

BASE_DIR = os.path.dirname(os.path.dirname
(os.path.dirname(os.path.abspath(__file__

sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{{ secret_key }}'



# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['52.220.91.39']

# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'user_profiles.middleware.CustomCsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'vms2.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "static/templates"),
os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'vms2.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# django-allauth settings

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)

ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "none"
ACCOUNT_EMAIL_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = "username"
ACCOUNT_LOGIN_ATTEMPTS_LIMIT = None
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = "/"
ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL =
"/user_details/edit/"
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True

# rest_auth settings

REST_AUTH_SERIALIZERS = {
'USER_DETAILS_SERIALIZER':
'user_profiles.serializers.UserSerializer'
}

REST_AUTH_REGISTER_SERIALIZERS = {
'REGISTER_SERIALIZER':
'authentication.serializers.UserRegisterSerializer'
}


# Email settings for gmail
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
# EMAIL_HOST_USER = get_env_variable('EMAIL_HOST_USER')
# EMAIL_HOST_PASSWORD = get_env_variable('EMAIL_HOST_PASSWORD')
# DEFAULT_FROM_EMAIL = get_env_variable('DEFAULT_FROM_EMAIL')

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


hi kasper,this is my settings.py


On Thu, Aug 9, 2018 at 1:11 PM, Kasper Laudrup 
wrote:

> Hi Ramandeep,
>
> On 08/09/2018 09:25 AM, Ramandeep Kaur wrote:
>
>> when i run my manage.py server its giving me invalid syntax error.
>>   File "C:\Users\Dell\vms2\vms2\settings\base.py", line 18
>> from .base import *pip install django-generate-secret-key
>>  ^
>> SyntaxError: invalid syntax
>>
>>
> What does your settings.py look like?
>
> Have you really written "from .base import *pip install
> django-generate-secret-key" in there?
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/000fb49c-8c46-9c67-1d2e-54e781795e17%40stacktrace.dk.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 

Re: django models

2018-08-09 Thread Kasper Laudrup

Hi Ramandeep,

On 08/09/2018 09:25 AM, Ramandeep Kaur wrote:

when i run my manage.py server its giving me invalid syntax error.
  File "C:\Users\Dell\vms2\vms2\settings\base.py", line 18
    from .base import *pip install django-generate-secret-key
                         ^
SyntaxError: invalid syntax



What does your settings.py look like?

Have you really written "from .base import *pip install 
django-generate-secret-key" in there?


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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/000fb49c-8c46-9c67-1d2e-54e781795e17%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-09 Thread Ramandeep Kaur
t;> line 39, in load_command_class
>> module = import_module('%s.management.commands.%s' % (app_name,
>> name))
>>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
>> __import__(name)
>>   File 
>> "C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
>> line 8, in 
>> from django.db.migrations.autodetector import MigrationAutodetector
>>   File "C:\Python27\lib\site-packages\django\db\migrations\autodetector.py",
>> line 13, in 
>> from django.db.migrations.questioner import MigrationQuestioner
>>   File "C:\Python27\lib\site-packages\django\db\migrations\questioner.py",
>> line 12, in 
>> from .loader import MigrationLoader
>>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py",
>> line 10, in 
>> from django.db.migrations.recorder import MigrationRecorder
>>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
>> line 12, in 
>> class MigrationRecorder(object):
>>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
>> line 26, in MigrationRecorder
>> class Migration(models.Model):
>>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
>> line 27, in Migration
>> app = models.CharField(max_length=255)
>>   File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
>> line 1072, in __init__
>> super(CharField, self).__init__(*args, **kwargs)
>>   File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
>> line 166, in __init__
>> self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESP
>> ACE
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 55,
>> in __getattr__
>> self._setup(name)
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 43,
>> in _setup
>> self._wrapped = Settings(settings_module)
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line
>> 120, in __init__
>> raise ImproperlyConfigured("The SECRET_KEY setting must not be
>> empty.")
>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must
>> not be empty.
>>
>> On Thu, Aug 9, 2018 at 11:13 AM, Mike Dewhirst > <mailto:mi...@dewhirst.com.au>> wrote:
>>
>> On 9/08/2018 3:11 PM, Ramandeep Kaur wrote:
>>
>>> i set the secret key but its again giving me the same errror.
>>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY
>>>     setting must not be empty.
>>>
>>
>> Try running the migrations command with the settings option so
>> manage.py can find them.
>>
>> python manage.py makemigrations --settings=
>>
>>
>>
>>> On Wed, Aug 8, 2018 at 7:24 PM, Matthew Pava
>>> mailto:matthew.p...@iss.com>> wrote:
>>>
>>> Well, you could generate a SECRET KEY here:
>>>
>>> https://www.miniwebtool.com/django-secret-key-generator/
>>> <https://www.miniwebtool.com/django-secret-key-generator/>
>>>
>>> Then in your settings.py file you need to add this line:
>>>
>>> SECRET_KEY = “[insert secret key here]”
>>>
>>> https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
>>> <https://docs.djangoproject.com/en/dev/ref/settings/#secret-key>
>>>
>>> *From:*django-users@googlegroups.com
>>> <mailto:django-users@googlegroups.com>
>>> [mailto:django-users@googlegroups.com
>>> <mailto:django-users@googlegroups.com>] *On Behalf Of
>>> *Ramandeep Kaur
>>> *Sent:* Wednesday, August 8, 2018 8:50 AM
>>> *To:* django-users@googlegroups.com
>>> <mailto:django-users@googlegroups.com>
>>> *Subject:* Re: django models
>>>
>>> I am new at Django so I don't know how to create secret key.
>>> please explain me.
>>>
>>> On Wed, Aug 8, 2018, 1:20 PM Gerald Brown
>>> mailto:gsbrow...@gmail.com>> wrote:
>>>
>>> The last line of the error message tells you what to do.
>>> Create a Secret Key in your settings.py file because it
>>> says it is now empty.
>>>
>>>

Re: django models

2018-08-09 Thread Mike Dewhirst
igrationRecorder(object):
  File 
"C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 
26, in MigrationRecorder

    class Migration(models.Model):
  File 
"C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 
27, in Migration

    app = models.CharField(max_length=255)
  File 
"C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", 
line 1072, in __init__

    super(CharField, self).__init__(*args, **kwargs)
  File 
"C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", 
line 166, in __init__
    self.db_tablespace = db_tablespace or 
settings.DEFAULT_INDEX_TABLESPACE
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 
55, in __getattr__

    self._setup(name)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 
43, in _setup

    self._wrapped = Settings(settings_module)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 
120, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be 
empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting 
must not be empty.


On Thu, Aug 9, 2018 at 11:13 AM, Mike Dewhirst <mailto:mi...@dewhirst.com.au>> wrote:


On 9/08/2018 3:11 PM, Ramandeep Kaur wrote:

i set the secret key but its again giving me the same errror.
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY
setting must not be empty.


Try running the migrations command with the settings option so
manage.py can find them.

python manage.py makemigrations --settings=




On Wed, Aug 8, 2018 at 7:24 PM, Matthew Pava
mailto:matthew.p...@iss.com>> wrote:

Well, you could generate a SECRET KEY here:

https://www.miniwebtool.com/django-secret-key-generator/
<https://www.miniwebtool.com/django-secret-key-generator/>

Then in your settings.py file you need to add this line:

SECRET_KEY = “[insert secret key here]”

https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
<https://docs.djangoproject.com/en/dev/ref/settings/#secret-key>

*From:*django-users@googlegroups.com
<mailto:django-users@googlegroups.com>
[mailto:django-users@googlegroups.com
<mailto:django-users@googlegroups.com>] *On Behalf Of
*Ramandeep Kaur
*Sent:* Wednesday, August 8, 2018 8:50 AM
*To:* django-users@googlegroups.com
<mailto:django-users@googlegroups.com>
*Subject:* Re: django models

I am new at Django so I don't know how to create secret key.
please explain me.

On Wed, Aug 8, 2018, 1:20 PM Gerald Brown
mailto:gsbrow...@gmail.com>> wrote:

The last line of the error message tells you what to do.
Create a Secret Key in your settings.py file because it
says it is now empty.

On Wednesday, 08 August, 2018 02:43 PM, Ramandeep Kaur wrote:

when i run this ./manage.py makemigrations it gives
some error. Don't know what to do.

Traceback (most recent call last):

  File "manage.py", line 10, in 

    execute_from_command_line(sys.argv)

  File

"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 353, in execute_from_command_line

    utility.execute()

  File

"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 345, in execute

   
self.fetch_command(subcommand).run_from_argv(self.argv)

  File

"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 195, in fetch_command

    klass = load_command_class(app_name, subcommand)

  File

"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 39, in load_command_class

    module =
import_module('%s.management.commands.%s' %
(app_name, name))

  File "C:\Python27\lib\importlib\__init__.py", line
37, in import_module

    __import__(name)

  File

"C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
line 8, in 

    from django.db.migrations.autodetector import
MigrationAutodetector

  File

"C:\Python27\lib\site-packages\django\db\migrations\autodetector.py",
line 13, in 

    from django.db.migrations.questioner import
 

Re: django models

2018-08-08 Thread Ramandeep Kaur
i set the secret key but its again giving me the same errror.
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must
not be empty.

On Wed, Aug 8, 2018 at 7:24 PM, Matthew Pava  wrote:

> Well, you could generate a SECRET KEY here:
>
> https://www.miniwebtool.com/django-secret-key-generator/
>
>
>
> Then in your settings.py file you need to add this line:
>
> SECRET_KEY = “[insert secret key here]”
>
>
>
> https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
>
>
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *Ramandeep Kaur
> *Sent:* Wednesday, August 8, 2018 8:50 AM
> *To:* django-users@googlegroups.com
> *Subject:* Re: django models
>
>
>
> I am new at Django so I don't know how to create secret key. please
> explain me.
>
>
>
> On Wed, Aug 8, 2018, 1:20 PM Gerald Brown  wrote:
>
> The last line of the error message tells you what to do.  Create a Secret
> Key in your settings.py file because it says it is now empty.
>
>
>
> On Wednesday, 08 August, 2018 02:43 PM, Ramandeep Kaur wrote:
>
> when i run this ./manage.py makemigrations it gives some error. Don't
> know what to do.
>
>
>
> Traceback (most recent call last):
>
>   File "manage.py", line 10, in 
>
> execute_from_command_line(sys.argv)
>
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 353, in execute_from_command_line
>
> utility.execute()
>
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 345, in execute
>
> self.fetch_command(subcommand).run_from_argv(self.argv)
>
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 195, in fetch_command
>
> klass = load_command_class(app_name, subcommand)
>
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 39, in load_command_class
>
> module = import_module('%s.management.commands.%s' % (app_name, name))
>
>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
>
> __import__(name)
>
>   File 
> "C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
> line 8, in 
>
> from django.db.migrations.autodetector import MigrationAutodetector
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\autodetector.py",
> line 13, in 
>
> from django.db.migrations.questioner import MigrationQuestioner
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\questioner.py",
> line 12, in 
>
> from .loader import MigrationLoader
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py",
> line 10, in 
>
> from django.db.migrations.recorder import MigrationRecorder
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
> line 12, in 
>
> class MigrationRecorder(object):
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
> line 26, in MigrationRecorder
>
> class Migration(models.Model):
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
> line 27, in Migration
>
> app = models.CharField(max_length=255)
>
>   File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
> line 1072, in __init__
>
> super(CharField, self).__init__(*args, **kwargs)
>
>   File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
> line 166, in __init__
>
> self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_
> TABLESPACE
>
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 55,
> in __getattr__
>
> self._setup(name)
>
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 43,
> in _setup
>
> self._wrapped = Settings(settings_module)
>
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 120,
> in __init__
>
> raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
>
> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must
> not be empty.
>
>
>
> On Wed, Aug 8, 2018 at 6:22 AM, Gerald Brown  wrote:
>
> Just delete the code in models.py and run ./manage.py makemigrations and
> ./manage.py migrate.
>
>
>
> On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote:
>
> My question is that how to delete models in django?
>
> --
> You received this me

RE: django models

2018-08-08 Thread Matthew Pava
Well, you could generate a SECRET KEY here:
https://www.miniwebtool.com/django-secret-key-generator/

Then in your settings.py file you need to add this line:
SECRET_KEY = “[insert secret key here]”

https://docs.djangoproject.com/en/dev/ref/settings/#secret-key


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Ramandeep Kaur
Sent: Wednesday, August 8, 2018 8:50 AM
To: django-users@googlegroups.com
Subject: Re: django models

I am new at Django so I don't know how to create secret key. please explain me.

On Wed, Aug 8, 2018, 1:20 PM Gerald Brown 
mailto:gsbrow...@gmail.com>> wrote:

The last line of the error message tells you what to do.  Create a Secret Key 
in your settings.py file because it says it is now empty.

On Wednesday, 08 August, 2018 02:43 PM, Ramandeep Kaur wrote:
when i run this ./manage.py makemigrations it gives some error. Don't know what 
to do.

Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 
353, in execute_from_command_line
utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 
345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 
195, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 
39, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
 line 8, in 
from django.db.migrations.autodetector import MigrationAutodetector
  File "C:\Python27\lib\site-packages\django\db\migrations\autodetector.py", 
line 13, in 
from django.db.migrations.questioner import MigrationQuestioner
  File "C:\Python27\lib\site-packages\django\db\migrations\questioner.py", line 
12, in 
from .loader import MigrationLoader
  File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 10, 
in 
from django.db.migrations.recorder import MigrationRecorder
  File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 
12, in 
class MigrationRecorder(object):
  File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 
26, in MigrationRecorder
class Migration(models.Model):
  File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 
27, in Migration
app = models.CharField(max_length=255)
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", 
line 1072, in __init__
super(CharField, self).__init__(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", 
line 166, in __init__
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 55, in 
__getattr__
self._setup(name)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 43, in 
_setup
self._wrapped = Settings(settings_module)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 120, in 
__init__
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be 
empty.

On Wed, Aug 8, 2018 at 6:22 AM, Gerald Brown 
mailto:gsbrow...@gmail.com>> wrote:

Just delete the code in models.py and run ./manage.py makemigrations and 
./manage.py migrate.

On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote:
My question is that how to delete models in 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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com<https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
&qu

Re: django models

2018-08-08 Thread Ramandeep Kaur
I am new at Django so I don't know how to create secret key. please explain
me.

On Wed, Aug 8, 2018, 1:20 PM Gerald Brown  wrote:

> The last line of the error message tells you what to do.  Create a Secret
> Key in your settings.py file because it says it is now empty.
>
> On Wednesday, 08 August, 2018 02:43 PM, Ramandeep Kaur wrote:
>
> when i run this ./manage.py makemigrations it gives some error. Don't
> know what to do.
>
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 353, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 345, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 195, in fetch_command
> klass = load_command_class(app_name, subcommand)
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 39, in load_command_class
> module = import_module('%s.management.commands.%s' % (app_name, name))
>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
> __import__(name)
>   File
> "C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
> line 8, in 
> from django.db.migrations.autodetector import MigrationAutodetector
>   File
> "C:\Python27\lib\site-packages\django\db\migrations\autodetector.py", line
> 13, in 
> from django.db.migrations.questioner import MigrationQuestioner
>   File "C:\Python27\lib\site-packages\django\db\migrations\questioner.py",
> line 12, in 
> from .loader import MigrationLoader
>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py",
> line 10, in 
> from django.db.migrations.recorder import MigrationRecorder
>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
> line 12, in 
> class MigrationRecorder(object):
>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
> line 26, in MigrationRecorder
> class Migration(models.Model):
>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
> line 27, in Migration
> app = models.CharField(max_length=255)
>   File
> "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line
> 1072, in __init__
> super(CharField, self).__init__(*args, **kwargs)
>   File
> "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", line
> 166, in __init__
> self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 55,
> in __getattr__
> self._setup(name)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 43,
> in _setup
> self._wrapped = Settings(settings_module)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 120,
> in __init__
> raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must
> not be empty.
>
> On Wed, Aug 8, 2018 at 6:22 AM, Gerald Brown  wrote:
>
>> Just delete the code in models.py and run ./manage.py makemigrations and
>> ./manage.py migrate.
>>
>> On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote:
>>
>> My question is that how to delete models in 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/ebb428c7-b1cd-46e2-e139-9fe96a884353%40gmail.com
>> .
>>
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message 

Re: django models

2018-08-08 Thread Balasriharsha Cheeday
You must have removed the secret key in settings.py file, try re-adding 
that secret key, then it should work just fine

On Tuesday, August 7, 2018 at 10:17:00 AM UTC-7, Ramandeep Kaur wrote:
>
> My question is that how to delete models in 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cb8e793b-c45f-487f-93d8-e8fa271302e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-08 Thread Gerald Brown
The last line of the error message tells you what to do.  Create a 
Secret Key in your settings.py file because it says it is now empty.



On Wednesday, 08 August, 2018 02:43 PM, Ramandeep Kaur wrote:
when i run this ./manage.py makemigrations it gives some error. Don't 
know what to do.


Traceback (most recent call last):
  File "manage.py", line 10, in 
    execute_from_command_line(sys.argv)
  File 
"C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 353, in execute_from_command_line

    utility.execute()
  File 
"C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 345, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 195, in fetch_command

    klass = load_command_class(app_name, subcommand)
  File 
"C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 39, in load_command_class

    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py", 
line 8, in 

    from django.db.migrations.autodetector import MigrationAutodetector
  File 
"C:\Python27\lib\site-packages\django\db\migrations\autodetector.py", 
line 13, in 

    from django.db.migrations.questioner import MigrationQuestioner
  File 
"C:\Python27\lib\site-packages\django\db\migrations\questioner.py", 
line 12, in 

    from .loader import MigrationLoader
  File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", 
line 10, in 

    from django.db.migrations.recorder import MigrationRecorder
  File 
"C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 
12, in 

    class MigrationRecorder(object):
  File 
"C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 
26, in MigrationRecorder

    class Migration(models.Model):
  File 
"C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 
27, in Migration

    app = models.CharField(max_length=255)
  File 
"C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", 
line 1072, in __init__

    super(CharField, self).__init__(*args, **kwargs)
  File 
"C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", 
line 166, in __init__
    self.db_tablespace = db_tablespace or 
settings.DEFAULT_INDEX_TABLESPACE
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 
55, in __getattr__

    self._setup(name)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 
43, in _setup

    self._wrapped = Settings(settings_module)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 
120, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be 
empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting 
must not be empty.


On Wed, Aug 8, 2018 at 6:22 AM, Gerald Brown > wrote:


Just delete the code in models.py and run ./manage.py
makemigrations and ./manage.py migrate.


On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote:

My question is that how to delete models in 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 post to this group, send email to
django-users@googlegroups.com .
Visit this group at https://groups.google.com/group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout
.


-- 
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 post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/ebb428c7-b1cd-46e2-e139-9fe96a884353%40gmail.com


Re: django models

2018-08-08 Thread Ramandeep Kaur
when i run this ./manage.py makemigrations it gives some error. Don't know
what to do.

Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 353, in execute_from_command_line
utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 195, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 39, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
  File
"C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
line 8, in 
from django.db.migrations.autodetector import MigrationAutodetector
  File
"C:\Python27\lib\site-packages\django\db\migrations\autodetector.py", line
13, in 
from django.db.migrations.questioner import MigrationQuestioner
  File "C:\Python27\lib\site-packages\django\db\migrations\questioner.py",
line 12, in 
from .loader import MigrationLoader
  File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line
10, in 
from django.db.migrations.recorder import MigrationRecorder
  File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
line 12, in 
class MigrationRecorder(object):
  File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
line 26, in MigrationRecorder
class Migration(models.Model):
  File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
line 27, in Migration
app = models.CharField(max_length=255)
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
line 1072, in __init__
super(CharField, self).__init__(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
line 166, in __init__
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 55, in
__getattr__
self._setup(name)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 43, in
_setup
self._wrapped = Settings(settings_module)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 120,
in __init__
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must
not be empty.

On Wed, Aug 8, 2018 at 6:22 AM, Gerald Brown  wrote:

> Just delete the code in models.py and run ./manage.py makemigrations and
> ./manage.py migrate.
>
> On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote:
>
> My question is that how to delete models in 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ebb428c7-b1cd-46e2-e139-9fe96a884353%40gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL18nxmkKT9JPrvxnzQ3n1hs-KXXEUzBSX0YYqr-PP69K_PPJw%40mail.gmail.com.
For more 

Re: django models

2018-08-07 Thread Gerald Brown
Just delete the code in models.py and run ./manage.py makemigrations and 
./manage.py migrate.



On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote:

My question is that how to delete models in 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 post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ebb428c7-b1cd-46e2-e139-9fe96a884353%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-07 Thread Christophe Pettus


> On Aug 7, 2018, at 10:14, Ramandeep Kaur  wrote:
> 
> My question is that how to delete models in django?

Do you need to delete a model *class*, or a model *instance*?

--
-- Christophe Pettus
   x...@thebuild.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6F27F93D-AD7C-4ACD-99A0-D940DF1BC87E%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.


django models

2018-08-07 Thread Ramandeep Kaur
My question is that how to delete models in 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how set image (dimension) upload height and weight in django models without from

2018-03-20 Thread Andréas Kühne
Hi,

I use a plugin called easy thumbnails for things like this. It doesn't set
what the user can upload, however it scales the uploads to the dimensions
you need.

See here : https://pypi.python.org/pypi/easy-thumbnails

Regards,

Andréas

2018-03-20 13:50 GMT+01:00 arvind yadav :

> class Member(models.Model):
> id = models.AutoField(db_column='ID', primary_key=True)
> name = models.CharField(db_column='NAME', max_length=255)
> member = models.CharField(db_column='MEMBER', max_length=255)
> sequence_num = models.IntegerField(db_column='SEQUENCE_NUM')
> img_url = models.FileField(db_column='IMG_URL',
> storage=S3BotoStorage(bucket=settings.S3_BUCKET_COMMON,
> location=settings.CDN_PREFIX_MEMBER_IMG, calling_format=
> OrdinaryCallingFormat()),
> max_length=200, blank=True, null=True)
>
> class Meta:
> managed = False
> db_table = 'MEMBER'
>
> how set image (dimension) upload height and weight  in img_url FileField
> please 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/0f9dc4fd-5b73-451f-bc49-31801a13537d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCc81xEgSXU8QG-Rbz8-UddQkVEdd0Gd2PcRq31T0cXutQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how set image (dimension) upload height and weight in django models without from

2018-03-20 Thread arvind yadav
class Member(models.Model):
id = models.AutoField(db_column='ID', primary_key=True) 
name = models.CharField(db_column='NAME', max_length=255) 
member = models.CharField(db_column='MEMBER', max_length=255) 
sequence_num = models.IntegerField(db_column='SEQUENCE_NUM') 
img_url = models.FileField(db_column='IMG_URL',

storage=S3BotoStorage(bucket=settings.S3_BUCKET_COMMON,location=settings.CDN_PREFIX_MEMBER_IMG,
 
calling_format=OrdinaryCallingFormat()), 
max_length=200, blank=True, null=True)

class Meta:
managed = False
db_table = 'MEMBER'

how set image (dimension) upload height and weight  in img_url FileField 
please 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0f9dc4fd-5b73-451f-bc49-31801a13537d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can i get more clear understanding on django models?

2018-01-05 Thread Etienne Robillard

you can put docstrings to document what the classes are doing.. :-)

cheers,

Etienne


Le 2018-01-05 à 05:52, utpalbrahma1...@gmail.com a écrit :

from  django.db  import  models


class  Question(models.Model):
 question_text  =  models.CharField(max_length=200)
 pub_date  =  models.DateTimeField('date published')


class  Choice(models.Model):
 question  =  models.ForeignKey(Question,  on_delete=models.CASCADE)
 choice_text  =  models.CharField(max_length=200)
 votes  =  models.IntegerField(default=0)
--
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 post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39e00f5e-41d1-4d17-8116-41db3c6ab072%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/818a5636-3448-217c-88e6-fe68a245a460%40yandex.com.
For more options, visit https://groups.google.com/d/optout.


How can i get more clear understanding on django models?

2018-01-05 Thread utpalbrahma1995


from django.db import models

class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39e00f5e-41d1-4d17-8116-41db3c6ab072%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: having trouble with django models

2017-12-17 Thread Mike Dewhirst

On 17/12/2017 9:26 AM, Daniel Roseman wrote:

This is expected behaviour. You've set them to be populated automatically on 
create and update. So there's no need to be modifiable via the admin.


Of course!

However, if you want to see the fields you have to mention them among 
other fields you wish to display as indicated below and - based on 
Daniel's advice above - you might need to include ...


readonly_fields = ['timestamp', 'updated']

On 17/12/2017 8:18 AM, Mike Dewhirst wrote:

On 16/12/2017 10:06 PM, Mukul Agrawal wrote:
Hello, I am newbie to django. I was trying my hand on models. When i 
used the below code in models.py, "timestamp" and "updated" are not 
able visible on admin site. Is something wrong with the code?


It looks OK to me. Have you included them in your admin.py ...
    fieldsets = (
    ('RestaurantLocation', {
    'fields': (
    'name',
    'location',
    'category',
    'timestamp',
    'updated',
    ),
    }
    ),
    )




'''
from django.db import models

# Create your models here.
class RestaurantLocation(models.Model):
    name             = models.CharField(max_length=120)
    location         = models.CharField(max_length=120, null=True, 
blank=True)
    category         = models.CharField(max_length=120, null=True, 
blank=True)
    timestamp        = 
models.DateTimeField(auto_now=False,auto_now_add=True)
    updated          = models.DateTimeField(auto_now=True, 
auto_now_add=False)

'''
--
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 post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a80a81c1-fade-42a0-b8f5-20638541a5bf%40googlegroups.com 
. 


For more options, visit https://groups.google.com/d/optout.




--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7589b965-420d-9df8-cf91-dab04a40c2ff%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


having trouble with django models

2017-12-16 Thread Daniel Roseman
This is expected behaviour. You've set them to be populated automatically on 
create and update. So there's no need to be modifiable via the admin.

-- 
DR.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7fdfb3b-9277-4c35-a6ae-296cff8a4608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: having trouble with django models

2017-12-16 Thread Mike Dewhirst

On 16/12/2017 10:06 PM, Mukul Agrawal wrote:
Hello, I am newbie to django. I was trying my hand on models. When i 
used the below code in models.py, "timestamp" and "updated" are not 
able visible on admin site. Is something wrong with the code?


It looks OK to me. Have you included them in your admin.py ...
    fieldsets = (
    ('RestaurantLocation', {
    'fields': (
    'name',
    'location',
    'category',
    'timestamp',
    'updated',
    ),
    }
    ),
    )




'''
from django.db import models

# Create your models here.
class RestaurantLocation(models.Model):
    name             = models.CharField(max_length=120)
    location         = models.CharField(max_length=120, null=True, 
blank=True)
    category         = models.CharField(max_length=120, null=True, 
blank=True)
    timestamp        = 
models.DateTimeField(auto_now=False,auto_now_add=True)
    updated          = models.DateTimeField(auto_now=True, 
auto_now_add=False)

'''
--
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 post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a80a81c1-fade-42a0-b8f5-20638541a5bf%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/83a8f5c8-3db4-b684-f612-b48e40a06752%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


having trouble with django models

2017-12-16 Thread Mukul Agrawal
Hello, I am newbie to django. I was trying my hand on models. When i used 
the below code in models.py, "timestamp" and "updated" are not able visible 
on admin site. Is something wrong with the code? 

'''
from django.db import models

# Create your models here.
class RestaurantLocation(models.Model):
name = models.CharField(max_length=120)
location = models.CharField(max_length=120, null=True, 
blank=True)
category = models.CharField(max_length=120, null=True, 
blank=True)
timestamp= 
models.DateTimeField(auto_now=False,auto_now_add=True)
updated  = models.DateTimeField(auto_now=True, 
auto_now_add=False)

'''

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a80a81c1-fade-42a0-b8f5-20638541a5bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with Django Models

2017-12-13 Thread Mike Dewhirst

On 14/12/2017 11:14 AM, Udit Vashisht wrote:
Thanks for the reply. I am new to python and django. Will have to 
google a lot to understand your solution :-)


Look at models.ForeignKey ...

https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey

When you add a foreign key field to a table, the Django Admin form 
offers a choice of all the values from the table you specify.


If you are writing your own forms this might help ...

https://stackoverflow.com/questions/5104277/field-choices-as-queryset

A custom command just needs to follow a specific pattern and contain 
functions with specific names so the command can be executed like python 
manage.py fetch_web_values


https://docs.djangoproject.com/en/2.0/howto/custom-management-commands/

Cheers

Mike




On Dec 13, 2017 19:12, "Mike Dewhirst" > wrote:


On 14/12/2017 3:15 AM, Udit Vashisht wrote:

I have an outside python function which reads a csv from web
and fetch certain data in forms of tuple. So that i can use
that tuple in my python models for choices in one of the
fields. Till now i am running the function independently and
copying the returned tuple to my models.py for choices. But
there must be some better way. like pickling it etc etc. Can
anyone help me with that?


I suggest you import the csv data into a table using a manage.py
custom command. Then you need to point your field requiring
choices at that table.

You could perhaps then run your manage.py command on a cron schedule?


-- 
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 post to this group, send email to
django-users@googlegroups.com

>.
Visit this group at
https://groups.google.com/group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/723351d1-aaae-4784-8c78-ae114e5a64c2%40googlegroups.com



>.
For more options, visit https://groups.google.com/d/optout
.




--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23dd4164-e27f-c49d-ea38-d061babb35c7%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Help with Django Models

2017-12-13 Thread Mike Dewhirst

On 14/12/2017 3:15 AM, Udit Vashisht wrote:
I have an outside python function which reads a csv from web and fetch 
certain data in forms of tuple. So that i can use that tuple in my 
python models for choices in one of the fields. Till now i am running 
the function independently and copying the returned tuple to my 
models.py for choices. But there must be some better way. like 
pickling it etc etc. Can anyone help me with that?


I suggest you import the csv data into a table using a manage.py custom 
command. Then you need to point your field requiring choices at that table.


You could perhaps then run your manage.py command on a cron schedule?



--
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 post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/723351d1-aaae-4784-8c78-ae114e5a64c2%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1f6bc2f-3dc9-dc19-6a99-28aab11b5a06%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Help with Django Models

2017-12-13 Thread Udit Vashisht
I have an outside python function which reads a csv from web and fetch 
certain data in forms of tuple. So that i can use that tuple in my python 
models for choices in one of the fields. Till now i am running the function 
independently and copying the returned tuple to my models.py for choices. 
But there must be some better way. like pickling it etc etc. Can anyone 
help me with that? 

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/723351d1-aaae-4784-8c78-ae114e5a64c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django forms and django models

2017-11-30 Thread Andrea Cristiana Adamczyk Abascal
I have an attribute of a model called "options" that is an array of prayers 
that are entered through textinputs. How can I declare this attribute in 
the model and what widget may I use in the model form? 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/10861b26-4ec2-49c3-967b-5819959fa732%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Models Relationship

2017-09-12 Thread james lin
Hi,

I have the following models:

class UserPost(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, 
on_delete=models.CASCADE)
post = models.ForeignKey(Post, on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)

class User(AbstractUser):
MALE = 'M'
FEMALE = 'F'
GENDER_CHOICES = (
(MALE, 'Male'),
(FEMALE, 'Female')
)
posts = models.ManyToManyField(Post, through='UserPost')
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)

class Post(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, 
on_delete=models.CASCADE)
title = models.CharField(max_length=100)
content = models.TextField()
status = models.CharField(max_length=100)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)

When I run python manage.py makemigrations, it raises the following error:

users.User.posts: (fields.E303) Reverse query name for 'User.posts' clashes 
with field name 'Post.user'.
HINT: Rename field 'Post.user', or add/change a related_name 
argument to the definition for field 'User.posts'.

There is a many-to-many relationship between User and Post models. Each 
user can like many posts and each post can be liked by many users.
There is also a many-to-one relationship between User and Post models. Each 
user can write many posts and each post can be written by only one user.

Shouldn't reverse query name for 'User.posts' be user_set by default. If 
so, why is this name clashing with field name 'Post.user'? Can someone 
explain the meaning of this error? 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/975613b8-b404-4284-83ab-b9a9af29c5e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Ask for help]How to convert django models schema to json?

2016-11-01 Thread GMail
Hi!

There's also an alternative to Django REST Framework - Tastypie 
(https://django-tastypie.readthedocs.io/en/latest/ 
<https://django-tastypie.readthedocs.io/en/latest/>). You could use 
[Namespaced]ModelResource with Django Models.

And if you're not interested in API and only want to use JSON internally, you 
could write your own serialization method in some abstract model class - Django 
allows you to iterate over model fields 
(https://docs.djangoproject.com/en/1.10/ref/models/meta/#django.db.models.options.Options.get_fields
 
<https://docs.djangoproject.com/en/1.10/ref/models/meta/#django.db.models.options.Options.get_fields>).

> On 2 Nov 2016, at 07:19, Asif Saifuddin <auv...@gmail.com> wrote:
> 
> But seems like you are using sqlalchemy models. for sqlalchemy models you 
> could try sqlalchemy-marshmellow
> 
> On Wednesday, November 2, 2016 at 2:27:47 AM UTC+6, 周华 wrote:
> This is an example models
> class UserModel(db.Model):
> __tablename__ = "user"
> id = db.Column(db.Integer, primary_key=True)
> user_id = db.Column(db.String(255), unique=True)
> name = db.Column(db.String(255))
> 
> 
> 
> This is a Json example which I want get.
> {
>   "user":
>   {
> "id":{
>   "type": "Integer",
>   "primary_key": True,
>   "null": True,
>   "default value": "",
>   "foreign key": ""},
>   
>   "user_id":{
>   "type": "Integer",
>   "primary_key": True,
>   "null": True,
>   "default value": "",
>   "foreign key": ""},
>   
>   "name":{
>   "type": "Integer",
>   "primary_key": True,
>   "null": True,
>   "default value": "",
>   "foreign key": ""},
>   }
> }
> 
> Wait your response online
> 
> 
> 
> -- 
> 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 
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com 
> <mailto:django-users@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users 
> <https://groups.google.com/group/django-users>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/bd6f5f3b-2e8c-4eac-80f3-1f787ab969ef%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/bd6f5f3b-2e8c-4eac-80f3-1f787ab969ef%40googlegroups.com?utm_medium=email_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/906193B1-BA55-4670-ADDE-8770B68C23F8%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Ask for help]How to convert django models schema to json?

2016-11-01 Thread Asif Saifuddin
But seems like you are using sqlalchemy models. for sqlalchemy models you 
could try sqlalchemy-marshmellow

On Wednesday, November 2, 2016 at 2:27:47 AM UTC+6, 周华 wrote:
>
>
>- This is an example models
>- class UserModel(db.Model):
>__tablename__ = "user"
>id = db.Column(db.Integer, primary_key=True)
>user_id = db.Column(db.String(255), unique=True)
>name = db.Column(db.String(255))
>
>
>
>- This is a Json example which I want get.
>- {
>  "user":
>  {
>"id":{
>"type": "Integer",
>"primary_key": True,
>"null": True,
>"default value": "",
>"foreign key": ""},
>"user_id":{
>"type": "Integer",
>"primary_key": True,
>"null": True,
>"default value": "",
>"foreign key": ""},
>"name":{
>"type": "Integer",
>"primary_key": True,
>"null": True,
>"default value": "",
>"foreign key": ""},
>  }
>}
>- 
>Wait your response online
>
>
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd6f5f3b-2e8c-4eac-80f3-1f787ab969ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Ask for help]How to convert django models schema to json?

2016-11-01 Thread Asif Saifuddin
Hi,

you can try django-rest-frameworks model serializer, modelviewsets and 
django-json-api package for this job.

thanks

On Wednesday, November 2, 2016 at 2:27:47 AM UTC+6, 周华 wrote:
>
>
>- This is an example models
>- class UserModel(db.Model):
>__tablename__ = "user"
>id = db.Column(db.Integer, primary_key=True)
>user_id = db.Column(db.String(255), unique=True)
>name = db.Column(db.String(255))
>
>
>
>- This is a Json example which I want get.
>- {
>  "user":
>  {
>"id":{
>"type": "Integer",
>"primary_key": True,
>"null": True,
>"default value": "",
>"foreign key": ""},
>"user_id":{
>"type": "Integer",
>"primary_key": True,
>"null": True,
>"default value": "",
>"foreign key": ""},
>"name":{
>"type": "Integer",
>"primary_key": True,
>"null": True,
>"default value": "",
>"foreign key": ""},
>  }
>}
>- 
>Wait your response online
>
>
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/00fc2393-20a7-4196-a8b5-a2c368913f59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Ask for help]How to convert django models schema to json?

2016-11-01 Thread 周华

   
   - This is an example models
   - class UserModel(db.Model):
   __tablename__ = "user"
   id = db.Column(db.Integer, primary_key=True)
   user_id = db.Column(db.String(255), unique=True)
   name = db.Column(db.String(255))
   
   
   
   - This is a Json example which I want get.
   - {
 "user":
 {
   "id":{
   "type": "Integer",
   "primary_key": True,
   "null": True,
   "default value": "",
   "foreign key": ""},
   "user_id":{
   "type": "Integer",
   "primary_key": True,
   "null": True,
   "default value": "",
   "foreign key": ""},
   "name":{
   "type": "Integer",
   "primary_key": True,
   "null": True,
   "default value": "",
   "foreign key": ""},
 }
   }
   - 
   Wait your response online
   
   

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52bb44ce-6dba-42e9-99e8-c9e5050a43f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing session in Django models?

2016-08-03 Thread Constantine Covtushenko
Hi Neto,

As said in Documentation of 'limit_choices_to'

value for this key should be:
`Either a dictionary, a Q object, or a callable returning a dictionary or Q
object can be used.`

For your case these mean that you should use at least callable as 'use__id'
should be defined every Request/Response cycle.

Regards,


On Wed, Aug 3, 2016 at 7:25 PM, Neto  wrote:

> I have a field with *limit_choices_to*, and want it to be only filtered
> items related the account ('ID') user. How can I do this?
>
> Example (Does not work):
>
> class Car(models.Model):
> user = models.ForeignKey(User)
> color = models.CharField(max_length=200)
> typeo = models.ForeignKey(Typeo, limit_choices_to={'user__id': 
> session['user_id']})
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8d2b4b10-83b9-489c-b834-31ddebc0c9df%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boXQ3T1Hb-OodKYLR%3DT66JDW76H_sBuRY0A33etJS-JFnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Accessing session in Django models?

2016-08-03 Thread Neto
I have a field with *limit_choices_to*, and want it to be only filtered 
items related the account ('ID') user. How can I do this?

Example (Does not work):

class Car(models.Model):
user = models.ForeignKey(User)
color = models.CharField(max_length=200)
typeo = models.ForeignKey(Typeo, limit_choices_to={'user__id': 
session['user_id']})

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d2b4b10-83b9-489c-b834-31ddebc0c9df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search multiple fields in Django Models

2016-08-01 Thread Constantine Covtushenko
Hi Jurgens,

Django is the right choice.
With Django all are possible.

All that you described are possible. If you need more precise answer give
us more precise question.

Regards,

On Mon, Aug 1, 2016 at 4:21 PM, Jurgens de Bruin 
wrote:

> Hi,
>
> I am new to Django, I have been using TurboGears for the last few years. I
> would like to help with regards to a multi search function.
>
> In essence I would like 1 search field/form that will search multiple
> fields of different datatype example user should be able to search the
> model/db for either an ID(interger),Name(Text/Char),Date Captured(date
> time). Secondely my models in split in classes each class representing a
> database table I have setup forgein keys within the Model Classes to the
> relation tables. The search should also search all the tables/model.
>
> Is this possible?
>
> Thank 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/65c0df55-dfb1-49eb-a6ed-838e9e7b420a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boWOtRV5YsGz5D1oVH0b-j50zg3TPk5X07CbnAmbdUwtxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Search multiple fields in Django Models

2016-08-01 Thread Jurgens de Bruin
Hi,

I am new to Django, I have been using TurboGears for the last few years. I 
would like to help with regards to a multi search function.

In essence I would like 1 search field/form that will search multiple 
fields of different datatype example user should be able to search the 
model/db for either an ID(interger),Name(Text/Char),Date Captured(date 
time). Secondely my models in split in classes each class representing a 
database table I have setup forgein keys within the Model Classes to the 
relation tables. The search should also search all the tables/model. 

Is this possible?

Thank 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65c0df55-dfb1-49eb-a6ed-838e9e7b420a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Models

2016-05-27 Thread Ken Edem
Wow, Derek what a great link. Thanks very much.

Ken

On Friday, May 27, 2016 at 4:47:56 PM UTC+2, Derek wrote:
>
> There a number of designs for similar situations online; a quick Google 
> showed me:
>
> * http://www.databasedev.co.uk/student_courses_data_model.html
> * http://databaseanswers.org/data_models/ 
>
> And I am sure there are more... 
>
> If this is your first project. I would not be too fussed about making it 
> perfect.  Try out what seems to work and then iterate as you go.  You'll 
> learn a lot and probably end up having to rewrite based on all your 
> learning.
>
> On Friday, 27 May 2016 02:47:34 UTC+2, Ken Edem wrote:
>>
>> I am new to Django Python and I need bit of help
>>
>>
>>
>> Can someone please help me with how I should structure my models, since 
>> this is a very important part of the project I am trying to develop, I had 
>> been teaching myself and not yet good at this stuff. I want to develop a 
>> web project for matching teachers or instructors who will teach students 
>> who subscribes to our service at they residence.For now I think I will need 
>> these models:
>>
>>
>> Students = Database to contain all students details.  See below for the 
>> database fields
>>
>> Instructors = Database to contain all instructors or teachers details. 
>> See below
>>
>> Course = Databases for all the courses or services that will be offering
>>
>> Feedbacks = Database to contains both feedbacks from students about 
>> teachers and also teachers about students.
>>
>>
>> So, I have done something in terms of normalising my database, but I do 
>> not think it is efficient enough.? I think I also need a database Class, 
>> which is combination of Students and Instructors, but I cannot figures what 
>> the fields of this database should be.
>>
>> I also think I need a combine database Instructors & Course and Course & 
>> Students. But I cannot figure out what the fields of these databases also 
>> should be and what the foreign key or whatever should be.
>>
>>
>> You see, our primary service will be matching students with instructors 
>> and having these instructors teach student what they want to be thought.
>>
>>
>> Please can  someone assist me in structuring my models a structure and 
>> also should I just have one app or separate apps for students, instructors, 
>> feedbacks etc. Thanks in advance.
>>
>>
>> Below is my database models.
>>
>>
>> Thanks agains
>>
>>
>>  
>>
>>
>> Models and Tables
>>
>> -   Students
>>
>> -   Instructors
>>
>> -   Course
>>
>> -   Feedbacks
>>
>> -   Class
>>
>>
>> Model Properties and Fields
>>
>> Students
>>
>> -   student-id
>>
>> -   student_firstname
>>
>> -   student_lastname
>>
>> -   student_address
>>
>> -   student_city
>>
>> -   student_region
>>
>> -   student_startdate  (immediately, in 2 weeks, in a month over 6 months)
>>
>> -   student_classLocation (student address, instructor address, arrange 
>> location)
>>
>> -   student_phone1
>>
>> -   student_email
>>
>> -   student_phone2
>>
>> -   student_internetContact  (skype, viber etc)
>>
>> -   student_days_to_take_classes (mon - sun)
>>
>> -   student_duration_of_course  (1 - 12 months)
>>
>> -   student_hours_to_spend_on_course  (1 -8 hours)
>>
>> -   student_class_start_time  ( 06am - 06am)
>>
>> -   student_course_skill_level (beginner, intermediate, advance)
>>
>> -   student_personal_wishes_to_help_match_an_intructor ( )
>>
>> -   student_budget_amount
>>
>> -   student_preferred_instructor_gender  (male, female)
>>
>> -   student_date_of_birth
>>
>>
>> Students Methods and actions
>>
>> -   match a student to instructors
>>
>> -   seek payment
>>
>> -   message update
>>
>>
>>
>>
>> Instuctors
>>
>> -   id
>>
>> -   firstname
>>
>> -   lastname
>>
>> -   middlename
>>
>> -   gender
>>
>> -   date_of_birth
>>
>> -   phone1
>>
>> -   phone2
>>
>> -   streetaddress
>>
>> -   city
>>
>> -   region
>>
>> -   country
>>
>> -   qualifications  (multiple entry)
>>
>> -   certfications  (multiple entry)
>>
>> -   degrees (multiple entry)
>>
>> -   present occupation
>>
>> -   previous occupations (multiple entry)
>>
>> -   present job position
>>
>> -   length of teaching skills
>>
>> -   type of skills to teach
>>
>> -   class location (student address, tutor address, arranged address)
>>
>>
>> Instructor Methods and Actions
>>
>> match instructor to students
>>
>> seek instructors
>>
>> pay instructors
>>
>> -
>>
>>
>>
>> Courses
>>
>> -   id
>>
>> -   course_name
>>
>> -   course_description
>>
>> -   course_duration
>>
>>
>> Methods
>>
>>
>>
>> Feedbacks
>>
>> -   id
>>
>> -   course_name
>>
>> -   instructor
>>
>> -   student
>>
>> -   Feedback_details
>>
>> -   Grade (Beneficial, Great, Average, Satisfied, Very Satisfied, 
>> Excellent)
>>
>>
>>
>>
>> Class
>>
>> -   instructor
>>
>> -   students
>>
>> -   course
>>
>

-- 
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 

  1   2   3   4   5   >