Hey All,
I’m pretty fresh to Django/Anvil development. I have a site that I have working from an admin console that modifies my models and I was hoping to use Anvil to make the web UI side of it. Does anyone have a link that they can post to get me pointed in the right direction?
My apologies if this is a dumb question because it seems like it would but I can’t find anything about importing code into anvil.
Thank you!
Do you want to call the existing code from your Anvil UI (API style) or do you want to import everything into Anvil?
If it’s the former, you can either communicate as you would any other API (ie using something like the requests
library : https://anvil.works/doc/#http_module) or you could modify your existing code to be uplink
compatible (making the functions callable directly from Anvil code - https://anvil.works/doc/#uplink).
To import code (and I’m assuming you’re trying to avoid copy/pasting large amounts of code) you could use git. All anvil projects are essentially git repositories which you can pull locally, edit/add to/etc. then push back for editing/use in your Anvil IDE : https://anvil.works/doc/#version_history
If you let me know which one interests you the most I’ll try and help some more when I’m back at my desk tomorrow, assuming someone doesn’t beat me to it
I’m not sure that I know enough about Django/Python to give an informed opinion on what you’re asking. I’m doing this as a software engineering project for school that is a basic IT ticketing system. I came here because someone recommended this site for building the front end portion.
Here is a repo of what I have so far:
Thank you for all your help so far!
@Eagle2083 David will be a better source of information than me, but just to help nail down some specifics, I’ll try to provide a little guidance.
Is it safe to say that, in general, you are building a site for which Anvil could take care of some of the interactive UI functionality?
For example, your link led to these django tutorial docs that deal with a CRUD admin page (create, read, update, delete), seen here:
which leads to this:
If you are asking if Anvil could be used for this type of functionality, then yes, Anvil is fantastic for this type of thing.
If you have not already, I would suggest reading through the introductory Anvil tutorials, which includes relevant material such as: basic CRUD apps, DataTables (databases), Multi-User applications, and more. This should give you a sense of what you can use Anvil for in terms of building interactive applications.
The Admin page shown above reminded me of a CRUD app that was built purely in Anvil. It is somewhat more complex CRUD design, but it shows you where you can take things once you become more familiar with Anvil.
I know there are other things you may eventually have to consider (e.g., combining static sites with Anvil), but others here have done that and they will have good tips for you. Certainly you can display Anvil apps inside of an iframe.
I hope this can get you started at least.
Yeah I did the django tutorial from Mozilla to get familiar with making the admin site and the models. My admin site looks pretty much the same as that and it reads/writes just fine from what testing I’ve done so far.
I looked at a few of the tutorials and have a few ideas on what I want to do but didn’t see any obvious way that I could import my prebuilt models into it. Again I’m very new to Django and even newer to Anvil so I could be missing something incredibly obvious simply because of my ignorance on what best practices and procedures are.
I’ll read more on your suggestions. Thanks!
I’m not that familiar with Django and I may be misunderstanding your request, but would it be sufficient to export your models to CSV or another common format?
Then you could upload them into Anvil DataTables and begin to build the interactive UI with Anvil.
A quick google for “export django model to csv” turned up many results.
In terms of importing that data into Anvil DataTables, there is a post here that provides an example app and an alternative approach using the uplink service.
Apologies if I’m not understanding the main thrust of your question.
I may have misunderstood, too. I took the above to mean you had a working app (if only partially) and wanted to reuse the code.
I think reading your subsequent posts that you might do better to reproduce your app in Anvil rather than trying to shoehorn a Django app into Anvil (I am a little familiar with Django). The paradigms are slightly different.
Can you post a link to the tutorial you did, or even better, post what you want to build. We may be able to guide you a little more reliably that way.
This is the tutorial from Mozilla:
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Tutorial_local_library_website
I think I have already satisfied the requirements of my project (an IT ticketing system) and may only need to do a simple submit ticket page which I believe I can create on my own. My understanding of Anvil could be completely off base as well. I thought Anvil was a sort of Django front end framework that allowed people to create their templates and forms as well as the models if they weren’t already built/defined inside of their program.
I believe the requirements of my project will likely necessitate me keeping the Django functionality I have as my professor is expecting that type of a program. I was merely looking for a way to build out more and try to go beyond what was expected.
Not really. It is a complete, full stack development environment in its own right. It won’t produce Django compatible modules so it might not compliment your coursework on this occasion.
But do please consider Anvil for future projects. If you build the entire app in Anvil you will find that the combination of the front end designer, and the ability to run Python code front end and back, will enable you to produce lighting fast results which are robust and production quality.
I’m going to tag “Anvil Central” (@meredydd, @shaun and @daviesian) just in case they want to chip in (or correct me) on this topic.
I would add that Anvil can do all Django can do and more: it is impossible (as far as I know) to sign on some Django portal, write some code and get a website running in 30 seconds. Anvil allows you to get your finished app without setting up any server or database or templates or css.
Before any Django expert start a revolt, I would also add that Django is not worse than Anvil, it’s just different. There are many things that Django can do and Anvil can’t. But you said “basic IT ticketing system”, and I made one of those with Anvil without problems.
1 Like