Update data instead of creating a new row entry in django model

2018-08-26 Thread Joel Mathew
I have a page for editing existing data from a model.

The model:

class billitem(models.Model):
code = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
description = models.CharField(max_length=60, null=True)
price = models.DecimalField(decimal_places=2, max_digits=8)

The form:

class BillItem(forms.Form):
code = forms.IntegerField(max_value=10, disabled=True)
name = forms.CharField(label='Item Name', max_length=32)
description = forms.CharField(
label='Description', max_length=57, required=False)
price = forms.DecimalField(decimal_places=2, max_digits=8)

The view is:

def edit_bill_item(request, itemcode):
if request.method == 'POST':
form = BillItem(request.POST)
code = request.POST.get('code')
name = request.POST.get('name').title()
description = request.POST.get('description')
price = request.POST.get('price')
billitem.objects.filter(code=code).update(
name=name, description=description, price=price)
msg = 'Successfully saved Billing item.'
# form = BillItem(request.POST)
return render(request, 'billing/edititem.html', {'form':
form, 'msg': msg})
else:
itemcode = int(itemcode)
item = get_object_or_404(billitem, code=itemcode)
form = BillItem(initial={
'code': item.code,
'name': item.name,
'description': item.description,
'price': item.price
})
return render(request, 'billing/edititem.html', {'form': form})

The problem is that every time POST is submitted, another entry gets
added in the table, with a new code, instead of updating existing row.

I also tried:

item = billitem(code=code, name=name, description=description, price=price)
item.save()

Which also had the same effect.
How can I handle updation of existing data only within my model and form.

-- 
You received this message because you are 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/CAA%3Diw_8pzmdTOOXFtNmpvF3tFU5fVNKppXPgpJRxTUN%2BwW70dQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Update the django project from local to production

2018-08-26 Thread Mikhailo Keda
Check the documentation 
- https://docs.djangoproject.com/en/2.1/howto/deployment/

субота, 25 серпня 2018 р. 12:35:20 UTC+3 користувач Kamal Sharma написав:
>
> Hey,
> How i have deployed my django project to my VPS and now i have done some 
> change in my local django project and want to update on production server. 
> How can i do that.?
> please help me 
> Thanks
>
> Kamal Sharma
>

-- 
You received this message because you are 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/880241ea-63cc-457f-b3cb-5a16fbf2c64a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Geographical location filter app in Django

2018-08-26 Thread Benjamin Smith
Okay. Thank you for your insight.

On Thu, Aug 23, 2018 at 3:06 PM Christian Ledermann <
christian.lederm...@gmail.com> wrote:

> Go with geo django, postgis will accelerate these kind of lookups with
> indices.
>
> https://stackoverflow.com/questions/19703975/django-sort-by-distance/35896358#35896358
>
> On Thu, 23 Aug 2018 at 09:04, Benjamin Smith 
> wrote:
>
>> I would like to create a market place like app with Djano as the backend
>> server, where users can buy/sell items. In the app I would like have to a
>> feature related to geographic region of a user. Such as, to filter out
>> items in a given specific miles of radius.
>>
>> Example use case:
>>
>>- User uploads an item, get the gps cordinates from their mobile and
>>store in db.
>>- User can search item, also filter to only get items in X miles
>>radius.
>>
>>
>> For this feature
>>
>>1. I have looked at GeoDjango. But it seems like I need to extend the
>>postgresql database to use it, also by using the postgis engine.
>>2. I have also looked at the Haversine formula for nearby queries.
>>3. There is also an option for multiple database support.
>>
>>
>> But I have some initial doubts before proceeding and your insights would
>> really help me alot. Could you please help me with this queries:
>>
>>1. I will have to store user data and some other data including the
>>geo location. Will there be any difference/side effects between
>>postgresql_psycopg2 and postgis, to store all the data in one single db?
>>2. For my simple use case would you rather prefer to go with the
>>Haversine formula? Or integrating GeoDjango will help me lot in the 
>> future?
>>3. Or having a multiple database support be better for me or it will
>>be an over head?
>>
>> --
>> You received this message because you are 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/CAM4YLW%2B%2BOS%2B6JqJW5Bs211FHAHo3n6F9sHW0B%2BeN%3DPE4OEGR9g%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Newark-on-Trent - UK
> Mobile : +44 7474997517
>
> https://uk.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>
> --
> You received this message because you are 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/CABCjzWp8hxN0JbdSqk8-c18ZaV_7GCSukOpt-31MeZBK5DhgGA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Error during GeoDjango tutorial documentaion

2018-08-26 Thread Benjamin Smith
I am going through the GeoDjango tutorial from the official documentation.

   1. I have installed the required geospatial libraries, installed and
   enabled spatial functionality by extending the PostgreSQL via postgis.
   2. Downloaded the world borders data, and have unzipped the data.
   3. Created a GeoDjango model (WorldBorder) in the world app.
   4. Created the load.py inside the world app, as instructed in the
   documentation.

But when I try to import the *load* module and call the *run* routine, I am
getting an error:

  Failed to save the feature (id: 141) into the model with the keyword
> arguments:
>   Traceback (most recent call last):
> File
> "/home/vagrant/.virtualenvs/testenv/lib/python3.6/site-packages/django/contrib/gis/utils/layermapping.py",
> line 577, in _save
>   stream.write('%s: %s\n' % ('Updated' if is_update else 'Saved', m))
>   UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 7-8: ordinal not in range(128)
>   During handling of the above exception, another exception occurred:
>   Traceback (most recent call last):
> File "", line 1, in 
> File "/vagrant/geo_project/world/load.py", line 30, in run
>   lm.save(strict=True, verbose=verbose)
> File
> "/home/vagrant/.virtualenvs/testenv/lib/python3.6/site-packages/django/contrib/gis/utils/layermapping.py",
> line 627, in save
>   _save()
> File "/usr/lib/python3.6/contextlib.py", line 52, in inner
>   return func(*args, **kwds)
> File
> "/home/vagrant/.virtualenvs/testenv/lib/python3.6/site-packages/django/contrib/gis/utils/layermapping.py",
> line 586, in _save
>   stream.write('%s\n' % kwargs)
>   UnicodeEncodeError: 'ascii' codec can't encode character '\xc3' in
> position 62: ordinal not in range(128)


I cannot figure out where I am wrong. Could you please help me out? Thank
you.

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


Re: Django database problem

2018-08-26 Thread Mikko Meronen
Hi,

Thanks for advice ^^

I have one new concern. Is there a limit for for Django model IDs?

Now I have automated the data insert with python code loop, but the
ID-number is not consecutive. It jumps for example from ...56 to 571... and
from ...587 to 3763... and so forth.

Do you know why it is doing that?

I'm not using django custom command (if that makes the difference or can be
used for my case, I will get familiar with it a bit later), I'm just
inserting the data to django's database with separate python code.

-Mikko

ma 20. elok. 2018 klo 20.41 Jani Tiainen (rede...@gmail.com) kirjoitti:

> Hi,
>
> Instead of doing everything by hand I would recommend doing a custom
> management command in Django.
>
> Because management commands live inside Django ecosystem you get full
> benefits of Django. Migrations to setup database tables from model
> definitions. Models and ORM to interact with database. (Model)forms to
> validate your incoming data etc.
>
> Also I really suggest that you do the official tutorial from the docs to
> get hang of basic django concepts.
>
> ma 20. elok. 2018 klo 19.59 Mikko Meronen 
> kirjoitti:
>
>> Hi and thanks for your help.
>>
>> I have tried postgress and now I have a problem using it. Here's my code
>> following an error. I appreciate any help.
>>
>> def do():
>> x = 1
>> while x == 1:
>> create_table()
>> print('finding data')
>> find_data()
>> time.sleep(120)
>>
>> def create_table():
>> c.execute('CREATE TABLE IF NOT EXISTS testi(url TEXT, title TEXT,
>> published TEXT, UNIQUE(url))')
>>
>> def find_data():
>> r = requests.get(homepage)
>> soup = BeautifulSoup(r.text, 'html.parser')
>> results = soup.find_all('data')
>> for result in results:
>> title = result.find('h1').text
>> url = result.find('a')['href']
>> published = result.find('time')['datetime']
>>
>>
>> c.execute("INSERT OR IGNORE INTO testi (url, title,
>> published) VALUES (%s, %s, %s)",
>>   ('url', 'title', 'published'))
>> connection.commit()
>>
>>
>> do()
>>
>> ERROR:
>>
>> Traceback (most recent call last):
>>   File "C:\Users\Mikko\django-project\top\datas\dataTESTI.py", line 43,
>> in 
>> do()
>>   File "C:\Users\Mikko\django-project\top\datas\dataTESTI.py", line 21,
>> in do
>> find_data()
>>   File "C:\Users\Mikko\django-project\top\datas\dataTESTI.py", line 39,
>> in find_data
>> ('url', 'title', 'published'))
>> *psycopg2.ProgrammingError: syntax error at or near "OR"*
>> *LINE 1: INSERT OR IGNORE INTO testi (url, title, published) VALUES (...*
>>
>>
>>
>> -Mikko
>>
>>
>> 2018-08-17 19:09 GMT+03:00 Mikhailo Keda :
>>
>>> You could generate models from sqlite database -
>>> https://docs.djangoproject.com/en/2.1/howto/legacy-databases/
>>> Than switch to PostgresQL
>>>
>>> --
>>> You received this message because you are 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/52f5c754-7310-4baa-8008-edbcea15eafb%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAGD0jjJof7v9nMPF593DJiQHRv6z_%3DmQ_ZtQWob47PBT1gvL9Q%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHn91oex8cAE1yFshSABt9QZpdiiRVtALtLx0AWDNU84w0%2Bqvw%40mail

Re: Error during GeoDjango tutorial documentaion

2018-08-26 Thread Benjamin Smith
I am using these version:

gdal-bin v2.2.3+dfsg-2

Python v3.6.5
Django v2.1
psycopg2 v2.7.5
postgis v2.4.3+dfsg-4

On Sun, Aug 26, 2018 at 3:45 PM Benjamin Smith 
wrote:

> I am going through the GeoDjango tutorial from the official documentation.
>
>1. I have installed the required geospatial libraries, installed and
>enabled spatial functionality by extending the PostgreSQL via postgis.
>2. Downloaded the world borders data, and have unzipped the data.
>3. Created a GeoDjango model (WorldBorder) in the world app.
>4. Created the load.py inside the world app, as instructed in the
>documentation.
>
> But when I try to import the *load* module and call the *run* routine, I
> am getting an error:
>
>   Failed to save the feature (id: 141) into the model with the keyword
>> arguments:
>>   Traceback (most recent call last):
>> File
>> "/home/vagrant/.virtualenvs/testenv/lib/python3.6/site-packages/django/contrib/gis/utils/layermapping.py",
>> line 577, in _save
>>   stream.write('%s: %s\n' % ('Updated' if is_update else 'Saved', m))
>>   UnicodeEncodeError: 'ascii' codec can't encode characters in position
>> 7-8: ordinal not in range(128)
>>   During handling of the above exception, another exception occurred:
>>   Traceback (most recent call last):
>> File "", line 1, in 
>> File "/vagrant/geo_project/world/load.py", line 30, in run
>>   lm.save(strict=True, verbose=verbose)
>> File
>> "/home/vagrant/.virtualenvs/testenv/lib/python3.6/site-packages/django/contrib/gis/utils/layermapping.py",
>> line 627, in save
>>   _save()
>> File "/usr/lib/python3.6/contextlib.py", line 52, in inner
>>   return func(*args, **kwds)
>> File
>> "/home/vagrant/.virtualenvs/testenv/lib/python3.6/site-packages/django/contrib/gis/utils/layermapping.py",
>> line 586, in _save
>>   stream.write('%s\n' % kwargs)
>>   UnicodeEncodeError: 'ascii' codec can't encode character '\xc3' in
>> position 62: ordinal not in range(128)
>
>
> I cannot figure out where I am wrong. Could you please help me out? Thank
> you.
>

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


Re: Error during GeoDjango tutorial documentaion

2018-08-26 Thread Jason
this might be related:  
https://groups.google.com/forum/#!topic/geodjango/Imkq2DDI7qg

-- 
You received this message because you are 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/94e6dc8f-ddb3-464a-be35-3bcc526cf5cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django database problem

2018-08-26 Thread Jason
yeah, there is a limit, and its set by the data type you use for the id 
field.  by default, id is set to IntegerField 

 which 
has a maximum value of 2147483647 

sounds like the issue with the ids jumping around like that is with your 
management command, not django or the db.  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/2716221c-ccfa-4123-a2f4-f77724ee497a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Update data instead of creating a new row entry in django model

2018-08-26 Thread Jason
what you should do in your post check is 

   bill_item = BillItem.objects.get(code = itemcode)

form = BillItem(request.POST, instance = bill_item)


This populates the form with the existing model instance and merges with 
the post data.  you then can run form.save() to persist the update to the 
db. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/16d395cf-5c2e-4970-8899-b32b3884c2c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Documentation

2018-08-26 Thread Artur Gevorgyan
Hi to all.
In the documentation the whole examples are for machine that has only one 
python version installed. So I was trying for an hour to understand what 
I've done wrong with django instalation.
But the reason was I was typing `python` instead of `python3`. Please give 
some note about that.
I'm just starting to learn python. But I'm a senior JS developer.

-- 
You received this message because you are 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/889b613d-95b3-438b-834d-3b75b5eacb2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Documentation

2018-08-26 Thread Jason
basically, there's two versions of python: python 2 and 3.  They're 
incompatible with each other, though there's ways you can get py2 code to 
run in py3 (the inverse is not true).  Effectively, think of what ES6 would 
have been like if TC39 had the guts to make a backwards incompatible 
version of ECMAscript to clean up JS warts once and for all.

Thing is, lots of operating system functionality relies on python 2, so you 
can have two versions of python installed on your system, with the python3 
command pointing to v3.

Furthermore, you really should be using virtualenvs, which are effectively 
like smaller node_modules.  then doing python $COMMAND will point to your 
venv python symlink.

-- 
You received this message because you are 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/88150c65-d25c-4296-a03a-1e178a179de9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Documentation

2018-08-26 Thread Jason
Furthermore, the reason this isn't mentioned in the django docs is because 
its assumed the developer will have familiarity with python.  I would 
suggest you get comfortable with python and then learn a framework like 
django/flask.  Learning both at the same time can be done (I did it), but 
it would be like me learning JS by doing an Angular or React project, which 
would definitely not be the best approach.

-- 
You received this message because you are 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/171852a3-467a-4b51-9deb-28f74e5294e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Documentation

2018-08-26 Thread Artur Gevorgyan
Thank you in advanced)
I actually know about the two versions of python the differences,  and
about not compatibility.
So I've learned the main concerns in python and I just wanted to have a
overlook to django yet not in real project.
But the case I have mentioned was just for a non programmer a green
beginner as the documentation says that it is ok for beginner to start with
this. I understand that this is because of my machine. I've installed the
one this two
But maybe some guy with non experience will face the same issue on his
machine.
Thanks a lot. I love thus community, very fast interaction))

On Sun, 26 Aug 2018, 17:51 Jason,  wrote:

> Furthermore, the reason this isn't mentioned in the django docs is because
> its assumed the developer will have familiarity with python.  I would
> suggest you get comfortable with python and then learn a framework like
> django/flask.  Learning both at the same time can be done (I did it), but
> it would be like me learning JS by doing an Angular or React project, which
> would definitely not be the best approach.
>
> --
> You received this message because you are 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/171852a3-467a-4b51-9deb-28f74e5294e2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Andy
I want to execute a check after the related data from the admin has been 
saved, but the default clean methods get executed before the formsets are 
saved. Where could i place my check to have access to a full version of 
what has been changed on the admin page?

-- 
You received this message because you are 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/0623c315-eed4-407a-9166-7fc66910adeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Jason
why would you want to persist unvalidated data to your db?

On Sunday, August 26, 2018 at 10:42:28 AM UTC-4, Andy wrote:
>
> I want to execute a check after the related data from the admin has been 
> saved, but the default clean methods get executed before the formsets are 
> saved. Where could i place my check to have access to a full version of 
> what has been changed on the admin page?
>

-- 
You received this message because you are 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/02d9d1ae-9f17-4c16-8af6-88911f461442%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Andy


Am Sonntag, 26. August 2018 18:07:25 UTC+2 schrieb Jason:
>
> why would you want to persist unvalidated data to your db?
>
>>
>>
Well, i dont necessarily have to, but i somehow need to be able to perform 
a query with all updated data taken into account. The easiest solution i 
came up with is putting everything into the DB while in transaction so i 
could perform my queries and rollback if the checks dont work out. 

Im open to any other ideas.
And is there a prepared admin function that is suitable for validation 
logic after related objects are validated?
I might also just write some validation data to the parent while executing 
the formet validation and so i could verify my parent validation against 
this extra data even without additional queries against the DB.

So far i just see that the changeform_view handles object and formset 
validation without any way of interfering (other than rewriting that view 
logic).

-- 
You received this message because you are 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/2f46c2d4-a628-4571-8f23-9607125d462b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Jason
I think we're missing a few things.  how fast does this query with updated 
values execute after the form submits? if you need to return the value back 
to the view, can't you do some sort of post-save retrieval and form 
populate?

-- 
You received this message because you are 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/f7dc3c9f-3630-4ec8-96f0-ce28c14d7d29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-26 Thread Tosin Ayoola
good day guys I'm working on a project but currently I'm having
issues, which is I created a model to save some images files & I
created a template to display the images but the issue now is for loop
isn't displaying the files at the template

On 8/23/18, Tosin Ayoola  wrote:
> this is the link https://github.com/olaneat/ask_the_schools will rili b
> glad if u can help
>
>
> On Thu, Aug 23, 2018 at 2:31 PM Tosin Ayoola 
> wrote:
>
>> i have the code on git actually because i'm trying to get the add a file
>> at the admin page but i'm getting the error
>>
>>
>> On Thu, Aug 23, 2018 at 2:17 PM ireoluwa fakeye 
>> wrote:
>>
>>> Sorry didn't look at it well ,can I see a screen shot of your code
>>>
>>> On Thu, 23 Aug 2018, 14:10 Tosin Ayoola,  wrote:
>>>
 not properly routing my urls as in, i don't understand

 On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye 
 wrote:

> You Are not properly routing your  urls
>
> On Thu, 23 Aug 2018, 14:03 Tosin Ayoola, 
> wrote:
>
>> good day please i'm having issues, attached below is one of the error
>> i'm getting also ive been trying to add bootstrap glyphicon to my
>> project
>> but it just display the text without the glyphicon,
>>
>> On Fri, Aug 17, 2018 at 12:54 PM MikeKJ 
>> wrote:
>>
>>> I want to pass 2 variables to a templatetag from within a template,
>>> a
>>> name and a date (eg, John 29/09/2018) to output the result of the
>>> templatetag def.
>>>
>>> The reason I want to do this is:
>>>
>>> From a list of all names:
>>>
>>> The name comes from a model that has a foreign key to another model
>>> that has actions performed by that name by date and I want to output
>>> the
>>> action taken on that date so something like:
>>>
>>> from django import template
>>> from django.conf import settings
>>> from django.utils.html import escape
>>> from user.models import person
>>> from action.models import data
>>>
>>> def (get_action):
>>> action = Data.objects.get.filter(person=name).filter(date=date)
>>> return action
>>>
>>> but how do I pass the variables in the 1st place please?
>>>
>>>
>>> --
>>> You received this message because you are 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/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send
>> an email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To post to this group, send em

Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Andy


Am Sonntag, 26. August 2018 18:29:49 UTC+2 schrieb Jason:
>
> I think we're missing a few things.  how fast does this query with updated 
> values execute after the form submits? 
>

a neglectable amount of milliseconds
 

> if you need to return the value back to the view, can't you do some sort 
> of post-save retrieval and form populate?
>

No i dont want to return anything but a possible validation error based on 
all related objects new data. 
I probably see myself rewriting the changeform_view and manually adding the 
error the the forms non field errors, unless somebody comes up with a more 
clever idea.

-- 
You received this message because you are 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/1d2f8a9e-57f3-4d67-83b7-6f6f6a0cf9ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Jason
I still don't understand why you want to persist unvalidated data to the db 
then?  if a user requests the data in mid-update, that's something that can 
be handled with transaction locks on the db.  so when that happens, the 
request will wait till the locks are released before executing the db query

https://stackoverflow.com/questions/42520917/does-django-atomic-transaction-lock-the-database

-- 
You received this message because you are 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/d4044b1c-9ef8-4b17-99e3-67c8ea1d82ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to clean a model after the related models inline forms have been saved?

2018-08-26 Thread Andy
Please forget about the persisting data part. 
The problem is that inside the parent form i dont have access to the 
related data and the formsets new related data is validated after the 
parent models data.
Inside the formset every related data model does not have access to the 
other related instances.

I want to have additional validation after all data on the admin page has 
been processed .. not necessarily saved into the database, but i need some 
way of doing additional validation after the basic stuff has been taken 
care of by the admin and its form.



Am Sonntag, 26. August 2018 18:44:17 UTC+2 schrieb Jason:
>
> I still don't understand why you want to persist unvalidated data to the 
> db then?  if a user requests the data in mid-update, that's something that 
> can be handled with transaction locks on the db.  so when that happens, the 
> request will wait till the locks are released before executing the db query
>
>
> https://stackoverflow.com/questions/42520917/does-django-atomic-transaction-lock-the-database
>

-- 
You received this message because you are 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/6aa2f0c1-eb89-46fa-8b19-6d4a6927405b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.