Re: ValueError at /api/list/ invalid literal for int() with base 10: '35/like'

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

See my comments below.

Regards,

Andréas

2018-08-10 5:29 GMT+02:00 mounikesh mintu :

> hey guys when i tried to like  a post in drf i have got in to an error
>
> models.py
>
> class status(models.Model):
> user=models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE, 
> null=False)
> # 
> user=models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
>
> content=models.TextField(blank=True,null=True)
>
> image=models.ImageField(upload_to="upload",null=True,blank=True)
> updated=models.DateTimeField(auto_now=True)
> time=models.DateTimeField(auto_now_add=True)
> 
> likes=models.ManyToManyField(settings.AUTH_USER_MODEL,blank=True,related_name='post_likes')
>
> def __str__(self):
> return self.content
>
> serilaizers
>
> serializers.py
>
> class statusSerializer(serializers.ModelSerializer):
> # user_name = serializers.ReadOnlyField(source='user.username')
> user=UserPublicSerializer(read_only=True)
> # rating=RatingSerializer(required=False)
> # rating=RatingSerializer()
>
> class Meta:
> model=status
> fields=['id','user','content','image','likes']
>
> views.py
>
> @api_view(['POST'])def LikesApi(self,request,id):
> # status = get_object_or_404(id=request.POST.get('id', ''))
> status = get_object_or_404(id=id)
>
> status.likes.add(request.user)
> serializer = statusSerializer(status)
> return Response(serializer.data, status=status.HTTP_201_CREATED)
>
> i have tried both the ways with regards of that question from stack
>
> @api_view(['POST'])def LikesApi(self,request,id):
> serializer=statusSerializer(data=request.DATA)
> if serializer.is_valid():
> 
> serializer.object.content_object=get_object_or_404(status,id=request.POST.get('id',
>  ''))
> serializer.object.likes.add(request.user)
> serializer.save()
> return  RestResponse(serializer.data, status=status.HTTP_201_CREATED)
> return RestResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
>
> here is my urls.py
>
> urlpatterns = [
> # url(r'^$/', StatusListSearchApi.as_view()),
> url(r'^list/', StatusListSearchApi.as_view()),
> url(r'^user/', UserPost.as_view()),
>
> url(r'^like/(?P\d+)/$',LikesApi),
>
> post objects are present in my api/list/ url
>

The url endpoints you have registered are:
/api/list/
/api/user/

and /api/like//

where id is a part of the url.

So to like a post with the id 35 you would enter:
/api/like/35/


> http://127.0.0.1:8000/api/list/like?id=35
>
> when i fired this url i cant see any incremination of likes in my
> browasable api detailview
>
> http://127.0.0.1:8000/api/like?id=35
>
> tried this as well but rather got a page not found 404 error
>
> but when i tried
>
> this url pattern
>
> http://127.0.0.1:8000/api/list/?id=35/like
>
> i have got that value error
>
> please can anyone help me
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/a64dbbfd-ace5-4186-9c2b-801c66bd7804%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/CAK4qSCfPPg-boUPFEfMcoWuJPsY4z_QxnOfCyoEo6VQn2yMonw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: issue with bootstrap

2018-08-10 Thread Tosin Ayoola
oh Thanks for the reply, I load it at each of the templates i intend using
it with but the I still getting same issues, it only shows the content of
the generic page, even after using the loading it.

On Thu, Aug 9, 2018 at 7:10 PM, Kasper Laudrup 
wrote:

> Hi Tosin,
>
> On 09/08/2018 14.52, Tosin Ayoola wrote:
>
>>
>>   Halo guyz working on a Django project that requires me using bootstrap
>>   but the issue I'm having is that I can use the load static to include
>>   bootstrap @ be base_generic.html, but can't use it with the index
>>   page, tried fixing it, what should I do, how to i fix this and move on ?
>>
>>
> You're question is extremely vague, so it's not really clear how you are
> using bootstrap and what your problem is.
>
> I have personally used django-bootstrap4:
>
> https://django-bootstrap4.readthedocs.io/en/latest/
>
> Which works well in my experience.
>
> If you have problems using it in other templates than your base template,
> remember that you need to load it on every template you use, even if it's
> extending another template that has already loaded the template library.
>
> Hope that helps. Otherwise, please provide some more information.
>
> 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/7a80655d-3fd3-8f07-5374-2cc6eb12984a%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 
https://groups.google.com/d/msgid/django-users/CAHLKn71Cbo5EZqsW46FVvGP%2B4CSCWwfzzrE1gkJ%2BhUW%2B8XDwtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


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: issue with bootstrap

2018-08-10 Thread Kasper Laudrup

Hi Tosin,

On 08/10/2018 09:57 AM, Tosin Ayoola wrote:
oh Thanks for the reply, I load it at each of the templates i intend 
using it with but the I still getting same issues, it only shows the 
content of the generic page, even after using the loading it.




It sounds like the browser is not loading the bootstrap CSS files. Try 
to look at the developer console in your browser and see if any errors 
are shown there.


Also, please provide some more details.

Are you using the bootstrap4 Django package I linked to or are you 
loading bootstrap some other way?


Which errors do you see in the browser console (if any)?

Which errors do you see in the output from django runserver (if any)?

Or anything else that might help others help you.

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/681388ae-8290-28be-c84e-ed52ccc97dfc%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: issue with bootstrap

2018-08-10 Thread Tosin Ayoola
thanks, but the browser is actually loading it because, the bootstrap i'm
using at the base.html is been loaded by the same browser

On Fri, Aug 10, 2018 at 9:17 AM, Kasper Laudrup 
wrote:

> Hi Tosin,
>
> On 08/10/2018 09:57 AM, Tosin Ayoola wrote:
>
>> oh Thanks for the reply, I load it at each of the templates i intend
>> using it with but the I still getting same issues, it only shows the
>> content of the generic page, even after using the loading it.
>>
>>
> It sounds like the browser is not loading the bootstrap CSS files. Try to
> look at the developer console in your browser and see if any errors are
> shown there.
>
> Also, please provide some more details.
>
> Are you using the bootstrap4 Django package I linked to or are you loading
> bootstrap some other way?
>
> Which errors do you see in the browser console (if any)?
>
> Which errors do you see in the output from django runserver (if any)?
>
> Or anything else that might help others help you.
>
> 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/681388ae-8290-28be-c84e-ed52ccc97dfc%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 
https://groups.google.com/d/msgid/django-users/CAHLKn70Txs-2ftkGpUmaFO4Mb9NOsJdjWd82fbTv6NfoJzhp%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: issue with bootstrap

2018-08-10 Thread Tosin Ayoola
Maybe it is my error that is leading to that, I have it uploaded on github
this is the link https://github.com/olaneat/ask_the_schools, probably you
can be of help.
thanks

On Fri, Aug 10, 2018 at 9:21 AM, Tosin Ayoola 
wrote:

> thanks, but the browser is actually loading it because, the bootstrap i'm
> using at the base.html is been loaded by the same browser
>
> On Fri, Aug 10, 2018 at 9:17 AM, Kasper Laudrup 
> wrote:
>
>> Hi Tosin,
>>
>> On 08/10/2018 09:57 AM, Tosin Ayoola wrote:
>>
>>> oh Thanks for the reply, I load it at each of the templates i intend
>>> using it with but the I still getting same issues, it only shows the
>>> content of the generic page, even after using the loading it.
>>>
>>>
>> It sounds like the browser is not loading the bootstrap CSS files. Try to
>> look at the developer console in your browser and see if any errors are
>> shown there.
>>
>> Also, please provide some more details.
>>
>> Are you using the bootstrap4 Django package I linked to or are you
>> loading bootstrap some other way?
>>
>> Which errors do you see in the browser console (if any)?
>>
>> Which errors do you see in the output from django runserver (if any)?
>>
>> Or anything else that might help others help you.
>>
>> 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/681388ae-8290-28be-c84e-ed52ccc97dfc%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 
https://groups.google.com/d/msgid/django-users/CAHLKn71MR5CxnAzVFbAtZovtRv-8xeFqKph4RjuydxVotbiCmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: issue with bootstrap

2018-08-10 Thread Kasper Laudrup

Hi Tosin.

On 08/10/2018 10:42 AM, Tosin Ayoola wrote:
Maybe it is my error that is leading to that, I have it uploaded on 
github this is the link https://github.com/olaneat/ask_the_schools, 
probably you can be of help.

thanks



So you are not using the boostrap django package I linked to earlier, 
but instead you have copied the CSS and javascript files to you static 
directory. Information like that is quite useful if you want someone to 
help you.


Quickly looking at your templates, I can see that you are attempting to 
include the bootstrap CSS in the body of your rendered HTML page in the 
index template. That will probably not work. At best, it probably just 
doesn't do anything. That is probably not the cause of your error, but 
it is definitely suspicious.


If I were you, I would look at the HTML django sends to your browser for 
the index page. There should be one link reference to you static files 
bootstrap CSS in the head section.


Debugging this further would require me to checkout your code and 
attempt to run it, which I don't have the time for right now.


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/947fdb24-3f4e-5976-2ba9-87f86bb0b522%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Setting up a system for testing by users (tables are tables?)

2018-08-10 Thread guettli
I see: no reply. Why?

Am Mittwoch, 18. Juli 2018 11:45:00 UTC+2 schrieb guettli:
>
> I have a task which looks simple at the first sight:
>
>  Setting up a system for testing by users. 
>
> In my case it is a custom issue tracking system.
>
> The users who should do the testing say "The new system should be like the 
> production system."
>
> If this would be true, then dump+restore of the database should work.
>
> No Nr2: the production system contains a lot of issues, and these should 
> not be in the new system.
>
> No Nr2: The production system contains configuration (in the database) of 
> remote storage systems. These
> database rows must not get copied, otherwise the testing system would 
> transfer testing data
> to the production storage system.
>
> Configuration like the list of ticket types should get copied.
>
> Tables are tables, or is there a difference between tables?
>
> Up to now I only found one hint to this task: In SAP this is called 
> "client copy" and there seem
> to be different "delivery classes" of a table:
>
>
> https://help.sap.com/doc/saphelp_crm70/7.0.0.18/en-US/43/45860774b711d2959700a0c929b3c3/content.htm?no_cache=true
>
> Are there tools/framework which support copying a system? I am curious, if 
> you know a framework outside django, please tell me.
>
> Up to now I could not find a tool or hint about solving this in a reusable 
> way in django. If I was blind, please let me know.
>
> Any kind of feedback is welcome.
>
> Regards,
>   Thomas Gütler
>

-- 
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/0949314c-189f-4e90-b4f0-802ffe7de7fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django solr with haystack problem

2018-08-10 Thread Jason
if your code indentation is accurate, check get_model and index_queryset 
are actually part of the NoteIndex class

class NoteIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True,use_template=True)
author = indexes.CharField(model_attr='user')
pub_date = indexes.DateTimeField(model_attr='pub_date')


def get_model(self):
return Note

def index_queryset(self, using=None):
"""Used when the entire index for model is update."""
return 
self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())

as you posted suggests that is not the case.

-- 
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/8438fdef-4e64-4731-b2a3-0679b267f6a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Generic Date Views

2018-08-10 Thread Michal Petrucha
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hi Gerald,

Couple of points:
- - please try to stick to the mailing list when posting follow-up
  questions or materials rather than replying off-list; this makes it
  possible for other people to jump in and offer their advice (and
  also doesn't send the message that you expect the one person who
  tried to help you to personally coach you through your issue), and
- - rather than attaching your code in a tarball, posting the relevant
  parts of your code in-line typically makes it easier for people to
  help you – I can just look at the email and directly see the code,
  rather than having to fetch the attachment, unpack it, and go
  through all that hassle. (And don't even get me started on the trend
  of posting screenshots of stack traces or even code; some of us are
  reading our mail in text-mode terminals. Get off my lawn, kids! :P )

With that out of the way, let's get back to your questions.

On Thu, Aug 09, 2018 at 09:15:36PM +0800, Gerald Brown wrote:
> Thanks for your info.
> 
> I am attaching my views.py, url.py and index.html.  The index.html creates a
> menu on the main admin page.  I have included some comments there about the
> strange happenings that are going on.  I am not able to include any trace
> info because I have gone back to my original program from before these
> generic date views.
> 
> The URLS1.py file is from my top level and URL.py is from my visit app. In
> the views.py file most of the code is formatting the reportlab pdf file with
> the data from the queryset assigned to various locations in the pdf.

urls.py::

from django.contrib import admin
from django.urls import include, path

#from visit import views # as visit_views
from visit.views import PaymentTodayArchiveView 

urlpatterns = [
path('today/', PaymentTodayArchiveView.as_view, name="today"),
]

urls1.py::

from django.contrib.admin.sites import AdminSite
from django.contrib import admin
from django.urls import path
from django.conf.urls import include, url
#from django.views.generic.dates import DateDetailView

from patient import views as patient_views
from visit import views as visit_views

admin.site.site_header = 'MEDREC Administration'

class DashboardSite(AdminSite):
def get_urls(self):
urls = super(DashboardSite, self).get_urls()
custom_urls = [
path('^$', self.admin_view(HomeView.as_view()), 
name='admin'),
]
del urls[2]
return custom_urls + urls

urlpatterns = [
path('admin/patient/', patient_views.prescription_view),

path('admin/visit/', visit_views.daily_payment_view),

path('admin/', admin.site.urls),
]

views.py::

@staff_member_required
# ~ class PaymentTodayArchiveView(TodayArchiveView):
# ~ queryset = Visit.objects.all()
# ~ date_field = "visit_date"

So, starting from the beginning – the correct way to reference a
generic class-based view in an URL config is to use
MyViewClass.as_view() – note the parentheses. You can see that in
action in the custom AdminSite that you wrote. The parentheses are
missing in your urls.py.

Second, I don't see urls.py being referenced anywhere in urls1.py,
which you say is the root URL config.

Third, your usage of the ``staff_member_required`` decorator is not
correct – I recommend reading the section of the docs which covers
decorating class-based views [1] to learn how to do that. Not to
mention that you left the decorator in place, while you commented out
the view itself, which means the decorator would get applied to the
next definition following it.

I'm not quite sure how I can help you here, since you don't actually
have any code in place that would use the GCBV...

> It seems like all tutorials I try to follow they are only half complete and
> they leave out a lot of stuff..like how to access these views.  Maybe that
> is something I should know, but don't.
> 
> As it is getting late here I will be taking another look at this tomorrow.

Michal

[1]: 
https://docs.djangoproject.com/en/2.1/topics/class-based-views/intro/#decorating-class-based-views
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQIcBAEBCgAGBQJbbXEsAAoJEHA7T/IPM/kl410QAM6IM+hMFu7+0n41MysAJebW
qk7LE/YaO5lWeBFtbBnzKuQTQ3cIV102Q2e/YBYLOwh0lmlefD01iqR+pOJLdWAu
/Fbr6uqG5Nlem7hFoc0g6QvQLADej4AqsdGlQ80de12gb66PHvHaAkqV726cPodI
13V8qXsfZsj4ix0XsAZmPEmYKW6PoL4TV2J9FFQYLr8ZqlzD3Y+QkEojtnspfVod
ayK7nH3DcABEU1R0SGx+e/7ifwCFXkk3KjIC4ESRGH7pEaozJZu9onb7YP32Yejd
B9sUA1+7A5Cj1IQvlKc8cDayZ3qLRTV7tOG3oUvy/adiRFoBU1MgTodNJccT5Rrx
+WdEgYeGsmd5rrBZAio0S6fhGuCClRMQiknmFjX4YJ2pN4aBCZo7R8RlmkCkODmw
JgKecTujBLC8ax2EDYH887W/qALIsyk5+J1tOZlDblg3+cYMm8LCGQLUCpz5hARb
z35ZXRjb8f7WY6KN8JXDPvL9oNvypOV+AxmJP6NsYAPufA0RtTvkrTrPdXr0a5VK
YCB1E4

Re: Multi Tenancy

2018-08-10 Thread Gagan Kalia
Andrew,

Even if you keep the application servers in another geography, wouldn't it
be a performance hit in terms of accessing the Database hosted in another
geography? My take would be to keep the systems in the same geography to
avoid the performance issues down the line and making the customer
dissatisfied.

Secondly, when companies are asking for on-prem versions, you are not left
with much of the options as they would be reluctant to open their DB server
firewalls to the public cloud where your applications servers would be
hosted.

This is a compliance thing and every country would have their own rules and
regulations anyways wrt to the data security and retention. You are in the
best position to assess what your app does and what kind of data it stores
and processes, so make a good judgement and don't just think about a middle
way to avoid re-architecting some parts of you SaaS design.

Sorry if I couldn't understand the complete problem though...

Regards,
Gagan

On 10 August 2018 at 07:15, Andrew Fam  wrote:

> Hi all, I have a saas solution currently sitting in 1 instance using a
> postgres db.
> Due to recent expansions, I need to keep the data in the country of which
> it came from. e.g Malaysia or Philippines will have a database of their
> own.
> In addition, some companies are asking for on - prem versions and I was
> thinking it might be good for them to own their database while we keep the
> application server.
> Does anyone have an idea of how to solve this issue and what is the most
> elegant way of doing this?
>
> Some background to this.
> I have a tenant model that is storing the country using countryfield.
> Some models directly link to the tenant model, others reference a field
> which is tied to a model with the tenant model.
>
>
> --
> 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/be6fb573-50fa-4f48-be37-712d1a279859%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/CAM-Jvq5Shvrcksi%3Dhsiyt3S%3D%2Byp1MoP%2Bs77_n6ZyS-yepXTHiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Administration with Django 2

2018-08-10 Thread t.mayet via Django users
Hi,

I want to add a administration at my django project, this admin part is 
writen by me, not admin app.
I want to know the good method to build this, the god way is to create a 
app admin with new views, model etc... or just create a other views in my 
apps ? Blog, etc...

Thx

-- 
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/9500dc34-438c-4476-9b76-1a58a97c5a31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recursive one-to-many foreign key on the same table

2018-08-10 Thread Phlip Pretorius
Thank you Marius; the video is worth the watch and thought provoking

Phlip

On Thursday, August 9, 2018 at 2:42:13 PM UTC+2, Phlip Pretorius wrote:
>
> I want to build a one-to-many recursive foreign key on a table in Django.
>
> The concept is something like this:
>
> Table: staff/person
>
> staff numberSurnameFirstnamesSupervisor
> 4637ZondoJulien
> 859076VanderbildtJohn4637
>
> That is, Julien Zondo is John Vanderbildt's supervisor and to enter the 
> staff number in the supervisor field, it must exist in the staff table.
>
> Each staff member can have only one supervisor but a person can be the 
> supervisor of many staff members.
>
> I have read the documentation at 
> https://docs.djangoproject.com/en/2.1/ref/models/fields/#recursive-relationships
>  
> but i do not get the gist of it
>
> I want to build an index table on three levels where a level 1 index will 
> have no predecessor
> Level 2 indexes must have a level 1 predecessor and a level 3 index must 
> have a level 2 pedecessor.
>
> Can this be done by using recursive relationships or should this be done 
> in a business layer?
>
> Here is part of the definition of the model:
>
> =
> Class DecisionIndex(models.Model):
> """A mechanism to index decision taken by a committee"""
> IndexCode = models.CharField(max_length=6)
> IndexDesc = models.CharField(max_length=80, null=False)
> IndexLevel = models.IntegerField(choices=list(zip(range(1, 4),
>   range(1, 4))),
>  null=False)
> IndexPredecessor = models.ForeignKey('self',
>  on_delete=models.CASCADE,
>  limit_choices_to={'IdexLevel': 
> 1},)
>
> 
>
> I get the following error message:
> no such column: komadm_apps_decisionindex.IndexPredecessor_idno such 
> column: 
>
> Any help will be welcome.
>
> Regards,
>
> Phlip
>

-- 
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/6242ca97-ca47-466c-9545-076fe607ad49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I need help! How to add a language in Django that its not supported by default?

2018-08-10 Thread Deniz Bazan


I m trying to make a website in 5 languages. The main language should be 
kurdish but it is not supported by Django default. I tried already the how 
to add new languages into Django? 


but it didnt work for me. I receive an error mesagge

**LANG_INFO = dict(django.conf.locale.LANG_INFO.items() + 
EXTRA_LANG_INFO.items())

TypeError: unsupported operand type(s) for +: 'dict_items' and 
'dict_items'**

I also tried already to copy an english *po file* and rename it "ku" 
(kurdish) and i added into django/conf/*init*.py the language info.

'ku': {
'bidi': False,
'code': 'ku',
'name': 'Kurdish',
'name_local': 'Kurdî',},

I can see the language by languages option by template but when i click it 
i receive an error message.

File "/usr/lib/python3.6/gettext.py", line 91, in _tokenizeraise 
ValueError('invalid token in plural form: %s' % value)

ValueError: invalid token in plural form: EXPRESSION

Does anybody know how can i fix it? Thanks so much!

-- 
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/2d14351c-e7d9-4aee-b4e5-c6e0ec175fcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to add a language in Django that its not supported by default?

2018-08-10 Thread Clay Records
Hey Deniz,

It seems you're making a mistake with adding dictionaries. Dictionaries 
cannot be added with the '+' symbol.

This code gets the same error.

a = {1:1, 2:2}
b = {4:4, 5:5}
c = dict(a.items() + b.items())
print(c)


However, this code has no errors.

a = {1:1, 2:2}
b = {4:4, 5:5}
c = {**a, **b}
print(c)


Try adding your dictionaries together this way.

-Clay Records


On Thursday, August 9, 2018 at 11:31:59 AM UTC-4, Deniz Bazan wrote:
>
> Im trying to make a website in 5 languages. The main language should be 
> kurdish but it is not supported by Django default. I tried already the how 
> to add new languages into Django? 
> 
>
> but it didnt work for me. I receive an error mesagge
>
> **LANG_INFO = dict(django.conf.locale.LANG_INFO.items() + 
> EXTRA_LANG_INFO.items())
>
> TypeError: unsupported operand type(s) for +: 'dict_items' and 
> 'dict_items'**
>
> I also tried already to copy an english *po file* and rename it "ku" 
> (kurdish) and i added into django/conf/*init*.py the language info.
>
> 'ku': {
> 'bidi': False,
> 'code': 'ku',
> 'name': 'Kurdish',
> 'name_local': 'Kurdî',},
>
> I can see the language by languages option by template but when i click it 
> i receive an error message.
>
> File "/usr/lib/python3.6/gettext.py", line 91, in _tokenizeraise 
> ValueError('invalid token in plural form: %s' % value)
>
> ValueError: invalid token in plural form: EXPRESSION
>
> Does anybody know how can i fix it? Thanks so much!
>
>

-- 
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/bb88-3616-4ec5-b518-9f2df2ef9a63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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', CallV

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', FormDataViewSet

Re: How to add a language in Django that its not supported by default?

2018-08-10 Thread Deniz Bazan
thanks Clay, but this code  was not from me,i cant understand this code.I
need help for extra language by Django,wenn i dont find any solution for
this it ist very sad for me.


On Fri, Aug 10, 2018 at 3:17 PM Clay Records 
wrote:

> Hey Deniz,
>
> It seems you're making a mistake with adding dictionaries. Dictionaries
> cannot be added with the '+' symbol.
>
> This code gets the same error.
>
> a = {1:1, 2:2}
> b = {4:4, 5:5}
> c = dict(a.items() + b.items())
> print(c)
>
>
> However, this code has no errors.
>
> a = {1:1, 2:2}
> b = {4:4, 5:5}
> c = {**a, **b}
> print(c)
>
>
> Try adding your dictionaries together this way.
>
> -Clay Records
>
>
> On Thursday, August 9, 2018 at 11:31:59 AM UTC-4, Deniz Bazan wrote:
>>
>> Im trying to make a website in 5 languages. The main language should be
>> kurdish but it is not supported by Django default. I tried already the how
>> to add new languages into Django?
>> 
>>
>> but it didnt work for me. I receive an error mesagge
>>
>> **LANG_INFO = dict(django.conf.locale.LANG_INFO.items() + 
>> EXTRA_LANG_INFO.items())
>>
>> TypeError: unsupported operand type(s) for +: 'dict_items' and
>> 'dict_items'**
>>
>> I also tried already to copy an english *po file* and rename it "ku"
>> (kurdish) and i added into django/conf/*init*.py the language info.
>>
>> 'ku': {
>> 'bidi': False,
>> 'code': 'ku',
>> 'name': 'Kurdish',
>> 'name_local': 'Kurdî',},
>>
>> I can see the language by languages option by template but when i click
>> it i receive an error message.
>>
>> File "/usr/lib/python3.6/gettext.py", line 91, in _tokenizeraise 
>> ValueError('invalid token in plural form: %s' % value)
>>
>> ValueError: invalid token in plural form: EXPRESSION
>>
>> Does anybody know how can i fix it? Thanks so much!
>>
>> --
> 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/bb88-3616-4ec5-b518-9f2df2ef9a63%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Mit freundlichen Grüßen
*Deniz Bazan*

Web Entwickler
Filmmaker, Cutter, 3D  Artist
Tel:+49 163 133 68 00
http://denizbazan.jimdo.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/CADVVM_hYTLWBnAUPS8S5uL1xiitv7BwZO3G%3D%3DXDX0RU5Hdd_cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to include delete function in UpdateView instead a DeleteView

2018-08-10 Thread zengkeat
I have a UpdateView for editing a post, but instead of making a DeleteView 
for delete a post, i try to make UpdateView include a function to delete 
the post. So ,i want to edit and delete a post in UpdateView. Is that 
possible ?

form_valid() missing 1 required positional argument: 'pk'


views.py

class PostUpdate(LoginRequiredMixin,generic.UpdateView):
model = PostModel
fields = ['title','file','description']
template_name = 'post/post_update.html'
success_url = reverse_lazy('user_profile:profile')

def form_valid(self, form, pk):
if 'confirm_post' in self.request.POST:
form.instance.user = self.request.user
elif 'confirm_delete' in self.request.POST:
post_delete = PostModel.objects.get(pk = id)
post_delete.delete()
return super(PostUpdate, self).form_valid(form)

urls.py

from django.conf.urls import urlfrom . import viewsfrom django.urls import path
app_name = 'post'

urlpatterns = [
url('user_post/', views.PostView.as_view(), name= 'user_post'),
url('post_list/', views.PostList.as_view(), name='post_list'),
path('', views.PostDetail.as_view(), name= 'post_detail'),
path('update//', views.PostUpdate.as_view(), name= 'post_update'),]

post_update.html

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

  
{% csrf_token %}

{% bootstrap_form form%}


  {% endblock %}

-- 
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/88e67ef3-d673-4662-aa14-34eb1cdfe3d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unexpected behavior with icontains in query filter

2018-08-10 Thread Joel
I'm trying to do a case insensitive search for a substring within a field 
in my model.

My model:


class doctor(models.Model):
docid = models.AutoField(primary_key=True, unique=True) # Need 
autoincrement, unique and primary
name = models.CharField(max_length=35)
username = models.CharField(max_length=15)
regid = models.CharField(max_length=15, default="", blank=True)
photo = models.CharField(
max_length=35, default="", blank=True)
email = models.EmailField(default="", blank=True)
phone = models.CharField(max_length=15)
qualifications = models.CharField(
max_length=50, default="", blank=True)
about = models.CharField(
max_length=35, default="", blank=True)
specialities = models.CharField(
max_length=50, default="", blank=True)
department = models.CharField(max_length=50, default="ENT", blank=
True)
fees = models.FloatField(default=300.0)
displayfee = models.IntegerField(default=0, blank=True)
slotrange = models.CharField(max_length=50, blank=True)
slotdurn = models.IntegerField(default=10)
breakrange = models.CharField(
max_length=50, default="", blank=True)
slotsleft = models.CharField(
max_length=50, default="", blank=True)
def __str__(self):
return self.name
def Range(self):
return self.slotrange
def listslots(self):
SlotRange = self.slotrange
SlotDurn = self.slotdurn
startime = SlotRange.split('-')[0]
endtime = SlotRange.split('-')[1]
sthr, stmin = SplitTimeString(startime)
enhr, enmin = SplitTimeString(endtime)
print(stamptoday(sthr, stmin))
print(stamptoday(enhr, enmin))
startstamp = stamptoday(sthr, stmin)
endstamp = stamptoday(enhr, enmin)
secdurn = SlotDurn*60
slotlist = []
for sec in range(startstamp, endstamp, secdurn):
enttime = sec + secdurn
myrange = ("%s - %s" % (HumanTime(sec),
HumanTime(enttime)))
slotlist.append(myrange)
return slotlist


Under the field 'name' in my mysql database, are two rows with values for 
name as 'Joel' and 'Jaffy Joel'.

When I do the search like this:


from appointments.models import customer, doctor, appointment
doctor.objects.filter(name__icontains='joel')


Output:





But when I do:

doctor.objects.filter(name__icontains='Joel')



Output:

   
 , ]>


Why isnt the case insensitive search working for a lowercase search?

I'm on django 2.0.7

-- 
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/46579c92-8a12-4977-814c-9c3fcaa14711%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to include delete function in UpdateView instead a DeleteView

2018-08-10 Thread zengkeat

down vofavori 


I have a UpdateView for editing a post, but instead of making a DeleteView 
for delete a post, i try to make UpdateView include a function to delete 
the post. So ,i want to edit and delete a post in UpdateView. Is that 
possible ? i think i missing something in my code so the code keep getting 
error.

form_valid() missing 1 required positional argument: 'pk'

views.py

class PostUpdate(LoginRequiredMixin,generic.UpdateView):
model = PostModel
fields = ['title','file','description']
template_name = 'post/post_update.html'
success_url = reverse_lazy('user_profile:profile')

def form_valid(self, form, pk):
if 'confirm_post' in self.request.POST:
form.instance.user = self.request.user
elif 'confirm_delete' in self.request.POST:
post_delete = PostModel.objects.get(pk = id)
post_delete.delete()
return super(PostUpdate, self).form_valid(form)

urls.py

from django.conf.urls import urlfrom . import viewsfrom django.urls import path
app_name = 'post'

urlpatterns = [
url('user_post/', views.PostView.as_view(), name= 'user_post'),
url('post_list/', views.PostList.as_view(), name='post_list'),
path('', views.PostDetail.as_view(), name= 'post_detail'),
path('update//', views.PostUpdate.as_view(), name= 'post_update'),]

post_update.html

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

  
{% csrf_token %}

{% bootstrap_form form%}


  {% endblock %}

-- 
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/30679efe-5f30-4417-8492-1d85427cc538%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Unexpected behavior with icontains in query filter

2018-08-10 Thread Matthew Pava
I’m fascinated by this problem.
Try this workaround.
https://docs.djangoproject.com/en/2.0/ref/models/database-functions/#lower

Register the lookup Lower like so:
CharField.register_lookup(Lower, "lower")

Then use the contains lookup.
doctor.objects.filter(name__lower__contains="joel")


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel
Sent: Friday, August 10, 2018 10:56 AM
To: Django users
Subject: Unexpected behavior with icontains in query filter

I'm trying to do a case insensitive search for a substring within a field in my 
model.

My model:


class doctor(models.Model):
docid = models.AutoField(primary_key=True, unique=True) # Need 
autoincrement, unique and primary
name = models.CharField(max_length=35)
username = models.CharField(max_length=15)
regid = models.CharField(max_length=15, default="", blank=True)
photo = models.CharField(
max_length=35, default="", blank=True)
email = models.EmailField(default="", blank=True)
phone = models.CharField(max_length=15)
qualifications = models.CharField(
max_length=50, default="", blank=True)
about = models.CharField(
max_length=35, default="", blank=True)
specialities = models.CharField(
max_length=50, default="", blank=True)
department = models.CharField(max_length=50, default="ENT", blank=True)
fees = models.FloatField(default=300.0)
displayfee = models.IntegerField(default=0, blank=True)
slotrange = models.CharField(max_length=50, blank=True)
slotdurn = models.IntegerField(default=10)
breakrange = models.CharField(
max_length=50, default="", blank=True)
slotsleft = models.CharField(
max_length=50, default="", blank=True)
def __str__(self):
return self.name
def Range(self):
return self.slotrange
def listslots(self):
SlotRange = self.slotrange
SlotDurn = self.slotdurn
startime = SlotRange.split('-')[0]
endtime = SlotRange.split('-')[1]
sthr, stmin = SplitTimeString(startime)
enhr, enmin = SplitTimeString(endtime)
print(stamptoday(sthr, stmin))
print(stamptoday(enhr, enmin))
startstamp = stamptoday(sthr, stmin)
endstamp = stamptoday(enhr, enmin)
secdurn = SlotDurn*60
slotlist = []
for sec in range(startstamp, endstamp, secdurn):
enttime = sec + secdurn
myrange = ("%s - %s" % (HumanTime(sec),
HumanTime(enttime)))
slotlist.append(myrange)
return slotlist


Under the field 'name' in my mysql database, are two rows with values for name 
as 'Joel' and 'Jaffy Joel'.

When I do the search like this:


from appointments.models import customer, doctor, appointment
doctor.objects.filter(name__icontains='joel')


Output:





But when I do:

doctor.objects.filter(name__icontains='Joel')

Output:


 , ]>


Why isnt the case insensitive search working for a lowercase search?

I'm on django 2.0.7
--
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/46579c92-8a12-4977-814c-9c3fcaa14711%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/c204f799406943208eaabb1ece752054%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Not able to connect to SQL Server 2012 from current version of DJango and Python

2018-08-10 Thread Gurmeet Kaur
Hi All,

I am trying to connect to SQL server 2012 using Pyodbc and DJango framework
but the version of Django is 2.1. Now, when I try to connect using below
code when I only have Pyodbc installed then the below code doesnot run.

DATABASES = {
'default': {
# 'ENGINE': '{ODBC Driver 11 for SQL Server}', Tried this as well
but it did not work.
'ENGINE': 'sql_server.pyodbc',
'NAME': 'MY_DATABASE',
# 'HOST': 'XXX.XX.XXX.XXX', Tried this as well but it did not work.
'SERVER': 'XXX.XX.XXX.XXX',
# 'HOST': 'SQLSERVER_InstanceName',
'PORT': '',
'USER': 'SQLSERVERUSER',
'PASSWORD': 'USER's PASSWORD',
 'DATABASE': 'MY_DATABASE',
 # 'Trusted_Connection': 'Yes',
# 'OPTIONS': {
# 'driver': 'ODBC Driver 11 for SQL Server',
#}

},
}


But when I install django-pyodbc-azure and try to run the above code by
running python manage.py inspectdb command, it works.

But the problem with using django-pyodbc-azure is that it downgrades the
current version of django to 2.0.8 version - which I do not want.

I do not want to use FreeTDS or Pymssql. I want to go with pyodbc only.

Can someone please suggest some way for this?


Thanks,
Gurmeet Kaur

-- 
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/CAEbKJVinxbK8KMVdUH74kxkGC%3DNv1FCU3H4B9w7HYznM8-DQLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[no subject]

2018-08-10 Thread shivam sharma
Can someone explain me difference between Context object and RequestContext
obj.
And also difference between
render_to_response() and render()

-- 
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/CAKd5AUUPToxjMeg%2B47ENB3T5KQ%2BXyRVb%2BNKnGLKsGz10OyRFPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.