Re: facing issue on unit test

2019-09-08 Thread Arulselvam K
Thanks!, So for each test , do i need to add same test data? or do we have 
any other way not to repeat the same test data?

On Tuesday, 13 August 2019 20:32:16 UTC+5:30, Vinicius Assef wrote:
>
> The database is cleared after each test method.
>
> So, in a new testcase your database is empty.
>
> On Tue, 13 Aug 2019 at 00:34, Arulselvam K  > wrote:
>
>> Have hosted the code @ "https://github.com/tbone230590/plib; 
>> Here is the problem I have two models Book and IssuedBook, IssuedBook 
>> have foreign key relation to Book object.Those models are defined @ 
>> "/api/data/models" I have unit tests for testing those models and are 
>> available @ "/api/unit_tests/models". 
>> I am able to test Book model successfully. But I have a test for 
>> IssuedBook model which is referring Book model is getting failed. 
>> It seems cause of the problem is referring Book object created in 
>> BookTestCase that was previously run. But I dont understand that why Book 
>> record getting deleted after first testcase execution.
>> Could you educate me on this to solve the problem?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3bd0af6e-7e6d-4115-9c95-f92c4d9ca60d%40googlegroups.com.


Managing links on static files from a static file

2019-09-08 Thread Михаил Брунман
Good daytime.
I've spent some time trying to find a solution to my problem, but I still 
can't.
Here is my problem.
One of my html templates has a link on a javascript file, looking similar 
to this:

The page is returned, when asking the next url:
http://127.0.0.1:8000/app_name/page_name/
The mode is Debug, the static is registered and turned on and the script 
itself is loaded quite successfully.
But the script is a part of a complete project and it contains some 
references on other .js and .css files from that project, that are also 
store locally.
And when script is loading and requesting that other files, the server 
respond with 404 "Not found", because their references are relative and 
become like this:
http://127.0.0.1:8000/app_name/page_name/file_relative_path
instead of
/static/file_relative_path
So is there a way to translate such links from a page-relative link to a 
static-relative link?


Best wishes, Mikhail

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/74c4d0f3-7056-4d67-988c-cafd9e7b0570%40googlegroups.com.


Re: Python +django

2019-09-08 Thread Jani Tiainen
Hi.

You're on good track.

Using Django doesn't require much but knowing Python, HTML and CSS surely
helps.

Django Girls do have excellent tutorial to get you kickstarted with Django.

CSS can be easily handled with libs like bootstrap or material ui.

What comes to programmin itself it takes a good while to learn. Few months
and you will handle most tasks with rather easily.

su 8. syysk. 2019 klo 21.09 kemo0 king  kirjoitti:

> I am new on programming  ,to be a programmer and getting the ability to
> create a web program that is one of my dreams , I have started   with
> python  I know little about html and css and js now I want to learn django
> am I on the right  way what should I learn before diving in django  I need
> ur help
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/69cfa675-0023-464b-a4ad-080f4c59db4d%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91od6KXyi28tE55TuuRvZvDaibH5H3xS5Q6%2BTHavby20iRw%40mail.gmail.com.


Re: Python +django

2019-09-08 Thread Devdutt Bhati
https://www.youtube.com/watch?v=q6qE_uJB59c=PLd3UqWTnYXOnkicyzePnIg8rc2qEXgjiF

learn this videos first and after learn django get some knowledge  about
python.


I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sun, Sep 8, 2019 at 11:08 AM kemo0 king  wrote:

> I am new on programming  ,to be a programmer and getting the ability to
> create a web program that is one of my dreams , I have started   with
> python  I know little about html and css and js now I want to learn django
> am I on the right  way what should I learn before diving in django  I need
> ur help
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/69cfa675-0023-464b-a4ad-080f4c59db4d%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP1z-%3D%2B_h0x%3D_YvjFukMZ%3Dd7REROhONCw3Rv6cb9FdffdN%2B1Fg%40mail.gmail.com.


Python +django

2019-09-08 Thread kemo0 king
I am new on programming  ,to be a programmer and getting the ability to 
create a web program that is one of my dreams , I have started   with 
python  I know little about html and css and js now I want to learn django 
am I on the right  way what should I learn before diving in django  I need 
ur help  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/69cfa675-0023-464b-a4ad-080f4c59db4d%40googlegroups.com.


Re: how to pass user input into raw sql query ?

2019-09-08 Thread testdevleb
Sent from my Samsung Galaxy smartphone.
I tried daniel solution and this was right.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5d751fca.1c69fb81.8be36.2078%40mx.google.com.


Data on Popup

2019-09-08 Thread nitin kumar
How to popup unique id of recently saved data.
I get the data by 
 data = Class(##inserting value into table)
data.save()
data.id


But how to print this is on popup

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/88bd1632-60a1-4cfb-ab72-256679a6ff93%40googlegroups.com.


Writing a text file from Form input

2019-09-08 Thread Michal Pavliš
Hello, so i'm writing a program that uploads invoices to an accounting 
webapp based on order info from Wordpress. 

At one point, the code takes an order number, fetches order data using the 
WP REST API and is supposed to write a .txt file in a specified location 
containing mentioned order data.

All of the files are stored in the same app directory. 

app>
ikros_faktury (folder)>
  orders.txt
all of the .py files



*After submitting the form data i get an error:* 

FileNotFoundError at /faktury/ [Errno 2] 
No such file or directory: 'ikros_faktury/7079.txt'

You can see more of the error message* here 
*

*Here are my files:*

*views.py*
def faktury(request):
if request.method == 'POST':
form = InvoiceForm(request.POST)
if form.is_valid():
invoices_to_do = form.cleaned_data.get('orders')
do_done = form.cleaned_data.get('Zmeniť_stav_objednávky_na_Vybavené')

invoices_to_do_parsed = invoices_to_do.split(', ')
errors = []

for i in invoices_to_do_parsed:
add_invoice(i)
else:
form = InvoiceForm()
return render(request, 'invoices/faktury.html', 
{'title':'FAKTÚRY','form':form})

*forms.py*
class InvoiceForm(forms.Form):
orders = forms.CharField()
Zmeniť_stav_objednávky_na_Vybavené = forms.BooleanField(required=False)

class Meta:
fields = ['orders', 'mark_as_done']

*urls.py*
urlpatterns = [
path('', views.faktury, name='invoices')
]


*here is the function where it should handle all the data:*
def add_invoice(cislo_objednavky):
#definuje casy pre fakturu
now = datetime.now()
after_seven_days = datetime.now() + timedelta(days=14) 
completion_date = now.strftime("%Y-%m-%dT%H:%M:%S")
end_date = after_seven_days.strftime("%Y-%m-%dT%H:%M:%S")

#defining directories
direct = "ikros_faktury/"
direct_produkty = "ikros_faktury/produkty/"

#fetches wordpress data
kniznica = 
requests.get('http://cryformercy.eu/wp-json/wc/v3/orders/'+str(cislo_objednavky),
 
auth=HTTPBasicAuth('username', 'password'))
data = kniznica.json()

obj_c = cislo_objednavky
sposob_platby = ''
produkty = data['line_items']

#checkes payment method
if data['payment_method'] == 'cod':
sposob_platby= 'paymentType_Dobierka\nclosingText_'
else:
sposob_platby= 'paymentType_Bankový prevod\nclosingText_Faktúra uhradená.'

#checks country
if data['shipping']['country'] == 'SK':
stat_na_fakture = 'Slovensko'
mena = 'EUR'
suma_var = data['shipping_total']
elif data['shipping']['country'] == 'CZ':
stat_na_fakture = 'Česká republika'
mena = 'EUR'

#defines tottal COD
suma_var = data['shipping_total']
suma_dobierky = {'name':'Dobierka',
'totalPriceWithVat':suma_var,
'unitPriceWithVat':suma_var,
'measureType':'ks',
'vat':'0'}

#looks for product variables
hladam_farbu = data['line_items'][0]['meta_data']
ma_farbu = ''
for i in hladam_farbu:
if i['key'] == 'farba':
ma_farbu = ', ' + i['value']
else:
pass

#creates files 'ordernum.txt' -> uses the same keys as acounting app
with open(direct+f"{obj_c}.txt", "w") as f:   *<-* *this is where 
is is supposed to create the and write the file, but doesn't*
f.write('documentNumber_\n'
'clientName_'+ data['shipping']['first_name'] + ' ' + 
data['shipping']['last_name'] + '\n' 
'clientStreet_'+ data['shipping']['address_1'] + '\n'
'clientPostCode_'+ str(data['shipping']['postcode']) + '\n'
'clientTown_'+ data['shipping']['city'] + '\n'
'clientCountry_'+ stat_na_fakture + '\n'
'orderNumber_'+ str(cislo_objednavky) + '\n'
'totalPrice_'+ str(data['total']) + '\n'
'totalPriceWithVat_' + str(data['total']) + '\n'
'createDate_'+ str(now) + '\n'
'dueDate_' + str(end_date) + '\n'
'completionDate_' + str(now) + '\n'
'currency_' + mena + '\n'
'deliveryType_Dobierka\n'
f'{sposob_platby}'
)


Any help would be greatly appreciated. 
Thanks alot,
Mike.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4013af00-c8c4-4ed6-b734-5b74d6191454%40googlegroups.com.


Re: Page 404 - No Job matches the given query.

2019-09-08 Thread Kean
access a given URL

On 7 Sep 2019, at 21:46, Mclaren Sunday  wrote:

> What are you trying to do?
> 
> On Sat, 7 Sep 2019 20:30 Kean,  wrote:
> Hi,
> 
> New to Django, Have an issue. the table exists and the view references the 
> table however, I still get 404 message.
> I have spent 8 hours trying to resolve, nothing seems to work, please help?
> 
> urls.py
> 
>  path('businesslogin/businessadmin/busproject',
>  views.project_detail, name='project_detail'),
> 
> models.py
> 
> class Job(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
> 
> def __str__(self):
> return(self.name)
> 
> 
> class Category(models.Model):
> project = models.ForeignKey(
> Job, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
> 
> def __str__(self):
> return(self.project)
> 
> class Expense(models.Model):
> project = models.ForeignKey(
> Job, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
> 
> def __str__(self):
> return(self.project)
> 
> views.py
> 
> def project_detail(request):
> project = get_object_or_404(Job)
> return render(request, 'projectdetail.html', {'project': project, 
> 'expense_list': project.expenses.all()})
> 
> 
> Error message:
> 
> Page not found (404)
> Request Method:   GET
> Request URL:  http://127.0.0.1:8000/businesslogin/businessadmin/busproject
> Raised by:core.views.project_detail
> No Job matches the given query.
> 
> 
> 
> 
> 
> 
> 
> Please can anyone help, with getting the url to connect and resolving this 
> error?
> 
> 
> 
> Best 
> 
> 
> 
> Kean
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/0c13a01b-ff4f-4c59-9f9c-d8805b1d2ef8%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAPm7yyWW0kecfF3Rfu8tYnwfR5FtStj%3D9FWHLfjXQUCVth9WPg%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/09347CDD-59ED-47AA-8729-F2839699BC68%40gmail.com.