Query on 2 non related models

2019-05-20 Thread Ivan Martić
Hi guys, hope you can help me. 
I have 2 models and i want to make a count query on them. I need a count on 
how many articles i have in every category.

Models:
class Vendors(models.Model):
id = models.AutoField(db_column='id', primary_key=True, blank=False, 
unique=True)
name = models.CharField(db_column='name', max_length=150, blank=True, 
null=True)
groupid = models.IntegerField(db_column='groupid', blank=True, 
null=True)


class VendorGroup(models.Model):
id = models.AutoField(db_column='ID', primary_key=True, null=False, 
max_length=255, blank=True)
vendor_group = models.CharField(db_column='Vendor Group', 
max_length=255, blank=True, null=True)

view:
def vendorsgrouping_view(request):
list_vendor = VendorGroup.objects.all().order_by('vendor_group')

context = {
'lista_vendora':lista_vendora, 
}
return render(request, "templates/vendorgroup.html", context)

I have list of vendors listed in template:
{% for item in lista_vendora %}
{{ item.vendor_group }}
{% endfor %}

Prefetch, annotate, select related dont work since they are not connected. 
I know it is easier to give foreign key to fields but what about this?

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/f0413341-91b2-4308-afd5-ae486b09a71e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing values

2019-02-13 Thread Ivan Martić
In first page(form), i want to search for vendor. Afterwords when i click
on one we go into another page. On this page we have performance form where
we need to give ratings from 1 to 5 for that particular vendor.
So when I rate all the fields and press save, i want to store all rating
data in sql together with vendor name, timestamp and username who saved tha
data.

That was all working fine in for loop(except vendor part, needed to enter
data in input field myself), but when i divide performance form into
separate fields in HTML all crashed. Please see txt enclosed.
Thank you for your response.


sri, 13. velj 2019. u 11:48 Mohammad Etemaddar 
napisao je:

> Dear Ivan,
> If I get you right, You have a page with form, and you want to post it to
> another page. so, fill the "action" part of html form with the second
> page's url.
>
> Also the timezone.now is allways available in any python file you are
> working on it, and also request and request.user
>
> What do you want to do exactly?
>
> On Wednesday, February 13, 2019 at 1:45:46 PM UTC+3:30, Ivan Martić wrote:
>>
>> Hi all,
>>
>> where can i find more info regarding passing values in views/forms/url.
>> What I need is to pass value from form in previous url page to the form
>> in next url page(also prefilling with data like timezone.now, request,user)
>>
>> Thank you in advance.
>> Ivan
>>
> --
> 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/5eb3df26-ae0d-44c7-8f4b-e7b0b6e5e01e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/5eb3df26-ae0d-44c7-8f4b-e7b0b6e5e01e%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/CAFab_C_HtQsH7%3Dq0%3D4vYtRHN%3D5RKO0qhNow%3Degosk0RLfbdUSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
from __future__ import unicode_literals
from django.db import models, connection
from django.utils import timezone
from datetime import date
from django.forms import widgets


GRADE_CHOICES = (
('1', 'Excellent'),
('2', 'Very good'),
('3', 'Good'),
('4', 'Adequate'),
('5', 'Poor')
)


class Performance(models.Model):
id = models.AutoField(db_column='ID', primary_key=True, blank=False, 
unique=True)
supplier_name = models.CharField(db_column='Supplier name',max_length=9, 
blank=True, null=True)
deliverability = models.CharField(db_column='Deliverability', max_length=1, 
blank=True, null=True, choices=GRADE_CHOICES)
goodwill = models.CharField(db_column='Goodwill', blank=True, max_length=1, 
null=True, choices=GRADE_CHOICES)
certification = models.CharField(db_column='Certification', max_length=1, 
blank=True, null=True, choices=GRADE_CHOICES)

compliance_with_spec_field = models.CharField(db_column='Compliance with 
spec#', max_length=1, blank=True, null=True, choices=GRADE_CHOICES)
quality_of_the_delivery = models.CharField(db_column='Quality of the 
Delivery', max_length=1, blank=True, null=True, choices=GRADE_CHOICES)
quantity_reliability = models.CharField(db_column='Quantity reliability', 
max_length=1, blank=True, null=True, choices=GRADE_CHOICES)
fulfilment_of_deadlines = models.CharField(db_column='Fulfilment of 
deadlines', max_length=1, blank=True, null=True, choices=GRADE_CHOICES)

reaction_time = models.CharField(db_column='Reaction time', max_length=1, 
blank=True, null=True, choices=GRADE_CHOICES)
flexibilty = models.CharField(db_column='Flexibilty', max_length=1, 
blank=True, null=True, choices=GRADE_CHOICES)
economical_offer = models.CharField(db_column='Economical offer', 
max_length=1, blank=True, null=True, choices=GRADE_CHOICES)
price_performance_ratio = models.CharField(db_column='Price-performance 
ratio', max_length=1, blank=True, null=True, choices=GRADE_CHOICES)

credit = models.CharField(db_column='Credit', max_length=1, blank=True, 
null=True, choices=GRADE_CHOICES)
rating = models.CharField(db_colu

Passing values

2019-02-13 Thread Ivan Martić
Hi all,

where can i find more info regarding passing values in views/forms/url.
What I need is to pass value from form in previous url page to the form in 
next url page(also prefilling with data like timezone.now, request,user)

Thank you in advance.
Ivan

-- 
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/53f99288-1b18-4c4a-8a1a-92b465519d87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: The database driver doesn't support modern datatime types.

2019-02-11 Thread Ivan Martić
resolved.

Microsoft ODBC driver was missing, download it from MS official web page 
and all is working perfect now

On Monday, February 11, 2019 at 11:21:37 AM UTC+1, Ivan Martić wrote:
>
> Hi all, 
>
> I am migrating to from development to prod server and getting this error 
> app.
>
> Error started to show after installation of allauth library.
> I cant find anything on google related to this topic so I hope you can 
> help me out.
>
> Traceback is saying:
> Exception Type: ImproperlyConfigured at /accounts/login/
> Exception Value: The database driver doesn't support modern datatime types.
>
> DB is MSSQL and I should have all neccesery installation because it worked 
> previously (on local server - pyodbc, azure...)
>
> 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 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/f46f35b0-0dcf-4355-bc40-64f5463465d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


The database driver doesn't support modern datatime types.

2019-02-11 Thread Ivan Martić
Hi all, 

I am migrating to from development to prod server and getting this error 
app.

Error started to show after installation of allauth library.
I cant find anything on google related to this topic so I hope you can help 
me out.

Traceback is saying:
Exception Type: ImproperlyConfigured at /accounts/login/
Exception Value: The database driver doesn't support modern datatime types.

DB is MSSQL and I should have all neccesery installation because it worked 
previously (on local server - pyodbc, azure...)

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 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/7a36a458-7a3e-446a-b224-a5b2d4cd0ff8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at - Reverse with arguments '('',)' not found

2019-02-07 Thread Ivan Martić
Problem solved, I had a null value in the db so listing couldnt work..

On Monday, February 4, 2019 at 6:59:09 PM UTC+1, B.navya spoorthi Sweety 
wrote:
>
> hi all , 
> i just started with django. i am following this document
> https://docs.djangoproject.com/en/2.1/intro/tutorial01/ 
> here database used is sqlite. but i want to try out  django+mongodb
> what all changes i can made so that django uses mongodb database 
> where should i create database and use with django.
>
> i knew Regular Mongo Db operations 
>
> but not able to do from Django 
>
>
> thanks in advance.
> waiting for a reply
>
> On Mon, Feb 4, 2019 at 5:18 PM Ivan Martić  > wrote:
>
>> Hi all,
>>
>> I need help.
>> I keep getting this issue, NoReverseMatch at /
>> Reverse for 'productsgrouping-update' with arguments '('',)' not found. 1 
>> pattern(s) tried: ['update/(?P[0-9]+)/$']
>>
>> not sure what am doing wrong. Any time I put url tag {% url 
>> 'productsgrouping-update' lista.id%} in html i get the error.
>> Both url work as stand alone,* /index* and */index/update/1/* but when i 
>> put url tag all hell break loose.. I strugling for a week now. Thank you 
>> all in advance.
>>
>> **
>> from django.shortcuts import render, redirect
>> from django.http import HttpResponse
>> from .models import Material4, MaterialGroup
>> from django.db import connection
>> from .forms import ProductgroupinputForm, MaterialGroupForm
>> from django.conf import settings
>>
>> def productsView(request):
>> lista = MaterialGroup.objects.all() 
>> #text5 = MaterialGroup.objects.get(id=url_id)
>> #return redirect(reverse('productsgrouping_update', kwargs=('id':url_id)))
>> return render(request, "productsgroup.html", {"lista" : lista})
>>
>> def productsUpdateView(request, url_id):
>> text5 = MaterialGroup.objects.get(id=url_id)
>> form5 = ProductgroupinputForm(request.POST or None, instance=text5)
>>
>> context1 = {'text5': text5,'form5': form5}
>>
>> if form5.is_valid():
>> form5.save()
>> return render(request, 'productsgroup-update.html', context1)
>>
>> **
>> from django.urls import path
>> from . import views
>>
>> urlpatterns = [
>> path('', views.productsView, name='productsgrouping'),
>> path('update//', views.productsUpdateView, 
>> name='productsgrouping-update'),
>> ]
>>
>> **
>> from django.contrib import admin
>> from django.urls import path, include
>> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> path('', include('product.urls')),
>> ]
>>
>>
>> **
>> from __future__ import unicode_literals
>> from django.db import models, connection
>> from django.utils import timezone
>> from datetime import date
>> from django.urls import reverse
>>
>> class Material4(models.Model):
>> id = models.IntegerField(db_column='ID', primary_key=True, 
>> blank=False, unique=True)
>> bukrs = models.CharField(db_column='BUKRS', max_length=3)
>> materialid = models.CharField(db_column='MaterialID', max_length=50)
>> maktx = models.CharField(db_column='MAKTX', max_length=150)
>> input_group = models.IntegerField(db_column='Input_group')
>>
>> class Meta:
>> managed = False
>> db_table = 'Material4'
>>
>> def __str__(self):
>> return '%s %s %s %s' % (self.id, self.materialid, self.maktx, 
>> self.input_group)
>>
>>
>> **
>> from django import forms
>> from .models import Material4, MaterialGroup
>>
>> class ProductgroupinputForm(forms.ModelForm):
>>
>> class Meta:
>> model = Material4
>> fields = ['materialid', 'input_group', 'id', 'input_group']
>>
>> class MaterialGroupForm(forms.ModelForm):
>>
>> class Meta:
>> model = MaterialGroup
>> fields = ['material_group', '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...@googlegroups.com .
>> To post to this group, send email to django...@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/0f15b6d

NoReverseMatch at - Reverse with arguments '('',)' not found

2019-02-04 Thread Ivan Martić
Hi all,

I need help.
I keep getting this issue, NoReverseMatch at /
Reverse for 'productsgrouping-update' with arguments '('',)' not found. 1 
pattern(s) tried: ['update/(?P[0-9]+)/$']

not sure what am doing wrong. Any time I put url tag {% url 
'productsgrouping-update' lista.id%} in html i get the error.
Both url work as stand alone,* /index* and */index/update/1/* but when i 
put url tag all hell break loose.. I strugling for a week now. Thank you 
all in advance.

**
from django.shortcuts import render, redirect
from django.http import HttpResponse
from .models import Material4, MaterialGroup
from django.db import connection
from .forms import ProductgroupinputForm, MaterialGroupForm
from django.conf import settings

def productsView(request):
lista = MaterialGroup.objects.all() 
#text5 = MaterialGroup.objects.get(id=url_id)
#return redirect(reverse('productsgrouping_update', kwargs=('id':url_id)))
return render(request, "productsgroup.html", {"lista" : lista})

def productsUpdateView(request, url_id):
text5 = MaterialGroup.objects.get(id=url_id)
form5 = ProductgroupinputForm(request.POST or None, instance=text5)

context1 = {'text5': text5,'form5': form5}

if form5.is_valid():
form5.save()
return render(request, 'productsgroup-update.html', context1)

**
from django.urls import path
from . import views

urlpatterns = [
path('', views.productsView, name='productsgrouping'),
path('update//', views.productsUpdateView, 
name='productsgrouping-update'),
]

**
from django.contrib import admin
from django.urls import path, include
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('product.urls')),
]


**
from __future__ import unicode_literals
from django.db import models, connection
from django.utils import timezone
from datetime import date
from django.urls import reverse

class Material4(models.Model):
id = models.IntegerField(db_column='ID', primary_key=True, blank=False, 
unique=True)
bukrs = models.CharField(db_column='BUKRS', max_length=3)
materialid = models.CharField(db_column='MaterialID', max_length=50)
maktx = models.CharField(db_column='MAKTX', max_length=150)
input_group = models.IntegerField(db_column='Input_group')

class Meta:
managed = False
db_table = 'Material4'

def __str__(self):
return '%s %s %s %s' % (self.id, self.materialid, self.maktx, 
self.input_group)


**
from django import forms
from .models import Material4, MaterialGroup

class ProductgroupinputForm(forms.ModelForm):

class Meta:
model = Material4
fields = ['materialid', 'input_group', 'id', 'input_group']

class MaterialGroupForm(forms.ModelForm):

class Meta:
model = MaterialGroup
fields = ['material_group', '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/0f15b6d9-4dec-4ef9-b79a-643fc37a8781%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing pk arguments from a URL into another view

2019-02-04 Thread Ivan Martić
Can you elaborate a bit, i have the same issue with noreverse error

ned, 3. velj 2019. u 15:08 poOya mOsaddegh 
napisao je:

> Hi
> You may use include in urls.py
>
> urlpatterns = [
> path('', views.club_home, name='club_home'),
> path('/', include(club_home_urls, namespace='club_home')),
> ]
>
>
>
> On Sat, Feb 2, 2019 at 8:20 PM GavinB841  wrote:
>
>> *Hi all,*
>>
>> *I am having issues using arguments from a URL in another view, I have
>> reached out on stackover flow with no success, i believe i am wording this
>> question poorly.*
>>
>> *To quickly explain *
>>
>>- *I have a main site which shows a list of sports clubs. When the
>>user selects on one it renders that specific club home page using the PK
>>passed in the template.*
>>- *Once I get to this home page
>>e.g. http://127.0.0.1:8000/club_home/2/
>>  .  I have many sub-pages which a 
>> user
>>can select but I have no idea how I can use that same PK to filter data in
>>the other pages to only show details based on that club.*
>>- *I would also like to include that PK in the rest of the URLs.
>>e.g. http://127.0.0.1:8000/club_home/2/teams/
>>*
>>
>>
>> *Code:*
>>
>> *index.html:*
>>
>> Our Clubs
>> {% for club in all_clubs %}
>> 
>> {{ club.club_name }}
>> 
>>   {% endfor %}
>>
>>
>> *urls.py*
>>
>> I understand I must include the / before teams in the URL but
>> I am unsure how to pass in that argument
>>
>> urlpatterns = [
>> path('', views.club_home, name='club_home'),
>> path('/', views.club_home, name='club_home_with_pk'),
>> path('teams/', views.TeamInfo.as_view(), name='teams'),
>> ]
>>
>>
>>
>>
>>
>> *views.py *
>>
>>
>>
>> def club_home(request, pk=None):
>> if pk:
>> club = ClubInfo.objects.filter(pk=pk)
>> club_posts = ClubPosts.objects.filter(club_id=club[0])
>> elif request.user.is_authenticated:
>> club = ClubInfo.objects.filter(user=request.user)
>> club_posts = ClubPosts.objects.filter(club_id=club[0])
>> # photo = model.club_logo.ImageField(storage=profile_pics)
>> args = {'club': club,
>> 'club_posts': club_posts
>> }
>> return render(request, 'club_home_page.html', args)
>>
>>
>>
>> class TeamInfo(APIView):
>> renderer_classes = [TemplateHTMLRenderer]
>> template_name = 'teams.html'
>>
>> def get(self, request):
>> serializer = TeamSerializer()
>> user = ClubInfo.objects.filter(user=request.user).first()
>> teams = Team.objects.filter(club_id=user.pk)
>> return Response({'serializer': serializer,
>>  'teams': teams,
>>  })
>>
>>
>>
>> *club_main_page.html*
>>
>>
>> navbar on club home page to get to other pages, I know I need to include 
>>  into the **URL and** I need to pass this argument into the href of this 
>> URL but as need to figure out the view before adding this 
>>
>>
>>
>> Team
>>
>>
>>
>> *Any idea what I need to add into the view to allow for this. I would really 
>> appreciate any help as I've been stuck on this for weeks now. *
>>
>>
>> *Thanks *
>>
>>
>> *Gavin*
>>
>>
>>
>> *Séanadh Ríomhphoist/Email DisclaimerTá an ríomhphost seo agus aon
>> chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin
>> amháin é. Is féidir tuilleadh a léamh anseo.
>> 
>> This e-mail and any
>> files transmitted with it are confidential and are intended solely for use
>> by the addressee. Read more here.
>>  *
>>
>> --
>> 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/3465a2fc-347a-4096-b037-83be9b57d8a2%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
> 

Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-02-01 Thread Ivan Martić
i think i found the issue, problem was in the html url tag..
i should look like this
href="{ url 'update_group' list_all.url_id }">

not like this
href="{ url 'update_group' item.id }">

thank you all

pet, 1. velj 2019. u 09:26 Ivan Martić  napisao je:

> Hi guys, any help on this matter? i still have noreverse issue. There is
> something wrong with my url nameing
>
> sri, 30. sij 2019. u 10:55 Ivan Martić  napisao je:
>
>> Bok Nebojša, jel možeš uletit i pogledati molim te što radim krivo.
>>>>
>>>> Znači, imam 2 aplikacije, prva abc radi a druga product groups ne radi..
>>>> Sve je kopirano u 2 privitka.
>>>>
>>>> Da li imaš vremena pogledati pliz?
>>>>
>>> Šta god napravim, No reverse mi se javlja...
>>
>

-- 
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/CAFab_C8vxGNnJ1N8cJ%3D1nsuAD306TY9s46TuObJs-%2BsvnVP0eQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-02-01 Thread Ivan Martić
Hi guys, any help on this matter? i still have noreverse issue. There is
something wrong with my url nameing

sri, 30. sij 2019. u 10:55 Ivan Martić  napisao je:

> Bok Nebojša, jel možeš uletit i pogledati molim te što radim krivo.
>>>
>>> Znači, imam 2 aplikacije, prva abc radi a druga product groups ne radi..
>>> Sve je kopirano u 2 privitka.
>>>
>>> Da li imaš vremena pogledati pliz?
>>>
>> Šta god napravim, No reverse mi se javlja...
>

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


Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-01-30 Thread Ivan Martić
>
> Bok Nebojša, jel možeš uletit i pogledati molim te što radim krivo.
>>
>> Znači, imam 2 aplikacije, prva abc radi a druga product groups ne radi..
>> Sve je kopirano u 2 privitka.
>>
>> Da li imaš vremena pogledati pliz?
>>
> Šta god napravim, No reverse mi se javlja...

-- 
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/CAFab_C8%2BhPxKUsLah%3D%3DtOrn8ro8-DgA3GFhy8%2Bz99kF4r80tog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
app 1
view:
from django.shortcuts import render, redirect
from django.http import HttpResponse
from .models import AbcClassification
from django.db import connection
from .forms import AbcForm
from django.core.mail import send_mail
from django.conf import settings
from django.core.mail import send_mail
from django.contrib import messages
import time
from django.contrib.auth import login, logout
from django.contrib.auth.decorators import user_passes_test, login_required

def check_user(user):
if user.groups.filter(name='abc_all').count() == 1:
return True
return False

@login_required(login_url='/accounts/login/')
@user_passes_test(check_user, login_url='/denied')

def abc_view(request):
queryset = AbcClassification.objects.all()
context = {
"lista" : queryset,
}
return render(request, "qif/abc.html", context)

@login_required(login_url='/accounts/login/')
@user_passes_test(check_user, login_url='/denied')

def abc_update_view(request, url_id):
abc_lista = AbcClassification.objects.get(id=url_id)
abc_url_id = AbcForm(request.POST or None, instance=abc_lista)
context1 = {'abc_url_id': abc_url_id, 'abc_lista': abc_lista}

if abc_url_id.is_valid():
abc_url_id.save()
messages.success(request, 'Your entry has been saved. Relevant 
persons will be informed of this change.')
return render(request, 'qif/abc-update.html', context1)

url:
from django.urls import path
from . import views


urlpatterns = [
path('', views.abc_view, name='abc'),
path('update//', views.abc_update_view, name='update_abc'),
]


model:
from __future__ import unicode_literals
from django.db import models, connection
from django.utils import timezone
from simple_history.models import HistoricalRecords
from django.contrib.auth.models import User




class AbcClassification(models.Model):
id = models.IntegerField(db_column='ID', primary_key=True)
class_field = models.CharField(db_column='Class', max_length=1)
value = models.SmallIntegerField(db_column='Value')

history = HistoricalRecords()


class Meta:
managed = False
db_table = 'ABC_Classification'

def __str__(self):
return '%s %s' % (self.class_field, self.value, self.id)


app2

view:
from django.shortcuts import render, redirect
from django.http import HttpResponse
from .models import Material4, MaterialGroup
from django.db import connection
from .forms import ProductgroupinputForm, MaterialGroupForm
from django.core.mail import send_mail
from django.conf import settings
from django.core.mail import send_mail
from django.contrib import messages
from django.db.models import Q
from django.contrib.auth import login, logout
from django.contrib.auth.decorators import user_passes_test, login_required
from django.shortcuts import get_object_or_404

def check_user(user):
if user.groups.filter(name='productsgrouping_all').count() == 1:
return True
return False


#novi views
@login_required(login_url='/accounts/login/')
@user_passes_test(check_user, login_url='/denied')

def productsgrouping_view(request):
queryset = MaterialGroup.objects.all()
#not_assigned = 
Material4.objects.filter(input_group__isnull=True).count()
context = {
"lista" : queryset, 
#"not_assigned":not_assigned
}

return render(request, 'qif/productsgrouping/productsgroup.html', 
context)

@login_required(login_url='/accounts/login/')
@user_passes_test(check_user, login_url='/denied')

def productsgrouping_update_view(request, url_id):
#assigned = get_object_or_404(id=url_id)
assigned = Material4.objects.filter(input_group=url_id)
not_assigned = None
search = request.GET.get("search", None)

if search:
not_assigned = 
Material4.objects.filter(Q(materialid__icontains=search) | 
Q(maktx__icontains=search))


product_lista = MaterialGroup.objects.get(id=url_id)
#product_lista = get_object_or_404(MaterialGroup, 

Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-01-29 Thread Ivan Martić
ok, pokušat ću. ak neuspijem posaljem ti sta god ti treba da pokusas sam
rekreirati...ovo je zaista zeznuto

uto, 29. sij 2019. u 13:56 Nebojsa Hajdukovic 
napisao je:

> To je greška zato što ne može da nađe url_id ajd ako ne uspeš pogledaću
> večeras detaljno šta si radio pa da vidim gde je greška
>
> уто, 29. јан 2019. у 13:51 Ivan Martić  је
> написао/ла:
>
>> napravio sam točno kako si rekao i dalje nece, isti error ...vec danima
>> se mucim sa ovime..nešto drugo je posrijedi.
>>
>>
>>
>>
>>
>> uto, 29. sij 2019. u 12:16 Nebojsa Hajdukovic 
>> napisao je:
>>
>>> neće raditi ali ne zbog html već zbog greške u views
>>> probaj ovako
>>>
>>> def productsgrouping_update_view(request, url_id):
>>> assigned = get_object_or_404(Material, pk=url_id)
>>>
>>>
>>> naravno prvo moraš da importuješ get object or 404:
>>>
>>> from django.shortcuts import get_object_or_404
>>>
>>>
>>> уто, 29. јан 2019. у 12:00 Ivan Martić  је
>>> написао/ла:
>>>
>>>> Bok Nebojša,
>>>>
>>>> mislim da je stvar u HTML možda prije, jer mi je ranije sve radilo..u
>>>> jednom trenu je puknula veza. Neznam točno kada.
>>>> Znači, da odem na url *productsgrouping *prikaze sve grupe, kad
>>>> kliknem na grupu (dodam joj a=href) no reverse mathc, ako maknem atribute u
>>>> url dobijem #, a ako ručno upišem productsgrouping/update/1 onda prikaze i
>>>> nastavi sve kako treba.
>>>> Znaci samo nemogu povezati ta dva linkapogledaj htmlove u privitku
>>>>
>>>> hvala ti za pomoć
>>>>
>>>>
>>>> uto, 29. sij 2019. u 11:35 Nebojsa Hajdukovic <
>>>> nebojsa.zero...@gmail.com> napisao je:
>>>>
>>>>> A što ne uradiš update preko class based view daleko je lakše?
>>>>>
>>>>> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/
>>>>>
>>>>> Ako hoćeš preko funkcije ja radim sa get_object_or_404, ovako:
>>>>> def productsgrouping_update_view(request, url_id):
>>>>> product_lista = get_object_or_404(MaterialGroup, pk=url_id)
>>>>>
>>>>>
>>>>> уто, 29. јан 2019. у 10:20 Ivan Martić  је
>>>>> написао/ла:
>>>>>
>>>>>> not sure what to say
>>>>>>
>>>>>> čet, 24. sij 2019. u 13:53 Ivan Martić 
>>>>>> napisao je:
>>>>>>
>>>>>>> Hi  Andréas,
>>>>>>> sorry for misspeling in codes. All is working ok except when i try
>>>>>>> to put url tag for 'update_productsgrouping'.
>>>>>>> I need to update group with new products but It does not argument
>>>>>>> for group id.
>>>>>>> What do you think i am doing wrong...?
>>>>>>>
>>>>>>> čet, 24. sij 2019. u 13:43 Andréas Kühne 
>>>>>>> napisao je:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> The reason you are getting this is that you are adding an argument
>>>>>>>> to the productsgrouping url - which doesn't take any arguments.
>>>>>>>>
>>>>>>>> In your code you have:
>>>>>>>> 
>>>>>>>> (Which by the way isn't correct either, I think you mean: >>>>>>> href="{% url 'productsgrouping' item.id%}">{{ item }} - {{item.id}}
>>>>>>>> )
>>>>>>>>
>>>>>>>> If you look at the url for the producsgrouping view, you have:
>>>>>>>> path('', views.productsgrouping_view, name='productsgrouping'),
>>>>>>>>
>>>>>>>> Which doesn't take any arguments, when you then add an argument
>>>>>>>> django can't find the right URL.
>>>>>>>>
>>>>>>>> You may mean:
>>>>>>>> {{ item }} -
>>>>>>>> {{item.id}} 
>>>>>>>> ?
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>>
>>>>>>>> Andréas
>>>>>>>>
>>>>>>>>
>>>>>>>> Den tors 24 jan. 2019 kl 13:28 skrev Ivan Martić <
>>>>>>>> ma

Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-01-29 Thread Ivan Martić
napravio sam točno kako si rekao i dalje nece, isti error ...vec danima se
mucim sa ovime..nešto drugo je posrijedi.





uto, 29. sij 2019. u 12:16 Nebojsa Hajdukovic 
napisao je:

> neće raditi ali ne zbog html već zbog greške u views
> probaj ovako
>
> def productsgrouping_update_view(request, url_id):
>   assigned = get_object_or_404(Material, pk=url_id)
>
>
> naravno prvo moraš da importuješ get object or 404:
>
> from django.shortcuts import get_object_or_404
>
>
> уто, 29. јан 2019. у 12:00 Ivan Martić  је
> написао/ла:
>
>> Bok Nebojša,
>>
>> mislim da je stvar u HTML možda prije, jer mi je ranije sve radilo..u
>> jednom trenu je puknula veza. Neznam točno kada.
>> Znači, da odem na url *productsgrouping *prikaze sve grupe, kad kliknem
>> na grupu (dodam joj a=href) no reverse mathc, ako maknem atribute u url
>> dobijem #, a ako ručno upišem productsgrouping/update/1 onda prikaze i
>> nastavi sve kako treba.
>> Znaci samo nemogu povezati ta dva linkapogledaj htmlove u privitku
>>
>> hvala ti za pomoć
>>
>>
>> uto, 29. sij 2019. u 11:35 Nebojsa Hajdukovic 
>> napisao je:
>>
>>> A što ne uradiš update preko class based view daleko je lakše?
>>>
>>> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/
>>>
>>> Ako hoćeš preko funkcije ja radim sa get_object_or_404, ovako:
>>> def productsgrouping_update_view(request, url_id):
>>> product_lista = get_object_or_404(MaterialGroup, pk=url_id)
>>>
>>>
>>> уто, 29. јан 2019. у 10:20 Ivan Martić  је
>>> написао/ла:
>>>
>>>> not sure what to say
>>>>
>>>> čet, 24. sij 2019. u 13:53 Ivan Martić  napisao
>>>> je:
>>>>
>>>>> Hi  Andréas,
>>>>> sorry for misspeling in codes. All is working ok except when i try to
>>>>> put url tag for 'update_productsgrouping'.
>>>>> I need to update group with new products but It does not argument for
>>>>> group id.
>>>>> What do you think i am doing wrong...?
>>>>>
>>>>> čet, 24. sij 2019. u 13:43 Andréas Kühne 
>>>>> napisao je:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> The reason you are getting this is that you are adding an argument to
>>>>>> the productsgrouping url - which doesn't take any arguments.
>>>>>>
>>>>>> In your code you have:
>>>>>> 
>>>>>> (Which by the way isn't correct either, I think you mean: {{ item }} - {{item.id}} )
>>>>>>
>>>>>> If you look at the url for the producsgrouping view, you have:
>>>>>> path('', views.productsgrouping_view, name='productsgrouping'),
>>>>>>
>>>>>> Which doesn't take any arguments, when you then add an argument
>>>>>> django can't find the right URL.
>>>>>>
>>>>>> You may mean:
>>>>>> {{ item }} - {{
>>>>>> item.id}} 
>>>>>> ?
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Andréas
>>>>>>
>>>>>>
>>>>>> Den tors 24 jan. 2019 kl 13:28 skrev Ivan Martić <
>>>>>> martic.i...@gmail.com>:
>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> i am having issue with url tag, every time i put url tag like --{%
>>>>>>> url 'productsgrouping' item.id%}-- i get no reverse error.
>>>>>>> Can you help me figure it out on what am i doing wrong?
>>>>>>>
>>>>>>> view:
>>>>>>> def productsgrouping_view(request):
>>>>>>> queryset = MaterialGroup.objects.all()
>>>>>>> context = {"list" : queryset}
>>>>>>> return render(request, 'qif/productsgrouping/productsgroup.html',
>>>>>>> context)
>>>>>>>
>>>>>>> def productsgrouping_update_view(request, url_id):
>>>>>>> product_lista = MaterialGroup.objects.get(id=url_id)
>>>>>>> product_url_id = ProductgroupinputForm(request.POST or None,
>>>>>>> instance=product_lista)
>>>>>>> context1 = {'product_url_id': product_url_id, 'product_lista':
>>>>>>> product_lista}
>>>>>>>
>>

Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-01-29 Thread Ivan Martić
Bok Nebojša,

mislim da je stvar u HTML možda prije, jer mi je ranije sve radilo..u
jednom trenu je puknula veza. Neznam točno kada.
Znači, da odem na url *productsgrouping *prikaze sve grupe, kad kliknem na
grupu (dodam joj a=href) no reverse mathc, ako maknem atribute u url
dobijem #, a ako ručno upišem productsgrouping/update/1 onda prikaze i
nastavi sve kako treba.
Znaci samo nemogu povezati ta dva linkapogledaj htmlove u privitku

hvala ti za pomoć


uto, 29. sij 2019. u 11:35 Nebojsa Hajdukovic 
napisao je:

> A što ne uradiš update preko class based view daleko je lakše?
>
> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/
>
> Ako hoćeš preko funkcije ja radim sa get_object_or_404, ovako:
> def productsgrouping_update_view(request, url_id):
> product_lista = get_object_or_404(MaterialGroup, pk=url_id)
>
>
> уто, 29. јан 2019. у 10:20 Ivan Martić  је
> написао/ла:
>
>> not sure what to say
>>
>> čet, 24. sij 2019. u 13:53 Ivan Martić  napisao
>> je:
>>
>>> Hi  Andréas,
>>> sorry for misspeling in codes. All is working ok except when i try to
>>> put url tag for 'update_productsgrouping'.
>>> I need to update group with new products but It does not argument for
>>> group id.
>>> What do you think i am doing wrong...?
>>>
>>> čet, 24. sij 2019. u 13:43 Andréas Kühne 
>>> napisao je:
>>>
>>>> Hi,
>>>>
>>>> The reason you are getting this is that you are adding an argument to
>>>> the productsgrouping url - which doesn't take any arguments.
>>>>
>>>> In your code you have:
>>>> 
>>>> (Which by the way isn't correct either, I think you mean: {{ item }} - {{item.id}} )
>>>>
>>>> If you look at the url for the producsgrouping view, you have:
>>>> path('', views.productsgrouping_view, name='productsgrouping'),
>>>>
>>>> Which doesn't take any arguments, when you then add an argument django
>>>> can't find the right URL.
>>>>
>>>> You may mean:
>>>> {{ item }} - {{
>>>> item.id}} 
>>>> ?
>>>>
>>>> Regards,
>>>>
>>>> Andréas
>>>>
>>>>
>>>> Den tors 24 jan. 2019 kl 13:28 skrev Ivan Martić >>> >:
>>>>
>>>>> Hi all,
>>>>>
>>>>> i am having issue with url tag, every time i put url tag like --{% url
>>>>> 'productsgrouping' item.id%}-- i get no reverse error.
>>>>> Can you help me figure it out on what am i doing wrong?
>>>>>
>>>>> view:
>>>>> def productsgrouping_view(request):
>>>>> queryset = MaterialGroup.objects.all()
>>>>> context = {"list" : queryset}
>>>>> return render(request, 'qif/productsgrouping/productsgroup.html',
>>>>> context)
>>>>>
>>>>> def productsgrouping_update_view(request, url_id):
>>>>> product_lista = MaterialGroup.objects.get(id=url_id)
>>>>> product_url_id = ProductgroupinputForm(request.POST or None,
>>>>> instance=product_lista)
>>>>> context1 = {'product_url_id': product_url_id, 'product_lista':
>>>>> product_lista}
>>>>>
>>>>> if product_url_id.is_valid():
>>>>> product_url_id.save()
>>>>>
>>>>> return render(request, 'productsgroup-update.html', context1)
>>>>>
>>>>> url:
>>>>> urlpatterns = [
>>>>> path('', views.productsgrouping_view, name='productsgrouping'),
>>>>> path('update//', views.productsgrouping_update_view,
>>>>> name='update_productsgrouping'),
>>>>> path('new/', views.creategroup_view, name='create_group'),
>>>>> ]
>>>>>
>>>>> html:
>>>>> {% extends 'base.html' %}
>>>>> {% block content %}
>>>>> 
>>>>> {% for item in list %}
>>>>> 
>>>>> 
>>>>> {{ item }} - {{item.id}}
>>>>> 
>>>>> {% endfor %}
>>>>> {% 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.
>>>&

Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-01-29 Thread Ivan Martić
not sure what to say

čet, 24. sij 2019. u 13:53 Ivan Martić  napisao je:

> Hi  Andréas,
> sorry for misspeling in codes. All is working ok except when i try to put
> url tag for 'update_productsgrouping'.
> I need to update group with new products but It does not argument for
> group id.
> What do you think i am doing wrong...?
>
> čet, 24. sij 2019. u 13:43 Andréas Kühne 
> napisao je:
>
>> Hi,
>>
>> The reason you are getting this is that you are adding an argument to the
>> productsgrouping url - which doesn't take any arguments.
>>
>> In your code you have:
>> 
>> (Which by the way isn't correct either, I think you mean: {{ item }} - {{item.id}} )
>>
>> If you look at the url for the producsgrouping view, you have:
>> path('', views.productsgrouping_view, name='productsgrouping'),
>>
>> Which doesn't take any arguments, when you then add an argument django
>> can't find the right URL.
>>
>> You may mean:
>> {{ item }} - {{
>> item.id}} 
>> ?
>>
>> Regards,
>>
>> Andréas
>>
>>
>> Den tors 24 jan. 2019 kl 13:28 skrev Ivan Martić :
>>
>>> Hi all,
>>>
>>> i am having issue with url tag, every time i put url tag like --{% url
>>> 'productsgrouping' item.id%}-- i get no reverse error.
>>> Can you help me figure it out on what am i doing wrong?
>>>
>>> view:
>>> def productsgrouping_view(request):
>>> queryset = MaterialGroup.objects.all()
>>> context = {"list" : queryset}
>>> return render(request, 'qif/productsgrouping/productsgroup.html',
>>> context)
>>>
>>> def productsgrouping_update_view(request, url_id):
>>> product_lista = MaterialGroup.objects.get(id=url_id)
>>> product_url_id = ProductgroupinputForm(request.POST or None,
>>> instance=product_lista)
>>> context1 = {'product_url_id': product_url_id, 'product_lista':
>>> product_lista}
>>>
>>> if product_url_id.is_valid():
>>> product_url_id.save()
>>>
>>> return render(request, 'productsgroup-update.html', context1)
>>>
>>> url:
>>> urlpatterns = [
>>> path('', views.productsgrouping_view, name='productsgrouping'),
>>> path('update//', views.productsgrouping_update_view,
>>> name='update_productsgrouping'),
>>> path('new/', views.creategroup_view, name='create_group'),
>>> ]
>>>
>>> html:
>>> {% extends 'base.html' %}
>>> {% block content %}
>>> 
>>> {% for item in list %}
>>> 
>>> 
>>> {{ item }} - {{item.id}}
>>> 
>>> {% endfor %}
>>> {% 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/ca1ef95d-166a-40ef-91bc-16f2d704f2ee%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/ca1ef95d-166a-40ef-91bc-16f2d704f2ee%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/CAK4qSCcnxCFkss1b8sOTDW3Kb6Vc1fFst4MO024%2BEq%3DwXLGjcg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAK4qSCcnxCFkss1b8sOTDW3Kb6Vc1fFst4MO024%2BEq%3DwXLGjcg%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/CAFab_C8HUsxdpqz-MGqcpw0ZwgFOvrYZ-RJte6-H5x38b97ciQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-01-24 Thread Ivan Martić
Hi  Andréas,
sorry for misspeling in codes. All is working ok except when i try to put
url tag for 'update_productsgrouping'.
I need to update group with new products but It does not argument for group
id.
What do you think i am doing wrong...?

čet, 24. sij 2019. u 13:43 Andréas Kühne 
napisao je:

> Hi,
>
> The reason you are getting this is that you are adding an argument to the
> productsgrouping url - which doesn't take any arguments.
>
> In your code you have:
> 
> (Which by the way isn't correct either, I think you mean: {{ item }} - {{item.id}} )
>
> If you look at the url for the producsgrouping view, you have:
> path('', views.productsgrouping_view, name='productsgrouping'),
>
> Which doesn't take any arguments, when you then add an argument django
> can't find the right URL.
>
> You may mean:
> {{ item }} - {{
> item.id}} 
> ?
>
> Regards,
>
> Andréas
>
>
> Den tors 24 jan. 2019 kl 13:28 skrev Ivan Martić :
>
>> Hi all,
>>
>> i am having issue with url tag, every time i put url tag like --{% url
>> 'productsgrouping' item.id%}-- i get no reverse error.
>> Can you help me figure it out on what am i doing wrong?
>>
>> view:
>> def productsgrouping_view(request):
>> queryset = MaterialGroup.objects.all()
>> context = {"list" : queryset}
>> return render(request, 'qif/productsgrouping/productsgroup.html', context)
>>
>> def productsgrouping_update_view(request, url_id):
>> product_lista = MaterialGroup.objects.get(id=url_id)
>> product_url_id = ProductgroupinputForm(request.POST or None,
>> instance=product_lista)
>> context1 = {'product_url_id': product_url_id, 'product_lista':
>> product_lista}
>>
>> if product_url_id.is_valid():
>> product_url_id.save()
>>
>> return render(request, 'productsgroup-update.html', context1)
>>
>> url:
>> urlpatterns = [
>> path('', views.productsgrouping_view, name='productsgrouping'),
>> path('update//', views.productsgrouping_update_view,
>> name='update_productsgrouping'),
>> path('new/', views.creategroup_view, name='create_group'),
>> ]
>>
>> html:
>> {% extends 'base.html' %}
>> {% block content %}
>> 
>> {% for item in list %}
>> 
>> 
>> {{ item }} - {{item.id}}
>> 
>> {% endfor %}
>> {% 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/ca1ef95d-166a-40ef-91bc-16f2d704f2ee%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/ca1ef95d-166a-40ef-91bc-16f2d704f2ee%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/CAK4qSCcnxCFkss1b8sOTDW3Kb6Vc1fFst4MO024%2BEq%3DwXLGjcg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAK4qSCcnxCFkss1b8sOTDW3Kb6Vc1fFst4MO024%2BEq%3DwXLGjcg%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/CAFab_C9Vn0x87bxxBShySUfcC6mQvxZD%3D_f-ej67eWMhWQ9TQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


NoReverseMatch at /someurlname/ - Reverse for 'htmlname' with arguments '('1',)' not found. 1 pattern(s) tried: ['somehtmlname/$']

2019-01-24 Thread Ivan Martić
Hi all,

i am having issue with url tag, every time i put url tag like --{% url 
'productsgrouping' item.id%}-- i get no reverse error.
Can you help me figure it out on what am i doing wrong?

view:
def productsgrouping_view(request):
queryset = MaterialGroup.objects.all()
context = {"list" : queryset}
return render(request, 'qif/productsgrouping/productsgroup.html', context)

def productsgrouping_update_view(request, url_id):
product_lista = MaterialGroup.objects.get(id=url_id)
product_url_id = ProductgroupinputForm(request.POST or None, 
instance=product_lista)
context1 = {'product_url_id': product_url_id, 'product_lista': 
product_lista}

if product_url_id.is_valid():
product_url_id.save()

return render(request, 'productsgroup-update.html', context1)

url:
urlpatterns = [
path('', views.productsgrouping_view, name='productsgrouping'),
path('update//', views.productsgrouping_update_view, 
name='update_productsgrouping'),
path('new/', views.creategroup_view, name='create_group'),
]

html:
{% extends 'base.html' %}
{% block content %}

{% for item in list %}


{{ item }} - {{item.id}}  
 
{% endfor %}
{% 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/ca1ef95d-166a-40ef-91bc-16f2d704f2ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Environment:


Request Method: GET
Request URL: http://localhost:8000/productsgrouping/

Django Version: 2.1.4
Python Version: 3.7.1
Installed Applications:
['main',
 'abcclass',
 'performance',
 'productsgrouping',
 'vendorsgrouping',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'crispy_forms',
 'multiselectfield',
 'sortedm2m',
 'simple_history']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'simple_history.middleware.HistoryRequestMiddleware']


Template error:
In template C:\Users\martici\QIF\qif\templates\qif\base.html, error at line 8
   Reverse for 'productsgrouping' with arguments '('1',)' not found. 1 
pattern(s) tried: ['productsgrouping/$']
   1 : {% load staticfiles %}
   2 : 
   3 : 
   4 : 
   5 : 
   6 :   
   7 : 
   8 : 
   9 : 
   10 : 
   11 : 
   12 : Carousel Template · Bootstrap
   13 : 
   14 : 
   15 : 
   16 : 
   17 : 
   18 : 

Re: Matching query does not exist

2019-01-18 Thread Ivan Martić
Hi,

im not sure that i understand "specifying your database columns explicitly".
I have connected to existing MSSQL database so i had to adapt my model due
to that. Just copied model from inspectdb and added:
- def __str__
-ForeignKey(class name, on delete=models.CASCADE)xtimes for materialid
and group.

I am not so experience  as you :) but i think you are on the good lead.
I am watching this case :
https://stackoverflow.com/questions/44107021/django-admin-doesnt-display-value
Seems like same issue, same error occured.
What do you think?

pet, 18. sij 2019. u 11:16 Kasper Laudrup  napisao
je:

> Hi Ivan,
>
> On 1/18/19 10:59 AM, Ivan Martić wrote:
> > Thank you Kasper,
> >
>
> You're welcome.
>
> > i have copied that model after doing inspectdb. So it should be set by
> > default from django that way. Usually all was ok..
> > Also, i have tried that  change now and got the same result.
> >
> > Any other idea where i gone wrong?
> >
>
> Sorry, not really. I'm wondering why you are specifying your database
> columns explicitly though? I've never had a need for that, but I'm far
> from being very experienced with Django.
>
> Hopefully someone else can 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/54b11d43-d6c5-dcff-6d3d-29cbeca2ef43%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/CAFab_C-2tbFNeo_JJV7tt8LYPP%3DP%3DKJXbEXjfQuLFEQgMP86-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Matching query does not exist

2019-01-18 Thread Ivan Martić
Thank you Kasper, 

i have copied that model after doing inspectdb. So it should be set by 
default from django that way. Usually all was ok..
Also, i have tried that  change now and got the same result.

Any other idea where i gone wrong?

-- 
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/836e1018-233d-4eb4-9f24-39dd321ce253%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Matching query does not exist

2019-01-18 Thread Ivan Martić
Hi all,
 i am having trouble to get this query on db table right. 
I am always getting error.

Please check shell erorr attached.

I appreciate your 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 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/ca5a10a1-b8ea-4950-89b7-6806a4682ef8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#models

from __future__ import unicode_literals
from django.db import models, connection
from django.utils import timezone
from datetime import date



class Material(models.Model):
id = models.IntegerField(db_column='ID', primary_key=True, blank=False, 
unique=True)
bukrs = models.CharField(db_column='Bukrs', max_length=4)
materialid = models.CharField(db_column='MaterialID', max_length=10)
material_name = models.CharField(db_column='Material_name', max_length=7)

class Meta:
managed = False
db_table = 'Material'

def __str__(self):
return '%s %s %s' % (self.bukrs, self.materialid, self.material_name)


class MaterialGroup(models.Model):
id = models.CharField(db_column='ID', max_length=255, blank=False, 
primary_key=True)
material_group = models.CharField(db_column='Material Group', 
max_length=255, blank=True, null=True)

class Meta:
managed = False
db_table = 'Material Group'

def __str__(self):
return '%s' % (self.material_group)


class Productgroupinput(models.Model):
id = models.IntegerField(db_column='ID', primary_key=True, blank=False, 
unique=True)
bukrs = models.CharField(db_column='Bukrs', max_length=4)
materialid = models.ForeignKey(Material, on_delete=models.CASCADE, 
db_column='Materialid', max_length=10)
material_group = models.ForeignKey(MaterialGroup, on_delete=models.CASCADE, 
db_column='Material_group', max_length=2)

class Meta:
managed = False
db_table = 'ProductGroupInput'

def __str__(self):
return '%s %s %s' % (self.bukrs, self.materialid, self.material_group)>>> from productsgrouping.models import Material, MaterialGroup, 
>>> Productgroupinput
>>> test = Productgroupinput.objects.all()
>>> test
Traceback (most recent call last):
  File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related_des
criptors.py", line 163, in __get__
rel_obj = self.field.get_cached_value(instance)
  File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\mixins.py",
 line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
KeyError: 'materialid'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\query.py",
 line 24
7, in __repr__
return '<%s %r>' % (self.__class__.__name__, data)
  File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\base.py",
 line 503
, in __repr__
return '<%s: %s>' % (self.__class__.__name__, self)
  File "C:\Users\martici\QIF\qif\productsgrouping\models.py", line 45, in 
__str__
return '%s %s %s' % (self.bukrs, self.materialid, self.material_group)
  File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related_des
criptors.py", line 177, in __get__
rel_obj = self.get_object(instance)
  File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related_des
criptors.py", line 144, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
  File 
"C:\Users\martici\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\query.py",
 line 39
9, in get
self.model._meta.object_name
productsgrouping.models.Material.DoesNotExist: Material matching query does not 
exist.>>> query = Material.objects.all()
>>> query
, , , , ]>
>>>

Re: Populate modelform field with username

2019-01-15 Thread Ivan Martić
hvala Nebojša, to je to!!!
Kralj si

uto, 15. sij 2019. u 15:34 Nebojsa Hajdukovic 
napisao je:

> e izvini kao što sam ti rekao bio sam u gužvi, pa sam napamet pisao i
> zaboravio glupost da dodam. Evo ga.
>
> def prepoznaj(request):
> prepoznaj_form = PrepoznajForm(request.POST or None, 
> initial={'supplier_name':request.user})
> if prepoznaj_form.is_valid():
> prepoznaj_form.save()
>
> context = {
> 'prepoznaj_form': prepoznaj_form
> }
>
> return render(request, 'prepoznaj/forma.html', context)
>
>
> уто, 15. јан 2019. у 13:03 Ivan Martić  је
> написао/ла:
>
>> Nema greški ali save ne prolazi..
>>
>> System check identified no issues (0 silenced).
>> January 15, 2019 - 13:01:29
>> Django version 2.1.4, using settings 'qif.settings'
>> Starting development server at http://127.0.0.1:8000/
>> Quit the server with CTRL-BREAK.
>> [15/Jan/2019 13:01:31] "GET / HTTP/1.1" 200 8939
>> [15/Jan/2019 13:01:33] "GET /performance/ HTTP/1.1" 200 14799
>> [15/Jan/2019 13:01:39] "POST /performance/ HTTP/1.1" 200 14811
>>
>> Da li ovi podaci mogu što pomoći?
>>
>> uto, 15. sij 2019. u 12:54 Ivan Martić  napisao
>> je:
>>
>>> Nažalost, iz nekog razloga ne prolazi save ni poruka nakog save...
>>>
>>>
>>> uto, 15. sij 2019. u 12:52 Nebojsa Hajdukovic 
>>> napisao je:
>>>
>>>> view:
>>>> def performance_view(request):
>>>> form = PerformanceForm( {'supplier_name':request.user}  )
>>>> if request.method == "POST":
>>>> form = PerformanceForm[request.POST]
>>>> if form.is_valid():
>>>> form.save()
>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>
>>>> ovako nekako bi trebalo da radi
>>>>
>>>> уто, 15. јан 2019. у 12:49 Ivan Martić  је
>>>> написао/ла:
>>>>
>>>>> Ej hvala ti, puno mi je jasnije.. razumijem da si u gužvi, idem dalje
>>>>> sam pa ako zapnem javim se...
>>>>>
>>>>> 5 Star for support!!
>>>>>
>>>>> uto, 15. sij 2019. u 12:45 Nebojsa Hajdukovic <
>>>>> nebojsa.zero...@gmail.com> napisao je:
>>>>>
>>>>>> moras da dodas
>>>>>> if request.method == "POST"
>>>>>> form = PerformanceForm[request.POST]
>>>>>> izvini sad sam u nekoj bas velikoj guzvi, evo ti otprilike kako sam
>>>>>> ja na drugoj formi uradio, ako ne uspes ispisacu ti malo kasnije
>>>>>> [image: image.png]
>>>>>>
>>>>>> уто, 15. јан 2019. у 12:26 Ivan Martić  је
>>>>>> написао/ла:
>>>>>>
>>>>>>> Bravo! radi!
>>>>>>> Samo što sad neradi spremanje (request.POST)...kako da to sad
>>>>>>> implementiram, jel može savjet?
>>>>>>>
>>>>>>> uto, 15. sij 2019. u 12:22 Nebojsa Hajdukovic <
>>>>>>> nebojsa.zero...@gmail.com> napisao je:
>>>>>>>
>>>>>>>> Obrisi ovo request.post or none
>>>>>>>>
>>>>>>>> uto, 15. jan 2019. 12:19 Ivan Martić  je
>>>>>>>> napisao/la:
>>>>>>>>
>>>>>>>>> Bok Nebojsa,
>>>>>>>>>
>>>>>>>>> hvala ti na brzom odgovoru.
>>>>>>>>> napravio sam ovako i nema promjene
>>>>>>>>>
>>>>>>>>> def performance_view(request):
>>>>>>>>> * form = PerformanceForm(request.POST or None,
>>>>>>>>> {'supplier_name':request.user})*
>>>>>>>>> if form.is_valid():
>>>>>>>>> form.save()
>>>>>>>>> messages.success(request, 'Your entry has been saved. Relevant
>>>>>>>>> persons will be informed of this change.')
>>>>>>>>> #(nevezano za populate) i ovaj message.success mi se isto  javlja
>>>>>>>>> kao problem.. na performance appu mi bilježi login/logout umjesto samo
>>>>>>>>> poruka nakon uspješnog spremanja.
>>>>>>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>>>>>>
>>>>>>>>> Možda mi nešto na 

Re: Populate modelform field with username

2019-01-15 Thread Ivan Martić
Nema greški ali save ne prolazi..

System check identified no issues (0 silenced).
January 15, 2019 - 13:01:29
Django version 2.1.4, using settings 'qif.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[15/Jan/2019 13:01:31] "GET / HTTP/1.1" 200 8939
[15/Jan/2019 13:01:33] "GET /performance/ HTTP/1.1" 200 14799
[15/Jan/2019 13:01:39] "POST /performance/ HTTP/1.1" 200 14811

Da li ovi podaci mogu što pomoći?

uto, 15. sij 2019. u 12:54 Ivan Martić  napisao je:

> Nažalost, iz nekog razloga ne prolazi save ni poruka nakog save...
>
>
> uto, 15. sij 2019. u 12:52 Nebojsa Hajdukovic 
> napisao je:
>
>> view:
>> def performance_view(request):
>> form = PerformanceForm( {'supplier_name':request.user}  )
>> if request.method == "POST":
>> form = PerformanceForm[request.POST]
>> if form.is_valid():
>> form.save()
>> return render(request, 'qif/performance.html', {"form" : form})
>>
>> ovako nekako bi trebalo da radi
>>
>> уто, 15. јан 2019. у 12:49 Ivan Martić  је
>> написао/ла:
>>
>>> Ej hvala ti, puno mi je jasnije.. razumijem da si u gužvi, idem dalje
>>> sam pa ako zapnem javim se...
>>>
>>> 5 Star for support!!
>>>
>>> uto, 15. sij 2019. u 12:45 Nebojsa Hajdukovic 
>>> napisao je:
>>>
>>>> moras da dodas
>>>> if request.method == "POST"
>>>> form = PerformanceForm[request.POST]
>>>> izvini sad sam u nekoj bas velikoj guzvi, evo ti otprilike kako sam ja
>>>> na drugoj formi uradio, ako ne uspes ispisacu ti malo kasnije
>>>> [image: image.png]
>>>>
>>>> уто, 15. јан 2019. у 12:26 Ivan Martić  је
>>>> написао/ла:
>>>>
>>>>> Bravo! radi!
>>>>> Samo što sad neradi spremanje (request.POST)...kako da to sad
>>>>> implementiram, jel može savjet?
>>>>>
>>>>> uto, 15. sij 2019. u 12:22 Nebojsa Hajdukovic <
>>>>> nebojsa.zero...@gmail.com> napisao je:
>>>>>
>>>>>> Obrisi ovo request.post or none
>>>>>>
>>>>>> uto, 15. jan 2019. 12:19 Ivan Martić  je
>>>>>> napisao/la:
>>>>>>
>>>>>>> Bok Nebojsa,
>>>>>>>
>>>>>>> hvala ti na brzom odgovoru.
>>>>>>> napravio sam ovako i nema promjene
>>>>>>>
>>>>>>> def performance_view(request):
>>>>>>> * form = PerformanceForm(request.POST or None,
>>>>>>> {'supplier_name':request.user})*
>>>>>>> if form.is_valid():
>>>>>>> form.save()
>>>>>>> messages.success(request, 'Your entry has been saved. Relevant
>>>>>>> persons will be informed of this change.')
>>>>>>> #(nevezano za populate) i ovaj message.success mi se isto  javlja
>>>>>>> kao problem.. na performance appu mi bilježi login/logout umjesto samo
>>>>>>> poruka nakon uspješnog spremanja.
>>>>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>>>>
>>>>>>> Možda mi nešto na formi nedostaje?
>>>>>>>
>>>>>>> uto, 15. sij 2019. u 11:59 Nebojsa Hajdukovic <
>>>>>>> nebojsa.zero...@gmail.com> napisao je:
>>>>>>>
>>>>>>>> Hey, based on your name I believe u speak our language, so will
>>>>>>>> switch to that : )
>>>>>>>>
>>>>>>>> Ako hoces da na primer supplier_name bude automatski popunjeno kao
>>>>>>>> koristik samo dodaj ovako u views.py:
>>>>>>>> view:
>>>>>>>> def performance_view(request):
>>>>>>>> form = PerformanceForm({'supplier_name':request.user})
>>>>>>>> if form.is_valid():
>>>>>>>> form.save()
>>>>>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>>>>>
>>>>>>>> уто, 15. јан 2019. у 09:51 Ivan Martić  је
>>>>>>>> написао/ла:
>>>>>>>>
>>>>>>>>> Hi all,
>>>>>>>>>
>>>>>>>>> can someone assist me.
>>>>>>>>> I cant get the modelform field get popula

Re: Populate modelform field with username

2019-01-15 Thread Ivan Martić
Nažalost, iz nekog razloga ne prolazi save ni poruka nakog save...


uto, 15. sij 2019. u 12:52 Nebojsa Hajdukovic 
napisao je:

> view:
> def performance_view(request):
> form = PerformanceForm( {'supplier_name':request.user}  )
> if request.method == "POST":
> form = PerformanceForm[request.POST]
> if form.is_valid():
> form.save()
> return render(request, 'qif/performance.html', {"form" : form})
>
> ovako nekako bi trebalo da radi
>
> уто, 15. јан 2019. у 12:49 Ivan Martić  је
> написао/ла:
>
>> Ej hvala ti, puno mi je jasnije.. razumijem da si u gužvi, idem dalje sam
>> pa ako zapnem javim se...
>>
>> 5 Star for support!!
>>
>> uto, 15. sij 2019. u 12:45 Nebojsa Hajdukovic 
>> napisao je:
>>
>>> moras da dodas
>>> if request.method == "POST"
>>> form = PerformanceForm[request.POST]
>>> izvini sad sam u nekoj bas velikoj guzvi, evo ti otprilike kako sam ja
>>> na drugoj formi uradio, ako ne uspes ispisacu ti malo kasnije
>>> [image: image.png]
>>>
>>> уто, 15. јан 2019. у 12:26 Ivan Martić  је
>>> написао/ла:
>>>
>>>> Bravo! radi!
>>>> Samo što sad neradi spremanje (request.POST)...kako da to sad
>>>> implementiram, jel može savjet?
>>>>
>>>> uto, 15. sij 2019. u 12:22 Nebojsa Hajdukovic <
>>>> nebojsa.zero...@gmail.com> napisao je:
>>>>
>>>>> Obrisi ovo request.post or none
>>>>>
>>>>> uto, 15. jan 2019. 12:19 Ivan Martić  je
>>>>> napisao/la:
>>>>>
>>>>>> Bok Nebojsa,
>>>>>>
>>>>>> hvala ti na brzom odgovoru.
>>>>>> napravio sam ovako i nema promjene
>>>>>>
>>>>>> def performance_view(request):
>>>>>> * form = PerformanceForm(request.POST or None,
>>>>>> {'supplier_name':request.user})*
>>>>>> if form.is_valid():
>>>>>> form.save()
>>>>>> messages.success(request, 'Your entry has been saved. Relevant
>>>>>> persons will be informed of this change.')
>>>>>> #(nevezano za populate) i ovaj message.success mi se isto  javlja kao
>>>>>> problem.. na performance appu mi bilježi login/logout umjesto samo poruka
>>>>>> nakon uspješnog spremanja.
>>>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>>>
>>>>>> Možda mi nešto na formi nedostaje?
>>>>>>
>>>>>> uto, 15. sij 2019. u 11:59 Nebojsa Hajdukovic <
>>>>>> nebojsa.zero...@gmail.com> napisao je:
>>>>>>
>>>>>>> Hey, based on your name I believe u speak our language, so will
>>>>>>> switch to that : )
>>>>>>>
>>>>>>> Ako hoces da na primer supplier_name bude automatski popunjeno kao
>>>>>>> koristik samo dodaj ovako u views.py:
>>>>>>> view:
>>>>>>> def performance_view(request):
>>>>>>> form = PerformanceForm({'supplier_name':request.user})
>>>>>>> if form.is_valid():
>>>>>>> form.save()
>>>>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>>>>
>>>>>>> уто, 15. јан 2019. у 09:51 Ivan Martić  је
>>>>>>> написао/ла:
>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> can someone assist me.
>>>>>>>> I cant get the modelform field get populated with active username.
>>>>>>>>
>>>>>>>> Does any one have a good advice?
>>>>>>>>
>>>>>>>> view:
>>>>>>>> def performance_view(request):
>>>>>>>> form = PerformanceForm(request.POST or None)
>>>>>>>> if form.is_valid():
>>>>>>>> form.save()
>>>>>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>>>>>
>>>>>>>> forms:
>>>>>>>> from django import forms
>>>>>>>> from .models import Performance
>>>>>>>>
>>>>>>>>
>>>>>>>> class PerformanceForm(forms.ModelForm):
>>>>>>>&

Re: Populate modelform field with username

2019-01-15 Thread Ivan Martić
Ej hvala ti, puno mi je jasnije.. razumijem da si u gužvi, idem dalje sam
pa ako zapnem javim se...

5 Star for support!!

uto, 15. sij 2019. u 12:45 Nebojsa Hajdukovic 
napisao je:

> moras da dodas
> if request.method == "POST"
> form = PerformanceForm[request.POST]
> izvini sad sam u nekoj bas velikoj guzvi, evo ti otprilike kako sam ja na
> drugoj formi uradio, ako ne uspes ispisacu ti malo kasnije
> [image: image.png]
>
> уто, 15. јан 2019. у 12:26 Ivan Martić  је
> написао/ла:
>
>> Bravo! radi!
>> Samo što sad neradi spremanje (request.POST)...kako da to sad
>> implementiram, jel može savjet?
>>
>> uto, 15. sij 2019. u 12:22 Nebojsa Hajdukovic 
>> napisao je:
>>
>>> Obrisi ovo request.post or none
>>>
>>> uto, 15. jan 2019. 12:19 Ivan Martić  je
>>> napisao/la:
>>>
>>>> Bok Nebojsa,
>>>>
>>>> hvala ti na brzom odgovoru.
>>>> napravio sam ovako i nema promjene
>>>>
>>>> def performance_view(request):
>>>> * form = PerformanceForm(request.POST or None,
>>>> {'supplier_name':request.user})*
>>>> if form.is_valid():
>>>> form.save()
>>>> messages.success(request, 'Your entry has been saved. Relevant persons
>>>> will be informed of this change.')
>>>> #(nevezano za populate) i ovaj message.success mi se isto  javlja kao
>>>> problem.. na performance appu mi bilježi login/logout umjesto samo poruka
>>>> nakon uspješnog spremanja.
>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>
>>>> Možda mi nešto na formi nedostaje?
>>>>
>>>> uto, 15. sij 2019. u 11:59 Nebojsa Hajdukovic <
>>>> nebojsa.zero...@gmail.com> napisao je:
>>>>
>>>>> Hey, based on your name I believe u speak our language, so will switch
>>>>> to that : )
>>>>>
>>>>> Ako hoces da na primer supplier_name bude automatski popunjeno kao
>>>>> koristik samo dodaj ovako u views.py:
>>>>> view:
>>>>> def performance_view(request):
>>>>> form = PerformanceForm({'supplier_name':request.user})
>>>>> if form.is_valid():
>>>>> form.save()
>>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>>
>>>>> уто, 15. јан 2019. у 09:51 Ivan Martić  је
>>>>> написао/ла:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> can someone assist me.
>>>>>> I cant get the modelform field get populated with active username.
>>>>>>
>>>>>> Does any one have a good advice?
>>>>>>
>>>>>> view:
>>>>>> def performance_view(request):
>>>>>> form = PerformanceForm(request.POST or None)
>>>>>> if form.is_valid():
>>>>>> form.save()
>>>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>>>
>>>>>> forms:
>>>>>> from django import forms
>>>>>> from .models import Performance
>>>>>>
>>>>>>
>>>>>> class PerformanceForm(forms.ModelForm):
>>>>>> class Meta:
>>>>>> model = Performance
>>>>>> fields = [
>>>>>> 'supplier_name',
>>>>>> 'deliverability',
>>>>>> 'rating',
>>>>>> 'rated_by',
>>>>>> 'date_of_entry'
>>>>>> ]
>>>>>>
>>>>>> def __init__(self, rated_by, *args, **kwargs):
>>>>>> super(PerformanceForm, self).__init__(*args, **kwargs)
>>>>>> self.fields["rated_by"].initial = rated_by
>>>>>>
>>>>>> what am i missing..
>>>>>> 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 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 discussi

Re: Populate modelform field with username

2019-01-15 Thread Ivan Martić
Bravo! radi!
Samo što sad neradi spremanje (request.POST)...kako da to sad
implementiram, jel može savjet?

uto, 15. sij 2019. u 12:22 Nebojsa Hajdukovic 
napisao je:

> Obrisi ovo request.post or none
>
> uto, 15. jan 2019. 12:19 Ivan Martić  je
> napisao/la:
>
>> Bok Nebojsa,
>>
>> hvala ti na brzom odgovoru.
>> napravio sam ovako i nema promjene
>>
>> def performance_view(request):
>> * form = PerformanceForm(request.POST or None,
>> {'supplier_name':request.user})*
>> if form.is_valid():
>> form.save()
>> messages.success(request, 'Your entry has been saved. Relevant persons
>> will be informed of this change.')
>> #(nevezano za populate) i ovaj message.success mi se isto  javlja kao
>> problem.. na performance appu mi bilježi login/logout umjesto samo poruka
>> nakon uspješnog spremanja.
>> return render(request, 'qif/performance.html', {"form" : form})
>>
>> Možda mi nešto na formi nedostaje?
>>
>> uto, 15. sij 2019. u 11:59 Nebojsa Hajdukovic 
>> napisao je:
>>
>>> Hey, based on your name I believe u speak our language, so will switch
>>> to that : )
>>>
>>> Ako hoces da na primer supplier_name bude automatski popunjeno kao
>>> koristik samo dodaj ovako u views.py:
>>> view:
>>> def performance_view(request):
>>> form = PerformanceForm({'supplier_name':request.user})
>>> if form.is_valid():
>>> form.save()
>>> return render(request, 'qif/performance.html', {"form" : form})
>>>
>>> уто, 15. јан 2019. у 09:51 Ivan Martić  је
>>> написао/ла:
>>>
>>>> Hi all,
>>>>
>>>> can someone assist me.
>>>> I cant get the modelform field get populated with active username.
>>>>
>>>> Does any one have a good advice?
>>>>
>>>> view:
>>>> def performance_view(request):
>>>> form = PerformanceForm(request.POST or None)
>>>> if form.is_valid():
>>>> form.save()
>>>> return render(request, 'qif/performance.html', {"form" : form})
>>>>
>>>> forms:
>>>> from django import forms
>>>> from .models import Performance
>>>>
>>>>
>>>> class PerformanceForm(forms.ModelForm):
>>>> class Meta:
>>>> model = Performance
>>>> fields = [
>>>> 'supplier_name',
>>>> 'deliverability',
>>>> 'rating',
>>>> 'rated_by',
>>>> 'date_of_entry'
>>>> ]
>>>>
>>>> def __init__(self, rated_by, *args, **kwargs):
>>>> super(PerformanceForm, self).__init__(*args, **kwargs)
>>>> self.fields["rated_by"].initial = rated_by
>>>>
>>>> what am i missing..
>>>> 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 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/df4ca182-fb48-4a27-a2a0-a9b20f0e6a21%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/df4ca182-fb48-4a27-a2a0-a9b20f0e6a21%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/CAJ60hW2jg6rAeHtX-dW8KJj3dVK5DRsYDWCT0f0eh9-tJKqTBQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAJ60hW2jg6rAeHtX-dW8KJj3dVK5DRsYDWCT0f0eh9-tJKqTBQ%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout

Re: Populate modelform field with username

2019-01-15 Thread Ivan Martić
Bok Nebojsa,

hvala ti na brzom odgovoru.
napravio sam ovako i nema promjene

def performance_view(request):
* form = PerformanceForm(request.POST or None,
{'supplier_name':request.user})*
if form.is_valid():
form.save()
messages.success(request, 'Your entry has been saved. Relevant persons will
be informed of this change.')
#(nevezano za populate) i ovaj message.success mi se isto  javlja kao
problem.. na performance appu mi bilježi login/logout umjesto samo poruka
nakon uspješnog spremanja.
return render(request, 'qif/performance.html', {"form" : form})

Možda mi nešto na formi nedostaje?

uto, 15. sij 2019. u 11:59 Nebojsa Hajdukovic 
napisao je:

> Hey, based on your name I believe u speak our language, so will switch to
> that : )
>
> Ako hoces da na primer supplier_name bude automatski popunjeno kao
> koristik samo dodaj ovako u views.py:
> view:
> def performance_view(request):
> form = PerformanceForm({'supplier_name':request.user})
> if form.is_valid():
> form.save()
> return render(request, 'qif/performance.html', {"form" : form})
>
> уто, 15. јан 2019. у 09:51 Ivan Martić  је
> написао/ла:
>
>> Hi all,
>>
>> can someone assist me.
>> I cant get the modelform field get populated with active username.
>>
>> Does any one have a good advice?
>>
>> view:
>> def performance_view(request):
>> form = PerformanceForm(request.POST or None)
>> if form.is_valid():
>> form.save()
>> return render(request, 'qif/performance.html', {"form" : form})
>>
>> forms:
>> from django import forms
>> from .models import Performance
>>
>>
>> class PerformanceForm(forms.ModelForm):
>> class Meta:
>> model = Performance
>> fields = [
>> 'supplier_name',
>> 'deliverability',
>> 'rating',
>> 'rated_by',
>> 'date_of_entry'
>> ]
>>
>> def __init__(self, rated_by, *args, **kwargs):
>> super(PerformanceForm, self).__init__(*args, **kwargs)
>> self.fields["rated_by"].initial = rated_by
>>
>> what am i missing..
>> 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 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/df4ca182-fb48-4a27-a2a0-a9b20f0e6a21%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/df4ca182-fb48-4a27-a2a0-a9b20f0e6a21%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/CAJ60hW2jg6rAeHtX-dW8KJj3dVK5DRsYDWCT0f0eh9-tJKqTBQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJ60hW2jg6rAeHtX-dW8KJj3dVK5DRsYDWCT0f0eh9-tJKqTBQ%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/CAFab_C_iOye2LahEJxOArPPqyEaqEFcM_H%2B2MrDeRXHbTaYGYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Populate modelform field with username

2019-01-15 Thread Ivan Martić
Hi all,

can someone assist me.
I cant get the modelform field get populated with active username.

Does any one have a good advice?

view:
def performance_view(request):
form = PerformanceForm(request.POST or None) 
if form.is_valid():
form.save()
return render(request, 'qif/performance.html', {"form" : form})

forms:
from django import forms
from .models import Performance


class PerformanceForm(forms.ModelForm):
class Meta:
model = Performance
fields = [
'supplier_name', 
'deliverability', 
'rating', 
'rated_by', 
'date_of_entry'
]

def __init__(self, rated_by, *args, **kwargs):
super(PerformanceForm, self).__init__(*args, **kwargs)
self.fields["rated_by"].initial = rated_by

what am i missing..
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 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/df4ca182-fb48-4a27-a2a0-a9b20f0e6a21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ms sql server connectivity to django

2019-01-07 Thread Ivan Martić
Hi mate,

I had the same issue with MS SQL.

This worked for me:
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'HOST': 'xxx',
'PORT': '1433',

'USER': 'xxx',
'PASSWORD': 'xxx',
'NAME': 'xx',#table name
'CONN_MAX_AGE': 0,
'AUTOCOMMIT': True,

'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
'host_is_server': True,
'autocommit': True,
'driver_needs_utf8': True,
'use_legacy_date_fields' : True,
},
}
}

You need to have pyodbc azure installed.

GL,
Ivan

-- 
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/7b00ad3b-8964-4b39-9eaa-4a204f45eb92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ms sql server connectivity to django

2019-01-07 Thread Ivan Martić
Hi Mate,

I had the same issues with connecting to MS SQL.
This is the configuration which worked for me...

DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'HOST': 'XXX',
'PORT': '1433',

'USER': 'XXX',
'PASSWORD': 'XXX',
'NAME': 'XXX', #name of your table
'CONN_MAX_AGE': 0,
'AUTOCOMMIT': True,

'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
'host_is_server': True,
'autocommit': True,
'driver_needs_utf8': True,
'use_legacy_date_fields' : True,
},
}
}
You need to have pyodbc installed.

BR,
Ivan

On Sunday, January 6, 2019 at 6:56:09 PM UTC+1, Praveen Kumar wrote:
>
> Hi All,
>
> Changed DATABASE code as under in setting.py in Django project. But not 
> getting able to connect to MS SQL Server. Please suggest.
>
> ATABASES = {
> 'default': {
> 'NAME': 'APJ_AIM_LITE',
> 'ENGINE': 'sqlserver_ado',
> 'HOST': 'DB_SERVER',
> 'USER': '',
> 'PASSWORD': '',
> }
> }
>

-- 
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/c8366067-faf8-426a-b6d1-3b0e37a35e15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.